pub async fn fetch_positions_in_whirlpool(
    rpc: &RpcClient,
    whirlpool: Pubkey,
) -> Result<Vec<DecodedAccount<Position>>, Box<dyn Error>>
Expand description

Fetches all positions associated with a specific Whirlpool.

This function retrieves all positions linked to the given Whirlpool address using program filters. The positions are decoded and returned as a vector of hydrated position objects.

§Arguments

  • rpc - A reference to the Solana RPC client.
  • whirlpool - The public key of the Whirlpool whose positions should be fetched.

§Returns

A Result containing a vector of DecodedAccount<Position> objects, representing the positions associated with the given Whirlpool.

§Errors

This function will return an error if:

  • RPC calls fail while fetching filtered accounts.
  • Decoding the position data fails.

§Example

use solana_client::rpc_client::RpcClient;
use solana_sdk::pubkey::Pubkey;
use orca_whirlpools::fetch_positions_in_whirlpool;
use std::str::FromStr;

let rpc = RpcClient::new("https://api.devnet.solana.com");
let whirlpool = Pubkey::from_str("WHIRLPOOL_PUBLIC_KEY").unwrap();

let positions = fetch_positions_in_whirlpool(&rpc, whirlpool).unwrap();
println!("{:?}", positions);