diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-12-15 02:23:01 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-12-15 07:34:45 +0800 |
commit | a3d93d17cdefc2258a9f08e6fc680df1fb2b8456 (patch) | |
tree | 0f074b7205b4026b0e3b9bd84c9d8a1257411757 /packages/asset-buyer/test/buy_quote_calculator_test.ts | |
parent | c6c45095a8511814db6aa33e39794ae60debad8b (diff) | |
download | dexon-sol-tools-a3d93d17cdefc2258a9f08e6fc680df1fb2b8456.tar dexon-sol-tools-a3d93d17cdefc2258a9f08e6fc680df1fb2b8456.tar.gz dexon-sol-tools-a3d93d17cdefc2258a9f08e6fc680df1fb2b8456.tar.bz2 dexon-sol-tools-a3d93d17cdefc2258a9f08e6fc680df1fb2b8456.tar.lz dexon-sol-tools-a3d93d17cdefc2258a9f08e6fc680df1fb2b8456.tar.xz dexon-sol-tools-a3d93d17cdefc2258a9f08e6fc680df1fb2b8456.tar.zst dexon-sol-tools-a3d93d17cdefc2258a9f08e6fc680df1fb2b8456.zip |
Factor in slippage amount in InsufficientAssetLiquidityError error, and show in instant
Diffstat (limited to 'packages/asset-buyer/test/buy_quote_calculator_test.ts')
-rw-r--r-- | packages/asset-buyer/test/buy_quote_calculator_test.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/asset-buyer/test/buy_quote_calculator_test.ts b/packages/asset-buyer/test/buy_quote_calculator_test.ts index 1dd829a0f..98458cd5b 100644 --- a/packages/asset-buyer/test/buy_quote_calculator_test.ts +++ b/packages/asset-buyer/test/buy_quote_calculator_test.ts @@ -81,6 +81,34 @@ describe('buyQuoteCalculator', () => { }; testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(400)); }); + it('should throw if not enough maker asset liquidity (multiple orders with 20% slippage)', () => { + // we have 400 makerAsset units available to fill but attempt to calculate a quote for 500 makerAsset units + const errorFunction = () => { + buyQuoteCalculator.calculate( + ordersAndFillableAmounts, + smallFeeOrderAndFillableAmount, + new BigNumber(500), + 0, + 0.2, + false, + ); + }; + testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(333)); + }); + it('should throw if not enough maker asset liquidity (multiple orders with 5% slippage)', () => { + // we have 400 makerAsset units available to fill but attempt to calculate a quote for 500 makerAsset units + const errorFunction = () => { + buyQuoteCalculator.calculate( + ordersAndFillableAmounts, + smallFeeOrderAndFillableAmount, + new BigNumber(600), + 0, + 0.05, + false, + ); + }; + testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(380)); + }); it('should throw if not enough maker asset liquidity (partially filled order)', () => { const firstOrderAndFillableAmount: OrdersAndFillableAmounts = { orders: [firstOrder], |