fix: divide by zero error on pool page (#6837)

* fix: divide by zero error on pool page

* removing changes here

* adding price in conditional

---------

Co-authored-by: John Short <john.short@CORN-Jack-899.local>
This commit is contained in:
Jack Short 2023-06-23 15:56:41 -04:00 committed by GitHub
parent 2f84507a23
commit f290787b99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -21,6 +21,11 @@ export function PoolPriceBar({
price?: Price<Currency, Currency> price?: Price<Currency, Currency>
}) { }) {
const theme = useTheme() const theme = useTheme()
const canInvertPrice = Boolean(
price && price.baseCurrency && price.quoteCurrency && !price.baseCurrency.equals(price.quoteCurrency)
)
const invertedPrice = canInvertPrice ? price?.invert()?.toSignificant(6) : undefined
return ( return (
<AutoColumn gap="md"> <AutoColumn gap="md">
<AutoRow justify="space-around" gap="4px"> <AutoRow justify="space-around" gap="4px">
@ -33,7 +38,7 @@ export function PoolPriceBar({
</Text> </Text>
</AutoColumn> </AutoColumn>
<AutoColumn justify="center"> <AutoColumn justify="center">
<ThemedText.DeprecatedBlack>{price?.invert()?.toSignificant(6) ?? '-'}</ThemedText.DeprecatedBlack> <ThemedText.DeprecatedBlack>{invertedPrice ?? '-'}</ThemedText.DeprecatedBlack>
<Text fontWeight={500} fontSize={14} color={theme.textSecondary} pt={1}> <Text fontWeight={500} fontSize={14} color={theme.textSecondary} pt={1}>
<Trans> <Trans>
{currencies[Field.CURRENCY_A]?.symbol} per {currencies[Field.CURRENCY_B]?.symbol} {currencies[Field.CURRENCY_A]?.symbol} per {currencies[Field.CURRENCY_B]?.symbol}