aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src
diff options
context:
space:
mode:
authorRemco Bloemen <remco@wicked.ventures>2018-08-24 06:18:55 +0800
committerRemco Bloemen <remco@wicked.ventures>2018-08-25 05:09:51 +0800
commit6734f2f1bcdab8f0d50524a26195707da00bd8ed (patch)
treeedbe63bacd2b991256f6391b7946f31a8067974c /packages/contracts/src
parent0fb7617a785b765415cb7f43448c9b8ea905963f (diff)
downloaddexon-sol-tools-6734f2f1bcdab8f0d50524a26195707da00bd8ed.tar
dexon-sol-tools-6734f2f1bcdab8f0d50524a26195707da00bd8ed.tar.gz
dexon-sol-tools-6734f2f1bcdab8f0d50524a26195707da00bd8ed.tar.bz2
dexon-sol-tools-6734f2f1bcdab8f0d50524a26195707da00bd8ed.tar.lz
dexon-sol-tools-6734f2f1bcdab8f0d50524a26195707da00bd8ed.tar.xz
dexon-sol-tools-6734f2f1bcdab8f0d50524a26195707da00bd8ed.tar.zst
dexon-sol-tools-6734f2f1bcdab8f0d50524a26195707da00bd8ed.zip
Add docs
Diffstat (limited to 'packages/contracts/src')
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol9
1 files changed, 7 insertions, 2 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 1c14dbcae..8a1444af1 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
@@ -74,7 +74,7 @@ contract LibMath is
return partialAmount;
}
- /// @dev Checks if rounding error > 0.1%.
+ /// @dev Checks if rounding error >= 0.1% when rounding down.
/// @param numerator Numerator.
/// @param denominator Denominator.
/// @param target Value to multiply with numerator/denominator.
@@ -121,7 +121,7 @@ contract LibMath is
return isError;
}
- /// @dev Checks if rounding error > 0.1%.
+ /// @dev Checks if rounding error >= 0.1% when rounding up.
/// @param numerator Numerator.
/// @param denominator Denominator.
/// @param target Value to multiply with numerator/denominator.
@@ -137,9 +137,14 @@ contract LibMath is
{
require(denominator > 0, "DIVISION_BY_ZERO");
+ // See the comments in `isRoundingError`.
if (target == 0 || numerator == 0) {
+ // When either is zero, the ideal value and rounded value are zero
+ // and there is no rounding error. (Although the relative error
+ // is undefined.)
return false;
}
+ // Compute remainder as before
uint256 remainder = mulmod(target, numerator, denominator);
// TODO: safeMod
remainder = safeSub(denominator, remainder) % denominator;