import { Currency, CurrencyAmount, Percent } from "@uniswap/sdk-core"; import React, { useMemo } from "react"; import useTheme from "../../hooks/useTheme"; import { TYPE } from "../../theme"; import { warningSeverity } from "../../utils/prices"; import HoverInlineText from "../HoverInlineText"; export function FiatValue({ fiatValue, priceImpact, }: { fiatValue: CurrencyAmount | null | undefined; priceImpact?: Percent; }) { const theme = useTheme(); const priceImpactColor = useMemo(() => { if (!priceImpact) return undefined; if (priceImpact.lessThan("0")) return theme.green1; const severity = warningSeverity(priceImpact); if (severity < 1) return theme.text4; if (severity < 3) return theme.yellow1; return theme.red1; }, [priceImpact, theme.green1, theme.red1, theme.text4, theme.yellow1]); return ( {fiatValue ? "~" : ""}$ {" "} {priceImpact ? ( {" "} ({priceImpact.multiply(-1).toSignificant(3)}%) ) : null} ); }