Fix rounding bug in marketUtils

This commit is contained in:
Brandon Millman
2018-08-21 17:07:14 -07:00
parent 05ba049f59
commit 67d33ec10c
2 changed files with 10 additions and 3 deletions

View File

@@ -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"
"note": "Make `sortFeeOrdersByFeeAdjustedRate` in `sortingUtils` generic",
"pr": 954
},
{
"note":
"Update `findFeeOrdersThatCoverFeesForTargetOrders` to round the the nearest integer when calculating required fees",
"pr": 954
}
]
},

View File

@@ -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,