diff --git a/contracts/libraries/math/WadRayMath.sol b/contracts/libraries/math/WadRayMath.sol index 6b67641c..696a0e09 100644 --- a/contracts/libraries/math/WadRayMath.sol +++ b/contracts/libraries/math/WadRayMath.sol @@ -100,7 +100,7 @@ library WadRayMath { uint256 result = a * b + halfRAY; - require((result - halfRAY) / a == b, Errors.MULTIPLICATION_OVERFLOW); + require(result >= halfRAY && (result - halfRAY) / a == b, Errors.MULTIPLICATION_OVERFLOW); return result / RAY; } @@ -118,7 +118,7 @@ library WadRayMath { uint256 result = a * RAY + halfB; - require((result - halfB) / RAY == a, Errors.MULTIPLICATION_OVERFLOW); + require(result >= halfB && (result - halfB) / RAY == a, Errors.MULTIPLICATION_OVERFLOW); return result / b; }