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

Giveth farms adapter v2 #2

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Giveth farms adapter v2 #2

wants to merge 11 commits into from

Conversation

mateodaza
Copy link
Collaborator

@mateodaza mateodaza commented Aug 31, 2022

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'; and const urlGivEconomyGnosis = 'https://api.thegraph.com/subgraphs/name/mateodaza/giveth-economy-second-xdai'

Copy link
Owner

@CarlosQ96 CarlosQ96 left a 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.

: BigNumber(contractInfo.rewardRate)
.div(totalSupply)
.times(secsInOneYear)
.times('100')
Copy link
Owner

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.

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

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

.times(secsInOneYear)
.times('100')
.times(lp)
.div(10 ** 18);
Copy link
Owner

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.

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

Copy link
Collaborator Author

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

@mateodaza
Copy link
Collaborator Author

mateodaza commented Sep 1, 2022

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

@mateodaza
Copy link
Collaborator Author

mateodaza commented Sep 2, 2022

WEI value fixed for every farm that had the problem @CarlosQ96

@mendesfabio
Copy link

I couldn't review the code but left 2 comments, thanks for working on this Mateo :)

CarlosQ96
CarlosQ96 previously approved these changes Sep 2, 2022
Copy link
Owner

@CarlosQ96 CarlosQ96 left a 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.

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

Successfully merging this pull request may close these issues.

4 participants