-
Notifications
You must be signed in to change notification settings - Fork 22
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
Harmonize p2p rate computation #1492
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.
There are other places where the function could be used.
_poolSupplyRate + | ||
_p2pIndexCursor * | ||
_poolBorrowRate) / MAX_BASIS_POINTS; | ||
return PercentageMath.weightedAvg(_poolSupplyRate, _poolBorrowRate, _p2pIndexCursor); |
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.
isn't this function supposed to handle the case where the rates are inverted ?
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.
Yes, but this PR does not address this issue. I chose to handle them independently. I'm opening a PR on top of this one to handle #1467 (the one in your mind)
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.
Also, inverted spreads are only possible on aave-v2?
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.
No on both, but for different reasons
Please show me (note the function doesn't exist in aave-v2's InterestRatesModel) |
In the |
859a946
to
e8efeb1
Compare
Just force-pushed (because it's a change of paradigm) a new version, getting rid of this unnecessary function in |
e8efeb1
to
072742d
Compare
Don't we have issues here when the spread is natively inverted ? This time, I was in favor of having an internal function |
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.
Still one question to answer
Can we have the same issue as on Aave? Knowing that there's no flashloans nor stable rates on Compound. Anyway, I think it's safe doing the same we did on Aave. |
The indexes can grow as if there were an inverted spread, when someone send some token on the cToken contract |
Yes but it broke the growth factors, not the rates no? But as I say I'm for changing it |
tbh I don't remember how the supply rate is computed exacly on Compound |
…cts into fix/lens-p2p-rate
On Compound, Note: |
The white paper abstracts the computation too much in this case. Only the supply index is changed if some underlying tokens are sent to the cToken contract, so the equality does not stand anymore. See the computation of the supply index. Notice that the function For an explanation of why the equation stands without transfer of underlyings to the cToken contract : https://github.com/morpho-labs/morpho-yellowpaper/issues/117 |
Seen together:
Note: Compound exposes rates per block which are not computed based on the CToken indexes. This is what we call "desync", because the indexes can grow by sending underlyings to CTokens, and may grow faster than what is computed by |
Note: I think we should not rely on papers but on the code for the behavior of the underlying contracts we're plugging into. |
Pull Request
Issue(s) fixed