Open divine-comedian opened 1 year ago
@mateodaza can you investigate how we can access and cache the API data?
@alireza-sharifpour JFYI
@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
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
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:
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