• 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.

    Parameters

    • rpc: Rpc<GetTokenAccountsByOwnerApi & GetMultipleAccountsApi>

      The Solana RPC client used to fetch token accounts and multiple accounts.

    • owner: Address

      The wallet address whose positions you want to fetch.

    Returns Promise<PositionData[]>

    • A promise that resolves to an array of decoded position data for the given owner.
    import { fetchPositionsForOwner } from '@orca-so/whirlpools';
    import { generateKeyPairSigner, createSolanaRpc, devnet } from '@solana/web3.js';

    const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
    const wallet = address("INSERT_WALLET_ADDRESS");

    const positions = await fetchPositionsForOwner(devnetRpc, wallet.address);