Skip to main content
The ixExecuteWithdrawal method builds a transaction instruction that transfers the underlying tokens to the depositor. This is the final step of the withdrawal process — LP tokens are burned during the manager’s fillWithdrawal step.

Usage

import { ExponentVault } from "@exponent-labs/exponent-sdk";
import { Connection, PublicKey, Transaction, sendAndConfirmTransaction } from "@solana/web3.js";
import { getAssociatedTokenAddressSync } from "@solana/spl-token";
import { ExponentVaultsPDA } from "@exponent-labs/exponent-vaults-pda";

const connection = new Connection("https://api.mainnet-beta.solana.com");
const vault = await ExponentVault.load({ connection, address: vaultAddress });

// Build token account pairs — one per token entry in the vault
const pda = new ExponentVaultsPDA();
const tokenAccountPairs = vault.state.tokenEntries.map((entry) => ({
  tokenSrc: pda.tokenEntryEscrow({
    vault: vaultAddress,
    mint: entry.mint,
  })[0],
  tokenDst: getAssociatedTokenAddressSync(entry.mint, wallet.publicKey),
}));

// Use the withdrawal address saved from queueWithdrawal
const ix = vault.ixExecuteWithdrawal({
  owner: wallet.publicKey,
  withdrawalAccount: withdrawalAddress,
  tokenAccountPairs,
});

const tx = new Transaction().add(ix);
await sendAndConfirmTransaction(connection, tx, [wallet]);

Required Parameters

ParameterTypeDescription
ownerPublicKeyThe depositor’s wallet public key
withdrawalAccountPublicKeyThe withdrawal account address returned from queueWithdrawal
tokenAccountPairsTokenAccountPair[]Array of { tokenSrc, tokenDst } pairs — one per vault token entry

TokenAccountPair

FieldTypeDescription
tokenSrcPublicKeyThe vault’s token entry escrow (source)
tokenDstPublicKeyThe depositor’s token account (destination)

Optional Parameters

ParameterTypeDescription
tokenProgramPublicKeyToken program. Defaults to TOKEN_PROGRAM_ID
tokenLpEscrowPublicKeyLP token escrow. Defaults to the vault’s LP escrow PDA
mintLpPublicKeyLP mint. Defaults to the vault’s LP mint PDA

Returns

Returns a TransactionInstruction that burns LP tokens from escrow and transfers underlying tokens to the depositor.
executeWithdrawal will fail if the vault manager has not yet called fillWithdrawal for your withdrawal request. Check that the withdrawal account has been filled before calling this instruction.

Checking Withdrawal Status

To check if a withdrawal has been filled, fetch the withdrawal account by its address:
const withdrawalAccount = await vault.fetchWithdrawalAccount(withdrawalAddress);

// The withdrawal is ready to execute when fills are present
console.log("fills:", withdrawalAccount?.fills);