Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

1104/fix issue with small usd amounts again #1126

Merged
merged 3 commits into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/custom/components/swap/TradePrice/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -13,8 +13,8 @@ export default function TradePrice(props: Omit<TradePriceProps, 'fiatValue'>) {
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)
Expand Down
1 change: 0 additions & 1 deletion src/custom/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/custom/hooks/useUSDCPrice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Currency>) {
const { price, error } = useUSDCPrice(currencyAmount?.currency)
Expand Down