aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/test
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-10-05 05:33:07 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-10-05 05:37:34 +0800
commit63d97f4c8837dcf8d17afc494dcd8b1ba10fee16 (patch)
tree6b381d8920aac38a67854ed7000d216dc4d3aec5 /packages/asset-buyer/test
parent4394036e341e9755a57a29680f5b14f3c92fef9c (diff)
downloaddexon-sol-tools-63d97f4c8837dcf8d17afc494dcd8b1ba10fee16.tar
dexon-sol-tools-63d97f4c8837dcf8d17afc494dcd8b1ba10fee16.tar.gz
dexon-sol-tools-63d97f4c8837dcf8d17afc494dcd8b1ba10fee16.tar.bz2
dexon-sol-tools-63d97f4c8837dcf8d17afc494dcd8b1ba10fee16.tar.lz
dexon-sol-tools-63d97f4c8837dcf8d17afc494dcd8b1ba10fee16.tar.xz
dexon-sol-tools-63d97f4c8837dcf8d17afc494dcd8b1ba10fee16.tar.zst
dexon-sol-tools-63d97f4c8837dcf8d17afc494dcd8b1ba10fee16.zip
Update BuyQuote interface
Diffstat (limited to 'packages/asset-buyer/test')
-rw-r--r--packages/asset-buyer/test/buy_quote_calculator_test.ts34
1 files changed, 24 insertions, 10 deletions
diff --git a/packages/asset-buyer/test/buy_quote_calculator_test.ts b/packages/asset-buyer/test/buy_quote_calculator_test.ts
index 667dec051..b987b45a8 100644
--- a/packages/asset-buyer/test/buy_quote_calculator_test.ts
+++ b/packages/asset-buyer/test/buy_quote_calculator_test.ts
@@ -103,11 +103,17 @@ describe('buyQuoteCalculator', () => {
expect(buyQuote.feeOrders).to.deep.equal([smallFeeOrderAndFillableAmount.orders[0]]);
// test if rates are correct
// 50 eth to fill the first order + 100 eth for fees
- const expectedMinEthToFill = new BigNumber(150);
- const expectedMinRate = assetBuyAmount.div(expectedMinEthToFill.mul(feePercentage + 1));
- expect(buyQuote.minRate).to.bignumber.equal(expectedMinRate);
+ const expectedFillEthAmount = new BigNumber(150);
+ const expectedTotalEthAmount = expectedFillEthAmount.mul(feePercentage + 1);
+ const expectedFeeEthAmount = expectedTotalEthAmount.minus(expectedFillEthAmount);
+ const expectedEthPerAssetPrice = expectedFillEthAmount.div(assetBuyAmount);
+ expect(buyQuote.bestCaseQuoteInfo.feeEthAmount).to.bignumber.equal(expectedFeeEthAmount);
+ expect(buyQuote.bestCaseQuoteInfo.totalEthAmount).to.bignumber.equal(expectedTotalEthAmount);
+ expect(buyQuote.bestCaseQuoteInfo.ethPerAssetPrice).to.bignumber.equal(expectedEthPerAssetPrice);
// because we have no slippage protection, minRate is equal to maxRate
- expect(buyQuote.maxRate).to.bignumber.equal(expectedMinRate);
+ expect(buyQuote.worstCaseQuoteInfo.feeEthAmount).to.bignumber.equal(expectedFeeEthAmount);
+ expect(buyQuote.worstCaseQuoteInfo.totalEthAmount).to.bignumber.equal(expectedTotalEthAmount);
+ expect(buyQuote.worstCaseQuoteInfo.ethPerAssetPrice).to.bignumber.equal(expectedEthPerAssetPrice);
// test if feePercentage gets passed through
expect(buyQuote.feePercentage).to.equal(feePercentage);
});
@@ -132,13 +138,21 @@ describe('buyQuoteCalculator', () => {
expect(buyQuote.feeOrders).to.deep.equal(allFeeOrdersAndFillableAmounts.orders);
// test if rates are correct
// 50 eth to fill the first order + 100 eth for fees
- const expectedMinEthToFill = new BigNumber(150);
- const expectedMinRate = assetBuyAmount.div(expectedMinEthToFill.mul(feePercentage + 1));
- expect(buyQuote.minRate).to.bignumber.equal(expectedMinRate);
+ const expectedFillEthAmount = new BigNumber(150);
+ const expectedTotalEthAmount = expectedFillEthAmount.mul(feePercentage + 1);
+ const expectedFeeEthAmount = expectedTotalEthAmount.minus(expectedFillEthAmount);
+ const expectedEthPerAssetPrice = expectedFillEthAmount.div(assetBuyAmount);
+ 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
- const expectedMaxEthToFill = new BigNumber(300);
- const expectedMaxRate = assetBuyAmount.div(expectedMaxEthToFill.mul(feePercentage + 1));
- expect(buyQuote.maxRate).to.bignumber.equal(expectedMaxRate);
+ const expectedWorstFillEthAmount = new BigNumber(300);
+ const expectedWorstTotalEthAmount = expectedWorstFillEthAmount.mul(feePercentage + 1);
+ const expectedWorstFeeEthAmount = expectedWorstTotalEthAmount.minus(expectedWorstFillEthAmount);
+ const expectedWorstEthPerAssetPrice = expectedWorstFillEthAmount.div(assetBuyAmount);
+ expect(buyQuote.worstCaseQuoteInfo.feeEthAmount).to.bignumber.equal(expectedWorstFeeEthAmount);
+ expect(buyQuote.worstCaseQuoteInfo.totalEthAmount).to.bignumber.equal(expectedWorstTotalEthAmount);
+ expect(buyQuote.worstCaseQuoteInfo.ethPerAssetPrice).to.bignumber.equal(expectedWorstEthPerAssetPrice);
// test if feePercentage gets passed through
expect(buyQuote.feePercentage).to.equal(feePercentage);
});