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));
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));
}
}
get the current liquidity pool price
let rpc = RpcClient::new("".to_string());
let ray = Raydium::new(Arc::new(rpc));
let pool_data = ray.get_liquidity_pool_v4(pool_address).await.unwrap();
let price = pool_data.get_price(Arc::clone(&ray.client)).await;