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
| Parameter | Type | Description |
|---|
owner | PublicKey | The depositor’s wallet public key |
withdrawalAccount | PublicKey | The withdrawal account address returned from queueWithdrawal |
tokenAccountPairs | TokenAccountPair[] | Array of { tokenSrc, tokenDst } pairs — one per vault token entry |
TokenAccountPair
| Field | Type | Description |
|---|
tokenSrc | PublicKey | The vault’s token entry escrow (source) |
tokenDst | PublicKey | The depositor’s token account (destination) |
Optional Parameters
| Parameter | Type | Description |
|---|
tokenProgram | PublicKey | Token program. Defaults to TOKEN_PROGRAM_ID |
tokenLpEscrow | PublicKey | LP token escrow. Defaults to the vault’s LP escrow PDA |
mintLp | PublicKey | LP 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);