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
| 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 |
minAmountOut | bigint | No | Minimum SY amount to receive, in raw SY token units. Defaults to 0n |
tokenLpSrc | PublicKey | Yes | User LP token source account |
tokenDst | PublicKey | Yes | User SY destination account |
tokenProgram | PublicKey | No | SPL Token program |
Behavior
The instruction:
- Syncs market NAV against the current SY exchange rate.
- Validates the selected tranche and lifecycle state.
- Calculates the SY claim for the burned LP shares.
- 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.