feat: changes usdcPrice formatting to fixed decimals (#3849)
* change usdcPrice in swap modal to use fixed decimals instead of significant formatting * change text for fiatValue as well * change decimal points condition to 1.05 * (m) missed one value
This commit is contained in:
parent
148e415fe8
commit
251339a9ef
@ -27,13 +27,16 @@ export function FiatValue({
|
|||||||
return theme.red1
|
return theme.red1
|
||||||
}, [priceImpact, theme.green1, theme.red1, theme.text3, theme.yellow1])
|
}, [priceImpact, theme.green1, theme.red1, theme.text3, theme.yellow1])
|
||||||
|
|
||||||
|
const p = Number(fiatValue?.toFixed())
|
||||||
|
const visibleDecimalPlaces = p < 1.05 ? 4 : 2
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemedText.Body fontSize={14} color={fiatValue ? theme.text3 : theme.text4}>
|
<ThemedText.Body fontSize={14} color={fiatValue ? theme.text3 : theme.text4}>
|
||||||
{fiatValue ? (
|
{fiatValue ? (
|
||||||
<Trans>
|
<Trans>
|
||||||
$
|
$
|
||||||
<HoverInlineText
|
<HoverInlineText
|
||||||
text={fiatValue?.toSignificant(6, { groupSeparator: ',' })}
|
text={fiatValue?.toFixed(visibleDecimalPlaces, { groupSeparator: ',' })}
|
||||||
textColor={fiatValue ? theme.text3 : theme.text4}
|
textColor={fiatValue ? theme.text3 : theme.text4}
|
||||||
/>
|
/>
|
||||||
</Trans>
|
</Trans>
|
||||||
|
@ -33,6 +33,11 @@ export default function TradePrice({ price, showInverted, setShowInverted }: Tra
|
|||||||
const theme = useContext(ThemeContext)
|
const theme = useContext(ThemeContext)
|
||||||
|
|
||||||
const usdcPrice = useUSDCPrice(showInverted ? price.baseCurrency : price.quoteCurrency)
|
const usdcPrice = useUSDCPrice(showInverted ? price.baseCurrency : price.quoteCurrency)
|
||||||
|
/*
|
||||||
|
* calculate needed amount of decimal prices, for prices between 0.95-1.05 use 4 decimal places
|
||||||
|
*/
|
||||||
|
const p = Number(usdcPrice?.toFixed())
|
||||||
|
const visibleDecimalPlaces = p < 1.05 ? 4 : 2
|
||||||
|
|
||||||
let formattedPrice: string
|
let formattedPrice: string
|
||||||
try {
|
try {
|
||||||
@ -60,7 +65,7 @@ export default function TradePrice({ price, showInverted, setShowInverted }: Tra
|
|||||||
</Text>{' '}
|
</Text>{' '}
|
||||||
{usdcPrice && (
|
{usdcPrice && (
|
||||||
<ThemedText.DarkGray>
|
<ThemedText.DarkGray>
|
||||||
<Trans>(${usdcPrice.toSignificant(6, { groupSeparator: ',' })})</Trans>
|
<Trans>(${usdcPrice.toFixed(visibleDecimalPlaces, { groupSeparator: ',' })})</Trans>
|
||||||
</ThemedText.DarkGray>
|
</ThemedText.DarkGray>
|
||||||
)}
|
)}
|
||||||
</StyledPriceContainer>
|
</StyledPriceContainer>
|
||||||
|
Loading…
Reference in New Issue
Block a user