morpho-optimizers
morpho-optimizers copied to clipboard
[Lens] p2p rate reverts when utilization > 100% on Compound
In Compound it is actually possible to borrow the reserves, in which case utilization > 100%. The computation of the p2p rate of the Compound Lens reverts if utilization > 100%. This is because the supply rate is computed as multiplying the borrow rate by the utilization, so the pool supply rate is greater than the borrow rate.
A few things to note:
- it is not enforced that cash > reserves, where cash is simply the balance of the pool in underlying:
- in accrueInterest, the reserves grow (by interestAccumulated * reserveFactor but the cash obv does not change
- it is not checked in the main functions. For example, there is no such check when withdrawing
- this effectively means you can borrow the reserves rights now, with about $16M available. I guess it's useful in events like this when the market is deprecated. But it's also a risk of loss for Compound (they could take most of those reserves now though)
- the utilization rate's definition is borrow / (cash + borrow - reserves), which is over 100% when reserves > cash
- note that this utilization is not just for display on the interface, and it is used in the interest rate model (piecewise linear, so no problem there, it just goes up)
- the documentation of this function says that it cannot go over 100%
- the total amount of underlying tokens owed to suppliers is also defined as cash + borrow - reserves, given how the exchange rate is computed