diff options
author | Jacob Evans <jacob@dekz.net> | 2018-03-26 13:43:12 +0800 |
---|---|---|
committer | Jacob Evans <jacob@dekz.net> | 2018-03-26 13:43:12 +0800 |
commit | 125ace351924ee124d45c79c400966a11db24042 (patch) | |
tree | 26b827093124aa0cc023e6b2a05d4d18b28ce294 /packages/website | |
parent | 109fc41474f5319a27052ab09234cc0426eb22ce (diff) | |
download | dexon-sol-tools-125ace351924ee124d45c79c400966a11db24042.tar dexon-sol-tools-125ace351924ee124d45c79c400966a11db24042.tar.gz dexon-sol-tools-125ace351924ee124d45c79c400966a11db24042.tar.bz2 dexon-sol-tools-125ace351924ee124d45c79c400966a11db24042.tar.lz dexon-sol-tools-125ace351924ee124d45c79c400966a11db24042.tar.xz dexon-sol-tools-125ace351924ee124d45c79c400966a11db24042.tar.zst dexon-sol-tools-125ace351924ee124d45c79c400966a11db24042.zip |
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)
Diffstat (limited to 'packages/website')
-rw-r--r-- | packages/website/ts/components/fill_order.tsx | 6 |
1 files 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<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 = |