curvefi / curve-api

https://api.curve.fi/v1/documentation
98 stars 46 forks source link

Possible bug in getFactoGauges #358

Open 0xqiba opened 3 months ago

0xqiba commented 3 months ago

When inflation_rate is 0 on a sidechain child gauge, getFactoGauges/[blockchainId].js (lines 116-130) tries to determine an effective inflation rate using total_emissions on the root gauge. However, it looks like total_emissions is a cumulative number, which would make the calculation incorrect. One downstream effect of this is that getPools returns a very high gaugeCrvApy for sidechain child gauges whose inflation_rate is 0.

Example: The Curve front end for the fxETH pool reports 0% CRV APR, but the getPools API reports a gaugeCrvApy of 6700.

I'm not sure what the right fix is for effective inflation rate, but if you can provide some guidance I am willing to work on it and submit a PR. Thanks!

0xqiba commented 3 months ago

Just wanted to mention that the fxETH example I gave above is now working again since the CRV APR is no longer 0%, but I believe the underlying issue remains.

philippe-git commented 3 months ago

Thank you for these messages! Just acknowledging your report, I'll make sure to take a closer look later!

0xqiba commented 3 months ago

Thanks! Let me know if there's anything I can do to help.

philippe-git commented 2 months ago

Note: if confirmed this is quite low impact; I tend to agree with your observation, but not being a contract specialist myself, I need someone else's eyes on this first; the core team has many more important things to work on contract-side for the foreseeable future so taking a closer look at total_emissions is not a priority at the moment. I'm leaving this open since this matter isn't resolved yet, but note that it won't be resolved soon

0xqiba commented 1 month ago

OK. I can't comment on the impact/importance of this relative to other priorities, but I should mention that the way I came across this bug is on DefiLlama's yields page. For some Curve pools on sidechains, the yields temporarily shoot up to absurd levels and then come back down days later.

Here's an example of a Curve pool on Fraxtal that DefiLlama currently thinks is yielding ~900%:

https://defillama.com/yields/pool/394e78dd-2207-40ea-b5ee-4e459229baef

The Curve front end shows a very different number:

https://curve.fi/#/fraxtal/pools/factory-tricrypto-0/deposit

It's possible there is a better way to retrieve CRV yields from the DefiLlama side, but I thought I'd start here first since it's a lower-level issue that could be impacting other things.