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
| Parameter | Type | Required | Description |
|---|
user | PublicKey | Yes | Wallet withdrawing from the market |
trancheSide | TrancheSide | Yes | TrancheSide.Senior or TrancheSide.Junior |
lpAmountIn | bigint | Yes | Selected-tranche LP shares to burn, in raw LP units |
minBaseOut | bigint | No | Minimum base asset amount to receive, in raw base-token units. Defaults to 0n |
setupPayer | PublicKey | No | Payer for associated token account setup. Defaults to user |
tokenLpSrc | PublicKey | No | LP token source account. Defaults to the selected LP ATA |
tokenSyDst | PublicKey | No | Temporary/user SY destination account. Defaults to the user’s SY ATA |
tokenBaseDst | PublicKey | No | Base token destination account. Defaults to the user’s base ATA |
tokenProgram | PublicKey | No | SPL 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.