Position Management
The Fusion AMM SDK provides tools to manage concentrated liquidity positions in a FusionPool. Developers can open, close, increase, or decrease liquidity for positions using intuitive SDK methods, as well as fetch Positions by the owner.
Open Position: creates a new position and optionally adds liquidity if specified (e.g., via token amounts). See
openPositionInstructions
,increaseLiquidityInstructions
functions of the high-level SDK package.Close Position: removes all liquidity from a position, collects any accrued fees and then closes the position. See
closePositionInstructions
,decreaseLiquidityInstructions
functions of the high-level SDK package.Fetch Positions: fetches multiple positions according to input parameters. See
fetchPositionsForOwner
function of the high-level SDK package.
Additionally, liquidity can be increased or decreased independently without opening or closing a position, offering flexible position management.
Examples:
1. Open Position
import { openPositionInstructions, SLIPPAGE_TOLERANCE_BPS }
from "@crypticdot/fusionamm-sdk";
import { sendTransaction } from "@crypticdot/fusionamm-tx-sender";
import { address, createSolanaRpc } from "@solana/kit";
export const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
export const signer = await loadKeypair(); // Load your wallet
// SOL/USDC pool address
let = address("7VuKeevbvbQQcxz6N4SNLmuq6PYy4AcGQRDssoqo4t65");
const open = await openPositionInstructions(
rpc,
poolAddress,
{ tokenA: 1_000_000_000n },
{ price: 100.0 },
{ price: 120.0 },
SLIPPAGE_TOLERANCE_BPS,
signer,
);
const signature = await sendTransaction(rpc, open.instructions, signer);
console.log("Transaction ID:", signature);
console.log("Position mint:", open.positionMint);
2. Close Position
import { closePositionInstructions, SLIPPAGE_TOLERANCE_BPS }
from "@crypticdot/fusionamm-sdk";
import { sendTransaction } from "@crypticdot/fusionamm-tx-sender";
import { address, createSolanaRpc } from "@solana/kit";
export const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
export const signer = await loadKeypair(); // Load your wallet
let positionMintAddress =
address("HqoV7Qv27REUtmd9UKSJGGmCRNx3531t33bDG1BUfo9K");
const open = await closePositionInstructions(
rpc,
positionMint,
SLIPPAGE_TOLERANCE_BPS,
signer
);
const signature = await sendTransaction(rpc, open.instructions, signer);
console.log("Transaction ID:", signature);
Last updated