aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/2.0.0/forwarder/MixinWeth.sol
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/src/2.0.0/forwarder/MixinWeth.sol')
-rw-r--r--packages/contracts/src/2.0.0/forwarder/MixinWeth.sol12
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,