From 9c9ce9752537122df51b935bf1f63f128414fc0f Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Wed, 22 Nov 2017 11:08:39 +1100 Subject: Perform the division last to not compound any errors --- packages/0x.js/src/order_watcher/remaining_fillable_calculator.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'packages') 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; -- cgit v1.2.3