Skip to main content
The ixWrapperWithdraw instruction burns tranche LP shares, withdraws SY from the market, and redeems SY back to the base asset.

Usage

import { Transaction, sendAndConfirmTransaction } from "@solana/web3.js";
import { TrancheSide } from "@exponent-labs/exponent-sdk/client/tranching";

const { ixs, setupIxs } = await market.ixWrapperWithdraw({
  user: wallet.publicKey,
  trancheSide: TrancheSide.Senior,
  lpAmountIn: 500_000_000n, // raw Senior LP units to burn
  minBaseOut: 0n,           // raw base-token units; set above 0 for output protection
});

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

Parameters

ParameterTypeRequiredDescription
userPublicKeyYesWallet withdrawing from the market
trancheSideTrancheSideYesTrancheSide.Senior or TrancheSide.Junior
lpAmountInbigintYesSelected-tranche LP shares to burn, in raw LP units
minBaseOutbigintNoMinimum base asset amount to receive, in raw base-token units. Defaults to 0n
setupPayerPublicKeyNoPayer for associated token account setup. Defaults to user
tokenLpSrcPublicKeyNoLP token source account. Defaults to the selected LP ATA
tokenSyDstPublicKeyNoTemporary/user SY destination account. Defaults to the user’s SY ATA
tokenBaseDstPublicKeyNoBase token destination account. Defaults to the user’s base ATA
tokenProgramPublicKeyNoSPL Token program for SY and LP token accounts

Returns

Returns an object with:
  • ixs - Instructions that perform tranche withdrawal, SY redemption, and flavor-specific pre/post steps
  • setupIxs - Associated token account setup instructions for LP, SY, and base token accounts
Senior withdrawals are only allowed while the market is Active. Junior withdrawals can run during Active or FixedTermRecovery, but cannot reduce coverage beyond the market’s allowed utilization.