diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-12-15 07:18:20 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-12-15 07:34:45 +0800 |
commit | 69054d85e80f9e41200015a9b0eef2a9fe00f439 (patch) | |
tree | c8296279c2f51518940cc772a26e626f5931e9de /packages/asset-buyer/src/utils | |
parent | 3e596f6a8c211eb39917cfd2a9a68a6facf2c904 (diff) | |
download | dexon-sol-tools-69054d85e80f9e41200015a9b0eef2a9fe00f439.tar.gz dexon-sol-tools-69054d85e80f9e41200015a9b0eef2a9fe00f439.tar.zst dexon-sol-tools-69054d85e80f9e41200015a9b0eef2a9fe00f439.zip |
Only send in amountAvailableToFill if it's a non-zero amount, add additional tests and nest, and put error into its own file
Diffstat (limited to 'packages/asset-buyer/src/utils')
-rw-r--r-- | packages/asset-buyer/src/utils/buy_quote_calculator.ts | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/packages/asset-buyer/src/utils/buy_quote_calculator.ts b/packages/asset-buyer/src/utils/buy_quote_calculator.ts index 23d3e9b24..59293d1b7 100644 --- a/packages/asset-buyer/src/utils/buy_quote_calculator.ts +++ b/packages/asset-buyer/src/utils/buy_quote_calculator.ts @@ -1,16 +1,10 @@ import { marketUtils, SignedOrder } from '@0x/order-utils'; import { BigNumber } from '@0x/utils'; -import { Web3Wrapper } from '@0x/web3-wrapper'; import * as _ from 'lodash'; import { constants } from '../constants'; -import { - AssetBuyerError, - BuyQuote, - BuyQuoteInfo, - InsufficientAssetLiquidityError, - OrdersAndFillableAmounts, -} from '../types'; +import { InsufficientAssetLiquidityError } from '../errors'; +import { AssetBuyerError, BuyQuote, BuyQuoteInfo, OrdersAndFillableAmounts } from '../types'; import { orderUtils } from './order_utils'; @@ -53,7 +47,11 @@ export const buyQuoteCalculator = { .div(multiplerNeededWithSlippage) .round(0, BigNumber.ROUND_DOWN); - throw new InsufficientAssetLiquidityError(amountAvailableToFillConsideringSlippage); + throw new InsufficientAssetLiquidityError( + amountAvailableToFillConsideringSlippage.gt(constants.ZERO_AMOUNT) + ? amountAvailableToFillConsideringSlippage + : undefined, + ); } // if we are not buying ZRX: // given the orders calculated above, find the fee-orders that cover the desired assetBuyAmount (with slippage) |