Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Make amountAvailableToFill required
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklebanoff committed Dec 22, 2018
1 parent e144ebb commit c8c8219
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/asset-buyer/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export class InsufficientAssetLiquidityError extends Error {
/**
* The amount availabe to fill (in base units) factoring in slippage.
*/
public amountAvailableToFill?: BigNumber;
public amountAvailableToFill: BigNumber;
/**
* @param amountAvailableToFill The amount availabe to fill (in base units) factoring in slippage
*/
constructor(amountAvailableToFill?: BigNumber) {
constructor(amountAvailableToFill: BigNumber) {
super(AssetBuyerError.InsufficientAssetLiquidity);
this.amountAvailableToFill = amountAvailableToFill;
// Setting prototype so instanceof works. See https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
Expand Down
6 changes: 1 addition & 5 deletions packages/asset-buyer/src/utils/buy_quote_calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ export const buyQuoteCalculator = {
.div(multiplerNeededWithSlippage)
.round(0, BigNumber.ROUND_DOWN);

throw new InsufficientAssetLiquidityError(
amountAvailableToFillConsideringSlippage.gt(constants.ZERO_AMOUNT)
? amountAvailableToFillConsideringSlippage
: undefined,
);
throw new InsufficientAssetLiquidityError(amountAvailableToFillConsideringSlippage);
}
// if we are not buying ZRX:
// given the orders calculated above, find the fee-orders that cover the desired assetBuyAmount (with slippage)
Expand Down
1 change: 0 additions & 1 deletion packages/instant/src/util/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export const assetUtils = {
const assetName = assetUtils.bestNameForAsset(asset, 'of this asset');
if (
error instanceof InsufficientAssetLiquidityError &&
error.amountAvailableToFill &&
error.amountAvailableToFill.greaterThan(BIG_NUMBER_ZERO)
) {
const unitAmountAvailableToFill = Web3Wrapper.toUnitAmount(
Expand Down

0 comments on commit c8c8219

Please sign in to comment.