Skip to main content
The ixWithdraw instruction burns Senior or Junior LP shares and withdraws SY from the market. Use this when your integration wants SY output directly.

Usage

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

const ix = market.ixWithdraw({
  user: wallet.publicKey,
  trancheSide: TrancheSide.Senior,
  lpAmountIn: 500_000_000n, // raw Senior LP units to burn
  minAmountOut: 0n,         // raw SY units; set above 0 for output protection
  tokenLpSrc: userSeniorLpTokenAccount,
  tokenDst: userSyTokenAccount,
});

const tx = new Transaction().add(ix);
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
minAmountOutbigintNoMinimum SY amount to receive, in raw SY token units. Defaults to 0n
tokenLpSrcPublicKeyYesUser LP token source account
tokenDstPublicKeyYesUser SY destination account
tokenProgramPublicKeyNoSPL Token program

Behavior

The instruction:
  1. Syncs market NAV against the current SY exchange rate.
  2. Validates the selected tranche and lifecycle state.
  3. Calculates the SY claim for the burned LP shares.
  4. Burns LP shares and transfers SY to tokenDst.
A Junior withdrawal can fail with a coverage error if the post-withdraw utilization would exceed the allowed threshold.