Skip to main content

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

ParameterTypeRequiredDescription
sharesstringAmount of shares to redeem (defaults to all shares if not provided)
chainIdSupportedChainIdChain 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

  1. Gets max redeemable: If no shares specified, retrieves your maximum redeemable amount
  2. Requests redeem: Calls requestRedeem on the vault contract
  3. Gets withdraw key: Returns a unique key to track and claim this withdrawal
  4. 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 withdrawKey to claim your funds later
  • Use vaultClaim to claim your USDC when the status is claimable