aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/test
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-10-23 14:23:50 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-10-24 05:06:21 +0800
commit4db33ba2b37f4682ecae5da325e631d546a8a24e (patch)
treec0453e856ee02a5d4538ee640a34cdb46861dc94 /packages/asset-buyer/test
parent37f87ab267c5eb10c70d7eb4d3eef01bf8ed7ac1 (diff)
downloaddexon-sol-tools-4db33ba2b37f4682ecae5da325e631d546a8a24e.tar
dexon-sol-tools-4db33ba2b37f4682ecae5da325e631d546a8a24e.tar.gz
dexon-sol-tools-4db33ba2b37f4682ecae5da325e631d546a8a24e.tar.bz2
dexon-sol-tools-4db33ba2b37f4682ecae5da325e631d546a8a24e.tar.lz
dexon-sol-tools-4db33ba2b37f4682ecae5da325e631d546a8a24e.tar.xz
dexon-sol-tools-4db33ba2b37f4682ecae5da325e631d546a8a24e.tar.zst
dexon-sol-tools-4db33ba2b37f4682ecae5da325e631d546a8a24e.zip
feat(asset-buyer): update buyQuoteCalculator to match rounding behavior in contracts
Diffstat (limited to 'packages/asset-buyer/test')
-rw-r--r--packages/asset-buyer/test/buy_quote_calculator_test.ts12
1 files changed, 8 insertions, 4 deletions
diff --git a/packages/asset-buyer/test/buy_quote_calculator_test.ts b/packages/asset-buyer/test/buy_quote_calculator_test.ts
index 0f516a0f7..0ea371982 100644
--- a/packages/asset-buyer/test/buy_quote_calculator_test.ts
+++ b/packages/asset-buyer/test/buy_quote_calculator_test.ts
@@ -49,9 +49,9 @@ describe('buyQuoteCalculator', () => {
remainingFillableMakerAssetAmounts: [smallFeeOrder.makerAssetAmount],
};
const largeFeeOrder = orderFactory.createSignedOrderFromPartial({
- makerAssetAmount: new BigNumber(110),
+ makerAssetAmount: new BigNumber(113),
takerAssetAmount: new BigNumber(200),
- takerFee: new BigNumber(10),
+ takerFee: new BigNumber(11),
});
allFeeOrdersAndFillableAmounts = {
orders: [smallFeeOrder, largeFeeOrder],
@@ -70,6 +70,7 @@ describe('buyQuoteCalculator', () => {
new BigNumber(500),
0,
0,
+ false,
),
).to.throw(AssetBuyerError.InsufficientAssetLiquidity);
});
@@ -82,6 +83,7 @@ describe('buyQuoteCalculator', () => {
new BigNumber(300),
0,
0,
+ false,
),
).to.throw(AssetBuyerError.InsufficientZrxLiquidity);
});
@@ -97,6 +99,7 @@ describe('buyQuoteCalculator', () => {
assetBuyAmount,
feePercentage,
slippagePercentage,
+ false,
);
// test if orders are correct
expect(buyQuote.orders).to.deep.equal([ordersAndFillableAmounts.orders[0]]);
@@ -134,6 +137,7 @@ describe('buyQuoteCalculator', () => {
assetBuyAmount,
feePercentage,
slippagePercentage,
+ false,
);
// test if orders are correct
expect(buyQuote.orders).to.deep.equal(ordersAndFillableAmounts.orders);
@@ -149,9 +153,9 @@ describe('buyQuoteCalculator', () => {
expect(buyQuote.bestCaseQuoteInfo.feeEthAmount).to.bignumber.equal(expectedFeeEthAmount);
expect(buyQuote.bestCaseQuoteInfo.totalEthAmount).to.bignumber.equal(expectedTotalEthAmount);
expect(buyQuote.bestCaseQuoteInfo.ethPerAssetPrice).to.bignumber.equal(expectedEthPerAssetPrice);
- // 100 eth to fill the first order + 200 eth for fees
+ // 100 eth to fill the first order + 208 eth for fees
const expectedWorstEthAmountForAsset = new BigNumber(100);
- const expectedWorstEthAmountForZrxFees = new BigNumber(200);
+ const expectedWorstEthAmountForZrxFees = new BigNumber(208);
const expectedWorstFillEthAmount = expectedWorstEthAmountForAsset.plus(expectedWorstEthAmountForZrxFees);
const expectedWorstFeeEthAmount = expectedWorstEthAmountForAsset.mul(feePercentage);
const expectedWorstTotalEthAmount = expectedWorstFillEthAmount.plus(expectedWorstFeeEthAmount);