# YieldOptions

The YieldOptions class lets you access yield data for various protocols on multiple chains. Use it to compare farm yields for your assets or discover new opportunities. It covers supported protocols, assets, and expected yields across different networks.

We currently support the following networks and protocols, with more being added soon:

```tsx
Ethereum
├── Aave V2
├── Aave V3
├── Aura
├── Balancer
├── Beefy
├── Compound V2
├── Compound V3
├── Convex
├── Curve
├── Flux
├── Idle
├── Origin
├── Yearn
```

### Initialization

To set it up, provide a yield data source and specify the cache duration (in seconds).

```tsx
const ttl = 3600; // cache for 1 hour
const yieldOptions = new YieldOptions(provider, ttl);
```

### Choose Provider

#### Cached Provider

The CachedProvider is the most efficient solution. It is a simple wrapper class for static yield data. You pass it a URL pointing to a JSON file on initialization and it stores the data in memory.

```tsx
const provider = new CachedProvider();
await provider.initialize("<https://raw.githubusercontent.com/Popcorn-Limited/apy-data/main/apy-data.json>");

const ttl = 3600;
const yieldOptions = new YieldOptions(provider, 3600);
```

#### Protocol Provider

The LiveProvider utilizes real-time yield data obtained from on-chain contracts or the protocol's API. To access on-chain data, it requires a connection to a viem public client.

```tsx
const ttl = 3600;
const clients = {
    1: createPublicClient({
        chain: mainnet,
        transport: http()
    }),
};
const provider = new LiveProvider(clients, ttl);
const yieldOptions = new YieldOptions(provider, ttl);
```

> Check our [GitHub](https://github.com/Popcorn-Limited/vaultcraft-sdk/blob/main/docs/vault.md) for available methods.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.vaultcraft.io/products/vaultcraft-vci-and-sdk/sdk/yieldoptions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
