clmm-common 0.1.39

Blockchain, Clmm for Solana
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use solana_client::rpc_client::RpcClient;
use solana_program::program_pack::Pack;
use solana_program::pubkey::Pubkey;
use spl_token::ui_amount_to_amount;

pub fn get_decimals(rpc_client: &RpcClient, pubkey: &Pubkey) -> u8 {
    spl_token::state::Mint::unpack(rpc_client.get_account(pubkey).unwrap().data.as_slice()).unwrap().decimals
}


pub fn get_lamport(rpc_client: &RpcClient, pubkey: &Pubkey, token_amount: f64) -> u64 {
    ui_amount_to_amount(token_amount, get_decimals(rpc_client, pubkey))
}