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 From 0a8b7cb49402d440df41ea0119f8a75d6f6c7a50 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 26 Mar 2018 13:21:02 +0100 Subject: Improve rounding error message --- packages/website/ts/utils/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index 25d7e449b..75597a7e2 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -219,7 +219,8 @@ export const utils = { [ExchangeContractErrs.OrderFillAmountZero]: "Order fill amount can't be 0", [ExchangeContractErrs.OrderRemainingFillAmountZero]: 'This order has already been completely filled or cancelled', - [ExchangeContractErrs.OrderFillRoundingError]: 'Rounding error will occur when filling this order', + [ExchangeContractErrs.OrderFillRoundingError]: + 'Rounding error will occur when filling this order. Please try filling a different amount.', [ExchangeContractErrs.InsufficientTakerBalance]: 'Taker no longer has a sufficient balance to complete this order', [ExchangeContractErrs.InsufficientTakerAllowance]: -- cgit