Skip to main content

createQueueWithdrawalInstruction

Builds a raw instruction to queue a withdrawal from a Strategy Vault. The depositor’s LP tokens are locked in escrow and a withdrawal account is created to track the request. The withdrawal must later be filled by the vault manager and then executed to receive underlying tokens. Called by depositors who want to withdraw from the vault.

Usage

import { createQueueWithdrawalInstruction } from "@exponent-labs/exponent-sdk/client/vaults";
import { Keypair, PublicKey } from "@solana/web3.js";

const withdrawalAccountKeypair = Keypair.generate();

const ix = createQueueWithdrawalInstruction(
  {
    depositor: wallet.publicKey,
    vault: vaultAddress,
    exponentPrices: exponentPricesPda,
    withdrawalAccount: withdrawalAccountKeypair.publicKey,
    tokenLpSrc: depositorLpTokenAccount,
    tokenLpEscrow: vaultLpEscrowAccount,
    tokenProgram: TOKEN_PROGRAM_ID,
    systemProgram: SYSTEM_PROGRAM_ID,
  },
  {
    lpAmount: BigInt(500_000),
    withdrawalType: { token: {} },
  }
);

Accounts

NameSignerWritableDescription
depositorYesYesThe user queuing the withdrawal
vaultNoYesThe Strategy Vault account
exponentPricesNoNoGlobal ExponentPrices account for AUM calculations
withdrawalAccountYesYesNew withdrawal request account (keypair signer)
tokenLpSrcNoYesDepositor’s LP token account (source)
tokenLpEscrowNoYesVault’s LP token escrow account
tokenProgramNoNoSPL Token program
systemProgramNoNoSystem program

Args

NameTypeDescription
lpAmountbigintAmount of LP tokens to queue for withdrawal (u64)
withdrawalTypeWithdrawalTypeType of withdrawal: { sol: {} } or { token: {} }

Returns

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