Skip to content

Commit a4e8d65

Browse files
committed
fix: mul before div to avoid precision loss
1 parent 9ee3aa3 commit a4e8d65

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

contracts/DAIInterestRateModelV4.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ contract DAIInterestRateModelV4 is JumpRateModelV2 {
8282
*/
8383
function dsrPerBlock() public view returns (uint) {
8484
return (pot.dsr() - RAY_BASE) // scaled RAY_BASE aka RAY, and includes an extra "ONE" before subtraction
85-
/ RAY_TO_BASE_SCALE // descale to BASE
8685
* SECONDS_PER_BLOCK; // seconds per block
86+
/ RAY_TO_BASE_SCALE // descale to BASE
8787
}
8888

8989
/**
9090
* @notice Resets the baseRate and multiplier per block based on the stability fee and Dai savings rate
9191
*/
9292
function poke() public {
9393
(uint duty, ) = jug.ilks("ETH-B");
94-
uint stabilityFeePerBlock = (duty + jug.base() - RAY_BASE) / RAY_TO_BASE_SCALE * SECONDS_PER_BLOCK;
94+
uint stabilityFeePerBlock = (duty + jug.base() - RAY_BASE) * SECONDS_PER_BLOCK / RAY_TO_BASE_SCALE;
9595

9696
// We ensure the minimum borrow rate >= DSR / (1 - reserve factor)
9797
baseRatePerBlock = dsrPerBlock() * BASE / assumedOneMinusReserveFactorMantissa;

0 commit comments

Comments
 (0)