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