diff --git a/src/pages/Pool/PositionPage.tsx b/src/pages/Pool/PositionPage.tsx index 671f8b867b..400c7c72a6 100644 --- a/src/pages/Pool/PositionPage.tsx +++ b/src/pages/Pool/PositionPage.tsx @@ -23,7 +23,7 @@ import { currencyId } from 'utils/currencyId' import { formatTokenAmount } from 'utils/formatTokenAmount' import { useV3PositionFees } from 'hooks/useV3PositionFees' import { BigNumber } from '@ethersproject/bignumber' -import { WETH9, Currency, CurrencyAmount, Percent } from '@uniswap/sdk-core' +import { WETH9, Currency, CurrencyAmount, Percent, Fraction } from '@uniswap/sdk-core' import { useActiveWeb3React } from 'hooks' import { useV3NFTPositionManagerContract } from 'hooks/useContract' import { useIsTransactionPending, useTransactionAdder } from 'state/transactions/hooks' @@ -39,6 +39,7 @@ import RateToggle from '../../components/RateToggle' import { useSingleCallResult } from 'state/multicall/hooks' import RangeBadge from '../../components/Badge/RangeBadge' +import useUSDCPrice from 'hooks/useUSDCPrice' const PageWrapper = styled.div` min-width: 800px; @@ -241,6 +242,23 @@ export function PositionPage({ const owner = useSingleCallResult(!!tokenId ? positionManager : null, 'ownerOf', [tokenId]).result?.[0] const ownsNFT = owner === account || positionDetails?.operator === account + const price0 = useUSDCPrice(token0 ?? undefined) + const price1 = useUSDCPrice(token1 ?? undefined) + + const fiatValueOfFees: CurrencyAmount | null = useMemo(() => { + if (!price0 || !price1 || !feeValue0 || !feeValue1) return null + const amount0 = price0.quote(feeValue0) + const amount1 = price1.quote(feeValue1) + return amount0.add(amount1) + }, [price0, price1, feeValue0, feeValue1]) + + const fiatValueOfLiquidity: CurrencyAmount | null = useMemo(() => { + if (!price0 || !price1 || !position) return null + const amount0 = price0.quote(position.amount0) + const amount1 = price1.quote(position.amount1) + return amount0.add(amount1) + }, [price0, price1, position]) + return loading || poolState === PoolState.LOADING || !feeAmount ? (
@@ -330,9 +348,11 @@ export function PositionPage({ - - $1222.22 - + {fiatValueOfLiquidity?.greaterThan(new Fraction(1, 100)) && ( + + ${fiatValueOfLiquidity.toFixed(2)} + + )} @@ -366,9 +386,11 @@ export function PositionPage({ - - $2.22 - + {fiatValueOfFees?.greaterThan(new Fraction(1, 100)) && ( + + ${fiatValueOfFees.toFixed(2)} + + )} {feeValue0?.greaterThan(0) || feeValue1?.greaterThan(0) || !!collectMigrationHash ? (