Commit a11e89c0 authored by Noah Zinsmeister's avatar Noah Zinsmeister Committed by GitHub

hide WETH toggle for non-WETH pairs (#1633)

* only show weth toggle for eth pairs

* revert unwrappedToken change
parent 3efe5268
...@@ -24,7 +24,17 @@ import { currencyId } from 'utils/currencyId' ...@@ -24,7 +24,17 @@ 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 { Token, Currency, CurrencyAmount, Percent, Fraction, Price, Ether } from '@uniswap/sdk-core' import {
Token,
Currency,
CurrencyAmount,
Percent,
Fraction,
Price,
Ether,
currencyEquals,
ETHER,
} from '@uniswap/sdk-core'
import { useActiveWeb3React } from 'hooks/web3' import { useActiveWeb3React } from 'hooks/web3'
import { useV3NFTPositionManagerContract } from 'hooks/useContract' import { useV3NFTPositionManagerContract } from 'hooks/useContract'
import { useIsTransactionPending, useTransactionAdder } from 'state/transactions/hooks' import { useIsTransactionPending, useTransactionAdder } from 'state/transactions/hooks'
...@@ -677,7 +687,12 @@ export function PositionPage({ ...@@ -677,7 +687,12 @@ export function PositionPage({
</RowBetween> </RowBetween>
</AutoColumn> </AutoColumn>
</LightCard> </LightCard>
{ownsNFT && (feeValue0?.greaterThan(0) || feeValue1?.greaterThan(0)) && !collectMigrationHash ? ( {ownsNFT &&
(feeValue0?.greaterThan(0) || feeValue1?.greaterThan(0)) &&
currency0 &&
currency1 &&
(currencyEquals(currency0, ETHER) || currencyEquals(currency1, ETHER)) &&
!collectMigrationHash ? (
<AutoColumn gap="md"> <AutoColumn gap="md">
<RowBetween> <RowBetween>
<TYPE.main>Collect as WETH</TYPE.main> <TYPE.main>Collect as WETH</TYPE.main>
......
...@@ -21,7 +21,7 @@ import ReactGA from 'react-ga' ...@@ -21,7 +21,7 @@ import ReactGA from 'react-ga'
import { useActiveWeb3React } from 'hooks/web3' import { useActiveWeb3React } from 'hooks/web3'
import { TransactionResponse } from '@ethersproject/providers' import { TransactionResponse } from '@ethersproject/providers'
import { useTransactionAdder } from 'state/transactions/hooks' import { useTransactionAdder } from 'state/transactions/hooks'
import { Percent } from '@uniswap/sdk-core' import { Percent, currencyEquals, Token, ETHER } from '@uniswap/sdk-core'
import { TYPE } from 'theme' import { TYPE } from 'theme'
import { Wrapper, SmallMaxButton, ResponsiveHeaderText } from './styled' import { Wrapper, SmallMaxButton, ResponsiveHeaderText } from './styled'
import Loader from 'components/Loader' import Loader from 'components/Loader'
...@@ -33,6 +33,7 @@ import useTheme from 'hooks/useTheme' ...@@ -33,6 +33,7 @@ import useTheme from 'hooks/useTheme'
import { AddRemoveTabs } from 'components/NavigationTabs' import { AddRemoveTabs } from 'components/NavigationTabs'
import RangeBadge from 'components/Badge/RangeBadge' import RangeBadge from 'components/Badge/RangeBadge'
import Toggle from 'components/Toggle' import Toggle from 'components/Toggle'
import { unwrappedToken } from 'utils/wrappedCurrency'
export const UINT128MAX = BigNumber.from(2).pow(128).sub(1) export const UINT128MAX = BigNumber.from(2).pow(128).sub(1)
...@@ -369,14 +370,21 @@ function Remove({ tokenId }: { tokenId: BigNumber }) { ...@@ -369,14 +370,21 @@ function Remove({ tokenId }: { tokenId: BigNumber }) {
</AutoColumn> </AutoColumn>
</LightCard> </LightCard>
<RowBetween> {liquidityValue0?.currency &&
<TYPE.main>Collect as WETH</TYPE.main> liquidityValue1?.currency &&
<Toggle (liquidityValue0.currency.isEther ||
id="receive-as-weth" liquidityValue1.currency.isEther ||
isActive={receiveWETH} currencyEquals(unwrappedToken(liquidityValue0.currency as Token), ETHER) ||
toggle={() => setReceiveWETH((receiveWETH) => !receiveWETH)} currencyEquals(unwrappedToken(liquidityValue1.currency as Token), ETHER)) ? (
/> <RowBetween>
</RowBetween> <TYPE.main>Collect as WETH</TYPE.main>
<Toggle
id="receive-as-weth"
isActive={receiveWETH}
toggle={() => setReceiveWETH((receiveWETH) => !receiveWETH)}
/>
</RowBetween>
) : null}
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<AutoColumn gap="12px" style={{ flex: '1' }}> <AutoColumn gap="12px" style={{ flex: '1' }}>
......
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