vaultWithdraw
Request a withdrawal from the Zyfai Vault. Withdrawals are asynchronous — after requesting, you must wait for processing and then claim.
Signature
vaultWithdraw(
shares?: string,
chainId?: SupportedChainId
): Promise<VaultWithdrawResponse>
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
shares | string | ❌ | Amount of shares to redeem (defaults to all shares if not provided) |
chainId | SupportedChainId | ❌ | Chain ID (default: 8453 - Base) |
Returns
Withdraw request result with a withdrawKey for tracking
Return Type
interface VaultWithdrawResponse {
success: boolean;
txHash: string;
withdrawKey: string;
status: "claimable" | "pending";
}
Example
// Request withdrawal of all shares
const result = await sdk.vaultWithdraw();
console.log("Withdraw key:", result.withdrawKey);
console.log("Status:", result.status);
// If already claimable, claim immediately
if (result.status === "claimable") {
const claim = await sdk.vaultClaim(result.withdrawKey);
console.log("Claimed:", claim.txHash);
}
Partial Withdrawal
// Check your shares balance first
const shares = await sdk.getVaultShares();
console.log("Shares balance:", shares.shares);
// Withdraw specific amount of shares
const result = await sdk.vaultWithdraw("4994744"); // 4994744 shares
console.log("Withdraw key:", result.withdrawKey);
Withdrawal Flow
1. vaultWithdraw() → Request withdrawal, get withdrawKey
2. Wait for processing → Check status in response
3. vaultClaim() → Claim your USDC when ready
How It Works
- Gets max redeemable: If no shares specified, retrieves your maximum redeemable amount
- Requests redeem: Calls
requestRedeemon the vault contract - Gets withdraw key: Returns a unique key to track and claim this withdrawal
- Checks status: Returns whether the withdrawal is immediately claimable or pending
Notes
- Wallet must be connected via
connectAccount()before calling - Withdrawals are not instant — there may be a processing period
- Save the
withdrawKeyto claim your funds later - Use vaultClaim to claim your USDC when the status is claimable