Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API for fetching vault APY #877

Open
divine-comedian opened this issue May 30, 2023 · 2 comments
Open

API for fetching vault APY #877

divine-comedian opened this issue May 30, 2023 · 2 comments
Assignees

Comments

@divine-comedian
Copy link

divine-comedian commented May 30, 2023

We need to fetch the APY rates for the underlying vaults of the Beefy contracts

This is the relevant API documentation:
https://docs.beefy.finance/developer-documentation/beefy-api#get-apy

image

We will need to fetch this APY daily for the correct vault we are using for the GIVsavings vault and add it to the historical APY to produce the APY graph
The APY will be unique to each vault but not to each user.

subtracting fees

We can get the current fee % from the contract here:
https://goerli-optimism.etherscan.io/address/0x799E7D9776c4A0392F6829DCB6BDc593d598F7AA#readProxyContract#F10
This returns for example 100000000000000000 in wei, so 0.1 or 10% fee on yield accrued.

To apply the fee to the APY we simply multiply the APY by 1- fee decimal | APY * (1 - fee) = feeAdjustedAPY

For example:
APY = 5%
fee = 10% (0.1)

5 * (1 - 0.1) = 4.5%
The APY we calculate for subsequent use on graphs, calculations and UI would be 4.5%

The average APY to date can be calculated so:

  1. Record the APY for each day since inception.
  2. Sum up all the daily APYs.
  3. Divide the total by the number of days since inception to find the average daily APY.
  4. Multiply the result by 365 (or 366 in a leap year) to convert it to the average annual APY.

The APY table

The APY table can be calculated by graphing the daily APY rates along the y-axis and the period of time along the x-axis

@divine-comedian
Copy link
Author

divine-comedian commented May 30, 2023

@mateodaza can you investigate how we can access and cache the API data?

@alireza-sharifpour JFYI

@divine-comedian divine-comedian changed the title API for fetchin vault APY API for fetching vault APY May 30, 2023
@mateodaza
Copy link
Member

mateodaza commented May 30, 2023

@mateodaza can you investigate how we can access and cache the API data?

@alireza-sharifpour JFYI

yeah man we can use something like redis for that, vercel just released something cool called vercel storage we could save the APY data in there and just upgrade when needed, it's not that complicated - all this through a serverless api function on the dapp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants