aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol')
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol14
1 files changed, 10 insertions, 4 deletions
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol
index 57fd53f29..c0b85ea10 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol
@@ -24,7 +24,6 @@ import "../../../utils/SafeMath/SafeMath.sol";
contract LibMath is
SafeMath
{
-
/// @dev Calculates partial value given a numerator and denominator rounded down.
/// Reverts if rounding error is >= 0.1%
/// @param numerator Numerator.
@@ -206,7 +205,11 @@ contract LibMath is
// 1000 * remainder < numerator * target
// so we have a rounding error iff:
// 1000 * remainder >= numerator * target
- uint256 remainder = mulmod(target, numerator, denominator);
+ uint256 remainder = mulmod(
+ target,
+ numerator,
+ denominator
+ );
isError = safeMul(1000, remainder) >= safeMul(numerator, target);
return isError;
}
@@ -238,8 +241,11 @@ contract LibMath is
return false;
}
// Compute remainder as before
- uint256 remainder = mulmod(target, numerator, denominator);
- // TODO: safeMod
+ uint256 remainder = mulmod(
+ target,
+ numerator,
+ denominator
+ );
remainder = safeSub(denominator, remainder) % denominator;
isError = safeMul(1000, remainder) >= safeMul(numerator, target);
return isError;