aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-02-09 03:51:09 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-21 04:56:16 +0800
commit6b897f6fd2b3bf894662f11f67ebb555f20c2464 (patch)
treee5eab4fea3905cc55ac02bc4dc0ceddd3b76027a /packages/contracts/test
parent389f1cde519f9c6824bc1599aedaa0c3c0b792c2 (diff)
downloaddexon-sol-tools-6b897f6fd2b3bf894662f11f67ebb555f20c2464.tar
dexon-sol-tools-6b897f6fd2b3bf894662f11f67ebb555f20c2464.tar.gz
dexon-sol-tools-6b897f6fd2b3bf894662f11f67ebb555f20c2464.tar.bz2
dexon-sol-tools-6b897f6fd2b3bf894662f11f67ebb555f20c2464.tar.lz
dexon-sol-tools-6b897f6fd2b3bf894662f11f67ebb555f20c2464.tar.xz
dexon-sol-tools-6b897f6fd2b3bf894662f11f67ebb555f20c2464.tar.zst
dexon-sol-tools-6b897f6fd2b3bf894662f11f67ebb555f20c2464.zip
Get tests to build
Diffstat (limited to 'packages/contracts/test')
-rw-r--r--packages/contracts/test/exchange/core.ts213
-rw-r--r--packages/contracts/test/exchange/wrapper.ts110
2 files changed, 150 insertions, 173 deletions
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index 689b11062..0a9b7b2c9 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -1,4 +1,5 @@
import { LogWithDecodedArgs, SignedOrder, TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js';
+
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -130,18 +131,6 @@ describe('Exchange', () => {
it('should include transferViaTokenTransferProxy', () => {
expect((exchange as any).transferViaTokenTransferProxy).to.be.undefined();
});
-
- it('should include isTransferable', () => {
- expect((exchange as any).isTransferable).to.be.undefined();
- });
-
- it('should include getBalance', () => {
- expect((exchange as any).getBalance).to.be.undefined();
- });
-
- it('should include getAllowance', () => {
- expect((exchange as any).getAllowance).to.be.undefined();
- });
});
describe('fillOrder', () => {
@@ -163,7 +152,7 @@ describe('Exchange', () => {
const fillTakerTokenAmount1 = new BigNumber(2);
await exWrapper.fillOrderAsync(signedOrder, taker, {
- fillTakerTokenAmount: fillTakerTokenAmount1,
+ takerTokenFillAmount: fillTakerTokenAmount1,
});
const filledTakerTokenAmountAfter1 = await zeroEx.exchange.getFilledTakerAmountAsync(
@@ -173,7 +162,7 @@ describe('Exchange', () => {
const fillTakerTokenAmount2 = new BigNumber(1);
await exWrapper.fillOrderAsync(signedOrder, taker, {
- fillTakerTokenAmount: fillTakerTokenAmount2,
+ takerTokenFillAmount: fillTakerTokenAmount2,
});
const filledTakerTokenAmountAfter2 = await zeroEx.exchange.getFilledTakerAmountAsync(
@@ -193,45 +182,45 @@ describe('Exchange', () => {
);
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
- const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrderAsync(signedOrder, taker, { takerTokenFillAmount });
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
ZeroEx.getOrderHashHex(signedOrder),
);
- expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
+ expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(takerTokenFillAmount);
const newBalances = await dmyBalances.getAsync();
- const fillMakerTokenAmount = fillTakerTokenAmount
+ const makerTokenFillAmount = takerTokenFillAmount
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
- const paidMakerFee = signedOrder.makerFee
- .times(fillMakerTokenAmount)
+ const makerFeePaid = signedOrder.makerFee
+ .times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- const paidTakerFee = signedOrder.takerFee
- .times(fillMakerTokenAmount)
+ const takerFeePaid = signedOrder.takerFee
+ .times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
+ balances[maker][signedOrder.makerTokenAddress].minus(makerTokenFillAmount),
);
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
+ balances[maker][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
- balances[maker][zrx.address].minus(paidMakerFee),
+ balances[maker][zrx.address].minus(makerFeePaid),
);
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
+ balances[taker][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
);
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
+ balances[taker][signedOrder.makerTokenAddress].add(makerTokenFillAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
- balances[taker][zrx.address].minus(paidTakerFee),
+ balances[taker][zrx.address].minus(takerFeePaid),
);
expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
- balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)),
+ balances[feeRecipient][zrx.address].add(makerFeePaid.add(takerFeePaid)),
);
});
@@ -246,45 +235,45 @@ describe('Exchange', () => {
);
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
- const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrderAsync(signedOrder, taker, { takerTokenFillAmount });
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
ZeroEx.getOrderHashHex(signedOrder),
);
- expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
+ expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(takerTokenFillAmount);
const newBalances = await dmyBalances.getAsync();
- const fillMakerTokenAmount = fillTakerTokenAmount
+ const makerTokenFillAmount = takerTokenFillAmount
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
- const paidMakerFee = signedOrder.makerFee
- .times(fillMakerTokenAmount)
+ const makerFeePaid = signedOrder.makerFee
+ .times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- const paidTakerFee = signedOrder.takerFee
- .times(fillMakerTokenAmount)
+ const takerFeePaid = signedOrder.takerFee
+ .times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
+ balances[maker][signedOrder.makerTokenAddress].minus(makerTokenFillAmount),
);
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
+ balances[maker][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
- balances[maker][zrx.address].minus(paidMakerFee),
+ balances[maker][zrx.address].minus(makerFeePaid),
);
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
+ balances[taker][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
);
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
+ balances[taker][signedOrder.makerTokenAddress].add(makerTokenFillAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
- balances[taker][zrx.address].minus(paidTakerFee),
+ balances[taker][zrx.address].minus(takerFeePaid),
);
expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
- balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)),
+ balances[feeRecipient][zrx.address].add(makerFeePaid.add(takerFeePaid)),
);
});
@@ -299,45 +288,45 @@ describe('Exchange', () => {
);
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
- const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrderAsync(signedOrder, taker, { takerTokenFillAmount });
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
ZeroEx.getOrderHashHex(signedOrder),
);
- expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
+ expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(takerTokenFillAmount);
const newBalances = await dmyBalances.getAsync();
- const fillMakerTokenAmount = fillTakerTokenAmount
+ const makerTokenFillAmount = takerTokenFillAmount
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
- const paidMakerFee = signedOrder.makerFee
- .times(fillMakerTokenAmount)
+ const makerFeePaid = signedOrder.makerFee
+ .times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- const paidTakerFee = signedOrder.takerFee
- .times(fillMakerTokenAmount)
+ const takerFeePaid = signedOrder.takerFee
+ .times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
+ balances[maker][signedOrder.makerTokenAddress].minus(makerTokenFillAmount),
);
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
+ balances[maker][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
- balances[maker][zrx.address].minus(paidMakerFee),
+ balances[maker][zrx.address].minus(makerFeePaid),
);
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
+ balances[taker][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
);
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
+ balances[taker][signedOrder.makerTokenAddress].add(makerTokenFillAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
- balances[taker][zrx.address].minus(paidTakerFee),
+ balances[taker][zrx.address].minus(takerFeePaid),
);
expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
- balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)),
+ balances[feeRecipient][zrx.address].add(makerFeePaid.add(takerFeePaid)),
);
});
@@ -353,59 +342,59 @@ describe('Exchange', () => {
);
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
- const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrderAsync(signedOrder, taker, { takerTokenFillAmount });
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
ZeroEx.getOrderHashHex(signedOrder),
);
- const expectedFillAmountTAfter = fillTakerTokenAmount.add(filledTakerTokenAmountBefore);
+ const expectedFillAmountTAfter = takerTokenFillAmount.add(filledTakerTokenAmountBefore);
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(expectedFillAmountTAfter);
const newBalances = await dmyBalances.getAsync();
- const fillMakerTokenAmount = fillTakerTokenAmount
+ const makerTokenFillAmount = takerTokenFillAmount
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
- const paidMakerFee = signedOrder.makerFee
- .times(fillMakerTokenAmount)
+ const makerFeePaid = signedOrder.makerFee
+ .times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- const paidTakerFee = signedOrder.takerFee
- .times(fillMakerTokenAmount)
+ const takerFeePaid = signedOrder.takerFee
+ .times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
+ balances[maker][signedOrder.makerTokenAddress].minus(makerTokenFillAmount),
);
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
+ balances[maker][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
- balances[maker][zrx.address].minus(paidMakerFee),
+ balances[maker][zrx.address].minus(makerFeePaid),
);
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
+ balances[taker][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
);
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
+ balances[taker][signedOrder.makerTokenAddress].add(makerTokenFillAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
- balances[taker][zrx.address].minus(paidTakerFee),
+ balances[taker][zrx.address].minus(takerFeePaid),
);
expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
- balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)),
+ balances[feeRecipient][zrx.address].add(makerFeePaid.add(takerFeePaid)),
);
});
- it('should fill remaining value if fillTakerTokenAmount > remaining takerTokenAmount', async () => {
- const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
+ it('should fill remaining value if takerTokenFillAmount > remaining takerTokenAmount', async () => {
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrderAsync(signedOrder, taker, { takerTokenFillAmount });
const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
- fillTakerTokenAmount: signedOrder.takerTokenAmount,
+ takerTokenFillAmount: signedOrder.takerTokenAmount,
});
const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>;
expect(log.args.filledTakerTokenAmount).to.be.bignumber.equal(
- signedOrder.takerTokenAmount.minus(fillTakerTokenAmount),
+ signedOrder.takerTokenAmount.minus(takerTokenFillAmount),
);
const newBalances = await dmyBalances.getAsync();
@@ -435,7 +424,7 @@ describe('Exchange', () => {
it('should log 1 event with the correct arguments when order has a feeRecipient', async () => {
const divisor = 2;
const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
- fillTakerTokenAmount: signedOrder.takerTokenAmount.div(divisor),
+ takerTokenFillAmount: signedOrder.takerTokenAmount.div(divisor),
});
expect(res.logs).to.have.length(1);
@@ -454,8 +443,8 @@ describe('Exchange', () => {
expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerToken);
expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.filledMakerTokenAmount);
expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.filledTakerTokenAmount);
- expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.paidMakerFee);
- expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.paidTakerFee);
+ expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.makerFeePaid);
+ expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.takerFeePaid);
expect(expectedTokens).to.be.equal(logArgs.tokens);
expect(ZeroEx.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash);
});
@@ -466,7 +455,7 @@ describe('Exchange', () => {
});
const divisor = 2;
const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
- fillTakerTokenAmount: signedOrder.takerTokenAmount.div(divisor),
+ takerTokenFillAmount: signedOrder.takerTokenAmount.div(divisor),
});
expect(res.logs).to.have.length(1);
@@ -485,8 +474,8 @@ describe('Exchange', () => {
expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerToken);
expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.filledMakerTokenAmount);
expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.filledTakerTokenAmount);
- expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.paidMakerFee);
- expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.paidTakerFee);
+ expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.makerFeePaid);
+ expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.takerFeePaid);
expect(expectedTokens).to.be.equal(logArgs.tokens);
expect(ZeroEx.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash);
});
@@ -527,12 +516,12 @@ describe('Exchange', () => {
return expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
- it('should throw if fillTakerTokenAmount is 0', async () => {
+ it('should throw if takerTokenFillAmount is 0', async () => {
signedOrder = await orderFactory.newSignedOrderAsync();
return expect(
exWrapper.fillOrderAsync(signedOrder, taker, {
- fillTakerTokenAmount: new BigNumber(0),
+ takerTokenFillAmount: new BigNumber(0),
}),
).to.be.rejectedWith(constants.REVERT);
});
@@ -578,11 +567,7 @@ describe('Exchange', () => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
- return expect(
- exWrapper.fillOrderAsync(signedOrder, taker, {
- shouldThrowOnInsufficientBalanceOrAllowance: true,
- }),
- ).to.be.rejectedWith(constants.REVERT);
+ return expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should not change balances if maker allowances are too low to fill order and \
@@ -600,11 +585,7 @@ describe('Exchange', () => {
it('should throw if maker allowances are too low to fill order and \
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
await rep.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: maker });
- expect(
- exWrapper.fillOrderAsync(signedOrder, taker, {
- shouldThrowOnInsufficientBalanceOrAllowance: true,
- }),
- ).to.be.rejectedWith(constants.REVERT);
+ expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
await rep.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, {
from: maker,
});
@@ -625,11 +606,7 @@ describe('Exchange', () => {
it('should throw if taker allowances are too low to fill order and \
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
await dgd.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: taker });
- expect(
- exWrapper.fillOrderAsync(signedOrder, taker, {
- shouldThrowOnInsufficientBalanceOrAllowance: true,
- }),
- ).to.be.rejectedWith(constants.REVERT);
+ expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
await dgd.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, {
from: taker,
});
@@ -765,12 +742,12 @@ describe('Exchange', () => {
return expect(exWrapper.cancelOrderAsync(signedOrder, maker)).to.be.rejectedWith(constants.REVERT);
});
- it('should throw if cancelTakerTokenAmount is 0', async () => {
+ it('should throw if takerTokenCancelAmount is 0', async () => {
signedOrder = await orderFactory.newSignedOrderAsync();
return expect(
exWrapper.cancelOrderAsync(signedOrder, maker, {
- cancelTakerTokenAmount: new BigNumber(0),
+ takerTokenCancelAmount: new BigNumber(0),
}),
).to.be.rejectedWith(constants.REVERT);
});
@@ -778,7 +755,7 @@ describe('Exchange', () => {
it('should be able to cancel a full order', async () => {
await exWrapper.cancelOrderAsync(signedOrder, maker);
await exWrapper.fillOrderAsync(signedOrder, taker, {
- fillTakerTokenAmount: signedOrder.takerTokenAmount.div(2),
+ takerTokenFillAmount: signedOrder.takerTokenAmount.div(2),
});
const newBalances = await dmyBalances.getAsync();
@@ -786,56 +763,56 @@ describe('Exchange', () => {
});
it('should be able to cancel part of an order', async () => {
- const cancelTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
+ const takerTokenCancelAmount = signedOrder.takerTokenAmount.div(2);
await exWrapper.cancelOrderAsync(signedOrder, maker, {
- cancelTakerTokenAmount,
+ takerTokenCancelAmount,
});
const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
- fillTakerTokenAmount: signedOrder.takerTokenAmount,
+ takerTokenFillAmount: signedOrder.takerTokenAmount,
});
const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>;
expect(log.args.filledTakerTokenAmount).to.be.bignumber.equal(
- signedOrder.takerTokenAmount.minus(cancelTakerTokenAmount),
+ signedOrder.takerTokenAmount.minus(takerTokenCancelAmount),
);
const newBalances = await dmyBalances.getAsync();
- const cancelMakerTokenAmount = cancelTakerTokenAmount
+ const cancelMakerTokenAmount = takerTokenCancelAmount
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
- const paidMakerFee = signedOrder.makerFee
+ const makerFeePaid = signedOrder.makerFee
.times(cancelMakerTokenAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- const paidTakerFee = signedOrder.takerFee
+ const takerFeePaid = signedOrder.takerFee
.times(cancelMakerTokenAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrder.makerTokenAddress].minus(cancelMakerTokenAmount),
);
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrder.takerTokenAddress].add(cancelTakerTokenAmount),
+ balances[maker][signedOrder.takerTokenAddress].add(takerTokenCancelAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
- balances[maker][zrx.address].minus(paidMakerFee),
+ balances[maker][zrx.address].minus(makerFeePaid),
);
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrder.takerTokenAddress].minus(cancelTakerTokenAmount),
+ balances[taker][signedOrder.takerTokenAddress].minus(takerTokenCancelAmount),
);
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrder.makerTokenAddress].add(cancelMakerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
- balances[taker][zrx.address].minus(paidTakerFee),
+ balances[taker][zrx.address].minus(takerFeePaid),
);
expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
- balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)),
+ balances[feeRecipient][zrx.address].add(makerFeePaid.add(takerFeePaid)),
);
});
it('should log 1 event with correct arguments', async () => {
const divisor = 2;
const res = await exWrapper.cancelOrderAsync(signedOrder, maker, {
- cancelTakerTokenAmount: signedOrder.takerTokenAmount.div(divisor),
+ takerTokenCancelAmount: signedOrder.takerTokenAmount.div(divisor),
});
expect(res.logs).to.have.length(1);
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index c658dca79..440fd0517 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -124,34 +124,34 @@ describe('Exchange', () => {
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
- const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
await exWrapper.fillOrKillOrderAsync(signedOrder, taker, {
- fillTakerTokenAmount,
+ takerTokenFillAmount,
});
const newBalances = await dmyBalances.getAsync();
- const fillMakerTokenAmount = fillTakerTokenAmount
+ const makerTokenFillAmount = takerTokenFillAmount
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFee = signedOrder.makerFee
- .times(fillMakerTokenAmount)
+ .times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFee = signedOrder.takerFee
- .times(fillMakerTokenAmount)
+ .times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
+ balances[maker][signedOrder.makerTokenAddress].minus(makerTokenFillAmount),
);
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
+ balances[maker][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(fillTakerTokenAmount),
+ balances[taker][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
);
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
+ balances[taker][signedOrder.makerTokenAddress].add(makerTokenFillAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(balances[taker][zrx.address].minus(takerFee));
expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
@@ -167,12 +167,12 @@ describe('Exchange', () => {
return expect(exWrapper.fillOrKillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
- it('should throw if entire fillTakerTokenAmount not filled', async () => {
+ it('should throw if entire takerTokenFillAmount not filled', async () => {
const signedOrder = await orderFactory.newSignedOrderAsync();
const from = taker;
await exWrapper.fillOrderAsync(signedOrder, from, {
- fillTakerTokenAmount: signedOrder.takerTokenAmount.div(2),
+ takerTokenFillAmount: signedOrder.takerTokenAmount.div(2),
});
return expect(exWrapper.fillOrKillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
@@ -192,26 +192,26 @@ describe('Exchange', () => {
describe('batchFillOrders', () => {
it('should transfer the correct amounts', async () => {
- const fillTakerTokenAmounts: BigNumber[] = [];
+ const takerTokenFillAmounts: BigNumber[] = [];
const makerTokenAddress = rep.address;
const takerTokenAddress = dgd.address;
signedOrders.forEach(signedOrder => {
- const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
- const fillMakerTokenAmount = fillTakerTokenAmount
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ const makerTokenFillAmount = takerTokenFillAmount
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFee = signedOrder.makerFee
- .times(fillMakerTokenAmount)
+ .times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFee = signedOrder.takerFee
- .times(fillMakerTokenAmount)
+ .times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- fillTakerTokenAmounts.push(fillTakerTokenAmount);
- balances[maker][makerTokenAddress] = balances[maker][makerTokenAddress].minus(fillMakerTokenAmount);
- balances[maker][takerTokenAddress] = balances[maker][takerTokenAddress].add(fillTakerTokenAmount);
+ 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(fillMakerTokenAmount);
- balances[taker][takerTokenAddress] = balances[taker][takerTokenAddress].minus(fillTakerTokenAmount);
+ 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),
@@ -219,7 +219,7 @@ describe('Exchange', () => {
});
await exWrapper.batchFillOrdersAsync(signedOrders, taker, {
- fillTakerTokenAmounts,
+ takerTokenFillAmounts,
});
const newBalances = await dmyBalances.getAsync();
@@ -229,26 +229,26 @@ describe('Exchange', () => {
describe('batchFillOrKillOrders', () => {
it('should transfer the correct amounts', async () => {
- const fillTakerTokenAmounts: BigNumber[] = [];
+ const takerTokenFillAmounts: BigNumber[] = [];
const makerTokenAddress = rep.address;
const takerTokenAddress = dgd.address;
signedOrders.forEach(signedOrder => {
- const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
- const fillMakerTokenAmount = fillTakerTokenAmount
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ const makerTokenFillAmount = takerTokenFillAmount
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFee = signedOrder.makerFee
- .times(fillMakerTokenAmount)
+ .times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFee = signedOrder.takerFee
- .times(fillMakerTokenAmount)
+ .times(makerTokenFillAmount)
.dividedToIntegerBy(signedOrder.makerTokenAmount);
- fillTakerTokenAmounts.push(fillTakerTokenAmount);
- balances[maker][makerTokenAddress] = balances[maker][makerTokenAddress].minus(fillMakerTokenAmount);
- balances[maker][takerTokenAddress] = balances[maker][takerTokenAddress].add(fillTakerTokenAmount);
+ 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(fillMakerTokenAmount);
- balances[taker][takerTokenAddress] = balances[taker][takerTokenAddress].minus(fillTakerTokenAmount);
+ 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),
@@ -256,7 +256,7 @@ describe('Exchange', () => {
});
await exWrapper.batchFillOrKillOrdersAsync(signedOrders, taker, {
- fillTakerTokenAmounts,
+ takerTokenFillAmounts,
});
const newBalances = await dmyBalances.getAsync();
@@ -264,52 +264,52 @@ describe('Exchange', () => {
});
it('should throw if a single signedOrder does not fill the expected amount', async () => {
- const fillTakerTokenAmounts: BigNumber[] = [];
+ const takerTokenFillAmounts: BigNumber[] = [];
signedOrders.forEach(signedOrder => {
- const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
- fillTakerTokenAmounts.push(fillTakerTokenAmount);
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ takerTokenFillAmounts.push(takerTokenFillAmount);
});
await exWrapper.fillOrKillOrderAsync(signedOrders[0], taker);
return expect(
exWrapper.batchFillOrKillOrdersAsync(signedOrders, taker, {
- fillTakerTokenAmounts,
+ takerTokenFillAmounts,
}),
).to.be.rejectedWith(constants.REVERT);
});
});
describe('fillOrdersUpTo', () => {
- it('should stop when the entire fillTakerTokenAmount is filled', async () => {
- const fillTakerTokenAmount = signedOrders[0].takerTokenAmount.plus(
+ it('should stop when the entire takerTokenFillAmount is filled', async () => {
+ const takerTokenFillAmount = signedOrders[0].takerTokenAmount.plus(
signedOrders[1].takerTokenAmount.div(2),
);
- await exWrapper.fillOrdersUpToAsync(signedOrders, taker, {
- fillTakerTokenAmount,
+ await exWrapper.marketFillOrdersAsync(signedOrders, taker, {
+ takerTokenFillAmount,
});
const newBalances = await dmyBalances.getAsync();
- const fillMakerTokenAmount = signedOrders[0].makerTokenAmount.add(
+ 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(fillMakerTokenAmount),
+ balances[maker][signedOrders[0].makerTokenAddress].minus(makerTokenFillAmount),
);
expect(newBalances[maker][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[maker][signedOrders[0].takerTokenAddress].add(fillTakerTokenAmount),
+ balances[maker][signedOrders[0].takerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
balances[maker][zrx.address].minus(makerFee),
);
expect(newBalances[taker][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrders[0].takerTokenAddress].minus(fillTakerTokenAmount),
+ balances[taker][signedOrders[0].takerTokenAddress].minus(takerTokenFillAmount),
);
expect(newBalances[taker][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[taker][signedOrders[0].makerTokenAddress].add(fillMakerTokenAmount),
+ balances[taker][signedOrders[0].makerTokenAddress].add(makerTokenFillAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
balances[taker][zrx.address].minus(takerFee),
@@ -319,8 +319,8 @@ describe('Exchange', () => {
);
});
- it('should fill all signedOrders if cannot fill entire fillTakerTokenAmount', async () => {
- const fillTakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
+ 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][
signedOrder.makerTokenAddress
@@ -340,8 +340,8 @@ describe('Exchange', () => {
signedOrder.makerFee.add(signedOrder.takerFee),
);
});
- await exWrapper.fillOrdersUpToAsync(signedOrders, taker, {
- fillTakerTokenAmount,
+ await exWrapper.marketFillOrdersAsync(signedOrders, taker, {
+ takerTokenFillAmount,
});
const newBalances = await dmyBalances.getAsync();
@@ -356,8 +356,8 @@ describe('Exchange', () => {
]);
return expect(
- exWrapper.fillOrdersUpToAsync(signedOrders, taker, {
- fillTakerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
+ exWrapper.marketFillOrdersAsync(signedOrders, taker, {
+ takerTokenFillAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
}),
).to.be.rejectedWith(constants.REVERT);
});
@@ -365,13 +365,13 @@ describe('Exchange', () => {
describe('batchCancelOrders', () => {
it('should be able to cancel multiple signedOrders', async () => {
- const cancelTakerTokenAmounts = _.map(signedOrders, signedOrder => signedOrder.takerTokenAmount);
+ const takerTokenCancelAmounts = _.map(signedOrders, signedOrder => signedOrder.takerTokenAmount);
await exWrapper.batchCancelOrdersAsync(signedOrders, maker, {
- cancelTakerTokenAmounts,
+ takerTokenCancelAmounts,
});
await exWrapper.batchFillOrdersAsync(signedOrders, taker, {
- fillTakerTokenAmounts: cancelTakerTokenAmounts,
+ takerTokenFillAmounts: takerTokenCancelAmounts,
});
const newBalances = await dmyBalances.getAsync();
expect(balances).to.be.deep.equal(newBalances);