Add validation for rounding error

This commit is contained in:
Leonid Logvinov
2017-11-13 18:09:18 -05:00
parent 315e4015de
commit f936363440

View File

@@ -117,6 +117,13 @@ export class OrderStateUtils {
throw new Error(ExchangeContractErrs.InsufficientMakerFeeAllowance);
}
}
const minimumFillableTakerTokenAmountWithingNoRoundingErrorRange = signedOrder.takerTokenAmount
.times(1000)
.dividedBy(signedOrder.makerTokenAmount);
if (orderRelevantState.remainingFillableTakerTokenAmount
.lessThan(minimumFillableTakerTokenAmountWithingNoRoundingErrorRange)) {
throw new Error(ExchangeContractErrs.OrderFillRoundingError);
}
// TODO Add linear function solver when maker token is ZRX #badass
// Return the max amount that's fillable
}