Skip to main content

API Reference Overview

The Zyfai Vault API provides methods for depositing, withdrawing, and managing shares in the Zyfai Vault on Base. The vault is a shared yield-generating pool where users deposit USDC and receive vault shares. The vault is redirecting the deposited assets to one globally shared safe subaccount for automated yield optimization. Full architecture documentation

API Organization

The Vault API methods are organized by operation type.

Deposits

Deposit assets into the vault.

MethodDescription
vaultDepositDeposit USDC into the vault, receive shares

Withdrawals

Request and claim withdrawals from the vault.

MethodDescription
vaultWithdrawRequest withdrawal of shares
vaultClaimClaim completed withdrawal

Shares

Check your vault share balance.

MethodDescription
getVaultSharesGet share balance and symbol

Common Patterns

Authentication Required

Vault methods require wallet connection via connectAccount():

await sdk.connectAccount(walletClient, 8453); // Base only

// Now vault methods work
const deposit = await sdk.vaultDeposit("100", "USDC");

Chain Support

The Vault is currently only available on Base (chain ID 8453).

// Vault only works on Base
await sdk.connectAccount(walletClient, 8453);

Amount Formatting

Unlike Smart Wallet methods, vault deposit amounts are in human readable format:

// Vault: human readable (100 USDC)
await sdk.vaultDeposit("100", "USDC");

// Smart Wallet: least decimal units (100 * 10^6)
await sdk.depositFunds(userAddress, chainId, "100000000");

Withdrawal Flow

Vault withdrawals are asynchronous and require two steps:

// Step 1: Request withdrawal
const withdraw = await sdk.vaultWithdraw();
console.log("Withdraw key:", withdraw.withdrawKey);

// Step 2: Claim when ready
if (withdraw.status === "claimable") {
const claim = await sdk.vaultClaim(withdraw.withdrawKey);
console.log("Claimed:", claim.txHash);
}

Type Safety

The SDK is fully typed with TypeScript. Import types as needed:

import type {
VaultDepositResponse,
VaultWithdrawResponse,
VaultClaimResponse,
VaultSharesResponse,
} from "@zyfai/sdk";

Response Format

All Vault methods return consistent response objects:

{
success: boolean; // Operation success status
// ... method-specific data
}

Support