Skip to main content
The Zyfai SDK provides a comprehensive TypeScript API for integrating DeFi yield optimization into your applications. All methods are fully typed and include built-in error handling.

API Organization

The SDK methods are organized into logical categories matching the sidebar navigation.

Account Management

Manage wallet connections and SIWE authentication.

Smart Wallet

Resolve and manage Safe smart wallets. The Safe (with session key) is assigned on the first depositFunds call — there is no separate deploy or session-key API.

Fund Management

Deposit and withdraw funds from your Smart Wallet. First deposit onboards the user onto a pre-deployed Safe with a signed session key (Base, Arbitrum, Mainnet).

User Data

Retrieve and update user profile, positions, and settings.

Earnings & Performance

Track and calculate earnings and APY.

Protocol Data

Access DeFi protocol information.

Opportunities Data

Discover yield opportunities by risk profile.

SDK Key Information

Get information about wallets and TVL for your SDK API key. No wallet connection required.

Analytics & Metrics

Platform-wide analytics and metrics.

Rebalancing

Monitor rebalancing activity.

ERC-8004

Agent identity registration on-chain.

Intelligence Layer

Read-only access to the Zyfai yield engine. No wallet connection required — API key only. See the Intelligence Layer overview for the full context.

Yield Simulation

Real-Time Risk Events


Common Patterns

Authentication Required

Most methods require SIWE authentication, which is handled automatically when you call connectAccount():

SDK Key Methods (No Wallet Required)

Some methods only require your SDK API key and don’t need a wallet connection:
These methods are ideal for:
  • B2B dashboards showing client metrics
  • Analytics and monitoring without user interaction
  • Server-side reporting and billing

Chain IDs

The SDK supports three chains:

Error Handling

All methods throw typed errors:

Amount Formatting

Token amounts are always in the least decimal units (wei):

Async Processing

Some operations like withdrawals are processed asynchronously:

Type Safety

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

Response Format

All SDK methods return consistent response objects:

Rate Limiting

API calls are rate-limited. The SDK includes automatic retry logic with exponential backoff.

Support