Skip to main content

createWithdrawInstruction

Builds a raw instruction that burns Senior or Junior LP shares and withdraws SY.

Usage

import {
  TrancheSide,
  createWithdrawInstruction,
} from "@exponent-labs/exponent-sdk/client/tranching";

const ix = createWithdrawInstruction(
  {
    user: wallet.publicKey,
    market: marketAddress,
    returnModelStorage,
    addressLookupTable,
    syProgram,
    syMint,
    tokenLpSrc: userLpTokenAccount,
    tokenSyEscrow,
    tokenDst: userSyTokenAccount,
    mintLp: mintLpSenior,
    tokenProgram,
    eventAuthority,
    program: tranchingProgram,
  },
  {
    trancheSide: TrancheSide.Senior,
    lpAmountIn: 500_000_000n, // raw Senior LP units to burn
    minAmountOut: 0n,         // raw SY units
  }
);

Accounts

NameTypeSignerWritableDescription
userPublicKeyYesYesWithdrawer
marketPublicKeyNoYesTranching market account
returnModelStoragePublicKeyNoYesReturn model storage account
addressLookupTablePublicKeyNoNoMarket address lookup table
syProgramPublicKeyNoNoLinked SY program
syMintPublicKeyNoYesSY mint
tokenLpSrcPublicKeyNoYesUser LP source account
tokenSyEscrowPublicKeyNoYesMarket SY escrow
tokenDstPublicKeyNoYesUser SY destination account
mintLpPublicKeyNoYesSenior or Junior LP mint
tokenProgramPublicKeyNoNoSPL Token program
eventAuthorityPublicKeyNoNoEvent authority PDA
programPublicKeyNoNoExponent Tranching program

Args

NameTypeDescription
trancheSideTrancheSideSenior or Junior
lpAmountInu64Selected-tranche LP shares to burn, in raw LP units
minAmountOutu64Minimum SY amount to receive, in raw SY token units

Remaining accounts

Append the market’s getSyState and withdrawSy CPI remaining accounts after the generated keys.

Returns

TransactionInstruction - a transaction instruction ready to be added to a transaction.