From 6239686afaf733707ad0c4687c535969c2d53205 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 13 Jun 2018 18:36:30 +0200 Subject: Fix divide by zero bug --- packages/order-utils/src/remaining_fillable_calculator.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'packages/order-utils') diff --git a/packages/order-utils/src/remaining_fillable_calculator.ts b/packages/order-utils/src/remaining_fillable_calculator.ts index bc146e931..29e19e5ab 100644 --- a/packages/order-utils/src/remaining_fillable_calculator.ts +++ b/packages/order-utils/src/remaining_fillable_calculator.ts @@ -23,9 +23,9 @@ export class RemainingFillableCalculator { this._transferrableAssetAmount = transferrableAssetAmount; this._transferrableFeeAmount = transferrableFeeAmount; this._remainingOrderAssetAmount = remainingOrderAssetAmount; - this._remainingOrderFeeAmount = remainingOrderAssetAmount - .times(this._orderFee) - .dividedToIntegerBy(this._orderAssetAmount); + this._remainingOrderFeeAmount = orderAssetAmount.eq(0) + ? new BigNumber(0) + : remainingOrderAssetAmount.times(orderFee).dividedToIntegerBy(orderAssetAmount); } public computeRemainingFillable(): BigNumber { if (this._hasSufficientFundsForFeeAndTransferAmount()) { -- cgit v1.2.3