aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/IExchange.sol8
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol6
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol16
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol72
-rw-r--r--packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol31
-rw-r--r--packages/contracts/src/utils/order_utils.ts6
-rw-r--r--packages/contracts/src/utils/types.ts2
-rw-r--r--packages/contracts/test/exchange/core.ts152
-rw-r--r--packages/contracts/test/exchange/helpers.ts2
-rw-r--r--packages/contracts/test/exchange/wrapper.ts181
10 files changed, 237 insertions, 239 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/IExchange.sol b/packages/contracts/src/contracts/current/protocol/Exchange/IExchange.sol
index 3315e270f..083966425 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/IExchange.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/IExchange.sol
@@ -35,8 +35,8 @@ contract IExchange {
address indexed maker,
address taker,
address indexed feeRecipient,
- address makerToken,
- address takerToken,
+ bytes makerAssetData,
+ bytes takerAssetData,
uint256 makerTokenFilledAmount,
uint256 takerTokenFilledAmount,
uint256 makerFeePaid,
@@ -47,8 +47,8 @@ contract IExchange {
event LogCancel(
address indexed maker,
address indexed feeRecipient,
- address makerToken,
- address takerToken,
+ bytes makerAssetData,
+ bytes takerAssetData,
uint256 makerTokenCancelledAmount,
uint256 takerTokenCancelledAmount,
bytes32 indexed orderHash
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol b/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol
index 862a8cfb5..d47a0fbbe 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol
@@ -25,8 +25,6 @@ contract LibOrder {
"address exchangeAddress",
"address makerAddress",
"address takerAddress",
- "address makerTokenAddress",
- "address takerTokenAddress",
"address feeRecipientAddress",
"uint256 makerTokenAmount",
"uint256 takerTokenAmount",
@@ -41,8 +39,6 @@ contract LibOrder {
struct Order {
address makerAddress;
address takerAddress;
- address makerTokenAddress;
- address takerTokenAddress;
address feeRecipientAddress;
uint256 makerTokenAmount;
uint256 takerTokenAmount;
@@ -69,8 +65,6 @@ contract LibOrder {
address(this),
order.makerAddress,
order.takerAddress,
- order.makerTokenAddress,
- order.takerTokenAddress,
order.feeRecipientAddress,
order.makerTokenAmount,
order.takerTokenAmount,
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol
index 000977cf6..ec1bd57ce 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol
@@ -53,8 +53,8 @@ contract MixinExchangeCore is
address indexed makerAddress,
address takerAddress,
address indexed feeRecipientAddress,
- address makerTokenAddress,
- address takerTokenAddress,
+ bytes makerAssetData,
+ bytes takerAssetData,
uint256 makerTokenFilledAmount,
uint256 takerTokenFilledAmount,
uint256 makerFeePaid,
@@ -65,8 +65,8 @@ contract MixinExchangeCore is
event Cancel(
address indexed makerAddress,
address indexed feeRecipientAddress,
- address makerTokenAddress,
- address takerTokenAddress,
+ bytes makerAssetData,
+ bytes takerAssetData,
bytes32 indexed orderHash
);
@@ -153,8 +153,8 @@ contract MixinExchangeCore is
order.makerAddress,
msg.sender,
order.feeRecipientAddress,
- order.makerTokenAddress,
- order.takerTokenAddress,
+ order.makerAssetData,
+ order.takerAssetData,
fillResults.makerTokenFilledAmount,
fillResults.takerTokenFilledAmount,
fillResults.makerFeePaid,
@@ -195,8 +195,8 @@ contract MixinExchangeCore is
emit Cancel(
order.makerAddress,
order.feeRecipientAddress,
- order.makerTokenAddress,
- order.takerTokenAddress,
+ order.makerAssetData,
+ order.takerAssetData,
orderHash
);
return true;
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
index 8ac9977bd..027fcd87f 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
@@ -22,11 +22,13 @@ pragma experimental ABIEncoderV2;
import "./mixins/MExchangeCore.sol";
import "./LibPartialAmount.sol";
import "../../utils/SafeMath/SafeMath.sol";
+import "../../utils/LibBytes/LibBytes.sol";
/// @dev Consumes MExchangeCore
contract MixinWrapperFunctions is
MExchangeCore,
SafeMath,
+ LibBytes,
LibPartialAmount
{
/// @dev Fills the input order. Reverts if exact takerTokenFillAmount not filled.
@@ -73,26 +75,24 @@ contract MixinWrapperFunctions is
// | | 0x00 | | 1. offset to order (*) |
// | | 0x20 | | 2. takerTokenFillAmount |
// | | 0x40 | | 3. offset to signature (*) |
- // | Data | | 13 * 32 | order: |
+ // | Data | | 11 * 32 | order: |
// | | 0x000 | | 1. makerAddress |
// | | 0x020 | | 2. takerAddress |
- // | | 0x040 | | 3. makerTokenAddress |
- // | | 0x060 | | 4. takerTokenAddress |
- // | | 0x080 | | 5. feeRecipientAddress |
- // | | 0x0A0 | | 6. makerTokenAmount |
- // | | 0x0C0 | | 7. takerTokenAmount |
- // | | 0x0E0 | | 8. makerFeeAmount |
- // | | 0x100 | | 9. takerFeeAmount |
- // | | 0x120 | | 10. expirationTimeSeconds |
- // | | 0x140 | | 11. salt |
- // | | 0x160 | | 12. Offset to makerAssetProxyMetadata (*) |
- // | | 0x180 | | 13. Offset to takerAssetProxyMetadata (*) |
- // | | 0x1A0 | 32 | makerAssetProxyMetadata Length |
- // | | 0x1C0 | ** | makerAssetProxyMetadata Contents |
- // | | 0x1E0 | 32 | takerAssetProxyMetadata Length |
- // | | 0x200 | ** | takerAssetProxyMetadata Contents |
- // | | 0x220 | 32 | signature Length |
- // | | 0x240 | ** | signature Contents |
+ // | | 0x040 | | 3. feeRecipientAddress |
+ // | | 0x060 | | 4. makerTokenAmount |
+ // | | 0x080 | | 5. takerTokenAmount |
+ // | | 0x0A0 | | 6. makerFeeAmount |
+ // | | 0x0C0 | | 7. takerFeeAmount |
+ // | | 0x0E0 | | 8. expirationTimeSeconds |
+ // | | 0x100 | | 9. salt |
+ // | | 0x120 | | 10. Offset to makerAssetProxyMetadata (*) |
+ // | | 0x140 | | 11. Offset to takerAssetProxyMetadata (*) |
+ // | | 0x160 | 32 | makerAssetProxyMetadata Length |
+ // | | 0x180 | ** | makerAssetProxyMetadata Contents |
+ // | | 0x1A0 | 32 | takerAssetProxyMetadata Length |
+ // | | 0x1C0 | ** | takerAssetProxyMetadata Contents |
+ // | | 0x1E0 | 32 | signature Length |
+ // | | 0x200 | ** | signature Contents |
// * Offsets are calculated from the beginning of the current area: Header, Params, Data:
// An offset stored in the Params area is calculated from the beginning of the Params section.
@@ -149,22 +149,20 @@ contract MixinWrapperFunctions is
// the stores sequentially.
mstore(dataAreaEnd, mload(sourceOffset)) // makerAddress
mstore(add(dataAreaEnd, 0x20), mload(add(sourceOffset, 0x20))) // takerAddress
- mstore(add(dataAreaEnd, 0x40), mload(add(sourceOffset, 0x40))) // makerTokenAddress
- mstore(add(dataAreaEnd, 0x60), mload(add(sourceOffset, 0x60))) // takerTokenAddress
- mstore(add(dataAreaEnd, 0x80), mload(add(sourceOffset, 0x80))) // feeRecipientAddress
- mstore(add(dataAreaEnd, 0xA0), mload(add(sourceOffset, 0xA0))) // makerTokenAmount
- mstore(add(dataAreaEnd, 0xC0), mload(add(sourceOffset, 0xC0))) // takerTokenAmount
- mstore(add(dataAreaEnd, 0xE0), mload(add(sourceOffset, 0xE0))) // makerFeeAmount
- mstore(add(dataAreaEnd, 0x100), mload(add(sourceOffset, 0x100))) // takerFeeAmount
- mstore(add(dataAreaEnd, 0x120), mload(add(sourceOffset, 0x120))) // expirationTimeSeconds
- mstore(add(dataAreaEnd, 0x140), mload(add(sourceOffset, 0x140))) // salt
- mstore(add(dataAreaEnd, 0x160), mload(add(sourceOffset, 0x160))) // Offset to makerAssetProxyMetadata
- mstore(add(dataAreaEnd, 0x180), mload(add(sourceOffset, 0x180))) // Offset to takerAssetProxyMetadata
- dataAreaEnd := add(dataAreaEnd, 0x1A0)
- sourceOffset := add(sourceOffset, 0x1A0)
+ mstore(add(dataAreaEnd, 0x40), mload(add(sourceOffset, 0x40))) // feeRecipientAddress
+ mstore(add(dataAreaEnd, 0x60), mload(add(sourceOffset, 0x60))) // makerTokenAmount
+ mstore(add(dataAreaEnd, 0x80), mload(add(sourceOffset, 0x80))) // takerTokenAmount
+ mstore(add(dataAreaEnd, 0xA0), mload(add(sourceOffset, 0xA0))) // makerFeeAmount
+ mstore(add(dataAreaEnd, 0xC0), mload(add(sourceOffset, 0xC0))) // takerFeeAmount
+ mstore(add(dataAreaEnd, 0xE0), mload(add(sourceOffset, 0xE0))) // expirationTimeSeconds
+ mstore(add(dataAreaEnd, 0x100), mload(add(sourceOffset, 0x100))) // salt
+ mstore(add(dataAreaEnd, 0x120), mload(add(sourceOffset, 0x120))) // Offset to makerAssetProxyMetadata
+ mstore(add(dataAreaEnd, 0x140), mload(add(sourceOffset, 0x140))) // Offset to takerAssetProxyMetadata
+ dataAreaEnd := add(dataAreaEnd, 0x160)
+ sourceOffset := add(sourceOffset, 0x160)
// Write offset to <order.makerAssetProxyMetadata>
- mstore(add(dataAreaStart, mul(11, 0x20)), sub(dataAreaEnd, dataAreaStart))
+ mstore(add(dataAreaStart, mul(9, 0x20)), sub(dataAreaEnd, dataAreaStart))
// Calculate length of <order.makerAssetProxyMetadata>
arrayLenBytes := mload(sourceOffset)
@@ -183,7 +181,7 @@ contract MixinWrapperFunctions is
}
// Write offset to <order.takerAssetProxyMetadata>
- mstore(add(dataAreaStart, mul(12, 0x20)), sub(dataAreaEnd, dataAreaStart))
+ mstore(add(dataAreaStart, mul(10, 0x20)), sub(dataAreaEnd, dataAreaStart))
// Calculate length of <order.takerAssetProxyMetadata>
arrayLenBytes := mload(sourceOffset)
@@ -325,7 +323,7 @@ contract MixinWrapperFunctions is
for (uint256 i = 0; i < orders.length; i++) {
// Token being sold by taker must be the same for each order
- require(orders[i].takerTokenAddress == orders[0].takerTokenAddress);
+ require(areBytesEqual(orders[i].takerAssetData, orders[0].takerAssetData));
// Calculate the remaining amount of takerToken to sell
uint256 remainingTakerTokenFillAmount = safeSub(takerTokenFillAmount, totalFillResults.takerTokenFilledAmount);
@@ -364,7 +362,7 @@ contract MixinWrapperFunctions is
for (uint256 i = 0; i < orders.length; i++) {
// Token being sold by taker must be the same for each order
- require(orders[i].takerTokenAddress == orders[0].takerTokenAddress);
+ require(areBytesEqual(orders[i].takerAssetData, orders[0].takerAssetData));
// Calculate the remaining amount of takerToken to sell
uint256 remainingTakerTokenFillAmount = safeSub(takerTokenFillAmount, totalFillResults.takerTokenFilledAmount);
@@ -402,7 +400,7 @@ contract MixinWrapperFunctions is
for (uint256 i = 0; i < orders.length; i++) {
// Token being bought by taker must be the same for each order
- require(orders[i].makerTokenAddress == orders[0].makerTokenAddress);
+ require(areBytesEqual(orders[i].makerAssetData, orders[0].makerAssetData));
// Calculate the remaining amount of makerToken to buy
uint256 remainingMakerTokenFillAmount = safeSub(makerTokenFillAmount, totalFillResults.makerTokenFilledAmount);
@@ -449,7 +447,7 @@ contract MixinWrapperFunctions is
for (uint256 i = 0; i < orders.length; i++) {
// Token being bought by taker must be the same for each order
- require(orders[i].makerTokenAddress == orders[0].makerTokenAddress);
+ require(areBytesEqual(orders[i].makerAssetData, orders[0].makerAssetData));
// Calculate the remaining amount of makerToken to buy
uint256 remainingMakerTokenFillAmount = safeSub(makerTokenFillAmount, totalFillResults.makerTokenFilledAmount);
diff --git a/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol b/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol
index ed65463db..106536572 100644
--- a/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol
+++ b/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol
@@ -20,6 +20,37 @@ pragma solidity ^0.4.21;
contract LibBytes {
+ /// @dev Compares two byte arrays.
+ /// @param lhs First byte array to compare.
+ /// @param rhs Second byte array.
+ /// @return True if arrays are the same.
+ function areBytesEqual(bytes memory lhs, bytes memory rhs)
+ public
+ returns (bool equal)
+ {
+ assembly {
+ // Get the number of words occupied by <lhs>
+ let lenFullWords := div(add(mload(lhs), 0x1F), 0x20)
+
+ // Add 1 to the number of words, to account for the length field
+ lenFullWords := add(lenFullWords, 0x1)
+
+ // Verify equality word-by-word.
+ // Terminates early if there is a mismatch.
+ for {let i := 0} lt(i, lenFullWords) {i := add(i, 1)} {
+ let lhsWord := mload(add(lhs, mul(i, 0x20)))
+ let rhsWord := mload(add(rhs, mul(i, 0x20)))
+ equal := eq(lhsWord, rhsWord)
+ if eq(equal, 0) {
+ // Break
+ i := lenFullWords
+ }
+ }
+ }
+
+ return equal;
+ }
+
/// @dev Reads an address from a position in a byte array.
/// @param b Byte array containing an address.
/// @param index Index in byte array of address.
diff --git a/packages/contracts/src/utils/order_utils.ts b/packages/contracts/src/utils/order_utils.ts
index 052ae89d6..18892b4d4 100644
--- a/packages/contracts/src/utils/order_utils.ts
+++ b/packages/contracts/src/utils/order_utils.ts
@@ -26,8 +26,6 @@ export const orderUtils = {
const orderStruct = {
makerAddress: signedOrder.makerAddress,
takerAddress: signedOrder.takerAddress,
- makerTokenAddress: signedOrder.makerTokenAddress,
- takerTokenAddress: signedOrder.takerTokenAddress,
feeRecipientAddress: signedOrder.feeRecipientAddress,
makerTokenAmount: signedOrder.makerTokenAmount,
takerTokenAmount: signedOrder.takerTokenAmount,
@@ -45,8 +43,6 @@ export const orderUtils = {
'address exchangeAddress',
'address makerAddress',
'address takerAddress',
- 'address makerTokenAddress',
- 'address takerTokenAddress',
'address feeRecipientAddress',
'uint256 makerTokenAmount',
'uint256 takerTokenAmount',
@@ -61,8 +57,6 @@ export const orderUtils = {
order.exchangeAddress,
order.makerAddress,
order.takerAddress,
- order.makerTokenAddress,
- order.takerTokenAddress,
order.feeRecipientAddress,
order.makerTokenAmount,
order.takerTokenAmount,
diff --git a/packages/contracts/src/utils/types.ts b/packages/contracts/src/utils/types.ts
index f51dd5a1d..d692bed61 100644
--- a/packages/contracts/src/utils/types.ts
+++ b/packages/contracts/src/utils/types.ts
@@ -139,8 +139,6 @@ export interface SignedOrder extends UnsignedOrder {
export interface OrderStruct {
makerAddress: string;
takerAddress: string;
- makerTokenAddress: string;
- takerTokenAddress: string;
feeRecipientAddress: string;
makerTokenAmount: BigNumber;
takerTokenAmount: BigNumber;
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index 9e201a8e7..d3cafe316 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -78,6 +78,9 @@ describe('Exchange', () => {
new BigNumber('0x4040404040404040404040404040404040404040404040404040404040404040'),
];
+ let defaultMakerTokenAddress: string;
+ let defaultTakerTokenAddress: string;
+
let zeroEx: ZeroEx;
before(async () => {
@@ -176,12 +179,13 @@ describe('Exchange', () => {
});
exWrapper = new ExchangeWrapper(exchange, zeroEx);
+ defaultMakerTokenAddress = rep.address;
+ defaultTakerTokenAddress = dgd.address;
+
const defaultOrderParams = {
exchangeAddress: exchange.address,
makerAddress,
feeRecipientAddress,
- makerTokenAddress: rep.address,
- takerTokenAddress: dgd.address,
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
@@ -327,20 +331,20 @@ describe('Exchange', () => {
const takerFeePaid = signedOrder.takerFee
.times(makerTokenFilledAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.makerTokenAddress].minus(makerTokenFilledAmount),
+ expect(newBalances[makerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultMakerTokenAddress].minus(makerTokenFilledAmount),
);
- expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
+ expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultTakerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFeePaid),
);
- expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
+ expect(newBalances[takerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultTakerTokenAddress].minus(takerTokenFillAmount),
);
- expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.makerTokenAddress].add(makerTokenFilledAmount),
+ expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultMakerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFeePaid),
@@ -380,20 +384,20 @@ describe('Exchange', () => {
const takerFeePaid = signedOrder.takerFee
.times(makerTokenFilledAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.makerTokenAddress].minus(makerTokenFilledAmount),
+ expect(newBalances[makerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultMakerTokenAddress].minus(makerTokenFilledAmount),
);
- expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
+ expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultTakerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFeePaid),
);
- expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
+ expect(newBalances[takerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultTakerTokenAddress].minus(takerTokenFillAmount),
);
- expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.makerTokenAddress].add(makerTokenFilledAmount),
+ expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultMakerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFeePaid),
@@ -433,20 +437,20 @@ describe('Exchange', () => {
const takerFeePaid = signedOrder.takerFee
.times(makerTokenFilledAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.makerTokenAddress].minus(makerTokenFilledAmount),
+ expect(newBalances[makerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultMakerTokenAddress].minus(makerTokenFilledAmount),
);
- expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
+ expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultTakerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFeePaid),
);
- expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
+ expect(newBalances[takerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultTakerTokenAddress].minus(takerTokenFillAmount),
);
- expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.makerTokenAddress].add(makerTokenFilledAmount),
+ expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultMakerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFeePaid),
@@ -488,20 +492,20 @@ describe('Exchange', () => {
const takerFeePaid = signedOrder.takerFee
.times(makerTokenFilledAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.makerTokenAddress].minus(makerTokenFilledAmount),
+ expect(newBalances[makerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultMakerTokenAddress].minus(makerTokenFilledAmount),
);
- expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
+ expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultTakerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFeePaid),
);
- expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
+ expect(newBalances[takerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultTakerTokenAddress].minus(takerTokenFillAmount),
);
- expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.makerTokenAddress].add(makerTokenFilledAmount),
+ expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultMakerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFeePaid),
@@ -524,20 +528,20 @@ describe('Exchange', () => {
);
const newBalances = await dmyBalances.getAsync();
- expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.makerTokenAddress].minus(signedOrder.makerTokenAmount),
+ expect(newBalances[makerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultMakerTokenAddress].minus(signedOrder.makerTokenAmount),
);
- expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.takerTokenAddress].add(signedOrder.takerTokenAmount),
+ expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultTakerTokenAddress].add(signedOrder.takerTokenAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(signedOrder.makerFee),
);
- expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.takerTokenAddress].minus(signedOrder.takerTokenAmount),
+ expect(newBalances[takerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultTakerTokenAddress].minus(signedOrder.takerTokenAmount),
);
- expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.makerTokenAddress].add(signedOrder.makerTokenAmount),
+ expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultMakerTokenAddress].add(signedOrder.makerTokenAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(signedOrder.takerFee),
@@ -564,8 +568,8 @@ describe('Exchange', () => {
expect(signedOrder.makerAddress).to.be.equal(logArgs.makerAddress);
expect(takerAddress).to.be.equal(logArgs.takerAddress);
expect(signedOrder.feeRecipientAddress).to.be.equal(logArgs.feeRecipientAddress);
- expect(signedOrder.makerTokenAddress).to.be.equal(logArgs.makerTokenAddress);
- expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerTokenAddress);
+ expect(signedOrder.makerAssetData).to.be.equal(logArgs.makerAssetData);
+ expect(signedOrder.takerAssetData).to.be.equal(logArgs.takerAssetData);
expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.makerTokenFilledAmount);
expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.takerTokenFilledAmount);
expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.makerFeePaid);
@@ -593,8 +597,8 @@ describe('Exchange', () => {
expect(signedOrder.makerAddress).to.be.equal(logArgs.makerAddress);
expect(takerAddress).to.be.equal(logArgs.takerAddress);
expect(signedOrder.feeRecipientAddress).to.be.equal(logArgs.feeRecipientAddress);
- expect(signedOrder.makerTokenAddress).to.be.equal(logArgs.makerTokenAddress);
- expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerTokenAddress);
+ expect(signedOrder.makerAssetData).to.be.equal(logArgs.makerAssetData);
+ expect(signedOrder.takerAssetData).to.be.equal(logArgs.takerAssetData);
expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.makerTokenFilledAmount);
expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.takerTokenFilledAmount);
expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.makerFeePaid);
@@ -767,8 +771,8 @@ describe('Exchange', () => {
expect(signedOrder.makerAddress).to.be.equal(logArgs.makerAddress);
expect(signedOrder.feeRecipientAddress).to.be.equal(logArgs.feeRecipientAddress);
- expect(signedOrder.makerTokenAddress).to.be.equal(logArgs.makerTokenAddress);
- expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerTokenAddress);
+ expect(signedOrder.makerAssetData).to.be.equal(logArgs.makerAssetData);
+ expect(signedOrder.takerAssetData).to.be.equal(logArgs.takerAssetData);
expect(orderUtils.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash);
});
@@ -850,20 +854,20 @@ describe('Exchange', () => {
const fillTakerTokenAmount = signedOrders[2].takerTokenAmount.add(signedOrders[3].takerTokenAmount);
const makerFee = signedOrders[2].makerFee.add(signedOrders[3].makerFee);
const takerFee = signedOrders[2].takerFee.add(signedOrders[3].takerFee);
- expect(newBalances[makerAddress][signedOrders[3].makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[3].makerTokenAddress].minus(fillMakerTokenAmount),
+ expect(newBalances[makerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultMakerTokenAddress].minus(fillMakerTokenAmount),
);
- expect(newBalances[makerAddress][signedOrders[3].takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[3].takerTokenAddress].add(fillTakerTokenAmount),
+ expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultTakerTokenAddress].add(fillTakerTokenAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFee),
);
- expect(newBalances[takerAddress][signedOrders[3].takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[3].takerTokenAddress].minus(fillTakerTokenAmount),
+ expect(newBalances[takerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultTakerTokenAddress].minus(fillTakerTokenAmount),
);
- expect(newBalances[takerAddress][signedOrders[3].makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[3].makerTokenAddress].add(fillMakerTokenAmount),
+ expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultMakerTokenAddress].add(fillMakerTokenAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFee),
@@ -880,8 +884,6 @@ describe('Exchange', () => {
const makerTokenId = erc721MakerTokenIds[0];
const takerTokenId = erc721TakerTokenIds[1];
signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: erc721Token.address,
- takerTokenAddress: erc721Token.address,
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(1),
makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
@@ -907,8 +909,6 @@ describe('Exchange', () => {
const makerTokenId = erc721TakerTokenIds[0];
const takerTokenId = erc721TakerTokenIds[1];
signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: erc721Token.address,
- takerTokenAddress: erc721Token.address,
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(1),
makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
@@ -931,8 +931,6 @@ describe('Exchange', () => {
const makerTokenId = erc721MakerTokenIds[0];
const takerTokenId = erc721MakerTokenIds[1];
signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: erc721Token.address,
- takerTokenAddress: erc721Token.address,
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(1),
makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
@@ -955,8 +953,6 @@ describe('Exchange', () => {
const makerTokenId = erc721MakerTokenIds[0];
const takerTokenId = erc721TakerTokenIds[0];
signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: erc721Token.address,
- takerTokenAddress: erc721Token.address,
makerTokenAmount: new BigNumber(2),
takerTokenAmount: new BigNumber(1),
makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
@@ -979,8 +975,6 @@ describe('Exchange', () => {
const makerTokenId = erc721MakerTokenIds[0];
const takerTokenId = erc721TakerTokenIds[0];
signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: erc721Token.address,
- takerTokenAddress: erc721Token.address,
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(500),
makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
@@ -1003,8 +997,6 @@ describe('Exchange', () => {
const makerTokenId = erc721MakerTokenIds[0];
const takerTokenId = erc721TakerTokenIds[0];
signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: erc721Token.address,
- takerTokenAddress: erc721Token.address,
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(0),
makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
@@ -1026,12 +1018,10 @@ describe('Exchange', () => {
// Construct Exchange parameters
const makerTokenId = erc721MakerTokenIds[0];
signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: erc721Token.address,
- takerTokenAddress: dgd.address,
makerTokenAmount: new BigNumber(1),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
- takerAssetData: encodeERC20ProxyData(dgd.address),
+ takerAssetData: encodeERC20ProxyData(defaultTakerTokenAddress),
});
// Verify pre-conditions
const initialOwnerMakerToken = await erc721Token.ownerOf.callAsync(makerTokenId);
@@ -1045,11 +1035,11 @@ describe('Exchange', () => {
expect(newOwnerMakerToken).to.be.bignumber.equal(takerAddress);
// Verify ERC20 tokens were transferred from Taker to Maker & fees were paid correctly
const newBalances = await dmyBalances.getAsync();
- expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
+ expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultTakerTokenAddress].add(takerTokenFillAmount),
);
- expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
+ expect(newBalances[takerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultTakerTokenAddress].minus(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(signedOrder.makerFee),
@@ -1066,12 +1056,10 @@ describe('Exchange', () => {
// Construct Exchange parameters
const takerTokenId = erc721TakerTokenIds[0];
signedOrder = orderFactory.newSignedOrder({
- takerTokenAddress: erc721Token.address,
- makerTokenAddress: dgd.address,
takerTokenAmount: new BigNumber(1),
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerAssetData: encodeERC721ProxyData(erc721Token.address, takerTokenId),
- makerAssetData: encodeERC20ProxyData(dgd.address),
+ makerAssetData: encodeERC20ProxyData(defaultMakerTokenAddress),
});
// Verify pre-conditions
const initialOwnerTakerToken = await erc721Token.ownerOf.callAsync(takerTokenId);
@@ -1085,11 +1073,11 @@ describe('Exchange', () => {
expect(newOwnerTakerToken).to.be.bignumber.equal(makerAddress);
// Verify ERC20 tokens were transferred from Maker to Taker & fees were paid correctly
const newBalances = await dmyBalances.getAsync();
- expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.makerTokenAddress].add(signedOrder.makerTokenAmount),
+ expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultMakerTokenAddress].add(signedOrder.makerTokenAmount),
);
- expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.makerTokenAddress].minus(signedOrder.makerTokenAmount),
+ expect(newBalances[makerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultMakerTokenAddress].minus(signedOrder.makerTokenAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(signedOrder.makerFee),
diff --git a/packages/contracts/test/exchange/helpers.ts b/packages/contracts/test/exchange/helpers.ts
index c447c0e01..92fce8e47 100644
--- a/packages/contracts/test/exchange/helpers.ts
+++ b/packages/contracts/test/exchange/helpers.ts
@@ -56,8 +56,6 @@ describe('Exchange', () => {
exchangeAddress: exchange.address,
makerAddress,
feeRecipientAddress,
- makerTokenAddress: rep.address,
- takerTokenAddress: dgd.address,
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index 83915d07d..caff990d6 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -55,6 +55,9 @@ describe('Exchange', () => {
const erc721MakerTokenId = new BigNumber('0x1010101010101010101010101010101010101010101010101010101010101010');
const erc721TakerTokenId = new BigNumber('0x3030303030303030303030303030303030303030303030303030303030303030');
+ let defaultMakerTokenAddress: string;
+ let defaultTakerTokenAddress: string;
+
before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
tokenOwner = accounts[0];
@@ -123,12 +126,12 @@ describe('Exchange', () => {
const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID });
exWrapper = new ExchangeWrapper(exchange, zeroEx);
+ defaultMakerTokenAddress = rep.address;
+ defaultTakerTokenAddress = dgd.address;
const defaultOrderParams = {
exchangeAddress: exchange.address,
makerAddress,
feeRecipientAddress,
- makerTokenAddress: rep.address,
- takerTokenAddress: dgd.address,
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
@@ -192,20 +195,20 @@ describe('Exchange', () => {
const takerFee = signedOrder.takerFee
.times(makerTokenFilledAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.makerTokenAddress].minus(makerTokenFilledAmount),
+ expect(newBalances[makerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultMakerTokenAddress].minus(makerTokenFilledAmount),
);
- expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
+ expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultTakerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFee),
);
- expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
+ expect(newBalances[takerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultTakerTokenAddress].minus(takerTokenFillAmount),
);
- expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.makerTokenAddress].add(makerTokenFilledAmount),
+ expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultMakerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFee),
@@ -260,20 +263,20 @@ describe('Exchange', () => {
const takerFee = signedOrder.takerFee
.times(makerTokenFilledAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.makerTokenAddress].minus(makerTokenFilledAmount),
+ expect(newBalances[makerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultMakerTokenAddress].minus(makerTokenFilledAmount),
);
- expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
+ expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultTakerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFee),
);
- expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
+ expect(newBalances[takerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultTakerTokenAddress].minus(takerTokenFillAmount),
);
- expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.makerTokenAddress].add(makerTokenFilledAmount),
+ expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultMakerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFee),
@@ -334,7 +337,6 @@ describe('Exchange', () => {
it('should not change balances if makerTokenAddress is ZRX, makerTokenAmount + makerFee > maker balance', async () => {
const makerZRXBalance = new BigNumber(balances[makerAddress][zrx.address]);
const signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: zrx.address,
makerTokenAmount: makerZRXBalance,
makerFee: new BigNumber(1),
makerAssetData: encodeERC20ProxyData(zrx.address),
@@ -347,7 +349,6 @@ describe('Exchange', () => {
it('should not change balances if makerTokenAddress is ZRX, makerTokenAmount + makerFee > maker allowance', async () => {
const makerZRXAllowance = await zrx.allowance.callAsync(makerAddress, erc20TransferProxy.address);
const signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: zrx.address,
makerTokenAmount: new BigNumber(makerZRXAllowance),
makerFee: new BigNumber(1),
makerAssetData: encodeERC20ProxyData(zrx.address),
@@ -360,7 +361,6 @@ describe('Exchange', () => {
it('should not change balances if takerTokenAddress is ZRX, takerTokenAmount + takerFee > taker balance', async () => {
const takerZRXBalance = new BigNumber(balances[takerAddress][zrx.address]);
const signedOrder = orderFactory.newSignedOrder({
- takerTokenAddress: zrx.address,
takerTokenAmount: takerZRXBalance,
takerFee: new BigNumber(1),
takerAssetData: encodeERC20ProxyData(zrx.address),
@@ -373,7 +373,6 @@ describe('Exchange', () => {
it('should not change balances if takerTokenAddress is ZRX, takerTokenAmount + takerFee > taker allowance', async () => {
const takerZRXAllowance = await zrx.allowance.callAsync(takerAddress, erc20TransferProxy.address);
const signedOrder = orderFactory.newSignedOrder({
- takerTokenAddress: zrx.address,
takerTokenAmount: new BigNumber(takerZRXAllowance),
takerFee: new BigNumber(1),
takerAssetData: encodeERC20ProxyData(zrx.address),
@@ -388,8 +387,6 @@ describe('Exchange', () => {
const makerTokenId = erc721MakerTokenId;
const takerTokenId = erc721TakerTokenId;
const signedOrder = orderFactory.newSignedOrder({
- makerTokenAddress: erc721Token.address,
- takerTokenAddress: erc721Token.address,
makerTokenAmount: new BigNumber(1),
takerTokenAmount: new BigNumber(1),
makerAssetData: encodeERC721ProxyData(erc721Token.address, makerTokenId),
@@ -640,20 +637,20 @@ describe('Exchange', () => {
);
const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2));
const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2));
- expect(newBalances[makerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[0].makerTokenAddress].minus(makerTokenFilledAmount),
+ expect(newBalances[makerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultMakerTokenAddress].minus(makerTokenFilledAmount),
);
- expect(newBalances[makerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[0].takerTokenAddress].add(takerTokenFillAmount),
+ expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultTakerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFee),
);
- expect(newBalances[takerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[0].takerTokenAddress].minus(takerTokenFillAmount),
+ expect(newBalances[takerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultTakerTokenAddress].minus(takerTokenFillAmount),
);
- expect(newBalances[takerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[0].makerTokenAddress].add(makerTokenFilledAmount),
+ expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultMakerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFee),
@@ -666,20 +663,20 @@ describe('Exchange', () => {
it('should fill all signedOrders if cannot fill entire takerTokenFillAmount', async () => {
const takerTokenFillAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
_.forEach(signedOrders, signedOrder => {
- balances[makerAddress][signedOrder.makerTokenAddress] = balances[makerAddress][
- signedOrder.makerTokenAddress
+ balances[makerAddress][defaultMakerTokenAddress] = balances[makerAddress][
+ defaultMakerTokenAddress
].minus(signedOrder.makerTokenAmount);
- balances[makerAddress][signedOrder.takerTokenAddress] = balances[makerAddress][
- signedOrder.takerTokenAddress
+ balances[makerAddress][defaultTakerTokenAddress] = balances[makerAddress][
+ defaultTakerTokenAddress
].add(signedOrder.takerTokenAmount);
balances[makerAddress][zrx.address] = balances[makerAddress][zrx.address].minus(
signedOrder.makerFee,
);
- balances[takerAddress][signedOrder.makerTokenAddress] = balances[takerAddress][
- signedOrder.makerTokenAddress
+ balances[takerAddress][defaultMakerTokenAddress] = balances[takerAddress][
+ defaultMakerTokenAddress
].add(signedOrder.makerTokenAmount);
- balances[takerAddress][signedOrder.takerTokenAddress] = balances[takerAddress][
- signedOrder.takerTokenAddress
+ balances[takerAddress][defaultTakerTokenAddress] = balances[takerAddress][
+ defaultTakerTokenAddress
].minus(signedOrder.takerTokenAmount);
balances[takerAddress][zrx.address] = balances[takerAddress][zrx.address].minus(
signedOrder.takerFee,
@@ -699,7 +696,7 @@ describe('Exchange', () => {
it('should throw when an signedOrder does not use the same takerTokenAddress', async () => {
signedOrders = [
orderFactory.newSignedOrder(),
- orderFactory.newSignedOrder({ takerTokenAddress: zrx.address }),
+ orderFactory.newSignedOrder({ takerAssetData: encodeERC20ProxyData(zrx.address) }),
orderFactory.newSignedOrder(),
];
@@ -727,20 +724,20 @@ describe('Exchange', () => {
);
const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2));
const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2));
- expect(newBalances[makerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[0].makerTokenAddress].minus(makerTokenFilledAmount),
+ expect(newBalances[makerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultMakerTokenAddress].minus(makerTokenFilledAmount),
);
- expect(newBalances[makerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[0].takerTokenAddress].add(takerTokenFillAmount),
+ expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultTakerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFee),
);
- expect(newBalances[takerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[0].takerTokenAddress].minus(takerTokenFillAmount),
+ expect(newBalances[takerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultTakerTokenAddress].minus(takerTokenFillAmount),
);
- expect(newBalances[takerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[0].makerTokenAddress].add(makerTokenFilledAmount),
+ expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultMakerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFee),
@@ -753,20 +750,20 @@ describe('Exchange', () => {
it('should fill all signedOrders if cannot fill entire takerTokenFillAmount', async () => {
const takerTokenFillAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
_.forEach(signedOrders, signedOrder => {
- balances[makerAddress][signedOrder.makerTokenAddress] = balances[makerAddress][
- signedOrder.makerTokenAddress
+ balances[makerAddress][defaultMakerTokenAddress] = balances[makerAddress][
+ defaultMakerTokenAddress
].minus(signedOrder.makerTokenAmount);
- balances[makerAddress][signedOrder.takerTokenAddress] = balances[makerAddress][
- signedOrder.takerTokenAddress
+ balances[makerAddress][defaultTakerTokenAddress] = balances[makerAddress][
+ defaultTakerTokenAddress
].add(signedOrder.takerTokenAmount);
balances[makerAddress][zrx.address] = balances[makerAddress][zrx.address].minus(
signedOrder.makerFee,
);
- balances[takerAddress][signedOrder.makerTokenAddress] = balances[takerAddress][
- signedOrder.makerTokenAddress
+ balances[takerAddress][defaultMakerTokenAddress] = balances[takerAddress][
+ defaultMakerTokenAddress
].add(signedOrder.makerTokenAmount);
- balances[takerAddress][signedOrder.takerTokenAddress] = balances[takerAddress][
- signedOrder.takerTokenAddress
+ balances[takerAddress][defaultTakerTokenAddress] = balances[takerAddress][
+ defaultTakerTokenAddress
].minus(signedOrder.takerTokenAmount);
balances[takerAddress][zrx.address] = balances[takerAddress][zrx.address].minus(
signedOrder.takerFee,
@@ -786,7 +783,7 @@ describe('Exchange', () => {
it('should throw when a signedOrder does not use the same takerTokenAddress', async () => {
signedOrders = [
orderFactory.newSignedOrder(),
- orderFactory.newSignedOrder({ takerTokenAddress: zrx.address }),
+ orderFactory.newSignedOrder({ takerAssetData: encodeERC20ProxyData(zrx.address) }),
orderFactory.newSignedOrder(),
];
@@ -814,20 +811,20 @@ describe('Exchange', () => {
);
const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2));
const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2));
- expect(newBalances[makerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[0].makerTokenAddress].minus(makerTokenFillAmount),
+ expect(newBalances[makerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultMakerTokenAddress].minus(makerTokenFillAmount),
);
- expect(newBalances[makerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[0].takerTokenAddress].add(makerAmountBought),
+ expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultTakerTokenAddress].add(makerAmountBought),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFee),
);
- expect(newBalances[takerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[0].takerTokenAddress].minus(makerAmountBought),
+ expect(newBalances[takerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultTakerTokenAddress].minus(makerAmountBought),
);
- expect(newBalances[takerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[0].makerTokenAddress].add(makerTokenFillAmount),
+ expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultMakerTokenAddress].add(makerTokenFillAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFee),
@@ -840,20 +837,20 @@ describe('Exchange', () => {
it('should fill all signedOrders if cannot fill entire makerTokenFillAmount', async () => {
const makerTokenFillAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
_.forEach(signedOrders, signedOrder => {
- balances[makerAddress][signedOrder.makerTokenAddress] = balances[makerAddress][
- signedOrder.makerTokenAddress
+ balances[makerAddress][defaultMakerTokenAddress] = balances[makerAddress][
+ defaultMakerTokenAddress
].minus(signedOrder.makerTokenAmount);
- balances[makerAddress][signedOrder.takerTokenAddress] = balances[makerAddress][
- signedOrder.takerTokenAddress
+ balances[makerAddress][defaultTakerTokenAddress] = balances[makerAddress][
+ defaultTakerTokenAddress
].add(signedOrder.takerTokenAmount);
balances[makerAddress][zrx.address] = balances[makerAddress][zrx.address].minus(
signedOrder.makerFee,
);
- balances[takerAddress][signedOrder.makerTokenAddress] = balances[takerAddress][
- signedOrder.makerTokenAddress
+ balances[takerAddress][defaultMakerTokenAddress] = balances[takerAddress][
+ defaultMakerTokenAddress
].add(signedOrder.makerTokenAmount);
- balances[takerAddress][signedOrder.takerTokenAddress] = balances[takerAddress][
- signedOrder.takerTokenAddress
+ balances[takerAddress][defaultTakerTokenAddress] = balances[takerAddress][
+ defaultTakerTokenAddress
].minus(signedOrder.takerTokenAmount);
balances[takerAddress][zrx.address] = balances[takerAddress][zrx.address].minus(
signedOrder.takerFee,
@@ -873,7 +870,7 @@ describe('Exchange', () => {
it('should throw when an signedOrder does not use the same makerTokenAddress', async () => {
signedOrders = [
orderFactory.newSignedOrder(),
- orderFactory.newSignedOrder({ makerTokenAddress: zrx.address }),
+ orderFactory.newSignedOrder({ makerAssetData: encodeERC20ProxyData(zrx.address) }),
orderFactory.newSignedOrder(),
];
@@ -901,20 +898,20 @@ describe('Exchange', () => {
);
const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2));
const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2));
- expect(newBalances[makerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[0].makerTokenAddress].minus(makerTokenFillAmount),
+ expect(newBalances[makerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultMakerTokenAddress].minus(makerTokenFillAmount),
);
- expect(newBalances[makerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[0].takerTokenAddress].add(makerAmountBought),
+ expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][defaultTakerTokenAddress].add(makerAmountBought),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFee),
);
- expect(newBalances[takerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[0].takerTokenAddress].minus(makerAmountBought),
+ expect(newBalances[takerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultTakerTokenAddress].minus(makerAmountBought),
);
- expect(newBalances[takerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[0].makerTokenAddress].add(makerTokenFillAmount),
+ expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][defaultMakerTokenAddress].add(makerTokenFillAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFee),
@@ -927,20 +924,20 @@ describe('Exchange', () => {
it('should fill all signedOrders if cannot fill entire takerTokenFillAmount', async () => {
const takerTokenFillAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
_.forEach(signedOrders, signedOrder => {
- balances[makerAddress][signedOrder.makerTokenAddress] = balances[makerAddress][
- signedOrder.makerTokenAddress
+ balances[makerAddress][defaultMakerTokenAddress] = balances[makerAddress][
+ defaultMakerTokenAddress
].minus(signedOrder.makerTokenAmount);
- balances[makerAddress][signedOrder.takerTokenAddress] = balances[makerAddress][
- signedOrder.takerTokenAddress
+ balances[makerAddress][defaultTakerTokenAddress] = balances[makerAddress][
+ defaultTakerTokenAddress
].add(signedOrder.takerTokenAmount);
balances[makerAddress][zrx.address] = balances[makerAddress][zrx.address].minus(
signedOrder.makerFee,
);
- balances[takerAddress][signedOrder.makerTokenAddress] = balances[takerAddress][
- signedOrder.makerTokenAddress
+ balances[takerAddress][defaultMakerTokenAddress] = balances[takerAddress][
+ defaultMakerTokenAddress
].add(signedOrder.makerTokenAmount);
- balances[takerAddress][signedOrder.takerTokenAddress] = balances[takerAddress][
- signedOrder.takerTokenAddress
+ balances[takerAddress][defaultTakerTokenAddress] = balances[takerAddress][
+ defaultTakerTokenAddress
].minus(signedOrder.takerTokenAmount);
balances[takerAddress][zrx.address] = balances[takerAddress][zrx.address].minus(
signedOrder.takerFee,
@@ -960,7 +957,7 @@ describe('Exchange', () => {
it('should throw when a signedOrder does not use the same makerTokenAddress', async () => {
signedOrders = [
orderFactory.newSignedOrder(),
- orderFactory.newSignedOrder({ makerTokenAddress: zrx.address }),
+ orderFactory.newSignedOrder({ makerAssetData: encodeERC20ProxyData(zrx.address) }),
orderFactory.newSignedOrder(),
];