diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-08-10 02:20:06 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-08-10 02:26:32 +0800 |
commit | b9d8d2d5e3e7aa5f14ae2fd2019460890497bb7e (patch) | |
tree | 16c7a6bf3fc0ee332639023eebc5e6dcfd8b09ae /packages/contracts/src/2.0.0/forwarder/MixinWeth.sol | |
parent | b60a74c8bc4de5c897cefc2fbf9a247d8422d560 (diff) | |
download | dexon-0x-contracts-b9d8d2d5e3e7aa5f14ae2fd2019460890497bb7e.tar.gz dexon-0x-contracts-b9d8d2d5e3e7aa5f14ae2fd2019460890497bb7e.tar.zst dexon-0x-contracts-b9d8d2d5e3e7aa5f14ae2fd2019460890497bb7e.zip |
Make marketBuy functions revert if entire amount not filled
Diffstat (limited to 'packages/contracts/src/2.0.0/forwarder/MixinWeth.sol')
-rw-r--r-- | packages/contracts/src/2.0.0/forwarder/MixinWeth.sol | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/packages/contracts/src/2.0.0/forwarder/MixinWeth.sol b/packages/contracts/src/2.0.0/forwarder/MixinWeth.sol index 8ba236e7f..e07940776 100644 --- a/packages/contracts/src/2.0.0/forwarder/MixinWeth.sol +++ b/packages/contracts/src/2.0.0/forwarder/MixinWeth.sol @@ -71,12 +71,16 @@ contract MixinWeth is "FEE_PERCENTAGE_TOO_LARGE" ); - // Calculate amount of WETH that hasn't been sold. - uint256 wethRemaining = safeSub( - msg.value, - safeAdd(wethSoldExcludingFeeOrders, wethSoldForZrx) + // Ensure that no extra WETH owned by this contract has been sold. + uint256 wethSold = safeAdd(wethSoldExcludingFeeOrders, wethSoldForZrx); + require( + wethSold <= msg.value, + "OVERSOLD_WETH" ); + // Calculate amount of WETH that hasn't been sold. + uint256 wethRemaining = safeSub(msg.value, wethSold); + // Calculate ETH fee to pay to feeRecipient. uint256 ethFee = getPartialAmount( feePercentage, |