recreate bug fixes (#109)
This commit is contained in:
parent
eedba9795e
commit
042967502e
@ -8,16 +8,33 @@ import CurrencyLogo from 'components/CurrencyLogo'
|
|||||||
import { unwrappedToken } from 'utils/wrappedCurrency'
|
import { unwrappedToken } from 'utils/wrappedCurrency'
|
||||||
import { Break } from 'components/earn/styled'
|
import { Break } from 'components/earn/styled'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { Currency } from '@uniswap/sdk-core'
|
||||||
import RateToggle from 'components/RateToggle'
|
import RateToggle from 'components/RateToggle'
|
||||||
|
|
||||||
export const PositionPreview = ({ position, title }: { position: Position; title?: string }) => {
|
export const PositionPreview = ({
|
||||||
|
position,
|
||||||
|
title,
|
||||||
|
baseCurrencyDefault,
|
||||||
|
}: {
|
||||||
|
position: Position
|
||||||
|
title?: string
|
||||||
|
baseCurrencyDefault?: Currency | undefined
|
||||||
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
const currency0 = unwrappedToken(position.pool.token0)
|
const currency0 = unwrappedToken(position.pool.token0)
|
||||||
const currency1 = unwrappedToken(position.pool.token1)
|
const currency1 = unwrappedToken(position.pool.token1)
|
||||||
|
|
||||||
// track which currency should be base
|
// track which currency should be base
|
||||||
const [baseCurrency, setBaseCurrency] = useState(currency0)
|
const [baseCurrency, setBaseCurrency] = useState(
|
||||||
|
baseCurrencyDefault
|
||||||
|
? baseCurrencyDefault === currency0
|
||||||
|
? currency0
|
||||||
|
: baseCurrencyDefault === currency1
|
||||||
|
? currency1
|
||||||
|
: currency0
|
||||||
|
: currency0
|
||||||
|
)
|
||||||
const sorted = baseCurrency === currency0
|
const sorted = baseCurrency === currency0
|
||||||
const quoteCurrency = sorted ? currency1 : currency0
|
const quoteCurrency = sorted ? currency1 : currency0
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ export function Review({
|
|||||||
position,
|
position,
|
||||||
currencies,
|
currencies,
|
||||||
outOfRange,
|
outOfRange,
|
||||||
|
baseCurrency,
|
||||||
}: {
|
}: {
|
||||||
position?: Position
|
position?: Position
|
||||||
existingPosition?: Position
|
existingPosition?: Position
|
||||||
@ -36,6 +37,7 @@ export function Review({
|
|||||||
priceLower?: Price
|
priceLower?: Price
|
||||||
priceUpper?: Price
|
priceUpper?: Price
|
||||||
outOfRange: boolean
|
outOfRange: boolean
|
||||||
|
baseCurrency?: Currency
|
||||||
}) {
|
}) {
|
||||||
const currencyA: Currency | undefined = currencies[Field.CURRENCY_A]
|
const currencyA: Currency | undefined = currencies[Field.CURRENCY_A]
|
||||||
const currencyB: Currency | undefined = currencies[Field.CURRENCY_B]
|
const currencyB: Currency | undefined = currencies[Field.CURRENCY_B]
|
||||||
@ -52,18 +54,9 @@ export function Review({
|
|||||||
</RowFixed>
|
</RowFixed>
|
||||||
<RangeBadge inRange={!outOfRange}>{outOfRange ? 'Out of range' : 'In Range'}</RangeBadge>
|
<RangeBadge inRange={!outOfRange}>{outOfRange ? 'Out of range' : 'In Range'}</RangeBadge>
|
||||||
</RowBetween>
|
</RowBetween>
|
||||||
{position ? <PositionPreview position={position} title={'Tokens To Add'} /> : null}
|
{position ? (
|
||||||
{/* <YellowCard>
|
<PositionPreview position={position} title={'Tokens To Add'} baseCurrencyDefault={baseCurrency} />
|
||||||
<AutoColumn gap="md">
|
) : null}
|
||||||
<RowBetween>
|
|
||||||
<TYPE.label color={theme.text2}>Efficiency Comparison</TYPE.label>
|
|
||||||
<AlertCircle stroke={theme.text2} />
|
|
||||||
</RowBetween>
|
|
||||||
<TYPE.label fontWeight={400} color={theme.text2}>
|
|
||||||
This liquidity position has an increased capital efficiency relative to an unbounded price limit.
|
|
||||||
</TYPE.label>
|
|
||||||
</AutoColumn>
|
|
||||||
</YellowCard> */}
|
|
||||||
</AutoColumn>
|
</AutoColumn>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
)
|
)
|
||||||
|
@ -293,9 +293,10 @@ export default function AddLiquidity({
|
|||||||
// if there was a tx hash, we want to clear the input
|
// if there was a tx hash, we want to clear the input
|
||||||
if (txHash) {
|
if (txHash) {
|
||||||
onFieldAInput('')
|
onFieldAInput('')
|
||||||
|
history.push('/pool')
|
||||||
}
|
}
|
||||||
setTxHash('')
|
setTxHash('')
|
||||||
}, [onFieldAInput, txHash])
|
}, [history, onFieldAInput, txHash])
|
||||||
|
|
||||||
const addIsUnsupported = useIsSwapUnsupported(currencies?.CURRENCY_A, currencies?.CURRENCY_B)
|
const addIsUnsupported = useIsSwapUnsupported(currencies?.CURRENCY_A, currencies?.CURRENCY_B)
|
||||||
|
|
||||||
@ -304,7 +305,7 @@ export default function AddLiquidity({
|
|||||||
onFieldBInput('')
|
onFieldBInput('')
|
||||||
onLeftRangeInput('')
|
onLeftRangeInput('')
|
||||||
onRightRangeInput('')
|
onRightRangeInput('')
|
||||||
history.push(`/add/`)
|
history.push(`/add`)
|
||||||
}, [history, onFieldAInput, onFieldBInput, onLeftRangeInput, onRightRangeInput])
|
}, [history, onFieldAInput, onFieldBInput, onLeftRangeInput, onRightRangeInput])
|
||||||
|
|
||||||
// get value and prices at ticks
|
// get value and prices at ticks
|
||||||
@ -339,6 +340,7 @@ export default function AddLiquidity({
|
|||||||
priceLower={priceLower}
|
priceLower={priceLower}
|
||||||
priceUpper={priceUpper}
|
priceUpper={priceUpper}
|
||||||
outOfRange={outOfRange}
|
outOfRange={outOfRange}
|
||||||
|
baseCurrency={baseCurrency ?? undefined}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
bottomContent={() => (
|
bottomContent={() => (
|
||||||
|
@ -28,6 +28,7 @@ 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'
|
||||||
import ReactGA from 'react-ga'
|
import ReactGA from 'react-ga'
|
||||||
|
import TransactionConfirmationModal, { ConfirmationModalContent } from 'components/TransactionConfirmationModal'
|
||||||
import { TransactionResponse } from '@ethersproject/providers'
|
import { TransactionResponse } from '@ethersproject/providers'
|
||||||
import { Dots } from 'components/swap/styleds'
|
import { Dots } from 'components/swap/styleds'
|
||||||
import { getPriceOrderingFromPositionForUI } from '../../components/PositionListItem'
|
import { getPriceOrderingFromPositionForUI } from '../../components/PositionListItem'
|
||||||
@ -230,14 +231,15 @@ export function PositionPage({
|
|||||||
// const below = pool && typeof tickLower === 'number' ? pool.tickCurrent < tickLower : false
|
// const below = pool && typeof tickLower === 'number' ? pool.tickCurrent < tickLower : false
|
||||||
// const above = pool && typeof tickUpper === 'number' ? pool.tickCurrent >= tickUpper : false
|
// const above = pool && typeof tickUpper === 'number' ? pool.tickCurrent >= tickUpper : false
|
||||||
|
|
||||||
const ratio =
|
const ratio = useMemo(() => {
|
||||||
priceLower && pool && priceUpper
|
return priceLower && pool && priceUpper
|
||||||
? getRatio(
|
? getRatio(
|
||||||
inverted ? priceUpper.invert() : priceLower,
|
inverted ? priceUpper.invert() : priceLower,
|
||||||
pool.token0Price,
|
pool.token0Price,
|
||||||
inverted ? priceLower.invert() : priceUpper
|
inverted ? priceLower.invert() : priceUpper
|
||||||
)
|
)
|
||||||
: undefined
|
: undefined
|
||||||
|
}, [inverted, pool, priceLower, priceUpper])
|
||||||
|
|
||||||
// fees
|
// fees
|
||||||
const [feeValue0, feeValue1] = useV3PositionFees(pool ?? undefined, positionDetails)
|
const [feeValue0, feeValue1] = useV3PositionFees(pool ?? undefined, positionDetails)
|
||||||
@ -245,6 +247,7 @@ export function PositionPage({
|
|||||||
const [collecting, setCollecting] = useState<boolean>(false)
|
const [collecting, setCollecting] = useState<boolean>(false)
|
||||||
const [collectMigrationHash, setCollectMigrationHash] = useState<string | null>(null)
|
const [collectMigrationHash, setCollectMigrationHash] = useState<string | null>(null)
|
||||||
const isCollectPending = useIsTransactionPending(collectMigrationHash ?? undefined)
|
const isCollectPending = useIsTransactionPending(collectMigrationHash ?? undefined)
|
||||||
|
const [showConfirm, setShowConfirm] = useState(false)
|
||||||
|
|
||||||
const addTransaction = useTransactionAdder()
|
const addTransaction = useTransactionAdder()
|
||||||
const positionManager = useV3NFTPositionManagerContract()
|
const positionManager = useV3NFTPositionManagerContract()
|
||||||
@ -319,6 +322,49 @@ export function PositionPage({
|
|||||||
return amount0.add(amount1)
|
return amount0.add(amount1)
|
||||||
}, [price0, price1, position])
|
}, [price0, price1, position])
|
||||||
|
|
||||||
|
function modalHeader() {
|
||||||
|
return (
|
||||||
|
<AutoColumn gap={'md'} style={{ marginTop: '20px' }}>
|
||||||
|
<LightCard padding="12px 16px">
|
||||||
|
<AutoColumn gap="md">
|
||||||
|
<RowBetween>
|
||||||
|
<RowFixed>
|
||||||
|
<CurrencyLogo currency={currencyQuote} size={'20px'} style={{ marginRight: '0.5rem' }} />
|
||||||
|
<TYPE.main>
|
||||||
|
{inverted
|
||||||
|
? feeValue0
|
||||||
|
? formatTokenAmount(feeValue0, 4)
|
||||||
|
: '-'
|
||||||
|
: feeValue1
|
||||||
|
? formatTokenAmount(feeValue1, 4)
|
||||||
|
: '-'}
|
||||||
|
</TYPE.main>
|
||||||
|
</RowFixed>
|
||||||
|
<TYPE.main>{currencyQuote?.symbol}</TYPE.main>
|
||||||
|
</RowBetween>
|
||||||
|
<RowBetween>
|
||||||
|
<RowFixed>
|
||||||
|
<CurrencyLogo currency={currencyBase} size={'20px'} style={{ marginRight: '0.5rem' }} />
|
||||||
|
<TYPE.main>
|
||||||
|
{inverted
|
||||||
|
? feeValue0
|
||||||
|
? formatTokenAmount(feeValue1, 4)
|
||||||
|
: '-'
|
||||||
|
: feeValue1
|
||||||
|
? formatTokenAmount(feeValue0, 4)
|
||||||
|
: '-'}
|
||||||
|
</TYPE.main>
|
||||||
|
</RowFixed>
|
||||||
|
<TYPE.main>{currencyBase?.symbol}</TYPE.main>
|
||||||
|
</RowBetween>
|
||||||
|
</AutoColumn>
|
||||||
|
</LightCard>
|
||||||
|
<TYPE.italic>Collecting fees will withdraw currently available fees for you.</TYPE.italic>
|
||||||
|
<ButtonPrimary onClick={collect}>Collect</ButtonPrimary>
|
||||||
|
</AutoColumn>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return loading || poolState === PoolState.LOADING || !feeAmount ? (
|
return loading || poolState === PoolState.LOADING || !feeAmount ? (
|
||||||
<LoadingRows>
|
<LoadingRows>
|
||||||
<div />
|
<div />
|
||||||
@ -336,6 +382,20 @@ export function PositionPage({
|
|||||||
</LoadingRows>
|
</LoadingRows>
|
||||||
) : (
|
) : (
|
||||||
<PageWrapper>
|
<PageWrapper>
|
||||||
|
<TransactionConfirmationModal
|
||||||
|
isOpen={showConfirm}
|
||||||
|
onDismiss={() => setShowConfirm(false)}
|
||||||
|
attemptingTxn={collecting}
|
||||||
|
hash={collectMigrationHash ?? ''}
|
||||||
|
content={() => (
|
||||||
|
<ConfirmationModalContent
|
||||||
|
title={'Collect fees'}
|
||||||
|
onDismiss={() => setShowConfirm(false)}
|
||||||
|
topContent={modalHeader}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
pendingText={'Collecting fees'}
|
||||||
|
/>
|
||||||
<AutoColumn gap="md">
|
<AutoColumn gap="md">
|
||||||
<AutoColumn gap="sm">
|
<AutoColumn gap="sm">
|
||||||
<Link style={{ textDecoration: 'none', width: 'fit-content', marginBottom: '0.5rem' }} to="/pool">
|
<Link style={{ textDecoration: 'none', width: 'fit-content', marginBottom: '0.5rem' }} to="/pool">
|
||||||
@ -466,7 +526,7 @@ export function PositionPage({
|
|||||||
width="fit-content"
|
width="fit-content"
|
||||||
style={{ borderRadius: '12px' }}
|
style={{ borderRadius: '12px' }}
|
||||||
padding="4px 8px"
|
padding="4px 8px"
|
||||||
onClick={collect}
|
onClick={() => setShowConfirm(true)}
|
||||||
>
|
>
|
||||||
{!!collectMigrationHash && !isCollectPending ? (
|
{!!collectMigrationHash && !isCollectPending ? (
|
||||||
<TYPE.main color={theme.text1}> Collected</TYPE.main>
|
<TYPE.main color={theme.text1}> Collected</TYPE.main>
|
||||||
|
Loading…
Reference in New Issue
Block a user