Documentation
    Preparing search index...

    Function harvestPositionInstructions

    • This function creates a set of instructions that collect any accumulated fees and rewards from a position. The liquidity remains in place, and the position stays open.

      Parameters

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

        A Solana RPC client used to interact with the blockchain.

      • positionMintAddress: Address

        The position mint address you want to harvest fees and rewards from.

      • Optionalauthority: TransactionSigner = FUNDER

        The account that authorizes the transaction. Defaults to a predefined funder.

      Returns Promise<HarvestPositionInstructions>

      A promise that resolves to an object containing the instructions, fees, and rewards quotes.

      import { harvestPositionInstructions, setWhirlpoolsConfig } from '@orca-so/whirlpools';
      import { createSolanaRpc, devnet, address } from '@solana/kit';
      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 { feesQuote, rewardsQuote, instructions } = await harvestPositionInstructions(
      devnetRpc,
      positionMint,
      wallet
      );

      console.log(`Fees owed token A: ${feesQuote.feeOwedA}`);
      console.log(`Rewards '1' owed: ${rewardsQuote.rewards[0].rewardsOwed}`);