Skip to main content
The ixWithdrawLiquidityClassic method on the MarketThree class withdraws liquidity from the CLMM pool. Unlike ixWithdrawLiquidityToBase which converts everything to base assets, this method returns the PT and SY components separately — the SY portion is redeemed for base, while PT tokens are returned directly to the withdrawer.

Usage

import { MarketThree, LOCAL_ENV } from "@exponent-labs/exponent-sdk";
import { Connection, PublicKey, Transaction, sendAndConfirmTransaction } from "@solana/web3.js";

const connection = new Connection("https://api.mainnet-beta.solana.com");
const market = await MarketThree.load(LOCAL_ENV, connection, marketAddress);

const { ixs, setupIxs } = await market.ixWithdrawLiquidityClassic({
  owner: wallet.publicKey,
  amountLp: 9_000_000_000n,
  lpPosition: lpPositionPublicKey,
});

const tx = new Transaction().add(...setupIxs, ...ixs);
const signature = await sendAndConfirmTransaction(connection, tx, [wallet]);
Use market.getPtAndSyOnWithdrawLiquidity(position) to preview the PT and SY amounts you would receive before withdrawing.

Required Parameters

ParameterTypeDescription
ownerPublicKeyThe owner’s wallet public key
amountLpbigintAmount of LP tokens to withdraw
lpPositionPublicKeyPublic key of the LP position account

Optional Parameters

ParameterTypeDescription
tokenSyWithdrawerPublicKeyIntermediate SY token account. Defaults to owner’s ATA
tokenYtWithdrawerPublicKeyIntermediate YT token account. Defaults to owner’s ATA
tokenPtWithdrawerPublicKeyDestination PT token account. Defaults to owner’s ATA
tokenBaseWithdrawerPublicKeyDestination base token account. Defaults to owner’s ATA

Returns

Returns a Promise<PreparedInstruction> with the following structure:
{
  ixs: TransactionInstruction[],      // Main instructions to execute
  setupIxs: TransactionInstruction[]  // Setup instructions for creating ATAs
}