aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/exchange/wrapper.ts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-03-08 08:07:36 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-21 04:56:16 +0800
commit6bfc02d79d189ee6487a74ec095bc7d12314e6a9 (patch)
tree02bb5618a11c229c7bea8bc56b84150a3b63015a /packages/contracts/test/exchange/wrapper.ts
parent7b166837d3ded48874042347d356dc7e4e02f2c1 (diff)
downloaddexon-sol-tools-6bfc02d79d189ee6487a74ec095bc7d12314e6a9.tar
dexon-sol-tools-6bfc02d79d189ee6487a74ec095bc7d12314e6a9.tar.gz
dexon-sol-tools-6bfc02d79d189ee6487a74ec095bc7d12314e6a9.tar.bz2
dexon-sol-tools-6bfc02d79d189ee6487a74ec095bc7d12314e6a9.tar.lz
dexon-sol-tools-6bfc02d79d189ee6487a74ec095bc7d12314e6a9.tar.xz
dexon-sol-tools-6bfc02d79d189ee6487a74ec095bc7d12314e6a9.tar.zst
dexon-sol-tools-6bfc02d79d189ee6487a74ec095bc7d12314e6a9.zip
Modify tests to work with new utils
Diffstat (limited to 'packages/contracts/test/exchange/wrapper.ts')
-rw-r--r--packages/contracts/test/exchange/wrapper.ts258
1 files changed, 145 insertions, 113 deletions
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index 2a803e2ac..182578f42 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -1,4 +1,4 @@
-import { SignedOrder, ZeroEx } from '0x.js';
+import { ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -19,7 +19,7 @@ import { Balances } from '../../src/utils/balances';
import { constants } from '../../src/utils/constants';
import { ExchangeWrapper } from '../../src/utils/exchange_wrapper';
import { OrderFactory } from '../../src/utils/order_factory';
-import { BalancesByOwner, ContractName } from '../../src/utils/types';
+import { BalancesByOwner, ContractName, SignedOrder } from '../../src/utils/types';
import { chaiSetup } from '../utils/chai_setup';
import { deployer } from '../utils/deployer';
import { provider, web3Wrapper } from '../utils/web3_wrapper';
@@ -29,10 +29,10 @@ const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('Exchange', () => {
- let maker: string;
+ let makerAddress: string;
let tokenOwner: string;
- let taker: string;
- let feeRecipient: string;
+ let takerAddress: string;
+ let feeRecipientAddress: string;
const INIT_BAL = ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18);
const INIT_ALLOW = ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18);
@@ -53,7 +53,7 @@ describe('Exchange', () => {
before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
tokenOwner = accounts[0];
- [maker, taker, feeRecipient] = accounts;
+ [makerAddress, takerAddress, feeRecipientAddress] = accounts;
const [repInstance, dgdInstance, zrxInstance] = await Promise.all([
deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
@@ -80,32 +80,33 @@ describe('Exchange', () => {
exWrapper = new ExchangeWrapper(exchange, zeroEx);
const defaultOrderParams = {
- exchangeContractAddress: exchange.address,
- maker,
- feeRecipient,
+ 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),
- takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
+ makerFeeAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
+ takerFeeAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
};
- orderFactory = new OrderFactory(zeroEx, defaultOrderParams);
- dmyBalances = new Balances([rep, dgd, zrx], [maker, taker, feeRecipient]);
+ const secretKey = constants.TESTRPC_ACCOUNTS[0].secretKey;
+ orderFactory = new OrderFactory(secretKey, defaultOrderParams);
+ dmyBalances = new Balances([rep, dgd, zrx], [makerAddress, takerAddress, feeRecipientAddress]);
await Promise.all([
- rep.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: maker }),
- rep.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: taker }),
- rep.setBalance.sendTransactionAsync(maker, INIT_BAL, { from: tokenOwner }),
- rep.setBalance.sendTransactionAsync(taker, INIT_BAL, { from: tokenOwner }),
- dgd.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: maker }),
- dgd.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: taker }),
- dgd.setBalance.sendTransactionAsync(maker, INIT_BAL, { from: tokenOwner }),
- dgd.setBalance.sendTransactionAsync(taker, INIT_BAL, { from: tokenOwner }),
- zrx.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: maker }),
- zrx.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: taker }),
- zrx.setBalance.sendTransactionAsync(maker, INIT_BAL, { from: tokenOwner }),
- zrx.setBalance.sendTransactionAsync(taker, INIT_BAL, { from: tokenOwner }),
+ rep.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: makerAddress }),
+ rep.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: takerAddress }),
+ rep.setBalance.sendTransactionAsync(makerAddress, INIT_BAL, { from: tokenOwner }),
+ rep.setBalance.sendTransactionAsync(takerAddress, INIT_BAL, { from: tokenOwner }),
+ dgd.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: makerAddress }),
+ dgd.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: takerAddress }),
+ dgd.setBalance.sendTransactionAsync(makerAddress, INIT_BAL, { from: tokenOwner }),
+ dgd.setBalance.sendTransactionAsync(takerAddress, INIT_BAL, { from: tokenOwner }),
+ zrx.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: makerAddress }),
+ zrx.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: takerAddress }),
+ zrx.setBalance.sendTransactionAsync(makerAddress, INIT_BAL, { from: tokenOwner }),
+ zrx.setBalance.sendTransactionAsync(takerAddress, INIT_BAL, { from: tokenOwner }),
]);
});
beforeEach(async () => {
@@ -120,12 +121,12 @@ describe('Exchange', () => {
});
it('should transfer the correct amounts', async () => {
- const signedOrder = await orderFactory.newSignedOrderAsync({
+ const signedOrder = orderFactory.newSignedOrder({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
- await exWrapper.fillOrKillOrderAsync(signedOrder, taker, {
+ await exWrapper.fillOrKillOrderAsync(signedOrder, takerAddress, {
takerTokenFillAmount,
});
@@ -134,59 +135,66 @@ describe('Exchange', () => {
const makerTokenFillAmount = takerTokenFillAmount
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
- const makerFee = signedOrder.makerFee
+ const makerFeeAmount = signedOrder.makerFeeAmount
.times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- const takerFee = signedOrder.takerFee
+ const takerFeeAmount = signedOrder.takerFeeAmount
.times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrder.makerTokenAddress].minus(makerTokenFillAmount),
+ expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][signedOrder.makerTokenAddress].minus(makerTokenFillAmount),
);
- expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
+ expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
);
- expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(balances[maker][zrx.address].minus(makerFee));
- expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
+ expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
+ balances[makerAddress][zrx.address].minus(makerFeeAmount),
);
- expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrder.makerTokenAddress].add(makerTokenFillAmount),
+ expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
);
- expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(balances[taker][zrx.address].minus(takerFee));
- expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
- balances[feeRecipient][zrx.address].add(makerFee.add(takerFee)),
+ expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][signedOrder.makerTokenAddress].add(makerTokenFillAmount),
+ );
+ expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
+ balances[takerAddress][zrx.address].minus(takerFeeAmount),
+ );
+ expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipientAddress][zrx.address].add(makerFeeAmount.add(takerFeeAmount)),
);
});
it('should throw if an signedOrder is expired', async () => {
- const signedOrder = await orderFactory.newSignedOrderAsync({
- expirationUnixTimestampSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
+ const signedOrder = orderFactory.newSignedOrder({
+ expirationTimeSeconds: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
});
- return expect(exWrapper.fillOrKillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
+ return expect(exWrapper.fillOrKillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
it('should throw if entire takerTokenFillAmount not filled', async () => {
- const signedOrder = await orderFactory.newSignedOrderAsync();
+ const signedOrder = orderFactory.newSignedOrder();
- const from = taker;
- await exWrapper.fillOrderAsync(signedOrder, from, {
+ await exWrapper.fillOrderAsync(signedOrder, takerAddress, {
takerTokenFillAmount: signedOrder.takerTokenAmount.div(2),
});
- return expect(exWrapper.fillOrKillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
+ return expect(exWrapper.fillOrKillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
+ constants.REVERT,
+ );
});
});
describe('batch functions', () => {
let signedOrders: SignedOrder[];
beforeEach(async () => {
- signedOrders = await Promise.all([
- orderFactory.newSignedOrderAsync(),
- orderFactory.newSignedOrderAsync(),
- orderFactory.newSignedOrderAsync(),
- ]);
+ signedOrders = [
+ orderFactory.newSignedOrder(),
+ orderFactory.newSignedOrder(),
+ orderFactory.newSignedOrder(),
+ ];
balances = await dmyBalances.getAsync();
});
@@ -200,25 +208,33 @@ describe('Exchange', () => {
const makerTokenFillAmount = takerTokenFillAmount
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
- const makerFee = signedOrder.makerFee
+ const makerFeeAmount = signedOrder.makerFeeAmount
.times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- const takerFee = signedOrder.takerFee
+ const takerFeeAmount = signedOrder.takerFeeAmount
.times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
takerTokenFillAmounts.push(takerTokenFillAmount);
- balances[maker][makerTokenAddress] = balances[maker][makerTokenAddress].minus(makerTokenFillAmount);
- balances[maker][takerTokenAddress] = balances[maker][takerTokenAddress].add(takerTokenFillAmount);
- balances[maker][zrx.address] = balances[maker][zrx.address].minus(makerFee);
- balances[taker][makerTokenAddress] = balances[taker][makerTokenAddress].add(makerTokenFillAmount);
- balances[taker][takerTokenAddress] = balances[taker][takerTokenAddress].minus(takerTokenFillAmount);
- balances[taker][zrx.address] = balances[taker][zrx.address].minus(takerFee);
- balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
- makerFee.add(takerFee),
+ balances[makerAddress][makerTokenAddress] = balances[makerAddress][makerTokenAddress].minus(
+ makerTokenFillAmount,
+ );
+ balances[makerAddress][takerTokenAddress] = balances[makerAddress][takerTokenAddress].add(
+ takerTokenFillAmount,
+ );
+ balances[makerAddress][zrx.address] = balances[makerAddress][zrx.address].minus(makerFeeAmount);
+ balances[takerAddress][makerTokenAddress] = balances[takerAddress][makerTokenAddress].add(
+ makerTokenFillAmount,
+ );
+ balances[takerAddress][takerTokenAddress] = balances[takerAddress][takerTokenAddress].minus(
+ takerTokenFillAmount,
+ );
+ balances[takerAddress][zrx.address] = balances[takerAddress][zrx.address].minus(takerFeeAmount);
+ balances[feeRecipientAddress][zrx.address] = balances[feeRecipientAddress][zrx.address].add(
+ makerFeeAmount.add(takerFeeAmount),
);
});
- await exWrapper.batchFillOrdersAsync(signedOrders, taker, {
+ await exWrapper.batchFillOrdersAsync(signedOrders, takerAddress, {
takerTokenFillAmounts,
});
@@ -237,25 +253,33 @@ describe('Exchange', () => {
const makerTokenFillAmount = takerTokenFillAmount
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
- const makerFee = signedOrder.makerFee
+ const makerFee = signedOrder.makerFeeAmount
.times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- const takerFee = signedOrder.takerFee
+ const takerFee = signedOrder.takerFeeAmount
.times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
takerTokenFillAmounts.push(takerTokenFillAmount);
- balances[maker][makerTokenAddress] = balances[maker][makerTokenAddress].minus(makerTokenFillAmount);
- balances[maker][takerTokenAddress] = balances[maker][takerTokenAddress].add(takerTokenFillAmount);
- balances[maker][zrx.address] = balances[maker][zrx.address].minus(makerFee);
- balances[taker][makerTokenAddress] = balances[taker][makerTokenAddress].add(makerTokenFillAmount);
- balances[taker][takerTokenAddress] = balances[taker][takerTokenAddress].minus(takerTokenFillAmount);
- balances[taker][zrx.address] = balances[taker][zrx.address].minus(takerFee);
- balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
+ balances[makerAddress][makerTokenAddress] = balances[makerAddress][makerTokenAddress].minus(
+ makerTokenFillAmount,
+ );
+ balances[makerAddress][takerTokenAddress] = balances[makerAddress][takerTokenAddress].add(
+ takerTokenFillAmount,
+ );
+ balances[makerAddress][zrx.address] = balances[makerAddress][zrx.address].minus(makerFee);
+ balances[takerAddress][makerTokenAddress] = balances[takerAddress][makerTokenAddress].add(
+ makerTokenFillAmount,
+ );
+ balances[takerAddress][takerTokenAddress] = balances[takerAddress][takerTokenAddress].minus(
+ takerTokenFillAmount,
+ );
+ balances[takerAddress][zrx.address] = balances[takerAddress][zrx.address].minus(takerFee);
+ balances[feeRecipientAddress][zrx.address] = balances[feeRecipientAddress][zrx.address].add(
makerFee.add(takerFee),
);
});
- await exWrapper.batchFillOrKillOrdersAsync(signedOrders, taker, {
+ await exWrapper.batchFillOrKillOrdersAsync(signedOrders, takerAddress, {
takerTokenFillAmounts,
});
@@ -270,10 +294,10 @@ describe('Exchange', () => {
takerTokenFillAmounts.push(takerTokenFillAmount);
});
- await exWrapper.fillOrKillOrderAsync(signedOrders[0], taker);
+ await exWrapper.fillOrKillOrderAsync(signedOrders[0], takerAddress);
return expect(
- exWrapper.batchFillOrKillOrdersAsync(signedOrders, taker, {
+ exWrapper.batchFillOrKillOrdersAsync(signedOrders, takerAddress, {
takerTokenFillAmounts,
}),
).to.be.rejectedWith(constants.REVERT);
@@ -285,7 +309,7 @@ describe('Exchange', () => {
const takerTokenFillAmount = signedOrders[0].takerTokenAmount.plus(
signedOrders[1].takerTokenAmount.div(2),
);
- await exWrapper.marketFillOrdersAsync(signedOrders, taker, {
+ await exWrapper.marketFillOrdersAsync(signedOrders, takerAddress, {
takerTokenFillAmount,
});
@@ -294,53 +318,61 @@ describe('Exchange', () => {
const makerTokenFillAmount = signedOrders[0].makerTokenAmount.add(
signedOrders[1].makerTokenAmount.dividedToIntegerBy(2),
);
- const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2));
- const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2));
- expect(newBalances[maker][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrders[0].makerTokenAddress].minus(makerTokenFillAmount),
+ const makerFee = signedOrders[0].makerFeeAmount.add(
+ signedOrders[1].makerFeeAmount.dividedToIntegerBy(2),
+ );
+ const takerFee = signedOrders[0].takerFeeAmount.add(
+ signedOrders[1].takerFeeAmount.dividedToIntegerBy(2),
+ );
+ expect(newBalances[makerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][signedOrders[0].makerTokenAddress].minus(makerTokenFillAmount),
);
- expect(newBalances[maker][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrders[0].takerTokenAddress].add(takerTokenFillAmount),
+ expect(newBalances[makerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][signedOrders[0].takerTokenAddress].add(takerTokenFillAmount),
);
- expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
- balances[maker][zrx.address].minus(makerFee),
+ expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
+ balances[makerAddress][zrx.address].minus(makerFee),
);
- expect(newBalances[taker][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrders[0].takerTokenAddress].minus(takerTokenFillAmount),
+ expect(newBalances[takerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][signedOrders[0].takerTokenAddress].minus(takerTokenFillAmount),
);
- expect(newBalances[taker][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrders[0].makerTokenAddress].add(makerTokenFillAmount),
+ expect(newBalances[takerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][signedOrders[0].makerTokenAddress].add(makerTokenFillAmount),
);
- expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
- balances[taker][zrx.address].minus(takerFee),
+ expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
+ balances[takerAddress][zrx.address].minus(takerFee),
);
- expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
- balances[feeRecipient][zrx.address].add(makerFee.add(takerFee)),
+ expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(
+ balances[feeRecipientAddress][zrx.address].add(makerFee.add(takerFee)),
);
});
it('should fill all signedOrders if cannot fill entire takerTokenFillAmount', async () => {
const takerTokenFillAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
signedOrders.forEach(signedOrder => {
- balances[maker][signedOrder.makerTokenAddress] = balances[maker][
+ balances[makerAddress][signedOrder.makerTokenAddress] = balances[makerAddress][
signedOrder.makerTokenAddress
].minus(signedOrder.makerTokenAmount);
- balances[maker][signedOrder.takerTokenAddress] = balances[maker][signedOrder.takerTokenAddress].add(
- signedOrder.takerTokenAmount,
- );
- balances[maker][zrx.address] = balances[maker][zrx.address].minus(signedOrder.makerFee);
- balances[taker][signedOrder.makerTokenAddress] = balances[taker][signedOrder.makerTokenAddress].add(
- signedOrder.makerTokenAmount,
+ balances[makerAddress][signedOrder.takerTokenAddress] = balances[makerAddress][
+ signedOrder.takerTokenAddress
+ ].add(signedOrder.takerTokenAmount);
+ balances[makerAddress][zrx.address] = balances[makerAddress][zrx.address].minus(
+ signedOrder.makerFeeAmount,
);
- balances[taker][signedOrder.takerTokenAddress] = balances[taker][
+ balances[takerAddress][signedOrder.makerTokenAddress] = balances[takerAddress][
+ signedOrder.makerTokenAddress
+ ].add(signedOrder.makerTokenAmount);
+ balances[takerAddress][signedOrder.takerTokenAddress] = balances[takerAddress][
signedOrder.takerTokenAddress
].minus(signedOrder.takerTokenAmount);
- balances[taker][zrx.address] = balances[taker][zrx.address].minus(signedOrder.takerFee);
- balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
- signedOrder.makerFee.add(signedOrder.takerFee),
+ balances[takerAddress][zrx.address] = balances[takerAddress][zrx.address].minus(
+ signedOrder.takerFeeAmount,
+ );
+ balances[feeRecipientAddress][zrx.address] = balances[feeRecipientAddress][zrx.address].add(
+ signedOrder.makerFeeAmount.add(signedOrder.takerFeeAmount),
);
});
- await exWrapper.marketFillOrdersAsync(signedOrders, taker, {
+ await exWrapper.marketFillOrdersAsync(signedOrders, takerAddress, {
takerTokenFillAmount,
});
@@ -349,14 +381,14 @@ describe('Exchange', () => {
});
it('should throw when an signedOrder does not use the same takerTokenAddress', async () => {
- signedOrders = await Promise.all([
- orderFactory.newSignedOrderAsync(),
- orderFactory.newSignedOrderAsync({ takerTokenAddress: zrx.address }),
- orderFactory.newSignedOrderAsync(),
- ]);
+ signedOrders = [
+ orderFactory.newSignedOrder(),
+ orderFactory.newSignedOrder({ takerTokenAddress: zrx.address }),
+ orderFactory.newSignedOrder(),
+ ];
return expect(
- exWrapper.marketFillOrdersAsync(signedOrders, taker, {
+ exWrapper.marketFillOrdersAsync(signedOrders, takerAddress, {
takerTokenFillAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
}),
).to.be.rejectedWith(constants.REVERT);
@@ -366,11 +398,11 @@ describe('Exchange', () => {
describe('batchCancelOrders', () => {
it('should be able to cancel multiple signedOrders', async () => {
const takerTokenCancelAmounts = _.map(signedOrders, signedOrder => signedOrder.takerTokenAmount);
- await exWrapper.batchCancelOrdersAsync(signedOrders, maker, {
+ await exWrapper.batchCancelOrdersAsync(signedOrders, makerAddress, {
takerTokenCancelAmounts,
});
- await exWrapper.batchFillOrdersAsync(signedOrders, taker, {
+ await exWrapper.batchFillOrdersAsync(signedOrders, takerAddress, {
takerTokenFillAmounts: takerTokenCancelAmounts,
});
const newBalances = await dmyBalances.getAsync();