diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-14 00:36:30 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-14 00:36:30 +0800 |
commit | 6239686afaf733707ad0c4687c535969c2d53205 (patch) | |
tree | c43588ae155b03b1e7fbadfff69892301237c62f /packages/order-utils | |
parent | 45186b70ec446a42736dd99b947463b1e1569b59 (diff) | |
download | dexon-0x-contracts-6239686afaf733707ad0c4687c535969c2d53205.tar dexon-0x-contracts-6239686afaf733707ad0c4687c535969c2d53205.tar.gz dexon-0x-contracts-6239686afaf733707ad0c4687c535969c2d53205.tar.bz2 dexon-0x-contracts-6239686afaf733707ad0c4687c535969c2d53205.tar.lz dexon-0x-contracts-6239686afaf733707ad0c4687c535969c2d53205.tar.xz 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.ts | 6 |
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()) { |