Portal fill with mixed decimals

When the token pair has different decimal precison we can end up with a remainder when multiplying by an exchange rate (as one is in 18 decimals and the other is 6 for example)
This commit is contained in:
Jacob Evans
2018-03-26 16:43:12 +11:00
parent 109fc41474
commit 125ace3519

View File

@@ -198,11 +198,13 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
symbol: takerToken.symbol,
};
const parsedOrderExpiration = new BigNumber(this.state.parsedOrder.signedOrder.expirationUnixTimestampSec);
const exchangeRate = orderMakerAmount.div(orderTakerAmount);
let orderReceiveAmount = 0;
if (!_.isUndefined(this.props.orderFillAmount)) {
const orderReceiveAmountBigNumber = exchangeRate.mul(this.props.orderFillAmount);
const orderReceiveAmountBigNumber = orderMakerAmount
.times(this.props.orderFillAmount)
.dividedBy(orderTakerAmount)
.floor();
orderReceiveAmount = this._formatCurrencyAmount(orderReceiveAmountBigNumber, makerToken.decimals);
}
const isUserMaker =