-
Notifications
You must be signed in to change notification settings - Fork 0
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
Giveth farms adapter v2 #2
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Mateo Great work, After running the Data I got this, which I think its good the APRs:
Sample pools: [
{
pool: '0x4b9efae862a1755f7cecb021856d467e86976755',
chain: 'Ethereum',
project: 'giveth',
symbol: 'GIV',
tvlUsd: 1.0588029122164071e+23,
apy: 56.315087315088626
},
{
pool: '0xc3151A58d519B94E915f66B044De3E55F77c2dd9',
chain: 'Ethereum',
project: 'giveth',
symbol: 'oneGIV-GIV',
tvlUsd: 296831.47946687107,
apy: 176.71785123226564
},
{
pool: '0x7819f1532c49388106f7762328c51ee70edd134c000200000000000000000109',
chain: 'Ethereum',
project: 'giveth',
symbol: 'GIV-WETH',
tvlUsd: 93972.07590370328,
apy: 190.07712269687542
},
{
pool: '0xbeba1666c62c65e58770376de332891b09461eeb',
chain: 'Ethereum',
project: 'giveth',
symbol: 'DAI-GIV',
tvlUsd: 82895.29771004083,
apy: 377.00997047088856
}
]
Like Mitch said in my PR there is a discrepancy in tvlUsd value format. I am not sure if that's an issue or not. But we should come to a agreement in how to display the value, because I am not sure if defiLlama reads both formats correctly or not.
Mitch Comment:
I also noticed that the single asset GIV pools on mainnet and gnosis chain have their tvlUsd in WEI while the LP pools are in regular amounts.
src/adaptors/giveth/index.js
Outdated
: BigNumber(contractInfo.rewardRate) | ||
.div(totalSupply) | ||
.times(secsInOneYear) | ||
.times('100') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see times '100' in many calculations, what does this represent?
Lets keep numbers in variables for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is basically to have APR in the 0-100% range - otherwise, the result would be between 0-1 cc @mateodaza
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
src/adaptors/giveth/index.js
Outdated
.times(secsInOneYear) | ||
.times('100') | ||
.times(lp) | ||
.div(10 ** 18); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this multiplication represent? Save it in a variable for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it quite confusing the upscaling and downscaling as well. For instance, the lp
variable is multiplied by 10e18, but right after, we divide lp
by 10e18 to calculate APR. This only adds complexity to the math since the terms cancel each other. cc @mateodaza
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for noticing :)) the disadvantages of recklessly copy pasting haha
Hey @CarlosQ96! Thanks for your review :) A couple of responses Regarding the 100 and multiplication representation I wouldn't know how to respond to that, I based this from the formulas for the APY we use on the front-end, maybe Amin or someone more specialized can make it more clear to you, not sure if this is a blocker EDIT: Also, just noticed I missed xDAI staking, will update. I'll also remove GIV mainnet staking and GIV/DAI farm as they're deprecated |
WEI value fixed for every farm that had the problem @CarlosQ96 |
I couldn't review the code but left 2 comments, thanks for working on this Mateo :) |
also fixes PR suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Mateo, Thanks, functionality seems ok I ran giveth-adapter as you said, and values are more similar in format. Let's move forward so we can see what's next in the process with defi llama IMO.
We need to get the new subgraph on mainnet working to change the variable
const urlGivEconomyMainnet = 'https://api.thegraph.com/subgraphs/name/mateodaza/givpower-subgraph-mainnet';
andconst urlGivEconomyGnosis = 'https://api.thegraph.com/subgraphs/name/mateodaza/giveth-economy-second-xdai'