aboutsummaryrefslogtreecommitdiffstats
path: root/contracts/protocol
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-12-19 07:55:24 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-12-21 01:11:30 +0800
commit2a2260de45925bc309b6d6baf990d5ea6a171a90 (patch)
tree3cf97b1b93ad82236c0ac86afcb95ab929f7582a /contracts/protocol
parenta7c3996627aaedfcd0ba37e7e15895480a0b065c (diff)
downloaddexon-sol-tools-2a2260de45925bc309b6d6baf990d5ea6a171a90.tar
dexon-sol-tools-2a2260de45925bc309b6d6baf990d5ea6a171a90.tar.gz
dexon-sol-tools-2a2260de45925bc309b6d6baf990d5ea6a171a90.tar.bz2
dexon-sol-tools-2a2260de45925bc309b6d6baf990d5ea6a171a90.tar.lz
dexon-sol-tools-2a2260de45925bc309b6d6baf990d5ea6a171a90.tar.xz
dexon-sol-tools-2a2260de45925bc309b6d6baf990d5ea6a171a90.tar.zst
dexon-sol-tools-2a2260de45925bc309b6d6baf990d5ea6a171a90.zip
Use more efficient check for overflow
Diffstat (limited to 'contracts/protocol')
-rw-r--r--contracts/protocol/contracts/protocol/AssetProxy/MultiAssetProxy.sol10
1 files changed, 5 insertions, 5 deletions
diff --git a/contracts/protocol/contracts/protocol/AssetProxy/MultiAssetProxy.sol b/contracts/protocol/contracts/protocol/AssetProxy/MultiAssetProxy.sol
index b42aa79ee..4285725d0 100644
--- a/contracts/protocol/contracts/protocol/AssetProxy/MultiAssetProxy.sol
+++ b/contracts/protocol/contracts/protocol/AssetProxy/MultiAssetProxy.sol
@@ -181,11 +181,11 @@ contract MultiAssetProxy is
let amountsElement := calldataload(add(amountsContentsStart, i))
let totalAmount := mul(amountsElement, amount)
- // Revert if multiplication resulted in an overflow
- if and(
- gt(amount, 0),
- iszero(eq(div(totalAmount, amount), amountsElement))
- ) {
+ // Revert if `amount` != 0 and multiplication resulted in an overflow
+ if iszero(or(
+ iszero(amount),
+ eq(div(totalAmount, amount), amountsElement)
+ )) {
// Revert with `Error("UINT256_OVERFLOW")`
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)