Commit 60d1f874 authored by Moody Salem's avatar Moody Salem

just a bit more refactoring to remove the data directory

parent 2d118a90
...@@ -4,7 +4,7 @@ import { X } from 'react-feather' ...@@ -4,7 +4,7 @@ import { X } from 'react-feather'
import styled from 'styled-components' import styled from 'styled-components'
import tokenLogo from '../../assets/images/token-logo.png' import tokenLogo from '../../assets/images/token-logo.png'
import { UNI } from '../../constants' import { UNI } from '../../constants'
import { useTotalSupply } from '../../data/TotalSupply' import { useTotalSupply } from '../../hooks/useTotalSupply'
import { useActiveWeb3React } from '../../hooks' import { useActiveWeb3React } from '../../hooks'
import { useMerkleDistributorContract } from '../../hooks/useContract' import { useMerkleDistributorContract } from '../../hooks/useContract'
import useCurrentBlockTimestamp from '../../hooks/useCurrentBlockTimestamp' import useCurrentBlockTimestamp from '../../hooks/useCurrentBlockTimestamp'
......
...@@ -5,7 +5,7 @@ import { ChevronDown, ChevronUp } from 'react-feather' ...@@ -5,7 +5,7 @@ import { ChevronDown, ChevronUp } from 'react-feather'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { Text } from 'rebass' import { Text } from 'rebass'
import styled from 'styled-components' import styled from 'styled-components'
import { useTotalSupply } from '../../data/TotalSupply' import { useTotalSupply } from '../../hooks/useTotalSupply'
import { useActiveWeb3React } from '../../hooks' import { useActiveWeb3React } from '../../hooks'
import { useTokenBalance } from '../../state/wallet/hooks' import { useTokenBalance } from '../../state/wallet/hooks'
......
...@@ -6,7 +6,7 @@ import { ChevronDown, ChevronUp } from 'react-feather' ...@@ -6,7 +6,7 @@ import { ChevronDown, ChevronUp } from 'react-feather'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { Text } from 'rebass' import { Text } from 'rebass'
import styled from 'styled-components' import styled from 'styled-components'
import { useTotalSupply } from '../../data/TotalSupply' import { useTotalSupply } from '../../hooks/useTotalSupply'
import { useActiveWeb3React } from '../../hooks' import { useActiveWeb3React } from '../../hooks'
import { useTokenBalance } from '../../state/wallet/hooks' import { useTokenBalance } from '../../state/wallet/hooks'
......
...@@ -12,8 +12,8 @@ import { useColor } from '../../hooks/useColor' ...@@ -12,8 +12,8 @@ import { useColor } from '../../hooks/useColor'
import { currencyId } from '../../utils/currencyId' import { currencyId } from '../../utils/currencyId'
import { Break, CardNoise, CardBGImage } from './styled' import { Break, CardNoise, CardBGImage } from './styled'
import { unwrappedToken } from '../../utils/wrappedCurrency' import { unwrappedToken } from '../../utils/wrappedCurrency'
import { useTotalSupply } from '../../data/TotalSupply' import { useTotalSupply } from '../../hooks/useTotalSupply'
import { usePair } from '../../data/V2' import { useV2Pair } from '../../hooks/useV2Pairs'
import useUSDCPrice from '../../hooks/useUSDCPrice' import useUSDCPrice from '../../hooks/useUSDCPrice'
import { BIG_INT_SECONDS_IN_WEEK } from '../../constants' import { BIG_INT_SECONDS_IN_WEEK } from '../../constants'
...@@ -84,7 +84,7 @@ export default function PoolCard({ stakingInfo }: { stakingInfo: StakingInfo }) ...@@ -84,7 +84,7 @@ export default function PoolCard({ stakingInfo }: { stakingInfo: StakingInfo })
const backgroundColor = useColor(token) const backgroundColor = useColor(token)
const totalSupplyOfStakingToken = useTotalSupply(stakingInfo.stakedAmount.token) const totalSupplyOfStakingToken = useTotalSupply(stakingInfo.stakedAmount.token)
const [, stakingTokenPair] = usePair(...stakingInfo.tokens) const [, stakingTokenPair] = useV2Pair(...stakingInfo.tokens)
// let returnOverMonth: Percent = new Percent('0') // let returnOverMonth: Percent = new Percent('0')
let valueOfTotalStakedAmountInWETH: TokenAmount | undefined let valueOfTotalStakedAmountInWETH: TokenAmount | undefined
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -4,7 +4,7 @@ import { JSBI, Router, SwapParameters, Trade } from '@uniswap/v2-sdk' ...@@ -4,7 +4,7 @@ import { JSBI, Router, SwapParameters, Trade } from '@uniswap/v2-sdk'
import { Percent, TradeType } from '@uniswap/sdk-core' import { Percent, TradeType } from '@uniswap/sdk-core'
import { useMemo } from 'react' import { useMemo } from 'react'
import { BIPS_BASE, INITIAL_ALLOWED_SLIPPAGE } from '../constants' import { BIPS_BASE, INITIAL_ALLOWED_SLIPPAGE } from '../constants'
import { getTradeVersion } from '../data/getTradeVersion' import { getTradeVersion } from '../utils/getTradeVersion'
import { useTransactionAdder } from '../state/transactions/hooks' import { useTransactionAdder } from '../state/transactions/hooks'
import { calculateGasMargin, getRouterContract, isAddress, shortenAddress } from '../utils' import { calculateGasMargin, getRouterContract, isAddress, shortenAddress } from '../utils'
import isZero from '../utils/isZero' import isZero from '../utils/isZero'
......
...@@ -2,6 +2,7 @@ import useParsedQueryString from './useParsedQueryString' ...@@ -2,6 +2,7 @@ import useParsedQueryString from './useParsedQueryString'
export enum Version { export enum Version {
v2 = 'v2', v2 = 'v2',
v3 = 'v3',
} }
export const DEFAULT_VERSION: Version = Version.v2 export const DEFAULT_VERSION: Version = Version.v2
......
import { BigNumber } from '@ethersproject/bignumber' import { BigNumber } from '@ethersproject/bignumber'
import { Token, TokenAmount } from '@uniswap/sdk-core' import { Token, TokenAmount } from '@uniswap/sdk-core'
import { useTokenContract } from '../hooks/useContract' import { useTokenContract } from './useContract'
import { useSingleCallResult } from '../state/multicall/hooks' import { useSingleCallResult } from '../state/multicall/hooks'
// returns undefined if input token is undefined, or fails to get token contract, // returns undefined if input token is undefined, or fails to get token contract,
......
...@@ -2,7 +2,7 @@ import { ChainId, Currency, currencyEquals, Price, WETH9 } from '@uniswap/sdk-co ...@@ -2,7 +2,7 @@ import { ChainId, Currency, currencyEquals, Price, WETH9 } from '@uniswap/sdk-co
import { JSBI } from '@uniswap/v2-sdk' import { JSBI } from '@uniswap/v2-sdk'
import { useMemo } from 'react' import { useMemo } from 'react'
import { USDC } from '../constants' import { USDC } from '../constants'
import { PairState, usePairs } from '../data/V2' import { PairState, useV2Pairs } from './useV2Pairs'
import { useActiveWeb3React } from '../hooks' import { useActiveWeb3React } from '../hooks'
import { wrappedCurrency } from '../utils/wrappedCurrency' import { wrappedCurrency } from '../utils/wrappedCurrency'
...@@ -24,7 +24,7 @@ export default function useUSDCPrice(currency?: Currency): Price | undefined { ...@@ -24,7 +24,7 @@ export default function useUSDCPrice(currency?: Currency): Price | undefined {
], ],
[chainId, currency, wrapped] [chainId, currency, wrapped]
) )
const [[ethPairState, ethPair], [usdcPairState, usdcPair], [usdcEthPairState, usdcEthPair]] = usePairs(tokenPairs) const [[ethPairState, ethPair], [usdcPairState, usdcPair], [usdcEthPairState, usdcEthPair]] = useV2Pairs(tokenPairs)
return useMemo(() => { return useMemo(() => {
if (!currency || !wrapped || !chainId) { if (!currency || !wrapped || !chainId) {
......
...@@ -2,8 +2,7 @@ import { Pair } from '@uniswap/v2-sdk' ...@@ -2,8 +2,7 @@ import { Pair } from '@uniswap/v2-sdk'
import { useMemo } from 'react' import { useMemo } from 'react'
import { abi as IUniswapV2PairABI } from '@uniswap/v2-core/build/IUniswapV2Pair.json' import { abi as IUniswapV2PairABI } from '@uniswap/v2-core/build/IUniswapV2Pair.json'
import { Interface } from '@ethersproject/abi' import { Interface } from '@ethersproject/abi'
import { useActiveWeb3React } from '../hooks' import { useActiveWeb3React } from './index'
import { useMultipleContractSingleData } from '../state/multicall/hooks' import { useMultipleContractSingleData } from '../state/multicall/hooks'
import { wrappedCurrency } from '../utils/wrappedCurrency' import { wrappedCurrency } from '../utils/wrappedCurrency'
import { Currency, TokenAmount } from '@uniswap/sdk-core' import { Currency, TokenAmount } from '@uniswap/sdk-core'
...@@ -17,7 +16,7 @@ export enum PairState { ...@@ -17,7 +16,7 @@ export enum PairState {
INVALID, INVALID,
} }
export function usePairs(currencies: [Currency | undefined, Currency | undefined][]): [PairState, Pair | null][] { export function useV2Pairs(currencies: [Currency | undefined, Currency | undefined][]): [PairState, Pair | null][] {
const { chainId } = useActiveWeb3React() const { chainId } = useActiveWeb3React()
const tokens = useMemo( const tokens = useMemo(
...@@ -58,6 +57,6 @@ export function usePairs(currencies: [Currency | undefined, Currency | undefined ...@@ -58,6 +57,6 @@ export function usePairs(currencies: [Currency | undefined, Currency | undefined
}, [results, tokens]) }, [results, tokens])
} }
export function usePair(tokenA?: Currency, tokenB?: Currency): [PairState, Pair | null] { export function useV2Pair(tokenA?: Currency, tokenB?: Currency): [PairState, Pair | null] {
return usePairs([[tokenA, tokenB]])[0] return useV2Pairs([[tokenA, tokenB]])[0]
} }
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
BETTER_TRADE_LESS_HOPS_THRESHOLD, BETTER_TRADE_LESS_HOPS_THRESHOLD,
CUSTOM_BASES, CUSTOM_BASES,
} from '../constants' } from '../constants'
import { PairState, usePairs } from '../data/V2' import { PairState, useV2Pairs } from './useV2Pairs'
import { wrappedCurrency } from '../utils/wrappedCurrency' import { wrappedCurrency } from '../utils/wrappedCurrency'
import { useActiveWeb3React } from './index' import { useActiveWeb3React } from './index'
...@@ -69,7 +69,7 @@ function useAllCommonPairs(currencyA?: Currency, currencyB?: Currency): Pair[] { ...@@ -69,7 +69,7 @@ function useAllCommonPairs(currencyA?: Currency, currencyB?: Currency): Pair[] {
[tokenA, tokenB, bases, basePairs, chainId] [tokenA, tokenB, bases, basePairs, chainId]
) )
const allPairs = usePairs(allPairCombinations) const allPairs = useV2Pairs(allPairCombinations)
// only pass along valid pairs, non-duplicated pairs // only pass along valid pairs, non-duplicated pairs
return useMemo( return useMemo(
......
...@@ -18,7 +18,7 @@ import { MinimalPositionCard } from '../../components/PositionCard' ...@@ -18,7 +18,7 @@ import { MinimalPositionCard } from '../../components/PositionCard'
import Row, { RowBetween, RowFlat } from '../../components/Row' import Row, { RowBetween, RowFlat } from '../../components/Row'
import { ROUTER_ADDRESS } from '../../constants' import { ROUTER_ADDRESS } from '../../constants'
import { PairState } from '../../data/V2' import { PairState } from '../../hooks/useV2Pairs'
import { useActiveWeb3React } from '../../hooks' import { useActiveWeb3React } from '../../hooks'
import { useCurrency } from '../../hooks/Tokens' import { useCurrency } from '../../hooks/Tokens'
import { ApprovalState, useApproveCallback } from '../../hooks/useApproveCallback' import { ApprovalState, useApproveCallback } from '../../hooks/useApproveCallback'
......
...@@ -25,8 +25,8 @@ import { CountUp } from 'use-count-up' ...@@ -25,8 +25,8 @@ import { CountUp } from 'use-count-up'
import { wrappedCurrency } from '../../utils/wrappedCurrency' import { wrappedCurrency } from '../../utils/wrappedCurrency'
import { currencyId } from '../../utils/currencyId' import { currencyId } from '../../utils/currencyId'
import { useTotalSupply } from '../../data/TotalSupply' import { useTotalSupply } from '../../hooks/useTotalSupply'
import { usePair } from '../../data/V2' import { useV2Pair } from '../../hooks/useV2Pairs'
import usePrevious from '../../hooks/usePrevious' import usePrevious from '../../hooks/usePrevious'
import useUSDCPrice from '../../hooks/useUSDCPrice' import useUSDCPrice from '../../hooks/useUSDCPrice'
import { BIG_INT_ZERO, BIG_INT_SECONDS_IN_WEEK } from '../../constants' import { BIG_INT_ZERO, BIG_INT_SECONDS_IN_WEEK } from '../../constants'
...@@ -100,7 +100,7 @@ export default function Manage({ ...@@ -100,7 +100,7 @@ export default function Manage({
const tokenA = wrappedCurrency(currencyA ?? undefined, chainId) const tokenA = wrappedCurrency(currencyA ?? undefined, chainId)
const tokenB = wrappedCurrency(currencyB ?? undefined, chainId) const tokenB = wrappedCurrency(currencyB ?? undefined, chainId)
const [, stakingTokenPair] = usePair(tokenA, tokenB) const [, stakingTokenPair] = useV2Pair(tokenA, tokenB)
const stakingInfo = useStakingInfo(stakingTokenPair)?.[0] const stakingInfo = useStakingInfo(stakingTokenPair)?.[0]
// detect existing unstaked LP position to show add button if none found // detect existing unstaked LP position to show add button if none found
......
...@@ -8,7 +8,7 @@ import CurrencyLogo from '../../components/CurrencyLogo' ...@@ -8,7 +8,7 @@ import CurrencyLogo from '../../components/CurrencyLogo'
import FormattedCurrencyAmount from '../../components/FormattedCurrencyAmount' import FormattedCurrencyAmount from '../../components/FormattedCurrencyAmount'
import QuestionHelper from '../../components/QuestionHelper' import QuestionHelper from '../../components/QuestionHelper'
import { AutoRow, RowBetween, RowFixed } from '../../components/Row' import { AutoRow, RowBetween, RowFixed } from '../../components/Row'
import { useTotalSupply } from '../../data/TotalSupply' import { useTotalSupply } from '../../hooks/useTotalSupply'
import { useActiveWeb3React } from '../../hooks' import { useActiveWeb3React } from '../../hooks'
import { useToken } from '../../hooks/Tokens' import { useToken } from '../../hooks/Tokens'
import { usePairContract, useV2MigratorContract } from '../../hooks/useContract' import { usePairContract, useV2MigratorContract } from '../../hooks/useContract'
......
...@@ -13,7 +13,7 @@ import QuestionHelper from '../../components/QuestionHelper' ...@@ -13,7 +13,7 @@ import QuestionHelper from '../../components/QuestionHelper'
import { Dots } from '../../components/swap/styleds' import { Dots } from '../../components/swap/styleds'
import { toV2LiquidityToken, useTrackedTokenPairs } from '../../state/user/hooks' import { toV2LiquidityToken, useTrackedTokenPairs } from '../../state/user/hooks'
import MigrateV2PositionCard from 'components/PositionCard/V2' import MigrateV2PositionCard from 'components/PositionCard/V2'
import { usePairs } from 'data/V2' import { useV2Pairs } from 'hooks/useV2Pairs'
// TODO there's a bug in loading where "No V2 Liquidity found" flashes // TODO there's a bug in loading where "No V2 Liquidity found" flashes
// TODO add support for more pairs // TODO add support for more pairs
...@@ -52,7 +52,7 @@ export default function MigrateV2() { ...@@ -52,7 +52,7 @@ export default function MigrateV2() {
[tokenPairsWithLiquidityTokens, v2PairsBalances] [tokenPairsWithLiquidityTokens, v2PairsBalances]
) )
const v2Pairs = usePairs(liquidityTokensWithBalances.map(({ tokens }) => tokens)) const v2Pairs = useV2Pairs(liquidityTokensWithBalances.map(({ tokens }) => tokens))
const v2IsLoading = const v2IsLoading =
fetchingV2PairBalances || v2Pairs?.length < liquidityTokensWithBalances.length || v2Pairs?.some((V2Pair) => !V2Pair) fetchingV2PairBalances || v2Pairs?.length < liquidityTokensWithBalances.length || v2Pairs?.some((V2Pair) => !V2Pair)
const allV2PairsWithLiquidity = v2Pairs.map(([, pair]) => pair).filter((v2Pair): v2Pair is Pair => Boolean(v2Pair)) const allV2PairsWithLiquidity = v2Pairs.map(([, pair]) => pair).filter((v2Pair): v2Pair is Pair => Boolean(v2Pair))
......
...@@ -13,7 +13,7 @@ import { ButtonPrimary, ButtonSecondary } from '../../components/Button' ...@@ -13,7 +13,7 @@ import { ButtonPrimary, ButtonSecondary } from '../../components/Button'
import { AutoColumn } from '../../components/Column' import { AutoColumn } from '../../components/Column'
import { useActiveWeb3React } from '../../hooks' import { useActiveWeb3React } from '../../hooks'
import { usePairs } from '../../data/V2' import { useV2Pairs } from '../../hooks/useV2Pairs'
import { toV2LiquidityToken, useTrackedTokenPairs } from '../../state/user/hooks' import { toV2LiquidityToken, useTrackedTokenPairs } from '../../state/user/hooks'
import { Dots } from '../../components/swap/styleds' import { Dots } from '../../components/swap/styleds'
import { CardSection, DataCard, CardNoise, CardBGImage } from '../../components/earn/styled' import { CardSection, DataCard, CardNoise, CardBGImage } from '../../components/earn/styled'
...@@ -100,7 +100,7 @@ export default function Pool() { ...@@ -100,7 +100,7 @@ export default function Pool() {
[tokenPairsWithLiquidityTokens, v2PairsBalances] [tokenPairsWithLiquidityTokens, v2PairsBalances]
) )
const v2Pairs = usePairs(liquidityTokensWithBalances.map(({ tokens }) => tokens)) const v2Pairs = useV2Pairs(liquidityTokensWithBalances.map(({ tokens }) => tokens))
const v2IsLoading = const v2IsLoading =
fetchingV2PairBalances || v2Pairs?.length < liquidityTokensWithBalances.length || v2Pairs?.some((V2Pair) => !V2Pair) fetchingV2PairBalances || v2Pairs?.length < liquidityTokensWithBalances.length || v2Pairs?.some((V2Pair) => !V2Pair)
...@@ -109,7 +109,7 @@ export default function Pool() { ...@@ -109,7 +109,7 @@ export default function Pool() {
// show liquidity even if its deposited in rewards contract // show liquidity even if its deposited in rewards contract
const stakingInfo = useStakingInfo() const stakingInfo = useStakingInfo()
const stakingInfosWithBalance = stakingInfo?.filter((pool) => JSBI.greaterThan(pool.stakedAmount.raw, BIG_INT_ZERO)) const stakingInfosWithBalance = stakingInfo?.filter((pool) => JSBI.greaterThan(pool.stakedAmount.raw, BIG_INT_ZERO))
const stakingPairs = usePairs(stakingInfosWithBalance?.map((stakingInfo) => stakingInfo.tokens)) const stakingPairs = useV2Pairs(stakingInfosWithBalance?.map((stakingInfo) => stakingInfo.tokens))
// remove any pairs that also are included in pairs with stake in mining pool // remove any pairs that also are included in pairs with stake in mining pool
const v2PairsWithoutStakedAmount = allV2PairsWithLiquidity.filter((v2Pair) => { const v2PairsWithoutStakedAmount = allV2PairsWithLiquidity.filter((v2Pair) => {
......
...@@ -11,7 +11,7 @@ import { FindPoolTabs } from '../../components/NavigationTabs' ...@@ -11,7 +11,7 @@ import { FindPoolTabs } from '../../components/NavigationTabs'
import { MinimalPositionCard } from '../../components/PositionCard' import { MinimalPositionCard } from '../../components/PositionCard'
import Row from '../../components/Row' import Row from '../../components/Row'
import CurrencySearchModal from '../../components/SearchModal/CurrencySearchModal' import CurrencySearchModal from '../../components/SearchModal/CurrencySearchModal'
import { PairState, usePair } from '../../data/V2' import { PairState, useV2Pair } from '../../hooks/useV2Pairs'
import { useActiveWeb3React } from '../../hooks' import { useActiveWeb3React } from '../../hooks'
import { usePairAdder } from '../../state/user/hooks' import { usePairAdder } from '../../state/user/hooks'
import { useTokenBalance } from '../../state/wallet/hooks' import { useTokenBalance } from '../../state/wallet/hooks'
...@@ -43,7 +43,7 @@ export default function PoolFinder() { ...@@ -43,7 +43,7 @@ export default function PoolFinder() {
const [currency0, setCurrency0] = useState<Currency | null>(ETHER) const [currency0, setCurrency0] = useState<Currency | null>(ETHER)
const [currency1, setCurrency1] = useState<Currency | null>(null) const [currency1, setCurrency1] = useState<Currency | null>(null)
const [pairState, pair] = usePair(currency0 ?? undefined, currency1 ?? undefined) const [pairState, pair] = useV2Pair(currency0 ?? undefined, currency1 ?? undefined)
const addPair = usePairAdder() const addPair = usePairAdder()
useEffect(() => { useEffect(() => {
if (pair) { if (pair) {
......
...@@ -22,7 +22,7 @@ import ProgressSteps from '../../components/ProgressSteps' ...@@ -22,7 +22,7 @@ import ProgressSteps from '../../components/ProgressSteps'
import SwapHeader from '../../components/swap/SwapHeader' import SwapHeader from '../../components/swap/SwapHeader'
import { INITIAL_ALLOWED_SLIPPAGE } from '../../constants' import { INITIAL_ALLOWED_SLIPPAGE } from '../../constants'
import { getTradeVersion } from '../../data/getTradeVersion' import { getTradeVersion } from '../../utils/getTradeVersion'
import { useActiveWeb3React } from '../../hooks' import { useActiveWeb3React } from '../../hooks'
import { useCurrency, useAllTokens } from '../../hooks/Tokens' import { useCurrency, useAllTokens } from '../../hooks/Tokens'
import { ApprovalState, useApproveCallbackFromTrade } from '../../hooks/useApproveCallback' import { ApprovalState, useApproveCallbackFromTrade } from '../../hooks/useApproveCallback'
...@@ -101,6 +101,7 @@ export default function Swap({ history }: RouteComponentProps) { ...@@ -101,6 +101,7 @@ export default function Swap({ history }: RouteComponentProps) {
const toggledVersion = useToggledVersion() const toggledVersion = useToggledVersion()
const tradesByVersion = { const tradesByVersion = {
[Version.v2]: v2Trade, [Version.v2]: v2Trade,
[Version.v3]: undefined,
} }
const trade = showWrap ? undefined : tradesByVersion[toggledVersion] const trade = showWrap ? undefined : tradesByVersion[toggledVersion]
......
...@@ -2,8 +2,8 @@ import { Currency, CurrencyAmount, Percent, TokenAmount } from '@uniswap/sdk-cor ...@@ -2,8 +2,8 @@ import { Currency, CurrencyAmount, Percent, TokenAmount } from '@uniswap/sdk-cor
import { JSBI, Pair } from '@uniswap/v2-sdk' import { JSBI, Pair } from '@uniswap/v2-sdk'
import { useCallback } from 'react' import { useCallback } from 'react'
import { useDispatch, useSelector } from 'react-redux' import { useDispatch, useSelector } from 'react-redux'
import { usePair } from '../../data/V2' import { useV2Pair } from '../../hooks/useV2Pairs'
import { useTotalSupply } from '../../data/TotalSupply' import { useTotalSupply } from '../../hooks/useTotalSupply'
import { useActiveWeb3React } from '../../hooks' import { useActiveWeb3React } from '../../hooks'
import { wrappedCurrency } from '../../utils/wrappedCurrency' import { wrappedCurrency } from '../../utils/wrappedCurrency'
...@@ -34,7 +34,7 @@ export function useDerivedBurnInfo( ...@@ -34,7 +34,7 @@ export function useDerivedBurnInfo(
const { independentField, typedValue } = useBurnState() const { independentField, typedValue } = useBurnState()
// pair + totalsupply // pair + totalsupply
const [, pair] = usePair(currencyA, currencyB) const [, pair] = useV2Pair(currencyA, currencyB)
// balances // balances
const relevantTokenBalances = useTokenBalances(account ?? undefined, [pair?.liquidityToken]) const relevantTokenBalances = useTokenBalances(account ?? undefined, [pair?.liquidityToken])
......
...@@ -2,8 +2,8 @@ import { useMemo } from 'react' ...@@ -2,8 +2,8 @@ import { useMemo } from 'react'
import { Pair } from '@uniswap/v2-sdk' import { Pair } from '@uniswap/v2-sdk'
import { Currency, CurrencyAmount, ETHER, Percent, Price, TokenAmount } from '@uniswap/sdk-core' import { Currency, CurrencyAmount, ETHER, Percent, Price, TokenAmount } from '@uniswap/sdk-core'
import JSBI from 'jsbi' import JSBI from 'jsbi'
import { PairState, usePair } from '../../data/V2' import { PairState, useV2Pair } from '../../hooks/useV2Pairs'
import { useTotalSupply } from '../../data/TotalSupply' import { useTotalSupply } from '../../hooks/useTotalSupply'
import { useActiveWeb3React } from '../../hooks' import { useActiveWeb3React } from '../../hooks'
import { wrappedCurrency, wrappedCurrencyAmount } from '../../utils/wrappedCurrency' import { wrappedCurrency, wrappedCurrencyAmount } from '../../utils/wrappedCurrency'
...@@ -46,7 +46,7 @@ export function useV2DerivedMintInfo( ...@@ -46,7 +46,7 @@ export function useV2DerivedMintInfo(
) )
// pair // pair
const [pairState, pair] = usePair(currencies[Field.CURRENCY_A], currencies[Field.CURRENCY_B]) const [pairState, pair] = useV2Pair(currencies[Field.CURRENCY_A], currencies[Field.CURRENCY_B])
const totalSupply = useTotalSupply(pair?.liquidityToken) const totalSupply = useTotalSupply(pair?.liquidityToken)
const noLiquidity: boolean = const noLiquidity: boolean =
......
import { Trade as V2Trade } from '@uniswap/v2-sdk' import { Trade as V2Trade } from '@uniswap/v2-sdk'
import { Trade as V3Trade } from '@uniswap/v3-sdk'
import { Version } from '../hooks/useToggledVersion' import { Version } from '../hooks/useToggledVersion'
export function getTradeVersion(trade?: V2Trade): Version | undefined { export function getTradeVersion(trade?: V2Trade | V3Trade): Version | undefined {
if (!trade) return undefined if (!trade) return undefined
return Version.v2 if (trade instanceof V2Trade) return Version.v2
if (trade instanceof V3Trade) return Version.v3
throw new Error('Unknown trade type')
} }
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