From dde76a4dbb782463d1f58801a108c40afa481fed Mon Sep 17 00:00:00 2001 From: Daniel Pyrathon Date: Mon, 5 Oct 2020 17:36:52 -0700 Subject: [PATCH] Mark decimal places --- .../src/utils/market_operation_utils/constants.ts | 1 + .../asset-swapper/src/utils/market_operation_utils/index.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/asset-swapper/src/utils/market_operation_utils/constants.ts b/packages/asset-swapper/src/utils/market_operation_utils/constants.ts index 1b65b5538a..4ee43377c8 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/constants.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/constants.ts @@ -221,3 +221,4 @@ export const ONE_HOUR_IN_SECONDS = 60 * 60; export const ONE_SECOND_MS = 1000; export const NULL_BYTES = '0x'; export const NULL_ADDRESS = '0x0000000000000000000000000000000000000000'; +export const COMPARISON_PRICE_DECIMALS = 5; diff --git a/packages/asset-swapper/src/utils/market_operation_utils/index.ts b/packages/asset-swapper/src/utils/market_operation_utils/index.ts index 87d973a4aa..e1af8102b0 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/index.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/index.ts @@ -11,6 +11,7 @@ import { QuoteRequestor } from '../quote_requestor'; import { generateQuoteReport, QuoteReport } from './../quote_report_generator'; import { BUY_SOURCE_FILTER, + COMPARISON_PRICE_DECIMALS, DEFAULT_GET_MARKET_ORDERS_OPTS, FEE_QUOTE_SOURCES, ONE_ETHER, @@ -608,7 +609,7 @@ export class MarketOperationUtils { if (totalMakerAmount.gt(0)) { const totalMakerAmountUnitAmount = Web3Wrapper.toUnitAmount(totalMakerAmount, marketSideLiquidity.makerTokenDecimals); const totalTakerAmountUnitAmount = Web3Wrapper.toUnitAmount(totalTakerAmount, marketSideLiquidity.takerTokenDecimals); - comparisonPrice = totalTakerAmountUnitAmount.div(totalMakerAmountUnitAmount); + comparisonPrice = totalMakerAmountUnitAmount.div(totalTakerAmountUnitAmount).decimalPlaces(COMPARISON_PRICE_DECIMALS); } }