The Solana RPC client used to fetch token accounts and multiple accounts.
The wallet address whose positions you want to fetch.
OptionalwhirlpoolDeployment: WhirlpoolDeployment = DEFAULT_WHIRLPOOL_DEPLOYMENTThe whirlpool program and config to query against. Defaults to DEFAULT_WHIRLPOOL_DEPLOYMENT.
import { fetchPositionsForOwner, WhirlpoolDeployment } from '@orca-so/whirlpools';
import { generateKeyPairSigner, createSolanaRpc, devnet } from '@solana/kit';
const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
const wallet = address("INSERT_WALLET_ADDRESS");
const positions = await fetchPositionsForOwner(devnetRpc, wallet, WhirlpoolDeployment.devnet);
Fetches all positions owned by a given wallet in the Orca Whirlpools. It looks for token accounts owned by the wallet using both the TOKEN_PROGRAM_ADDRESS and TOKEN_2022_PROGRAM_ADDRESS. For token accounts holding exactly 1 token (indicating a position or bundle), it fetches the corresponding position addresses, decodes the accounts, and returns an array of position or bundle data.