pub async fn fetch_concentrated_liquidity_pool(
rpc: &RpcClient,
token_1: Pubkey,
token_2: Pubkey,
tick_spacing: u16,
) -> Result<PoolInfo, Box<dyn Error>>
Expand description
Fetches the details of a specific Concentrated Liquidity Pool.
This function retrieves information about a pool for the specified tick spacing. It determines whether the pool is initialized or not and returns the corresponding details.
§Arguments
rpc
- A reference to the Solana RPC client.token_1
- The public key of the first token mint in the pool.token_2
- The public key of the second token mint in the pool.tick_spacing
- The tick spacing of the pool.
§Returns
A Result
containing PoolInfo
:
PoolInfo::Initialized
if the pool is initialized, including the pool’s state and price.PoolInfo::Uninitialized
if the pool is not yet initialized, including configuration details.
§Errors
This function will return an error if:
- Any required account or mint information cannot be fetched.
- The pool or its configuration details are invalid.
§Example
use solana_client::rpc_client::RpcClient;
use solana_sdk::pubkey::Pubkey;
use orca_whirlpools::{fetch_concentrated_liquidity_pool, PoolInfo, set_whirlpools_config_address, WhirlpoolsConfigInput};
use std::str::FromStr;
set_whirlpools_config_address(WhirlpoolsConfigInput::SolanaDevnet).unwrap();
let rpc = RpcClient::new("https://api.devnet.solana.com");
let token_1 = Pubkey::from_str("TOKEN_MINT_ONE").unwrap();
let token_2 = Pubkey::from_str("TOKEN_MINT_TWO").unwrap();
let tick_spacing = 64;
let pool_info = fetch_concentrated_liquidity_pool(&rpc, token_1, token_2, tick_spacing).unwrap();
match pool_info {
PoolInfo::Initialized(pool) => println!("Pool is initialized: {:?}", pool),
PoolInfo::Uninitialized(pool) => println!("Pool is not initialized: {:?}", pool),
}