vaultDeposit
Deposit assets into the Zyfai Vault. Currently only supports USDC on Base chain.
Vault vs Safe SubAccount
The Vault is different from the Safe subaccount. The Vault is a shared contract where users deposit assets and receive shares. The Safe is a personal smart wallet for automated yield optimization. The vault is redirecting the deposited assets to one globally shared safe subaccount for automated yield optimization. Full architecture documentation
Signature
vaultDeposit(
amount: string,
asset?: VaultAsset,
chainId?: SupportedChainId
): Promise<VaultDepositResponse>
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
amount | string | ✅ | Amount to deposit in human readable format (e.g., "100" for 100 USDC) |
asset | VaultAsset | ❌ | Asset to deposit (default: "USDC") |
chainId | SupportedChainId | ❌ | Chain ID (default: 8453 - Base) |
Returns
Deposit transaction result with transaction hash
Return Type
interface VaultDepositResponse {
success: boolean;
txHash: string;
amount: string;
asset: string;
vaultAddress: string;
}
Example
// Connect wallet first
await sdk.connectAccount(walletClient, 8453);
// Deposit 100 USDC into the vault
const result = await sdk.vaultDeposit("100", "USDC");
console.log("Deposited:", result.txHash);
console.log("Vault address:", result.vaultAddress);
How It Works
- Checks allowance: Verifies if the vault has permission to spend your USDC
- Approves if needed: If allowance is insufficient, sends an approval transaction
- Deposits: Transfers USDC to the vault and mints shares to your wallet
- Waits for confirmation: Returns after the transaction is confirmed
Notes
- Wallet must be connected via
connectAccount()before calling - The amount is in human readable format (not wei/smallest units)
- You receive vault shares in return, representing your stake in the vault
- Use getVaultShares to check your share balance
- To withdraw, use vaultWithdraw