From b85b42f13e4bb3acbfde242fdfd98014441c4ab7 Mon Sep 17 00:00:00 2001 From: keshav Date: Tue, 25 Jun 2024 14:15:09 -0700 Subject: [PATCH 1/3] Replaced computation using mulWad --- src/lib/EDAPrice.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/EDAPrice.sol b/src/lib/EDAPrice.sol index 9e5c8b5c..a79c7491 100644 --- a/src/lib/EDAPrice.sol +++ b/src/lib/EDAPrice.sol @@ -33,7 +33,7 @@ library EDAPrice { // which would require secondsElapsed > int256.max, i.e. > 5.78e76 or 1.8e69 years int256 multiplier = FixedPointMathLib.powWad(int256(percentWadRemainingPerPeriod), int256(ratio)); - uint256 price = (startPrice * uint256(multiplier)) / FixedPointMathLib.WAD; + uint256 price = FixedPointMathLib.mulWad(startPrice, uint256(multiplier)); return price; } } From fae5850390d5e940f8975d9e13c9ab471f7d7857 Mon Sep 17 00:00:00 2001 From: keshav Date: Wed, 26 Jun 2024 11:41:24 -0700 Subject: [PATCH 2/3] typo fix --- src/lib/EDAPrice.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/EDAPrice.sol b/src/lib/EDAPrice.sol index a79c7491..381e011e 100644 --- a/src/lib/EDAPrice.sol +++ b/src/lib/EDAPrice.sol @@ -30,7 +30,7 @@ library EDAPrice { // percentWadRemainingPerPeriod can be safely cast because < 1e18 // ratio can be safely cast because will not overflow unless ratio > int256.max, - // which would require secondsElapsed > int256.max, i.e. > 5.78e76 or 1.8e69 years + // which would require secondsElapsed > type(uint256).max, i.e. > 1.157e59 years int256 multiplier = FixedPointMathLib.powWad(int256(percentWadRemainingPerPeriod), int256(ratio)); uint256 price = FixedPointMathLib.mulWad(startPrice, uint256(multiplier)); From 0439fdcb81aff27053001d19b30b1f683d39eae1 Mon Sep 17 00:00:00 2001 From: keshav Date: Tue, 9 Jul 2024 11:20:40 -0700 Subject: [PATCH 3/3] Typo fixed --- src/lib/EDAPrice.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/EDAPrice.sol b/src/lib/EDAPrice.sol index 381e011e..28ea1e7c 100644 --- a/src/lib/EDAPrice.sol +++ b/src/lib/EDAPrice.sol @@ -29,8 +29,8 @@ library EDAPrice { uint256 percentWadRemainingPerPeriod = FixedPointMathLib.WAD - perPeriodDecayPercentWad; // percentWadRemainingPerPeriod can be safely cast because < 1e18 - // ratio can be safely cast because will not overflow unless ratio > int256.max, - // which would require secondsElapsed > type(uint256).max, i.e. > 1.157e59 years + // ratio can be safely cast because will not overflow unless ratio > type(int256).max, + // which would require secondsElapsed > type(int256).max, i.e. > 5.78e76 or 1.8e69 years int256 multiplier = FixedPointMathLib.powWad(int256(percentWadRemainingPerPeriod), int256(ratio)); uint256 price = FixedPointMathLib.mulWad(startPrice, uint256(multiplier));