Commit 878fc9cf authored by Ian Lapham's avatar Ian Lapham Committed by GitHub

Refactor with core (#33)

* Update index.ts

* feature(service worker): add offline support (#1319)

* Revert "feature(service worker): add offline support (#1319)" (#1320)

This reverts commit 34dfb41a.

* Revert "Revert "feature(service worker): add offline support (#1319)" (#1320)" (#1321)

This reverts commit db3328c8.

* unregisters all installed service workers (#1322)

* fix: modals stealing focus across frames (#1326)

* improvement(lists): add BA SEC tokens to unsupported list  (#1327)

* show hidden search results by default

* update break styles

* optimize filter, use debounce on input

* increase debounce time

* add ba association list

* handle dismiss (#1328)

* split up sdk use between core and v2

* Fix code style issues with ESLint

* remove service worker
Co-authored-by: default avatarMoody Salem <moodysalem@users.noreply.github.com>
Co-authored-by: default avatarJordan Frankfurt <jordanwfrankfurt@gmail.com>
Co-authored-by: default avatarHyperion <72735936+moontools-hyperion@users.noreply.github.com>
Co-authored-by: default avatarLint Action <lint-action@samuelmeuli.com>
parent 32e679c6
......@@ -41,7 +41,6 @@
"@uniswap/governance": "^1.0.2",
"@uniswap/liquidity-staker": "^1.0.2",
"@uniswap/merkle-distributor": "1.0.1",
"@uniswap/sdk": "3.0.3",
"@uniswap/token-lists": "^1.0.0-beta.19",
"@uniswap/v2-core": "1.0.0",
"@uniswap/v2-periphery": "^1.1.0-beta.0",
......@@ -94,19 +93,25 @@
"react-window": "^1.8.5",
"rebass": "^4.0.7",
"redux-localstorage-simple": "^2.3.1",
"serve": "^11.3.0",
"serve": "^11.3.2",
"start-server-and-test": "^1.11.0",
"styled-components": "^4.2.0",
"styled-system": "^5.1.5",
"typescript": "^3.8.3",
"use-count-up": "^2.2.5",
"wcag-contrast": "^3.0.0"
"wcag-contrast": "^3.0.0",
"workbox-core": "^6.1.0",
"workbox-expiration": "^6.1.0",
"workbox-precaching": "^6.1.0",
"workbox-routing": "^6.1.0",
"workbox-strategies": "^6.1.0"
},
"resolutions": {
"@walletconnect/web3-provider": "1.1.1-alpha.0"
},
"scripts": {
"start": "react-scripts start",
"start:service-worker": "yarn build && yarn serve -s build",
"build": "react-scripts build",
"eject": "react-scripts eject",
"integration-test": "start-server-and-test 'serve build -l 3000' http://localhost:3000 'cypress run'",
......@@ -134,6 +139,8 @@
"license": "GPL-3.0-or-later",
"dependencies": {
"@uniswap/default-token-list": "^2.0.0",
"@uniswap/sdk-core": "^1.0.8",
"@uniswap/v2-sdk": "^1.0.6",
"lightweight-charts": "^3.3.0"
}
}
{
"short_name": "Uniswap",
"name": "Uniswap",
"background_color": "#fff",
"display": "standalone",
"homepage_url": "https://app.uniswap.org",
"icons": [
{
"src": "./images/192x192_App_Icon.png",
......@@ -16,7 +17,8 @@
}
],
"orientation": "portrait",
"display": "standalone",
"theme_color": "#ff007a",
"background_color": "#fff"
"name": "Uniswap",
"short_name": "Uniswap",
"start_url": ".",
"theme_color": "#ff007a"
}
import { Currency, Pair } from '@uniswap/sdk'
import { Pair } from '@uniswap/v2-sdk'
import { Currency } from '@uniswap/sdk-core'
import React, { useState, useCallback } from 'react'
import styled from 'styled-components'
import { darken } from 'polished'
......
import { Currency, ETHER, Token } from '@uniswap/sdk'
import { Currency, ETHER, Token } from '@uniswap/sdk-core'
import React, { useMemo } from 'react'
import styled from 'styled-components'
......
import { Currency } from '@uniswap/sdk'
import { Currency } from '@uniswap/sdk-core'
import React from 'react'
import styled from 'styled-components'
import CurrencyLogo from '../CurrencyLogo'
......
import React from 'react'
import { CurrencyAmount, Fraction, JSBI } from '@uniswap/sdk'
import { CurrencyAmount, Fraction } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
const CURRENCY_AMOUNT_MIN = new Fraction(JSBI.BigInt(1), JSBI.BigInt(1000000))
......
import { ChainId, TokenAmount } from '@uniswap/sdk'
import { ChainId, TokenAmount } from '@uniswap/sdk-core'
import React, { useMemo } from 'react'
import { X } from 'react-feather'
import styled from 'styled-components'
......
import { ChainId, TokenAmount } from '@uniswap/sdk'
import { ChainId, TokenAmount } from '@uniswap/sdk-core'
import React, { useState } from 'react'
import { Text } from 'rebass'
import { NavLink } from 'react-router-dom'
......
......@@ -117,7 +117,13 @@ export default function Modal({
{fadeTransition.map(
({ item, key, props }) =>
item && (
<StyledDialogOverlay key={key} style={props} onDismiss={onDismiss} initialFocusRef={initialFocusRef}>
<StyledDialogOverlay
key={key}
style={props}
onDismiss={onDismiss}
initialFocusRef={initialFocusRef}
unstable_lockFocusAcrossFrames={false}
>
<StyledDialogContent
{...(isMobile
? {
......
import { TokenAmount } from '@uniswap/sdk'
import { TokenAmount } from '@uniswap/sdk-core'
import React, { useEffect } from 'react'
import { X } from 'react-feather'
import styled, { keyframes } from 'styled-components'
......
import { Token, TokenAmount, WETH } from '@uniswap/sdk'
import React, { useContext } from 'react'
import { Link, RouteComponentProps, withRouter } from 'react-router-dom'
import { Token, TokenAmount, WETH9 } from '@uniswap/sdk-core'
import { Text } from 'rebass'
import { ThemeContext } from 'styled-components'
import { useActiveWeb3React } from '../../hooks'
......@@ -27,7 +27,7 @@ function V1PositionCard({ token, V1LiquidityBalance }: PositionCardProps) {
<RowFixed>
<DoubleCurrencyLogo currency0={token} margin={true} size={20} />
<Text fontWeight={500} fontSize={20} style={{ marginLeft: '' }}>
{`${chainId && token.equals(WETH[chainId]) ? 'WETH' : token.symbol}/ETH`}
{`${chainId && token.equals(WETH9[chainId]) ? 'WETH' : token.symbol}/ETH`}
</Text>
<Text
fontSize={12}
......
import { JSBI, Pair, Percent, TokenAmount } from '@uniswap/sdk'
import { Percent, TokenAmount } from '@uniswap/sdk-core'
import { JSBI, Pair } from '@uniswap/v2-sdk'
import { darken } from 'polished'
import React, { useState } from 'react'
import { ChevronDown, ChevronUp } from 'react-feather'
......
import { Story } from '@storybook/react/types-6-0'
import { TokenAmount } from '@uniswap/sdk'
import React from 'react'
import { basisPointsToPercent } from 'utils'
import { DAI, WBTC } from '../../constants'
import Component, { PositionListProps } from './index'
import { TokenAmount } from '@uniswap/sdk-core'
import JSBI from 'jsbi'
const FEE_BIPS = {
FIVE: basisPointsToPercent(5),
THIRTY: basisPointsToPercent(30),
ONE_HUNDRED: basisPointsToPercent(100),
}
const daiAmount = new TokenAmount(DAI, BigInt(500) * BigInt(10e18))
const wbtcAmount = new TokenAmount(WBTC, BigInt(1) * BigInt(10e7))
const daiAmount = new TokenAmount(DAI, JSBI.BigInt(500 * 10 ** 18))
const wbtcAmount = new TokenAmount(WBTC, JSBI.BigInt(10 ** 7))
const positions = [
{
feesEarned: {
......
import { Percent, TokenAmount } from '@uniswap/sdk'
import Badge, { BadgeVariant } from 'components/Badge'
import DoubleCurrencyLogo from 'components/DoubleLogo'
import React from 'react'
......@@ -215,7 +214,7 @@ export default function PositionList({ loading, positions, showUnwrapped }: Posi
const symbol1 = tokenAmount1.token.symbol || ''
const currency0 = showUnwrapped ? tokenAmount0.token : unwrappedToken(tokenAmount0.token)
const currency1 = showUnwrapped ? tokenAmount1.token : unwrappedToken(tokenAmount1.token)
const limitCrossed = tokenAmount0.equalTo(BigInt(0)) || tokenAmount1.equalTo(BigInt(0))
const limitCrossed = tokenAmount0.equalTo(0) || tokenAmount1.equalTo(0)
const key = `${feeLevel.toFixed()}-${symbol0}-${tokenAmount0.toFixed(2)}-${symbol1}-${tokenAmount1.toFixed(
2
......
import React from 'react'
import { Text } from 'rebass'
import { ChainId, Currency, currencyEquals, ETHER, Token } from '@uniswap/sdk'
import { ChainId, Currency, currencyEquals, ETHER, Token } from '@uniswap/sdk-core'
import styled from 'styled-components'
import { SUGGESTED_BASES } from '../../constants'
......
import { Currency, CurrencyAmount, currencyEquals, ETHER, Token } from '@uniswap/sdk'
import { Currency, CurrencyAmount, currencyEquals, ETHER, Token } from '@uniswap/sdk-core'
import React, { CSSProperties, MutableRefObject, useCallback, useMemo } from 'react'
import { FixedSizeList } from 'react-window'
import { Text } from 'rebass'
......
import { Currency, ETHER, Token } from '@uniswap/sdk'
import { Currency, ETHER, Token } from '@uniswap/sdk-core'
import React, { KeyboardEvent, RefObject, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import ReactGA from 'react-ga'
import { useTranslation } from 'react-i18next'
......
import { Currency, Token } from '@uniswap/sdk'
import { Currency, Token } from '@uniswap/sdk-core'
import React, { useCallback, useEffect, useState } from 'react'
import useLast from '../../hooks/useLast'
import Modal from '../Modal'
......
import React, { CSSProperties } from 'react'
import { Token } from '@uniswap/sdk'
import { Token } from '@uniswap/sdk-core'
import { AutoRow, RowFixed } from 'components/Row'
import { AutoColumn } from 'components/Column'
import CurrencyLogo from 'components/CurrencyLogo'
......
import React, { useState } from 'react'
import { Token, Currency } from '@uniswap/sdk'
import { Token, Currency } from '@uniswap/sdk-core'
import styled from 'styled-components'
import { TYPE, CloseIcon } from 'theme'
import Card from 'components/Card'
......
......@@ -5,7 +5,7 @@ import { ArrowLeft } from 'react-feather'
import { Text } from 'rebass'
import { CloseIcon } from 'theme'
import styled from 'styled-components'
import { Token } from '@uniswap/sdk'
import { Token } from '@uniswap/sdk-core'
import { ManageLists } from './ManageLists'
import ManageTokens from './ManageTokens'
import { TokenList } from '@uniswap/token-lists'
......
......@@ -6,7 +6,7 @@ import { TYPE, ExternalLinkIcon, TrashIcon, ButtonText, ExternalLink } from 'the
import { useToken } from 'hooks/Tokens'
import styled from 'styled-components'
import { useUserAddedTokens, useRemoveUserAddedToken } from 'state/user/hooks'
import { Token } from '@uniswap/sdk'
import { Token } from '@uniswap/sdk-core'
import CurrencyLogo from 'components/CurrencyLogo'
import { getEtherscanLink, isAddress } from 'utils'
import { useActiveWeb3React } from 'hooks'
......
import { useMemo } from 'react'
import { isAddress } from '../../utils'
import { Token } from '@uniswap/sdk'
import { Token } from '@uniswap/sdk-core'
export function filterTokens(tokens: Token[], search: string): Token[] {
if (search.length === 0) return tokens
......
import { Token, TokenAmount } from '@uniswap/sdk'
import { Token, TokenAmount } from '@uniswap/sdk-core'
import { useMemo } from 'react'
import { useAllTokenBalances } from '../../state/wallet/hooks'
......
import { Token } from '@uniswap/sdk'
import React, { useCallback } from 'react'
import { Token } from '@uniswap/sdk-core'
import React from 'react'
import Modal from '../Modal'
import { ImportToken } from 'components/SearchModal/ImportToken'
......@@ -7,15 +7,15 @@ export default function TokenWarningModal({
isOpen,
tokens,
onConfirm,
onDismiss,
}: {
isOpen: boolean
tokens: Token[]
onConfirm: () => void
onDismiss: () => void
}) {
const handleDismiss = useCallback(() => null, [])
return (
<Modal isOpen={isOpen} onDismiss={handleDismiss} maxHeight={90}>
<Modal isOpen={isOpen} onDismiss={onDismiss} maxHeight={100}>
<ImportToken tokens={tokens} handleCurrencySelect={onConfirm} />
</Modal>
)
......
import { ChainId, Currency } from '@uniswap/sdk'
import { ChainId, Currency } from '@uniswap/sdk-core'
import React, { useContext } from 'react'
import styled, { ThemeContext } from 'styled-components'
import Modal from '../Modal'
......
......@@ -17,7 +17,7 @@ import { isAddress } from 'ethers/lib/utils'
import Confetti from '../Confetti'
import { CardNoise, CardBGImage, CardBGImageSmaller } from '../earn/styled'
import { useIsTransactionPending } from '../../state/transactions/hooks'
import { TokenAmount } from '@uniswap/sdk'
import { TokenAmount } from '@uniswap/sdk-core'
import { getEtherscanLink, shortenAddress } from '../../utils'
const ContentWrapper = styled(AutoColumn)`
......
import { JSBI, TokenAmount } from '@uniswap/sdk'
import { TokenAmount } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
import { isAddress } from 'ethers/lib/utils'
import React, { useEffect, useState } from 'react'
import { Text } from 'rebass'
......
......@@ -4,7 +4,8 @@ import { RowBetween } from '../Row'
import styled from 'styled-components'
import { TYPE, StyledInternalLink } from '../../theme'
import DoubleCurrencyLogo from '../DoubleLogo'
import { ETHER, JSBI, TokenAmount } from '@uniswap/sdk'
import { ETHER, TokenAmount } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
import { ButtonPrimary } from '../Button'
import { StakingInfo } from '../../state/stake/hooks'
import { useColor } from '../../hooks/useColor'
......
......@@ -9,7 +9,8 @@ import { TYPE, CloseIcon } from '../../theme'
import { ButtonConfirmed, ButtonError } from '../Button'
import ProgressCircles from '../ProgressSteps'
import CurrencyInputPanel from '../CurrencyInputPanel'
import { TokenAmount, Pair } from '@uniswap/sdk'
import { Pair } from '@uniswap/v2-sdk'
import { TokenAmount } from '@uniswap/sdk-core'
import { useActiveWeb3React } from '../../hooks'
import { maxAmountSpend } from '../../utils/maxAmountSpend'
import { usePairContract, useStakingContract } from '../../hooks/useContract'
......
import { Trade, TradeType } from '@uniswap/sdk'
import { TradeType } from '@uniswap/sdk-core'
import { Trade } from '@uniswap/v2-sdk'
import React, { useContext } from 'react'
import styled, { ThemeContext } from 'styled-components'
import { Field } from '../../state/swap/actions'
......
import { currencyEquals, Trade } from '@uniswap/sdk'
import { currencyEquals } from '@uniswap/sdk-core'
import { Trade } from '@uniswap/v2-sdk'
import React, { useCallback, useMemo } from 'react'
import TransactionConfirmationModal, {
ConfirmationModalContent,
......
import { Percent } from '@uniswap/sdk'
import { Percent } from '@uniswap/sdk-core'
import React from 'react'
import { ONE_BIPS } from '../../constants'
import { warningSeverity } from '../../utils/prices'
......
import { Trade, TradeType } from '@uniswap/sdk'
import { Trade } from '@uniswap/v2-sdk'
import { TradeType } from '@uniswap/sdk-core'
import React, { useContext, useMemo, useState } from 'react'
import { Repeat } from 'react-feather'
import { Text } from 'rebass'
......
import { Trade, TradeType } from '@uniswap/sdk'
import { TradeType } from '@uniswap/sdk-core'
import { Trade } from '@uniswap/v2-sdk'
import React, { useContext, useMemo } from 'react'
import { ArrowDown, AlertTriangle } from 'react-feather'
import { Text } from 'rebass'
......
import { Trade } from '@uniswap/sdk'
import { Trade } from '@uniswap/v2-sdk'
import React, { Fragment, memo, useContext } from 'react'
import { ChevronRight } from 'react-feather'
import { Flex } from 'rebass'
......
import React from 'react'
import { Price } from '@uniswap/sdk'
import { Price } from '@uniswap/sdk-core'
import { useContext } from 'react'
import { Repeat } from 'react-feather'
import { Text } from 'rebass'
......
......@@ -9,7 +9,7 @@ import { AutoColumn } from 'components/Column'
import CurrencyLogo from 'components/CurrencyLogo'
import { useActiveWeb3React } from 'hooks'
import { getEtherscanLink } from 'utils'
import { Currency, Token } from '@uniswap/sdk'
import { Currency, Token } from '@uniswap/sdk-core'
import { wrappedCurrency } from 'utils/wrappedCurrency'
import { useUnsupportedTokens } from '../../hooks/Tokens'
......@@ -64,7 +64,6 @@ export default function UnsupportedCurrencyFooter({
<AutoColumn gap="lg">
<RowBetween>
<TYPE.mediumHeader>Unsupported Assets</TYPE.mediumHeader>
<CloseIcon onClick={() => setShowDetails(false)} />
</RowBetween>
{tokens.map((token) => {
......
import { Percent } from '@uniswap/sdk'
import { Percent } from '@uniswap/sdk-core'
import { ALLOWED_PRICE_IMPACT_HIGH, PRICE_IMPACT_WITHOUT_FEE_CONFIRM_MIN } from '../../constants'
/**
......
......@@ -12,7 +12,7 @@ import Circle from '../../assets/images/blue-loader.svg'
import { useVoteCallback, useUserVotes } from '../../state/governance/hooks'
import { getEtherscanLink } from '../../utils'
import { ExternalLink } from '../../theme/components'
import { TokenAmount } from '@uniswap/sdk'
import { TokenAmount } from '@uniswap/sdk-core'
const ContentWrapper = styled(AutoColumn)`
width: 100%;
......
import { ChainId } from '@uniswap/sdk'
import { ChainId } from '@uniswap/sdk-core'
import { FortmaticConnector as FortmaticConnectorCore } from '@web3-react/fortmatic-connector'
export const OVERLAY_READY = 'OVERLAY_READY'
......
import { ChainId, JSBI, Percent, Token, WETH } from '@uniswap/sdk'
import { ChainId, Percent, Token, WETH9 } from '@uniswap/sdk-core'
import { AbstractConnector } from '@web3-react/abstract-connector'
import JSBI from 'jsbi'
import { fortmatic, injected, portis, walletconnect, walletlink } from '../connectors'
......@@ -52,11 +53,11 @@ export const MERKLE_DISTRIBUTOR_ADDRESS: { [chainId in ChainId]?: string } = {
}
const WETH_ONLY: ChainTokenList = {
[ChainId.MAINNET]: [WETH[ChainId.MAINNET]],
[ChainId.ROPSTEN]: [WETH[ChainId.ROPSTEN]],
[ChainId.RINKEBY]: [WETH[ChainId.RINKEBY]],
[ChainId.GÖRLI]: [WETH[ChainId.GÖRLI]],
[ChainId.KOVAN]: [WETH[ChainId.KOVAN]],
[ChainId.MAINNET]: [WETH9[ChainId.MAINNET]],
[ChainId.ROPSTEN]: [WETH9[ChainId.ROPSTEN]],
[ChainId.RINKEBY]: [WETH9[ChainId.RINKEBY]],
[ChainId.GÖRLI]: [WETH9[ChainId.GÖRLI]],
[ChainId.KOVAN]: [WETH9[ChainId.KOVAN]],
}
// used to construct intermediary pairs for trading
......@@ -71,7 +72,7 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
*/
export const CUSTOM_BASES: { [chainId in ChainId]?: { [tokenAddress: string]: Token[] } } = {
[ChainId.MAINNET]: {
[AMPL.address]: [DAI, WETH[ChainId.MAINNET]],
[AMPL.address]: [DAI, WETH9[ChainId.MAINNET]],
},
}
......@@ -186,8 +187,8 @@ export const BIG_INT_SECONDS_IN_WEEK = JSBI.BigInt(60 * 60 * 24 * 7)
export const BIG_INT_ZERO = JSBI.BigInt(0)
// one basis point
export const ONE_BIPS = new Percent(JSBI.BigInt(1), JSBI.BigInt(10000))
// one basis JSBI.BigInt
export const ONE_BIPS = new Percent(JSBI.BigInt(1), JSBI.BigInt(10))
export const BIPS_BASE = JSBI.BigInt(10000)
// used for warning states
export const ALLOWED_PRICE_IMPACT_LOW: Percent = new Percent(JSBI.BigInt(100), BIPS_BASE) // 1%
......@@ -211,4 +212,5 @@ export const BLOCKED_ADDRESSES: string[] = [
'0xd882cFc20F52f2599D84b8e8D58C7FB62cfE344b',
'0x901bb9583b24D97e995513C6778dc6888AB6870e',
'0xA7e5d5A720f06526557c513402f2e6B5fA20b008',
'0x8576aCC5C05D6Ce88f4e49bf65BdF0C62F91353C',
]
// used to mark unsupported tokens, these are hosted lists of unsupported tokens
/**
* @TODO add list from blockchain association
*/
export const UNSUPPORTED_LIST_URLS: string[] = []
const COMPOUND_LIST = 'https://raw.githubusercontent.com/compound-finance/token-list/master/compound.tokenlist.json'
const UMA_LIST = 'https://umaproject.org/uma.tokenlist.json'
......@@ -17,6 +13,9 @@ const CMC_ALL_LIST = 'defi.cmc.eth'
const CMC_STABLECOIN = 'stablecoin.cmc.eth'
const KLEROS_LIST = 't2crtokens.eth'
const GEMINI_LIST = 'https://www.gemini.com/uniswap/manifest.json'
const BA_LIST = 'https://raw.githubusercontent.com/The-Blockchain-Association/sec-notice-list/master/ba-sec-list.json'
export const UNSUPPORTED_LIST_URLS: string[] = [BA_LIST]
// lower index == higher priority for token import
export const DEFAULT_LIST_OF_LISTS: string[] = [
......
import { ChainId } from '@uniswap/sdk'
import { ChainId } from '@uniswap/sdk-core'
import MULTICALL_ABI from './abi.json'
const MULTICALL_NETWORKS: { [chainId in ChainId]: string } = {
......
import { Interface } from '@ethersproject/abi'
import { ChainId } from '@uniswap/sdk'
import { ChainId } from '@uniswap/sdk-core'
import V1_EXCHANGE_ABI from './v1_exchange.json'
import V1_FACTORY_ABI from './v1_factory.json'
......
import { ChainId } from '@uniswap/sdk'
import { ChainId } from '@uniswap/sdk-core'
export const NONFUNGIBLE_POSITION_MANAGER_ADDRESSES: { [chainId in ChainId | 1337]: string } = {
[ChainId.MAINNET]: '',
......
import { Token, TokenAmount } from '@uniswap/sdk'
import { Token, TokenAmount } from '@uniswap/sdk-core'
import { useMemo } from 'react'
import { useTokenContract } from '../hooks/useContract'
......
import { TokenAmount, Pair, Currency } from '@uniswap/sdk'
import { Pair } from '@uniswap/v2-sdk'
import { TokenAmount, Currency } from '@uniswap/sdk-core'
import { useMemo } from 'react'
import { abi as IUniswapV2PairABI } from '@uniswap/v2-core/build/IUniswapV2Pair.json'
import { Interface } from '@ethersproject/abi'
......
import { BigNumber } from '@ethersproject/bignumber'
import { Token, TokenAmount } from '@uniswap/sdk'
import { Token, TokenAmount } from '@uniswap/sdk-core'
import { useTokenContract } from '../hooks/useContract'
import { useSingleCallResult } from '../state/multicall/hooks'
......
......@@ -4,15 +4,14 @@ import {
Currency,
CurrencyAmount,
ETHER,
JSBI,
Pair,
Route,
Token,
TokenAmount,
Trade,
TradeType,
WETH,
} from '@uniswap/sdk'
WETH9,
ChainId,
} from '@uniswap/sdk-core'
import JSBI from 'jsbi'
import { Pair as V2Pair, Route as V2Route, Trade as V2Trade } from '@uniswap/v2-sdk'
import { useMemo } from 'react'
import { useActiveWeb3React } from '../hooks'
import { useAllTokens } from '../hooks/Tokens'
......@@ -20,6 +19,7 @@ import { useV1FactoryContract } from '../hooks/useContract'
import { Version } from '../hooks/useToggledVersion'
import { NEVER_RELOAD, useSingleCallResult, useSingleContractMultipleData } from '../state/multicall/hooks'
import { useETHBalances, useTokenBalance, useTokenBalances } from '../state/wallet/hooks'
import { supportedChainId } from 'utils'
export function useV1ExchangeAddress(tokenAddress?: string): string | undefined {
const contract = useV1FactoryContract()
......@@ -28,16 +28,16 @@ export function useV1ExchangeAddress(tokenAddress?: string): string | undefined
return useSingleCallResult(contract, 'getExchange', inputs)?.result?.[0]
}
export class MockV1Pair extends Pair {
export class MockV1Pair extends V2Pair {
constructor(etherAmount: BigintIsh, tokenAmount: TokenAmount) {
super(tokenAmount, new TokenAmount(WETH[tokenAmount.token.chainId], etherAmount))
super(tokenAmount, new TokenAmount(WETH9[tokenAmount.token.chainId as ChainId], etherAmount))
}
}
function useMockV1Pair(inputCurrency?: Currency): MockV1Pair | undefined {
const token = inputCurrency instanceof Token ? inputCurrency : undefined
const isWETH = Boolean(token && token.equals(WETH[token.chainId]))
const chainId: ChainId | undefined = token && supportedChainId(token.chainId)
const isWETH = Boolean(token && chainId && token.equals(WETH9[chainId]))
const v1PairAddress = useV1ExchangeAddress(isWETH ? undefined : token?.address)
const tokenBalance = useTokenBalance(v1PairAddress, token)
const ETHBalance = useETHBalances([v1PairAddress])[v1PairAddress ?? '']
......@@ -101,7 +101,7 @@ export function useV1Trade(
inputCurrency?: Currency,
outputCurrency?: Currency,
exactAmount?: CurrencyAmount
): Trade | undefined {
): V2Trade | undefined {
// get the mock v1 pairs
const inputPair = useMockV1Pair(inputCurrency)
const outputPair = useMockV1Pair(outputCurrency)
......@@ -110,7 +110,7 @@ export function useV1Trade(
const outputIsETH = outputCurrency === ETHER
// construct a direct or through ETH v1 route
let pairs: Pair[] = []
let pairs: V2Pair[] = []
if (inputIsETH && outputPair) {
pairs = [outputPair]
} else if (outputIsETH && inputPair) {
......@@ -121,12 +121,12 @@ export function useV1Trade(
pairs = [inputPair, outputPair]
}
const route = inputCurrency && pairs && pairs.length > 0 && new Route(pairs, inputCurrency, outputCurrency)
let v1Trade: Trade | undefined
const route = inputCurrency && pairs && pairs.length > 0 && new V2Route(pairs, inputCurrency, outputCurrency)
let v1Trade: V2Trade | undefined
try {
v1Trade =
route && exactAmount
? new Trade(route, exactAmount, isExactIn ? TradeType.EXACT_INPUT : TradeType.EXACT_OUTPUT)
? new V2Trade(route, exactAmount, isExactIn ? TradeType.EXACT_INPUT : TradeType.EXACT_OUTPUT)
: undefined
} catch (error) {
console.debug('Failed to create V1 trade', error)
......@@ -134,7 +134,7 @@ export function useV1Trade(
return v1Trade
}
export function getTradeVersion(trade?: Trade): Version | undefined {
export function getTradeVersion(trade?: V2Trade): Version | undefined {
const isV1 = trade?.route?.pairs?.some((pair) => pair instanceof MockV1Pair)
if (isV1) return Version.v1
if (isV1 === false) return Version.v2
......@@ -142,7 +142,7 @@ export function getTradeVersion(trade?: Trade): Version | undefined {
}
// returns the v1 exchange against which a trade should be executed
export function useV1TradeExchangeAddress(trade: Trade | undefined): string | undefined {
export function useV1TradeExchangeAddress(trade: V2Trade | undefined): string | undefined {
const tokenAddress: string | undefined = useMemo(() => {
if (!trade) return undefined
const isV1 = getTradeVersion(trade) === Version.v1
......
import { TokenAddressMap, useDefaultTokenList, useUnsupportedTokenList } from './../state/lists/hooks'
import { parseBytes32String } from '@ethersproject/strings'
import { Currency, ETHER, Token, currencyEquals } from '@uniswap/sdk'
import { Currency, ETHER, Token, currencyEquals } from '@uniswap/sdk-core'
import { useMemo } from 'react'
import { useCombinedActiveList, useCombinedInactiveList } from '../state/lists/hooks'
import { NEVER_RELOAD, useSingleCallResult } from '../state/multicall/hooks'
......
import { isTradeBetter } from 'utils/trades'
import { Currency, CurrencyAmount, Pair, Token, Trade } from '@uniswap/sdk'
import { Pair, Trade } from '@uniswap/v2-sdk'
import { Currency, CurrencyAmount, Token } from '@uniswap/sdk-core'
import flatMap from 'lodash.flatmap'
import { useMemo } from 'react'
......@@ -150,18 +151,18 @@ export function useTradeExactOut(currencyIn?: Currency, currencyAmountOut?: Curr
}
export function useIsTransactionUnsupported(currencyIn?: Currency, currencyOut?: Currency): boolean {
const unsupportedToken: { [address: string]: Token } = useUnsupportedTokens()
const unsupportedTokens: { [address: string]: Token } = useUnsupportedTokens()
const { chainId } = useActiveWeb3React()
const tokenIn = wrappedCurrency(currencyIn, chainId)
const tokenOut = wrappedCurrency(currencyOut, chainId)
// if unsupported list loaded & either token on list, mark as unsupported
if (unsupportedToken) {
if (tokenIn && Object.keys(unsupportedToken).includes(tokenIn.address)) {
if (unsupportedTokens) {
if (tokenIn && Object.keys(unsupportedTokens).includes(tokenIn.address)) {
return true
}
if (tokenOut && Object.keys(unsupportedToken).includes(tokenOut.address)) {
if (tokenOut && Object.keys(unsupportedTokens).includes(tokenOut.address)) {
return true
}
}
......
import { Web3Provider } from '@ethersproject/providers'
import { ChainId } from '@uniswap/sdk'
import { ChainId } from '@uniswap/sdk-core'
import { useWeb3React as useWeb3ReactCore } from '@web3-react/core'
import { Web3ReactContextInterface } from '@web3-react/core/dist/types'
import { useEffect, useState } from 'react'
......
import { getTokenLogoURL } from './../components/CurrencyLogo/index'
import { wrappedCurrency } from 'utils/wrappedCurrency'
import { Currency, Token } from '@uniswap/sdk'
import { Currency, Token } from '@uniswap/sdk-core'
import { useCallback, useState } from 'react'
import { useActiveWeb3React } from 'hooks'
......
import { MaxUint256 } from '@ethersproject/constants'
import { TransactionResponse } from '@ethersproject/providers'
import { Trade, TokenAmount, CurrencyAmount, ETHER } from '@uniswap/sdk'
import { TokenAmount, CurrencyAmount, ETHER } from '@uniswap/sdk-core'
import { Trade } from '@uniswap/v2-sdk'
import { useCallback, useMemo } from 'react'
import { ROUTER_ADDRESS } from '../constants'
import { useTokenAllowance } from '../data/Allowances'
......
......@@ -2,7 +2,7 @@ import { useState, useLayoutEffect } from 'react'
import { shade } from 'polished'
import Vibrant from 'node-vibrant'
import { hex } from 'wcag-contrast'
import { Token, ChainId } from '@uniswap/sdk'
import { Token, ChainId } from '@uniswap/sdk-core'
import uriToHttp from 'utils/uriToHttp'
async function getColorFromToken(token: Token): Promise<string | null> {
......
......@@ -3,7 +3,7 @@ import { abi as GOVERNANCE_ABI } from '@uniswap/governance/build/GovernorAlpha.j
import { abi as UNI_ABI } from '@uniswap/governance/build/Uni.json'
import { abi as STAKING_REWARDS_ABI } from '@uniswap/liquidity-staker/build/StakingRewards.json'
import { abi as MERKLE_DISTRIBUTOR_ABI } from '@uniswap/merkle-distributor/build/MerkleDistributor.json'
import { ChainId, WETH } from '@uniswap/sdk'
import { ChainId, WETH9 } from '@uniswap/sdk-core'
import { abi as IUniswapV2PairABI } from '@uniswap/v2-core/build/IUniswapV2Pair.json'
import { abi as NFTPositionManagerABI } from '@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json'
import { NONFUNGIBLE_POSITION_MANAGER_ADDRESSES } from 'constants/v3'
......@@ -60,7 +60,7 @@ export function useTokenContract(tokenAddress?: string, withSignerIfPossible?: b
export function useWETHContract(withSignerIfPossible?: boolean): Contract | null {
const { chainId } = useActiveWeb3React()
return useContract(chainId ? WETH[chainId].address : undefined, WETH_ABI, withSignerIfPossible)
return useContract(chainId ? WETH9[chainId].address : undefined, WETH_ABI, withSignerIfPossible)
}
export function useArgentWalletDetectorContract(): Contract | null {
......
import { nanoid } from '@reduxjs/toolkit'
import { ChainId } from '@uniswap/sdk'
import { ChainId } from '@uniswap/sdk-core'
import { TokenList } from '@uniswap/token-lists'
import { useCallback } from 'react'
import { useDispatch } from 'react-redux'
......
import { JSBI } from '@uniswap/sdk'
import { JSBI } from '@uniswap/v2-sdk'
import { useMemo } from 'react'
import { NEVER_RELOAD, useSingleCallResult } from '../state/multicall/hooks'
import { useActiveWeb3React } from './index'
......
import { BigNumber } from '@ethersproject/bignumber'
import { Contract } from '@ethersproject/contracts'
import { JSBI, Percent, Router, SwapParameters, Trade, TradeType } from '@uniswap/sdk'
import { JSBI, Router, SwapParameters, Trade } from '@uniswap/v2-sdk'
import { Percent, TradeType } from '@uniswap/sdk-core'
import { useMemo } from 'react'
import { BIPS_BASE, INITIAL_ALLOWED_SLIPPAGE } from '../constants'
import { getTradeVersion, useV1TradeExchangeAddress } from '../data/V1'
......
import { Currency, currencyEquals, ETHER, WETH } from '@uniswap/sdk'
import { Currency, currencyEquals, ETHER, WETH9 } from '@uniswap/sdk-core'
import { useMemo } from 'react'
import { tryParseAmount } from '../state/swap/hooks'
import { useTransactionAdder } from '../state/transactions/hooks'
......@@ -36,7 +36,7 @@ export default function useWrapCallback(
const sufficientBalance = inputAmount && balance && !balance.lessThan(inputAmount)
if (inputCurrency === ETHER && currencyEquals(WETH[chainId], outputCurrency)) {
if (inputCurrency === ETHER && currencyEquals(WETH9[chainId], outputCurrency)) {
return {
wrapType: WrapType.WRAP,
execute:
......@@ -52,7 +52,7 @@ export default function useWrapCallback(
: undefined,
inputError: sufficientBalance ? undefined : 'Insufficient ETH balance',
}
} else if (currencyEquals(WETH[chainId], inputCurrency) && outputCurrency === ETHER) {
} else if (currencyEquals(WETH9[chainId], inputCurrency) && outputCurrency === ETHER) {
return {
wrapType: WrapType.UNWRAP,
execute:
......
import { Currency, CurrencyAmount, Fraction, Percent } from '@uniswap/sdk-core'
import React from 'react'
import { Text } from 'rebass'
import { ButtonPrimary } from '../../components/Button'
import { RowBetween, RowFixed } from '../../components/Row'
import CurrencyLogo from '../../components/CurrencyLogo'
import { Field } from '../../state/mint/actions'
import { TYPE } from '../../theme'
export function ConfirmAddModalBottom({
noLiquidity,
price,
currencies,
parsedAmounts,
poolTokenPercentage,
onAdd,
}: {
noLiquidity?: boolean
price?: Fraction
currencies: { [field in Field]?: Currency }
parsedAmounts: { [field in Field]?: CurrencyAmount }
poolTokenPercentage?: Percent
onAdd: () => void
}) {
return (
<>
<RowBetween>
<TYPE.body>{currencies[Field.CURRENCY_A]?.symbol} Deposited</TYPE.body>
<RowFixed>
<CurrencyLogo currency={currencies[Field.CURRENCY_A]} style={{ marginRight: '8px' }} />
<TYPE.body>{parsedAmounts[Field.CURRENCY_A]?.toSignificant(6)}</TYPE.body>
</RowFixed>
</RowBetween>
<RowBetween>
<TYPE.body>{currencies[Field.CURRENCY_B]?.symbol} Deposited</TYPE.body>
<RowFixed>
<CurrencyLogo currency={currencies[Field.CURRENCY_B]} style={{ marginRight: '8px' }} />
<TYPE.body>{parsedAmounts[Field.CURRENCY_B]?.toSignificant(6)}</TYPE.body>
</RowFixed>
</RowBetween>
<RowBetween>
<TYPE.body>Rates</TYPE.body>
<TYPE.body>
{`1 ${currencies[Field.CURRENCY_A]?.symbol} = ${price?.toSignificant(4)} ${
currencies[Field.CURRENCY_B]?.symbol
}`}
</TYPE.body>
</RowBetween>
<RowBetween style={{ justifyContent: 'flex-end' }}>
<TYPE.body>
{`1 ${currencies[Field.CURRENCY_B]?.symbol} = ${price?.invert().toSignificant(4)} ${
currencies[Field.CURRENCY_A]?.symbol
}`}
</TYPE.body>
</RowBetween>
<RowBetween>
<TYPE.body>Share of Pool:</TYPE.body>
<TYPE.body>{noLiquidity ? '100' : poolTokenPercentage?.toSignificant(4)}%</TYPE.body>
</RowBetween>
<ButtonPrimary style={{ margin: '20px 0 0 0' }} onClick={onAdd}>
<Text fontWeight={500} fontSize={20}>
{noLiquidity ? 'Create Pool & Supply' : 'Confirm Supply'}
</Text>
</ButtonPrimary>
</>
)
}
import { Currency, CurrencyAmount, Fraction, Percent } from '@uniswap/sdk'
import React, { useState } from 'react'
import { ButtonPrimary } from '../../components/Button'
import { RowBetween, RowFixed } from '../../components/Row'
......@@ -13,6 +12,7 @@ import useTheme from 'hooks/useTheme'
import { AlertOctagon } from 'react-feather'
import { ToggleWrapper, ToggleElement } from 'components/Toggle/MultiToggle'
import { useTranslation } from 'react-i18next'
import { Price, Percent, Currency, CurrencyAmount } from '@uniswap/sdk-core'
const Wrapper = styled(AutoColumn)`
padding: 1rem 0;
......@@ -24,7 +24,7 @@ export function ConfirmContent({
onAdd,
}: {
noLiquidity?: boolean
price?: Fraction
price?: Price
currencies: { [field in Field]?: Currency }
parsedAmounts: { [field in Field]?: CurrencyAmount }
poolTokenPercentage?: Percent
......
import { Currency, Percent, Price } from '@uniswap/sdk'
import { Currency, Percent, Price } from '@uniswap/sdk-core'
import React, { useContext } from 'react'
import { Text } from 'rebass'
import { ThemeContext } from 'styled-components'
......
import { BigNumber } from '@ethersproject/bignumber'
import { TransactionResponse } from '@ethersproject/providers'
import { Currency, ETHER, TokenAmount } from '@uniswap/sdk'
import { Currency, ETHER, TokenAmount } from '@uniswap/sdk-core'
import React, { useCallback, useContext, useState } from 'react'
import { Link2, AlertTriangle, LifeBuoy, Circle } from 'react-feather'
import ReactGA from 'react-ga'
......@@ -64,8 +64,8 @@ export default function AddLiquidity({
// const oneCurrencyIsWETH = Boolean(
// chainId &&
// ((currencyA && currencyEquals(currencyA, WETH[chainId])) ||
// (currencyB && currencyEquals(currencyB, WETH[chainId])))
// ((currencyA && currencyEquals(currencyA, WETH9[chainId])) ||
// (currencyB && currencyEquals(currencyB, WETH9[chainId])))
// )
const toggleWalletModal = useWalletModalToggle() // toggle wallet when disconnected
......
......@@ -3,7 +3,8 @@ import { AutoColumn } from '../../components/Column'
import styled from 'styled-components'
import { Link } from 'react-router-dom'
import { JSBI, TokenAmount, ETHER } from '@uniswap/sdk'
import { TokenAmount, ETHER } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
import { RouteComponentProps } from 'react-router-dom'
import DoubleCurrencyLogo from '../../components/DoubleLogo'
import { useCurrency } from '../../hooks/Tokens'
......
......@@ -9,7 +9,7 @@ import { CardSection, DataCard, CardNoise, CardBGImage } from '../../components/
import { Countdown } from './Countdown'
import Loader from '../../components/Loader'
import { useActiveWeb3React } from '../../hooks'
import { JSBI } from '@uniswap/sdk'
import { JSBI } from '@uniswap/v2-sdk'
import { BIG_INT_ZERO } from '../../constants'
import { OutlineCard } from '../../components/Card'
......
import { TransactionResponse } from '@ethersproject/abstract-provider'
import { AddressZero } from '@ethersproject/constants'
import { Currency, CurrencyAmount, Fraction, JSBI, Percent, Token, TokenAmount, WETH } from '@uniswap/sdk'
import { Currency, CurrencyAmount, Fraction, Percent, Token, TokenAmount, WETH9 } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
import React, { useCallback, useMemo, useState } from 'react'
import ReactGA from 'react-ga'
import { Redirect, RouteComponentProps } from 'react-router'
......@@ -55,14 +56,14 @@ export function V1LiquidityInfo({
<div style={{ marginLeft: '.75rem' }}>
<TYPE.mediumHeader>
{<FormattedCurrencyAmount currencyAmount={liquidityTokenAmount} />}{' '}
{chainId && token.equals(WETH[chainId]) ? 'WETH' : token.symbol}/ETH
{chainId && token.equals(WETH9[chainId]) ? 'WETH' : token.symbol}/ETH
</TYPE.mediumHeader>
</div>
</AutoRow>
<RowBetween my="1rem">
<Text fontSize={16} fontWeight={500}>
Pooled {chainId && token.equals(WETH[chainId]) ? 'WETH' : token.symbol}:
Pooled {chainId && token.equals(WETH9[chainId]) ? 'WETH' : token.symbol}:
</Text>
<RowFixed>
<Text fontSize={16} fontWeight={500} marginLeft={'6px'}>
......@@ -92,10 +93,10 @@ function V1PairMigration({ liquidityTokenAmount, token }: { liquidityTokenAmount
const exchangeETHBalance = useETHBalances([liquidityTokenAmount.token.address])?.[liquidityTokenAmount.token.address]
const exchangeTokenBalance = useTokenBalance(liquidityTokenAmount.token.address, token)
const [v2PairState, v2Pair] = usePair(chainId ? WETH[chainId] : undefined, token)
const [v2PairState, v2Pair] = usePair(chainId ? WETH9[chainId] : undefined, token)
const isFirstLiquidityProvider: boolean = v2PairState === PairState.NOT_EXISTS
const v2SpotPrice = chainId && v2Pair ? v2Pair.reserveOf(token).divide(v2Pair.reserveOf(WETH[chainId])) : undefined
const v2SpotPrice = chainId && v2Pair ? v2Pair.reserveOf(token).divide(v2Pair.reserveOf(WETH9[chainId])) : undefined
const [confirmingMigration, setConfirmingMigration] = useState<boolean>(false)
const [pendingMigrationHash, setPendingMigrationHash] = useState<string | null>(null)
......@@ -344,7 +345,7 @@ export default function MigrateV1Exchange({
{!account ? (
<TYPE.largeHeader>You must connect an account.</TYPE.largeHeader>
) : validatedAddress && chainId && token?.equals(WETH[chainId]) ? (
) : validatedAddress && chainId && token?.equals(WETH9[chainId]) ? (
<>
<TYPE.body my={9} style={{ fontWeight: 400 }}>
Because Uniswap V2 uses WETH under the hood, your Uniswap V1 WETH/ETH liquidity cannot be migrated. You
......
import { TransactionResponse } from '@ethersproject/abstract-provider'
import { JSBI, Token, TokenAmount, WETH, Fraction, Percent, CurrencyAmount } from '@uniswap/sdk'
import { Token, TokenAmount, WETH9, Fraction, Percent, CurrencyAmount } from '@uniswap/sdk-core'
import JSBI from 'jsbi'
import React, { useCallback, useMemo, useState } from 'react'
import ReactGA from 'react-ga'
import { Redirect, RouteComponentProps } from 'react-router'
......@@ -79,7 +80,7 @@ function V1PairRemoval({
})
addTransaction(response, {
summary: `Remove ${chainId && token.equals(WETH[chainId]) ? 'WETH' : token.symbol}/ETH V1 liquidity`,
summary: `Remove ${chainId && token.equals(WETH9[chainId]) ? 'WETH' : token.symbol}/ETH V1 liquidity`,
})
setPendingRemovalHash(response.hash)
})
......@@ -119,7 +120,7 @@ function V1PairRemoval({
</LightCard>
<TYPE.darkGray style={{ textAlign: 'center' }}>
{`Your Uniswap V1 ${
chainId && token.equals(WETH[chainId]) ? 'WETH' : token.symbol
chainId && token.equals(WETH9[chainId]) ? 'WETH' : token.symbol
}/ETH liquidity will be redeemed for underlying assets.`}
</TYPE.darkGray>
</AutoColumn>
......
import { JSBI, Token } from '@uniswap/sdk'
import { Token } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
import React, { useCallback, useContext, useMemo, useState, useEffect } from 'react'
import { ThemeContext } from 'styled-components'
import { AutoColumn } from '../../components/Column'
......
......@@ -10,9 +10,9 @@ import { useV3Positions } from 'hooks/useV3PositionManager'
import React, { useContext, useMemo } from 'react'
import { BookOpen, ChevronDown, Download, Inbox, Info, PlusCircle } from 'react-feather'
import { useTranslation } from 'react-i18next'
import styled, { ThemeContext } from 'styled-components'
import { Link } from 'react-router-dom'
import { useWalletModalToggle } from 'state/application/hooks'
import styled, { ThemeContext } from 'styled-components'
import { HideSmall, MEDIA_WIDTHS, TYPE } from 'theme'
const PageWrapper = styled(AutoColumn)`
......
import React, { useContext, useMemo } from 'react'
import styled, { ThemeContext } from 'styled-components'
import { Pair, JSBI } from '@uniswap/sdk'
import JSBI from 'jsbi'
import { Link } from 'react-router-dom'
import { SwapPoolTabs } from '../../components/NavigationTabs'
......@@ -21,6 +21,7 @@ import { Dots } from '../../components/swap/styleds'
import { CardSection, DataCard, CardNoise, CardBGImage } from '../../components/earn/styled'
import { useStakingInfo } from '../../state/stake/hooks'
import { BIG_INT_ZERO } from '../../constants'
import { Pair } from '@uniswap/v2-sdk'
const PageWrapper = styled(AutoColumn)`
max-width: 640px;
......
import { Currency, ETHER, JSBI, TokenAmount } from '@uniswap/sdk'
import { Currency, ETHER, TokenAmount } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
import React, { useCallback, useEffect, useState } from 'react'
import { Plus } from 'react-feather'
import { Text } from 'rebass'
......
import { splitSignature } from '@ethersproject/bytes'
import { Contract } from '@ethersproject/contracts'
import { TransactionResponse } from '@ethersproject/providers'
import { Currency, currencyEquals, ETHER, Percent, WETH } from '@uniswap/sdk'
import { Currency, currencyEquals, ETHER, Percent, WETH9 } from '@uniswap/sdk-core'
import React, { useCallback, useContext, useMemo, useState } from 'react'
import { ArrowDown, Plus } from 'react-feather'
import ReactGA from 'react-ga'
......@@ -432,8 +432,8 @@ export default function RemoveLiquidity({
const oneCurrencyIsETH = currencyA === ETHER || currencyB === ETHER
const oneCurrencyIsWETH = Boolean(
chainId &&
((currencyA && currencyEquals(WETH[chainId], currencyA)) ||
(currencyB && currencyEquals(WETH[chainId], currencyB)))
((currencyA && currencyEquals(WETH9[chainId], currencyA)) ||
(currencyB && currencyEquals(WETH9[chainId], currencyB)))
)
const handleSelectCurrencyA = useCallback(
......@@ -573,8 +573,8 @@ export default function RemoveLiquidity({
<RowBetween style={{ justifyContent: 'flex-end' }}>
{oneCurrencyIsETH ? (
<StyledInternalLink
to={`/remove/${currencyA === ETHER ? WETH[chainId].address : currencyIdA}/${
currencyB === ETHER ? WETH[chainId].address : currencyIdB
to={`/remove/${currencyA === ETHER ? WETH9[chainId].address : currencyIdA}/${
currencyB === ETHER ? WETH9[chainId].address : currencyIdB
}`}
>
Receive WETH
......@@ -582,8 +582,8 @@ export default function RemoveLiquidity({
) : oneCurrencyIsWETH ? (
<StyledInternalLink
to={`/remove/${
currencyA && currencyEquals(currencyA, WETH[chainId]) ? 'ETH' : currencyIdA
}/${currencyB && currencyEquals(currencyB, WETH[chainId]) ? 'ETH' : currencyIdB}`}
currencyA && currencyEquals(currencyA, WETH9[chainId]) ? 'ETH' : currencyIdA
}/${currencyB && currencyEquals(currencyB, WETH9[chainId]) ? 'ETH' : currencyIdB}`}
>
Receive ETH
</StyledInternalLink>
......
import { CurrencyAmount, JSBI, Token, Trade } from '@uniswap/sdk'
import { CurrencyAmount, Token } from '@uniswap/sdk-core'
import { JSBI, Trade } from '@uniswap/v2-sdk'
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react'
import { ArrowDown } from 'react-feather'
import ReactGA from 'react-ga'
......@@ -48,8 +49,9 @@ import Loader from '../../components/Loader'
import { useIsTransactionUnsupported } from 'hooks/Trades'
import UnsupportedCurrencyFooter from 'components/swap/UnsupportedCurrencyFooter'
import { isTradeBetter } from 'utils/trades'
import { RouteComponentProps } from 'react-router-dom'
export default function Swap() {
export default function Swap({ history }: RouteComponentProps) {
const loadedUrlParams = useDefaultsFromURLSearch()
// token warning stuff
......@@ -97,6 +99,7 @@ export default function Swap() {
currencies,
inputError: swapInputError,
} = useDerivedSwapInfo()
const { wrapType, execute: onWrap, inputError: wrapInputError } = useWrapCallback(
currencies[Field.INPUT],
currencies[Field.OUTPUT],
......@@ -142,6 +145,12 @@ export default function Swap() {
[onUserInput]
)
// reset if they close warning without tokens in params
const handleDismissTokenWarning = useCallback(() => {
setDismissTokenWarning(true)
history.push('/swap/')
}, [history])
// modal and loading
const [{ showConfirm, tradeToConfirm, swapErrorMessage, attemptingTxn, txHash }, setSwapState] = useState<{
showConfirm: boolean
......@@ -297,6 +306,7 @@ export default function Swap() {
isOpen={importTokensNotInDefault.length > 0 && !dismissTokenWarning}
tokens={importTokensNotInDefault}
onConfirm={handleConfirmTokenWarning}
onDismiss={handleDismissTokenWarning}
/>
<SwapPoolTabs active={'swap'} />
<AppBody>
......
......@@ -13,7 +13,8 @@ import { useProposalData, useUserVotesAsOfBlock, ProposalData, useUserDelegatee
import { DateTime } from 'luxon'
import ReactMarkdown from 'react-markdown'
import VoteModal from '../../components/vote/VoteModal'
import { TokenAmount, JSBI } from '@uniswap/sdk'
import { TokenAmount } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
import { useActiveWeb3React } from '../../hooks'
import { AVERAGE_BLOCK_TIME_IN_SECS, COMMON_CONTRACT_NAMES, UNI, ZERO_ADDRESS } from '../../constants'
import { isAddress, getEtherscanLink } from '../../utils'
......
......@@ -14,7 +14,8 @@ import DelegateModal from '../../components/vote/DelegateModal'
import { useTokenBalance } from '../../state/wallet/hooks'
import { useActiveWeb3React } from '../../hooks'
import { UNI, ZERO_ADDRESS } from '../../constants'
import { JSBI, TokenAmount, ChainId } from '@uniswap/sdk'
import { TokenAmount, ChainId } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
import { shortenAddress, getEtherscanLink } from '../../utils'
import Loader from '../../components/Loader'
import FormattedCurrencyAmount from '../../components/FormattedCurrencyAmount'
......
import { ChainId } from '@uniswap/sdk'
import { ChainId } from '@uniswap/sdk-core'
import { createStore, Store } from 'redux'
import { addPopup, ApplicationModal, removePopup, setOpenModal, updateBlockNumber } from './actions'
import reducer, { ApplicationState } from './reducer'
......
import { Currency, CurrencyAmount, JSBI, Pair, Percent, TokenAmount } from '@uniswap/sdk'
import { Currency, CurrencyAmount, Percent, TokenAmount } from '@uniswap/sdk-core'
import { JSBI, Pair } from '@uniswap/v2-sdk'
import { useCallback } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { usePair } from '../../data/Reserves'
......
import { UNI } from './../../constants/index'
import { TokenAmount, JSBI, ChainId } from '@uniswap/sdk'
import { JSBI } from '@uniswap/v2-sdk'
import { TokenAmount, ChainId } from '@uniswap/sdk-core'
import { TransactionResponse } from '@ethersproject/providers'
import { useEffect, useState } from 'react'
import { useActiveWeb3React } from '../../hooks'
......
import { UNI, PRELOADED_PROPOSALS } from './../../constants/index'
import { TokenAmount } from '@uniswap/sdk'
import { TokenAmount } from '@uniswap/sdk-core'
import { isAddress } from 'ethers/lib/utils'
import { useGovernanceContract, useUniContract } from '../../hooks/useContract'
import { useSingleCallResult, useSingleContractMultipleData } from '../multicall/hooks'
......
import { UNSUPPORTED_LIST_URLS } from './../../constants/lists'
import DEFAULT_TOKEN_LIST from '@uniswap/default-token-list'
import { ChainId, Token } from '@uniswap/sdk'
import { ChainId, Token } from '@uniswap/sdk-core'
import { Tags, TokenInfo, TokenList } from '@uniswap/token-lists'
import { useMemo } from 'react'
import { useSelector } from 'react-redux'
......@@ -30,7 +30,7 @@ export class WrappedTokenInfo extends Token {
}
export type TokenAddressMap = Readonly<
{ [chainId in ChainId | 1337]: Readonly<{ [tokenAddress: string]: { token: WrappedTokenInfo; list: TokenList } }> }
{ [chainId in ChainId | number]: Readonly<{ [tokenAddress: string]: { token: WrappedTokenInfo; list: TokenList } }> }
>
/**
......@@ -62,11 +62,12 @@ export function listToTokenMap(list: TokenList): TokenAddressMap {
})
?.filter((x): x is TagInfo => Boolean(x)) ?? []
const token = new WrappedTokenInfo(tokenInfo, tags)
if (tokenMap[token.chainId][token.address] !== undefined) throw Error('Duplicate tokens.')
return {
...tokenMap,
[token.chainId]: {
...tokenMap[token.chainId],
...tokenMap[token.chainId as ChainId],
[token.address]: {
token,
list: list,
......
import { DEFAULT_ACTIVE_LIST_URLS } from './../../constants/lists'
import { DEFAULT_ACTIVE_LIST_URLS, UNSUPPORTED_LIST_URLS } from './../../constants/lists'
import { createReducer } from '@reduxjs/toolkit'
import { getVersionUpgrade, VersionUpgrade } from '@uniswap/token-lists'
import { TokenList } from '@uniswap/token-lists/dist/types'
......@@ -36,7 +36,7 @@ type Mutable<T> = { -readonly [P in keyof T]: T[P] extends ReadonlyArray<infer U
const initialState: ListsState = {
lastInitializedDefaultListOfLists: DEFAULT_LIST_OF_LISTS,
byUrl: {
...DEFAULT_LIST_OF_LISTS.reduce<Mutable<ListsState['byUrl']>>((memo, listUrl) => {
...DEFAULT_LIST_OF_LISTS.concat(...UNSUPPORTED_LIST_URLS).reduce<Mutable<ListsState['byUrl']>>((memo, listUrl) => {
memo[listUrl] = NEW_LIST_STATE
return memo
}, {}),
......
......@@ -10,6 +10,7 @@ import { AppDispatch } from '../index'
import { acceptListUpdate } from './actions'
import { useActiveListUrls } from './hooks'
import { useAllInactiveTokens } from 'hooks/Tokens'
import { UNSUPPORTED_LIST_URLS } from 'constants/lists'
export default function Updater(): null {
const { library } = useActiveWeb3React()
......@@ -44,6 +45,16 @@ export default function Updater(): null {
})
}, [dispatch, fetchList, library, lists])
// if any lists from unsupported lists are loaded, check them too (in case new updates since last visit)
useEffect(() => {
Object.keys(UNSUPPORTED_LIST_URLS).forEach((listUrl) => {
const list = lists[listUrl]
if (!list || (!list.current && !list.loadingRequestId && !list.error)) {
fetchList(listUrl).catch((error) => console.debug('list added fetching error', error))
}
})
}, [dispatch, fetchList, library, lists])
// automatically update lists if versions are minor/patch
useEffect(() => {
Object.keys(lists).forEach((listUrl) => {
......
import { Currency, CurrencyAmount, ETHER, JSBI, Pair, Percent, Price, TokenAmount } from '@uniswap/sdk'
import { Currency, CurrencyAmount, ETHER, Percent, Price, TokenAmount } from '@uniswap/sdk-core'
import { JSBI, Pair } from '@uniswap/v2-sdk'
import { useCallback, useMemo } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { PairState, usePair } from '../../data/Reserves'
......
import { ChainId, CurrencyAmount, JSBI, Token, TokenAmount, WETH, Pair } from '@uniswap/sdk'
import { ChainId, CurrencyAmount, Token, TokenAmount, WETH9 } from '@uniswap/sdk-core'
import { Pair } from '@uniswap/v2-sdk'
import JSBI from 'jsbi'
import { useMemo } from 'react'
import { DAI, UNI, USDC, USDT, WBTC } from '../../constants'
import { STAKING_REWARDS_INTERFACE } from '../../constants/abis/staking-rewards'
......@@ -20,19 +22,19 @@ export const STAKING_REWARDS_INFO: {
} = {
[ChainId.MAINNET]: [
{
tokens: [WETH[ChainId.MAINNET], DAI],
tokens: [WETH9[ChainId.MAINNET], DAI],
stakingRewardAddress: '0xa1484C3aa22a66C62b77E0AE78E15258bd0cB711',
},
{
tokens: [WETH[ChainId.MAINNET], USDC],
tokens: [WETH9[ChainId.MAINNET], USDC],
stakingRewardAddress: '0x7FBa4B8Dc5E7616e59622806932DBea72537A56b',
},
{
tokens: [WETH[ChainId.MAINNET], USDT],
tokens: [WETH9[ChainId.MAINNET], USDT],
stakingRewardAddress: '0x6C3e4cb2E96B01F4b866965A91ed4437839A121a',
},
{
tokens: [WETH[ChainId.MAINNET], WBTC],
tokens: [WETH9[ChainId.MAINNET], WBTC],
stakingRewardAddress: '0xCA35e32e7926b96A9988f61d510E038108d8068e',
},
],
......
import useENS from '../../hooks/useENS'
import { Version } from '../../hooks/useToggledVersion'
import { parseUnits } from '@ethersproject/units'
import { Currency, CurrencyAmount, ETHER, JSBI, Token, TokenAmount, Trade } from '@uniswap/sdk'
import { Currency, CurrencyAmount, ETHER, Token, TokenAmount } from '@uniswap/sdk-core'
import { JSBI, Trade } from '@uniswap/v2-sdk'
import { ParsedQs } from 'qs'
import { useCallback, useEffect, useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'
......
import { createAction } from '@reduxjs/toolkit'
import { ChainId } from '@uniswap/sdk'
import { ChainId } from '@uniswap/sdk-core'
export interface SerializableTransactionReceipt {
to: string
......
import { ChainId } from '@uniswap/sdk'
import { ChainId } from '@uniswap/sdk-core'
import { createStore, Store } from 'redux'
import { addTransaction, checkedTransaction, clearAllTransactions, finalizeTransaction } from './actions'
import reducer, { initialState, TransactionState } from './reducer'
......
import { ChainId, Pair, Token } from '@uniswap/sdk'
import { ChainId, Token } from '@uniswap/sdk-core'
import { Pair } from '@uniswap/v2-sdk'
import flatMap from 'lodash.flatmap'
import ReactGA from 'react-ga'
import { useCallback, useMemo } from 'react'
......
......@@ -111,11 +111,17 @@ export default createReducer(initialState, (builder) =>
state.userSingleHopOnly = action.payload.userSingleHopOnly
})
.addCase(addSerializedToken, (state, { payload: { serializedToken } }) => {
if (!state.tokens) {
state.tokens = {}
}
state.tokens[serializedToken.chainId] = state.tokens[serializedToken.chainId] || {}
state.tokens[serializedToken.chainId][serializedToken.address] = serializedToken
state.timestamp = currentTimestamp()
})
.addCase(removeSerializedToken, (state, { payload: { address, chainId } }) => {
if (!state.tokens) {
state.tokens = {}
}
state.tokens[chainId] = state.tokens[chainId] || {}
delete state.tokens[chainId][address]
state.timestamp = currentTimestamp()
......
import { UNI } from './../../constants/index'
import { Currency, CurrencyAmount, ETHER, JSBI, Token, TokenAmount } from '@uniswap/sdk'
import { Currency, CurrencyAmount, ETHER, Token, TokenAmount } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
import { useMemo } from 'react'
import ERC20_INTERFACE from '../../constants/abis/erc20'
import { useAllTokens } from '../../hooks/Tokens'
......
import { ChainId, JSBI, Token, TokenAmount } from '@uniswap/sdk'
import { ChainId, Token, TokenAmount } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
import { BigNumber } from 'ethers'
import { ZERO_ADDRESS } from '../constants'
import { computeUniCirculation } from './computeUniCirculation'
......
import { JSBI, Token, TokenAmount } from '@uniswap/sdk'
import { Token, TokenAmount } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
import { BigNumber } from 'ethers'
import { STAKING_GENESIS } from '../state/stake/hooks'
......
import { Currency, ETHER, Token } from '@uniswap/sdk'
import { Currency, ETHER, Token } from '@uniswap/sdk-core'
export function currencyId(currency: Currency): string {
if (currency === ETHER) return 'ETH'
......
import { BigNumber } from '@ethersproject/bignumber'
import { AddressZero } from '@ethersproject/constants'
import { TokenAmount, Token, ChainId, Percent, JSBI } from '@uniswap/sdk'
import { TokenAmount, Token, ChainId, Percent } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
import {
getEtherscanLink,
......
......@@ -5,7 +5,8 @@ import { JsonRpcSigner, Web3Provider } from '@ethersproject/providers'
import { BigNumber } from '@ethersproject/bignumber'
import { abi as IUniswapV2Router02ABI } from '@uniswap/v2-periphery/build/IUniswapV2Router02.json'
import { ROUTER_ADDRESS } from '../constants'
import { ChainId, JSBI, Percent, Token, CurrencyAmount, Currency, ETHER } from '@uniswap/sdk'
import { ChainId, Percent, Token, CurrencyAmount, Currency, ETHER } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
import { TokenAddressMap } from '../state/lists/hooks'
// returns the checksummed address if the address is valid, otherwise returns false
......@@ -108,5 +109,17 @@ export function escapeRegExp(string: string): string {
export function isTokenOnList(defaultTokens: TokenAddressMap, currency?: Currency): boolean {
if (currency === ETHER) return true
return Boolean(currency instanceof Token && defaultTokens[currency.chainId]?.[currency.address])
return Boolean(currency instanceof Token && defaultTokens[currency.chainId as ChainId]?.[currency.address])
}
/**
* Returns chain id if chain from chainId supports WETH
* if not, return undefined
* @param chainId
*/
export function supportedChainId(chainId: number): ChainId | undefined {
if (chainId in ChainId) {
return chainId
}
return undefined
}
import { CurrencyAmount, ETHER, JSBI } from '@uniswap/sdk'
import { CurrencyAmount, ETHER } from '@uniswap/sdk-core'
import { JSBI } from '@uniswap/v2-sdk'
import { MIN_ETH } from '../constants'
/**
......
import { ChainId, JSBI, Pair, Route, Token, TokenAmount, Trade, TradeType } from '@uniswap/sdk'
import { ChainId, Token, TokenAmount, TradeType } from '@uniswap/sdk-core'
import { JSBI, Trade, Pair, Route } from '@uniswap/v2-sdk'
import { computeTradePriceBreakdown } from './prices'
describe('prices', () => {
......
import { BLOCKED_PRICE_IMPACT_NON_EXPERT } from '../constants'
import { CurrencyAmount, Fraction, JSBI, Percent, TokenAmount, Trade } from '@uniswap/sdk'
import { CurrencyAmount, Fraction, Percent, TokenAmount } from '@uniswap/sdk-core'
import { JSBI, Trade } from '@uniswap/v2-sdk'
import { ALLOWED_PRICE_IMPACT_HIGH, ALLOWED_PRICE_IMPACT_LOW, ALLOWED_PRICE_IMPACT_MEDIUM } from '../constants'
import { Field } from '../state/swap/actions'
import { basisPointsToPercent } from './index'
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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