Commit ed801deb authored by Noah Zinsmeister's avatar Noah Zinsmeister

add fiat value of liquidity + fees

parent c3472764
...@@ -23,7 +23,7 @@ import { currencyId } from 'utils/currencyId' ...@@ -23,7 +23,7 @@ import { currencyId } from 'utils/currencyId'
import { formatTokenAmount } from 'utils/formatTokenAmount' import { formatTokenAmount } from 'utils/formatTokenAmount'
import { useV3PositionFees } from 'hooks/useV3PositionFees' import { useV3PositionFees } from 'hooks/useV3PositionFees'
import { BigNumber } from '@ethersproject/bignumber' 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 { useActiveWeb3React } from 'hooks'
import { useV3NFTPositionManagerContract } from 'hooks/useContract' import { useV3NFTPositionManagerContract } from 'hooks/useContract'
import { useIsTransactionPending, useTransactionAdder } from 'state/transactions/hooks' import { useIsTransactionPending, useTransactionAdder } from 'state/transactions/hooks'
...@@ -39,6 +39,7 @@ import RateToggle from '../../components/RateToggle' ...@@ -39,6 +39,7 @@ import RateToggle from '../../components/RateToggle'
import { useSingleCallResult } from 'state/multicall/hooks' import { useSingleCallResult } from 'state/multicall/hooks'
import RangeBadge from '../../components/Badge/RangeBadge' import RangeBadge from '../../components/Badge/RangeBadge'
import useUSDCPrice from 'hooks/useUSDCPrice'
const PageWrapper = styled.div` const PageWrapper = styled.div`
min-width: 800px; min-width: 800px;
...@@ -241,6 +242,23 @@ export function PositionPage({ ...@@ -241,6 +242,23 @@ export function PositionPage({
const owner = useSingleCallResult(!!tokenId ? positionManager : null, 'ownerOf', [tokenId]).result?.[0] const owner = useSingleCallResult(!!tokenId ? positionManager : null, 'ownerOf', [tokenId]).result?.[0]
const ownsNFT = owner === account || positionDetails?.operator === account 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 ? ( return loading || poolState === PoolState.LOADING || !feeAmount ? (
<LoadingRows> <LoadingRows>
<div /> <div />
...@@ -330,9 +348,11 @@ export function PositionPage({ ...@@ -330,9 +348,11 @@ export function PositionPage({
<AutoColumn gap="lg" style={{ width: '100%' }}> <AutoColumn gap="lg" style={{ width: '100%' }}>
<AutoColumn gap="md"> <AutoColumn gap="md">
<Label>Position liquidity</Label> <Label>Position liquidity</Label>
<TYPE.largeHeader fontSize="36px" fontWeight={500}> {fiatValueOfLiquidity?.greaterThan(new Fraction(1, 100)) && (
$1222.22 <TYPE.largeHeader fontSize="36px" fontWeight={500}>
</TYPE.largeHeader> ${fiatValueOfLiquidity.toFixed(2)}
</TYPE.largeHeader>
)}
</AutoColumn> </AutoColumn>
<LightCard padding="12px 16px"> <LightCard padding="12px 16px">
...@@ -366,9 +386,11 @@ export function PositionPage({ ...@@ -366,9 +386,11 @@ export function PositionPage({
<RowBetween style={{ alignItems: 'flex-start' }}> <RowBetween style={{ alignItems: 'flex-start' }}>
<AutoColumn gap="md"> <AutoColumn gap="md">
<Label>Fees Earned</Label> <Label>Fees Earned</Label>
<TYPE.largeHeader color={theme.green1} fontSize="36px" fontWeight={500}> {fiatValueOfFees?.greaterThan(new Fraction(1, 100)) && (
$2.22 <TYPE.largeHeader color={theme.green1} fontSize="36px" fontWeight={500}>
</TYPE.largeHeader> ${fiatValueOfFees.toFixed(2)}
</TYPE.largeHeader>
)}
</AutoColumn> </AutoColumn>
{feeValue0?.greaterThan(0) || feeValue1?.greaterThan(0) || !!collectMigrationHash ? ( {feeValue0?.greaterThan(0) || feeValue1?.greaterThan(0) || !!collectMigrationHash ? (
<ButtonConfirmed <ButtonConfirmed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment