The ixQueueWithdrawal method builds a transaction instruction that moves LP tokens into escrow and creates a withdrawal account — the first step in the two-phase withdrawal process.
Usage
import { ExponentVault } from "@exponent-labs/exponent-sdk";
import { Connection, Transaction, sendAndConfirmTransaction } from "@solana/web3.js";
const connection = new Connection("https://api.mainnet-beta.solana.com");
const vault = await ExponentVault.load({ connection, address: vaultAddress });
const { ix, withdrawalKeypair } = vault.ixQueueWithdrawal({
depositor: wallet.publicKey,
lpAmount: 500_000_000n,
});
// The withdrawalKeypair must be included as a signer
const tx = new Transaction().add(ix);
await sendAndConfirmTransaction(connection, tx, [wallet, withdrawalKeypair]);
// Save this address — you'll need it to execute the withdrawal
const withdrawalAddress = withdrawalKeypair.publicKey;
Required Parameters
| Parameter | Type | Description |
|---|
depositor | PublicKey | The depositor’s wallet public key |
lpAmount | bigint | number | Amount of LP tokens to lock for withdrawal |
Optional Parameters
| Parameter | Type | Description |
|---|
tokenLpSrc | PublicKey | Source LP token account. Defaults to the depositor’s ATA for the LP mint |
tokenLpEscrow | PublicKey | LP token escrow PDA. Defaults to the vault’s LP escrow |
tokenProgram | PublicKey | Token program. Defaults to TOKEN_PROGRAM_ID |
systemProgram | PublicKey | System program. Defaults to SystemProgram.programId |
Returns
Returns { ix: TransactionInstruction, withdrawalKeypair: Keypair }.
ix — the instruction that creates the withdrawal account and moves LP tokens to escrow
withdrawalKeypair — a freshly generated keypair whose public key is the withdrawal account address. Must be passed as a signer in the transaction.
Next Step
After queuing, the vault manager calls fillWithdrawal to associate the underlying token accounts with your request. Once filled, call executeWithdrawal.
Save the withdrawalKeypair.publicKey — you need it when calling executeWithdrawal. If lost, you can recover it by querying withdrawal accounts for your vault via RPC.