diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-01-14 22:50:32 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-01-15 23:25:24 +0800 |
commit | c3afc13dd660348e99b727c2dd01930eec8d99c3 (patch) | |
tree | 9a05e88e55200fdf72d08af10b5a753535e23256 /contracts/protocol/test | |
parent | f570f80674c22f69712c45e8e3c48e948b51f357 (diff) | |
download | dexon-sol-tools-c3afc13dd660348e99b727c2dd01930eec8d99c3.tar dexon-sol-tools-c3afc13dd660348e99b727c2dd01930eec8d99c3.tar.gz dexon-sol-tools-c3afc13dd660348e99b727c2dd01930eec8d99c3.tar.bz2 dexon-sol-tools-c3afc13dd660348e99b727c2dd01930eec8d99c3.tar.lz dexon-sol-tools-c3afc13dd660348e99b727c2dd01930eec8d99c3.tar.xz dexon-sol-tools-c3afc13dd660348e99b727c2dd01930eec8d99c3.tar.zst dexon-sol-tools-c3afc13dd660348e99b727c2dd01930eec8d99c3.zip |
Upgrade bignumber.js version
Diffstat (limited to 'contracts/protocol/test')
-rw-r--r-- | contracts/protocol/test/asset_proxy/proxies.ts | 24 | ||||
-rw-r--r-- | contracts/protocol/test/exchange/core.ts | 16 | ||||
-rw-r--r-- | contracts/protocol/test/exchange/dispatcher.ts | 2 | ||||
-rw-r--r-- | contracts/protocol/test/exchange/internal.ts | 54 | ||||
-rw-r--r-- | contracts/protocol/test/exchange/transactions.ts | 22 | ||||
-rw-r--r-- | contracts/protocol/test/exchange/wrapper.ts | 122 | ||||
-rw-r--r-- | contracts/protocol/test/utils/fill_order_combinatorial_utils.ts | 6 | ||||
-rw-r--r-- | contracts/protocol/test/utils/match_order_tester.ts | 24 |
8 files changed, 136 insertions, 134 deletions
diff --git a/contracts/protocol/test/asset_proxy/proxies.ts b/contracts/protocol/test/asset_proxy/proxies.ts index bbb44f402..c34be9c6a 100644 --- a/contracts/protocol/test/asset_proxy/proxies.ts +++ b/contracts/protocol/test/asset_proxy/proxies.ts @@ -259,7 +259,7 @@ describe('Asset Transfer Proxies', () => { erc20Balances[fromAddress][erc20TokenA.address].minus(amount), ); expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal( - erc20Balances[toAddress][erc20TokenA.address].add(amount), + erc20Balances[toAddress][erc20TokenA.address].plus(amount), ); }); @@ -318,7 +318,7 @@ describe('Asset Transfer Proxies', () => { erc20Balances[fromAddress][erc20TokenA.address].minus(amount), ); expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal( - erc20Balances[toAddress][erc20TokenA.address].add(amount), + erc20Balances[toAddress][erc20TokenA.address].plus(amount), ); }); @@ -737,7 +737,7 @@ describe('Asset Transfer Proxies', () => { erc20Balances[fromAddress][erc20TokenA.address].minus(totalAmount), ); expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal( - erc20Balances[toAddress][erc20TokenA.address].add(totalAmount), + erc20Balances[toAddress][erc20TokenA.address].plus(totalAmount), ); }); it('should dispatch an ERC20 transfer when input amount is 0', async () => { @@ -800,7 +800,7 @@ describe('Asset Transfer Proxies', () => { erc20Balances[fromAddress][erc20TokenA.address].minus(totalAmount), ); expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal( - erc20Balances[toAddress][erc20TokenA.address].add(totalAmount), + erc20Balances[toAddress][erc20TokenA.address].plus(totalAmount), ); }); it('should successfully transfer multiple different ERC20 tokens', async () => { @@ -834,13 +834,13 @@ describe('Asset Transfer Proxies', () => { erc20Balances[fromAddress][erc20TokenA.address].minus(totalErc20AAmount), ); expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal( - erc20Balances[toAddress][erc20TokenA.address].add(totalErc20AAmount), + erc20Balances[toAddress][erc20TokenA.address].plus(totalErc20AAmount), ); expect(newBalances[fromAddress][erc20TokenB.address]).to.be.bignumber.equal( erc20Balances[fromAddress][erc20TokenB.address].minus(totalErc20BAmount), ); expect(newBalances[toAddress][erc20TokenB.address]).to.be.bignumber.equal( - erc20Balances[toAddress][erc20TokenB.address].add(totalErc20BAmount), + erc20Balances[toAddress][erc20TokenB.address].plus(totalErc20BAmount), ); }); it('should transfer a single ERC721 token', async () => { @@ -970,7 +970,7 @@ describe('Asset Transfer Proxies', () => { erc20Balances[fromAddress][erc20TokenA.address].minus(totalAmount), ); expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal( - erc20Balances[toAddress][erc20TokenA.address].add(totalAmount), + erc20Balances[toAddress][erc20TokenA.address].plus(totalAmount), ); const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); expect(newOwnerFromAsset).to.be.equal(toAddress); @@ -1008,7 +1008,7 @@ describe('Asset Transfer Proxies', () => { erc20Balances[fromAddress][erc20TokenA.address].minus(totalAmount), ); expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal( - erc20Balances[toAddress][erc20TokenA.address].add(totalAmount), + erc20Balances[toAddress][erc20TokenA.address].plus(totalAmount), ); const newOwnerFromAsset = await erc721TokenA.ownerOf.callAsync(erc721AFromTokenId); expect(newOwnerFromAsset).to.be.equal(toAddress); @@ -1044,13 +1044,13 @@ describe('Asset Transfer Proxies', () => { erc20Balances[fromAddress][erc20TokenA.address].minus(totalErc20AAmount), ); expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal( - erc20Balances[toAddress][erc20TokenA.address].add(totalErc20AAmount), + erc20Balances[toAddress][erc20TokenA.address].plus(totalErc20AAmount), ); expect(newBalances[fromAddress][erc20TokenB.address]).to.be.bignumber.equal( erc20Balances[fromAddress][erc20TokenB.address].minus(totalErc20BAmount), ); expect(newBalances[toAddress][erc20TokenB.address]).to.be.bignumber.equal( - erc20Balances[toAddress][erc20TokenB.address].add(totalErc20BAmount), + erc20Balances[toAddress][erc20TokenB.address].plus(totalErc20BAmount), ); }); it('should successfully transfer a large amount of tokens', async () => { @@ -1122,13 +1122,13 @@ describe('Asset Transfer Proxies', () => { erc20Balances[fromAddress][erc20TokenA.address].minus(totalErc20AAmount), ); expect(newBalances[toAddress][erc20TokenA.address]).to.be.bignumber.equal( - erc20Balances[toAddress][erc20TokenA.address].add(totalErc20AAmount), + erc20Balances[toAddress][erc20TokenA.address].plus(totalErc20AAmount), ); expect(newBalances[fromAddress][erc20TokenB.address]).to.be.bignumber.equal( erc20Balances[fromAddress][erc20TokenB.address].minus(totalErc20BAmount), ); expect(newBalances[toAddress][erc20TokenB.address]).to.be.bignumber.equal( - erc20Balances[toAddress][erc20TokenB.address].add(totalErc20BAmount), + erc20Balances[toAddress][erc20TokenB.address].plus(totalErc20BAmount), ); }); it('should revert if a single transfer fails', async () => { diff --git a/contracts/protocol/test/exchange/core.ts b/contracts/protocol/test/exchange/core.ts index 700643b79..f88be1c94 100644 --- a/contracts/protocol/test/exchange/core.ts +++ b/contracts/protocol/test/exchange/core.ts @@ -538,7 +538,7 @@ describe('Exchange core', () => { it('should throw if order is expired', async () => { const currentTimestamp = await getLatestBlockTimestampAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ - expirationTimeSeconds: new BigNumber(currentTimestamp).sub(10), + expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10), }); return expectTransactionFailedAsync( exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress), @@ -625,15 +625,15 @@ describe('Exchange core', () => { }); const newBalances = await erc20Wrapper.getBalancesAsync(); - const fillMakerAssetAmount = signedOrders[2].makerAssetAmount.add(signedOrders[3].makerAssetAmount); - const fillTakerAssetAmount = signedOrders[2].takerAssetAmount.add(signedOrders[3].takerAssetAmount); - const makerFee = signedOrders[2].makerFee.add(signedOrders[3].makerFee); - const takerFee = signedOrders[2].takerFee.add(signedOrders[3].takerFee); + const fillMakerAssetAmount = signedOrders[2].makerAssetAmount.plus(signedOrders[3].makerAssetAmount); + const fillTakerAssetAmount = signedOrders[2].takerAssetAmount.plus(signedOrders[3].takerAssetAmount); + const makerFee = signedOrders[2].makerFee.plus(signedOrders[3].makerFee); + const takerFee = signedOrders[2].takerFee.plus(signedOrders[3].takerFee); expect(newBalances[makerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( erc20Balances[makerAddress][defaultMakerAssetAddress].minus(fillMakerAssetAmount), ); expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( - erc20Balances[makerAddress][defaultTakerAssetAddress].add(fillTakerAssetAmount), + erc20Balances[makerAddress][defaultTakerAssetAddress].plus(fillTakerAssetAmount), ); expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[makerAddress][zrxToken.address].minus(makerFee), @@ -642,13 +642,13 @@ describe('Exchange core', () => { erc20Balances[takerAddress][defaultTakerAssetAddress].minus(fillTakerAssetAmount), ); expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( - erc20Balances[takerAddress][defaultMakerAssetAddress].add(fillMakerAssetAmount), + erc20Balances[takerAddress][defaultMakerAssetAddress].plus(fillMakerAssetAmount), ); expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[takerAddress][zrxToken.address].minus(takerFee), ); expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFee.add(takerFee)), + erc20Balances[feeRecipientAddress][zrxToken.address].plus(makerFee.plus(takerFee)), ); }); }); diff --git a/contracts/protocol/test/exchange/dispatcher.ts b/contracts/protocol/test/exchange/dispatcher.ts index 5b1ac1e20..eca1b38f1 100644 --- a/contracts/protocol/test/exchange/dispatcher.ts +++ b/contracts/protocol/test/exchange/dispatcher.ts @@ -205,7 +205,7 @@ describe('AssetProxyDispatcher', () => { erc20Balances[makerAddress][zrxToken.address].minus(amount), ); expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( - erc20Balances[takerAddress][zrxToken.address].add(amount), + erc20Balances[takerAddress][zrxToken.address].plus(amount), ); }); diff --git a/contracts/protocol/test/exchange/internal.ts b/contracts/protocol/test/exchange/internal.ts index 972f5efb6..6ff1fdc2f 100644 --- a/contracts/protocol/test/exchange/internal.ts +++ b/contracts/protocol/test/exchange/internal.ts @@ -90,14 +90,14 @@ describe('Exchange core internal functions', () => { if (target.eq(0)) { return false; } - const product = numerator.mul(target); + const product = numerator.multipliedBy(target); const remainder = product.mod(denominator); - const remainderTimes1000 = remainder.mul('1000'); + const remainderTimes1000 = remainder.multipliedBy('1000'); const isError = remainderTimes1000.gte(product); - if (product.greaterThan(MAX_UINT256)) { + if (product.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } - if (remainderTimes1000.greaterThan(MAX_UINT256)) { + if (remainderTimes1000.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } return isError; @@ -117,15 +117,15 @@ describe('Exchange core internal functions', () => { if (target.eq(0)) { return false; } - const product = numerator.mul(target); + const product = numerator.multipliedBy(target); const remainder = product.mod(denominator); - const error = denominator.sub(remainder).mod(denominator); - const errorTimes1000 = error.mul('1000'); + const error = denominator.minus(remainder).mod(denominator); + const errorTimes1000 = error.multipliedBy('1000'); const isError = errorTimes1000.gte(product); - if (product.greaterThan(MAX_UINT256)) { + if (product.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } - if (errorTimes1000.greaterThan(MAX_UINT256)) { + if (errorTimes1000.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } return isError; @@ -143,8 +143,8 @@ describe('Exchange core internal functions', () => { if (isRoundingError) { throw roundingErrorForCall; } - const product = numerator.mul(target); - if (product.greaterThan(MAX_UINT256)) { + const product = numerator.multipliedBy(target); + if (product.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } return product.dividedToIntegerBy(denominator); @@ -177,8 +177,8 @@ describe('Exchange core internal functions', () => { _.cloneDeep(totalFillResults), singleFillResults, (totalVal: BigNumber, singleVal: BigNumber) => { - const newTotal = totalVal.add(singleVal); - if (newTotal.greaterThan(MAX_UINT256)) { + const newTotal = totalVal.plus(singleVal); + if (newTotal.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } return newTotal; @@ -271,8 +271,8 @@ describe('Exchange core internal functions', () => { if (denominator.eq(0)) { throw divisionByZeroErrorForCall; } - const product = numerator.mul(target); - if (product.greaterThan(MAX_UINT256)) { + const product = numerator.multipliedBy(target); + if (product.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } return product.dividedToIntegerBy(denominator); @@ -301,16 +301,16 @@ describe('Exchange core internal functions', () => { if (denominator.eq(0)) { throw divisionByZeroErrorForCall; } - const product = numerator.mul(target); - const offset = product.add(denominator.sub(1)); - if (offset.greaterThan(MAX_UINT256)) { + const product = numerator.multipliedBy(target); + const offset = product.plus(denominator.minus(1)); + if (offset.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } const result = offset.dividedToIntegerBy(denominator); if (product.mod(denominator).eq(0)) { - expect(result.mul(denominator)).to.be.bignumber.eq(product); + expect(result.multipliedBy(denominator)).to.be.bignumber.eq(product); } else { - expect(result.mul(denominator)).to.be.bignumber.gt(product); + expect(result.multipliedBy(denominator)).to.be.bignumber.gt(product); } return result; } @@ -358,16 +358,16 @@ describe('Exchange core internal functions', () => { if (isRoundingError) { throw roundingErrorForCall; } - const product = numerator.mul(target); - const offset = product.add(denominator.sub(1)); - if (offset.greaterThan(MAX_UINT256)) { + const product = numerator.multipliedBy(target); + const offset = product.plus(denominator.minus(1)); + if (offset.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } const result = offset.dividedToIntegerBy(denominator); if (product.mod(denominator).eq(0)) { - expect(result.mul(denominator)).to.be.bignumber.eq(product); + expect(result.multipliedBy(denominator)).to.be.bignumber.eq(product); } else { - expect(result.mul(denominator)).to.be.bignumber.gt(product); + expect(result.multipliedBy(denominator)).to.be.bignumber.gt(product); } return result; } @@ -433,8 +433,8 @@ describe('Exchange core internal functions', () => { // tslint:disable-next-line:no-unused-variable orderHash: string, ): Promise<BigNumber> { - const totalFilledAmount = takerAssetFilledAmount.add(orderTakerAssetFilledAmount); - if (totalFilledAmount.greaterThan(MAX_UINT256)) { + const totalFilledAmount = takerAssetFilledAmount.plus(orderTakerAssetFilledAmount); + if (totalFilledAmount.isGreaterThan(MAX_UINT256)) { throw overflowErrorForSendTransaction; } return totalFilledAmount; diff --git a/contracts/protocol/test/exchange/transactions.ts b/contracts/protocol/test/exchange/transactions.ts index 746f3cb04..e8c775f3e 100644 --- a/contracts/protocol/test/exchange/transactions.ts +++ b/contracts/protocol/test/exchange/transactions.ts @@ -160,7 +160,7 @@ describe('Exchange transactions', () => { erc20Balances[makerAddress][defaultMakerTokenAddress].minus(makerAssetFillAmount), ); expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal( - erc20Balances[makerAddress][defaultTakerTokenAddress].add(takerAssetFillAmount), + erc20Balances[makerAddress][defaultTakerTokenAddress].plus(takerAssetFillAmount), ); expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[makerAddress][zrxToken.address].minus(makerFeePaid), @@ -169,13 +169,13 @@ describe('Exchange transactions', () => { erc20Balances[takerAddress][defaultTakerTokenAddress].minus(takerAssetFillAmount), ); expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal( - erc20Balances[takerAddress][defaultMakerTokenAddress].add(makerAssetFillAmount), + erc20Balances[takerAddress][defaultMakerTokenAddress].plus(makerAssetFillAmount), ); expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[takerAddress][zrxToken.address].minus(takerFeePaid), ); expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFeePaid.add(takerFeePaid)), + erc20Balances[feeRecipientAddress][zrxToken.address].plus(makerFeePaid.plus(takerFeePaid)), ); }); @@ -234,7 +234,7 @@ describe('Exchange transactions', () => { senderAddress: exchangeWrapperContract.address, salt: orderSalt, }); - const targetOrderEpoch = orderSalt.add(1); + const targetOrderEpoch = orderSalt.plus(1); const cancelData = exchange.cancelOrdersUpTo.getABIEncodedTransactionData(targetOrderEpoch); const signedCancelTx = makerTransactionFactory.newSignedTransaction(cancelData); await exchangeWrapperContract.cancelOrdersUpTo.sendTransactionAsync( @@ -273,7 +273,7 @@ describe('Exchange transactions', () => { senderAddress: exchangeWrapperContract.address, salt: orderSalt, }); - const targetOrderEpoch = orderSalt.add(1); + const targetOrderEpoch = orderSalt.plus(1); await exchangeWrapper.cancelOrdersUpToAsync(targetOrderEpoch, makerAddress); erc20Balances = await erc20Wrapper.getBalancesAsync(); @@ -308,7 +308,7 @@ describe('Exchange transactions', () => { erc20Balances[makerAddress][defaultMakerTokenAddress].minus(makerAssetFillAmount), ); expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal( - erc20Balances[makerAddress][defaultTakerTokenAddress].add(takerAssetFillAmount), + erc20Balances[makerAddress][defaultTakerTokenAddress].plus(takerAssetFillAmount), ); expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[makerAddress][zrxToken.address].minus(makerFeePaid), @@ -317,13 +317,13 @@ describe('Exchange transactions', () => { erc20Balances[takerAddress][defaultTakerTokenAddress].minus(takerAssetFillAmount), ); expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal( - erc20Balances[takerAddress][defaultMakerTokenAddress].add(makerAssetFillAmount), + erc20Balances[takerAddress][defaultMakerTokenAddress].plus(makerAssetFillAmount), ); expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[takerAddress][zrxToken.address].minus(takerFeePaid), ); expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFeePaid.add(takerFeePaid)), + erc20Balances[feeRecipientAddress][zrxToken.address].plus(makerFeePaid.plus(takerFeePaid)), ); }); }); @@ -444,7 +444,7 @@ describe('Exchange transactions', () => { erc20Balances[makerAddress][defaultMakerTokenAddress].minus(makerAssetFillAmount), ); expect(newBalances[makerAddress][defaultTakerTokenAddress]).to.be.bignumber.equal( - erc20Balances[makerAddress][defaultTakerTokenAddress].add(takerAssetFillAmount), + erc20Balances[makerAddress][defaultTakerTokenAddress].plus(takerAssetFillAmount), ); expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[makerAddress][zrxToken.address].minus(makerFeePaid), @@ -453,13 +453,13 @@ describe('Exchange transactions', () => { erc20Balances[takerAddress][defaultTakerTokenAddress].minus(takerAssetFillAmount), ); expect(newBalances[takerAddress][defaultMakerTokenAddress]).to.be.bignumber.equal( - erc20Balances[takerAddress][defaultMakerTokenAddress].add(makerAssetFillAmount), + erc20Balances[takerAddress][defaultMakerTokenAddress].plus(makerAssetFillAmount), ); expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[takerAddress][zrxToken.address].minus(takerFeePaid), ); expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFeePaid.add(takerFeePaid)), + erc20Balances[feeRecipientAddress][zrxToken.address].plus(makerFeePaid.plus(takerFeePaid)), ); }); }); diff --git a/contracts/protocol/test/exchange/wrapper.ts b/contracts/protocol/test/exchange/wrapper.ts index 4c4506945..32ec64716 100644 --- a/contracts/protocol/test/exchange/wrapper.ts +++ b/contracts/protocol/test/exchange/wrapper.ts @@ -189,7 +189,7 @@ describe('Exchange wrappers', () => { erc20Balances[makerAddress][defaultMakerAssetAddress].minus(makerAssetFilledAmount), ); expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( - erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount), + erc20Balances[makerAddress][defaultTakerAssetAddress].plus(takerAssetFillAmount), ); expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[makerAddress][zrxToken.address].minus(makerFee), @@ -198,20 +198,20 @@ describe('Exchange wrappers', () => { erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount), ); expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( - erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount), + erc20Balances[takerAddress][defaultMakerAssetAddress].plus(makerAssetFilledAmount), ); expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[takerAddress][zrxToken.address].minus(takerFee), ); expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFee.add(takerFee)), + erc20Balances[feeRecipientAddress][zrxToken.address].plus(makerFee.plus(takerFee)), ); }); it('should throw if a signedOrder is expired', async () => { const currentTimestamp = await getLatestBlockTimestampAsync(); const signedOrder = await orderFactory.newSignedOrderAsync({ - expirationTimeSeconds: new BigNumber(currentTimestamp).sub(10), + expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10), }); return expectTransactionFailedAsync( @@ -284,7 +284,7 @@ describe('Exchange wrappers', () => { erc20Balances[makerAddress][defaultMakerAssetAddress].minus(makerAssetFilledAmount), ); expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( - erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount), + erc20Balances[makerAddress][defaultTakerAssetAddress].plus(takerAssetFillAmount), ); expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[makerAddress][zrxToken.address].minus(makerFee), @@ -293,13 +293,13 @@ describe('Exchange wrappers', () => { erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount), ); expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( - erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount), + erc20Balances[takerAddress][defaultMakerAssetAddress].plus(makerAssetFilledAmount), ); expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[takerAddress][zrxToken.address].minus(takerFee), ); expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFee.add(takerFee)), + erc20Balances[feeRecipientAddress][zrxToken.address].plus(makerFee.plus(takerFee)), ); }); @@ -493,13 +493,13 @@ describe('Exchange wrappers', () => { erc20Balances[makerAddress][makerAssetAddress] = erc20Balances[makerAddress][ makerAssetAddress ].minus(makerAssetFilledAmount); - erc20Balances[makerAddress][takerAssetAddress] = erc20Balances[makerAddress][takerAssetAddress].add( + erc20Balances[makerAddress][takerAssetAddress] = erc20Balances[makerAddress][takerAssetAddress].plus( takerAssetFillAmount, ); erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus( makerFee, ); - erc20Balances[takerAddress][makerAssetAddress] = erc20Balances[takerAddress][makerAssetAddress].add( + erc20Balances[takerAddress][makerAssetAddress] = erc20Balances[takerAddress][makerAssetAddress].plus( makerAssetFilledAmount, ); erc20Balances[takerAddress][takerAssetAddress] = erc20Balances[takerAddress][ @@ -510,7 +510,7 @@ describe('Exchange wrappers', () => { ); erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][ zrxToken.address - ].add(makerFee.add(takerFee)); + ].plus(makerFee.plus(takerFee)); }); await exchangeWrapper.batchFillOrdersAsync(signedOrders, takerAddress, { @@ -562,13 +562,13 @@ describe('Exchange wrappers', () => { erc20Balances[makerAddress][makerAssetAddress] = erc20Balances[makerAddress][ makerAssetAddress ].minus(makerAssetFilledAmount); - erc20Balances[makerAddress][takerAssetAddress] = erc20Balances[makerAddress][takerAssetAddress].add( + erc20Balances[makerAddress][takerAssetAddress] = erc20Balances[makerAddress][takerAssetAddress].plus( takerAssetFillAmount, ); erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus( makerFee, ); - erc20Balances[takerAddress][makerAssetAddress] = erc20Balances[takerAddress][makerAssetAddress].add( + erc20Balances[takerAddress][makerAssetAddress] = erc20Balances[takerAddress][makerAssetAddress].plus( makerAssetFilledAmount, ); erc20Balances[takerAddress][takerAssetAddress] = erc20Balances[takerAddress][ @@ -579,7 +579,7 @@ describe('Exchange wrappers', () => { ); erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][ zrxToken.address - ].add(makerFee.add(takerFee)); + ].plus(makerFee.plus(takerFee)); }); await exchangeWrapper.batchFillOrKillOrdersAsync(signedOrders, takerAddress, { @@ -647,13 +647,13 @@ describe('Exchange wrappers', () => { erc20Balances[makerAddress][makerAssetAddress] = erc20Balances[makerAddress][ makerAssetAddress ].minus(makerAssetFilledAmount); - erc20Balances[makerAddress][takerAssetAddress] = erc20Balances[makerAddress][takerAssetAddress].add( + erc20Balances[makerAddress][takerAssetAddress] = erc20Balances[makerAddress][takerAssetAddress].plus( takerAssetFillAmount, ); erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus( makerFee, ); - erc20Balances[takerAddress][makerAssetAddress] = erc20Balances[takerAddress][makerAssetAddress].add( + erc20Balances[takerAddress][makerAssetAddress] = erc20Balances[takerAddress][makerAssetAddress].plus( makerAssetFilledAmount, ); erc20Balances[takerAddress][takerAssetAddress] = erc20Balances[takerAddress][ @@ -664,7 +664,7 @@ describe('Exchange wrappers', () => { ); erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][ zrxToken.address - ].add(makerFee.add(takerFee)); + ].plus(makerFee.plus(takerFee)); }); await exchangeWrapper.batchFillOrdersNoThrowAsync(signedOrders, takerAddress, { @@ -706,13 +706,13 @@ describe('Exchange wrappers', () => { erc20Balances[makerAddress][makerAssetAddress] = erc20Balances[makerAddress][ makerAssetAddress ].minus(makerAssetFilledAmount); - erc20Balances[makerAddress][takerAssetAddress] = erc20Balances[makerAddress][takerAssetAddress].add( + erc20Balances[makerAddress][takerAssetAddress] = erc20Balances[makerAddress][takerAssetAddress].plus( takerAssetFillAmount, ); erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus( makerFee, ); - erc20Balances[takerAddress][makerAssetAddress] = erc20Balances[takerAddress][makerAssetAddress].add( + erc20Balances[takerAddress][makerAssetAddress] = erc20Balances[takerAddress][makerAssetAddress].plus( makerAssetFilledAmount, ); erc20Balances[takerAddress][takerAssetAddress] = erc20Balances[takerAddress][ @@ -723,7 +723,7 @@ describe('Exchange wrappers', () => { ); erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][ zrxToken.address - ].add(makerFee.add(takerFee)); + ].plus(makerFee.plus(takerFee)); }); const newOrders = [invalidOrder, ...validOrders]; @@ -773,16 +773,16 @@ describe('Exchange wrappers', () => { const newBalances = await erc20Wrapper.getBalancesAsync(); - const makerAssetFilledAmount = signedOrders[0].makerAssetAmount.add( + const makerAssetFilledAmount = signedOrders[0].makerAssetAmount.plus( signedOrders[1].makerAssetAmount.dividedToIntegerBy(2), ); - const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2)); - const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2)); + const makerFee = signedOrders[0].makerFee.plus(signedOrders[1].makerFee.dividedToIntegerBy(2)); + const takerFee = signedOrders[0].takerFee.plus(signedOrders[1].takerFee.dividedToIntegerBy(2)); expect(newBalances[makerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( erc20Balances[makerAddress][defaultMakerAssetAddress].minus(makerAssetFilledAmount), ); expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( - erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount), + erc20Balances[makerAddress][defaultTakerAssetAddress].plus(takerAssetFillAmount), ); expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[makerAddress][zrxToken.address].minus(makerFee), @@ -791,13 +791,13 @@ describe('Exchange wrappers', () => { erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount), ); expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( - erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount), + erc20Balances[takerAddress][defaultMakerAssetAddress].plus(makerAssetFilledAmount), ); expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[takerAddress][zrxToken.address].minus(takerFee), ); expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFee.add(takerFee)), + erc20Balances[feeRecipientAddress][zrxToken.address].plus(makerFee.plus(takerFee)), ); }); @@ -809,13 +809,13 @@ describe('Exchange wrappers', () => { ].minus(signedOrder.makerAssetAmount); erc20Balances[makerAddress][defaultTakerAssetAddress] = erc20Balances[makerAddress][ defaultTakerAssetAddress - ].add(signedOrder.takerAssetAmount); + ].plus(signedOrder.takerAssetAmount); erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus( signedOrder.makerFee, ); erc20Balances[takerAddress][defaultMakerAssetAddress] = erc20Balances[takerAddress][ defaultMakerAssetAddress - ].add(signedOrder.makerAssetAmount); + ].plus(signedOrder.makerAssetAmount); erc20Balances[takerAddress][defaultTakerAssetAddress] = erc20Balances[takerAddress][ defaultTakerAssetAddress ].minus(signedOrder.takerAssetAmount); @@ -824,7 +824,7 @@ describe('Exchange wrappers', () => { ); erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][ zrxToken.address - ].add(signedOrder.makerFee.add(signedOrder.takerFee)); + ].plus(signedOrder.makerFee.plus(signedOrder.takerFee)); }); await exchangeWrapper.marketSellOrdersAsync(signedOrders, takerAddress, { takerAssetFillAmount, @@ -890,16 +890,16 @@ describe('Exchange wrappers', () => { const newBalances = await erc20Wrapper.getBalancesAsync(); - const makerAssetFilledAmount = signedOrders[0].makerAssetAmount.add( + const makerAssetFilledAmount = signedOrders[0].makerAssetAmount.plus( signedOrders[1].makerAssetAmount.dividedToIntegerBy(2), ); - const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2)); - const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2)); + const makerFee = signedOrders[0].makerFee.plus(signedOrders[1].makerFee.dividedToIntegerBy(2)); + const takerFee = signedOrders[0].takerFee.plus(signedOrders[1].takerFee.dividedToIntegerBy(2)); expect(newBalances[makerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( erc20Balances[makerAddress][defaultMakerAssetAddress].minus(makerAssetFilledAmount), ); expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( - erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount), + erc20Balances[makerAddress][defaultTakerAssetAddress].plus(takerAssetFillAmount), ); expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[makerAddress][zrxToken.address].minus(makerFee), @@ -908,13 +908,13 @@ describe('Exchange wrappers', () => { erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount), ); expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( - erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount), + erc20Balances[takerAddress][defaultMakerAssetAddress].plus(makerAssetFilledAmount), ); expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[takerAddress][zrxToken.address].minus(takerFee), ); expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFee.add(takerFee)), + erc20Balances[feeRecipientAddress][zrxToken.address].plus(makerFee.plus(takerFee)), ); }); @@ -926,13 +926,13 @@ describe('Exchange wrappers', () => { ].minus(signedOrder.makerAssetAmount); erc20Balances[makerAddress][defaultTakerAssetAddress] = erc20Balances[makerAddress][ defaultTakerAssetAddress - ].add(signedOrder.takerAssetAmount); + ].plus(signedOrder.takerAssetAmount); erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus( signedOrder.makerFee, ); erc20Balances[takerAddress][defaultMakerAssetAddress] = erc20Balances[takerAddress][ defaultMakerAssetAddress - ].add(signedOrder.makerAssetAmount); + ].plus(signedOrder.makerAssetAmount); erc20Balances[takerAddress][defaultTakerAssetAddress] = erc20Balances[takerAddress][ defaultTakerAssetAddress ].minus(signedOrder.takerAssetAmount); @@ -941,7 +941,7 @@ describe('Exchange wrappers', () => { ); erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][ zrxToken.address - ].add(signedOrder.makerFee.add(signedOrder.takerFee)); + ].plus(signedOrder.makerFee.plus(signedOrder.takerFee)); }); await exchangeWrapper.marketSellOrdersNoThrowAsync(signedOrders, takerAddress, { takerAssetFillAmount, @@ -971,13 +971,13 @@ describe('Exchange wrappers', () => { ].minus(signedOrder.makerAssetAmount); erc20Balances[makerAddress][defaultTakerAssetAddress] = erc20Balances[makerAddress][ defaultTakerAssetAddress - ].add(signedOrder.takerAssetAmount); + ].plus(signedOrder.takerAssetAmount); erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus( signedOrder.makerFee, ); erc20Balances[takerAddress][defaultMakerAssetAddress] = erc20Balances[takerAddress][ defaultMakerAssetAddress - ].add(signedOrder.makerAssetAmount); + ].plus(signedOrder.makerAssetAmount); erc20Balances[takerAddress][defaultTakerAssetAddress] = erc20Balances[takerAddress][ defaultTakerAssetAddress ].minus(signedOrder.takerAssetAmount); @@ -986,7 +986,7 @@ describe('Exchange wrappers', () => { ); erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][ zrxToken.address - ].add(signedOrder.makerFee.add(signedOrder.takerFee)); + ].plus(signedOrder.makerFee.plus(signedOrder.takerFee)); }); await exchangeWrapper.marketSellOrdersNoThrowAsync(signedOrders, takerAddress, { takerAssetFillAmount, @@ -1034,16 +1034,16 @@ describe('Exchange wrappers', () => { const newBalances = await erc20Wrapper.getBalancesAsync(); - const makerAmountBought = signedOrders[0].takerAssetAmount.add( + const makerAmountBought = signedOrders[0].takerAssetAmount.plus( signedOrders[1].takerAssetAmount.dividedToIntegerBy(2), ); - const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2)); - const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2)); + const makerFee = signedOrders[0].makerFee.plus(signedOrders[1].makerFee.dividedToIntegerBy(2)); + const takerFee = signedOrders[0].takerFee.plus(signedOrders[1].takerFee.dividedToIntegerBy(2)); expect(newBalances[makerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( erc20Balances[makerAddress][defaultMakerAssetAddress].minus(makerAssetFillAmount), ); expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( - erc20Balances[makerAddress][defaultTakerAssetAddress].add(makerAmountBought), + erc20Balances[makerAddress][defaultTakerAssetAddress].plus(makerAmountBought), ); expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[makerAddress][zrxToken.address].minus(makerFee), @@ -1052,13 +1052,13 @@ describe('Exchange wrappers', () => { erc20Balances[takerAddress][defaultTakerAssetAddress].minus(makerAmountBought), ); expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( - erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFillAmount), + erc20Balances[takerAddress][defaultMakerAssetAddress].plus(makerAssetFillAmount), ); expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[takerAddress][zrxToken.address].minus(takerFee), ); expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFee.add(takerFee)), + erc20Balances[feeRecipientAddress][zrxToken.address].plus(makerFee.plus(takerFee)), ); }); @@ -1070,13 +1070,13 @@ describe('Exchange wrappers', () => { ].minus(signedOrder.makerAssetAmount); erc20Balances[makerAddress][defaultTakerAssetAddress] = erc20Balances[makerAddress][ defaultTakerAssetAddress - ].add(signedOrder.takerAssetAmount); + ].plus(signedOrder.takerAssetAmount); erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus( signedOrder.makerFee, ); erc20Balances[takerAddress][defaultMakerAssetAddress] = erc20Balances[takerAddress][ defaultMakerAssetAddress - ].add(signedOrder.makerAssetAmount); + ].plus(signedOrder.makerAssetAmount); erc20Balances[takerAddress][defaultTakerAssetAddress] = erc20Balances[takerAddress][ defaultTakerAssetAddress ].minus(signedOrder.takerAssetAmount); @@ -1085,7 +1085,7 @@ describe('Exchange wrappers', () => { ); erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][ zrxToken.address - ].add(signedOrder.makerFee.add(signedOrder.takerFee)); + ].plus(signedOrder.makerFee.plus(signedOrder.takerFee)); }); await exchangeWrapper.marketBuyOrdersAsync(signedOrders, takerAddress, { makerAssetFillAmount, @@ -1149,16 +1149,16 @@ describe('Exchange wrappers', () => { const newBalances = await erc20Wrapper.getBalancesAsync(); - const makerAmountBought = signedOrders[0].takerAssetAmount.add( + const makerAmountBought = signedOrders[0].takerAssetAmount.plus( signedOrders[1].takerAssetAmount.dividedToIntegerBy(2), ); - const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2)); - const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2)); + const makerFee = signedOrders[0].makerFee.plus(signedOrders[1].makerFee.dividedToIntegerBy(2)); + const takerFee = signedOrders[0].takerFee.plus(signedOrders[1].takerFee.dividedToIntegerBy(2)); expect(newBalances[makerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( erc20Balances[makerAddress][defaultMakerAssetAddress].minus(makerAssetFillAmount), ); expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( - erc20Balances[makerAddress][defaultTakerAssetAddress].add(makerAmountBought), + erc20Balances[makerAddress][defaultTakerAssetAddress].plus(makerAmountBought), ); expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[makerAddress][zrxToken.address].minus(makerFee), @@ -1167,13 +1167,13 @@ describe('Exchange wrappers', () => { erc20Balances[takerAddress][defaultTakerAssetAddress].minus(makerAmountBought), ); expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( - erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFillAmount), + erc20Balances[takerAddress][defaultMakerAssetAddress].plus(makerAssetFillAmount), ); expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( erc20Balances[takerAddress][zrxToken.address].minus(takerFee), ); expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFee.add(takerFee)), + erc20Balances[feeRecipientAddress][zrxToken.address].plus(makerFee.plus(takerFee)), ); }); @@ -1185,13 +1185,13 @@ describe('Exchange wrappers', () => { ].minus(signedOrder.makerAssetAmount); erc20Balances[makerAddress][defaultTakerAssetAddress] = erc20Balances[makerAddress][ defaultTakerAssetAddress - ].add(signedOrder.takerAssetAmount); + ].plus(signedOrder.takerAssetAmount); erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus( signedOrder.makerFee, ); erc20Balances[takerAddress][defaultMakerAssetAddress] = erc20Balances[takerAddress][ defaultMakerAssetAddress - ].add(signedOrder.makerAssetAmount); + ].plus(signedOrder.makerAssetAmount); erc20Balances[takerAddress][defaultTakerAssetAddress] = erc20Balances[takerAddress][ defaultTakerAssetAddress ].minus(signedOrder.takerAssetAmount); @@ -1200,7 +1200,7 @@ describe('Exchange wrappers', () => { ); erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][ zrxToken.address - ].add(signedOrder.makerFee.add(signedOrder.takerFee)); + ].plus(signedOrder.makerFee.plus(signedOrder.takerFee)); }); await exchangeWrapper.marketBuyOrdersNoThrowAsync(signedOrders, takerAddress, { makerAssetFillAmount, @@ -1231,13 +1231,13 @@ describe('Exchange wrappers', () => { ].minus(signedOrder.makerAssetAmount); erc20Balances[makerAddress][defaultTakerAssetAddress] = erc20Balances[makerAddress][ defaultTakerAssetAddress - ].add(signedOrder.takerAssetAmount); + ].plus(signedOrder.takerAssetAmount); erc20Balances[makerAddress][zrxToken.address] = erc20Balances[makerAddress][zrxToken.address].minus( signedOrder.makerFee, ); erc20Balances[takerAddress][defaultMakerAssetAddress] = erc20Balances[takerAddress][ defaultMakerAssetAddress - ].add(signedOrder.makerAssetAmount); + ].plus(signedOrder.makerAssetAmount); erc20Balances[takerAddress][defaultTakerAssetAddress] = erc20Balances[takerAddress][ defaultTakerAssetAddress ].minus(signedOrder.takerAssetAmount); @@ -1246,7 +1246,7 @@ describe('Exchange wrappers', () => { ); erc20Balances[feeRecipientAddress][zrxToken.address] = erc20Balances[feeRecipientAddress][ zrxToken.address - ].add(signedOrder.makerFee.add(signedOrder.takerFee)); + ].plus(signedOrder.makerFee.plus(signedOrder.takerFee)); }); await exchangeWrapper.marketBuyOrdersNoThrowAsync(signedOrders, takerAddress, { makerAssetFillAmount, diff --git a/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts b/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts index 2fd33bebd..c2f530e5b 100644 --- a/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts +++ b/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts @@ -469,7 +469,7 @@ export class FillOrderCombinatorialUtils { const remainingTakerAmountToFill = signedOrder.takerAssetAmount.minus(alreadyFilledTakerAmount); const expFilledTakerAmount = takerAssetFillAmount.gt(remainingTakerAmountToFill) ? remainingTakerAmountToFill - : alreadyFilledTakerAmount.add(takerAssetFillAmount); + : alreadyFilledTakerAmount.plus(takerAssetFillAmount); const expFilledMakerAmount = orderUtils.getPartialAmountFloor( expFilledTakerAmount, @@ -644,7 +644,7 @@ export class FillOrderCombinatorialUtils { break; case TakerAssetFillAmountScenario.GreaterThanRemainingFillableTakerAssetAmount: - takerAssetFillAmount = fillableTakerAssetAmount.add(1); + takerAssetFillAmount = fillableTakerAssetAmount.plus(1); break; case TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount: @@ -657,7 +657,7 @@ export class FillOrderCombinatorialUtils { 'Cannot test `TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount` together with ERC721 assets since orders involving ERC721 must always be filled exactly.', ); } - takerAssetFillAmount = fillableTakerAssetAmount.div(2).floor(); + takerAssetFillAmount = fillableTakerAssetAmount.div(2).integerValue(BigNumber.ROUND_FLOOR); break; default: diff --git a/contracts/protocol/test/utils/match_order_tester.ts b/contracts/protocol/test/utils/match_order_tester.ts index 31864820f..0ba8017c5 100644 --- a/contracts/protocol/test/utils/match_order_tester.ts +++ b/contracts/protocol/test/utils/match_order_tester.ts @@ -66,7 +66,7 @@ export class MatchOrderTester { const feePaidByRightMaker = new BigNumber(rightLog.makerFeePaid); const feePaidByTakerRight = new BigNumber(rightLog.takerFeePaid); // Derive amount received by taker - const amountReceivedByTaker = amountSoldByLeftMaker.sub(amountBoughtByRightMaker); + const amountReceivedByTaker = amountSoldByLeftMaker.minus(amountBoughtByRightMaker); // Assert log values - left order expect(amountBoughtByLeftMaker, 'Checking logged amount bought by left maker').to.be.bignumber.equal( expectedTransferAmounts.amountBoughtByLeftMaker, @@ -267,14 +267,16 @@ export class MatchOrderTester { // Assert left order status const maxAmountBoughtByLeftMaker = signedOrderLeft.takerAssetAmount.minus(initialLeftOrderFilledAmount); const leftOrderInfo: OrderInfo = await this._exchangeWrapper.getOrderInfoAsync(signedOrderLeft); - const leftExpectedStatus = expectedTransferAmounts.amountBoughtByLeftMaker.equals(maxAmountBoughtByLeftMaker) + const leftExpectedStatus = expectedTransferAmounts.amountBoughtByLeftMaker.isEqualTo(maxAmountBoughtByLeftMaker) ? OrderStatus.FullyFilled : OrderStatus.Fillable; expect(leftOrderInfo.orderStatus, 'Checking exchange status for left order').to.be.equal(leftExpectedStatus); // Assert right order status const maxAmountBoughtByRightMaker = signedOrderRight.takerAssetAmount.minus(initialRightOrderFilledAmount); const rightOrderInfo: OrderInfo = await this._exchangeWrapper.getOrderInfoAsync(signedOrderRight); - const rightExpectedStatus = expectedTransferAmounts.amountBoughtByRightMaker.equals(maxAmountBoughtByRightMaker) + const rightExpectedStatus = expectedTransferAmounts.amountBoughtByRightMaker.isEqualTo( + maxAmountBoughtByRightMaker, + ) ? OrderStatus.FullyFilled : OrderStatus.Fillable; expect(rightOrderInfo.orderStatus, 'Checking exchange status for right order').to.be.equal(rightExpectedStatus); @@ -364,13 +366,13 @@ export class MatchOrderTester { // Right Maker expectedNewERC20BalancesByOwner[makerAddressRight][ takerAssetAddressRight - ] = expectedNewERC20BalancesByOwner[makerAddressRight][takerAssetAddressRight].add( + ] = expectedNewERC20BalancesByOwner[makerAddressRight][takerAssetAddressRight].plus( expectedTransferAmounts.amountBoughtByRightMaker, ); // Taker expectedNewERC20BalancesByOwner[takerAddress][makerAssetAddressLeft] = expectedNewERC20BalancesByOwner[ takerAddress - ][makerAssetAddressLeft].add(expectedTransferAmounts.amountReceivedByTaker); + ][makerAssetAddressLeft].plus(expectedTransferAmounts.amountReceivedByTaker); } else if (makerAssetProxyIdLeft === AssetProxyId.ERC721) { // Decode asset data const erc721AssetData = assetDataUtils.decodeERC721AssetData(signedOrderLeft.makerAssetData); @@ -395,7 +397,7 @@ export class MatchOrderTester { // Left Maker expectedNewERC20BalancesByOwner[makerAddressLeft][takerAssetAddressLeft] = expectedNewERC20BalancesByOwner[ makerAddressLeft - ][takerAssetAddressLeft].add(expectedTransferAmounts.amountBoughtByLeftMaker); + ][takerAssetAddressLeft].plus(expectedTransferAmounts.amountBoughtByLeftMaker); // Right Maker expectedNewERC20BalancesByOwner[makerAddressRight][ makerAssetAddressRight @@ -426,19 +428,19 @@ export class MatchOrderTester { expectedNewERC20BalancesByOwner[takerAddress][this._feeTokenAddress] = expectedNewERC20BalancesByOwner[ takerAddress ][this._feeTokenAddress].minus( - expectedTransferAmounts.feePaidByTakerLeft.add(expectedTransferAmounts.feePaidByTakerRight), + expectedTransferAmounts.feePaidByTakerLeft.plus(expectedTransferAmounts.feePaidByTakerRight), ); // Left Fee Recipient Fees expectedNewERC20BalancesByOwner[feeRecipientAddressLeft][ this._feeTokenAddress - ] = expectedNewERC20BalancesByOwner[feeRecipientAddressLeft][this._feeTokenAddress].add( - expectedTransferAmounts.feePaidByLeftMaker.add(expectedTransferAmounts.feePaidByTakerLeft), + ] = expectedNewERC20BalancesByOwner[feeRecipientAddressLeft][this._feeTokenAddress].plus( + expectedTransferAmounts.feePaidByLeftMaker.plus(expectedTransferAmounts.feePaidByTakerLeft), ); // Right Fee Recipient Fees expectedNewERC20BalancesByOwner[feeRecipientAddressRight][ this._feeTokenAddress - ] = expectedNewERC20BalancesByOwner[feeRecipientAddressRight][this._feeTokenAddress].add( - expectedTransferAmounts.feePaidByRightMaker.add(expectedTransferAmounts.feePaidByTakerRight), + ] = expectedNewERC20BalancesByOwner[feeRecipientAddressRight][this._feeTokenAddress].plus( + expectedTransferAmounts.feePaidByRightMaker.plus(expectedTransferAmounts.feePaidByTakerRight), ); return [expectedNewERC20BalancesByOwner, expectedNewERC721TokenIdsByOwner]; |