curve-api icon indicating copy to clipboard operation
curve-api copied to clipboard

Possible bug in getFactoGauges

Open 0xqiba opened this issue 1 year ago • 5 comments

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 avatar Jul 17 '24 15:07 0xqiba

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.

0xqiba avatar Jul 23 '24 21:07 0xqiba

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

philippe-git avatar Jul 23 '24 21:07 philippe-git

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

0xqiba avatar Jul 24 '24 02:07 0xqiba

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

philippe-git avatar Sep 03 '24 16:09 philippe-git

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.

0xqiba avatar Sep 06 '24 15:09 0xqiba