compound-protocol icon indicating copy to clipboard operation
compound-protocol copied to clipboard

Wrong seconds per block in the DAI interest rate model

Open MathisGD opened this issue 2 years ago • 2 comments

https://github.com/compound-finance/compound-protocol/blob/a3214f67b73310d547e00fc578e8355911c9d376/contracts/DAIInterestRateModelV3.sol#L17

The average number of second between each block used here is 15, while since the Merge, the it is now stable at 12 seconds. This means that the supply rate given by getSupplyRate would be wrong.

Some discussions are open to re-enable deposits to the DSR from cDAI, and it will not be possible to re-use the old DAIInterestRateModelV3 available at 0xfed941d39905b23d6faf02c8301d40bd4834e27f because of this reason.

MathisGD avatar Dec 04 '22 21:12 MathisGD

Would an easy fix for this just be a simple change like so?

uint256 private constant SECONDS_PER_BLOCK = 12;

fmorisan avatar Dec 19 '22 15:12 fmorisan

By the way, I just noticed that all the other IRMs assume that the number of second between each block is 15 (2 102 400 blocks per year). But that's not that of an issue, because it is only used to covert the parameters from yearly to per-block at the construction of the contract.

MathisGD avatar Dec 22 '22 21:12 MathisGD