diff options
author | Jacob Evans <jacob@dekz.net> | 2017-11-22 08:08:39 +0800 |
---|---|---|
committer | Jacob Evans <jacob@dekz.net> | 2017-11-22 08:08:39 +0800 |
commit | 9c9ce9752537122df51b935bf1f63f128414fc0f (patch) | |
tree | 75c20266d3bc088bc1be15d396f39fa3561480cf /packages/0x.js | |
parent | 4bfb1fcc715b6da3352e1a6cbfe55bed0a973a78 (diff) | |
download | dexon-0x-contracts-9c9ce9752537122df51b935bf1f63f128414fc0f.tar.gz dexon-0x-contracts-9c9ce9752537122df51b935bf1f63f128414fc0f.tar.zst dexon-0x-contracts-9c9ce9752537122df51b935bf1f63f128414fc0f.zip |
Perform the division last to not compound any errors
Diffstat (limited to 'packages/0x.js')
-rw-r--r-- | packages/0x.js/src/order_watcher/remaining_fillable_calculator.ts | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/packages/0x.js/src/order_watcher/remaining_fillable_calculator.ts b/packages/0x.js/src/order_watcher/remaining_fillable_calculator.ts index b98ef3240..30f79e786 100644 --- a/packages/0x.js/src/order_watcher/remaining_fillable_calculator.ts +++ b/packages/0x.js/src/order_watcher/remaining_fillable_calculator.ts @@ -74,8 +74,12 @@ export class RemainingFillableCalculator { } // When Ratio is not fully divisible there can be remainders which cannot be represented, so they are floored. // This can result in a RoundingError being thrown by the Exchange Contract. - const partiallyFillableMakerTokenAmount = fillableTimesInMakerTokenUnits.times(orderToFeeRatio).floor(); - const partiallyFillableFeeTokenAmount = fillableTimesInFeeTokenBaseUnits.times(orderToFeeRatio).floor(); + const partiallyFillableMakerTokenAmount = fillableTimesInMakerTokenUnits + .times(this.signedOrder.makerTokenAmount) + .dividedToIntegerBy(this.signedOrder.makerFee); + const partiallyFillableFeeTokenAmount = fillableTimesInFeeTokenBaseUnits + .times(this.signedOrder.makerTokenAmount) + .dividedToIntegerBy(this.signedOrder.makerFee); const partiallyFillableAmount = BigNumber.min(partiallyFillableMakerTokenAmount, partiallyFillableFeeTokenAmount); return partiallyFillableAmount; |