aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorJacob Evans <jacob@dekz.net>2017-11-22 08:08:39 +0800
committerJacob Evans <jacob@dekz.net>2017-11-22 08:08:39 +0800
commit9c9ce9752537122df51b935bf1f63f128414fc0f (patch)
tree75c20266d3bc088bc1be15d396f39fa3561480cf /packages
parent4bfb1fcc715b6da3352e1a6cbfe55bed0a973a78 (diff)
downloaddexon-sol-tools-9c9ce9752537122df51b935bf1f63f128414fc0f.tar.gz
dexon-sol-tools-9c9ce9752537122df51b935bf1f63f128414fc0f.tar.zst
dexon-sol-tools-9c9ce9752537122df51b935bf1f63f128414fc0f.zip
Perform the division last to not compound any errors
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/src/order_watcher/remaining_fillable_calculator.ts8
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;