From 67d33ec10c3d2467d2d073d22bfe2957353a0cc8 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 21 Aug 2018 17:07:14 -0700 Subject: Fix rounding bug in marketUtils --- packages/order-utils/CHANGELOG.json | 11 +++++++++-- packages/order-utils/src/market_utils.ts | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'packages') diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json index c4260bc2f..55e0b499e 100644 --- a/packages/order-utils/CHANGELOG.json +++ b/packages/order-utils/CHANGELOG.json @@ -17,10 +17,17 @@ }, { "note": - "Rename `resultOrders` to `resultFeeOrders` for object returned by `findFeeOrdersThatCoverFeesForTargetOrders` in `marketUtils` api" + "Rename `resultOrders` to `resultFeeOrders` for object returned by `findFeeOrdersThatCoverFeesForTargetOrders` in `marketUtils` api", + "pr": 954 + }, + { + "note": "Make `sortFeeOrdersByFeeAdjustedRate` in `sortingUtils` generic", + "pr": 954 }, { - "note": "Make `sortFeeOrdersByFeeAdjustedRate` in `sortingUtils` generic" + "note": + "Update `findFeeOrdersThatCoverFeesForTargetOrders` to round the the nearest integer when calculating required fees", + "pr": 954 } ] }, diff --git a/packages/order-utils/src/market_utils.ts b/packages/order-utils/src/market_utils.ts index 7eae4c8fc..b31a2b135 100644 --- a/packages/order-utils/src/market_utils.ts +++ b/packages/order-utils/src/market_utils.ts @@ -123,7 +123,7 @@ export const marketUtils = { const makerAssetAmountAvailable = remainingFillableMakerAssetAmounts[index]; const feeToFillMakerAssetAmountAvailable = makerAssetAmountAvailable .mul(order.takerFee) - .div(order.makerAssetAmount); + .dividedToIntegerBy(order.makerAssetAmount); return accFees.plus(feeToFillMakerAssetAmountAvailable); }, constants.ZERO_AMOUNT, -- cgit