A Solana RPC client used to interact with the blockchain.
The position mint address you want to harvest fees and rewards from.
Optional
authority: TransactionSigner = FUNDERThe account that authorizes the transaction. Defaults to a predefined funder.
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/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 { 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}`);
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.