Round up for Market Buys in Forwarding Contract. Includes new test cases + regression testing.

This commit is contained in:
Greg Hysen
2018-10-15 17:52:51 -07:00
committed by Amir Bandeali
parent 1f0c7f8fbe
commit e086c7b8e6
3 changed files with 280 additions and 8 deletions

View File

@@ -26,9 +26,12 @@ export class ForwarderWrapper {
_.forEach(feeOrders, feeOrder => {
const feeAvailable = feeOrder.makerAssetAmount.minus(feeOrder.takerFee);
if (!remainingFeeAmount.isZero() && feeAvailable.gt(remainingFeeAmount)) {
wethAmount = wethAmount
.plus(feeOrder.takerAssetAmount.times(remainingFeeAmount).dividedToIntegerBy(feeAvailable))
.plus(1);
wethAmount = wethAmount.plus(
feeOrder.takerAssetAmount
.times(remainingFeeAmount)
.dividedBy(feeAvailable)
.ceil(),
);
remainingFeeAmount = new BigNumber(0);
} else if (!remainingFeeAmount.isZero()) {
wethAmount = wethAmount.plus(feeOrder.takerAssetAmount);