aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/2.0.0
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-07-23 12:04:49 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-07-23 23:02:51 +0800
commitdcc0908617b83de8f45af3e9ca6854b897be3d72 (patch)
tree061bbbc74e77143819aca9d9de3cde59566b5972 /packages/contracts/src/2.0.0
parent45d68285f14ba328e1bf5a8cc9e59cdb39d7f306 (diff)
downloaddexon-0x-contracts-dcc0908617b83de8f45af3e9ca6854b897be3d72.tar.gz
dexon-0x-contracts-dcc0908617b83de8f45af3e9ca6854b897be3d72.tar.zst
dexon-0x-contracts-dcc0908617b83de8f45af3e9ca6854b897be3d72.zip
Add more tests and fixes
Diffstat (limited to 'packages/contracts/src/2.0.0')
-rw-r--r--packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol5
-rw-r--r--packages/contracts/src/2.0.0/forwarder/MixinWeth.sol2
-rw-r--r--packages/contracts/src/2.0.0/forwarder/libs/LibConstants.sol2
-rw-r--r--packages/contracts/src/2.0.0/forwarder/libs/LibForwarderErrors.sol2
-rw-r--r--packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol2
5 files changed, 8 insertions, 5 deletions
diff --git a/packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol b/packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol
index d80e06350..e230767b7 100644
--- a/packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol
+++ b/packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol
@@ -100,12 +100,15 @@ contract MixinExchangeWrapper is
internal
returns (FillResults memory totalFillResults)
{
+ bytes memory makerAssetData = orders[0].makerAssetData;
bytes memory wethAssetData = WETH_ASSET_DATA;
uint256 ordersLength = orders.length;
for (uint256 i = 0; i < ordersLength; i++) {
+ // We assume that asset being bought by taker is the same for each order.
// We assume that asset being sold by taker is WETH for each order.
+ orders[i].makerAssetData = makerAssetData;
orders[i].takerAssetData = wethAssetData;
// Calculate the remaining amount of WETH to sell
@@ -231,7 +234,7 @@ contract MixinExchangeWrapper is
// Attempt to sell the remaining amount of WETH.
FillResults memory singleFillResult = fillOrderNoThrow(
orders[i],
- safeAdd(remainingWethSellAmount, 1),
+ safeAdd(remainingWethSellAmount, 1), // we add 1 wei to the fill amount to make up for rounding errors
signatures[i]
);
diff --git a/packages/contracts/src/2.0.0/forwarder/MixinWeth.sol b/packages/contracts/src/2.0.0/forwarder/MixinWeth.sol
index a50863a59..8ba236e7f 100644
--- a/packages/contracts/src/2.0.0/forwarder/MixinWeth.sol
+++ b/packages/contracts/src/2.0.0/forwarder/MixinWeth.sol
@@ -87,7 +87,7 @@ contract MixinWeth is
// Ensure fee is less than amount of WETH remaining.
require(
ethFee <= wethRemaining,
- "MAX_FEE_EXCEEDED"
+ "INSUFFICIENT_ETH_REMAINING"
);
// Do nothing if no WETH remaining
diff --git a/packages/contracts/src/2.0.0/forwarder/libs/LibConstants.sol b/packages/contracts/src/2.0.0/forwarder/libs/LibConstants.sol
index 8abe1e42d..c26d7902c 100644
--- a/packages/contracts/src/2.0.0/forwarder/libs/LibConstants.sol
+++ b/packages/contracts/src/2.0.0/forwarder/libs/LibConstants.sol
@@ -26,7 +26,7 @@ import "../../tokens/ERC20Token/IERC20Token.sol";
contract LibConstants {
bytes4 constant internal ERC20_DATA_ID = bytes4(keccak256("ERC20Token(address)"));
- bytes4 constant internal ERC721_DATA_ID = bytes4(keccak256("ERC721Token(address,uint256,bytes)"));
+ bytes4 constant internal ERC721_DATA_ID = bytes4(keccak256("ERC721Token(address,uint256)"));
uint256 constant internal MAX_UINT = 2**256 - 1;
uint256 constant internal PERCENTAGE_DENOMINATOR = 10**18;
uint256 constant internal MAX_FEE_PERCENTAGE = 5 * PERCENTAGE_DENOMINATOR / 100; // 5%
diff --git a/packages/contracts/src/2.0.0/forwarder/libs/LibForwarderErrors.sol b/packages/contracts/src/2.0.0/forwarder/libs/LibForwarderErrors.sol
index 69108738a..cdfb77a0b 100644
--- a/packages/contracts/src/2.0.0/forwarder/libs/LibForwarderErrors.sol
+++ b/packages/contracts/src/2.0.0/forwarder/libs/LibForwarderErrors.sol
@@ -23,7 +23,7 @@ pragma solidity 0.4.24;
/// This contract is intended to serve as a reference, but is not actually used for efficiency reasons.
contract LibForwarderErrors {
string constant FEE_PERCENTAGE_TOO_LARGE = "FEE_PROPORTION_TOO_LARGE"; // Provided fee percentage greater than 5%.
- string constant MAX_FEE_EXCEEDED = "MAX_FEE_EXCEEDED"; // Not enough ETH remaining to pay feeRecipient.
+ string constant INSUFFICIENT_ETH_REMAINING = "INSUFFICIENT_ETH_REMAINING"; // Not enough ETH remaining to pay feeRecipient.
string constant OVERSOLD_WETH = "OVERSOLD_WETH"; // More WETH sold than provided with current message call.
string constant COMPLETE_FILL_FAILED = "COMPLETE_FILL_FAILED"; // Desired purchase amount not completely filled (required for ZRX fees only).
string constant TRANSFER_FAILED = "TRANSFER_FAILED"; // Asset transfer failed.
diff --git a/packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol b/packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol
index 190989181..63a2a085f 100644
--- a/packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol
+++ b/packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol
@@ -34,7 +34,7 @@ contract SafeMath {
{
require(
b <= a,
- "UINT256_OVERFLOW"
+ "UINT256_UNDERFLOW"
);
return a - b;
}