diff options
author | Fabio Berger <me@fabioberger.com> | 2018-08-15 05:21:47 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-08-15 05:21:47 +0800 |
commit | 2f2582a0da3095d61a99ef09744dc0995677558e (patch) | |
tree | 54989565919038c42d495dafb7426d4148605e84 /packages/contracts/src/2.0.0/forwarder/MixinWeth.sol | |
parent | 8169155a6547fb0283cd0f5362aad3c0b173b00b (diff) | |
parent | fadd292ecf367e42154856509d0ea0c20b23f2f1 (diff) | |
download | dexon-0x-contracts-2f2582a0da3095d61a99ef09744dc0995677558e.tar dexon-0x-contracts-2f2582a0da3095d61a99ef09744dc0995677558e.tar.gz dexon-0x-contracts-2f2582a0da3095d61a99ef09744dc0995677558e.tar.bz2 dexon-0x-contracts-2f2582a0da3095d61a99ef09744dc0995677558e.tar.lz dexon-0x-contracts-2f2582a0da3095d61a99ef09744dc0995677558e.tar.xz dexon-0x-contracts-2f2582a0da3095d61a99ef09744dc0995677558e.tar.zst dexon-0x-contracts-2f2582a0da3095d61a99ef09744dc0995677558e.zip |
Merge development
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, |