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:

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).

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.

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.

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 for available methods.

Last updated