# Yield and APY tracking

#### Fetch aggregated yield accrual info  <a href="#key-features" id="key-features"></a>

Use this method to retrieve aggregated yield data for specified vaults, pools, and users within a given timeframe:

<pre class="language-typescript"><code class="lang-typescript"><strong>// Get all aggregated yield data
</strong>const aggregatedYieldData = await sdk.data.getAggregatedYield();

// Get aggregated yields with all filters
const filteredAggregatedYield = await sdk.data.getAggregatedYield(
	['0xVaultAddress'],              // Optional: filter by vault addresses
	[1, 2, 3],                       // Optional: filter by pool IDs
	['0xUserAddress1', '0xUserAddress2'], // Optional: filter by user addresses
	{ fromTimestamp: 1640000000 }    // Optional: timeframe filter
);const aggregatedYieldData = await sdk.yields.getYields([vaults], [poolIds], [users], timeframe);
</code></pre>

Where:

* `vaults` – Array of vault addresses to filter results.
* `poolIds` – Array of pool IDs to filter results.
* `users` – Array of user addresses to filter results.
* `timeframe` – Timeframe to limit results within a specific period.

#### Zooming in on rewards

The yield comes from two sources:&#x20;

* the native yield of the underlying vault
* reward tokens (f.e. $MORPHO or $SILO)&#x20;

The native yield is usually distributed more frequently, often whenever someone deposits or withdraws from the vault. On the other hand, rewards can be distributed by protocols sporadically and less regularly.

Compounding rewards means following process:

* Yelay vault claims those reward tokens (which are usually in a different ERC-20 token)
* Swaps them into the Yelay vault's underlying token
* Distributes them among users in form of yield.

Let’s say a user deposited an unspecified amount and earned 70 USDC in yield over the course of one week. The native APY is 4%, and there’s an additional 2% APY from rewards. On the 3rd day, the user receives an additional 35 USDC from compounding the rewards. So, his total yield suddenly jumps from 70 USDC to 105 USDC. If APY is calculated using data from each day except the last, the average yield is based on 10 USDC per day. However, if you calculate it using only the last 24 hours, the daily yield appears to be 45 USDC (10 + 35), which is significantly higher and results in an inflated APY.


---

# 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.yelay.io/yelay-sdk/yield-and-apy-tracking.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.
