Skip to main content

createWrapperWithdrawLiquidityClassicInstruction

Withdraws liquidity from a CLMM market and returns PT tokens and base assets separately. This instruction removes the LP position, returns the PT component directly to the withdrawer, and redeems the SY portion for the underlying base asset. This is useful when the caller wants to retain their PT tokens rather than selling them.

Usage

import { createWrapperWithdrawLiquidityClassicInstruction } from "@exponent-labs/exponent-sdk/client/clmm";
import { PublicKey, SystemProgram } from "@solana/web3.js";

const ix = createWrapperWithdrawLiquidityClassicInstruction({
  withdrawer: withdrawerKeypair.publicKey,
  market: new PublicKey("market..."),
  ticks: new PublicKey("ticks..."),
  tokenPtEscrow: new PublicKey("tokenPtEscrow..."),
  tokenSyEscrow: new PublicKey("tokenSyEscrow..."),
  tokenSyWithdrawer: new PublicKey("tokenSyWithdrawer..."),
  tokenPtWithdrawer: new PublicKey("tokenPtWithdrawer..."),
  tokenProgram: new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),
  marketAddressLookupTable: new PublicKey("lookupTable..."),
  syProgram: new PublicKey("syProgram..."),
  lpPosition: new PublicKey("lpPosition..."),
  systemProgram: SystemProgram.programId,
  eventAuthority: new PublicKey("eventAuthority..."),
  program: new PublicKey("program..."),
  amountLp: 1_000_000n,
  redeemSyAccountsLength: 3,
});

Accounts

NameTypeSignerWritableDescription
withdrawerPublicKeyYesYesWallet withdrawing liquidity
marketPublicKeyNoYesThe CLMM market account
ticksPublicKeyNoYesThe market tick array account
tokenPtEscrowPublicKeyNoYesMarket PT escrow account
tokenSyEscrowPublicKeyNoYesMarket SY escrow account
tokenSyWithdrawerPublicKeyNoYesWithdrawer’s SY token account
tokenPtWithdrawerPublicKeyNoYesWithdrawer’s PT token account
tokenProgramPublicKeyNoNoSPL Token program
marketAddressLookupTablePublicKeyNoNoMarket address lookup table
syProgramPublicKeyNoNoSY program
lpPositionPublicKeyNoYesLP position account
systemProgramPublicKeyNoNoSystem program
eventAuthorityPublicKeyNoNoEvent authority PDA
programPublicKeyNoNoCLMM program ID

Args

NameTypeDescription
amountLpu64The amount of LP tokens to withdraw
redeemSyAccountsLengthu8The number of CPI remaining accounts used for SY redemption

Returns

TransactionInstruction — a transaction instruction ready to be added to a transaction.