A Solana RPC client used to interact with the blockchain.
The position mint address you want to harvest fees and rewards from.
Optionalconfig: HarvestPositionConfig = {}The parameters to build the harvest position instruction.
import { harvestPositionInstructions, WhirlpoolDeployment } from '@orca-so/whirlpools';
import { createSolanaRpc, devnet, address } from '@solana/kit';
import { loadWallet } from './utils';
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,
{
authority: wallet,
whirlpoolDeployment: WhirlpoolDeployment.devnet,
}
);
console.log(`Fees owed token A: ${feesQuote.feeOwedA}`);
console.log(`Rewards '1' owed: ${rewardsQuote.rewards[0].rewardsOwed}`);
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.