curvefi / curve-contract

Vyper contracts used in Curve.fi exchange pools.
https://www.curve.fi/
Other
1.03k stars 385 forks source link

For mr. @iamdefinitelyahuman. Please, I need your help. #148

Open eugeneford opened 2 years ago

eugeneford commented 2 years ago

Hello, @iamdefinitelyahuman.

First of all, I want to apologize for posting this here. I know that Github issues are not intended for technical support and honestly tried to get some guidance in Telegram and Discord. I've also read all the documentation, whitepapers at Curve.fi, all history of the messages in Discord's #dev channel as well as tons of other documentation.

I'm trying to understand the specifics of the 3pool contract, and struggling to do so. I'm doing so with one very specific goal — to deeply understand how APRs are calculated for Curve pools. I need your help to understand the following:

https://github.com/curvefi/curve-contract/blob/b0bbf77f8f93c9c5f4e415bce9cd71f0cdee960e/contracts/pools/3pool/StableSwap3Pool.vy#L82

What the RATES constant stands for? I originally thought that it is about the precision of the specific token, but found that USDT and USDC have 6 decimals while this array contains much higher values 10^30.

https://github.com/curvefi/curve-contract/blob/b0bbf77f8f93c9c5f4e415bce9cd71f0cdee960e/contracts/pools/3pool/StableSwap3Pool.vy#L177-L181 What the _xp() function does? My guess was that it returns the DAI, USDC, USDT balances normalized with a Lending precision. If my guess is right, why do we use the Lending precision if it is not a lending pool?

https://github.com/curvefi/curve-contract/blob/b0bbf77f8f93c9c5f4e415bce9cd71f0cdee960e/contracts/pools/3pool/StableSwap3Pool.vy#L195-L218 What the _get_D() function does? My guess was that it is connected to the pool invariant calculation, but it is not clear to me why do we go through a loop to calculate the D? I have found some relevant information in dev documentation, but really struggling to understand the specifics of "converging solution"