raydium-sdk 0.1.1

raydium sdk
Documentation

Example

create Raydium object

let rpc = RpcClient::new("rpc url");
let raydium = Raydium::new(Arc::new(rpc));

get the data of the V4 liquidity pool of the specified address

let rpc = RpcClient::new("rpc url");
let raydium = Raydium::new(Arc::new(rpc));
// 58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2 SOL-USDC pool
let pool_data = raydium.get_liquidity_pool_v4("58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2");

parsing the data structure of the Liquidity v4 pool

let address: &str = "public key";
match Pubkey::from_str(address) {
    Ok(pool_address) => match self.client.get_account_data(&pool_address).await {
        Ok(v) => match RaydiumLiquidityPoolV4::get_liquidity_pool_info(&v) {
            Ok(pool) => return Ok(pool.clone()),
            Err(e) => return Err(e),
        },
        Err(e) => Err(format!("{:?}", e)),
    },
    Err(e) => {
        return Err(format!("{:?}", e));
    }
}