aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-06-14 00:36:30 +0800
committerFabio Berger <me@fabioberger.com>2018-06-14 00:36:30 +0800
commit6239686afaf733707ad0c4687c535969c2d53205 (patch)
treec43588ae155b03b1e7fbadfff69892301237c62f /packages/order-utils
parent45186b70ec446a42736dd99b947463b1e1569b59 (diff)
downloaddexon-0x-contracts-6239686afaf733707ad0c4687c535969c2d53205.tar.gz
dexon-0x-contracts-6239686afaf733707ad0c4687c535969c2d53205.tar.zst
dexon-0x-contracts-6239686afaf733707ad0c4687c535969c2d53205.zip
Fix divide by zero bug
Diffstat (limited to 'packages/order-utils')
-rw-r--r--packages/order-utils/src/remaining_fillable_calculator.ts6
1 files changed, 3 insertions, 3 deletions
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()) {