• Generates instructions to close a liquidity position in an Orca Whirlpool. This includes collecting all fees, rewards, removing any remaining liquidity, and closing the position.

    Parameters

    • rpc: Rpc<
          GetAccountInfoApi & GetMultipleAccountsApi & GetMinimumBalanceForRentExemptionApi & GetEpochInfoApi,
      >

      A Solana RPC client for fetching accounts and pool data.

    • positionMintAddress: Address

      The mint address of the NFT that represents ownership of the position to be closed.

    • OptionalslippageToleranceBps: number = SLIPPAGE_TOLERANCE_BPS

      The acceptable slippage tolerance in basis points.

    • Optionalauthority: TransactionSigner = FUNDER

      The account authorizing the transaction.

    Returns Promise<ClosePositionInstructions>

    A promise resolving to an object containing instructions, fees quote, rewards quote, and the liquidity quote for the closed position.

    import { closePositionInstructions, setWhirlpoolsConfig } from '@orca-so/whirlpools';
    import { createSolanaRpc, devnet, address } from '@solana/web3.js';
    import { loadWallet } from './utils';

    await setWhirlpoolsConfig('solanaDevnet');
    const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
    const wallet = await loadWallet();
    const positionMint = address("HqoV7Qv27REUtmd9UKSJGGmCRNx3531t33bDG1BUfo9K");

    const { instructions, quote, feesQuote, rewardsQuote } = await closePositionInstructions(
    devnetRpc,
    positionMint,
    100,
    wallet
    );

    console.log(`Quote token max B: ${quote.tokenEstB}`);
    console.log(`Fees owed token A: ${feesQuote.feeOwedA}`);
    console.log(`Rewards '1' owed: ${rewardsQuote.rewards[0].rewardsOwed}`);
    console.log(`Number of instructions:, ${instructions.length}`);