> For the complete documentation index, see [llms.txt](https://docs.yield.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yield.fi/earn-with-yieldfi/integration-sdk.md).

# Integration SDK

## YieldFi SDK Documentation

Welcome to the official YieldFi SDK documentation! This SDK provides a comprehensive TypeScript/JavaScript interface for interacting with YieldFi services, smart contracts, and blockchain protocols.

### What is YieldFi SDK?

The YieldFi SDK is a powerful, type-safe library that enables developers to:

* **Authenticate users** via EVM wallet signatures
* **Interact with vaults** - query vault information, protocol statistics, and transaction history
* **Manage partner transactions** and referrals through the Glassbook API
* **Interact with smart contracts** - Manager, YToken, VyToken, YVault contracts
* **Access utilities** - contract addresses, whitelisted tokens, and JWT management

### Key Features

* **Full TypeScript Support** - Complete type definitions for all APIs
* **Wallet Authentication** - Seamless EVM wallet integration
* **Role-Based Access** - Automatic filtering based on user roles
* **Comprehensive API Coverage** - Vault, Glassbook, Forms, and Curator Handoff APIs
* **Smart Contract Types** - Type-safe contract interactions with ethers.js
* **Error Handling** - Specialized error classes for different scenarios
* **Token Management** - Built-in utilities for JWT and token validation
* **Multi-Chain Support** - Works across all YieldFi supported chains

### Quick Example

```typescript
import { YieldFiSDK } from "yieldfi-sdk";

// Initialize SDK
const sdk = await YieldFiSDK.create({
  gatewayUrl: "https://gw.yield.fi",
});

// Authenticate user
const nonce = await sdk.auth.generateNonce({ address: "0x..." });
const signature = await wallet.signMessage(nonce.message);
const authResponse = await sdk.auth.login({
  address: "0x...",
  signature,
  message: nonce.message,
});

// Query vaults
const vaults = await sdk.vault.getVaults({ chainId: 1 });
const vault = await sdk.vault.getVaultByKey("yusd", 1);

// Get transactions (requires authentication)
const transactions = await sdk.vault.getTransactions(
  { chainId: 1, page: 1, pageSize: 20 },
  authResponse.accessToken
);
```

### Documentation Structure

This documentation is organized into the following sections:

#### Getting Started

Learn how to install and configure the SDK, and get your first integration working.

#### Authentication

Understand how to authenticate users with Ethereum wallets and manage tokens.

#### API Reference

Complete reference for all available APIs:

* Vault API - Query vaults, protocol stats, and transactions
* Glassbook API - Partner transactions and referrals
* Forms API - Dynamic form handling
* Curator Handoff API - Curator workflow management

#### Contract Interactions

Learn how to interact with YieldFi smart contracts using type-safe interfaces.

#### Utilities

Access contract addresses, whitelisted tokens, and JWT utilities.

#### Error Handling

Understand error types and best practices for handling errors.

#### Examples & Guides

Step-by-step guides and complete examples for common use cases.

#### Advanced Topics

Deep dive into advanced features like dependency injection and custom configurations.

### Version

Current SDK Version: **0.3.0**

### Support

* [Full Documentation](https://docs.yield.fi)
* [Discord Community](https://discord.gg/yieldfi)
* [GitHub Issues](https://github.com/yieldfi/yieldfi-sdk/issues)

### License

GPL-3.0 with restrictive distribution clause. See LICENSE for details.

***

**Ready to get started?** Head over to the Installation Guide!
