diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-12-19 07:55:24 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-12-21 01:11:30 +0800 |
commit | 2a2260de45925bc309b6d6baf990d5ea6a171a90 (patch) | |
tree | 3cf97b1b93ad82236c0ac86afcb95ab929f7582a | |
parent | a7c3996627aaedfcd0ba37e7e15895480a0b065c (diff) | |
download | dexon-0x-contracts-2a2260de45925bc309b6d6baf990d5ea6a171a90.tar.gz dexon-0x-contracts-2a2260de45925bc309b6d6baf990d5ea6a171a90.tar.zst dexon-0x-contracts-2a2260de45925bc309b6d6baf990d5ea6a171a90.zip |
Use more efficient check for overflow
-rw-r--r-- | contracts/protocol/contracts/protocol/AssetProxy/MultiAssetProxy.sol | 10 |
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) |