From 125ace351924ee124d45c79c400966a11db24042 Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Mon, 26 Mar 2018 16:43:12 +1100 Subject: 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) --- packages/website/ts/components/fill_order.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx index a6144bd6b..ea94e0987 100644 --- a/packages/website/ts/components/fill_order.tsx +++ b/packages/website/ts/components/fill_order.tsx @@ -198,11 +198,13 @@ export class FillOrder extends React.Component { 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 = -- cgit v1.2.3