From 98b14137d13e98ef649dd20306f6583eaf855f0c Mon Sep 17 00:00:00 2001 From: Anxo Rodriguez Date: Fri, 30 Jul 2021 11:50:30 +0200 Subject: [PATCH 1/3] Using token decimal precision instead of arbitrary value --- src/custom/components/swap/TradePrice/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/custom/components/swap/TradePrice/index.tsx b/src/custom/components/swap/TradePrice/index.tsx index 15334698f..f1c50cc70 100644 --- a/src/custom/components/swap/TradePrice/index.tsx +++ b/src/custom/components/swap/TradePrice/index.tsx @@ -3,7 +3,7 @@ import TradePriceMod, { TradePriceProps } from './TradePriceMod' import { useUSDCValue } from 'hooks/useUSDCPrice' import { formatSmart } from 'utils/format' import { tryParseAmount } from 'state/swap/hooks' -import { FIAT_FORMAT_SMART_OPTIONS, MAX_PRECISION } from 'constants/index' +import { FIAT_FORMAT_SMART_OPTIONS } from 'constants/index' export * from './TradePriceMod' @@ -13,8 +13,8 @@ export default function TradePrice(props: Omit) { const priceSide = useMemo( () => !showInverted - ? tryParseAmount(price.invert().toFixed(MAX_PRECISION), price.baseCurrency) - : tryParseAmount(price.toFixed(MAX_PRECISION), price.quoteCurrency), + ? tryParseAmount(price.invert().toFixed(price.baseCurrency.decimals), price.baseCurrency) + : tryParseAmount(price.toFixed(price.quoteCurrency.decimals), price.quoteCurrency), [price, showInverted] ) const amount = useUSDCValue(priceSide) From 410f932e72185960d4fcdece2f5c2eb264ec8196 Mon Sep 17 00:00:00 2001 From: Leandro Boscariol Date: Thu, 29 Jul 2021 14:43:36 -0700 Subject: [PATCH 2/3] Removing MAX_PRECISION constant --- src/custom/constants/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/custom/constants/index.ts b/src/custom/constants/index.ts index 1e8e42dab..e01cb512a 100644 --- a/src/custom/constants/index.ts +++ b/src/custom/constants/index.ts @@ -17,7 +17,6 @@ export const DEFAULT_DECIMALS = 18 export const DEFAULT_PRECISION = 6 export const SHORT_PRECISION = 4 export const SHORTEST_PRECISION = 3 -export const MAX_PRECISION = 18 export const LONG_PRECISION = 10 export const FIAT_PRECISION = 2 export const PERCENTAGE_PRECISION = 2 From b9b1066c5f229eb92f76f08488a324fffd474470 Mon Sep 17 00:00:00 2001 From: Leandro Boscariol Date: Thu, 29 Jul 2021 14:43:53 -0700 Subject: [PATCH 3/3] Tiny doc string fix --- src/custom/hooks/useUSDCPrice/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/custom/hooks/useUSDCPrice/index.ts b/src/custom/hooks/useUSDCPrice/index.ts index c4cda8563..588ef523e 100644 --- a/src/custom/hooks/useUSDCPrice/index.ts +++ b/src/custom/hooks/useUSDCPrice/index.ts @@ -85,7 +85,7 @@ export default function useUSDCPrice(currency?: Currency) { /** * Returns the price in USDC of the input currency from price APIs - * @param currency currency to compute the USDC price of + * @param currencyAmount currency to compute the USDC price of */ export function useUSDCValue(currencyAmount?: CurrencyAmount) { const { price, error } = useUSDCPrice(currencyAmount?.currency)