Commit d7785942 authored by Callil Capuozzo's avatar Callil Capuozzo Committed by GitHub

Update migration styles (#78)

* re-work migrate page

* Layout Tweaks

* cleanup
Co-authored-by: default avatarNoah Zinsmeister <noahwz@gmail.com>
parent ed801deb
...@@ -7,7 +7,9 @@ export enum BadgeVariant { ...@@ -7,7 +7,9 @@ export enum BadgeVariant {
DEFAULT = 'DEFAULT', DEFAULT = 'DEFAULT',
NEGATIVE = 'NEGATIVE', NEGATIVE = 'NEGATIVE',
POSITIVE = 'POSITIVE', POSITIVE = 'POSITIVE',
PRIMARY = 'PRIMARY',
WARNING = 'WARNING', WARNING = 'WARNING',
WARNING_OUTLINE = 'WARNING_OUTLINE', WARNING_OUTLINE = 'WARNING_OUTLINE',
} }
...@@ -21,6 +23,8 @@ function pickBackgroundColor(variant: BadgeVariant | undefined, theme: DefaultTh ...@@ -21,6 +23,8 @@ function pickBackgroundColor(variant: BadgeVariant | undefined, theme: DefaultTh
return theme.error return theme.error
case BadgeVariant.POSITIVE: case BadgeVariant.POSITIVE:
return theme.success return theme.success
case BadgeVariant.PRIMARY:
return theme.primary1
case BadgeVariant.WARNING: case BadgeVariant.WARNING:
return theme.warning return theme.warning
case BadgeVariant.WARNING_OUTLINE: case BadgeVariant.WARNING_OUTLINE:
......
...@@ -38,7 +38,7 @@ const FocusedOutlineCard = styled(OutlineCard)<{ active?: boolean; pulsing?: boo ...@@ -38,7 +38,7 @@ const FocusedOutlineCard = styled(OutlineCard)<{ active?: boolean; pulsing?: boo
` `
const StyledInput = styled(NumericalInput)<{ usePercent?: boolean }>` const StyledInput = styled(NumericalInput)<{ usePercent?: boolean }>`
background-color: ${({ theme }) => theme.bg0}; background-color: transparent;
text-align: left; text-align: left;
margin-right: 2px; margin-right: 2px;
` `
......
...@@ -17,6 +17,7 @@ import DoubleCurrencyLogo from '../DoubleLogo' ...@@ -17,6 +17,7 @@ import DoubleCurrencyLogo from '../DoubleLogo'
import { RowFixed, AutoRow } from '../Row' import { RowFixed, AutoRow } from '../Row'
import { Dots } from '../swap/styleds' import { Dots } from '../swap/styleds'
import { FixedHeightRow } from '.' import { FixedHeightRow } from '.'
import Badge, { BadgeVariant } from 'components/Badge'
const StyledPositionCard = styled(LightCard)<{ bgColor: any }>` const StyledPositionCard = styled(LightCard)<{ bgColor: any }>`
border: none; border: none;
...@@ -49,7 +50,8 @@ export default function SushiPositionCard({ tokenA, tokenB, liquidityToken, bord ...@@ -49,7 +50,8 @@ export default function SushiPositionCard({ tokenA, tokenB, liquidityToken, bord
<Text fontWeight={500} fontSize={20}> <Text fontWeight={500} fontSize={20}>
{!currency0 || !currency1 ? <Dots>Loading</Dots> : `${currency0.symbol}/${currency1.symbol}`} {!currency0 || !currency1 ? <Dots>Loading</Dots> : `${currency0.symbol}/${currency1.symbol}`}
</Text> </Text>
(Sushi)
<Badge variant={BadgeVariant.WARNING}>Sushi</Badge>
</AutoRow> </AutoRow>
<RowFixed gap="8px"> <RowFixed gap="8px">
<ButtonEmpty <ButtonEmpty
......
...@@ -21,7 +21,7 @@ import { BodyWrapper } from '../AppBody' ...@@ -21,7 +21,7 @@ import { BodyWrapper } from '../AppBody'
import { V3_MIGRATOR_ADDRESSES } from 'constants/v3' import { V3_MIGRATOR_ADDRESSES } from 'constants/v3'
import { PoolState, usePool } from 'hooks/usePools' import { PoolState, usePool } from 'hooks/usePools'
import { FeeAmount, Pool, Position, priceToClosestTick, TickMath } from '@uniswap/v3-sdk' import { FeeAmount, Pool, Position, priceToClosestTick, TickMath } from '@uniswap/v3-sdk'
import { LightCard, PinkCard, YellowCard } from 'components/Card' import { BlueCard, DarkGreyCard, LightCard, YellowCard } from 'components/Card'
import { ApprovalState, useApproveCallback } from 'hooks/useApproveCallback' import { ApprovalState, useApproveCallback } from 'hooks/useApproveCallback'
import { Dots } from 'components/swap/styleds' import { Dots } from 'components/swap/styleds'
import { ButtonConfirmed } from 'components/Button' import { ButtonConfirmed } from 'components/Button'
...@@ -33,7 +33,7 @@ import { useIsTransactionPending, useTransactionAdder } from 'state/transactions ...@@ -33,7 +33,7 @@ import { useIsTransactionPending, useTransactionAdder } from 'state/transactions
import { useDerivedMintInfo, useMintActionHandlers, useRangeHopCallbacks } from 'state/mint/hooks' import { useDerivedMintInfo, useMintActionHandlers, useRangeHopCallbacks } from 'state/mint/hooks'
import { Bound } from 'state/mint/actions' import { Bound } from 'state/mint/actions'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { AlertTriangle, ChevronDown } from 'react-feather' import { AlertCircle, AlertTriangle, ArrowDown } from 'react-feather'
import FeeSelector from 'components/FeeSelector' import FeeSelector from 'components/FeeSelector'
import RangeSelector from 'components/RangeSelector' import RangeSelector from 'components/RangeSelector'
import RateToggle from 'components/RateToggle' import RateToggle from 'components/RateToggle'
...@@ -42,6 +42,8 @@ import useCurrentBlockTimestamp from 'hooks/useCurrentBlockTimestamp' ...@@ -42,6 +42,8 @@ import useCurrentBlockTimestamp from 'hooks/useCurrentBlockTimestamp'
import { formatTokenAmount } from 'utils/formatTokenAmount' import { formatTokenAmount } from 'utils/formatTokenAmount'
import useTheme from 'hooks/useTheme' import useTheme from 'hooks/useTheme'
import { unwrappedToken } from 'utils/wrappedCurrency' import { unwrappedToken } from 'utils/wrappedCurrency'
import DoubleCurrencyLogo from 'components/DoubleLogo'
import Badge, { BadgeVariant } from 'components/Badge'
const ZERO = JSBI.BigInt(0) const ZERO = JSBI.BigInt(0)
...@@ -58,30 +60,31 @@ function LiquidityInfo({ token0Amount, token1Amount }: { token0Amount: TokenAmou ...@@ -58,30 +60,31 @@ function LiquidityInfo({ token0Amount, token1Amount }: { token0Amount: TokenAmou
const currency1 = unwrappedToken(token1Amount.token) const currency1 = unwrappedToken(token1Amount.token)
return ( return (
<> <AutoColumn gap="8px">
<RowBetween my="1rem"> <RowBetween>
<RowFixed>
<CurrencyLogo size="20px" style={{ marginRight: '8px' }} currency={currency0} />
<Text fontSize={16} fontWeight={500}> <Text fontSize={16} fontWeight={500}>
Pooled {currency0.symbol}: {currency0.symbol}
</Text> </Text>
<RowFixed> </RowFixed>
<Text fontSize={16} fontWeight={500} marginLeft={'6px'}> <Text fontSize={16} fontWeight={500}>
<FormattedCurrencyAmount currencyAmount={token0Amount} /> <FormattedCurrencyAmount currencyAmount={token0Amount} />
</Text> </Text>
<CurrencyLogo size="20px" style={{ marginLeft: '8px' }} currency={currency0} />
</RowFixed>
</RowBetween> </RowBetween>
<RowBetween mb="1rem"> <RowBetween>
<RowFixed>
<CurrencyLogo size="20px" style={{ marginRight: '8px' }} currency={currency1} />
<Text fontSize={16} fontWeight={500}> <Text fontSize={16} fontWeight={500}>
Pooled {currency1.symbol}: {currency1.symbol}
</Text> </Text>
<RowFixed> </RowFixed>
<Text fontSize={16} fontWeight={500} marginLeft={'6px'}>
<Text fontSize={16} fontWeight={500}>
<FormattedCurrencyAmount currencyAmount={token1Amount} /> <FormattedCurrencyAmount currencyAmount={token1Amount} />
</Text> </Text>
<CurrencyLogo size="20px" style={{ marginLeft: '8px' }} currency={currency1} />
</RowFixed>
</RowBetween> </RowBetween>
</> </AutoColumn>
) )
} }
...@@ -310,7 +313,7 @@ function V2PairMigration({ ...@@ -310,7 +313,7 @@ function V2PairMigration({
.then((response: TransactionResponse) => { .then((response: TransactionResponse) => {
ReactGA.event({ ReactGA.event({
category: 'Migrate', category: 'Migrate',
action: 'V2->V3', action: `${isNotUniswap ? 'SushiSwap' : 'V2'}->V3`,
label: `${currency0.symbol}/${currency1.symbol}`, label: `${currency0.symbol}/${currency1.symbol}`,
}) })
...@@ -323,6 +326,7 @@ function V2PairMigration({ ...@@ -323,6 +326,7 @@ function V2PairMigration({
setConfirmingMigration(false) setConfirmingMigration(false)
}) })
}, [ }, [
isNotUniswap,
migrator, migrator,
noLiquidity, noLiquidity,
blockTimestamp, blockTimestamp,
...@@ -349,7 +353,8 @@ function V2PairMigration({ ...@@ -349,7 +353,8 @@ function V2PairMigration({
return ( return (
<AutoColumn gap="20px"> <AutoColumn gap="20px">
<TYPE.body my={9} style={{ fontWeight: 400 }}> <TYPE.body my={9} style={{ fontWeight: 400 }}>
This tool will safely migrate your V2 liquidity to V3. The process is completely trustless thanks to the{' '} This tool will safely migrate your {isNotUniswap ? 'SushiSwap' : 'V2'} liquidity to V3. The process is
completely trustless thanks to the{' '}
{chainId && migratorAddress && ( {chainId && migratorAddress && (
<ExternalLink href={getEtherscanLink(chainId, migratorAddress, 'address')}> <ExternalLink href={getEtherscanLink(chainId, migratorAddress, 'address')}>
<TYPE.blue display="inline">Uniswap migration contract↗</TYPE.blue> <TYPE.blue display="inline">Uniswap migration contract↗</TYPE.blue>
...@@ -359,43 +364,69 @@ function V2PairMigration({ ...@@ -359,43 +364,69 @@ function V2PairMigration({
</TYPE.body> </TYPE.body>
<LightCard> <LightCard>
<AutoColumn gap="lg">
<RowBetween>
<RowFixed style={{ marginLeft: '8px' }}>
<DoubleCurrencyLogo currency0={currency0} currency1={currency1} margin={false} size={20} />
<TYPE.mediumHeader style={{ marginLeft: '8px' }}>
{currency0.symbol}/{currency1.symbol} LP Tokens
</TYPE.mediumHeader>
</RowFixed>
<Badge variant={BadgeVariant.WARNING}>{isNotUniswap ? 'Sushi' : 'V2'}</Badge>
</RowBetween>
<LiquidityInfo token0Amount={token0Value} token1Amount={token1Value} /> <LiquidityInfo token0Amount={token0Value} token1Amount={token1Value} />
</AutoColumn>
</LightCard> </LightCard>
<div style={{ display: 'flex', justifyContent: 'center' }}> <div style={{ display: 'flex', justifyContent: 'center' }}>
<ChevronDown size={24} /> <ArrowDown size={24} />
</div> </div>
<LightCard>
<AutoColumn gap="lg">
<RowBetween>
<RowFixed style={{ marginLeft: '8px' }}>
<DoubleCurrencyLogo currency0={currency0} currency1={currency1} margin={false} size={20} />
<TYPE.mediumHeader style={{ marginLeft: '8px' }}>
{currency0.symbol}/{currency1.symbol} LP NFT
</TYPE.mediumHeader>
</RowFixed>
<Badge variant={BadgeVariant.PRIMARY}>V3</Badge>
</RowBetween>
<FeeSelector feeAmount={feeAmount} handleFeePoolSelect={setFeeAmount} />
{noLiquidity && ( {noLiquidity && (
<PinkCard> <BlueCard style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
<TYPE.body style={{ marginBottom: 8, fontWeight: 400 }}> <AlertCircle color={theme.text1} style={{ marginBottom: '12px', opacity: 0.8 }} />
<TYPE.body fontSize={14} style={{ marginBottom: 8, fontWeight: 400, opacity: 0.8 }} textAlign="center">
You are the first liquidity provider for this Uniswap V3 pool. Your liquidity will be migrated at the You are the first liquidity provider for this Uniswap V3 pool. Your liquidity will be migrated at the
current V2 price. Your transaction cost will include the gas to create the pool. current {isNotUniswap ? 'SushiSwap' : 'V2'} price. Your transaction cost will include the gas to create
the pool.
</TYPE.body> </TYPE.body>
{v2SpotPrice && (
<AutoColumn gap="8px"> <AutoColumn gap="8px">
<RowBetween> <RowBetween>
<TYPE.body>V2 {invertPrice ? currency1.symbol : currency0.symbol} Price:</TYPE.body> <TYPE.body fontWeight={600} fontSize={14}>
<TYPE.black> {isNotUniswap ? 'SushiSwap' : 'V2'} {invertPrice ? currency1.symbol : currency0.symbol} Price:{' '}
{invertPrice {invertPrice
? `${v2SpotPrice?.invert()?.toSignificant(6)} ${currency0.symbol}` ? `${v2SpotPrice?.invert()?.toSignificant(6)} ${currency0.symbol}`
: `${v2SpotPrice?.toSignificant(6)} ${currency1.symbol}`} : `${v2SpotPrice?.toSignificant(6)} ${currency1.symbol}`}
</TYPE.black> </TYPE.body>
</RowBetween> </RowBetween>
</AutoColumn> </AutoColumn>
</PinkCard> )}
</BlueCard>
)} )}
{largePriceDifference && ( {largePriceDifference ? (
<YellowCard> <YellowCard>
<TYPE.body style={{ marginBottom: 8, fontWeight: 400 }}>
You should only deposit liquidity into Uniswap V3 at a price you believe is correct. If the price seems
incorrect, you can either make a swap to move the price or wait for someone else to do so.
</TYPE.body>
<AutoColumn gap="8px"> <AutoColumn gap="8px">
<RowBetween> <RowBetween>
<TYPE.body>V2 {invertPrice ? currency1.symbol : currency0.symbol} Price:</TYPE.body> <TYPE.body fontSize={14}>
<TYPE.black> {isNotUniswap ? 'SushiSwap' : 'V2'} {invertPrice ? currency1.symbol : currency0.symbol} Price:
</TYPE.body>
<TYPE.black fontSize={14}>
{invertPrice {invertPrice
? `${v2SpotPrice?.invert()?.toSignificant(6)} ${currency0.symbol}` ? `${v2SpotPrice?.invert()?.toSignificant(6)} ${currency0.symbol}`
: `${v2SpotPrice?.toSignificant(6)} ${currency1.symbol}`} : `${v2SpotPrice?.toSignificant(6)} ${currency1.symbol}`}
...@@ -403,8 +434,8 @@ function V2PairMigration({ ...@@ -403,8 +434,8 @@ function V2PairMigration({
</RowBetween> </RowBetween>
<RowBetween> <RowBetween>
<TYPE.body>V3 {invertPrice ? currency1.symbol : currency0.symbol} Price:</TYPE.body> <TYPE.body fontSize={14}>V3 {invertPrice ? currency1.symbol : currency0.symbol} Price:</TYPE.body>
<TYPE.black> <TYPE.black fontSize={14}>
{invertPrice {invertPrice
? `${v3SpotPrice?.invert()?.toSignificant(6)} ${currency0.symbol}` ? `${v3SpotPrice?.invert()?.toSignificant(6)} ${currency0.symbol}`
: `${v3SpotPrice?.toSignificant(6)} ${currency1.symbol}`} : `${v3SpotPrice?.toSignificant(6)} ${currency1.symbol}`}
...@@ -412,14 +443,29 @@ function V2PairMigration({ ...@@ -412,14 +443,29 @@ function V2PairMigration({
</RowBetween> </RowBetween>
<RowBetween> <RowBetween>
<TYPE.body color="inherit">Price Difference:</TYPE.body> <TYPE.body fontSize={14} color="inherit">
<TYPE.black color="inherit">{priceDifferenceFraction?.toSignificant(4)}%</TYPE.black> Price Difference:
</TYPE.body>
<TYPE.black fontSize={14} color="inherit">
{priceDifferenceFraction?.toSignificant(4)}%
</TYPE.black>
</RowBetween> </RowBetween>
</AutoColumn> </AutoColumn>
<TYPE.body fontSize={14} style={{ marginTop: 8, fontWeight: 400 }}>
You should only deposit liquidity into Uniswap V3 at a price you believe is correct. If the price seems
incorrect, you can either make a swap to move the price or wait for someone else to do so.
</TYPE.body>
</YellowCard> </YellowCard>
)} ) : !noLiquidity && v3SpotPrice ? (
<RowBetween>
<FeeSelector feeAmount={feeAmount} handleFeePoolSelect={setFeeAmount} /> <TYPE.body fontSize={14}>V3 {invertPrice ? currency1.symbol : currency0.symbol} Price:</TYPE.body>
<TYPE.black fontSize={14}>
{invertPrice
? `${v3SpotPrice?.invert()?.toSignificant(6)} ${currency0.symbol}`
: `${v3SpotPrice?.toSignificant(6)} ${currency1.symbol}`}
</TYPE.black>
</RowBetween>
) : null}
<RowBetween> <RowBetween>
<TYPE.label>{t('selectLiquidityRange')}</TYPE.label> <TYPE.label>{t('selectLiquidityRange')}</TYPE.label>
...@@ -470,14 +516,24 @@ function V2PairMigration({ ...@@ -470,14 +516,24 @@ function V2PairMigration({
</YellowCard> </YellowCard>
) : null} ) : null}
<LightCard>
{v3Amount0Min && v3Amount1Min ? ( {v3Amount0Min && v3Amount1Min ? (
<DarkGreyCard>
<AutoColumn gap="md">
<LiquidityInfo token0Amount={v3Amount0Min} token1Amount={v3Amount1Min} /> <LiquidityInfo token0Amount={v3Amount0Min} token1Amount={v3Amount1Min} />
{chainId && refund0 && refund1 ? (
<TYPE.black fontSize={12}>
{formatTokenAmount(refund0, 4)} {token0.equals(WETH9[chainId]) ? 'ETH' : token0.symbol} and{' '}
{formatTokenAmount(refund1, 4)} {token1.equals(WETH9[chainId]) ? 'ETH' : token1.symbol} will be
refunded to your wallet due to selected price range.
</TYPE.black>
) : null}
</AutoColumn>
</DarkGreyCard>
) : null} ) : null}
<div style={{ display: 'flex', marginTop: '1rem' }}> <AutoColumn gap="12px">
{!isSuccessfullyMigrated && !isMigrationPending ? ( {!isSuccessfullyMigrated && !isMigrationPending ? (
<AutoColumn gap="12px" style={{ flex: '1', marginRight: 12 }}> <AutoColumn gap="12px" style={{ flex: '1' }}>
<ButtonConfirmed <ButtonConfirmed
confirmed={approval === ApprovalState.APPROVED || signatureData !== null} confirmed={approval === ApprovalState.APPROVED || signatureData !== null}
disabled={ disabled={
...@@ -495,7 +551,7 @@ function V2PairMigration({ ...@@ -495,7 +551,7 @@ function V2PairMigration({
) : approval === ApprovalState.APPROVED || signatureData !== null ? ( ) : approval === ApprovalState.APPROVED || signatureData !== null ? (
'Approved' 'Approved'
) : ( ) : (
'Approve' 'Unlock LP tokens for migration'
)} )}
</ButtonConfirmed> </ButtonConfirmed>
</AutoColumn> </AutoColumn>
...@@ -517,25 +573,9 @@ function V2PairMigration({ ...@@ -517,25 +573,9 @@ function V2PairMigration({
{isSuccessfullyMigrated ? 'Success!' : isMigrationPending ? <Dots>Migrating</Dots> : 'Migrate'} {isSuccessfullyMigrated ? 'Success!' : isMigrationPending ? <Dots>Migrating</Dots> : 'Migrate'}
</ButtonConfirmed> </ButtonConfirmed>
</AutoColumn> </AutoColumn>
</div> </AutoColumn>
</AutoColumn>
{chainId && refund0 && refund1 ? (
<div style={{ marginTop: '1rem' }}>
<TYPE.darkGray style={{ textAlign: 'center' }}>
{formatTokenAmount(refund0, 4)} {token0.equals(WETH9[chainId]) ? 'ETH' : token0.symbol} and{' '}
{formatTokenAmount(refund1, 4)} {token1.equals(WETH9[chainId]) ? 'ETH' : token1.symbol} will be refunded
to your wallet.
</TYPE.darkGray>
</div>
) : null}
</LightCard> </LightCard>
<TYPE.darkGray style={{ textAlign: 'center' }}>
{`Your Uniswap V2 ${invertPrice ? currency0?.symbol : currency1?.symbol} / ${
invertPrice ? currency1?.symbol : currency0?.symbol
} liquidity tokens will become a Uniswap V3 ${invertPrice ? currency0?.symbol : currency1?.symbol} / ${
invertPrice ? currency1?.symbol : currency0?.symbol
} NFT.`}
</TYPE.darkGray>
</AutoColumn> </AutoColumn>
) )
} }
...@@ -562,7 +602,7 @@ export default function MigrateV2Pair({ ...@@ -562,7 +602,7 @@ export default function MigrateV2Pair({
// get liquidity token balance // get liquidity token balance
const liquidityToken: Token | undefined = useMemo( const liquidityToken: Token | undefined = useMemo(
() => (chainId && validatedAddress ? new Token(chainId, validatedAddress, 18, 'UNI-V2', 'Uniswap V2') : undefined), () => (chainId && validatedAddress ? new Token(chainId, validatedAddress, 18) : undefined),
[chainId, validatedAddress] [chainId, validatedAddress]
) )
......
import { createStore, Store } from 'redux' import { createStore, Store } from 'redux'
import { DEFAULT_DEADLINE_FROM_NOW, INITIAL_ALLOWED_SLIPPAGE } from '../../constants' import { DEFAULT_DEADLINE_FROM_NOW } from '../../constants'
import { updateVersion } from '../global/actions' import { updateVersion } from '../global/actions'
import reducer, { initialState, UserState } from './reducer' import reducer, { initialState, UserState } from './reducer'
......
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