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.

Backend APIs (OpenAPI)

@zyfai/sdk is a thin client over two production backends. Use the pages below for narrative method docs (parameters, examples). Use the OpenAPI (Swagger) UIs when you call the backends directly or debug SDK traffic. Deposit registration and custody lifecycle (for example log_deposit, JWT, credited status) live on the execution API. Portfolio and yield display often pull from the DeFi data API after a deposit is credited. Execution OpenAPI JSON: api.zyf.ai/api-docs-json.

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 sendDeposit 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). For the normal user journey, call sendDeposit, then waitForDepositCredit when the UI needs investable funds. Use getDepositStatus for refreshes rather than holding a request open.

External deposit composition

Compatibility

Withdrawals

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