Skip to main content
The ixWithdrawLiquidity method on the MarketThree class redeems LP tokens for PT and SY. You specify the LP position to withdraw from, the amount of LP to burn, and minimum outputs for slippage protection.
This is a low-level method that returns PT and SY tokens. To withdraw directly to a base asset (e.g., USDC), use ixWithdrawLiquidityToBase or ixWithdrawLiquidityClassic instead.

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 } = market.ixWithdrawLiquidity({
  withdrawer: wallet.publicKey,
  lpIn: 9_000_000_000n,           // LP tokens to burn
  lpPosition: lpPositionPublicKey, // from getUserLpPositions
  minPtOut: 4_000_000_000n,       // minimum PT to receive
  minSyOut: 4_000_000_000n,       // minimum SY to receive
});

const tx = new Transaction().add(...setupIxs, ...ixs);
await sendAndConfirmTransaction(connection, tx, [wallet]);

Required Parameters

ParameterTypeDescription
withdrawerPublicKeyThe withdrawer’s wallet public key
lpInbigintAmount of LP tokens to burn
lpPositionPublicKeyThe LP position account to withdraw from
minPtOutbigintMinimum amount of PT to receive
minSyOutbigintMinimum amount of SY to receive

Optional Parameters

ParameterTypeDescription
ptDstPublicKeyDestination PT token account. Defaults to withdrawer’s ATA
syDstPublicKeyDestination SY token account. Defaults to withdrawer’s ATA

Returns

Returns an object with:
{
  ixs: TransactionInstruction[],      // Main withdrawal instruction
  setupIxs: TransactionInstruction[]  // Setup instructions for creating PT and SY ATAs
}