A Solana RPC client for fetching accounts and pool data.
The mint address of the NFT that represents ownership of the position to be closed.
Optional
slippageToleranceBps: number = SLIPPAGE_TOLERANCE_BPSThe acceptable slippage tolerance in basis points.
Optional
authority: TransactionSigner = FUNDERThe account authorizing the transaction.
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}`);
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.