Commit 90f72e05 authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

feat: upgrade sdk-core to 3.2.6 and add AVAX (#6757)

* init refactor

* upgrade to 3.2.6 and refactor more uses of chainid

* cleaned up lock file

* remove console log and add placeholder

* use supported chains type for switch fn

* allow passing of all chainIds to switcher

* additional typecast

* better casting solution

* yarn.lock cleanup

* prettier

* better casting for rpc

* prettier

* deprecate no longer needed addresses

* better isSupported checking

* deprecate redundant fn

* cleanup toSupportedChainId

* address initial ocmments

* pretier

* includes testnet

* remove unused export

* merge conflicts

* spread for mutable copy

* explorer text

* check is supported before activating chain

* remove extra uses of mumbai

* remove cast to MockChainId

* retain var name supportedChainId

* updated prettier

* use t for explorer translation

* use mockchainid for test

* feat: Add Avalanche support (#6776)

* init avax

* add most avax props

* add logo

* correct subgraph

* update avax blocksPerFetch

* add square logo

* upgrade ur sdk

* version syntax

* correct tokens

* remove unused token

* remove unused token

* update token list and add coming soon to searchbar

* add coming soon to token explore page

* names to ids

* cleaned up routing

* usdc token

* upgrade default token list

* update SOR

* upgrade SOR

* merge conflicts

* snowtrace

* upgrade SOR

* handle be avax support

* temp hide avax

* show pool positions

* whole

* spotprice update

* not yet supported

* BACKEND_SUPPORTED_CHAINS

* add avax to BE not supported

* update multicall blocks to 5

* add todo

* updated prettier

---------
Co-authored-by: default avatarCharles Bachmeier <charlie@genie.xyz>

* be added avax token balances

* validateUrlChainParam should return eth for backend unsupported chain

* readonly

* respond to comments

---------
Co-authored-by: default avatarCharles Bachmeier <charlie@genie.xyz>
parent 3a0f6920
import { BigNumber } from '@ethersproject/bignumber' import { BigNumber } from '@ethersproject/bignumber'
import { SupportedChainId } from '@uniswap/sdk-core' import { ChainId } from '@uniswap/sdk-core'
import { DEFAULT_DEADLINE_FROM_NOW } from '../../../src/constants/misc' import { DEFAULT_DEADLINE_FROM_NOW } from '../../../src/constants/misc'
import { UNI, USDC_MAINNET } from '../../../src/constants/tokens' import { UNI, USDC_MAINNET } from '../../../src/constants/tokens'
import { getBalance, getTestSelector } from '../../utils' import { getBalance, getTestSelector } from '../../utils'
const UNI_MAINNET = UNI[SupportedChainId.MAINNET] const UNI_MAINNET = UNI[ChainId.MAINNET]
describe('Swap errors', () => { describe('Swap errors', () => {
it('wallet rejection', () => { it('wallet rejection', () => {
......
import { SupportedChainId } from '@uniswap/sdk-core' import { ChainId } from '@uniswap/sdk-core'
import { UNI, USDC_MAINNET } from '../../../src/constants/tokens' import { UNI, USDC_MAINNET } from '../../../src/constants/tokens'
import { getBalance, getTestSelector } from '../../utils' import { getBalance, getTestSelector } from '../../utils'
const UNI_MAINNET = UNI[SupportedChainId.MAINNET] const UNI_MAINNET = UNI[ChainId.MAINNET]
describe('Swap', () => { describe('Swap', () => {
describe('Swap on main page', () => { describe('Swap on main page', () => {
......
import { CurrencyAmount, SupportedChainId, WETH9 } from '@uniswap/sdk-core' import { ChainId, CurrencyAmount, WETH9 } from '@uniswap/sdk-core'
import { getBalance, getTestSelector } from '../../utils' import { getBalance, getTestSelector } from '../../utils'
const WETH = WETH9[SupportedChainId.MAINNET] const WETH = WETH9[ChainId.MAINNET]
describe('Swap wrap', () => { describe('Swap wrap', () => {
beforeEach(() => { beforeEach(() => {
......
import { SupportedChainId, WETH9 } from '@uniswap/sdk-core' import { ChainId, WETH9 } from '@uniswap/sdk-core'
import { ARB, UNI } from '../../src/constants/tokens' import { ARB, UNI } from '../../src/constants/tokens'
import { getTestSelector } from '../utils' import { getTestSelector } from '../utils'
const UNI_MAINNET = UNI[SupportedChainId.MAINNET] const UNI_MAINNET = UNI[ChainId.MAINNET]
const UNI_ADDRESS = '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984' const UNI_ADDRESS = '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984'
......
...@@ -3,11 +3,9 @@ ...@@ -3,11 +3,9 @@
*/ */
import { Eip1193Bridge } from '@ethersproject/experimental/lib/eip1193-bridge' import { Eip1193Bridge } from '@ethersproject/experimental/lib/eip1193-bridge'
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { JsonRpcProvider } from '@ethersproject/providers' import { JsonRpcProvider } from '@ethersproject/providers'
import { Wallet } from '@ethersproject/wallet' import { Wallet } from '@ethersproject/wallet'
import { ChainId } from '@uniswap/sdk-core'
import { SupportedChainId } from '../../src/constants/chains'
// todo: figure out how env vars actually work in CI // todo: figure out how env vars actually work in CI
// const TEST_PRIVATE_KEY = Cypress.env('INTEGRATION_TEST_PRIVATE_KEY') // const TEST_PRIVATE_KEY = Cypress.env('INTEGRATION_TEST_PRIVATE_KEY')
...@@ -15,7 +13,7 @@ const TEST_PRIVATE_KEY = '0xe580410d7c37d26c6ad1a837bbae46bc27f9066a466fb3a66e77 ...@@ -15,7 +13,7 @@ const TEST_PRIVATE_KEY = '0xe580410d7c37d26c6ad1a837bbae46bc27f9066a466fb3a66e77
// address of the above key // address of the above key
const TEST_ADDRESS_NEVER_USE = new Wallet(TEST_PRIVATE_KEY).address const TEST_ADDRESS_NEVER_USE = new Wallet(TEST_PRIVATE_KEY).address
const CHAIN_ID = SupportedChainId.GOERLI const CHAIN_ID = ChainId.GOERLI
const HEXLIFIED_CHAIN_ID = `0x${CHAIN_ID.toString(16)}` const HEXLIFIED_CHAIN_ID = `0x${CHAIN_ID.toString(16)}`
const provider = new JsonRpcProvider('https://goerli.infura.io/v3/4bf032f2d38a4ed6bb975b80d6340847', 5) const provider = new JsonRpcProvider('https://goerli.infura.io/v3/4bf032f2d38a4ed6bb975b80d6340847', 5)
......
import { SupportedChainId } from '@uniswap/sdk-core' import { ChainId } from '@uniswap/sdk-core'
/* eslint-env node */ /* eslint-env node */
require('dotenv').config() require('dotenv').config()
...@@ -16,12 +16,12 @@ const forkingConfig = { ...@@ -16,12 +16,12 @@ const forkingConfig = {
} }
const forks = { const forks = {
[SupportedChainId.MAINNET]: { [ChainId.MAINNET]: {
url: `https://mainnet.infura.io/v3/${process.env.REACT_APP_INFURA_KEY}`, url: `https://mainnet.infura.io/v3/${process.env.REACT_APP_INFURA_KEY}`,
blockNumber: BLOCK_NUMBER, blockNumber: BLOCK_NUMBER,
...forkingConfig, ...forkingConfig,
}, },
[SupportedChainId.POLYGON]: { [ChainId.POLYGON]: {
url: `https://polygon-mainnet.infura.io/v3/${process.env.REACT_APP_INFURA_KEY}`, url: `https://polygon-mainnet.infura.io/v3/${process.env.REACT_APP_INFURA_KEY}`,
blockNumber: POLYGON_BLOCK_NUMBER, blockNumber: POLYGON_BLOCK_NUMBER,
...forkingConfig, ...forkingConfig,
...@@ -32,8 +32,8 @@ module.exports = { ...@@ -32,8 +32,8 @@ module.exports = {
forks, forks,
networks: { networks: {
hardhat: { hardhat: {
chainId: SupportedChainId.MAINNET, chainId: ChainId.MAINNET,
forking: forks[SupportedChainId.MAINNET], forking: forks[ChainId.MAINNET],
accounts: { accounts: {
count: 2, count: 2,
}, },
......
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_13871_12533)">
<path d="M12.9341 2.74118H3.05524V11.7259H12.9341V2.74118Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.9947 8C15.9947 12.4154 12.4154 15.9947 7.99999 15.9947C3.58465 15.9947 0.00531006 12.4154 0.00531006 8C0.00531006 3.58466 3.58465 0.00532532 7.99999 0.00532532C12.4154 0.00532532 15.9947 3.58466 15.9947 8ZM5.73452 11.1815H4.18298C3.85696 11.1815 3.69591 11.1815 3.59772 11.1187C3.49166 11.0499 3.42685 10.936 3.41899 10.8103C3.4131 10.6945 3.49363 10.553 3.65467 10.2702L7.48562 3.51761C7.64864 3.23086 7.73112 3.08749 7.83521 3.03447C7.94715 2.97751 8.08071 2.97751 8.19266 3.03447C8.29675 3.08749 8.37924 3.23086 8.54224 3.51761L9.32981 4.89239L9.33382 4.89941C9.50989 5.20703 9.59917 5.36303 9.63815 5.52675C9.68135 5.70548 9.68135 5.89402 9.63815 6.07274C9.59887 6.23771 9.51049 6.39484 9.33177 6.70711L7.31946 10.2643L7.31426 10.2734C7.13703 10.5836 7.04722 10.7408 6.92274 10.8594C6.78722 10.989 6.62421 11.0832 6.44549 11.1363C6.28247 11.1815 6.09983 11.1815 5.73452 11.1815ZM9.65268 11.1815H11.8759C12.2038 11.1815 12.3689 11.1815 12.4671 11.1168C12.5731 11.048 12.6399 10.9321 12.6458 10.8064C12.6515 10.6943 12.5727 10.5584 12.4184 10.292C12.413 10.283 12.4077 10.2737 12.4023 10.2643L11.2887 8.35928L11.276 8.33783C11.1195 8.07321 11.0405 7.93958 10.9391 7.88793C10.8272 7.83096 10.6955 7.83096 10.5836 7.88793C10.4815 7.94095 10.399 8.0804 10.236 8.36124L9.12633 10.2663L9.12253 10.2729C8.96009 10.5533 8.87891 10.6934 8.88477 10.8084C8.89262 10.9341 8.95743 11.0499 9.06348 11.1187C9.15973 11.1815 9.3247 11.1815 9.65268 11.1815Z" fill="#E84142"/>
</g>
<defs>
<clipPath id="clip0_13871_12533">
<rect width="16" height="16" fill="white"/>
</clipPath>
</defs>
</svg>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_298_130193)">
<path d="M12.9346 2.74121H3.05566V11.7259H12.9346V2.74121Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.9998 0C15.9998 4.41538 15.9998 15.9947 15.9998 15.9947C11.5844 15.9947 0.00590861 15.9947 0.00590861 15.9947L0.00488281 5.43594e-05C4.42027 5.43594e-05 15.9998 0 15.9998 0ZM5.73493 11.1815H4.18339C3.85736 11.1815 3.69632 11.1815 3.59813 11.1187C3.49207 11.0499 3.42726 10.936 3.4194 10.8103C3.41351 10.6945 3.49404 10.553 3.65508 10.2702L7.48603 3.51765C7.64905 3.2309 7.73153 3.08753 7.83562 3.03451C7.94756 2.97755 8.08112 2.97755 8.19307 3.03451C8.29716 3.08753 8.37965 3.2309 8.54265 3.51765L9.33022 4.89243L9.33423 4.89945C9.51029 5.20707 9.59958 5.36307 9.63856 5.52679C9.68176 5.70552 9.68176 5.89406 9.63856 6.07278C9.59928 6.23775 9.5109 6.39488 9.33218 6.70715L7.31987 10.2643L7.31466 10.2734C7.13744 10.5836 7.04762 10.7408 6.92315 10.8594C6.78763 10.9891 6.62462 11.0833 6.44589 11.1364C6.28288 11.1815 6.10024 11.1815 5.73493 11.1815ZM9.65309 11.1815H11.8763C12.2043 11.1815 12.3693 11.1815 12.4675 11.1168C12.5735 11.048 12.6403 10.9321 12.6463 10.8065C12.6519 10.6944 12.5731 10.5584 12.4188 10.2921C12.4134 10.283 12.4081 10.2738 12.4027 10.2644L11.2891 8.35932L11.2764 8.33787C11.1199 8.07325 11.0409 7.93962 10.9395 7.88797C10.8276 7.831 10.6959 7.831 10.584 7.88797C10.4819 7.94099 10.3994 8.08044 10.2364 8.36128L9.12674 10.2663L9.12294 10.2729C8.9605 10.5533 8.87932 10.6934 8.88518 10.8084C8.89303 10.9341 8.95784 11.0499 9.06389 11.1187C9.16014 11.1815 9.32511 11.1815 9.65309 11.1815Z" fill="#E84142"/>
</g>
<defs>
<clipPath id="clip0_298_130193">
<rect width="16" height="16" fill="white"/>
</clipPath>
</defs>
</svg>
import { SupportedChainId, Token, TradeType as MockTradeType } from '@uniswap/sdk-core' import { ChainId, Token, TradeType as MockTradeType } from '@uniswap/sdk-core'
import { PERMIT2_ADDRESS } from '@uniswap/universal-router-sdk' import { PERMIT2_ADDRESS } from '@uniswap/universal-router-sdk'
import { DAI as MockDAI, nativeOnChain, USDC_MAINNET as MockUSDC_MAINNET, USDT as MockUSDT } from 'constants/tokens' import { DAI as MockDAI, nativeOnChain, USDC_MAINNET as MockUSDC_MAINNET, USDT as MockUSDT } from 'constants/tokens'
import { TransactionStatus as MockTxStatus } from 'graphql/data/__generated__/types-and-hooks' import { TransactionStatus as MockTxStatus } from 'graphql/data/__generated__/types-and-hooks'
...@@ -46,7 +46,7 @@ function mockSwapInfo( ...@@ -46,7 +46,7 @@ function mockSwapInfo(
const mockAccount1 = '0x000000000000000000000000000000000000000001' const mockAccount1 = '0x000000000000000000000000000000000000000001'
const mockAccount2 = '0x000000000000000000000000000000000000000002' const mockAccount2 = '0x000000000000000000000000000000000000000002'
const mockChainId = SupportedChainId.MAINNET const mockChainId = ChainId.MAINNET
const mockSpenderAddress = PERMIT2_ADDRESS[mockChainId] const mockSpenderAddress = PERMIT2_ADDRESS[mockChainId]
const mockCurrencyAmountRaw = '1000000000000000000' const mockCurrencyAmountRaw = '1000000000000000000'
const mockCurrencyAmountRawUSDC = '1000000' const mockCurrencyAmountRawUSDC = '1000000'
...@@ -246,7 +246,7 @@ describe('parseLocalActivity', () => { ...@@ -246,7 +246,7 @@ describe('parseLocalActivity', () => {
status: 1, status: 1,
}, },
} as TransactionDetails } as TransactionDetails
const chainId = SupportedChainId.MAINNET const chainId = ChainId.MAINNET
expect(parseLocalActivity(details, chainId, mockTokenAddressMap)).toEqual({ expect(parseLocalActivity(details, chainId, mockTokenAddressMap)).toEqual({
chainId: 1, chainId: 1,
currencies: [MockUSDC_MAINNET, MockDAI], currencies: [MockUSDC_MAINNET, MockDAI],
...@@ -287,7 +287,7 @@ describe('parseLocalActivity', () => { ...@@ -287,7 +287,7 @@ describe('parseLocalActivity', () => {
status: 1, status: 1,
}, },
} as TransactionDetails } as TransactionDetails
const chainId = SupportedChainId.MAINNET const chainId = ChainId.MAINNET
expect(parseLocalActivity(details, chainId, mockTokenAddressMap)).toMatchObject({ expect(parseLocalActivity(details, chainId, mockTokenAddressMap)).toMatchObject({
chainId: 1, chainId: 1,
currencies: [MockUSDC_MAINNET, MockDAI], currencies: [MockUSDC_MAINNET, MockDAI],
...@@ -311,7 +311,7 @@ describe('parseLocalActivity', () => { ...@@ -311,7 +311,7 @@ describe('parseLocalActivity', () => {
status: 1, status: 1,
}, },
} as TransactionDetails } as TransactionDetails
const chainId = SupportedChainId.MAINNET const chainId = ChainId.MAINNET
const tokens = {} as ChainTokenMap const tokens = {} as ChainTokenMap
expect(parseLocalActivity(details, chainId, tokens)).toMatchObject({ expect(parseLocalActivity(details, chainId, tokens)).toMatchObject({
chainId: 1, chainId: 1,
......
import { BigNumber } from '@ethersproject/bignumber' import { BigNumber } from '@ethersproject/bignumber'
import { t } from '@lingui/macro' import { t } from '@lingui/macro'
import { formatCurrencyAmount } from '@uniswap/conedison/format' import { formatCurrencyAmount } from '@uniswap/conedison/format'
import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core' import { ChainId, Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core'
import { nativeOnChain } from '@uniswap/smart-order-router' import { nativeOnChain } from '@uniswap/smart-order-router'
import { SupportedChainId } from 'constants/chains'
import { TransactionStatus } from 'graphql/data/__generated__/types-and-hooks' import { TransactionStatus } from 'graphql/data/__generated__/types-and-hooks'
import { ChainTokenMap, useAllTokensMultichain } from 'hooks/Tokens' import { ChainTokenMap, useAllTokensMultichain } from 'hooks/Tokens'
import { useMemo } from 'react' import { useMemo } from 'react'
...@@ -26,7 +25,7 @@ import { ...@@ -26,7 +25,7 @@ import {
import { getActivityTitle } from '../constants' import { getActivityTitle } from '../constants'
import { Activity, ActivityMap } from './types' import { Activity, ActivityMap } from './types'
function getCurrency(currencyId: string, chainId: SupportedChainId, tokens: ChainTokenMap): Currency | undefined { function getCurrency(currencyId: string, chainId: ChainId, tokens: ChainTokenMap): Currency | undefined {
return currencyId === 'ETH' ? nativeOnChain(chainId) : tokens[chainId]?.[currencyId] return currencyId === 'ETH' ? nativeOnChain(chainId) : tokens[chainId]?.[currencyId]
} }
...@@ -46,7 +45,7 @@ function buildCurrencyDescriptor( ...@@ -46,7 +45,7 @@ function buildCurrencyDescriptor(
function parseSwap( function parseSwap(
swap: ExactInputSwapTransactionInfo | ExactOutputSwapTransactionInfo, swap: ExactInputSwapTransactionInfo | ExactOutputSwapTransactionInfo,
chainId: SupportedChainId, chainId: ChainId,
tokens: ChainTokenMap tokens: ChainTokenMap
): Partial<Activity> { ): Partial<Activity> {
const tokenIn = getCurrency(swap.inputCurrencyId, chainId, tokens) const tokenIn = getCurrency(swap.inputCurrencyId, chainId, tokens)
...@@ -62,7 +61,7 @@ function parseSwap( ...@@ -62,7 +61,7 @@ function parseSwap(
} }
} }
function parseWrap(wrap: WrapTransactionInfo, chainId: SupportedChainId, status: TransactionStatus): Partial<Activity> { function parseWrap(wrap: WrapTransactionInfo, chainId: ChainId, status: TransactionStatus): Partial<Activity> {
const native = nativeOnChain(chainId) const native = nativeOnChain(chainId)
const wrapped = native.wrapped const wrapped = native.wrapped
const [input, output] = wrap.unwrapped ? [wrapped, native] : [native, wrapped] const [input, output] = wrap.unwrapped ? [wrapped, native] : [native, wrapped]
...@@ -76,7 +75,7 @@ function parseWrap(wrap: WrapTransactionInfo, chainId: SupportedChainId, status: ...@@ -76,7 +75,7 @@ function parseWrap(wrap: WrapTransactionInfo, chainId: SupportedChainId, status:
function parseApproval( function parseApproval(
approval: ApproveTransactionInfo, approval: ApproveTransactionInfo,
chainId: SupportedChainId, chainId: ChainId,
tokens: ChainTokenMap, tokens: ChainTokenMap,
status: TransactionStatus status: TransactionStatus
): Partial<Activity> { ): Partial<Activity> {
...@@ -97,7 +96,7 @@ type GenericLPInfo = Omit< ...@@ -97,7 +96,7 @@ type GenericLPInfo = Omit<
AddLiquidityV3PoolTransactionInfo | RemoveLiquidityV3TransactionInfo | AddLiquidityV2PoolTransactionInfo, AddLiquidityV3PoolTransactionInfo | RemoveLiquidityV3TransactionInfo | AddLiquidityV2PoolTransactionInfo,
'type' 'type'
> >
function parseLP(lp: GenericLPInfo, chainId: SupportedChainId, tokens: ChainTokenMap): Partial<Activity> { function parseLP(lp: GenericLPInfo, chainId: ChainId, tokens: ChainTokenMap): Partial<Activity> {
const baseCurrency = getCurrency(lp.baseCurrencyId, chainId, tokens) const baseCurrency = getCurrency(lp.baseCurrencyId, chainId, tokens)
const quoteCurrency = getCurrency(lp.quoteCurrencyId, chainId, tokens) const quoteCurrency = getCurrency(lp.quoteCurrencyId, chainId, tokens)
const [baseRaw, quoteRaw] = [lp.expectedAmountBaseRaw, lp.expectedAmountQuoteRaw] const [baseRaw, quoteRaw] = [lp.expectedAmountBaseRaw, lp.expectedAmountQuoteRaw]
...@@ -108,7 +107,7 @@ function parseLP(lp: GenericLPInfo, chainId: SupportedChainId, tokens: ChainToke ...@@ -108,7 +107,7 @@ function parseLP(lp: GenericLPInfo, chainId: SupportedChainId, tokens: ChainToke
function parseCollectFees( function parseCollectFees(
collect: CollectFeesTransactionInfo, collect: CollectFeesTransactionInfo,
chainId: SupportedChainId, chainId: ChainId,
tokens: ChainTokenMap tokens: ChainTokenMap
): Partial<Activity> { ): Partial<Activity> {
// Adapts CollectFeesTransactionInfo to generic LP type // Adapts CollectFeesTransactionInfo to generic LP type
...@@ -123,7 +122,7 @@ function parseCollectFees( ...@@ -123,7 +122,7 @@ function parseCollectFees(
function parseMigrateCreateV3( function parseMigrateCreateV3(
lp: MigrateV2LiquidityToV3TransactionInfo | CreateV3PoolTransactionInfo, lp: MigrateV2LiquidityToV3TransactionInfo | CreateV3PoolTransactionInfo,
chainId: SupportedChainId, chainId: ChainId,
tokens: ChainTokenMap tokens: ChainTokenMap
): Partial<Activity> { ): Partial<Activity> {
const baseCurrency = getCurrency(lp.baseCurrencyId, chainId, tokens) const baseCurrency = getCurrency(lp.baseCurrencyId, chainId, tokens)
...@@ -137,7 +136,7 @@ function parseMigrateCreateV3( ...@@ -137,7 +136,7 @@ function parseMigrateCreateV3(
export function parseLocalActivity( export function parseLocalActivity(
details: TransactionDetails, details: TransactionDetails,
chainId: SupportedChainId, chainId: ChainId,
tokens: ChainTokenMap tokens: ChainTokenMap
): Activity | undefined { ): Activity | undefined {
try { try {
......
import { t } from '@lingui/macro' import { t } from '@lingui/macro'
import { formatFiatPrice, formatNumberOrString, NumberType } from '@uniswap/conedison/format' import { formatFiatPrice, formatNumberOrString, NumberType } from '@uniswap/conedison/format'
import { SupportedChainId } from '@uniswap/sdk-core' import { ChainId, NONFUNGIBLE_POSITION_MANAGER_ADDRESSES, UNI_ADDRESSES } from '@uniswap/sdk-core'
import moonpayLogoSrc from 'assets/svg/moonpay.svg' import moonpayLogoSrc from 'assets/svg/moonpay.svg'
import { NONFUNGIBLE_POSITION_MANAGER_ADDRESSES, UNI_ADDRESS } from 'constants/addresses'
import { nativeOnChain } from 'constants/tokens' import { nativeOnChain } from 'constants/tokens'
import { import {
ActivityType, ActivityType,
...@@ -38,7 +37,7 @@ const ENS_IMG = ...@@ -38,7 +37,7 @@ const ENS_IMG =
'https://464911102-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/collections%2F2TjMAeHSzwlQgcOdL48E%2Ficon%2FKWP0gk2C6bdRPliWIA6o%2Fens%20transparent%20background.png?alt=media&token=bd28b063-5a75-4971-890c-97becea09076' 'https://464911102-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/collections%2F2TjMAeHSzwlQgcOdL48E%2Ficon%2FKWP0gk2C6bdRPliWIA6o%2Fens%20transparent%20background.png?alt=media&token=bd28b063-5a75-4971-890c-97becea09076'
const COMMON_CONTRACTS: { [key: string]: Partial<Activity> | undefined } = { const COMMON_CONTRACTS: { [key: string]: Partial<Activity> | undefined } = {
[UNI_ADDRESS[SupportedChainId.MAINNET].toLowerCase()]: { [UNI_ADDRESSES[ChainId.MAINNET].toLowerCase()]: {
title: t`UNI Governance`, title: t`UNI Governance`,
descriptor: t`Contract Interaction`, descriptor: t`Contract Interaction`,
logos: [UNI_IMG], logos: [UNI_IMG],
......
import { Currency } from '@uniswap/sdk-core' import { ChainId, Currency } from '@uniswap/sdk-core'
import { SupportedChainId } from 'constants/chains'
import { AssetActivityPartsFragment, TransactionStatus } from 'graphql/data/__generated__/types-and-hooks' import { AssetActivityPartsFragment, TransactionStatus } from 'graphql/data/__generated__/types-and-hooks'
type Receipt = AssetActivityPartsFragment['transaction'] type Receipt = AssetActivityPartsFragment['transaction']
export type Activity = { export type Activity = {
hash: string hash: string
chainId: SupportedChainId chainId: ChainId
status: TransactionStatus status: TransactionStatus
timestamp: number timestamp: number
title: string title: string
......
import { Token } from '@uniswap/sdk-core' import { ChainId, Token } from '@uniswap/sdk-core'
import { Pool, Position } from '@uniswap/v3-sdk' import { Pool, Position } from '@uniswap/v3-sdk'
import { SupportedChainId } from 'constants/chains'
import { useAllTokensMultichain } from 'hooks/Tokens' import { useAllTokensMultichain } from 'hooks/Tokens'
import { atom, useAtom } from 'jotai' import { atom, useAtom } from 'jotai'
import { atomWithStorage } from 'jotai/utils' import { atomWithStorage } from 'jotai/utils'
...@@ -16,7 +15,7 @@ import { useInterfaceMulticallContracts } from './hooks' ...@@ -16,7 +15,7 @@ import { useInterfaceMulticallContracts } from './hooks'
export type PositionInfo = { export type PositionInfo = {
owner: string owner: string
chainId: SupportedChainId chainId: ChainId
position: Position position: Position
pool: Pool pool: Pool
details: PositionDetails details: PositionDetails
...@@ -59,7 +58,7 @@ export function useCachedPositions(account: string): UseCachedPositionsReturnTyp ...@@ -59,7 +58,7 @@ export function useCachedPositions(account: string): UseCachedPositionsReturnTyp
return [cachedPositions[account], setPositionsAndStaleTimeout] return [cachedPositions[account], setPositionsAndStaleTimeout]
} }
const poolAddressKey = (details: PositionDetails, chainId: SupportedChainId) => const poolAddressKey = (details: PositionDetails, chainId: ChainId) =>
`${chainId}-${details.token0}-${details.token1}-${details.fee}` `${chainId}-${details.token0}-${details.token1}-${details.fee}`
type PoolAddressMap = { [key: string]: string | undefined } type PoolAddressMap = { [key: string]: string | undefined }
...@@ -71,11 +70,11 @@ const poolAddressCacheAtom = atomWithStorage<PoolAddressMap>('poolCache', {}) ...@@ -71,11 +70,11 @@ const poolAddressCacheAtom = atomWithStorage<PoolAddressMap>('poolCache', {})
export function usePoolAddressCache() { export function usePoolAddressCache() {
const [cache, updateCache] = useAtom(poolAddressCacheAtom) const [cache, updateCache] = useAtom(poolAddressCacheAtom)
const get = useCallback( const get = useCallback(
(details: PositionDetails, chainId: SupportedChainId) => cache[poolAddressKey(details, chainId)], (details: PositionDetails, chainId: ChainId) => cache[poolAddressKey(details, chainId)],
[cache] [cache]
) )
const set = useCallback( const set = useCallback(
(details: PositionDetails, chainId: SupportedChainId, address: string) => (details: PositionDetails, chainId: ChainId, address: string) =>
updateCache((c) => ({ ...c, [poolAddressKey(details, chainId)]: address })), updateCache((c) => ({ ...c, [poolAddressKey(details, chainId)]: address })),
[updateCache] [updateCache]
) )
...@@ -104,8 +103,8 @@ function useTokenCache() { ...@@ -104,8 +103,8 @@ function useTokenCache() {
return { get, set } return { get, set }
} }
type TokenGetterFn = (addresses: string[], chainId: SupportedChainId) => Promise<{ [key: string]: Token | undefined }> type TokenGetterFn = (addresses: string[], chainId: ChainId) => Promise<{ [key: string]: Token | undefined }>
export function useGetCachedTokens(chains: SupportedChainId[]): TokenGetterFn { export function useGetCachedTokens(chains: ChainId[]): TokenGetterFn {
const allTokens = useAllTokensMultichain() const allTokens = useAllTokensMultichain()
const multicallContracts = useInterfaceMulticallContracts(chains) const multicallContracts = useInterfaceMulticallContracts(chains)
const tokenCache = useTokenCache() const tokenCache = useTokenCache()
......
import { Token } from '@uniswap/sdk-core' import { ChainId, Token } from '@uniswap/sdk-core'
import ERC20_ABI from 'abis/erc20.json' import ERC20_ABI from 'abis/erc20.json'
import { Erc20Interface } from 'abis/types/Erc20' import { Erc20Interface } from 'abis/types/Erc20'
import { Erc20Bytes32Interface } from 'abis/types/Erc20Bytes32' import { Erc20Bytes32Interface } from 'abis/types/Erc20Bytes32'
import { SupportedChainId } from 'constants/chains'
import { DEFAULT_ERC20_DECIMALS } from 'constants/tokens' import { DEFAULT_ERC20_DECIMALS } from 'constants/tokens'
import { Interface } from 'ethers/lib/utils' import { Interface } from 'ethers/lib/utils'
import { UniswapInterfaceMulticall } from 'types/v3' import { UniswapInterfaceMulticall } from 'types/v3'
...@@ -38,7 +37,7 @@ async function fetchChunk(multicall: UniswapInterfaceMulticall, chunk: Call[]): ...@@ -38,7 +37,7 @@ async function fetchChunk(multicall: UniswapInterfaceMulticall, chunk: Call[]):
} }
} }
function tryParseToken(address: string, chainId: SupportedChainId, data: CallResult[]) { function tryParseToken(address: string, chainId: ChainId, data: CallResult[]) {
try { try {
const [nameData, symbolData, decimalsData, nameDataBytes32, symbolDataBytes32] = data const [nameData, symbolData, decimalsData, nameDataBytes32, symbolDataBytes32] = data
...@@ -61,7 +60,7 @@ function tryParseToken(address: string, chainId: SupportedChainId, data: CallRes ...@@ -61,7 +60,7 @@ function tryParseToken(address: string, chainId: SupportedChainId, data: CallRes
} }
} }
function parseTokens(addresses: string[], chainId: SupportedChainId, returnData: CallResult[]) { function parseTokens(addresses: string[], chainId: ChainId, returnData: CallResult[]) {
const tokenDataSlices = arrayToSlices(returnData, 5) const tokenDataSlices = arrayToSlices(returnData, 5)
return tokenDataSlices.reduce((acc: TokenMap, slice, index) => { return tokenDataSlices.reduce((acc: TokenMap, slice, index) => {
...@@ -90,7 +89,7 @@ const TokenPromiseCache: { [key: CurrencyKey]: Promise<Token | undefined> | unde ...@@ -90,7 +89,7 @@ const TokenPromiseCache: { [key: CurrencyKey]: Promise<Token | undefined> | unde
// Returns tokens using a single RPC call to the multicall contract // Returns tokens using a single RPC call to the multicall contract
export async function getTokensAsync( export async function getTokensAsync(
addresses: string[], addresses: string[],
chainId: SupportedChainId, chainId: ChainId,
multicall: UniswapInterfaceMulticall multicall: UniswapInterfaceMulticall
): Promise<TokenMap> { ): Promise<TokenMap> {
if (addresses.length === 0) return {} if (addresses.length === 0) return {}
......
import { Token } from '@uniswap/sdk-core' import {
ChainId,
MULTICALL_ADDRESSES,
NONFUNGIBLE_POSITION_MANAGER_ADDRESSES as V3NFT_ADDRESSES,
Token,
} from '@uniswap/sdk-core'
import { AddressMap } from '@uniswap/smart-order-router' import { AddressMap } from '@uniswap/smart-order-router'
import MulticallJSON from '@uniswap/v3-periphery/artifacts/contracts/lens/UniswapInterfaceMulticall.sol/UniswapInterfaceMulticall.json' import MulticallJSON from '@uniswap/v3-periphery/artifacts/contracts/lens/UniswapInterfaceMulticall.sol/UniswapInterfaceMulticall.json'
import NFTPositionManagerJSON from '@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json' import NFTPositionManagerJSON from '@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { MULTICALL_ADDRESS, NONFUNGIBLE_POSITION_MANAGER_ADDRESSES as V3NFT_ADDRESSES } from 'constants/addresses' import { isSupportedChain } from 'constants/chains'
import { isSupportedChain, SupportedChainId } from 'constants/chains'
import { RPC_PROVIDERS } from 'constants/providers' import { RPC_PROVIDERS } from 'constants/providers'
import { BaseContract } from 'ethers/lib/ethers' import { BaseContract } from 'ethers/lib/ethers'
import { ContractInput, useUniswapPricesQuery } from 'graphql/data/__generated__/types-and-hooks' import { ContractInput, useUniswapPricesQuery } from 'graphql/data/__generated__/types-and-hooks'
...@@ -23,7 +27,7 @@ type ContractMap<T extends BaseContract> = { [key: number]: T } ...@@ -23,7 +27,7 @@ type ContractMap<T extends BaseContract> = { [key: number]: T }
function useContractMultichain<T extends BaseContract>( function useContractMultichain<T extends BaseContract>(
addressMap: AddressMap, addressMap: AddressMap,
ABI: any, ABI: any,
chainIds?: SupportedChainId[] chainIds?: ChainId[]
): ContractMap<T> { ): ContractMap<T> {
const { chainId: walletChainId, provider: walletProvider } = useWeb3React() const { chainId: walletChainId, provider: walletProvider } = useWeb3React()
...@@ -35,19 +39,26 @@ function useContractMultichain<T extends BaseContract>( ...@@ -35,19 +39,26 @@ function useContractMultichain<T extends BaseContract>(
.filter(isSupportedChain) .filter(isSupportedChain)
return relevantChains.reduce((acc: ContractMap<T>, chainId) => { return relevantChains.reduce((acc: ContractMap<T>, chainId) => {
const provider = walletProvider && walletChainId === chainId ? walletProvider : RPC_PROVIDERS[chainId] const provider =
acc[chainId] = getContract(addressMap[chainId], ABI, provider) as T walletProvider && walletChainId === chainId
? walletProvider
: isSupportedChain(chainId)
? RPC_PROVIDERS[chainId]
: undefined
if (provider) {
acc[chainId] = getContract(addressMap[chainId] ?? '', ABI, provider) as T
}
return acc return acc
}, {}) }, {})
}, [ABI, addressMap, chainIds, walletChainId, walletProvider]) }, [ABI, addressMap, chainIds, walletChainId, walletProvider])
} }
export function useV3ManagerContracts(chainIds: SupportedChainId[]): ContractMap<NonfungiblePositionManager> { export function useV3ManagerContracts(chainIds: ChainId[]): ContractMap<NonfungiblePositionManager> {
return useContractMultichain<NonfungiblePositionManager>(V3NFT_ADDRESSES, NFTPositionManagerJSON.abi, chainIds) return useContractMultichain<NonfungiblePositionManager>(V3NFT_ADDRESSES, NFTPositionManagerJSON.abi, chainIds)
} }
export function useInterfaceMulticallContracts(chainIds: SupportedChainId[]): ContractMap<UniswapInterfaceMulticall> { export function useInterfaceMulticallContracts(chainIds: ChainId[]): ContractMap<UniswapInterfaceMulticall> {
return useContractMultichain<UniswapInterfaceMulticall>(MULTICALL_ADDRESS, MulticallJSON.abi, chainIds) return useContractMultichain<UniswapInterfaceMulticall>(MULTICALL_ADDRESSES, MulticallJSON.abi, chainIds)
} }
type PriceMap = { [key: CurrencyKey]: number | undefined } type PriceMap = { [key: CurrencyKey]: number | undefined }
......
import { BigNumber } from '@ethersproject/bignumber' import { BigNumber } from '@ethersproject/bignumber'
import { SupportedChainId, WETH9 } from '@uniswap/sdk-core' import { ChainId, WETH9 } from '@uniswap/sdk-core'
import { FeeAmount, Pool, Position } from '@uniswap/v3-sdk' import { FeeAmount, Pool, Position } from '@uniswap/v3-sdk'
import { USDC_MAINNET } from 'constants/tokens' import { USDC_MAINNET } from 'constants/tokens'
import { mocked } from 'test-utils/mocked' import { mocked } from 'test-utils/mocked'
...@@ -16,7 +16,7 @@ const owner = '0xf5b6bb25f5beaea03dd014c6ef9fa9f3926bf36c' ...@@ -16,7 +16,7 @@ const owner = '0xf5b6bb25f5beaea03dd014c6ef9fa9f3926bf36c'
const pool = new Pool( const pool = new Pool(
USDC_MAINNET, USDC_MAINNET,
WETH9[SupportedChainId.MAINNET], WETH9[ChainId.MAINNET],
FeeAmount.MEDIUM, FeeAmount.MEDIUM,
'1851127709498178402383049949138810', '1851127709498178402383049949138810',
'7076437181775065414', '7076437181775065414',
...@@ -34,7 +34,7 @@ const details = { ...@@ -34,7 +34,7 @@ const details = {
tokenId: BigNumber.from('0'), tokenId: BigNumber.from('0'),
operator: '0x0', operator: '0x0',
token0: USDC_MAINNET.address, token0: USDC_MAINNET.address,
token1: WETH9[SupportedChainId.MAINNET].address, token1: WETH9[ChainId.MAINNET].address,
fee: FeeAmount.MEDIUM, fee: FeeAmount.MEDIUM,
tickLower: -100, tickLower: -100,
tickUpper: 100, tickUpper: 100,
...@@ -48,7 +48,7 @@ const useMultiChainPositionsReturnValue = { ...@@ -48,7 +48,7 @@ const useMultiChainPositionsReturnValue = {
positions: [ positions: [
{ {
owner, owner,
chainId: SupportedChainId.MAINNET, chainId: ChainId.MAINNET,
position, position,
pool, pool,
details, details,
......
import { CurrencyAmount, Token } from '@uniswap/sdk-core' import { ChainId, CurrencyAmount, Token, V3_CORE_FACTORY_ADDRESSES } from '@uniswap/sdk-core'
import IUniswapV3PoolStateJSON from '@uniswap/v3-core/artifacts/contracts/interfaces/pool/IUniswapV3PoolState.sol/IUniswapV3PoolState.json' import IUniswapV3PoolStateJSON from '@uniswap/v3-core/artifacts/contracts/interfaces/pool/IUniswapV3PoolState.sol/IUniswapV3PoolState.json'
import { computePoolAddress, Pool, Position } from '@uniswap/v3-sdk' import { computePoolAddress, Pool, Position } from '@uniswap/v3-sdk'
import { V3_CORE_FACTORY_ADDRESSES } from 'constants/addresses'
import { SupportedChainId } from 'constants/chains'
import { DEFAULT_ERC20_DECIMALS } from 'constants/tokens' import { DEFAULT_ERC20_DECIMALS } from 'constants/tokens'
import { BigNumber } from 'ethers/lib/ethers' import { BigNumber } from 'ethers/lib/ethers'
import { Interface } from 'ethers/lib/utils' import { Interface } from 'ethers/lib/utils'
...@@ -18,7 +16,7 @@ import { useInterfaceMulticallContracts, usePoolPriceMap, useV3ManagerContracts ...@@ -18,7 +16,7 @@ import { useInterfaceMulticallContracts, usePoolPriceMap, useV3ManagerContracts
function createPositionInfo( function createPositionInfo(
owner: string, owner: string,
chainId: SupportedChainId, chainId: ChainId,
details: PositionDetails, details: PositionDetails,
slot0: any, slot0: any,
tokenA: Token, tokenA: Token,
...@@ -42,12 +40,13 @@ type FeeAmounts = [BigNumber, BigNumber] ...@@ -42,12 +40,13 @@ type FeeAmounts = [BigNumber, BigNumber]
const MAX_UINT128 = BigNumber.from(2).pow(128).sub(1) const MAX_UINT128 = BigNumber.from(2).pow(128).sub(1)
const DEFAULT_CHAINS = [ const DEFAULT_CHAINS = [
SupportedChainId.MAINNET, ChainId.MAINNET,
SupportedChainId.ARBITRUM_ONE, ChainId.ARBITRUM_ONE,
SupportedChainId.OPTIMISM, ChainId.OPTIMISM,
SupportedChainId.POLYGON, ChainId.POLYGON,
SupportedChainId.CELO, ChainId.CELO,
SupportedChainId.BNB, ChainId.BNB,
ChainId.AVALANCHE,
] ]
type UseMultiChainPositionsData = { positions?: PositionInfo[]; loading: boolean } type UseMultiChainPositionsData = { positions?: PositionInfo[]; loading: boolean }
...@@ -118,7 +117,7 @@ export default function useMultiChainPositions(account: string, chains = DEFAULT ...@@ -118,7 +117,7 @@ export default function useMultiChainPositions(account: string, chains = DEFAULT
// Combines PositionDetails with Pool data to build our return type // Combines PositionDetails with Pool data to build our return type
const fetchPositionInfo = useCallback( const fetchPositionInfo = useCallback(
async (positionDetails: PositionDetails[], chainId: SupportedChainId, multicall: UniswapInterfaceMulticall) => { async (positionDetails: PositionDetails[], chainId: ChainId, multicall: UniswapInterfaceMulticall) => {
const poolInterface = new Interface(IUniswapV3PoolStateJSON.abi) as UniswapV3PoolInterface const poolInterface = new Interface(IUniswapV3PoolStateJSON.abi) as UniswapV3PoolInterface
const tokens = await getTokens( const tokens = await getTokens(
positionDetails.flatMap((details) => [details.token0, details.token1]), positionDetails.flatMap((details) => [details.token0, details.token1]),
...@@ -159,7 +158,7 @@ export default function useMultiChainPositions(account: string, chains = DEFAULT ...@@ -159,7 +158,7 @@ export default function useMultiChainPositions(account: string, chains = DEFAULT
) )
const fetchPositionsForChain = useCallback( const fetchPositionsForChain = useCallback(
async (chainId: SupportedChainId): Promise<PositionInfo[]> => { async (chainId: ChainId): Promise<PositionInfo[]> => {
try { try {
const pm = pms[chainId] const pm = pms[chainId]
const multicall = multicalls[chainId] const multicall = multicalls[chainId]
......
import { SupportedChainId } from '@uniswap/sdk-core' import { ChainId } from '@uniswap/sdk-core'
import { DAI_ARBITRUM } from '@uniswap/smart-order-router' import { DAI_ARBITRUM } from '@uniswap/smart-order-router'
import { BRIDGED_USDC_ARBITRUM, DAI, USDC_MAINNET } from 'constants/tokens' import { BRIDGED_USDC_ARBITRUM, DAI, USDC_MAINNET } from 'constants/tokens'
import { render } from 'test-utils/render' import { render } from 'test-utils/render'
...@@ -7,13 +7,13 @@ import { PortfolioLogo } from './PortfolioLogo' ...@@ -7,13 +7,13 @@ import { PortfolioLogo } from './PortfolioLogo'
describe('PortfolioLogo', () => { describe('PortfolioLogo', () => {
it('renders without L2 icon', () => { it('renders without L2 icon', () => {
const { container } = render(<PortfolioLogo chainId={SupportedChainId.MAINNET} currencies={[DAI, USDC_MAINNET]} />) const { container } = render(<PortfolioLogo chainId={ChainId.MAINNET} currencies={[DAI, USDC_MAINNET]} />)
expect(container).toMatchSnapshot() expect(container).toMatchSnapshot()
}) })
it('renders with L2 icon', () => { it('renders with L2 icon', () => {
const { container } = render( const { container } = render(
<PortfolioLogo chainId={SupportedChainId.ARBITRUM_ONE} currencies={[DAI_ARBITRUM, BRIDGED_USDC_ARBITRUM]} /> <PortfolioLogo chainId={ChainId.ARBITRUM_ONE} currencies={[DAI_ARBITRUM, BRIDGED_USDC_ARBITRUM]} />
) )
expect(container).toMatchSnapshot() expect(container).toMatchSnapshot()
}) })
......
import { Currency } from '@uniswap/sdk-core' import { ChainId, Currency } from '@uniswap/sdk-core'
import blankTokenUrl from 'assets/svg/blank_token.svg' import blankTokenUrl from 'assets/svg/blank_token.svg'
import { ReactComponent as UnknownStatus } from 'assets/svg/contract-interaction.svg' import { ReactComponent as UnknownStatus } from 'assets/svg/contract-interaction.svg'
import { LogoImage, MissingImageLogo } from 'components/Logo/AssetLogo' import { LogoImage, MissingImageLogo } from 'components/Logo/AssetLogo'
import { Unicon } from 'components/Unicon' import { Unicon } from 'components/Unicon'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { SupportedChainId } from 'constants/chains'
import useTokenLogoSource from 'hooks/useAssetLogoSource' import useTokenLogoSource from 'hooks/useAssetLogoSource'
import useENSAvatar from 'hooks/useENSAvatar' import useENSAvatar from 'hooks/useENSAvatar'
import React from 'react' import React from 'react'
...@@ -37,7 +36,7 @@ const DoubleLogoContainer = styled.div` ...@@ -37,7 +36,7 @@ const DoubleLogoContainer = styled.div`
` `
type MultiLogoProps = { type MultiLogoProps = {
chainId: SupportedChainId chainId: ChainId
accountAddress?: string accountAddress?: string
currencies?: Array<Currency | undefined> currencies?: Array<Currency | undefined>
images?: (string | undefined)[] images?: (string | undefined)[]
...@@ -85,7 +84,7 @@ const L2LogoContainer = styled.div<{ $backgroundColor?: string }>` ...@@ -85,7 +84,7 @@ const L2LogoContainer = styled.div<{ $backgroundColor?: string }>`
* Renders an image by prioritizing a list of sources, and then eventually a fallback triangle alert * Renders an image by prioritizing a list of sources, and then eventually a fallback triangle alert
*/ */
export function PortfolioLogo({ export function PortfolioLogo({
chainId = SupportedChainId.MAINNET, chainId = ChainId.MAINNET,
accountAddress, accountAddress,
currencies, currencies,
images, images,
...@@ -142,7 +141,7 @@ export function PortfolioLogo({ ...@@ -142,7 +141,7 @@ export function PortfolioLogo({
} }
const L2Logo = const L2Logo =
chainId !== SupportedChainId.MAINNET && chainLogo ? ( chainId !== ChainId.MAINNET && chainLogo ? (
<L2LogoContainer $backgroundColor={squareLogoUrl ? theme.backgroundSurface : theme.textPrimary}> <L2LogoContainer $backgroundColor={squareLogoUrl ? theme.backgroundSurface : theme.textPrimary}>
{squareLogoUrl ? ( {squareLogoUrl ? (
<SquareChainLogo src={chainLogo} alt="chainLogo" /> <SquareChainLogo src={chainLogo} alt="chainLogo" />
......
import { BigNumber } from '@ethersproject/bignumber' import { BigNumber } from '@ethersproject/bignumber'
import type { TransactionResponse } from '@ethersproject/providers' import type { TransactionResponse } from '@ethersproject/providers'
import { UNISWAP_NFT_AIRDROP_CLAIM_ADDRESS } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import uniswapNftAirdropClaim from 'abis/uniswap-nft-airdrop-claim.json' import uniswapNftAirdropClaim from 'abis/uniswap-nft-airdrop-claim.json'
import airdropBackgroundv2 from 'assets/images/airdopBackground.png' import airdropBackgroundv2 from 'assets/images/airdopBackground.png'
import { ButtonEmphasis, ButtonSize, ThemeButton } from 'components/Button' import { ButtonEmphasis, ButtonSize, ThemeButton } from 'components/Button'
import { OpacityHoverState } from 'components/Common' import { OpacityHoverState } from 'components/Common'
import Loader from 'components/Icons/LoadingSpinner' import Loader from 'components/Icons/LoadingSpinner'
import { UNISWAP_NFT_AIRDROP_CLAIM_ADDRESS } from 'constants/addresses'
import { useContract } from 'hooks/useContract' import { useContract } from 'hooks/useContract'
import { ChevronRightIcon } from 'nft/components/icons' import { ChevronRightIcon } from 'nft/components/icons'
import { useIsNftClaimAvailable } from 'nft/hooks/useIsNftClaimAvailable' import { useIsNftClaimAvailable } from 'nft/hooks/useIsNftClaimAvailable'
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { ChainId, SUPPORTED_CHAINS } from '@uniswap/sdk-core'
import { FeeAmount } from '@uniswap/v3-sdk' import { FeeAmount } from '@uniswap/v3-sdk'
import { ALL_SUPPORTED_CHAIN_IDS, SupportedChainId } from 'constants/chains'
import type { ReactNode } from 'react' import type { ReactNode } from 'react'
export const FEE_AMOUNT_DETAIL: Record< export const FEE_AMOUNT_DETAIL: Record<
FeeAmount, FeeAmount,
{ label: string; description: ReactNode; supportedChains: SupportedChainId[] } { label: string; description: ReactNode; supportedChains: readonly ChainId[] }
> = { > = {
[FeeAmount.LOWEST]: { [FeeAmount.LOWEST]: {
label: '0.01', label: '0.01',
description: <Trans>Best for very stable pairs.</Trans>, description: <Trans>Best for very stable pairs.</Trans>,
supportedChains: [ supportedChains: [
SupportedChainId.ARBITRUM_ONE, ChainId.ARBITRUM_ONE,
SupportedChainId.BNB, ChainId.BNB,
SupportedChainId.CELO, ChainId.CELO,
SupportedChainId.CELO_ALFAJORES, ChainId.CELO_ALFAJORES,
SupportedChainId.MAINNET, ChainId.MAINNET,
SupportedChainId.OPTIMISM, ChainId.OPTIMISM,
SupportedChainId.POLYGON, ChainId.POLYGON,
SupportedChainId.POLYGON_MUMBAI, ChainId.POLYGON_MUMBAI,
ChainId.AVALANCHE,
], ],
}, },
[FeeAmount.LOW]: { [FeeAmount.LOW]: {
label: '0.05', label: '0.05',
description: <Trans>Best for stable pairs.</Trans>, description: <Trans>Best for stable pairs.</Trans>,
supportedChains: ALL_SUPPORTED_CHAIN_IDS, supportedChains: SUPPORTED_CHAINS,
}, },
[FeeAmount.MEDIUM]: { [FeeAmount.MEDIUM]: {
label: '0.3', label: '0.3',
description: <Trans>Best for most pairs.</Trans>, description: <Trans>Best for most pairs.</Trans>,
supportedChains: ALL_SUPPORTED_CHAIN_IDS, supportedChains: SUPPORTED_CHAINS,
}, },
[FeeAmount.HIGH]: { [FeeAmount.HIGH]: {
label: '1', label: '1',
description: <Trans>Best for exotic pairs.</Trans>, description: <Trans>Best for exotic pairs.</Trans>,
supportedChains: ALL_SUPPORTED_CHAIN_IDS, supportedChains: SUPPORTED_CHAINS,
}, },
} }
import { ChainId } from '@uniswap/sdk-core'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { SupportedChainId } from 'constants/chains'
import useTokenLogoSource from 'hooks/useAssetLogoSource' import useTokenLogoSource from 'hooks/useAssetLogoSource'
import React from 'react' import React from 'react'
import styled, { css } from 'styled-components/macro' import styled, { css } from 'styled-components/macro'
...@@ -63,7 +63,7 @@ const L2NetworkLogo = styled.div<{ networkUrl?: string; parentSize: string }>` ...@@ -63,7 +63,7 @@ const L2NetworkLogo = styled.div<{ networkUrl?: string; parentSize: string }>`
export default function AssetLogo({ export default function AssetLogo({
isNative, isNative,
address, address,
chainId = SupportedChainId.MAINNET, chainId = ChainId.MAINNET,
symbol, symbol,
backupImg, backupImg,
size = '24px', size = '24px',
......
import { t } from '@lingui/macro' import { t } from '@lingui/macro'
import { ChainId } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { WalletConnect } from '@web3-react/walletconnect-v2' import { WalletConnect } from '@web3-react/walletconnect-v2'
import { showTestnetsAtom } from 'components/AccountDrawer/TestnetsToggle' import { showTestnetsAtom } from 'components/AccountDrawer/TestnetsToggle'
...@@ -6,13 +7,7 @@ import { MouseoverTooltip } from 'components/Tooltip' ...@@ -6,13 +7,7 @@ import { MouseoverTooltip } from 'components/Tooltip'
import { getConnection } from 'connection' import { getConnection } from 'connection'
import { ConnectionType } from 'connection/types' import { ConnectionType } from 'connection/types'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { import { L1_CHAIN_IDS, L2_CHAIN_IDS, TESTNET_CHAIN_IDS, UniWalletSupportedChains } from 'constants/chains'
L1_CHAIN_IDS,
L2_CHAIN_IDS,
SupportedChainId,
TESTNET_CHAIN_IDS,
UniWalletSupportedChains,
} from 'constants/chains'
import { useOnClickOutside } from 'hooks/useOnClickOutside' import { useOnClickOutside } from 'hooks/useOnClickOutside'
import useSelectChain from 'hooks/useSelectChain' import useSelectChain from 'hooks/useSelectChain'
import useSyncChainQuery from 'hooks/useSyncChainQuery' import useSyncChainQuery from 'hooks/useSyncChainQuery'
...@@ -36,7 +31,7 @@ interface ChainSelectorProps { ...@@ -36,7 +31,7 @@ interface ChainSelectorProps {
leftAlign?: boolean leftAlign?: boolean
} }
function useWalletSupportedChains(): SupportedChainId[] { function useWalletSupportedChains(): ChainId[] {
const { connector } = useWeb3React() const { connector } = useWeb3React()
const connectionType = getConnection(connector).type const connectionType = getConnection(connector).type
...@@ -63,7 +58,7 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => { ...@@ -63,7 +58,7 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => {
const [supportedChains, unsupportedChains] = useMemo(() => { const [supportedChains, unsupportedChains] = useMemo(() => {
const { supported, unsupported } = NETWORK_SELECTOR_CHAINS.filter( const { supported, unsupported } = NETWORK_SELECTOR_CHAINS.filter(
(chain) => showTestnets || !TESTNET_CHAIN_IDS.has(chain) (chain: number) => showTestnets || !TESTNET_CHAIN_IDS.includes(chain)
).reduce( ).reduce(
(acc, chain) => { (acc, chain) => {
if (walletSupportsChain.includes(chain)) { if (walletSupportsChain.includes(chain)) {
...@@ -73,7 +68,7 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => { ...@@ -73,7 +68,7 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => {
} }
return acc return acc
}, },
{ supported: [], unsupported: [] } as Record<string, SupportedChainId[]> { supported: [], unsupported: [] } as Record<string, ChainId[]>
) )
return [supported, unsupported] return [supported, unsupported]
}, [showTestnets, walletSupportsChain]) }, [showTestnets, walletSupportsChain])
...@@ -87,10 +82,10 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => { ...@@ -87,10 +82,10 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => {
const selectChain = useSelectChain() const selectChain = useSelectChain()
useSyncChainQuery() useSyncChainQuery()
const [pendingChainId, setPendingChainId] = useState<SupportedChainId | undefined>(undefined) const [pendingChainId, setPendingChainId] = useState<ChainId | undefined>(undefined)
const onSelectChain = useCallback( const onSelectChain = useCallback(
async (targetChainId: SupportedChainId) => { async (targetChainId: ChainId) => {
setPendingChainId(targetChainId) setPendingChainId(targetChainId)
await selectChain(targetChainId) await selectChain(targetChainId)
setPendingChainId(undefined) setPendingChainId(undefined)
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { ChainId } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import Loader from 'components/Icons/LoadingSpinner' import Loader from 'components/Icons/LoadingSpinner'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { SupportedChainId } from 'constants/chains'
import { CheckMarkIcon } from 'nft/components/icons' import { CheckMarkIcon } from 'nft/components/icons'
import styled, { useTheme } from 'styled-components/macro' import styled, { useTheme } from 'styled-components/macro'
...@@ -63,7 +63,7 @@ const Logo = styled.img` ...@@ -63,7 +63,7 @@ const Logo = styled.img`
` `
interface ChainSelectorRowProps { interface ChainSelectorRowProps {
disabled?: boolean disabled?: boolean
targetChain: SupportedChainId targetChain: ChainId
onSelectChain: (targetChain: number) => void onSelectChain: (targetChain: number) => void
isPending: boolean isPending: boolean
} }
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { useTrace } from '@uniswap/analytics' import { useTrace } from '@uniswap/analytics'
import { InterfaceSectionName, NavBarSearchTypes } from '@uniswap/analytics-events' import { InterfaceSectionName, NavBarSearchTypes } from '@uniswap/analytics-events'
import { ChainId } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import clsx from 'clsx' import clsx from 'clsx'
import Badge from 'components/Badge' import Badge from 'components/Badge'
import { SupportedChainId } from 'constants/chains' import { getChainInfo } from 'constants/chainInfo'
import { HistoryDuration, SafetyLevel } from 'graphql/data/__generated__/types-and-hooks' import { HistoryDuration, SafetyLevel } from 'graphql/data/__generated__/types-and-hooks'
import { useTrendingCollections } from 'graphql/data/nft/TrendingCollections' import { useTrendingCollections } from 'graphql/data/nft/TrendingCollections'
import { SearchToken } from 'graphql/data/SearchTokens' import { SearchToken } from 'graphql/data/SearchTokens'
import useTrendingTokens from 'graphql/data/TrendingTokens' import useTrendingTokens from 'graphql/data/TrendingTokens'
import { BACKEND_NOT_YET_SUPPORTED_CHAIN_IDS } from 'graphql/data/util'
import { useDisableNFTRoutes } from 'hooks/useDisableNFTRoutes' import { useDisableNFTRoutes } from 'hooks/useDisableNFTRoutes'
import { useIsNftPage } from 'hooks/useIsNftPage' import { useIsNftPage } from 'hooks/useIsNftPage'
import { Box } from 'nft/components/Box' import { Box } from 'nft/components/Box'
...@@ -20,7 +22,6 @@ import { useLocation } from 'react-router-dom' ...@@ -20,7 +22,6 @@ import { useLocation } from 'react-router-dom'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { ThemedText } from 'theme' import { ThemedText } from 'theme'
import BnbLogoURI from '../../assets/svg/bnb-logo.svg'
import { ClockIcon, TrendingArrow } from '../../nft/components/icons' import { ClockIcon, TrendingArrow } from '../../nft/components/icons'
import { useRecentlySearchedAssets } from './RecentlySearchedAssets' import { useRecentlySearchedAssets } from './RecentlySearchedAssets'
import * as styles from './SearchBar.css' import * as styles from './SearchBar.css'
...@@ -104,12 +105,12 @@ function isKnownToken(token: SearchToken) { ...@@ -104,12 +105,12 @@ function isKnownToken(token: SearchToken) {
return token.project?.safetyLevel == SafetyLevel.Verified || token.project?.safetyLevel == SafetyLevel.MediumWarning return token.project?.safetyLevel == SafetyLevel.Verified || token.project?.safetyLevel == SafetyLevel.MediumWarning
} }
const BNBLogo = styled.img` const ChainLogo = styled.img`
height: 20px; height: 20px;
width: 20px; width: 20px;
margin-right: 8px; margin-right: 8px;
` `
const BNBComingSoonBadge = styled(Badge)` const ChainComingSoonBadge = styled(Badge)`
align-items: center; align-items: center;
background-color: ${({ theme }) => theme.backgroundModule}; background-color: ${({ theme }) => theme.backgroundModule};
color: ${({ theme }) => theme.textSecondary}; color: ${({ theme }) => theme.textSecondary};
...@@ -356,21 +357,33 @@ export const SearchBarDropdown = ({ ...@@ -356,21 +357,33 @@ export const SearchBarDropdown = ({
shouldDisableNFTRoutes, shouldDisableNFTRoutes,
]) ])
const showBNBComingSoonBadge = chainId === SupportedChainId.BNB && !isLoading const showChainComingSoonBadge = chainId && BACKEND_NOT_YET_SUPPORTED_CHAIN_IDS.includes(chainId) && !isLoading
const logoUri = getChainInfo(chainId)?.logoUrl
return ( return (
<Column overflow="hidden" className={clsx(styles.searchBarDropdownNft, styles.searchBarScrollable)}> <Column overflow="hidden" className={clsx(styles.searchBarDropdownNft, styles.searchBarScrollable)}>
<Box opacity={isLoading ? '0.3' : '1'} transition="125"> <Box opacity={isLoading ? '0.3' : '1'} transition="125">
{resultsState} {resultsState}
{showBNBComingSoonBadge && ( {showChainComingSoonBadge && (
<BNBComingSoonBadge> <ChainComingSoonBadge>
<BNBLogo src={BnbLogoURI} /> <ChainLogo src={logoUri} />
<ThemedText.BodySmall color="textSecondary" fontSize="14px" fontWeight="400" lineHeight="20px"> <ThemedText.BodySmall color="textSecondary" fontSize="14px" fontWeight="400" lineHeight="20px">
<Trans>Coming soon: search and explore tokens on BNB Chain</Trans> <ComingSoonText chainId={chainId} />
</ThemedText.BodySmall> </ThemedText.BodySmall>
</BNBComingSoonBadge> </ChainComingSoonBadge>
)} )}
</Box> </Box>
</Column> </Column>
) )
} }
function ComingSoonText({ chainId }: { chainId: ChainId }) {
switch (chainId) {
case ChainId.BNB:
return <Trans>Coming soon: search and explore tokens on BNB Chain</Trans>
case ChainId.AVALANCHE:
return <Trans>Coming soon: search and explore tokens on Avalanche Chain</Trans>
default:
return null
}
}
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { ChainId } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { SupportedChainId } from 'constants/chains'
import { ArrowUpRight } from 'react-feather' import { ArrowUpRight } from 'react-feather'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { ExternalLink, HideSmall } from 'theme' import { ExternalLink, HideSmall } from 'theme'
...@@ -30,15 +30,16 @@ const RootWrapper = styled.div` ...@@ -30,15 +30,16 @@ const RootWrapper = styled.div`
` `
const SHOULD_SHOW_ALERT = { const SHOULD_SHOW_ALERT = {
[SupportedChainId.OPTIMISM]: true, [ChainId.OPTIMISM]: true,
[SupportedChainId.OPTIMISM_GOERLI]: true, [ChainId.OPTIMISM_GOERLI]: true,
[SupportedChainId.ARBITRUM_ONE]: true, [ChainId.ARBITRUM_ONE]: true,
[SupportedChainId.ARBITRUM_GOERLI]: true, [ChainId.ARBITRUM_GOERLI]: true,
[SupportedChainId.POLYGON]: true, [ChainId.POLYGON]: true,
[SupportedChainId.POLYGON_MUMBAI]: true, [ChainId.POLYGON_MUMBAI]: true,
[SupportedChainId.CELO]: true, [ChainId.CELO]: true,
[SupportedChainId.CELO_ALFAJORES]: true, [ChainId.CELO_ALFAJORES]: true,
[SupportedChainId.BNB]: true, [ChainId.BNB]: true,
[ChainId.AVALANCHE]: true,
} }
type NetworkAlertChains = keyof typeof SHOULD_SHOW_ALERT type NetworkAlertChains = keyof typeof SHOULD_SHOW_ALERT
...@@ -47,44 +48,48 @@ const BG_COLORS_BY_DARK_MODE_AND_CHAIN_ID: { ...@@ -47,44 +48,48 @@ const BG_COLORS_BY_DARK_MODE_AND_CHAIN_ID: {
[darkMode in 'dark' | 'light']: { [chainId in NetworkAlertChains]: string } [darkMode in 'dark' | 'light']: { [chainId in NetworkAlertChains]: string }
} = { } = {
dark: { dark: {
[SupportedChainId.POLYGON]: [ChainId.POLYGON]:
'radial-gradient(100% 93.36% at 0% 6.64%, rgba(160, 108, 247, 0.1) 0%, rgba(82, 32, 166, 0.1) 100%)', 'radial-gradient(100% 93.36% at 0% 6.64%, rgba(160, 108, 247, 0.1) 0%, rgba(82, 32, 166, 0.1) 100%)',
[SupportedChainId.POLYGON_MUMBAI]: [ChainId.POLYGON_MUMBAI]:
'radial-gradient(100% 93.36% at 0% 6.64%, rgba(160, 108, 247, 0.1) 0%, rgba(82, 32, 166, 0.1) 100%)', 'radial-gradient(100% 93.36% at 0% 6.64%, rgba(160, 108, 247, 0.1) 0%, rgba(82, 32, 166, 0.1) 100%)',
[SupportedChainId.CELO]: [ChainId.CELO]:
'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(90, 190, 170, 0.15) 0%, rgba(80, 160, 40, 0.15) 100%)', 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(90, 190, 170, 0.15) 0%, rgba(80, 160, 40, 0.15) 100%)',
[SupportedChainId.CELO_ALFAJORES]: [ChainId.CELO_ALFAJORES]:
'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(90, 190, 170, 0.15) 0%, rgba(80, 160, 40, 0.15) 100%)', 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(90, 190, 170, 0.15) 0%, rgba(80, 160, 40, 0.15) 100%)',
[SupportedChainId.BNB]: [ChainId.BNB]:
'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(240, 185, 11, 0.16) 0%, rgba(255, 168, 0, 0.16) 100%)', 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(240, 185, 11, 0.16) 0%, rgba(255, 168, 0, 0.16) 100%)',
[SupportedChainId.OPTIMISM]: [ChainId.OPTIMISM]:
'radial-gradient(948% 292% at 42% 0%, rgba(255, 58, 212, 0.01) 0%, rgba(255, 255, 255, 0.04) 100%),radial-gradient(98% 96% at 2% 0%, rgba(255, 39, 39, 0.01) 0%, rgba(235, 0, 255, 0.01) 96%)', 'radial-gradient(948% 292% at 42% 0%, rgba(255, 58, 212, 0.01) 0%, rgba(255, 255, 255, 0.04) 100%),radial-gradient(98% 96% at 2% 0%, rgba(255, 39, 39, 0.01) 0%, rgba(235, 0, 255, 0.01) 96%)',
[SupportedChainId.OPTIMISM_GOERLI]: [ChainId.OPTIMISM_GOERLI]:
'radial-gradient(948% 292% at 42% 0%, rgba(255, 58, 212, 0.04) 0%, rgba(255, 255, 255, 0.04) 100%),radial-gradient(98% 96% at 2% 0%, rgba(255, 39, 39, 0.04) 0%, rgba(235, 0, 255, 0.01 96%)', 'radial-gradient(948% 292% at 42% 0%, rgba(255, 58, 212, 0.04) 0%, rgba(255, 255, 255, 0.04) 100%),radial-gradient(98% 96% at 2% 0%, rgba(255, 39, 39, 0.04) 0%, rgba(235, 0, 255, 0.01 96%)',
[SupportedChainId.ARBITRUM_ONE]: [ChainId.ARBITRUM_ONE]:
'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.01) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(75% 75% at 0% 0%, rgba(150, 190, 220, 0.05) 0%, rgba(33, 114, 229, 0.05) 100%), hsla(0, 0%, 100%, 0.05)', 'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.01) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(75% 75% at 0% 0%, rgba(150, 190, 220, 0.05) 0%, rgba(33, 114, 229, 0.05) 100%), hsla(0, 0%, 100%, 0.05)',
[SupportedChainId.ARBITRUM_GOERLI]: [ChainId.ARBITRUM_GOERLI]:
'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.05) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(75% 75% at 0% 0%, rgba(150, 190, 220, 0.05) 0%, rgba(33, 114, 229, 0.1) 100%), hsla(0, 0%, 100%, 0.05)', 'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.05) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(75% 75% at 0% 0%, rgba(150, 190, 220, 0.05) 0%, rgba(33, 114, 229, 0.1) 100%), hsla(0, 0%, 100%, 0.05)',
[ChainId.AVALANCHE]:
'radial-gradient(948% 292% at 42% 0%, rgba(255, 58, 212, 0.01) 0%, rgba(255, 255, 255, 0.04) 100%),radial-gradient(98% 96% at 2% 0%, rgba(255, 39, 39, 0.01) 0%, rgba(235, 0, 255, 0.01) 96%)',
}, },
light: { light: {
[SupportedChainId.POLYGON]: [ChainId.POLYGON]:
'radial-gradient(182.71% 205.59% at 2.81% 7.69%, rgba(130, 71, 229, 0.2) 0%, rgba(167, 202, 255, 0.2) 100%)', 'radial-gradient(182.71% 205.59% at 2.81% 7.69%, rgba(130, 71, 229, 0.2) 0%, rgba(167, 202, 255, 0.2) 100%)',
[SupportedChainId.POLYGON_MUMBAI]: [ChainId.POLYGON_MUMBAI]:
'radial-gradient(182.71% 205.59% at 2.81% 7.69%, rgba(130, 71, 229, 0.2) 0%, rgba(167, 202, 255, 0.2) 100%)', 'radial-gradient(182.71% 205.59% at 2.81% 7.69%, rgba(130, 71, 229, 0.2) 0%, rgba(167, 202, 255, 0.2) 100%)',
[SupportedChainId.CELO]: [ChainId.CELO]:
'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(63, 208, 137, 0.15) 0%, rgba(49, 205, 50, 0.15) 100%)', 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(63, 208, 137, 0.15) 0%, rgba(49, 205, 50, 0.15) 100%)',
[SupportedChainId.CELO_ALFAJORES]: [ChainId.CELO_ALFAJORES]:
'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(63, 208, 137, 0.15) 0%, rgba(49, 205, 50, 0.15) 100%)', 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(63, 208, 137, 0.15) 0%, rgba(49, 205, 50, 0.15) 100%)',
[SupportedChainId.BNB]: [ChainId.BNB]:
'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(240, 185, 11, 0.16) 0%, rgba(255, 168, 0, 0.16) 100%)', 'radial-gradient(182.71% 150.59% at 2.81% 7.69%, rgba(240, 185, 11, 0.16) 0%, rgba(255, 168, 0, 0.16) 100%)',
[SupportedChainId.OPTIMISM]: [ChainId.OPTIMISM]:
'radial-gradient(92% 105% at 50% 7%, rgba(255, 58, 212, 0.04) 0%, rgba(255, 255, 255, 0.03) 100%),radial-gradient(100% 97% at 0% 12%, rgba(235, 0, 255, 0.1) 0%, rgba(243, 19, 19, 0.1) 100%), hsla(0, 0%, 100%, 0.1)', 'radial-gradient(92% 105% at 50% 7%, rgba(255, 58, 212, 0.04) 0%, rgba(255, 255, 255, 0.03) 100%),radial-gradient(100% 97% at 0% 12%, rgba(235, 0, 255, 0.1) 0%, rgba(243, 19, 19, 0.1) 100%), hsla(0, 0%, 100%, 0.1)',
[SupportedChainId.OPTIMISM_GOERLI]: [ChainId.OPTIMISM_GOERLI]:
'radial-gradient(92% 105% at 50% 7%, rgba(255, 58, 212, 0.04) 0%, rgba(255, 255, 255, 0.03) 100%),radial-gradient(100% 97% at 0% 12%, rgba(235, 0, 255, 0.1) 0%, rgba(243, 19, 19, 0.1) 100%), hsla(0, 0%, 100%, 0.1)', 'radial-gradient(92% 105% at 50% 7%, rgba(255, 58, 212, 0.04) 0%, rgba(255, 255, 255, 0.03) 100%),radial-gradient(100% 97% at 0% 12%, rgba(235, 0, 255, 0.1) 0%, rgba(243, 19, 19, 0.1) 100%), hsla(0, 0%, 100%, 0.1)',
[SupportedChainId.ARBITRUM_ONE]: [ChainId.ARBITRUM_ONE]:
'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.1) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(circle at top left, hsla(206, 50%, 75%, 0.01), hsla(215, 79%, 51%, 0.12)), hsla(0, 0%, 100%, 0.1)', 'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.1) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(circle at top left, hsla(206, 50%, 75%, 0.01), hsla(215, 79%, 51%, 0.12)), hsla(0, 0%, 100%, 0.1)',
[SupportedChainId.ARBITRUM_GOERLI]: [ChainId.ARBITRUM_GOERLI]:
'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.1) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(circle at top left, hsla(206, 50%, 75%, 0.01), hsla(215, 79%, 51%, 0.12)), hsla(0, 0%, 100%, 0.1)', 'radial-gradient(285% 8200% at 30% 50%, rgba(40, 160, 240, 0.1) 0%, rgba(219, 255, 0, 0) 100%),radial-gradient(circle at top left, hsla(206, 50%, 75%, 0.01), hsla(215, 79%, 51%, 0.12)), hsla(0, 0%, 100%, 0.1)',
[ChainId.AVALANCHE]:
'radial-gradient(92% 105% at 50% 7%, rgba(255, 58, 212, 0.04) 0%, rgba(255, 255, 255, 0.03) 100%),radial-gradient(100% 97% at 0% 12%, rgba(235, 0, 255, 0.1) 0%, rgba(243, 19, 19, 0.1) 100%), hsla(0, 0%, 100%, 0.1)',
}, },
} }
...@@ -135,15 +140,16 @@ const StyledArrowUpRight = styled(ArrowUpRight)` ...@@ -135,15 +140,16 @@ const StyledArrowUpRight = styled(ArrowUpRight)`
` `
const TEXT_COLORS: { [chainId in NetworkAlertChains]: string } = { const TEXT_COLORS: { [chainId in NetworkAlertChains]: string } = {
[SupportedChainId.POLYGON]: 'rgba(130, 71, 229)', [ChainId.POLYGON]: 'rgba(130, 71, 229)',
[SupportedChainId.POLYGON_MUMBAI]: 'rgba(130, 71, 229)', [ChainId.POLYGON_MUMBAI]: 'rgba(130, 71, 229)',
[SupportedChainId.CELO]: 'rgba(53, 178, 97)', [ChainId.CELO]: 'rgba(53, 178, 97)',
[SupportedChainId.CELO_ALFAJORES]: 'rgba(53, 178, 97)', [ChainId.CELO_ALFAJORES]: 'rgba(53, 178, 97)',
[SupportedChainId.OPTIMISM]: '#ff3856', [ChainId.OPTIMISM]: '#ff3856',
[SupportedChainId.OPTIMISM_GOERLI]: '#ff3856', [ChainId.OPTIMISM_GOERLI]: '#ff3856',
[SupportedChainId.ARBITRUM_ONE]: '#0490ed', [ChainId.ARBITRUM_ONE]: '#0490ed',
[SupportedChainId.BNB]: colors.gold400, [ChainId.BNB]: colors.gold400,
[SupportedChainId.ARBITRUM_GOERLI]: '#0490ed', [ChainId.ARBITRUM_GOERLI]: '#0490ed',
[ChainId.AVALANCHE]: '#ff3856',
} }
function shouldShowAlert(chainId: number | undefined): chainId is NetworkAlertChains { function shouldShowAlert(chainId: number | undefined): chainId is NetworkAlertChains {
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { ChainId } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { getChainInfoOrDefault, L2ChainInfo } from 'constants/chainInfo' import { getChainInfoOrDefault, L2ChainInfo } from 'constants/chainInfo'
import { SupportedChainId } from 'constants/chains'
import { AlertTriangle } from 'react-feather' import { AlertTriangle } from 'react-feather'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { ExternalLink, MEDIA_WIDTHS } from 'theme' import { ExternalLink, MEDIA_WIDTHS } from 'theme'
...@@ -62,7 +62,7 @@ export function ChainConnectivityWarning() { ...@@ -62,7 +62,7 @@ export function ChainConnectivityWarning() {
</TitleText> </TitleText>
</TitleRow> </TitleRow>
<BodyRow> <BodyRow>
{chainId === SupportedChainId.MAINNET ? ( {chainId === ChainId.MAINNET ? (
<Trans>You may have lost your network connection.</Trans> <Trans>You may have lost your network connection.</Trans>
) : ( ) : (
<Trans>{label} might be down right now, or you may have lost your network connection.</Trans> <Trans>{label} might be down right now, or you may have lost your network connection.</Trans>
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { ChainId } from '@uniswap/sdk-core'
import AlertTriangleFilled from 'components/Icons/AlertTriangleFilled' import AlertTriangleFilled from 'components/Icons/AlertTriangleFilled'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { SupportedChainId } from 'constants/chains'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { ThemedText } from '../../theme' import { ThemedText } from '../../theme'
...@@ -22,7 +22,7 @@ export const PopupAlertTriangle = styled(AlertTriangleFilled)` ...@@ -22,7 +22,7 @@ export const PopupAlertTriangle = styled(AlertTriangleFilled)`
height: 32px; height: 32px;
` `
export default function FailedNetworkSwitchPopup({ chainId }: { chainId: SupportedChainId }) { export default function FailedNetworkSwitchPopup({ chainId }: { chainId: ChainId }) {
const chainInfo = getChainInfo(chainId) const chainInfo = getChainInfo(chainId)
return ( return (
......
import { ChainId } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { SupportedChainId } from 'constants/chains'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { MEDIA_WIDTHS } from 'theme' import { MEDIA_WIDTHS } from 'theme'
...@@ -62,7 +62,7 @@ export default function Popups() { ...@@ -62,7 +62,7 @@ export default function Popups() {
// need extra padding if network is not L1 Ethereum // need extra padding if network is not L1 Ethereum
const { chainId } = useWeb3React() const { chainId } = useWeb3React()
const isNotOnMainnet = Boolean(chainId && chainId !== SupportedChainId.MAINNET) const isNotOnMainnet = Boolean(chainId && chainId !== ChainId.MAINNET)
return ( return (
<> <>
......
import { BigNumber } from '@ethersproject/bignumber' import { BigNumber } from '@ethersproject/bignumber'
import { SupportedChainId, Token, WETH9 } from '@uniswap/sdk-core' import { ChainId, Token, WETH9 } from '@uniswap/sdk-core'
import { FeeAmount, Pool } from '@uniswap/v3-sdk' import { FeeAmount, Pool } from '@uniswap/v3-sdk'
import { USDC_MAINNET } from 'constants/tokens' import { USDC_MAINNET } from 'constants/tokens'
import { useToken } from 'hooks/Tokens' import { useToken } from 'hooks/Tokens'
...@@ -25,7 +25,7 @@ beforeEach(() => { ...@@ -25,7 +25,7 @@ beforeEach(() => {
// tokenA: Token, tokenB: Token, fee: FeeAmount, sqrtRatioX96: BigintIsh, liquidity: BigintIsh, tickCurrent: number // tokenA: Token, tokenB: Token, fee: FeeAmount, sqrtRatioX96: BigintIsh, liquidity: BigintIsh, tickCurrent: number
new Pool( new Pool(
USDC_MAINNET, USDC_MAINNET,
WETH9[SupportedChainId.MAINNET], WETH9[ChainId.MAINNET],
FeeAmount.MEDIUM, FeeAmount.MEDIUM,
'1745948049099224684665158875285708', '1745948049099224684665158875285708',
'4203610460178577802', '4203610460178577802',
...@@ -37,7 +37,7 @@ beforeEach(() => { ...@@ -37,7 +37,7 @@ beforeEach(() => {
test('PositionListItem should render a position', () => { test('PositionListItem should render a position', () => {
const positionDetails = { const positionDetails = {
token0: USDC_MAINNET.address, token0: USDC_MAINNET.address,
token1: WETH9[SupportedChainId.MAINNET].address, token1: WETH9[ChainId.MAINNET].address,
tokenId: BigNumber.from(479689), tokenId: BigNumber.from(479689),
fee: FeeAmount.MEDIUM, fee: FeeAmount.MEDIUM,
liquidity: BigNumber.from('1341008833950736'), liquidity: BigNumber.from('1341008833950736'),
......
// eslint-disable-next-line no-restricted-imports
import { Percent } from '@uniswap/sdk-core' import { Percent } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { AutoColumn } from 'components/Column' import { AutoColumn } from 'components/Column'
import { L2_CHAIN_IDS } from 'constants/chains' import { isSupportedChain, L2_CHAIN_IDS } from 'constants/chains'
import useDisableScrolling from 'hooks/useDisableScrolling' import useDisableScrolling from 'hooks/useDisableScrolling'
import { useOnClickOutside } from 'hooks/useOnClickOutside' import { useOnClickOutside } from 'hooks/useOnClickOutside'
import { isSupportedChainId } from 'lib/hooks/routing/clientSideSmartOrderRouter'
import { useRef } from 'react' import { useRef } from 'react'
import { useModalIsOpen, useToggleSettingsMenu } from 'state/application/hooks' import { useModalIsOpen, useToggleSettingsMenu } from 'state/application/hooks'
import { ApplicationModal } from 'state/application/reducer' import { ApplicationModal } from 'state/application/reducer'
...@@ -54,11 +52,11 @@ export default function SettingsTab({ autoSlippage, chainId }: { autoSlippage: P ...@@ -54,11 +52,11 @@ export default function SettingsTab({ autoSlippage, chainId }: { autoSlippage: P
useDisableScrolling(isOpen) useDisableScrolling(isOpen)
const isSupportedChain = isSupportedChainId(chainId) const isChainSupported = isSupportedChain(chainId)
return ( return (
<Menu ref={node}> <Menu ref={node}>
<MenuButton disabled={!isSupportedChain || chainId !== connectedChainId} isActive={isOpen} onClick={toggleMenu} /> <MenuButton disabled={!isChainSupported || chainId !== connectedChainId} isActive={isOpen} onClick={toggleMenu} />
{isOpen && ( {isOpen && (
<MenuFlyout> <MenuFlyout>
<RouterPreferenceSettings /> <RouterPreferenceSettings />
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { ChainId } from '@uniswap/sdk-core'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { SupportedChainId } from 'constants/chains'
import { darken } from 'polished' import { darken } from 'polished'
import { useState } from 'react' import { useState } from 'react'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
...@@ -67,7 +67,7 @@ const ResourcesContainer = styled.div` ...@@ -67,7 +67,7 @@ const ResourcesContainer = styled.div`
type AboutSectionProps = { type AboutSectionProps = {
address: string address: string
chainId: SupportedChainId chainId: ChainId
description?: string | null description?: string | null
homepageUrl?: string | null homepageUrl?: string | null
twitterName?: string | null twitterName?: string | null
...@@ -105,7 +105,7 @@ export function AboutSection({ address, chainId, description, homepageUrl, twitt ...@@ -105,7 +105,7 @@ export function AboutSection({ address, chainId, description, homepageUrl, twitt
</ThemedText.SubHeaderSmall> </ThemedText.SubHeaderSmall>
<ResourcesContainer data-cy="resources-container"> <ResourcesContainer data-cy="resources-container">
<Resource <Resource
name={chainId === SupportedChainId.MAINNET ? 'Etherscan' : 'Block Explorer'} name={chainId === ChainId.MAINNET ? 'Etherscan' : 'Block Explorer'}
link={`${explorer}${address === 'NATIVE' ? '' : 'address/' + address}`} link={`${explorer}${address === 'NATIVE' ? '' : 'address/' + address}`}
/> />
<Resource name="More analytics" link={`${infoLink}tokens/${address}`} /> <Resource name="More analytics" link={`${infoLink}tokens/${address}`} />
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { formatCurrencyAmount, NumberType } from '@uniswap/conedison/format' import { formatCurrencyAmount, NumberType } from '@uniswap/conedison/format'
import { Currency } from '@uniswap/sdk-core' import { ChainId, Currency } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import CurrencyLogo from 'components/Logo/CurrencyLogo' import CurrencyLogo from 'components/Logo/CurrencyLogo'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { SupportedChainId } from 'constants/chains' import { asSupportedChain } from 'constants/chains'
import { isSupportedChain } from 'constants/chains'
import { useStablecoinValue } from 'hooks/useStablecoinPrice' import { useStablecoinValue } from 'hooks/useStablecoinPrice'
import useCurrencyBalance from 'lib/hooks/useCurrencyBalance' import useCurrencyBalance from 'lib/hooks/useCurrencyBalance'
import styled, { useTheme } from 'styled-components/macro' import styled, { useTheme } from 'styled-components/macro'
...@@ -67,7 +66,7 @@ const StyledNetworkLabel = styled.div` ...@@ -67,7 +66,7 @@ const StyledNetworkLabel = styled.div`
export default function BalanceSummary({ token }: { token: Currency }) { export default function BalanceSummary({ token }: { token: Currency }) {
const { account, chainId } = useWeb3React() const { account, chainId } = useWeb3React()
const theme = useTheme() const theme = useTheme()
const { label, color } = getChainInfo(isSupportedChain(chainId) ? chainId : SupportedChainId.MAINNET) const { label, color } = getChainInfo(asSupportedChain(chainId) ?? ChainId.MAINNET)
const balance = useCurrencyBalance(account, token) const balance = useCurrencyBalance(account, token)
const formattedBalance = formatCurrencyAmount(balance, NumberType.TokenNonTx) const formattedBalance = formatCurrencyAmount(balance, NumberType.TokenNonTx)
const formattedUsdValue = formatCurrencyAmount(useStablecoinValue(balance), NumberType.FiatTokenStats) const formattedUsdValue = formatCurrencyAmount(useStablecoinValue(balance), NumberType.FiatTokenStats)
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { ChainId } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { ButtonPrimary } from 'components/Button' import { ButtonPrimary } from 'components/Button'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { SupportedChainId } from 'constants/chains'
import useSelectChain from 'hooks/useSelectChain' import useSelectChain from 'hooks/useSelectChain'
import { useNavigate } from 'react-router-dom' import { useNavigate } from 'react-router-dom'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
...@@ -43,7 +43,7 @@ export default function InvalidTokenDetails({ ...@@ -43,7 +43,7 @@ export default function InvalidTokenDetails({
pageChainId, pageChainId,
isInvalidAddress, isInvalidAddress,
}: { }: {
pageChainId: SupportedChainId pageChainId: ChainId
isInvalidAddress?: boolean isInvalidAddress?: boolean
}) { }) {
const { chainId } = useWeb3React() const { chainId } = useWeb3React()
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { formatNumber, NumberType } from '@uniswap/conedison/format' import { formatNumber, NumberType } from '@uniswap/conedison/format'
import { ChainId } from '@uniswap/sdk-core'
import { MouseoverTooltip } from 'components/Tooltip' import { MouseoverTooltip } from 'components/Tooltip'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { SupportedChainId } from 'constants/chains'
import { ReactNode } from 'react' import { ReactNode } from 'react'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { ExternalLink, ThemedText } from 'theme' import { ExternalLink, ThemedText } from 'theme'
...@@ -68,7 +68,7 @@ function Stat({ ...@@ -68,7 +68,7 @@ function Stat({
} }
type StatsSectionProps = { type StatsSectionProps = {
chainId: SupportedChainId chainId: ChainId
address: string address: string
priceLow52W?: NumericStat priceLow52W?: NumericStat
priceHigh52W?: NumericStat priceHigh52W?: NumericStat
......
import Badge from 'components/Badge' import Badge from 'components/Badge'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { Chain } from 'graphql/data/__generated__/types-and-hooks' import {
import { BACKEND_CHAIN_NAMES, supportedChainIdFromGQLChain, validateUrlChainParam } from 'graphql/data/util' BACKEND_NOT_YET_SUPPORTED_CHAIN_IDS,
BACKEND_SUPPORTED_CHAINS,
supportedChainIdFromGQLChain,
validateUrlChainParam,
} from 'graphql/data/util'
import { useOnClickOutside } from 'hooks/useOnClickOutside' import { useOnClickOutside } from 'hooks/useOnClickOutside'
import { useRef } from 'react' import { useRef } from 'react'
import { Check, ChevronDown, ChevronUp } from 'react-feather' import { Check, ChevronDown, ChevronUp } from 'react-feather'
...@@ -118,7 +122,6 @@ export default function NetworkFilter() { ...@@ -118,7 +122,6 @@ export default function NetworkFilter() {
const currentChainName = validateUrlChainParam(chainName) const currentChainName = validateUrlChainParam(chainName)
const chainInfo = getChainInfo(supportedChainIdFromGQLChain(currentChainName)) const chainInfo = getChainInfo(supportedChainIdFromGQLChain(currentChainName))
const BNBChainInfo = getChainInfo(supportedChainIdFromGQLChain(Chain.Bnb))
return ( return (
<StyledMenu ref={node}> <StyledMenu ref={node}>
...@@ -143,7 +146,7 @@ export default function NetworkFilter() { ...@@ -143,7 +146,7 @@ export default function NetworkFilter() {
</NetworkFilterOption> </NetworkFilterOption>
{open && ( {open && (
<MenuTimeFlyout> <MenuTimeFlyout>
{BACKEND_CHAIN_NAMES.map((network) => { {BACKEND_SUPPORTED_CHAINS.map((network) => {
const chainInfo = getChainInfo(supportedChainIdFromGQLChain(network)) const chainInfo = getChainInfo(supportedChainIdFromGQLChain(network))
return ( return (
<InternalLinkMenuItem <InternalLinkMenuItem
...@@ -166,13 +169,22 @@ export default function NetworkFilter() { ...@@ -166,13 +169,22 @@ export default function NetworkFilter() {
</InternalLinkMenuItem> </InternalLinkMenuItem>
) )
})} })}
<InternalLinkMenuItem data-testid="tokens-network-filter-option-bnb-chain" disabled> {BACKEND_NOT_YET_SUPPORTED_CHAIN_IDS.map((network) => {
<NetworkLabel> const chainInfo = getChainInfo(network)
<Logo src={BNBChainInfo.logoUrl} /> return (
{BNBChainInfo.label} <InternalLinkMenuItem
</NetworkLabel> key={network}
<Tag>Coming soon</Tag> data-testid={`tokens-network-filter-option-${network}-chain`}
</InternalLinkMenuItem> disabled
>
<NetworkLabel>
<Logo src={chainInfo.logoUrl} />
{chainInfo.label}
</NetworkLabel>
<Tag>Coming soon</Tag>
</InternalLinkMenuItem>
)
})}
</MenuTimeFlyout> </MenuTimeFlyout>
)} )}
</StyledMenu> </StyledMenu>
......
import { SupportedChainId } from 'constants/chains' import { ChainId } from '@uniswap/sdk-core'
import { Currency, TokenStandard } from 'graphql/data/__generated__/types-and-hooks' import { Currency, TokenStandard } from 'graphql/data/__generated__/types-and-hooks'
import { CHAIN_ID_TO_BACKEND_NAME } from 'graphql/data/util' import { CHAIN_ID_TO_BACKEND_NAME } from 'graphql/data/util'
import { render, screen } from 'test-utils/render' import { render, screen } from 'test-utils/render'
...@@ -72,7 +72,7 @@ describe('LoadedRow.tsx', () => { ...@@ -72,7 +72,7 @@ describe('LoadedRow.tsx', () => {
__typename: 'Token', __typename: 'Token',
id: 'VG9rZW46RVRIRVJFVU1fMHhBMGI4Njk5MWM2MjE4YjM2YzFkMTlENGEyZTlFYjBjRTM2MDZlQjQ4', id: 'VG9rZW46RVRIRVJFVU1fMHhBMGI4Njk5MWM2MjE4YjM2YzFkMTlENGEyZTlFYjBjRTM2MDZlQjQ4',
name: 'USD Coin', name: 'USD Coin',
chain: CHAIN_ID_TO_BACKEND_NAME[SupportedChainId.MAINNET], chain: CHAIN_ID_TO_BACKEND_NAME[ChainId.MAINNET],
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
symbol: 'USDC', symbol: 'USDC',
standard: TokenStandard.Erc20, standard: TokenStandard.Erc20,
...@@ -96,7 +96,7 @@ describe('LoadedRow.tsx', () => { ...@@ -96,7 +96,7 @@ describe('LoadedRow.tsx', () => {
__typename: 'Token', __typename: 'Token',
id: 'VG9rZW46RVRIRVJFVU1fMHhBMGI4Njk5MWM2MjE4YjM2YzFkMTlENGEyZTlFYjBjRTM2MDZlQjQ4', id: 'VG9rZW46RVRIRVJFVU1fMHhBMGI4Njk5MWM2MjE4YjM2YzFkMTlENGEyZTlFYjBjRTM2MDZlQjQ4',
name: 'USD Coin', name: 'USD Coin',
chain: CHAIN_ID_TO_BACKEND_NAME[SupportedChainId.MAINNET], chain: CHAIN_ID_TO_BACKEND_NAME[ChainId.MAINNET],
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
symbol: 'USDC', symbol: 'USDC',
standard: TokenStandard.Erc20, standard: TokenStandard.Erc20,
......
import { SupportedChainId } from 'constants/chains' import { ChainId } from '@uniswap/sdk-core'
export const MAX_WIDTH_MEDIA_BREAKPOINT = '1200px' export const MAX_WIDTH_MEDIA_BREAKPOINT = '1200px'
export const XLARGE_MEDIA_BREAKPOINT = '960px' export const XLARGE_MEDIA_BREAKPOINT = '960px'
...@@ -8,4 +8,4 @@ export const SMALL_MEDIA_BREAKPOINT = '540px' ...@@ -8,4 +8,4 @@ export const SMALL_MEDIA_BREAKPOINT = '540px'
export const MOBILE_MEDIA_BREAKPOINT = '420px' export const MOBILE_MEDIA_BREAKPOINT = '420px'
// includes chains that the backend does not current source off-chain metadata for // includes chains that the backend does not current source off-chain metadata for
export const UNSUPPORTED_METADATA_CHAINS = [SupportedChainId.BNB] export const UNSUPPORTED_METADATA_CHAINS = [ChainId.BNB, ChainId.AVALANCHE]
import { Trans } from '@lingui/macro' import { t, Trans } from '@lingui/macro'
import { Currency } from '@uniswap/sdk-core' import { ChainId, Currency } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import Badge from 'components/Badge' import Badge from 'components/Badge'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { SupportedChainId, SupportedL2ChainId } from 'constants/chains' import { SupportedL2ChainId } from 'constants/chains'
import useCurrencyLogoURIs from 'lib/hooks/useCurrencyLogoURIs' import useCurrencyLogoURIs from 'lib/hooks/useCurrencyLogoURIs'
import { ReactNode, useCallback, useState } from 'react' import { ReactNode, useCallback, useState } from 'react'
import { AlertCircle, ArrowUpCircle, CheckCircle } from 'react-feather' import { AlertCircle, ArrowUpCircle, CheckCircle } from 'react-feather'
...@@ -120,6 +120,8 @@ function TransactionSubmittedContent({ ...@@ -120,6 +120,8 @@ function TransactionSubmittedContent({
.catch(() => setSuccess(false)) .catch(() => setSuccess(false))
}, [connector, logoURL, token]) }, [connector, logoURL, token])
const explorerText = chainId === ChainId.MAINNET ? t`View on Etherscan` : t`View on Block Explorer`
return ( return (
<Wrapper> <Wrapper>
<AutoColumn> <AutoColumn>
...@@ -157,9 +159,7 @@ function TransactionSubmittedContent({ ...@@ -157,9 +159,7 @@ function TransactionSubmittedContent({
</ButtonPrimary> </ButtonPrimary>
{chainId && hash && ( {chainId && hash && (
<ExternalLink href={getExplorerLink(chainId, hash, ExplorerDataType.TRANSACTION)}> <ExternalLink href={getExplorerLink(chainId, hash, ExplorerDataType.TRANSACTION)}>
<ThemedText.Link color={theme.accentAction}> <ThemedText.Link color={theme.accentAction}>{explorerText}</ThemedText.Link>
<Trans>View on {chainId === SupportedChainId.MAINNET ? 'Etherscan' : 'Block Explorer'}</Trans>
</ThemedText.Link>
</ExternalLink> </ExternalLink>
)} )}
</ConfirmationModalContentWrapper> </ConfirmationModalContentWrapper>
......
...@@ -5,7 +5,7 @@ import { AutoRow } from 'components/Row' ...@@ -5,7 +5,7 @@ import { AutoRow } from 'components/Row'
import { getConnections, networkConnection } from 'connection' import { getConnections, networkConnection } from 'connection'
import { ActivationStatus, useActivationState } from 'connection/activate' import { ActivationStatus, useActivationState } from 'connection/activate'
import { ConnectionType } from 'connection/types' import { ConnectionType } from 'connection/types'
import { isSupportedChain } from 'constants/chains' import { asSupportedChain, isSupportedChain } from 'constants/chains'
import { useWalletConnectV2AsDefault } from 'featureFlags/flags/walletConnectV2' import { useWalletConnectV2AsDefault } from 'featureFlags/flags/walletConnectV2'
import { useEffect } from 'react' import { useEffect } from 'react'
import { Settings } from 'react-feather' import { Settings } from 'react-feather'
...@@ -55,7 +55,7 @@ export default function WalletModal({ openSettings }: { openSettings: () => void ...@@ -55,7 +55,7 @@ export default function WalletModal({ openSettings }: { openSettings: () => void
// Keep the network connector in sync with any active user connector to prevent chain-switching on wallet disconnection. // Keep the network connector in sync with any active user connector to prevent chain-switching on wallet disconnection.
useEffect(() => { useEffect(() => {
if (chainId && isSupportedChain(chainId) && connector !== networkConnection.connector) { if (chainId && isSupportedChain(chainId) && connector !== networkConnection.connector) {
networkConnection.connector.activate(chainId) networkConnection.connector.activate(asSupportedChain(chainId))
} }
}, [chainId, connector]) }, [chainId, connector])
......
import { t, Trans } from '@lingui/macro' import { t, Trans } from '@lingui/macro'
import { Currency } from '@uniswap/sdk-core' import { Currency } from '@uniswap/sdk-core'
import { ChainId } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { ColumnCenter } from 'components/Column' import { ColumnCenter } from 'components/Column'
import Column from 'components/Column' import Column from 'components/Column'
import Row from 'components/Row' import Row from 'components/Row'
import { SupportedChainId } from 'constants/chains'
import { useUnmountingAnimation } from 'hooks/useUnmountingAnimation' import { useUnmountingAnimation } from 'hooks/useUnmountingAnimation'
import { ReactNode, useRef } from 'react' import { ReactNode, useRef } from 'react'
import { InterfaceTrade } from 'state/routing/types' import { InterfaceTrade } from 'state/routing/types'
...@@ -212,7 +212,7 @@ export function PendingModalContent({ ...@@ -212,7 +212,7 @@ export function PendingModalContent({
} }
// On mainnet, we show the success icon once the tx is sent, since it takes longer to confirm than on L2s. // On mainnet, we show the success icon once the tx is sent, since it takes longer to confirm than on L2s.
const showSuccess = swapConfirmed || (swapPending && chainId === SupportedChainId.MAINNET) const showSuccess = swapConfirmed || (swapPending && chainId === ChainId.MAINNET)
return ( return (
<PendingModalContainer gap="lg"> <PendingModalContainer gap="lg">
......
import { SupportedChainId } from 'constants/chains' import { ChainId } from '@uniswap/sdk-core'
import { transparentize } from 'polished' import { transparentize } from 'polished'
import { ReactNode } from 'react' import { ReactNode } from 'react'
import { AlertTriangle } from 'react-feather' import { AlertTriangle } from 'react-feather'
...@@ -29,7 +29,7 @@ export const SwapWrapper = styled.main<{ chainId?: number }>` ...@@ -29,7 +29,7 @@ export const SwapWrapper = styled.main<{ chainId?: number }>`
border: 1px solid ${({ theme }) => theme.backgroundOutline}; border: 1px solid ${({ theme }) => theme.backgroundOutline};
padding: 8px; padding: 8px;
padding-top: 12px; padding-top: 12px;
box-shadow: ${({ chainId }) => !!chainId && chainId === SupportedChainId.BNB && '0px 40px 120px 0px #f0b90b29'}; box-shadow: ${({ chainId }) => !!chainId && chainId === ChainId.BNB && '0px 40px 120px 0px #f0b90b29'};
z-index: ${Z_INDEX.default}; z-index: ${Z_INDEX.default};
transition: transform 250ms ease; transition: transform 250ms ease;
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { ChainId } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { SupportedChainId } from 'constants/chains'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { ThemedText } from 'theme' import { ThemedText } from 'theme'
...@@ -38,7 +38,7 @@ const EmptyState = ({ HeaderContent, SubHeaderContent }: EmptyStateProps) => ( ...@@ -38,7 +38,7 @@ const EmptyState = ({ HeaderContent, SubHeaderContent }: EmptyStateProps) => (
export default function ProposalEmptyState() { export default function ProposalEmptyState() {
const { chainId } = useWeb3React() const { chainId } = useWeb3React()
if (chainId && chainId !== SupportedChainId.MAINNET) { if (chainId && chainId !== ChainId.MAINNET) {
return ( return (
<EmptyState <EmptyState
HeaderContent={() => <Trans>Please connect to Layer 1 Ethereum</Trans>} HeaderContent={() => <Trans>Please connect to Layer 1 Ethereum</Trans>}
......
import { sendAnalyticsEvent } from '@uniswap/analytics' import { sendAnalyticsEvent } from '@uniswap/analytics'
import { ChainId } from '@uniswap/sdk-core'
import { URI_AVAILABLE, WalletConnect, WalletConnectConstructorArgs } from '@web3-react/walletconnect-v2' import { URI_AVAILABLE, WalletConnect, WalletConnectConstructorArgs } from '@web3-react/walletconnect-v2'
import { L1_CHAIN_IDS, L2_CHAIN_IDS, SupportedChainId } from 'constants/chains' import { L1_CHAIN_IDS, L2_CHAIN_IDS } from 'constants/chains'
import { Z_INDEX } from 'theme/zIndex' import { Z_INDEX } from 'theme/zIndex'
import { isIOS } from 'utils/userAgent' import { isIOS } from 'utils/userAgent'
...@@ -69,7 +70,7 @@ export class UniwalletConnect extends WalletConnectV2 { ...@@ -69,7 +70,7 @@ export class UniwalletConnect extends WalletConnectV2 {
constructor({ actions, onError }: Omit<WalletConnectConstructorArgs, 'options'>) { constructor({ actions, onError }: Omit<WalletConnectConstructorArgs, 'options'>) {
// disables walletconnect's proprietary qr code modal; instead UniwalletModal will listen for events to trigger our custom modal // disables walletconnect's proprietary qr code modal; instead UniwalletModal will listen for events to trigger our custom modal
super({ actions, defaultChainId: SupportedChainId.MAINNET, qrcode: false, onError }) super({ actions, defaultChainId: ChainId.MAINNET, qrcode: false, onError })
this.events.once(URI_AVAILABLE, () => { this.events.once(URI_AVAILABLE, () => {
this.provider?.events.on('disconnect', this.deactivate) this.provider?.events.on('disconnect', this.deactivate)
......
import { ChainId } from '@uniswap/sdk-core'
import { Web3ReactHooks } from '@web3-react/core' import { Web3ReactHooks } from '@web3-react/core'
import { Connector } from '@web3-react/types' import { Connector } from '@web3-react/types'
import { SupportedChainId } from 'constants/chains'
import { useAppDispatch, useAppSelector } from 'state/hooks' import { useAppDispatch, useAppSelector } from 'state/hooks'
import { updateSelectedWallet } from 'state/user/reducer' import { updateSelectedWallet } from 'state/user/reducer'
import { createDeferredPromise } from 'test-utils/promise' import { createDeferredPromise } from 'test-utils/promise'
...@@ -67,11 +67,11 @@ it('Should call activate function on a connection', async () => { ...@@ -67,11 +67,11 @@ it('Should call activate function on a connection', async () => {
let activationCall: Promise<void> = new Promise(jest.fn()) let activationCall: Promise<void> = new Promise(jest.fn())
act(() => { act(() => {
activationCall = result.current.tryActivation(mockConnection, onSuccess, SupportedChainId.OPTIMISM) activationCall = result.current.tryActivation(mockConnection, onSuccess, ChainId.OPTIMISM)
}) })
expect(result.current.activationState).toEqual({ status: ActivationStatus.PENDING, connection: mockConnection }) expect(result.current.activationState).toEqual({ status: ActivationStatus.PENDING, connection: mockConnection })
expect(mockConnection.overrideActivate).toHaveBeenCalledWith(SupportedChainId.OPTIMISM) expect(mockConnection.overrideActivate).toHaveBeenCalledWith(ChainId.OPTIMISM)
expect(mockConnection.connector.activate).toHaveBeenCalledTimes(1) expect(mockConnection.connector.activate).toHaveBeenCalledTimes(1)
expect(console.debug).toHaveBeenLastCalledWith(`Connection activating: ${mockConnection.getName()}`) expect(console.debug).toHaveBeenLastCalledWith(`Connection activating: ${mockConnection.getName()}`)
expect(onSuccess).toHaveBeenCalledTimes(0) expect(onSuccess).toHaveBeenCalledTimes(0)
......
import { sendAnalyticsEvent } from '@uniswap/analytics' import { sendAnalyticsEvent } from '@uniswap/analytics'
import { InterfaceEventName, WalletConnectionResult } from '@uniswap/analytics-events' import { InterfaceEventName, WalletConnectionResult } from '@uniswap/analytics-events'
import { ChainId } from '@uniswap/sdk-core'
import { Connection } from 'connection/types' import { Connection } from 'connection/types'
import { SupportedChainId } from 'constants/chains'
import { atom } from 'jotai' import { atom } from 'jotai'
import { useAtomValue, useUpdateAtom } from 'jotai/utils' import { useAtomValue, useUpdateAtom } from 'jotai/utils'
import { useCallback } from 'react' import { useCallback } from 'react'
...@@ -32,7 +32,7 @@ function useTryActivation() { ...@@ -32,7 +32,7 @@ function useTryActivation() {
const currentPage = getCurrentPageFromLocation(pathname) const currentPage = getCurrentPageFromLocation(pathname)
return useCallback( return useCallback(
async (connection: Connection, onSuccess: () => void, chainId?: SupportedChainId) => { async (connection: Connection, onSuccess: () => void, chainId?: ChainId) => {
// Skips wallet connection if the connection should override the default // Skips wallet connection if the connection should override the default
// behavior, i.e. install MetaMask or launch Coinbase app // behavior, i.e. install MetaMask or launch Coinbase app
if (connection.overrideActivate?.(chainId)) return if (connection.overrideActivate?.(chainId)) return
......
import { ChainId } from '@uniswap/sdk-core'
import { CoinbaseWallet } from '@web3-react/coinbase-wallet' import { CoinbaseWallet } from '@web3-react/coinbase-wallet'
import { initializeConnector } from '@web3-react/core' import { initializeConnector } from '@web3-react/core'
import { GnosisSafe } from '@web3-react/gnosis-safe' import { GnosisSafe } from '@web3-react/gnosis-safe'
...@@ -9,7 +10,6 @@ import UNISWAP_LOGO from 'assets/svg/logo.svg' ...@@ -9,7 +10,6 @@ import UNISWAP_LOGO from 'assets/svg/logo.svg'
import COINBASE_ICON from 'assets/wallets/coinbase-icon.svg' import COINBASE_ICON from 'assets/wallets/coinbase-icon.svg'
import UNIWALLET_ICON from 'assets/wallets/uniswap-wallet-icon.png' import UNIWALLET_ICON from 'assets/wallets/uniswap-wallet-icon.png'
import WALLET_CONNECT_ICON from 'assets/wallets/walletconnect-icon.svg' import WALLET_CONNECT_ICON from 'assets/wallets/walletconnect-icon.svg'
import { SupportedChainId } from 'constants/chains'
import { isMobile, isNonIOSPhone } from 'utils/userAgent' import { isMobile, isNonIOSPhone } from 'utils/userAgent'
import { RPC_URLS } from '../constants/networks' import { RPC_URLS } from '../constants/networks'
...@@ -83,7 +83,7 @@ export const walletConnectV1Connection: Connection = { ...@@ -83,7 +83,7 @@ export const walletConnectV1Connection: Connection = {
} }
export const walletConnectV2Connection: Connection = new (class implements Connection { export const walletConnectV2Connection: Connection = new (class implements Connection {
private initializer = (actions: Actions, defaultChainId = SupportedChainId.MAINNET) => private initializer = (actions: Actions, defaultChainId = ChainId.MAINNET) =>
new WalletConnectV2({ actions, defaultChainId, onError }) new WalletConnectV2({ actions, defaultChainId, onError })
type = ConnectionType.WALLET_CONNECT_V2 type = ConnectionType.WALLET_CONNECT_V2
...@@ -92,7 +92,7 @@ export const walletConnectV2Connection: Connection = new (class implements Conne ...@@ -92,7 +92,7 @@ export const walletConnectV2Connection: Connection = new (class implements Conne
shouldDisplay = () => !getIsInjectedMobileBrowser() shouldDisplay = () => !getIsInjectedMobileBrowser()
private _connector = initializeConnector<WalletConnectV2>(this.initializer) private _connector = initializeConnector<WalletConnectV2>(this.initializer)
overrideActivate = (chainId?: SupportedChainId) => { overrideActivate = (chainId?: ChainId) => {
// Always re-create the connector, so that the chainId is updated. // Always re-create the connector, so that the chainId is updated.
this._connector = initializeConnector((actions) => this.initializer(actions, chainId)) this._connector = initializeConnector((actions) => this.initializer(actions, chainId))
return false return false
...@@ -136,7 +136,7 @@ const [web3CoinbaseWallet, web3CoinbaseWalletHooks] = initializeConnector<Coinba ...@@ -136,7 +136,7 @@ const [web3CoinbaseWallet, web3CoinbaseWalletHooks] = initializeConnector<Coinba
new CoinbaseWallet({ new CoinbaseWallet({
actions, actions,
options: { options: {
url: RPC_URLS[SupportedChainId.MAINNET][0], url: RPC_URLS[ChainId.MAINNET][0],
appName: 'Uniswap', appName: 'Uniswap',
appLogoUrl: UNISWAP_LOGO, appLogoUrl: UNISWAP_LOGO,
reloadOnDisconnect: false, reloadOnDisconnect: false,
......
import { ChainId } from '@uniswap/sdk-core'
import { Web3ReactHooks } from '@web3-react/core' import { Web3ReactHooks } from '@web3-react/core'
import { Connector } from '@web3-react/types' import { Connector } from '@web3-react/types'
import { SupportedChainId } from 'constants/chains'
export enum ConnectionType { export enum ConnectionType {
UNISWAP_WALLET = 'UNISWAP_WALLET', UNISWAP_WALLET = 'UNISWAP_WALLET',
...@@ -22,6 +22,6 @@ export interface Connection { ...@@ -22,6 +22,6 @@ export interface Connection {
type: ConnectionType type: ConnectionType
getIcon?(isDarkMode: boolean): string getIcon?(isDarkMode: boolean): string
shouldDisplay(): boolean shouldDisplay(): boolean
overrideActivate?: (chainId?: SupportedChainId) => boolean overrideActivate?: (chainId?: ChainId) => boolean
isNew?: boolean isNew?: boolean
} }
import { FACTORY_ADDRESS as V2_FACTORY_ADDRESS } from '@uniswap/v2-sdk'
import { FACTORY_ADDRESS as V3_FACTORY_ADDRESS } from '@uniswap/v3-sdk'
import { SupportedChainId } from './chains'
type AddressMap = { [chainId: number]: string }
const DEFAULT_NETWORKS = [SupportedChainId.MAINNET, SupportedChainId.GOERLI, SupportedChainId.SEPOLIA]
function constructSameAddressMap(address: string, additionalNetworks: SupportedChainId[] = []): AddressMap {
return DEFAULT_NETWORKS.concat(additionalNetworks).reduce<AddressMap>((memo, chainId) => {
memo[chainId] = address
return memo
}, {})
}
export const UNI_ADDRESS: AddressMap = constructSameAddressMap('0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984')
export const UNISWAP_NFT_AIRDROP_CLAIM_ADDRESS = '0x8B799381ac40b838BBA4131ffB26197C432AFe78'
export const V2_FACTORY_ADDRESSES: AddressMap = constructSameAddressMap(V2_FACTORY_ADDRESS)
export const V2_ROUTER_ADDRESS: AddressMap = constructSameAddressMap('0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D')
// celo v3 addresses
const CELO_V3_CORE_FACTORY_ADDRESSES = '0xAfE208a311B21f13EF87E33A90049fC17A7acDEc'
const CELO_V3_MIGRATOR_ADDRESSES = '0x3cFd4d48EDfDCC53D3f173F596f621064614C582'
const CELO_MULTICALL_ADDRESS = '0x633987602DE5C4F337e3DbF265303A1080324204'
const CELO_QUOTER_ADDRESSES = '0x82825d0554fA07f7FC52Ab63c961F330fdEFa8E8'
const CELO_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES = '0x3d79EdAaBC0EaB6F08ED885C05Fc0B014290D95A'
const CELO_TICK_LENS_ADDRESSES = '0x5f115D9113F88e0a0Db1b5033D90D4a9690AcD3D'
// BNB v3 addresses
const BNB_V3_CORE_FACTORY_ADDRESSES = '0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7'
const BNB_V3_MIGRATOR_ADDRESSES = '0x32681814957e0C13117ddc0c2aba232b5c9e760f'
const BNB_MULTICALL_ADDRESS = '0x963Df249eD09c358A4819E39d9Cd5736c3087184'
const BNB_QUOTER_ADDRESSES = '0x78D78E420Da98ad378D7799bE8f4AF69033EB077'
const BNB_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES = '0x7b8A01B39D58278b5DE7e48c8449c9f4F5170613'
const BNB_TICK_LENS_ADDRESSES = '0xD9270014D396281579760619CCf4c3af0501A47C'
// optimism goerli addresses
const OPTIMISM_GOERLI_V3_CORE_FACTORY_ADDRESSES = '0xB656dA17129e7EB733A557f4EBc57B76CFbB5d10'
const OPTIMISM_GOERLI_V3_MIGRATOR_ADDRESSES = '0xf6c55fBe84B1C8c3283533c53F51bC32F5C7Aba8'
const OPTIMISM_GOERLI_MULTICALL_ADDRESS = '0x07F2D8a2a02251B62af965f22fC4744A5f96BCCd'
const OPTIMISM_GOERLI_QUOTER_ADDRESSES = '0x9569CbA925c8ca2248772A9A4976A516743A246F'
const OPTIMISM_GOERLI_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES = '0x39Ca85Af2F383190cBf7d7c41ED9202D27426EF6'
const OPTIMISM_GOERLI_TICK_LENS_ADDRESSES = '0xe6140Bd164b63E8BfCfc40D5dF952f83e171758e'
// arbitrum goerli v3 addresses
const ARBITRUM_GOERLI_V3_CORE_FACTORY_ADDRESSES = '0x4893376342d5D7b3e31d4184c08b265e5aB2A3f6'
const ARBITRUM_GOERLI_V3_MIGRATOR_ADDRESSES = '0xA815919D2584Ac3F76ea9CB62E6Fd40a43BCe0C3'
const ARBITRUM_GOERLI_MULTICALL_ADDRESS = '0x8260CB40247290317a4c062F3542622367F206Ee'
const ARBITRUM_GOERLI_QUOTER_ADDRESSES = '0x1dd92b83591781D0C6d98d07391eea4b9a6008FA'
const ARBITRUM_GOERLI_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES = '0x622e4726a167799826d1E1D150b076A7725f5D81'
const ARBITRUM_GOERLI_TICK_LENS_ADDRESSES = '0xb52429333da969a0C79a60930a4Bf0020E5D1DE8'
// sepolia v3 addresses
const SEPOLIA_V3_CORE_FACTORY_ADDRESSES = '0x0227628f3F023bb0B980b67D528571c95c6DaC1c'
const SEPOLIA_V3_MIGRATOR_ADDRESSES = '0x729004182cF005CEC8Bd85df140094b6aCbe8b15'
const SEPOLIA_MULTICALL_ADDRESS = '0xD7F33bCdb21b359c8ee6F0251d30E94832baAd07'
const SEPOLIA_QUOTER_ADDRESSES = '0xEd1f6473345F45b75F8179591dd5bA1888cf2FB3'
const SEPOLIA_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES = '0x1238536071E1c677A632429e3655c799b22cDA52'
const SEPOLIA_TICK_LENS_ADDRESSES = '0xd7f33bcdb21b359c8ee6f0251d30e94832baad07'
/* V3 Contract Addresses */
export const V3_CORE_FACTORY_ADDRESSES: AddressMap = {
...constructSameAddressMap(V3_FACTORY_ADDRESS, [
SupportedChainId.OPTIMISM,
SupportedChainId.ARBITRUM_ONE,
SupportedChainId.POLYGON_MUMBAI,
SupportedChainId.POLYGON,
]),
[SupportedChainId.CELO]: CELO_V3_CORE_FACTORY_ADDRESSES,
[SupportedChainId.CELO_ALFAJORES]: CELO_V3_CORE_FACTORY_ADDRESSES,
[SupportedChainId.BNB]: BNB_V3_CORE_FACTORY_ADDRESSES,
[SupportedChainId.OPTIMISM_GOERLI]: OPTIMISM_GOERLI_V3_CORE_FACTORY_ADDRESSES,
[SupportedChainId.ARBITRUM_GOERLI]: ARBITRUM_GOERLI_V3_CORE_FACTORY_ADDRESSES,
[SupportedChainId.SEPOLIA]: SEPOLIA_V3_CORE_FACTORY_ADDRESSES,
}
export const V3_MIGRATOR_ADDRESSES: AddressMap = {
...constructSameAddressMap('0xA5644E29708357803b5A882D272c41cC0dF92B34', [
SupportedChainId.ARBITRUM_ONE,
SupportedChainId.POLYGON_MUMBAI,
SupportedChainId.POLYGON,
]),
[SupportedChainId.CELO]: CELO_V3_MIGRATOR_ADDRESSES,
[SupportedChainId.CELO_ALFAJORES]: CELO_V3_MIGRATOR_ADDRESSES,
[SupportedChainId.BNB]: BNB_V3_MIGRATOR_ADDRESSES,
[SupportedChainId.OPTIMISM_GOERLI]: OPTIMISM_GOERLI_V3_MIGRATOR_ADDRESSES,
[SupportedChainId.ARBITRUM_GOERLI]: ARBITRUM_GOERLI_V3_MIGRATOR_ADDRESSES,
[SupportedChainId.SEPOLIA]: SEPOLIA_V3_MIGRATOR_ADDRESSES,
}
export const MULTICALL_ADDRESS: AddressMap = {
...constructSameAddressMap('0x1F98415757620B543A52E61c46B32eB19261F984', [
SupportedChainId.OPTIMISM,
SupportedChainId.POLYGON_MUMBAI,
SupportedChainId.POLYGON,
]),
[SupportedChainId.ARBITRUM_ONE]: '0xadF885960B47eA2CD9B55E6DAc6B42b7Cb2806dB',
[SupportedChainId.CELO]: CELO_MULTICALL_ADDRESS,
[SupportedChainId.CELO_ALFAJORES]: CELO_MULTICALL_ADDRESS,
[SupportedChainId.BNB]: BNB_MULTICALL_ADDRESS,
[SupportedChainId.OPTIMISM_GOERLI]: OPTIMISM_GOERLI_MULTICALL_ADDRESS,
[SupportedChainId.ARBITRUM_GOERLI]: ARBITRUM_GOERLI_MULTICALL_ADDRESS,
[SupportedChainId.SEPOLIA]: SEPOLIA_MULTICALL_ADDRESS,
}
/**
* The oldest V0 governance address
*/
export const GOVERNANCE_ALPHA_V0_ADDRESSES: AddressMap = constructSameAddressMap(
'0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F'
)
/**
* The older V1 governance address
*/
export const GOVERNANCE_ALPHA_V1_ADDRESSES: AddressMap = {
[SupportedChainId.MAINNET]: '0xC4e172459f1E7939D522503B81AFAaC1014CE6F6',
}
/**
* The latest governor bravo that is currently admin of timelock
*/
export const GOVERNANCE_BRAVO_ADDRESSES: AddressMap = {
[SupportedChainId.MAINNET]: '0x408ED6354d4973f66138C91495F2f2FCbd8724C3',
}
export const TIMELOCK_ADDRESS: AddressMap = constructSameAddressMap('0x1a9C8182C09F50C8318d769245beA52c32BE35BC')
export const MERKLE_DISTRIBUTOR_ADDRESS: AddressMap = {
[SupportedChainId.MAINNET]: '0x090D4613473dEE047c3f2706764f49E0821D256e',
}
export const ARGENT_WALLET_DETECTOR_ADDRESS: AddressMap = {
[SupportedChainId.MAINNET]: '0xeca4B0bDBf7c55E9b7925919d03CbF8Dc82537E8',
}
export const QUOTER_ADDRESSES: AddressMap = {
...constructSameAddressMap('0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6', [
SupportedChainId.OPTIMISM,
SupportedChainId.ARBITRUM_ONE,
SupportedChainId.POLYGON_MUMBAI,
SupportedChainId.POLYGON,
]),
[SupportedChainId.CELO]: CELO_QUOTER_ADDRESSES,
[SupportedChainId.CELO_ALFAJORES]: CELO_QUOTER_ADDRESSES,
[SupportedChainId.BNB]: BNB_QUOTER_ADDRESSES,
[SupportedChainId.OPTIMISM_GOERLI]: OPTIMISM_GOERLI_QUOTER_ADDRESSES,
[SupportedChainId.ARBITRUM_GOERLI]: ARBITRUM_GOERLI_QUOTER_ADDRESSES,
[SupportedChainId.SEPOLIA]: SEPOLIA_QUOTER_ADDRESSES,
}
export const NONFUNGIBLE_POSITION_MANAGER_ADDRESSES: AddressMap = {
...constructSameAddressMap('0xC36442b4a4522E871399CD717aBDD847Ab11FE88', [
SupportedChainId.OPTIMISM,
SupportedChainId.ARBITRUM_ONE,
SupportedChainId.POLYGON_MUMBAI,
SupportedChainId.POLYGON,
]),
[SupportedChainId.CELO]: CELO_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES,
[SupportedChainId.CELO_ALFAJORES]: CELO_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES,
[SupportedChainId.BNB]: BNB_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES,
[SupportedChainId.OPTIMISM_GOERLI]: OPTIMISM_GOERLI_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES,
[SupportedChainId.ARBITRUM_GOERLI]: ARBITRUM_GOERLI_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES,
[SupportedChainId.SEPOLIA]: SEPOLIA_NONFUNGIBLE_POSITION_MANAGER_ADDRESSES,
}
export const ENS_REGISTRAR_ADDRESSES: AddressMap = {
[SupportedChainId.MAINNET]: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
[SupportedChainId.GOERLI]: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
}
export const SOCKS_CONTROLLER_ADDRESSES: AddressMap = {
[SupportedChainId.MAINNET]: '0x65770b5283117639760beA3F867b69b3697a91dd',
}
export const TICK_LENS_ADDRESSES: AddressMap = {
[SupportedChainId.ARBITRUM_ONE]: '0xbfd8137f7d1516D3ea5cA83523914859ec47F573',
[SupportedChainId.ARBITRUM_GOERLI]: ARBITRUM_GOERLI_TICK_LENS_ADDRESSES,
[SupportedChainId.CELO]: CELO_TICK_LENS_ADDRESSES,
[SupportedChainId.CELO_ALFAJORES]: CELO_TICK_LENS_ADDRESSES,
[SupportedChainId.BNB]: BNB_TICK_LENS_ADDRESSES,
[SupportedChainId.OPTIMISM_GOERLI]: OPTIMISM_GOERLI_TICK_LENS_ADDRESSES,
[SupportedChainId.SEPOLIA]: SEPOLIA_TICK_LENS_ADDRESSES,
}
import { ChainId } from '@uniswap/sdk-core'
import bnbCircleLogoUrl from 'assets/images/bnbCircle.svg' import bnbCircleLogoUrl from 'assets/images/bnbCircle.svg'
import ethereumLogoUrl from 'assets/images/ethereum-logo.png' import ethereumLogoUrl from 'assets/images/ethereum-logo.png'
import polygonCircleLogoUrl from 'assets/images/polygonCircle.png' import polygonCircleLogoUrl from 'assets/images/polygonCircle.png'
import { default as arbitrumCircleLogoUrl, default as arbitrumLogoUrl } from 'assets/svg/arbitrum_logo.svg' import { default as arbitrumCircleLogoUrl, default as arbitrumLogoUrl } from 'assets/svg/arbitrum_logo.svg'
import avaxLogo from 'assets/svg/avax_logo.svg'
import avaxSquareLogo from 'assets/svg/avax_square_logo.svg'
import bnbSquareLogoUrl from 'assets/svg/bnb_square_logo.svg' import bnbSquareLogoUrl from 'assets/svg/bnb_square_logo.svg'
import bnbLogo from 'assets/svg/bnb-logo.svg' import bnbLogo from 'assets/svg/bnb-logo.svg'
import celoLogo from 'assets/svg/celo_logo.svg' import celoLogo from 'assets/svg/celo_logo.svg'
...@@ -13,8 +16,8 @@ import polygonMaticLogo from 'assets/svg/polygon-matic-logo.svg' ...@@ -13,8 +16,8 @@ import polygonMaticLogo from 'assets/svg/polygon-matic-logo.svg'
import ms from 'ms.macro' import ms from 'ms.macro'
import { darkTheme } from 'theme/colors' import { darkTheme } from 'theme/colors'
import { SupportedChainId, SupportedL1ChainId, SupportedL2ChainId } from './chains' import { SupportedL1ChainId, SupportedL2ChainId } from './chains'
import { ARBITRUM_LIST, CELO_LIST, OPTIMISM_LIST, PLASMA_BNB_LIST } from './lists' import { ARBITRUM_LIST, AVALANCHE_LIST, CELO_LIST, OPTIMISM_LIST, PLASMA_BNB_LIST } from './lists'
export const AVERAGE_L1_BLOCK_TIME = ms`12s` export const AVERAGE_L1_BLOCK_TIME = ms`12s`
...@@ -60,7 +63,7 @@ type ChainInfoMap = { readonly [chainId: number]: L1ChainInfo | L2ChainInfo } & ...@@ -60,7 +63,7 @@ type ChainInfoMap = { readonly [chainId: number]: L1ChainInfo | L2ChainInfo } &
} & { readonly [chainId in SupportedL1ChainId]: L1ChainInfo } } & { readonly [chainId in SupportedL1ChainId]: L1ChainInfo }
const CHAIN_INFO: ChainInfoMap = { const CHAIN_INFO: ChainInfoMap = {
[SupportedChainId.MAINNET]: { [ChainId.MAINNET]: {
networkType: NetworkType.L1, networkType: NetworkType.L1,
docs: 'https://docs.uniswap.org/', docs: 'https://docs.uniswap.org/',
explorer: 'https://etherscan.io/', explorer: 'https://etherscan.io/',
...@@ -70,7 +73,7 @@ const CHAIN_INFO: ChainInfoMap = { ...@@ -70,7 +73,7 @@ const CHAIN_INFO: ChainInfoMap = {
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
color: darkTheme.chain_1, color: darkTheme.chain_1,
}, },
[SupportedChainId.GOERLI]: { [ChainId.GOERLI]: {
networkType: NetworkType.L1, networkType: NetworkType.L1,
docs: 'https://docs.uniswap.org/', docs: 'https://docs.uniswap.org/',
explorer: 'https://goerli.etherscan.io/', explorer: 'https://goerli.etherscan.io/',
...@@ -80,7 +83,7 @@ const CHAIN_INFO: ChainInfoMap = { ...@@ -80,7 +83,7 @@ const CHAIN_INFO: ChainInfoMap = {
nativeCurrency: { name: 'Görli Ether', symbol: 'görETH', decimals: 18 }, nativeCurrency: { name: 'Görli Ether', symbol: 'görETH', decimals: 18 },
color: darkTheme.chain_5, color: darkTheme.chain_5,
}, },
[SupportedChainId.SEPOLIA]: { [ChainId.SEPOLIA]: {
networkType: NetworkType.L1, networkType: NetworkType.L1,
docs: 'https://docs.uniswap.org/', docs: 'https://docs.uniswap.org/',
explorer: 'https://sepolia.etherscan.io/', explorer: 'https://sepolia.etherscan.io/',
...@@ -90,7 +93,7 @@ const CHAIN_INFO: ChainInfoMap = { ...@@ -90,7 +93,7 @@ const CHAIN_INFO: ChainInfoMap = {
nativeCurrency: { name: 'Sepolia Ether', symbol: 'SepoliaETH', decimals: 18 }, nativeCurrency: { name: 'Sepolia Ether', symbol: 'SepoliaETH', decimals: 18 },
color: darkTheme.chain_5, color: darkTheme.chain_5,
}, },
[SupportedChainId.OPTIMISM]: { [ChainId.OPTIMISM]: {
networkType: NetworkType.L2, networkType: NetworkType.L2,
blockWaitMsBeforeWarning: ms`25m`, blockWaitMsBeforeWarning: ms`25m`,
bridge: 'https://app.optimism.io/bridge', bridge: 'https://app.optimism.io/bridge',
...@@ -109,7 +112,7 @@ const CHAIN_INFO: ChainInfoMap = { ...@@ -109,7 +112,7 @@ const CHAIN_INFO: ChainInfoMap = {
color: darkTheme.chain_10, color: darkTheme.chain_10,
backgroundColor: darkTheme.chain_10_background, backgroundColor: darkTheme.chain_10_background,
}, },
[SupportedChainId.OPTIMISM_GOERLI]: { [ChainId.OPTIMISM_GOERLI]: {
networkType: NetworkType.L2, networkType: NetworkType.L2,
blockWaitMsBeforeWarning: ms`25m`, blockWaitMsBeforeWarning: ms`25m`,
bridge: 'https://app.optimism.io/bridge', bridge: 'https://app.optimism.io/bridge',
...@@ -124,7 +127,7 @@ const CHAIN_INFO: ChainInfoMap = { ...@@ -124,7 +127,7 @@ const CHAIN_INFO: ChainInfoMap = {
nativeCurrency: { name: 'Optimism Goerli Ether', symbol: 'görOpETH', decimals: 18 }, nativeCurrency: { name: 'Optimism Goerli Ether', symbol: 'görOpETH', decimals: 18 },
color: darkTheme.chain_420, color: darkTheme.chain_420,
}, },
[SupportedChainId.ARBITRUM_ONE]: { [ChainId.ARBITRUM_ONE]: {
networkType: NetworkType.L2, networkType: NetworkType.L2,
blockWaitMsBeforeWarning: ms`10m`, blockWaitMsBeforeWarning: ms`10m`,
bridge: 'https://bridge.arbitrum.io/', bridge: 'https://bridge.arbitrum.io/',
...@@ -140,7 +143,7 @@ const CHAIN_INFO: ChainInfoMap = { ...@@ -140,7 +143,7 @@ const CHAIN_INFO: ChainInfoMap = {
color: darkTheme.chain_42, color: darkTheme.chain_42,
backgroundColor: darkTheme.chain_42161_background, backgroundColor: darkTheme.chain_42161_background,
}, },
[SupportedChainId.ARBITRUM_GOERLI]: { [ChainId.ARBITRUM_GOERLI]: {
networkType: NetworkType.L2, networkType: NetworkType.L2,
blockWaitMsBeforeWarning: ms`10m`, blockWaitMsBeforeWarning: ms`10m`,
bridge: 'https://bridge.arbitrum.io/', bridge: 'https://bridge.arbitrum.io/',
...@@ -154,7 +157,7 @@ const CHAIN_INFO: ChainInfoMap = { ...@@ -154,7 +157,7 @@ const CHAIN_INFO: ChainInfoMap = {
nativeCurrency: { name: 'Goerli Arbitrum Ether', symbol: 'goerliArbETH', decimals: 18 }, nativeCurrency: { name: 'Goerli Arbitrum Ether', symbol: 'goerliArbETH', decimals: 18 },
color: darkTheme.chain_421613, color: darkTheme.chain_421613,
}, },
[SupportedChainId.POLYGON]: { [ChainId.POLYGON]: {
networkType: NetworkType.L1, networkType: NetworkType.L1,
blockWaitMsBeforeWarning: ms`10m`, blockWaitMsBeforeWarning: ms`10m`,
bridge: 'https://wallet.polygon.technology/polygon/bridge', bridge: 'https://wallet.polygon.technology/polygon/bridge',
...@@ -169,7 +172,7 @@ const CHAIN_INFO: ChainInfoMap = { ...@@ -169,7 +172,7 @@ const CHAIN_INFO: ChainInfoMap = {
color: darkTheme.chain_137, color: darkTheme.chain_137,
backgroundColor: darkTheme.chain_137_background, backgroundColor: darkTheme.chain_137_background,
}, },
[SupportedChainId.POLYGON_MUMBAI]: { [ChainId.POLYGON_MUMBAI]: {
networkType: NetworkType.L1, networkType: NetworkType.L1,
blockWaitMsBeforeWarning: ms`10m`, blockWaitMsBeforeWarning: ms`10m`,
bridge: 'https://wallet.polygon.technology/bridge', bridge: 'https://wallet.polygon.technology/bridge',
...@@ -180,7 +183,7 @@ const CHAIN_INFO: ChainInfoMap = { ...@@ -180,7 +183,7 @@ const CHAIN_INFO: ChainInfoMap = {
logoUrl: polygonMaticLogo, logoUrl: polygonMaticLogo,
nativeCurrency: { name: 'Polygon Mumbai Matic', symbol: 'mMATIC', decimals: 18 }, nativeCurrency: { name: 'Polygon Mumbai Matic', symbol: 'mMATIC', decimals: 18 },
}, },
[SupportedChainId.CELO]: { [ChainId.CELO]: {
networkType: NetworkType.L1, networkType: NetworkType.L1,
blockWaitMsBeforeWarning: ms`10m`, blockWaitMsBeforeWarning: ms`10m`,
bridge: 'https://www.portalbridge.com/#/transfer', bridge: 'https://www.portalbridge.com/#/transfer',
...@@ -194,7 +197,7 @@ const CHAIN_INFO: ChainInfoMap = { ...@@ -194,7 +197,7 @@ const CHAIN_INFO: ChainInfoMap = {
nativeCurrency: { name: 'Celo', symbol: 'CELO', decimals: 18 }, nativeCurrency: { name: 'Celo', symbol: 'CELO', decimals: 18 },
defaultListUrl: CELO_LIST, defaultListUrl: CELO_LIST,
}, },
[SupportedChainId.CELO_ALFAJORES]: { [ChainId.CELO_ALFAJORES]: {
networkType: NetworkType.L1, networkType: NetworkType.L1,
blockWaitMsBeforeWarning: ms`10m`, blockWaitMsBeforeWarning: ms`10m`,
bridge: 'https://www.portalbridge.com/#/transfer', bridge: 'https://www.portalbridge.com/#/transfer',
...@@ -206,7 +209,7 @@ const CHAIN_INFO: ChainInfoMap = { ...@@ -206,7 +209,7 @@ const CHAIN_INFO: ChainInfoMap = {
nativeCurrency: { name: 'Celo', symbol: 'CELO', decimals: 18 }, nativeCurrency: { name: 'Celo', symbol: 'CELO', decimals: 18 },
defaultListUrl: CELO_LIST, defaultListUrl: CELO_LIST,
}, },
[SupportedChainId.BNB]: { [ChainId.BNB]: {
networkType: NetworkType.L1, networkType: NetworkType.L1,
blockWaitMsBeforeWarning: ms`10m`, blockWaitMsBeforeWarning: ms`10m`,
bridge: 'https://cbridge.celer.network/1/56', bridge: 'https://cbridge.celer.network/1/56',
...@@ -222,20 +225,36 @@ const CHAIN_INFO: ChainInfoMap = { ...@@ -222,20 +225,36 @@ const CHAIN_INFO: ChainInfoMap = {
color: darkTheme.chain_56, color: darkTheme.chain_56,
backgroundColor: darkTheme.chain_56_background, backgroundColor: darkTheme.chain_56_background,
}, },
} [ChainId.AVALANCHE]: {
networkType: NetworkType.L1,
blockWaitMsBeforeWarning: ms`10m`,
bridge: 'https://core.app/bridge/',
docs: 'https://docs.avax.network/',
explorer: 'https://snowtrace.io/',
infoLink: 'https://info.uniswap.org/#/avax/', // TODO(WEB-2336): Add avax support to info site
label: 'Avalanche',
logoUrl: avaxLogo,
circleLogoUrl: avaxLogo,
squareLogoUrl: avaxSquareLogo,
nativeCurrency: { name: 'AVAX', symbol: 'AVAX', decimals: 18 },
defaultListUrl: AVALANCHE_LIST,
color: darkTheme.chain_43114,
backgroundColor: darkTheme.chain_43114_background,
},
} as const
export function getChainInfo(chainId: SupportedL1ChainId): L1ChainInfo export function getChainInfo(chainId: SupportedL1ChainId): L1ChainInfo
export function getChainInfo(chainId: SupportedL2ChainId): L2ChainInfo export function getChainInfo(chainId: SupportedL2ChainId): L2ChainInfo
export function getChainInfo(chainId: SupportedChainId): L1ChainInfo | L2ChainInfo export function getChainInfo(chainId: ChainId): L1ChainInfo | L2ChainInfo
export function getChainInfo( export function getChainInfo(
chainId: SupportedChainId | SupportedL1ChainId | SupportedL2ChainId | number | undefined chainId: ChainId | SupportedL1ChainId | SupportedL2ChainId | number | undefined
): L1ChainInfo | L2ChainInfo | undefined ): L1ChainInfo | L2ChainInfo | undefined
/** /**
* Overloaded method for returning ChainInfo given a chainID * Overloaded method for returning ChainInfo given a chainID
* Return type varies depending on input type: * Return type varies depending on input type:
* number | undefined -> returns chaininfo | undefined * number | undefined -> returns chaininfo | undefined
* SupportedChainId -> returns L1ChainInfo | L2ChainInfo * ChainId -> returns L1ChainInfo | L2ChainInfo
* SupportedL1ChainId -> returns L1ChainInfo * SupportedL1ChainId -> returns L1ChainInfo
* SupportedL2ChainId -> returns L2ChainInfo * SupportedL2ChainId -> returns L2ChainInfo
*/ */
...@@ -246,7 +265,7 @@ export function getChainInfo(chainId: any): any { ...@@ -246,7 +265,7 @@ export function getChainInfo(chainId: any): any {
return undefined return undefined
} }
const MAINNET_INFO = CHAIN_INFO[SupportedChainId.MAINNET] const MAINNET_INFO = CHAIN_INFO[ChainId.MAINNET]
export function getChainInfoOrDefault(chainId: number | undefined) { export function getChainInfoOrDefault(chainId: number | undefined) {
return getChainInfo(chainId) ?? MAINNET_INFO return getChainInfo(chainId) ?? MAINNET_INFO
} }
import { SupportedChainId as SdkSupportedChainId } from '@uniswap/sdk-core'
import { ALL_SUPPORTED_CHAIN_IDS, SupportedChainId } from './chains'
describe('ChainIds', () => {
describe('SupportedChainId', () => {
it('derives from sdk-core', () => {
const SDKChains = Object.values(SdkSupportedChainId)
.filter((chainId) => typeof chainId === 'number')
.map((value) => value.toString())
const InterfaceChains = Object.values(SupportedChainId)
.filter((chainId) => typeof chainId === 'number')
.map((value) => value.toString())
const isSubset = InterfaceChains.every((value) => SDKChains.includes(value))
expect(isSubset).toBe(true)
})
})
describe('ALL_SUPPORTED_CHAIN_IDS', () => {
it('contains all the values in the SupportedChainId enum', () => {
Object.values(SupportedChainId)
.filter((chainId) => typeof chainId === 'number')
.forEach((chainId) => {
expect(ALL_SUPPORTED_CHAIN_IDS.includes(chainId as number)).toBeTruthy()
})
})
it('contains no duplicates', () => {
const set = new Set<number>()
ALL_SUPPORTED_CHAIN_IDS.forEach((chainId) => {
expect(set.has(chainId)).toEqual(false)
set.add(chainId)
})
})
it('all values are in the SupportedChainId mapping', () => {
ALL_SUPPORTED_CHAIN_IDS.forEach((chainId) => {
// takes advantage of the reverse mapping
expect(SupportedChainId[chainId]).toBeTruthy()
})
})
it('all values are numeric', () => {
expect(ALL_SUPPORTED_CHAIN_IDS.every((chainId) => typeof chainId === 'number')).toBeTruthy()
})
})
})
/** import { ChainId, SUPPORTED_CHAINS, SupportedChainsType } from '@uniswap/sdk-core'
* SupportedChainId must be defined inline, without using @uniswap/sdk-core, so that its members are their own types
* {@see https://www.typescriptlang.org/docs/handbook/enums.html#union-enums-and-enum-member-types}. This allows the
* derived const arrays and their types (eg {@link L1_CHAIN_IDS}, {@link SupportedL1ChainId}) to be narrowed and used
* to enforce chain typing.
*
* Because this is not explicitly derived from @uniswap/sdk-core, there is a unit test to enforce conformance.
*/
export enum SupportedChainId {
MAINNET = 1,
GOERLI = 5,
SEPOLIA = 11155111,
ARBITRUM_ONE = 42161,
ARBITRUM_GOERLI = 421613,
OPTIMISM = 10,
OPTIMISM_GOERLI = 420,
POLYGON = 137,
POLYGON_MUMBAI = 80001,
CELO = 42220,
CELO_ALFAJORES = 44787,
BNB = 56, export const UniWalletSupportedChains = [ChainId.MAINNET, ChainId.ARBITRUM_ONE, ChainId.OPTIMISM, ChainId.POLYGON]
}
export const UniWalletSupportedChains = [
SupportedChainId.MAINNET,
SupportedChainId.ARBITRUM_ONE,
SupportedChainId.OPTIMISM,
SupportedChainId.POLYGON,
]
export const CHAIN_IDS_TO_NAMES = { export const CHAIN_IDS_TO_NAMES = {
[SupportedChainId.MAINNET]: 'mainnet', [ChainId.MAINNET]: 'mainnet',
[SupportedChainId.GOERLI]: 'goerli', [ChainId.GOERLI]: 'goerli',
[SupportedChainId.SEPOLIA]: 'sepolia', [ChainId.SEPOLIA]: 'sepolia',
[SupportedChainId.POLYGON]: 'polygon', [ChainId.POLYGON]: 'polygon',
[SupportedChainId.POLYGON_MUMBAI]: 'polygon_mumbai', [ChainId.POLYGON_MUMBAI]: 'polygon_mumbai',
[SupportedChainId.CELO]: 'celo', [ChainId.CELO]: 'celo',
[SupportedChainId.CELO_ALFAJORES]: 'celo_alfajores', [ChainId.CELO_ALFAJORES]: 'celo_alfajores',
[SupportedChainId.ARBITRUM_ONE]: 'arbitrum', [ChainId.ARBITRUM_ONE]: 'arbitrum',
[SupportedChainId.ARBITRUM_GOERLI]: 'arbitrum_goerli', [ChainId.ARBITRUM_GOERLI]: 'arbitrum_goerli',
[SupportedChainId.OPTIMISM]: 'optimism', [ChainId.OPTIMISM]: 'optimism',
[SupportedChainId.OPTIMISM_GOERLI]: 'optimism_goerli', [ChainId.OPTIMISM_GOERLI]: 'optimism_goerli',
[SupportedChainId.BNB]: 'bnb', [ChainId.BNB]: 'bnb',
[ChainId.AVALANCHE]: 'avalanche',
} as const
export function isSupportedChain(chainId: number | null | undefined | ChainId): chainId is SupportedChainsType {
return !!chainId && SUPPORTED_CHAINS.indexOf(chainId) !== -1
} }
/** export function asSupportedChain(chainId: number | null | undefined | ChainId): SupportedChainsType | undefined {
* Array of all the supported chain IDs return isSupportedChain(chainId) ? chainId : undefined
*/
export const ALL_SUPPORTED_CHAIN_IDS: SupportedChainId[] = Object.values(SupportedChainId).filter(
(id) => typeof id === 'number'
) as SupportedChainId[]
export function isSupportedChain(chainId: number | null | undefined): chainId is SupportedChainId {
return !!chainId && !!SupportedChainId[chainId]
} }
export const SUPPORTED_GAS_ESTIMATE_CHAIN_IDS = [ export const SUPPORTED_GAS_ESTIMATE_CHAIN_IDS = [
SupportedChainId.MAINNET, ChainId.MAINNET,
SupportedChainId.POLYGON, ChainId.POLYGON,
SupportedChainId.CELO, ChainId.CELO,
SupportedChainId.OPTIMISM, ChainId.OPTIMISM,
SupportedChainId.ARBITRUM_ONE, ChainId.ARBITRUM_ONE,
SupportedChainId.BNB, ChainId.BNB,
ChainId.AVALANCHE,
] as const ] as const
/** /**
* Unsupported networks for V2 pool behavior. * Unsupported networks for V2 pool behavior.
*/ */
export const UNSUPPORTED_V2POOL_CHAIN_IDS = [ export const UNSUPPORTED_V2POOL_CHAIN_IDS = [
SupportedChainId.POLYGON, ChainId.POLYGON,
SupportedChainId.OPTIMISM, ChainId.OPTIMISM,
SupportedChainId.ARBITRUM_ONE, ChainId.ARBITRUM_ONE,
SupportedChainId.BNB, ChainId.BNB,
SupportedChainId.ARBITRUM_GOERLI, ChainId.ARBITRUM_GOERLI,
ChainId.AVALANCHE,
] as const ] as const
export const TESTNET_CHAIN_IDS = new Set([ export const TESTNET_CHAIN_IDS = [
SupportedChainId.GOERLI, ChainId.GOERLI,
SupportedChainId.SEPOLIA, ChainId.SEPOLIA,
SupportedChainId.ARBITRUM_GOERLI, ChainId.POLYGON_MUMBAI,
SupportedChainId.OPTIMISM_GOERLI, ChainId.ARBITRUM_GOERLI,
SupportedChainId.POLYGON_MUMBAI, ChainId.OPTIMISM_GOERLI,
SupportedChainId.POLYGON_MUMBAI, ChainId.CELO_ALFAJORES,
SupportedChainId.CELO_ALFAJORES, ] as const
])
/** /**
* All the chain IDs that are running the Ethereum protocol. * All the chain IDs that are running the Ethereum protocol.
*/ */
export const L1_CHAIN_IDS = [ export const L1_CHAIN_IDS = [
SupportedChainId.MAINNET, ChainId.MAINNET,
SupportedChainId.GOERLI, ChainId.GOERLI,
SupportedChainId.SEPOLIA, ChainId.SEPOLIA,
SupportedChainId.POLYGON, ChainId.POLYGON,
SupportedChainId.POLYGON_MUMBAI, ChainId.POLYGON_MUMBAI,
SupportedChainId.CELO, ChainId.CELO,
SupportedChainId.CELO_ALFAJORES, ChainId.CELO_ALFAJORES,
SupportedChainId.BNB, ChainId.BNB,
ChainId.AVALANCHE,
] as const ] as const
export type SupportedL1ChainId = (typeof L1_CHAIN_IDS)[number] export type SupportedL1ChainId = (typeof L1_CHAIN_IDS)[number]
...@@ -110,14 +79,14 @@ export type SupportedL1ChainId = (typeof L1_CHAIN_IDS)[number] ...@@ -110,14 +79,14 @@ export type SupportedL1ChainId = (typeof L1_CHAIN_IDS)[number]
* The expectation is that all of these networks have immediate transaction confirmation. * The expectation is that all of these networks have immediate transaction confirmation.
*/ */
export const L2_CHAIN_IDS = [ export const L2_CHAIN_IDS = [
SupportedChainId.ARBITRUM_ONE, ChainId.ARBITRUM_ONE,
SupportedChainId.ARBITRUM_GOERLI, ChainId.ARBITRUM_GOERLI,
SupportedChainId.OPTIMISM, ChainId.OPTIMISM,
SupportedChainId.OPTIMISM_GOERLI, ChainId.OPTIMISM_GOERLI,
] as const ] as const
export type SupportedL2ChainId = (typeof L2_CHAIN_IDS)[number] export type SupportedL2ChainId = (typeof L2_CHAIN_IDS)[number]
export function isPolygonChain(chainId: number): chainId is SupportedChainId.POLYGON | SupportedChainId.POLYGON_MUMBAI { export function isPolygonChain(chainId: number): chainId is ChainId.POLYGON | ChainId.POLYGON_MUMBAI {
return chainId === SupportedChainId.POLYGON || chainId === SupportedChainId.POLYGON_MUMBAI return chainId === ChainId.POLYGON || chainId === ChainId.POLYGON_MUMBAI
} }
import { import {
ChainId,
GOVERNANCE_ALPHA_V0_ADDRESSES, GOVERNANCE_ALPHA_V0_ADDRESSES,
GOVERNANCE_ALPHA_V1_ADDRESSES, GOVERNANCE_ALPHA_V1_ADDRESSES,
GOVERNANCE_BRAVO_ADDRESSES, GOVERNANCE_BRAVO_ADDRESSES,
TIMELOCK_ADDRESS, TIMELOCK_ADDRESSES,
UNI_ADDRESS, UNI_ADDRESSES,
} from './addresses' } from '@uniswap/sdk-core'
import { SupportedChainId } from './chains'
export const COMMON_CONTRACT_NAMES: Record<number, { [address: string]: string }> = { export const COMMON_CONTRACT_NAMES: Record<number, { [address: string]: string }> = {
[SupportedChainId.MAINNET]: { [ChainId.MAINNET]: {
[UNI_ADDRESS[SupportedChainId.MAINNET]]: 'UNI', [UNI_ADDRESSES[ChainId.MAINNET]]: 'UNI',
[TIMELOCK_ADDRESS[SupportedChainId.MAINNET]]: 'Timelock', [TIMELOCK_ADDRESSES[ChainId.MAINNET]]: 'Timelock',
[GOVERNANCE_ALPHA_V0_ADDRESSES[SupportedChainId.MAINNET]]: 'Governance (V0)', [GOVERNANCE_ALPHA_V0_ADDRESSES[ChainId.MAINNET]]: 'Governance (V0)',
[GOVERNANCE_ALPHA_V1_ADDRESSES[SupportedChainId.MAINNET]]: 'Governance (V1)', [GOVERNANCE_ALPHA_V1_ADDRESSES[ChainId.MAINNET]]: 'Governance (V1)',
[GOVERNANCE_BRAVO_ADDRESSES[SupportedChainId.MAINNET]]: 'Governance', [GOVERNANCE_BRAVO_ADDRESSES[ChainId.MAINNET]]: 'Governance',
'0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e': 'ENS Registry', '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e': 'ENS Registry',
'0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41': 'ENS Public Resolver', '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41': 'ENS Public Resolver',
'0xf754A7E347F81cFdc70AF9FbCCe9Df3D826360FA': 'Franchiser Factory', '0xf754A7E347F81cFdc70AF9FbCCe9Df3D826360FA': 'Franchiser Factory',
......
...@@ -11,6 +11,7 @@ const COINGECKO_ARBITRUM_LIST = 'https://tokens.coingecko.com/arbitrum-one/all.j ...@@ -11,6 +11,7 @@ const COINGECKO_ARBITRUM_LIST = 'https://tokens.coingecko.com/arbitrum-one/all.j
const COINGECKO_OPTIMISM_LIST = 'https://tokens.coingecko.com/optimistic-ethereum/all.json' const COINGECKO_OPTIMISM_LIST = 'https://tokens.coingecko.com/optimistic-ethereum/all.json'
const COINGECKO_CELO_LIST = 'https://tokens.coingecko.com/celo/all.json' const COINGECKO_CELO_LIST = 'https://tokens.coingecko.com/celo/all.json'
const COINGECKO_POLYGON_LIST = 'https://tokens.coingecko.com/polygon-pos/all.json' const COINGECKO_POLYGON_LIST = 'https://tokens.coingecko.com/polygon-pos/all.json'
const COINGECKO_AVAX_LIST = 'https://tokens.coingecko.com/avalanche/all.json'
const COMPOUND_LIST = 'https://raw.githubusercontent.com/compound-finance/token-list/master/compound.tokenlist.json' const COMPOUND_LIST = 'https://raw.githubusercontent.com/compound-finance/token-list/master/compound.tokenlist.json'
const GEMINI_LIST = 'https://www.gemini.com/uniswap/manifest.json' const GEMINI_LIST = 'https://www.gemini.com/uniswap/manifest.json'
const KLEROS_LIST = 't2crtokens.eth' const KLEROS_LIST = 't2crtokens.eth'
...@@ -21,6 +22,8 @@ export const OPTIMISM_LIST = 'https://static.optimism.io/optimism.tokenlist.json ...@@ -21,6 +22,8 @@ export const OPTIMISM_LIST = 'https://static.optimism.io/optimism.tokenlist.json
export const ARBITRUM_LIST = 'https://bridge.arbitrum.io/token-list-42161.json' export const ARBITRUM_LIST = 'https://bridge.arbitrum.io/token-list-42161.json'
export const CELO_LIST = 'https://celo-org.github.io/celo-token-list/celo.tokenlist.json' export const CELO_LIST = 'https://celo-org.github.io/celo-token-list/celo.tokenlist.json'
export const PLASMA_BNB_LIST = 'https://raw.githubusercontent.com/plasmadlt/plasma-finance-token-list/master/bnb.json' export const PLASMA_BNB_LIST = 'https://raw.githubusercontent.com/plasmadlt/plasma-finance-token-list/master/bnb.json'
export const AVALANCHE_LIST =
'https://raw.githubusercontent.com/ava-labs/avalanche-bridge-resources/main/token_list.json'
export const UNSUPPORTED_LIST_URLS: string[] = [BA_LIST, UNI_UNSUPPORTED_LIST] export const UNSUPPORTED_LIST_URLS: string[] = [BA_LIST, UNI_UNSUPPORTED_LIST]
...@@ -37,6 +40,7 @@ export const DEFAULT_INACTIVE_LIST_URLS: string[] = [ ...@@ -37,6 +40,7 @@ export const DEFAULT_INACTIVE_LIST_URLS: string[] = [
COINGECKO_OPTIMISM_LIST, COINGECKO_OPTIMISM_LIST,
COINGECKO_CELO_LIST, COINGECKO_CELO_LIST,
COINGECKO_POLYGON_LIST, COINGECKO_POLYGON_LIST,
COINGECKO_AVAX_LIST,
KLEROS_LIST, KLEROS_LIST,
GEMINI_LIST, GEMINI_LIST,
WRAPPED_LIST, WRAPPED_LIST,
...@@ -45,6 +49,7 @@ export const DEFAULT_INACTIVE_LIST_URLS: string[] = [ ...@@ -45,6 +49,7 @@ export const DEFAULT_INACTIVE_LIST_URLS: string[] = [
OPTIMISM_LIST, OPTIMISM_LIST,
CELO_LIST, CELO_LIST,
PLASMA_BNB_LIST, PLASMA_BNB_LIST,
AVALANCHE_LIST,
...UNSUPPORTED_LIST_URLS, ...UNSUPPORTED_LIST_URLS,
] ]
......
import { SupportedChainId } from 'constants/chains' import { ChainId } from '@uniswap/sdk-core'
const INFURA_KEY = process.env.REACT_APP_INFURA_KEY const INFURA_KEY = process.env.REACT_APP_INFURA_KEY
if (typeof INFURA_KEY === 'undefined') { if (typeof INFURA_KEY === 'undefined') {
...@@ -20,7 +20,7 @@ if (typeof QUICKNODE_RPC_URL === 'undefined') { ...@@ -20,7 +20,7 @@ if (typeof QUICKNODE_RPC_URL === 'undefined') {
* These "Safe" URLs are listed first, followed by other fallback URLs, which are taken from chainlist.org. * These "Safe" URLs are listed first, followed by other fallback URLs, which are taken from chainlist.org.
*/ */
export const FALLBACK_URLS = { export const FALLBACK_URLS = {
[SupportedChainId.MAINNET]: [ [ChainId.MAINNET]: [
// "Safe" URLs // "Safe" URLs
'https://api.mycryptoapi.com/eth', 'https://api.mycryptoapi.com/eth',
'https://cloudflare-eth.com', 'https://cloudflare-eth.com',
...@@ -28,13 +28,13 @@ export const FALLBACK_URLS = { ...@@ -28,13 +28,13 @@ export const FALLBACK_URLS = {
'https://rpc.ankr.com/eth', 'https://rpc.ankr.com/eth',
'https://eth-mainnet.public.blastapi.io', 'https://eth-mainnet.public.blastapi.io',
], ],
[SupportedChainId.GOERLI]: [ [ChainId.GOERLI]: [
// "Safe" URLs // "Safe" URLs
'https://rpc.goerli.mudit.blog/', 'https://rpc.goerli.mudit.blog/',
// "Fallback" URLs // "Fallback" URLs
'https://rpc.ankr.com/eth_goerli', 'https://rpc.ankr.com/eth_goerli',
], ],
[SupportedChainId.SEPOLIA]: [ [ChainId.SEPOLIA]: [
// "Safe" URLs // "Safe" URLs
'https://rpc.sepolia.dev/', 'https://rpc.sepolia.dev/',
// "Fallback" URLs // "Fallback" URLs
...@@ -45,7 +45,7 @@ export const FALLBACK_URLS = { ...@@ -45,7 +45,7 @@ export const FALLBACK_URLS = {
'https://rpc-sepolia.rockx.com/', 'https://rpc-sepolia.rockx.com/',
'https://rpc.bordel.wtf/sepolia', 'https://rpc.bordel.wtf/sepolia',
], ],
[SupportedChainId.POLYGON]: [ [ChainId.POLYGON]: [
// "Safe" URLs // "Safe" URLs
'https://polygon-rpc.com/', 'https://polygon-rpc.com/',
'https://rpc-mainnet.matic.network', 'https://rpc-mainnet.matic.network',
...@@ -54,41 +54,41 @@ export const FALLBACK_URLS = { ...@@ -54,41 +54,41 @@ export const FALLBACK_URLS = {
'https://rpc-mainnet.matic.quiknode.pro', 'https://rpc-mainnet.matic.quiknode.pro',
'https://matic-mainnet-full-rpc.bwarelabs.com', 'https://matic-mainnet-full-rpc.bwarelabs.com',
], ],
[SupportedChainId.POLYGON_MUMBAI]: [ [ChainId.POLYGON_MUMBAI]: [
// "Safe" URLs // "Safe" URLs
'https://matic-mumbai.chainstacklabs.com', 'https://matic-mumbai.chainstacklabs.com',
'https://rpc-mumbai.maticvigil.com', 'https://rpc-mumbai.maticvigil.com',
'https://matic-testnet-archive-rpc.bwarelabs.com', 'https://matic-testnet-archive-rpc.bwarelabs.com',
], ],
[SupportedChainId.ARBITRUM_ONE]: [ [ChainId.ARBITRUM_ONE]: [
// "Safe" URLs // "Safe" URLs
'https://arb1.arbitrum.io/rpc', 'https://arb1.arbitrum.io/rpc',
// "Fallback" URLs // "Fallback" URLs
'https://arbitrum.public-rpc.com', 'https://arbitrum.public-rpc.com',
], ],
[SupportedChainId.ARBITRUM_GOERLI]: [ [ChainId.ARBITRUM_GOERLI]: [
// "Safe" URLs // "Safe" URLs
'https://goerli-rollup.arbitrum.io/rpc', 'https://goerli-rollup.arbitrum.io/rpc',
], ],
[SupportedChainId.OPTIMISM]: [ [ChainId.OPTIMISM]: [
// "Safe" URLs // "Safe" URLs
'https://mainnet.optimism.io/', 'https://mainnet.optimism.io/',
// "Fallback" URLs // "Fallback" URLs
'https://rpc.ankr.com/optimism', 'https://rpc.ankr.com/optimism',
], ],
[SupportedChainId.OPTIMISM_GOERLI]: [ [ChainId.OPTIMISM_GOERLI]: [
// "Safe" URLs // "Safe" URLs
'https://goerli.optimism.io', 'https://goerli.optimism.io',
], ],
[SupportedChainId.CELO]: [ [ChainId.CELO]: [
// "Safe" URLs // "Safe" URLs
`https://forno.celo.org`, `https://forno.celo.org`,
], ],
[SupportedChainId.CELO_ALFAJORES]: [ [ChainId.CELO_ALFAJORES]: [
// "Safe" URLs // "Safe" URLs
`https://alfajores-forno.celo-testnet.org`, `https://alfajores-forno.celo-testnet.org`,
], ],
[SupportedChainId.BNB]: [ [ChainId.BNB]: [
// "Safe" URLs // "Safe" URLs
'https://endpoints.omniatech.io/v1/bsc/mainnet/public', 'https://endpoints.omniatech.io/v1/bsc/mainnet/public',
'https://bsc-mainnet.gateway.pokt.network/v1/lb/6136201a7bad1500343e248d', 'https://bsc-mainnet.gateway.pokt.network/v1/lb/6136201a7bad1500343e248d',
...@@ -100,6 +100,15 @@ export const FALLBACK_URLS = { ...@@ -100,6 +100,15 @@ export const FALLBACK_URLS = {
'https://bsc-dataseed4.defibit.io', 'https://bsc-dataseed4.defibit.io',
'https://rpc.ankr.com/bsc', 'https://rpc.ankr.com/bsc',
], ],
[ChainId.AVALANCHE]: [
// "Safe" URLs
'https://api.avax.network/ext/bc/C/rpc',
'https://rpc.ankr.com/avalanche',
'https://avalanche.blockpi.network/v1/rpc/public',
'https://avalanche-c-chain.publicnode.com',
'https://endpoints.omniatech.io/v1/avax/mainnet/public',
'https://ava-mainnet.public.blastapi.io/ext/bc/C/rpc',
],
} }
/** /**
...@@ -107,40 +116,29 @@ export const FALLBACK_URLS = { ...@@ -107,40 +116,29 @@ export const FALLBACK_URLS = {
* These are the URLs used by the interface when there is not another available source of chain data. * These are the URLs used by the interface when there is not another available source of chain data.
*/ */
export const RPC_URLS = { export const RPC_URLS = {
[SupportedChainId.MAINNET]: [ [ChainId.MAINNET]: [`https://mainnet.infura.io/v3/${INFURA_KEY}`, ...FALLBACK_URLS[ChainId.MAINNET]],
`https://mainnet.infura.io/v3/${INFURA_KEY}`, [ChainId.GOERLI]: [`https://goerli.infura.io/v3/${INFURA_KEY}`, ...FALLBACK_URLS[ChainId.GOERLI]],
...FALLBACK_URLS[SupportedChainId.MAINNET], [ChainId.SEPOLIA]: [`https://sepolia.infura.io/v3/${INFURA_KEY}`, ...FALLBACK_URLS[ChainId.SEPOLIA]],
], [ChainId.OPTIMISM]: [`https://optimism-mainnet.infura.io/v3/${INFURA_KEY}`, ...FALLBACK_URLS[ChainId.OPTIMISM]],
[SupportedChainId.GOERLI]: [`https://goerli.infura.io/v3/${INFURA_KEY}`, ...FALLBACK_URLS[SupportedChainId.GOERLI]], [ChainId.OPTIMISM_GOERLI]: [
[SupportedChainId.SEPOLIA]: [
`https://sepolia.infura.io/v3/${INFURA_KEY}`,
...FALLBACK_URLS[SupportedChainId.SEPOLIA],
],
[SupportedChainId.OPTIMISM]: [
`https://optimism-mainnet.infura.io/v3/${INFURA_KEY}`,
...FALLBACK_URLS[SupportedChainId.OPTIMISM],
],
[SupportedChainId.OPTIMISM_GOERLI]: [
`https://optimism-goerli.infura.io/v3/${INFURA_KEY}`, `https://optimism-goerli.infura.io/v3/${INFURA_KEY}`,
...FALLBACK_URLS[SupportedChainId.OPTIMISM_GOERLI], ...FALLBACK_URLS[ChainId.OPTIMISM_GOERLI],
], ],
[SupportedChainId.ARBITRUM_ONE]: [ [ChainId.ARBITRUM_ONE]: [
`https://arbitrum-mainnet.infura.io/v3/${INFURA_KEY}`, `https://arbitrum-mainnet.infura.io/v3/${INFURA_KEY}`,
...FALLBACK_URLS[SupportedChainId.ARBITRUM_ONE], ...FALLBACK_URLS[ChainId.ARBITRUM_ONE],
], ],
[SupportedChainId.ARBITRUM_GOERLI]: [ [ChainId.ARBITRUM_GOERLI]: [
`https://arbitrum-goerli.infura.io/v3/${INFURA_KEY}`, `https://arbitrum-goerli.infura.io/v3/${INFURA_KEY}`,
...FALLBACK_URLS[SupportedChainId.ARBITRUM_GOERLI], ...FALLBACK_URLS[ChainId.ARBITRUM_GOERLI],
],
[SupportedChainId.POLYGON]: [
`https://polygon-mainnet.infura.io/v3/${INFURA_KEY}`,
...FALLBACK_URLS[SupportedChainId.POLYGON],
], ],
[SupportedChainId.POLYGON_MUMBAI]: [ [ChainId.POLYGON]: [`https://polygon-mainnet.infura.io/v3/${INFURA_KEY}`, ...FALLBACK_URLS[ChainId.POLYGON]],
[ChainId.POLYGON_MUMBAI]: [
`https://polygon-mumbai.infura.io/v3/${INFURA_KEY}`, `https://polygon-mumbai.infura.io/v3/${INFURA_KEY}`,
...FALLBACK_URLS[SupportedChainId.POLYGON_MUMBAI], ...FALLBACK_URLS[ChainId.POLYGON_MUMBAI],
], ],
[SupportedChainId.CELO]: FALLBACK_URLS[SupportedChainId.CELO], [ChainId.CELO]: FALLBACK_URLS[ChainId.CELO],
[SupportedChainId.CELO_ALFAJORES]: FALLBACK_URLS[SupportedChainId.CELO_ALFAJORES], [ChainId.CELO_ALFAJORES]: FALLBACK_URLS[ChainId.CELO_ALFAJORES],
[SupportedChainId.BNB]: [QUICKNODE_RPC_URL, ...FALLBACK_URLS[SupportedChainId.BNB]], [ChainId.BNB]: [QUICKNODE_RPC_URL, ...FALLBACK_URLS[ChainId.BNB]],
[ChainId.AVALANCHE]: [`https://avalanche-mainnet.infura.io/v3/${INFURA_KEY}`, ...FALLBACK_URLS[ChainId.AVALANCHE]],
} }
...@@ -3,7 +3,7 @@ import { deepCopy } from '@ethersproject/properties' ...@@ -3,7 +3,7 @@ import { deepCopy } from '@ethersproject/properties'
// eslint-disable-next-line @typescript-eslint/no-restricted-imports // eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { StaticJsonRpcProvider } from '@ethersproject/providers' import { StaticJsonRpcProvider } from '@ethersproject/providers'
import { isPlain } from '@reduxjs/toolkit' import { isPlain } from '@reduxjs/toolkit'
import { SupportedChainId } from 'constants/chains' import { ChainId, SupportedChainsType } from '@uniswap/sdk-core'
import { AVERAGE_L1_BLOCK_TIME } from './chainInfo' import { AVERAGE_L1_BLOCK_TIME } from './chainInfo'
import { CHAIN_IDS_TO_NAMES } from './chains' import { CHAIN_IDS_TO_NAMES } from './chains'
...@@ -20,7 +20,7 @@ class AppJsonRpcProvider extends StaticJsonRpcProvider { ...@@ -20,7 +20,7 @@ class AppJsonRpcProvider extends StaticJsonRpcProvider {
return this._blockCache return this._blockCache
} }
constructor(chainId: SupportedChainId) { constructor(chainId: SupportedChainsType) {
// Including networkish allows ethers to skip the initial detectNetwork call. // Including networkish allows ethers to skip the initial detectNetwork call.
super(RPC_URLS[chainId][0], /* networkish= */ { chainId, name: CHAIN_IDS_TO_NAMES[chainId] }) super(RPC_URLS[chainId][0], /* networkish= */ { chainId, name: CHAIN_IDS_TO_NAMES[chainId] })
...@@ -57,17 +57,18 @@ class AppJsonRpcProvider extends StaticJsonRpcProvider { ...@@ -57,17 +57,18 @@ class AppJsonRpcProvider extends StaticJsonRpcProvider {
/** /**
* These are the only JsonRpcProviders used directly by the interface. * These are the only JsonRpcProviders used directly by the interface.
*/ */
export const RPC_PROVIDERS: { [key in SupportedChainId]: StaticJsonRpcProvider } = { export const RPC_PROVIDERS: { [key in SupportedChainsType]: StaticJsonRpcProvider } = {
[SupportedChainId.MAINNET]: new AppJsonRpcProvider(SupportedChainId.MAINNET), [ChainId.MAINNET]: new AppJsonRpcProvider(ChainId.MAINNET),
[SupportedChainId.GOERLI]: new AppJsonRpcProvider(SupportedChainId.GOERLI), [ChainId.GOERLI]: new AppJsonRpcProvider(ChainId.GOERLI),
[SupportedChainId.SEPOLIA]: new AppJsonRpcProvider(SupportedChainId.SEPOLIA), [ChainId.SEPOLIA]: new AppJsonRpcProvider(ChainId.SEPOLIA),
[SupportedChainId.OPTIMISM]: new AppJsonRpcProvider(SupportedChainId.OPTIMISM), [ChainId.OPTIMISM]: new AppJsonRpcProvider(ChainId.OPTIMISM),
[SupportedChainId.OPTIMISM_GOERLI]: new AppJsonRpcProvider(SupportedChainId.OPTIMISM_GOERLI), [ChainId.OPTIMISM_GOERLI]: new AppJsonRpcProvider(ChainId.OPTIMISM_GOERLI),
[SupportedChainId.ARBITRUM_ONE]: new AppJsonRpcProvider(SupportedChainId.ARBITRUM_ONE), [ChainId.ARBITRUM_ONE]: new AppJsonRpcProvider(ChainId.ARBITRUM_ONE),
[SupportedChainId.ARBITRUM_GOERLI]: new AppJsonRpcProvider(SupportedChainId.ARBITRUM_GOERLI), [ChainId.ARBITRUM_GOERLI]: new AppJsonRpcProvider(ChainId.ARBITRUM_GOERLI),
[SupportedChainId.POLYGON]: new AppJsonRpcProvider(SupportedChainId.POLYGON), [ChainId.POLYGON]: new AppJsonRpcProvider(ChainId.POLYGON),
[SupportedChainId.POLYGON_MUMBAI]: new AppJsonRpcProvider(SupportedChainId.POLYGON_MUMBAI), [ChainId.POLYGON_MUMBAI]: new AppJsonRpcProvider(ChainId.POLYGON_MUMBAI),
[SupportedChainId.CELO]: new AppJsonRpcProvider(SupportedChainId.CELO), [ChainId.CELO]: new AppJsonRpcProvider(ChainId.CELO),
[SupportedChainId.CELO_ALFAJORES]: new AppJsonRpcProvider(SupportedChainId.CELO_ALFAJORES), [ChainId.CELO_ALFAJORES]: new AppJsonRpcProvider(ChainId.CELO_ALFAJORES),
[SupportedChainId.BNB]: new AppJsonRpcProvider(SupportedChainId.BNB), [ChainId.BNB]: new AppJsonRpcProvider(ChainId.BNB),
[ChainId.AVALANCHE]: new AppJsonRpcProvider(ChainId.AVALANCHE),
} }
import { SupportedChainId } from './chains' import { ChainId } from '@uniswap/sdk-core'
import { COMMON_BASES } from './routing' import { COMMON_BASES } from './routing'
describe('Routing', () => { describe('Routing', () => {
describe('COMMON_BASES', () => { describe('COMMON_BASES', () => {
it('contains all coins for mainnet', () => { it('contains all coins for mainnet', () => {
const symbols = COMMON_BASES[SupportedChainId.MAINNET].map((coin) => coin.symbol) const symbols = COMMON_BASES[ChainId.MAINNET].map((coin) => coin.symbol)
expect(symbols).toEqual(['ETH', 'DAI', 'USDC', 'USDT', 'WBTC', 'WETH']) expect(symbols).toEqual(['ETH', 'DAI', 'USDC', 'USDT', 'WBTC', 'WETH'])
}) })
it('contains all coins for arbitrum', () => { it('contains all coins for arbitrum', () => {
const symbols = COMMON_BASES[SupportedChainId.ARBITRUM_ONE].map((coin) => coin.symbol) const symbols = COMMON_BASES[ChainId.ARBITRUM_ONE].map((coin) => coin.symbol)
expect(symbols).toEqual(['ETH', 'ARB', 'DAI', 'USDC', 'USDT', 'WBTC', 'WETH']) expect(symbols).toEqual(['ETH', 'ARB', 'DAI', 'USDC', 'USDT', 'WBTC', 'WETH'])
}) })
it('contains all coins for optimism', () => { it('contains all coins for optimism', () => {
const symbols = COMMON_BASES[SupportedChainId.OPTIMISM].map((coin) => coin.symbol) const symbols = COMMON_BASES[ChainId.OPTIMISM].map((coin) => coin.symbol)
expect(symbols).toEqual(['ETH', 'OP', 'DAI', 'USDC', 'USDT', 'WBTC']) expect(symbols).toEqual(['ETH', 'OP', 'DAI', 'USDC', 'USDT', 'WBTC'])
}) })
it('contains all coins for polygon', () => { it('contains all coins for polygon', () => {
const symbols = COMMON_BASES[SupportedChainId.POLYGON].map((coin) => coin.symbol) const symbols = COMMON_BASES[ChainId.POLYGON].map((coin) => coin.symbol)
expect(symbols).toEqual(['MATIC', 'WETH', 'USDC', 'DAI', 'USDT', 'WBTC']) expect(symbols).toEqual(['MATIC', 'WETH', 'USDC', 'DAI', 'USDT', 'WBTC'])
}) })
it('contains all coins for celo', () => { it('contains all coins for celo', () => {
const symbols = COMMON_BASES[SupportedChainId.CELO].map((coin) => coin.symbol) const symbols = COMMON_BASES[ChainId.CELO].map((coin) => coin.symbol)
expect(symbols).toEqual(['CELO', 'cEUR', 'cUSD', 'ETH', 'USDCet', 'cMCO2']) expect(symbols).toEqual(['CELO', 'cEUR', 'cUSD', 'ETH', 'USDCet', 'cMCO2'])
}) })
it('contains all coins for bsc', () => { it('contains all coins for bsc', () => {
const symbols = COMMON_BASES[SupportedChainId.BNB].map((coin) => coin.symbol) const symbols = COMMON_BASES[ChainId.BNB].map((coin) => coin.symbol)
expect(symbols).toEqual(['BNB', 'DAI', 'USDC', 'USDT', 'ETH', 'BTCB', 'BUSD']) expect(symbols).toEqual(['BNB', 'DAI', 'USDC', 'USDT', 'ETH', 'BTCB', 'BUSD'])
}) })
}) })
......
// a list of tokens by chain // a list of tokens by chain
import { Currency, Token } from '@uniswap/sdk-core' import { ChainId, Currency, Token } from '@uniswap/sdk-core'
import { SupportedChainId } from 'constants/chains'
import { import {
AMPL, AMPL,
...@@ -15,6 +14,7 @@ import { ...@@ -15,6 +14,7 @@ import {
CUSD_CELO_ALFAJORES, CUSD_CELO_ALFAJORES,
DAI, DAI,
DAI_ARBITRUM_ONE, DAI_ARBITRUM_ONE,
DAI_AVALANCHE,
DAI_BSC, DAI_BSC,
DAI_OPTIMISM, DAI_OPTIMISM,
DAI_POLYGON, DAI_POLYGON,
...@@ -36,12 +36,14 @@ import { ...@@ -36,12 +36,14 @@ import {
TRIBE, TRIBE,
USDC_ARBITRUM, USDC_ARBITRUM,
USDC_ARBITRUM_GOERLI, USDC_ARBITRUM_GOERLI,
USDC_AVALANCHE,
USDC_BSC, USDC_BSC,
USDC_MAINNET, USDC_MAINNET,
USDC_OPTIMISM, USDC_OPTIMISM,
USDC_POLYGON, USDC_POLYGON,
USDT, USDT,
USDT_ARBITRUM_ONE, USDT_ARBITRUM_ONE,
USDT_AVALANCHE,
USDT_BSC, USDT_BSC,
USDT_OPTIMISM, USDT_OPTIMISM,
USDT_POLYGON, USDT_POLYGON,
...@@ -49,6 +51,7 @@ import { ...@@ -49,6 +51,7 @@ import {
WBTC_ARBITRUM_ONE, WBTC_ARBITRUM_ONE,
WBTC_OPTIMISM, WBTC_OPTIMISM,
WBTC_POLYGON, WBTC_POLYGON,
WETH_AVALANCHE,
WETH_POLYGON, WETH_POLYGON,
WETH_POLYGON_MUMBAI, WETH_POLYGON_MUMBAI,
WRAPPED_NATIVE_CURRENCY, WRAPPED_NATIVE_CURRENCY,
...@@ -71,34 +74,23 @@ const WRAPPED_NATIVE_CURRENCIES_ONLY: ChainTokenList = Object.fromEntries( ...@@ -71,34 +74,23 @@ const WRAPPED_NATIVE_CURRENCIES_ONLY: ChainTokenList = Object.fromEntries(
// used to construct intermediary pairs for trading // used to construct intermediary pairs for trading
export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = { export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
...WRAPPED_NATIVE_CURRENCIES_ONLY, ...WRAPPED_NATIVE_CURRENCIES_ONLY,
[SupportedChainId.MAINNET]: [ [ChainId.MAINNET]: [...WRAPPED_NATIVE_CURRENCIES_ONLY[ChainId.MAINNET], DAI, USDC_MAINNET, USDT, WBTC],
...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.MAINNET], [ChainId.OPTIMISM]: [...WRAPPED_NATIVE_CURRENCIES_ONLY[ChainId.OPTIMISM], DAI_OPTIMISM, USDT_OPTIMISM, WBTC_OPTIMISM],
DAI, [ChainId.ARBITRUM_ONE]: [
USDC_MAINNET, ...WRAPPED_NATIVE_CURRENCIES_ONLY[ChainId.ARBITRUM_ONE],
USDT,
WBTC,
],
[SupportedChainId.OPTIMISM]: [
...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.OPTIMISM],
DAI_OPTIMISM,
USDT_OPTIMISM,
WBTC_OPTIMISM,
],
[SupportedChainId.ARBITRUM_ONE]: [
...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.ARBITRUM_ONE],
DAI_ARBITRUM_ONE, DAI_ARBITRUM_ONE,
USDT_ARBITRUM_ONE, USDT_ARBITRUM_ONE,
WBTC_ARBITRUM_ONE, WBTC_ARBITRUM_ONE,
], ],
[SupportedChainId.POLYGON]: [ [ChainId.POLYGON]: [
...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.POLYGON], ...WRAPPED_NATIVE_CURRENCIES_ONLY[ChainId.POLYGON],
DAI_POLYGON, DAI_POLYGON,
USDC_POLYGON, USDC_POLYGON,
USDT_POLYGON, USDT_POLYGON,
WETH_POLYGON, WETH_POLYGON,
], ],
[SupportedChainId.BNB]: [ [ChainId.BNB]: [
...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.BNB], ...WRAPPED_NATIVE_CURRENCIES_ONLY[ChainId.BNB],
DAI_BSC, DAI_BSC,
USDC_BSC, USDC_BSC,
USDT_BSC, USDT_BSC,
...@@ -107,10 +99,17 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = { ...@@ -107,10 +99,17 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
MATIC_BSC, MATIC_BSC,
CAKE_BSC, CAKE_BSC,
], ],
[SupportedChainId.CELO]: [CUSD_CELO, CEUR_CELO, CMC02_CELO, PORTAL_USDC_CELO, PORTAL_ETH_CELO], [ChainId.AVALANCHE]: [
...WRAPPED_NATIVE_CURRENCIES_ONLY[ChainId.AVALANCHE],
DAI_AVALANCHE,
USDC_AVALANCHE,
USDT_AVALANCHE,
WETH_AVALANCHE,
],
[ChainId.CELO]: [CUSD_CELO, CEUR_CELO, CMC02_CELO, PORTAL_USDC_CELO, PORTAL_ETH_CELO],
} }
export const ADDITIONAL_BASES: { [chainId: number]: { [tokenAddress: string]: Token[] } } = { export const ADDITIONAL_BASES: { [chainId: number]: { [tokenAddress: string]: Token[] } } = {
[SupportedChainId.MAINNET]: { [ChainId.MAINNET]: {
'0xF16E4d813f4DcfDe4c5b44f305c908742De84eF0': [ETH2X_FLI], '0xF16E4d813f4DcfDe4c5b44f305c908742De84eF0': [ETH2X_FLI],
[rETH2.address]: [sETH2], [rETH2.address]: [sETH2],
[SWISE.address]: [sETH2], [SWISE.address]: [sETH2],
...@@ -127,8 +126,8 @@ export const ADDITIONAL_BASES: { [chainId: number]: { [tokenAddress: string]: To ...@@ -127,8 +126,8 @@ export const ADDITIONAL_BASES: { [chainId: number]: { [tokenAddress: string]: To
* tokens. * tokens.
*/ */
export const CUSTOM_BASES: { [chainId: number]: { [tokenAddress: string]: Token[] } } = { export const CUSTOM_BASES: { [chainId: number]: { [tokenAddress: string]: Token[] } } = {
[SupportedChainId.MAINNET]: { [ChainId.MAINNET]: {
[AMPL.address]: [DAI, WRAPPED_NATIVE_CURRENCY[SupportedChainId.MAINNET] as Token], [AMPL.address]: [DAI, WRAPPED_NATIVE_CURRENCY[ChainId.MAINNET] as Token],
}, },
} }
...@@ -136,96 +135,65 @@ export const CUSTOM_BASES: { [chainId: number]: { [tokenAddress: string]: Token[ ...@@ -136,96 +135,65 @@ export const CUSTOM_BASES: { [chainId: number]: { [tokenAddress: string]: Token[
* Shows up in the currency select for swap and add liquidity * Shows up in the currency select for swap and add liquidity
*/ */
export const COMMON_BASES: ChainCurrencyList = { export const COMMON_BASES: ChainCurrencyList = {
[SupportedChainId.MAINNET]: [ [ChainId.MAINNET]: [
nativeOnChain(SupportedChainId.MAINNET), nativeOnChain(ChainId.MAINNET),
DAI, DAI,
USDC_MAINNET, USDC_MAINNET,
USDT, USDT,
WBTC, WBTC,
WRAPPED_NATIVE_CURRENCY[SupportedChainId.MAINNET] as Token, WRAPPED_NATIVE_CURRENCY[ChainId.MAINNET] as Token,
],
[SupportedChainId.GOERLI]: [
nativeOnChain(SupportedChainId.GOERLI),
WRAPPED_NATIVE_CURRENCY[SupportedChainId.GOERLI] as Token,
],
[SupportedChainId.SEPOLIA]: [
nativeOnChain(SupportedChainId.SEPOLIA),
WRAPPED_NATIVE_CURRENCY[SupportedChainId.SEPOLIA] as Token,
], ],
[SupportedChainId.ARBITRUM_ONE]: [ [ChainId.GOERLI]: [nativeOnChain(ChainId.GOERLI), WRAPPED_NATIVE_CURRENCY[ChainId.GOERLI] as Token],
nativeOnChain(SupportedChainId.ARBITRUM_ONE), [ChainId.SEPOLIA]: [nativeOnChain(ChainId.SEPOLIA), WRAPPED_NATIVE_CURRENCY[ChainId.SEPOLIA] as Token],
[ChainId.ARBITRUM_ONE]: [
nativeOnChain(ChainId.ARBITRUM_ONE),
ARB, ARB,
DAI_ARBITRUM_ONE, DAI_ARBITRUM_ONE,
USDC_ARBITRUM, USDC_ARBITRUM,
USDT_ARBITRUM_ONE, USDT_ARBITRUM_ONE,
WBTC_ARBITRUM_ONE, WBTC_ARBITRUM_ONE,
WRAPPED_NATIVE_CURRENCY[SupportedChainId.ARBITRUM_ONE] as Token, WRAPPED_NATIVE_CURRENCY[ChainId.ARBITRUM_ONE] as Token,
], ],
[SupportedChainId.ARBITRUM_GOERLI]: [ [ChainId.ARBITRUM_GOERLI]: [
nativeOnChain(SupportedChainId.ARBITRUM_GOERLI), nativeOnChain(ChainId.ARBITRUM_GOERLI),
WRAPPED_NATIVE_CURRENCY[SupportedChainId.ARBITRUM_GOERLI] as Token, WRAPPED_NATIVE_CURRENCY[ChainId.ARBITRUM_GOERLI] as Token,
USDC_ARBITRUM_GOERLI, USDC_ARBITRUM_GOERLI,
], ],
[SupportedChainId.OPTIMISM]: [ [ChainId.OPTIMISM]: [nativeOnChain(ChainId.OPTIMISM), OP, DAI_OPTIMISM, USDC_OPTIMISM, USDT_OPTIMISM, WBTC_OPTIMISM],
nativeOnChain(SupportedChainId.OPTIMISM), [ChainId.OPTIMISM_GOERLI]: [nativeOnChain(ChainId.OPTIMISM_GOERLI)],
OP, [ChainId.POLYGON]: [
DAI_OPTIMISM, nativeOnChain(ChainId.POLYGON),
USDC_OPTIMISM,
USDT_OPTIMISM,
WBTC_OPTIMISM,
],
[SupportedChainId.OPTIMISM_GOERLI]: [nativeOnChain(SupportedChainId.OPTIMISM_GOERLI)],
[SupportedChainId.POLYGON]: [
nativeOnChain(SupportedChainId.POLYGON),
WETH_POLYGON, WETH_POLYGON,
USDC_POLYGON, USDC_POLYGON,
DAI_POLYGON, DAI_POLYGON,
USDT_POLYGON, USDT_POLYGON,
WBTC_POLYGON, WBTC_POLYGON,
], ],
[SupportedChainId.POLYGON_MUMBAI]: [ [ChainId.POLYGON_MUMBAI]: [
nativeOnChain(SupportedChainId.POLYGON_MUMBAI), nativeOnChain(ChainId.POLYGON_MUMBAI),
WRAPPED_NATIVE_CURRENCY[SupportedChainId.POLYGON_MUMBAI] as Token, WRAPPED_NATIVE_CURRENCY[ChainId.POLYGON_MUMBAI] as Token,
WETH_POLYGON_MUMBAI, WETH_POLYGON_MUMBAI,
], ],
[SupportedChainId.CELO]: [ [ChainId.CELO]: [nativeOnChain(ChainId.CELO), CEUR_CELO, CUSD_CELO, PORTAL_ETH_CELO, PORTAL_USDC_CELO, CMC02_CELO],
nativeOnChain(SupportedChainId.CELO), [ChainId.CELO_ALFAJORES]: [nativeOnChain(ChainId.CELO_ALFAJORES), CUSD_CELO_ALFAJORES, CEUR_CELO_ALFAJORES],
CEUR_CELO,
CUSD_CELO,
PORTAL_ETH_CELO,
PORTAL_USDC_CELO,
CMC02_CELO,
],
[SupportedChainId.CELO_ALFAJORES]: [
nativeOnChain(SupportedChainId.CELO_ALFAJORES),
CUSD_CELO_ALFAJORES,
CEUR_CELO_ALFAJORES,
],
[SupportedChainId.BNB]: [ [ChainId.BNB]: [nativeOnChain(ChainId.BNB), DAI_BSC, USDC_BSC, USDT_BSC, ETH_BSC, BTC_BSC, BUSD_BSC],
nativeOnChain(SupportedChainId.BNB), [ChainId.AVALANCHE]: [
DAI_BSC, nativeOnChain(ChainId.AVALANCHE),
USDC_BSC, DAI_AVALANCHE,
USDT_BSC, USDC_AVALANCHE,
ETH_BSC, USDT_AVALANCHE,
BTC_BSC, WETH_AVALANCHE,
BUSD_BSC,
], ],
} }
// used to construct the list of all pairs we consider by default in the frontend // used to construct the list of all pairs we consider by default in the frontend
export const BASES_TO_TRACK_LIQUIDITY_FOR: ChainTokenList = { export const BASES_TO_TRACK_LIQUIDITY_FOR: ChainTokenList = {
...WRAPPED_NATIVE_CURRENCIES_ONLY, ...WRAPPED_NATIVE_CURRENCIES_ONLY,
[SupportedChainId.MAINNET]: [ [ChainId.MAINNET]: [...WRAPPED_NATIVE_CURRENCIES_ONLY[ChainId.MAINNET], DAI, USDC_MAINNET, USDT, WBTC],
...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.MAINNET], [ChainId.BNB]: [
DAI, ...WRAPPED_NATIVE_CURRENCIES_ONLY[ChainId.BNB],
USDC_MAINNET,
USDT,
WBTC,
],
[SupportedChainId.BNB]: [
...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.BNB],
DAI_BSC, DAI_BSC,
USDC_BSC, USDC_BSC,
USDT_BSC, USDT_BSC,
...@@ -233,18 +201,19 @@ export const BASES_TO_TRACK_LIQUIDITY_FOR: ChainTokenList = { ...@@ -233,18 +201,19 @@ export const BASES_TO_TRACK_LIQUIDITY_FOR: ChainTokenList = {
BUSD_BSC, BUSD_BSC,
ETH_BSC, ETH_BSC,
], ],
[ChainId.AVALANCHE]: [
...WRAPPED_NATIVE_CURRENCIES_ONLY[ChainId.AVALANCHE],
DAI_AVALANCHE,
USDC_AVALANCHE,
USDT_AVALANCHE,
WETH_AVALANCHE,
],
} }
export const PINNED_PAIRS: { readonly [chainId: number]: [Token, Token][] } = { export const PINNED_PAIRS: { readonly [chainId: number]: [Token, Token][] } = {
[SupportedChainId.MAINNET]: [ [ChainId.MAINNET]: [
[ [
new Token(SupportedChainId.MAINNET, '0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643', 8, 'cDAI', 'Compound Dai'), new Token(ChainId.MAINNET, '0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643', 8, 'cDAI', 'Compound Dai'),
new Token( new Token(ChainId.MAINNET, '0x39AA39c021dfbaE8faC545936693aC917d5E7563', 8, 'cUSDC', 'Compound USD Coin'),
SupportedChainId.MAINNET,
'0x39AA39c021dfbaE8faC545936693aC917d5E7563',
8,
'cUSDC',
'Compound USD Coin'
),
], ],
[USDC_MAINNET, USDT], [USDC_MAINNET, USDT],
[DAI, USDT], [DAI, USDT],
......
This diff is collapsed.
import { SupportedChainId } from 'constants/chains' import { ChainId } from '@uniswap/sdk-core'
import { Chain } from './__generated__/types-and-hooks' import { Chain } from './__generated__/types-and-hooks'
import { isSupportedGQLChain, supportedChainIdFromGQLChain } from './util' import { isSupportedGQLChain, supportedChainIdFromGQLChain } from './util'
describe('fromGraphQLChain', () => { describe('fromGraphQLChain', () => {
it('should return the corresponding chain ID for supported chains', () => { it('should return the corresponding chain ID for supported chains', () => {
expect(supportedChainIdFromGQLChain(Chain.Ethereum)).toBe(SupportedChainId.MAINNET) expect(supportedChainIdFromGQLChain(Chain.Ethereum)).toBe(ChainId.MAINNET)
for (const chain of Object.values(Chain)) { for (const chain of Object.values(Chain)) {
if (!isSupportedGQLChain(chain)) continue if (!isSupportedGQLChain(chain)) continue
......
import { QueryResult } from '@apollo/client' import { QueryResult } from '@apollo/client'
import * as Sentry from '@sentry/react' import * as Sentry from '@sentry/react'
import { Currency, Token } from '@uniswap/sdk-core' import { ChainId, Currency, Token } from '@uniswap/sdk-core'
import { SupportedChainId } from 'constants/chains'
import { NATIVE_CHAIN_ID, nativeOnChain, WRAPPED_NATIVE_CURRENCY } from 'constants/tokens' import { NATIVE_CHAIN_ID, nativeOnChain, WRAPPED_NATIVE_CURRENCY } from 'constants/tokens'
import ms from 'ms.macro' import ms from 'ms.macro'
import { useEffect } from 'react' import { useEffect } from 'react'
...@@ -64,6 +63,7 @@ export const GQL_MAINNET_CHAINS = [ ...@@ -64,6 +63,7 @@ export const GQL_MAINNET_CHAINS = [
Chain.Optimism, Chain.Optimism,
Chain.Arbitrum, Chain.Arbitrum,
Chain.Bnb, Chain.Bnb,
Chain.Avalanche,
] as const ] as const
const GQL_TESTNET_CHAINS = [Chain.EthereumGoerli, Chain.EthereumSepolia] as const const GQL_TESTNET_CHAINS = [Chain.EthereumGoerli, Chain.EthereumSepolia] as const
...@@ -72,35 +72,31 @@ const UX_SUPPORTED_GQL_CHAINS = [...GQL_MAINNET_CHAINS, ...GQL_TESTNET_CHAINS] a ...@@ -72,35 +72,31 @@ const UX_SUPPORTED_GQL_CHAINS = [...GQL_MAINNET_CHAINS, ...GQL_TESTNET_CHAINS] a
export type InterfaceGqlChain = (typeof UX_SUPPORTED_GQL_CHAINS)[number] export type InterfaceGqlChain = (typeof UX_SUPPORTED_GQL_CHAINS)[number]
export const CHAIN_ID_TO_BACKEND_NAME: { [key: number]: InterfaceGqlChain } = { export const CHAIN_ID_TO_BACKEND_NAME: { [key: number]: InterfaceGqlChain } = {
[SupportedChainId.MAINNET]: Chain.Ethereum, [ChainId.MAINNET]: Chain.Ethereum,
[SupportedChainId.GOERLI]: Chain.EthereumGoerli, [ChainId.GOERLI]: Chain.EthereumGoerli,
[SupportedChainId.SEPOLIA]: Chain.EthereumSepolia, [ChainId.SEPOLIA]: Chain.EthereumSepolia,
[SupportedChainId.POLYGON]: Chain.Polygon, [ChainId.POLYGON]: Chain.Polygon,
[SupportedChainId.POLYGON_MUMBAI]: Chain.Polygon, [ChainId.POLYGON_MUMBAI]: Chain.Polygon,
[SupportedChainId.CELO]: Chain.Celo, [ChainId.CELO]: Chain.Celo,
[SupportedChainId.CELO_ALFAJORES]: Chain.Celo, [ChainId.CELO_ALFAJORES]: Chain.Celo,
[SupportedChainId.ARBITRUM_ONE]: Chain.Arbitrum, [ChainId.ARBITRUM_ONE]: Chain.Arbitrum,
[SupportedChainId.ARBITRUM_GOERLI]: Chain.Arbitrum, [ChainId.ARBITRUM_GOERLI]: Chain.Arbitrum,
[SupportedChainId.OPTIMISM]: Chain.Optimism, [ChainId.OPTIMISM]: Chain.Optimism,
[SupportedChainId.OPTIMISM_GOERLI]: Chain.Optimism, [ChainId.OPTIMISM_GOERLI]: Chain.Optimism,
[SupportedChainId.BNB]: Chain.Bnb, [ChainId.BNB]: Chain.Bnb,
[ChainId.AVALANCHE]: Chain.Avalanche,
} }
export function chainIdToBackendName(chainId: number | undefined) { export function chainIdToBackendName(chainId: number | undefined) {
return chainId && CHAIN_ID_TO_BACKEND_NAME[chainId] return chainId && CHAIN_ID_TO_BACKEND_NAME[chainId]
? CHAIN_ID_TO_BACKEND_NAME[chainId] ? CHAIN_ID_TO_BACKEND_NAME[chainId]
: CHAIN_ID_TO_BACKEND_NAME[SupportedChainId.MAINNET] : CHAIN_ID_TO_BACKEND_NAME[ChainId.MAINNET]
} }
const GQL_CHAINS: number[] = [ const GQL_CHAINS = [ChainId.MAINNET, ChainId.OPTIMISM, ChainId.POLYGON, ChainId.ARBITRUM_ONE, ChainId.CELO] as const
SupportedChainId.MAINNET, type GqlChainsType = (typeof GQL_CHAINS)[number]
SupportedChainId.OPTIMISM,
SupportedChainId.POLYGON,
SupportedChainId.ARBITRUM_ONE,
SupportedChainId.CELO,
]
export function isGqlSupportedChain(chainId: number | undefined): chainId is SupportedChainId { export function isGqlSupportedChain(chainId: number | undefined): chainId is GqlChainsType {
return !!chainId && GQL_CHAINS.includes(chainId) return !!chainId && GQL_CHAINS.includes(chainId)
} }
export function toContractInput(currency: Currency): ContractInput { export function toContractInput(currency: Currency): ContractInput {
...@@ -129,30 +125,39 @@ const URL_CHAIN_PARAM_TO_BACKEND: { [key: string]: InterfaceGqlChain } = { ...@@ -129,30 +125,39 @@ const URL_CHAIN_PARAM_TO_BACKEND: { [key: string]: InterfaceGqlChain } = {
arbitrum: Chain.Arbitrum, arbitrum: Chain.Arbitrum,
optimism: Chain.Optimism, optimism: Chain.Optimism,
bnb: Chain.Bnb, bnb: Chain.Bnb,
avalanche: Chain.Avalanche,
} }
/**
* @param chainName parsed in chain name from url query parameter
* @returns if chainName is a valid chain name supported by the backend, returns the backend chain name, otherwise returns Chain.Ethereum
*/
export function validateUrlChainParam(chainName: string | undefined) { export function validateUrlChainParam(chainName: string | undefined) {
return chainName && URL_CHAIN_PARAM_TO_BACKEND[chainName] ? URL_CHAIN_PARAM_TO_BACKEND[chainName] : Chain.Ethereum const isValidChainName = chainName && URL_CHAIN_PARAM_TO_BACKEND[chainName]
const isValidBackEndChain =
isValidChainName && (BACKEND_SUPPORTED_CHAINS as ReadonlyArray<Chain>).includes(isValidChainName)
return isValidBackEndChain ? URL_CHAIN_PARAM_TO_BACKEND[chainName] : Chain.Ethereum
} }
const CHAIN_NAME_TO_CHAIN_ID: { [key in InterfaceGqlChain]: SupportedChainId } = { const CHAIN_NAME_TO_CHAIN_ID: { [key in InterfaceGqlChain]: ChainId } = {
[Chain.Ethereum]: SupportedChainId.MAINNET, [Chain.Ethereum]: ChainId.MAINNET,
[Chain.EthereumGoerli]: SupportedChainId.GOERLI, [Chain.EthereumGoerli]: ChainId.GOERLI,
[Chain.EthereumSepolia]: SupportedChainId.SEPOLIA, [Chain.EthereumSepolia]: ChainId.SEPOLIA,
[Chain.Polygon]: SupportedChainId.POLYGON, [Chain.Polygon]: ChainId.POLYGON,
[Chain.Celo]: SupportedChainId.CELO, [Chain.Celo]: ChainId.CELO,
[Chain.Optimism]: SupportedChainId.OPTIMISM, [Chain.Optimism]: ChainId.OPTIMISM,
[Chain.Arbitrum]: SupportedChainId.ARBITRUM_ONE, [Chain.Arbitrum]: ChainId.ARBITRUM_ONE,
[Chain.Bnb]: SupportedChainId.BNB, [Chain.Bnb]: ChainId.BNB,
[Chain.Avalanche]: ChainId.AVALANCHE,
} }
export function isSupportedGQLChain(chain: Chain): chain is InterfaceGqlChain { export function isSupportedGQLChain(chain: Chain): chain is InterfaceGqlChain {
return (UX_SUPPORTED_GQL_CHAINS as ReadonlyArray<Chain>).includes(chain) return (UX_SUPPORTED_GQL_CHAINS as ReadonlyArray<Chain>).includes(chain)
} }
export function supportedChainIdFromGQLChain(chain: InterfaceGqlChain): SupportedChainId export function supportedChainIdFromGQLChain(chain: InterfaceGqlChain): ChainId
export function supportedChainIdFromGQLChain(chain: Chain): SupportedChainId | undefined export function supportedChainIdFromGQLChain(chain: Chain): ChainId | undefined
export function supportedChainIdFromGQLChain(chain: Chain): SupportedChainId | undefined { export function supportedChainIdFromGQLChain(chain: Chain): ChainId | undefined {
return isSupportedGQLChain(chain) ? CHAIN_NAME_TO_CHAIN_ID[chain] : undefined return isSupportedGQLChain(chain) ? CHAIN_NAME_TO_CHAIN_ID[chain] : undefined
} }
...@@ -172,13 +177,14 @@ export function logSentryErrorForUnsupportedChain({ ...@@ -172,13 +177,14 @@ export function logSentryErrorForUnsupportedChain({
}) })
} }
export const BACKEND_CHAIN_NAMES: InterfaceGqlChain[] = [ export const BACKEND_SUPPORTED_CHAINS = [
Chain.Ethereum, Chain.Ethereum,
Chain.Polygon, Chain.Polygon,
Chain.Optimism, Chain.Optimism,
Chain.Arbitrum, Chain.Arbitrum,
Chain.Celo, Chain.Celo,
] ] as const
export const BACKEND_NOT_YET_SUPPORTED_CHAIN_IDS = [ChainId.BNB, ChainId.AVALANCHE] as const
export function getTokenDetailsURL({ export function getTokenDetailsURL({
address, address,
......
import { ApolloClient, ApolloLink, concat, HttpLink, InMemoryCache } from '@apollo/client' import { ApolloClient, ApolloLink, concat, HttpLink, InMemoryCache } from '@apollo/client'
import { SupportedChainId } from 'constants/chains' import { ChainId } from '@uniswap/sdk-core'
import store from '../../state/index' import store from '../../state/index'
const CHAIN_SUBGRAPH_URL: Record<number, string> = { const CHAIN_SUBGRAPH_URL: Record<number, string> = {
[SupportedChainId.MAINNET]: 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3', [ChainId.MAINNET]: 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3',
[SupportedChainId.ARBITRUM_ONE]: 'https://thegraph.com/hosted-service/subgraph/ianlapham/uniswap-arbitrum-one', [ChainId.ARBITRUM_ONE]: 'https://thegraph.com/hosted-service/subgraph/ianlapham/uniswap-arbitrum-one',
[SupportedChainId.OPTIMISM]: 'https://api.thegraph.com/subgraphs/name/ianlapham/optimism-post-regenesis', [ChainId.OPTIMISM]: 'https://api.thegraph.com/subgraphs/name/ianlapham/optimism-post-regenesis',
[SupportedChainId.POLYGON]: 'https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-polygon', [ChainId.POLYGON]: 'https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-polygon',
[SupportedChainId.CELO]: 'https://api.thegraph.com/subgraphs/name/jesse-sawa/uniswap-celo', [ChainId.CELO]: 'https://api.thegraph.com/subgraphs/name/jesse-sawa/uniswap-celo',
[SupportedChainId.BNB]: 'https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-bsc', [ChainId.BNB]: 'https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v3-bsc',
[ChainId.AVALANCHE]: 'https://api.thegraph.com/subgraphs/name/lynnshaoyu/uniswap-v3-avax',
} }
const httpLink = new HttpLink({ uri: CHAIN_SUBGRAPH_URL[SupportedChainId.MAINNET] }) const httpLink = new HttpLink({ uri: CHAIN_SUBGRAPH_URL[ChainId.MAINNET] })
// This middleware will allow us to dynamically update the uri for the requests based off chainId // This middleware will allow us to dynamically update the uri for the requests based off chainId
// For more information: https://www.apollographql.com/docs/react/networking/advanced-http-networking/ // For more information: https://www.apollographql.com/docs/react/networking/advanced-http-networking/
...@@ -21,10 +22,7 @@ const authMiddleware = new ApolloLink((operation, forward) => { ...@@ -21,10 +22,7 @@ const authMiddleware = new ApolloLink((operation, forward) => {
const chainId = store.getState().application.chainId const chainId = store.getState().application.chainId
operation.setContext(() => ({ operation.setContext(() => ({
uri: uri: chainId && CHAIN_SUBGRAPH_URL[chainId] ? CHAIN_SUBGRAPH_URL[chainId] : CHAIN_SUBGRAPH_URL[ChainId.MAINNET],
chainId && CHAIN_SUBGRAPH_URL[chainId]
? CHAIN_SUBGRAPH_URL[chainId]
: CHAIN_SUBGRAPH_URL[SupportedChainId.MAINNET],
})) }))
return forward(operation) return forward(operation)
......
import { SupportedChainId as MockSupportedChainId } from 'constants/chains' import { ChainId as MockChainId } from '@uniswap/sdk-core'
import { import {
DAI as MockDAI, DAI as MockDAI,
USDC_MAINNET as MockUSDC_MAINNET, USDC_MAINNET as MockUSDC_MAINNET,
...@@ -13,11 +13,11 @@ import { useAllTokensMultichain } from './Tokens' ...@@ -13,11 +13,11 @@ import { useAllTokensMultichain } from './Tokens'
jest.mock('../state/lists/hooks.ts', () => { jest.mock('../state/lists/hooks.ts', () => {
return { return {
useCombinedTokenMapFromUrls: () => ({ useCombinedTokenMapFromUrls: () => ({
[MockSupportedChainId.MAINNET]: { [MockChainId.MAINNET]: {
[MockDAI.address]: { token: MockDAI }, [MockDAI.address]: { token: MockDAI },
[MockUSDC_MAINNET.address]: { token: MockUSDC_MAINNET }, [MockUSDC_MAINNET.address]: { token: MockUSDC_MAINNET },
}, },
[MockSupportedChainId.POLYGON]: { [MockChainId.POLYGON]: {
[MockWETH_POLYGON.address]: { token: MockWETH_POLYGON }, [MockWETH_POLYGON.address]: { token: MockWETH_POLYGON },
}, },
}), }),
...@@ -27,11 +27,11 @@ jest.mock('../state/lists/hooks.ts', () => { ...@@ -27,11 +27,11 @@ jest.mock('../state/lists/hooks.ts', () => {
jest.mock('../state/hooks.ts', () => { jest.mock('../state/hooks.ts', () => {
return { return {
useAppSelector: () => ({ useAppSelector: () => ({
[MockSupportedChainId.MAINNET]: { [MockChainId.MAINNET]: {
[MockDAI.address]: MockDAI, [MockDAI.address]: MockDAI,
[MockUSDT.address]: MockUSDT, [MockUSDT.address]: MockUSDT,
}, },
[MockSupportedChainId.OPTIMISM]: { [MockChainId.OPTIMISM]: {
[MockUSDC_OPTIMISM.address]: MockUSDC_OPTIMISM, [MockUSDC_OPTIMISM.address]: MockUSDC_OPTIMISM,
}, },
}), }),
...@@ -43,15 +43,15 @@ describe('useAllTokensMultichain', () => { ...@@ -43,15 +43,15 @@ describe('useAllTokensMultichain', () => {
const { result } = renderHook(() => useAllTokensMultichain()) const { result } = renderHook(() => useAllTokensMultichain())
expect(result.current).toStrictEqual({ expect(result.current).toStrictEqual({
[MockSupportedChainId.MAINNET]: { [MockChainId.MAINNET]: {
[MockDAI.address]: MockDAI, [MockDAI.address]: MockDAI,
[MockUSDC_MAINNET.address]: MockUSDC_MAINNET, [MockUSDC_MAINNET.address]: MockUSDC_MAINNET,
[MockUSDT.address]: MockUSDT, [MockUSDT.address]: MockUSDT,
}, },
[MockSupportedChainId.POLYGON]: { [MockChainId.POLYGON]: {
[MockWETH_POLYGON.address]: MockWETH_POLYGON, [MockWETH_POLYGON.address]: MockWETH_POLYGON,
}, },
[MockSupportedChainId.OPTIMISM]: { [MockChainId.OPTIMISM]: {
[MockUSDC_OPTIMISM.address]: MockUSDC_OPTIMISM, [MockUSDC_OPTIMISM.address]: MockUSDC_OPTIMISM,
}, },
}) })
......
import { Currency, Token } from '@uniswap/sdk-core' import { ChainId, Currency, Token } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { SupportedChainId } from 'constants/chains'
import { DEFAULT_INACTIVE_LIST_URLS, DEFAULT_LIST_OF_LISTS } from 'constants/lists' import { DEFAULT_INACTIVE_LIST_URLS, DEFAULT_LIST_OF_LISTS } from 'constants/lists'
import { useCurrencyFromMap, useTokenFromMapOrNetwork } from 'lib/hooks/useCurrency' import { useCurrencyFromMap, useTokenFromMapOrNetwork } from 'lib/hooks/useCurrency'
import { getTokenFilter } from 'lib/hooks/useTokenList/filtering' import { getTokenFilter } from 'lib/hooks/useTokenList/filtering'
...@@ -18,7 +17,7 @@ import { useUnsupportedTokenList } from './../state/lists/hooks' ...@@ -18,7 +17,7 @@ import { useUnsupportedTokenList } from './../state/lists/hooks'
type Maybe<T> = T | null | undefined type Maybe<T> = T | null | undefined
// reduce token map into standard address <-> Token mapping, optionally include user added tokens // reduce token map into standard address <-> Token mapping, optionally include user added tokens
function useTokensFromMap(tokenMap: TokenAddressMap, chainId: Maybe<SupportedChainId>): { [address: string]: Token } { function useTokensFromMap(tokenMap: TokenAddressMap, chainId: Maybe<ChainId>): { [address: string]: Token } {
return useMemo(() => { return useMemo(() => {
if (!chainId) return {} if (!chainId) return {}
...@@ -65,7 +64,7 @@ export function useAllTokensMultichain(): ChainTokenMap { ...@@ -65,7 +64,7 @@ export function useAllTokensMultichain(): ChainTokenMap {
} }
/** Returns all tokens from the default list + user added tokens */ /** Returns all tokens from the default list + user added tokens */
export function useDefaultActiveTokens(chainId: Maybe<SupportedChainId>): { [address: string]: Token } { export function useDefaultActiveTokens(chainId: Maybe<ChainId>): { [address: string]: Token } {
const defaultListTokens = useCombinedActiveList() const defaultListTokens = useCombinedActiveList()
const tokensFromMap = useTokensFromMap(defaultListTokens, chainId) const tokensFromMap = useTokensFromMap(defaultListTokens, chainId)
const userAddedTokens = useUserAddedTokens() const userAddedTokens = useUserAddedTokens()
...@@ -87,7 +86,7 @@ export function useDefaultActiveTokens(chainId: Maybe<SupportedChainId>): { [add ...@@ -87,7 +86,7 @@ export function useDefaultActiveTokens(chainId: Maybe<SupportedChainId>): { [add
} }
type BridgeInfo = Record< type BridgeInfo = Record<
SupportedChainId, ChainId,
{ {
tokenAddress: string tokenAddress: string
originBridgeAddress: string originBridgeAddress: string
...@@ -124,13 +123,13 @@ export function useUnsupportedTokens(): { [address: string]: Token } { ...@@ -124,13 +123,13 @@ export function useUnsupportedTokens(): { [address: string]: Token } {
const bridgeInfo = tokenInfo.extensions?.bridgeInfo as unknown as BridgeInfo const bridgeInfo = tokenInfo.extensions?.bridgeInfo as unknown as BridgeInfo
if ( if (
bridgeInfo && bridgeInfo &&
bridgeInfo[SupportedChainId.MAINNET] && bridgeInfo[ChainId.MAINNET] &&
bridgeInfo[SupportedChainId.MAINNET].tokenAddress && bridgeInfo[ChainId.MAINNET].tokenAddress &&
unsupportedSet.has(bridgeInfo[SupportedChainId.MAINNET].tokenAddress) unsupportedSet.has(bridgeInfo[ChainId.MAINNET].tokenAddress)
) { ) {
const address = bridgeInfo[SupportedChainId.MAINNET].tokenAddress const address = bridgeInfo[ChainId.MAINNET].tokenAddress
// don't rely on decimals--it's possible that a token could be bridged w/ different decimals on the L2 // don't rely on decimals--it's possible that a token could be bridged w/ different decimals on the L2
return { ...acc, [address]: new Token(SupportedChainId.MAINNET, address, tokenInfo.decimals) } return { ...acc, [address]: new Token(ChainId.MAINNET, address, tokenInfo.decimals) }
} }
return acc return acc
}, {}) }, {})
...@@ -191,7 +190,7 @@ export function useToken(tokenAddress?: string | null): Token | null | undefined ...@@ -191,7 +190,7 @@ export function useToken(tokenAddress?: string | null): Token | null | undefined
return useTokenFromMapOrNetwork(tokens, tokenAddress) return useTokenFromMapOrNetwork(tokens, tokenAddress)
} }
export function useCurrency(currencyId: Maybe<string>, chainId?: SupportedChainId): Currency | null | undefined { export function useCurrency(currencyId: Maybe<string>, chainId?: ChainId): Currency | null | undefined {
const { chainId: connectedChainId } = useWeb3React() const { chainId: connectedChainId } = useWeb3React()
const tokens = useDefaultActiveTokens(chainId ?? connectedChainId) const tokens = useDefaultActiveTokens(chainId ?? connectedChainId)
return useCurrencyFromMap(tokens, chainId ?? connectedChainId, currencyId) return useCurrencyFromMap(tokens, chainId ?? connectedChainId, currencyId)
......
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { isSupportedChainId } from 'lib/hooks/routing/clientSideSmartOrderRouter' import { isSupportedChain } from 'constants/chains'
export default function useAutoRouterSupported(): boolean { export default function useAutoRouterSupported(): boolean {
const { chainId } = useWeb3React() const { chainId } = useWeb3React()
return isSupportedChainId(chainId) return isSupportedChain(chainId)
} }
import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core' import { ChainId, Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core'
import { Route, SwapQuoter } from '@uniswap/v3-sdk' import { Route, SwapQuoter } from '@uniswap/v3-sdk'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { SupportedChainId } from 'constants/chains'
import JSBI from 'jsbi' import JSBI from 'jsbi'
import { useSingleContractWithCallData } from 'lib/hooks/multicall' import { useSingleContractWithCallData } from 'lib/hooks/multicall'
import { useMemo } from 'react' import { useMemo } from 'react'
...@@ -12,13 +11,14 @@ import { useAllV3Routes } from './useAllV3Routes' ...@@ -12,13 +11,14 @@ import { useAllV3Routes } from './useAllV3Routes'
import { useQuoter } from './useContract' import { useQuoter } from './useContract'
const QUOTE_GAS_OVERRIDES: { [chainId: number]: number } = { const QUOTE_GAS_OVERRIDES: { [chainId: number]: number } = {
[SupportedChainId.ARBITRUM_ONE]: 25_000_000, [ChainId.ARBITRUM_ONE]: 25_000_000,
[SupportedChainId.ARBITRUM_GOERLI]: 25_000_000, [ChainId.ARBITRUM_GOERLI]: 25_000_000,
[SupportedChainId.CELO]: 50_000_000, [ChainId.CELO]: 50_000_000,
[SupportedChainId.CELO_ALFAJORES]: 50_000_000, [ChainId.CELO_ALFAJORES]: 50_000_000,
[SupportedChainId.POLYGON]: 40_000_000, [ChainId.POLYGON]: 40_000_000,
[SupportedChainId.POLYGON_MUMBAI]: 40_000_000, [ChainId.POLYGON_MUMBAI]: 40_000_000,
[SupportedChainId.BNB]: 50_000_000, [ChainId.BNB]: 50_000_000,
[ChainId.AVALANCHE]: 50_000_000,
} }
const DEFAULT_GAS_QUOTE = 2_000_000 const DEFAULT_GAS_QUOTE = 2_000_000
......
import { Token } from '@uniswap/sdk-core' import { ChainId, Token } from '@uniswap/sdk-core'
import { SupportedChainId } from 'constants/chains'
import uriToHttp from 'lib/utils/uriToHttp' import uriToHttp from 'lib/utils/uriToHttp'
import Vibrant from 'node-vibrant/lib/bundle.js' import Vibrant from 'node-vibrant/lib/bundle.js'
import { shade } from 'polished' import { shade } from 'polished'
...@@ -20,7 +19,7 @@ async function getColorFromToken(token: Token): Promise<string | null> { ...@@ -20,7 +19,7 @@ async function getColorFromToken(token: Token): Promise<string | null> {
const { address } = wrappedToken const { address } = wrappedToken
let { logoURI } = wrappedToken let { logoURI } = wrappedToken
if (!logoURI) { if (!logoURI) {
if (token.chainId !== SupportedChainId.MAINNET) { if (token.chainId !== ChainId.MAINNET) {
return null return null
} else { } else {
logoURI = URIForEthToken(address) logoURI = URIForEthToken(address)
......
import { Contract } from '@ethersproject/contracts' import { Contract } from '@ethersproject/contracts'
import {
ARGENT_WALLET_DETECTOR_ADDRESS,
ENS_REGISTRAR_ADDRESSES,
MULTICALL_ADDRESSES,
NONFUNGIBLE_POSITION_MANAGER_ADDRESSES,
QUOTER_ADDRESSES,
TICK_LENS_ADDRESSES,
V2_ROUTER_ADDRESS,
V3_MIGRATOR_ADDRESSES,
} from '@uniswap/sdk-core'
import QuoterV2Json from '@uniswap/swap-router-contracts/artifacts/contracts/lens/QuoterV2.sol/QuoterV2.json' import QuoterV2Json from '@uniswap/swap-router-contracts/artifacts/contracts/lens/QuoterV2.sol/QuoterV2.json'
import IUniswapV2PairJson from '@uniswap/v2-core/build/IUniswapV2Pair.json' import IUniswapV2PairJson from '@uniswap/v2-core/build/IUniswapV2Pair.json'
import IUniswapV2Router02Json from '@uniswap/v2-periphery/build/IUniswapV2Router02.json' import IUniswapV2Router02Json from '@uniswap/v2-periphery/build/IUniswapV2Router02.json'
...@@ -18,16 +28,6 @@ import ERC721_ABI from 'abis/erc721.json' ...@@ -18,16 +28,6 @@ import ERC721_ABI from 'abis/erc721.json'
import ERC1155_ABI from 'abis/erc1155.json' import ERC1155_ABI from 'abis/erc1155.json'
import { ArgentWalletDetector, EnsPublicResolver, EnsRegistrar, Erc20, Erc721, Erc1155, Weth } from 'abis/types' import { ArgentWalletDetector, EnsPublicResolver, EnsRegistrar, Erc20, Erc721, Erc1155, Weth } from 'abis/types'
import WETH_ABI from 'abis/weth.json' import WETH_ABI from 'abis/weth.json'
import {
ARGENT_WALLET_DETECTOR_ADDRESS,
ENS_REGISTRAR_ADDRESSES,
MULTICALL_ADDRESS,
NONFUNGIBLE_POSITION_MANAGER_ADDRESSES,
QUOTER_ADDRESSES,
TICK_LENS_ADDRESSES,
V2_ROUTER_ADDRESS,
V3_MIGRATOR_ADDRESSES,
} from 'constants/addresses'
import { WRAPPED_NATIVE_CURRENCY } from 'constants/tokens' import { WRAPPED_NATIVE_CURRENCY } from 'constants/tokens'
import { useMemo } from 'react' import { useMemo } from 'react'
import { NonfungiblePositionManager, Quoter, QuoterV2, TickLens, UniswapInterfaceMulticall } from 'types/v3' import { NonfungiblePositionManager, Quoter, QuoterV2, TickLens, UniswapInterfaceMulticall } from 'types/v3'
...@@ -120,7 +120,7 @@ export function useV2RouterContract(): Contract | null { ...@@ -120,7 +120,7 @@ export function useV2RouterContract(): Contract | null {
} }
export function useInterfaceMulticall() { export function useInterfaceMulticall() {
return useContract<UniswapInterfaceMulticall>(MULTICALL_ADDRESS, MulticallABI, false) as UniswapInterfaceMulticall return useContract<UniswapInterfaceMulticall>(MULTICALL_ADDRESSES, MulticallABI, false) as UniswapInterfaceMulticall
} }
export function useV3NFTPositionManagerContract(withSignerIfPossible?: boolean): NonfungiblePositionManager | null { export function useV3NFTPositionManagerContract(withSignerIfPossible?: boolean): NonfungiblePositionManager | null {
......
import { BigNumber } from '@ethersproject/bignumber' import { BigNumber } from '@ethersproject/bignumber'
import { splitSignature } from '@ethersproject/bytes' import { splitSignature } from '@ethersproject/bytes'
import { Currency, CurrencyAmount } from '@uniswap/sdk-core' import { ChainId, Currency, CurrencyAmount } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { SupportedChainId } from 'constants/chains'
import JSBI from 'jsbi' import JSBI from 'jsbi'
import { useSingleCallResult } from 'lib/hooks/multicall' import { useSingleCallResult } from 'lib/hooks/multicall'
import { useMemo, useState } from 'react' import { useMemo, useState } from 'react'
...@@ -32,16 +31,16 @@ const PERMITTABLE_TOKENS: { ...@@ -32,16 +31,16 @@ const PERMITTABLE_TOKENS: {
[checksummedTokenAddress: string]: PermitInfo [checksummedTokenAddress: string]: PermitInfo
} }
} = { } = {
[SupportedChainId.MAINNET]: { [ChainId.MAINNET]: {
[USDC_MAINNET.address]: { type: PermitType.AMOUNT, name: 'USD Coin', version: '2' }, [USDC_MAINNET.address]: { type: PermitType.AMOUNT, name: 'USD Coin', version: '2' },
[DAI.address]: { type: PermitType.ALLOWED, name: 'Dai Stablecoin', version: '1' }, [DAI.address]: { type: PermitType.ALLOWED, name: 'Dai Stablecoin', version: '1' },
[UNI[SupportedChainId.MAINNET].address]: { type: PermitType.AMOUNT, name: 'Uniswap' }, [UNI[ChainId.MAINNET].address]: { type: PermitType.AMOUNT, name: 'Uniswap' },
}, },
[SupportedChainId.GOERLI]: { [ChainId.GOERLI]: {
[UNI[SupportedChainId.GOERLI].address]: { type: PermitType.AMOUNT, name: 'Uniswap' }, [UNI[ChainId.GOERLI].address]: { type: PermitType.AMOUNT, name: 'Uniswap' },
}, },
[SupportedChainId.SEPOLIA]: { [ChainId.SEPOLIA]: {
[UNI[SupportedChainId.SEPOLIA].address]: { type: PermitType.AMOUNT, name: 'Uniswap' }, [UNI[ChainId.SEPOLIA].address]: { type: PermitType.AMOUNT, name: 'Uniswap' },
}, },
} }
......
import { nanoid } from '@reduxjs/toolkit' import { nanoid } from '@reduxjs/toolkit'
import { ChainId } from '@uniswap/sdk-core'
import { TokenList } from '@uniswap/token-lists' import { TokenList } from '@uniswap/token-lists'
import { SupportedChainId } from 'constants/chains'
import { RPC_PROVIDERS } from 'constants/providers' import { RPC_PROVIDERS } from 'constants/providers'
import getTokenList from 'lib/hooks/useTokenList/fetchTokenList' import getTokenList from 'lib/hooks/useTokenList/fetchTokenList'
import resolveENSContentHash from 'lib/utils/resolveENSContentHash' import resolveENSContentHash from 'lib/utils/resolveENSContentHash'
...@@ -18,7 +18,7 @@ export function useFetchListCallback(): (listUrl: string, skipValidation?: boole ...@@ -18,7 +18,7 @@ export function useFetchListCallback(): (listUrl: string, skipValidation?: boole
dispatch(fetchTokenList.pending({ requestId, url: listUrl })) dispatch(fetchTokenList.pending({ requestId, url: listUrl }))
return getTokenList( return getTokenList(
listUrl, listUrl,
(ensName: string) => resolveENSContentHash(ensName, RPC_PROVIDERS[SupportedChainId.MAINNET]), (ensName: string) => resolveENSContentHash(ensName, RPC_PROVIDERS[ChainId.MAINNET]),
skipValidation skipValidation
) )
.then((tokenList) => { .then((tokenList) => {
......
import { Currency } from '@uniswap/sdk-core' import { ChainId, Currency, V3_CORE_FACTORY_ADDRESSES } from '@uniswap/sdk-core'
import { FeeAmount, nearestUsableTick, Pool, TICK_SPACINGS, tickToPrice } from '@uniswap/v3-sdk' import { FeeAmount, nearestUsableTick, Pool, TICK_SPACINGS, tickToPrice } from '@uniswap/v3-sdk'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { SupportedChainId } from 'constants/chains'
import { ZERO_ADDRESS } from 'constants/misc' import { ZERO_ADDRESS } from 'constants/misc'
import { useAllV3TicksQuery } from 'graphql/thegraph/__generated__/types-and-hooks' import { useAllV3TicksQuery } from 'graphql/thegraph/__generated__/types-and-hooks'
import { TickData, Ticks } from 'graphql/thegraph/AllV3TicksQuery' import { TickData, Ticks } from 'graphql/thegraph/AllV3TicksQuery'
...@@ -12,12 +11,11 @@ import ms from 'ms.macro' ...@@ -12,12 +11,11 @@ import ms from 'ms.macro'
import { useEffect, useMemo, useState } from 'react' import { useEffect, useMemo, useState } from 'react'
import computeSurroundingTicks from 'utils/computeSurroundingTicks' import computeSurroundingTicks from 'utils/computeSurroundingTicks'
import { V3_CORE_FACTORY_ADDRESSES } from '../constants/addresses'
import { useTickLens } from './useContract' import { useTickLens } from './useContract'
import { PoolState, usePool } from './usePools' import { PoolState, usePool } from './usePools'
const PRICE_FIXED_DIGITS = 8 const PRICE_FIXED_DIGITS = 8
const CHAIN_IDS_MISSING_SUBGRAPH_DATA = [SupportedChainId.ARBITRUM_ONE, SupportedChainId.ARBITRUM_GOERLI] const CHAIN_IDS_MISSING_SUBGRAPH_DATA = [ChainId.ARBITRUM_ONE, ChainId.ARBITRUM_GOERLI]
// Tick with fields parsed to JSBIs, and active liquidity computed. // Tick with fields parsed to JSBIs, and active liquidity computed.
export interface TickProcessed { export interface TickProcessed {
......
import { Interface } from '@ethersproject/abi' import { Interface } from '@ethersproject/abi'
import { BigintIsh, Currency, Token } from '@uniswap/sdk-core' import { BigintIsh, Currency, Token, V3_CORE_FACTORY_ADDRESSES } from '@uniswap/sdk-core'
import IUniswapV3PoolStateJSON from '@uniswap/v3-core/artifacts/contracts/interfaces/pool/IUniswapV3PoolState.sol/IUniswapV3PoolState.json' import IUniswapV3PoolStateJSON from '@uniswap/v3-core/artifacts/contracts/interfaces/pool/IUniswapV3PoolState.sol/IUniswapV3PoolState.json'
import { computePoolAddress } from '@uniswap/v3-sdk' import { computePoolAddress } from '@uniswap/v3-sdk'
import { FeeAmount, Pool } from '@uniswap/v3-sdk' import { FeeAmount, Pool } from '@uniswap/v3-sdk'
...@@ -8,7 +8,6 @@ import JSBI from 'jsbi' ...@@ -8,7 +8,6 @@ import JSBI from 'jsbi'
import { useMultipleContractSingleData } from 'lib/hooks/multicall' import { useMultipleContractSingleData } from 'lib/hooks/multicall'
import { useMemo } from 'react' import { useMemo } from 'react'
import { V3_CORE_FACTORY_ADDRESSES } from '../constants/addresses'
import { IUniswapV3PoolStateInterface } from '../types/v3/IUniswapV3PoolState' import { IUniswapV3PoolStateInterface } from '../types/v3/IUniswapV3PoolState'
const POOL_STATE_INTERFACE = new Interface(IUniswapV3PoolStateJSON.abi) as IUniswapV3PoolStateInterface const POOL_STATE_INTERFACE = new Interface(IUniswapV3PoolStateJSON.abi) as IUniswapV3PoolStateInterface
......
import { ChainId } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { getConnection } from 'connection' import { getConnection } from 'connection'
import { didUserReject } from 'connection/utils' import { didUserReject } from 'connection/utils'
import { SupportedChainId } from 'constants/chains'
import { useCallback } from 'react' import { useCallback } from 'react'
import { addPopup } from 'state/application/reducer' import { addPopup } from 'state/application/reducer'
import { useAppDispatch } from 'state/hooks' import { useAppDispatch } from 'state/hooks'
...@@ -14,7 +14,7 @@ export default function useSelectChain() { ...@@ -14,7 +14,7 @@ export default function useSelectChain() {
const switchChain = useSwitchChain() const switchChain = useSwitchChain()
return useCallback( return useCallback(
async (targetChain: SupportedChainId) => { async (targetChain: ChainId) => {
if (!connector) return if (!connector) return
const connection = getConnection(connector) const connection = getConnection(connector)
......
import { Token } from '@uniswap/sdk-core' import { ChainId, SOCKS_CONTROLLER_ADDRESSES, Token } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { SOCKS_CONTROLLER_ADDRESSES } from 'constants/addresses'
import { SupportedChainId } from 'constants/chains'
import { useMemo } from 'react' import { useMemo } from 'react'
import { useTokenBalance } from 'state/connection/hooks' import { useTokenBalance } from 'state/connection/hooks'
// technically a 721, not an ERC20, but suffices for our purposes // technically a 721, not an ERC20, but suffices for our purposes
const SOCKS = new Token(SupportedChainId.MAINNET, SOCKS_CONTROLLER_ADDRESSES[SupportedChainId.MAINNET], 0) const SOCKS = new Token(ChainId.MAINNET, SOCKS_CONTROLLER_ADDRESSES[ChainId.MAINNET], 0)
export function useHasSocks(): boolean | undefined { export function useHasSocks(): boolean | undefined {
const { account, chainId } = useWeb3React() const { account, chainId } = useWeb3React()
const balance = useTokenBalance(account ?? undefined, chainId === SupportedChainId.MAINNET ? SOCKS : undefined) const balance = useTokenBalance(account ?? undefined, chainId === ChainId.MAINNET ? SOCKS : undefined)
return useMemo(() => Boolean(balance?.greaterThan(0)), [balance]) return useMemo(() => Boolean(balance?.greaterThan(0)), [balance])
} }
import { Currency, CurrencyAmount, Price, Token, TradeType } from '@uniswap/sdk-core' import { ChainId, Currency, CurrencyAmount, Price, Token, TradeType } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { SupportedChainId } from 'constants/chains'
import tryParseCurrencyAmount from 'lib/utils/tryParseCurrencyAmount' import tryParseCurrencyAmount from 'lib/utils/tryParseCurrencyAmount'
import { useMemo, useRef } from 'react' import { useMemo, useRef } from 'react'
import { INTERNAL_ROUTER_PREFERENCE_PRICE } from 'state/routing/slice' import { INTERNAL_ROUTER_PREFERENCE_PRICE } from 'state/routing/slice'
...@@ -10,6 +9,7 @@ import { ...@@ -10,6 +9,7 @@ import {
BRIDGED_USDC_ARBITRUM, BRIDGED_USDC_ARBITRUM,
CUSD_CELO, CUSD_CELO,
DAI_OPTIMISM, DAI_OPTIMISM,
USDC_AVALANCHE,
USDC_MAINNET, USDC_MAINNET,
USDC_POLYGON, USDC_POLYGON,
USDT_BSC, USDT_BSC,
...@@ -18,12 +18,13 @@ import { ...@@ -18,12 +18,13 @@ import {
// Stablecoin amounts used when calculating spot price for a given currency. // Stablecoin amounts used when calculating spot price for a given currency.
// The amount is large enough to filter low liquidity pairs. // The amount is large enough to filter low liquidity pairs.
const STABLECOIN_AMOUNT_OUT: { [chainId: number]: CurrencyAmount<Token> } = { const STABLECOIN_AMOUNT_OUT: { [chainId: number]: CurrencyAmount<Token> } = {
[SupportedChainId.MAINNET]: CurrencyAmount.fromRawAmount(USDC_MAINNET, 100_000e6), [ChainId.MAINNET]: CurrencyAmount.fromRawAmount(USDC_MAINNET, 100_000e6),
[SupportedChainId.ARBITRUM_ONE]: CurrencyAmount.fromRawAmount(BRIDGED_USDC_ARBITRUM, 10_000e6), [ChainId.ARBITRUM_ONE]: CurrencyAmount.fromRawAmount(BRIDGED_USDC_ARBITRUM, 10_000e6),
[SupportedChainId.OPTIMISM]: CurrencyAmount.fromRawAmount(DAI_OPTIMISM, 10_000e18), [ChainId.OPTIMISM]: CurrencyAmount.fromRawAmount(DAI_OPTIMISM, 10_000e18),
[SupportedChainId.POLYGON]: CurrencyAmount.fromRawAmount(USDC_POLYGON, 10_000e6), [ChainId.POLYGON]: CurrencyAmount.fromRawAmount(USDC_POLYGON, 10_000e6),
[SupportedChainId.CELO]: CurrencyAmount.fromRawAmount(CUSD_CELO, 10_000e18), [ChainId.CELO]: CurrencyAmount.fromRawAmount(CUSD_CELO, 10_000e18),
[SupportedChainId.BNB]: CurrencyAmount.fromRawAmount(USDT_BSC, 100e18), [ChainId.BNB]: CurrencyAmount.fromRawAmount(USDT_BSC, 100e18),
[ChainId.AVALANCHE]: CurrencyAmount.fromRawAmount(USDC_AVALANCHE, 10_000e6),
} }
/** /**
......
import { ChainId, SupportedChainsType } from '@uniswap/sdk-core'
import { Connector } from '@web3-react/types' import { Connector } from '@web3-react/types'
import { import {
networkConnection, networkConnection,
...@@ -7,17 +8,17 @@ import { ...@@ -7,17 +8,17 @@ import {
walletConnectV2Connection, walletConnectV2Connection,
} from 'connection' } from 'connection'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { isSupportedChain, SupportedChainId } from 'constants/chains' import { isSupportedChain } from 'constants/chains'
import { FALLBACK_URLS, RPC_URLS } from 'constants/networks' import { FALLBACK_URLS, RPC_URLS } from 'constants/networks'
import { useCallback } from 'react' import { useCallback } from 'react'
import { useAppDispatch } from 'state/hooks' import { useAppDispatch } from 'state/hooks'
import { endSwitchingChain, startSwitchingChain } from 'state/wallets/reducer' import { endSwitchingChain, startSwitchingChain } from 'state/wallets/reducer'
function getRpcUrl(chainId: SupportedChainId): string { function getRpcUrl(chainId: SupportedChainsType): string {
switch (chainId) { switch (chainId) {
case SupportedChainId.MAINNET: case ChainId.MAINNET:
case SupportedChainId.GOERLI: case ChainId.GOERLI:
case SupportedChainId.SEPOLIA: case ChainId.SEPOLIA:
return RPC_URLS[chainId][0] return RPC_URLS[chainId][0]
// Attempting to add a chain using an infura URL will not work, as the URL will be unreachable from the MetaMask background page. // Attempting to add a chain using an infura URL will not work, as the URL will be unreachable from the MetaMask background page.
// MetaMask allows switching to any publicly reachable URL, but for novel chains, it will display a warning if it is not on the "Safe" list. // MetaMask allows switching to any publicly reachable URL, but for novel chains, it will display a warning if it is not on the "Safe" list.
...@@ -31,7 +32,7 @@ export function useSwitchChain() { ...@@ -31,7 +32,7 @@ export function useSwitchChain() {
const dispatch = useAppDispatch() const dispatch = useAppDispatch()
return useCallback( return useCallback(
async (connector: Connector, chainId: SupportedChainId) => { async (connector: Connector, chainId: ChainId) => {
if (!isSupportedChain(chainId)) { if (!isSupportedChain(chainId)) {
throw new Error(`Chain ${chainId} not supported for connector (${typeof connector})`) throw new Error(`Chain ${chainId} not supported for connector (${typeof connector})`)
} else { } else {
......
import { NetworkStatus } from '@apollo/client' import { NetworkStatus } from '@apollo/client'
import { Currency, CurrencyAmount, Price, SupportedChainId, TradeType } from '@uniswap/sdk-core' import { ChainId, Currency, CurrencyAmount, Price, TradeType } from '@uniswap/sdk-core'
import { nativeOnChain } from 'constants/tokens' import { nativeOnChain } from 'constants/tokens'
import { Chain, useTokenSpotPriceQuery } from 'graphql/data/__generated__/types-and-hooks' import { Chain, useTokenSpotPriceQuery } from 'graphql/data/__generated__/types-and-hooks'
import { chainIdToBackendName, isGqlSupportedChain, PollingInterval } from 'graphql/data/util' import { chainIdToBackendName, isGqlSupportedChain, PollingInterval } from 'graphql/data/util'
...@@ -13,11 +13,11 @@ import useStablecoinPrice from './useStablecoinPrice' ...@@ -13,11 +13,11 @@ import useStablecoinPrice from './useStablecoinPrice'
// ETH amounts used when calculating spot price for a given currency. // ETH amounts used when calculating spot price for a given currency.
// The amount is large enough to filter low liquidity pairs. // The amount is large enough to filter low liquidity pairs.
const ETH_AMOUNT_OUT: { [chainId: number]: CurrencyAmount<Currency> } = { const ETH_AMOUNT_OUT: { [chainId: number]: CurrencyAmount<Currency> } = {
[SupportedChainId.MAINNET]: CurrencyAmount.fromRawAmount(nativeOnChain(SupportedChainId.MAINNET), 50e18), [ChainId.MAINNET]: CurrencyAmount.fromRawAmount(nativeOnChain(ChainId.MAINNET), 50e18),
[SupportedChainId.ARBITRUM_ONE]: CurrencyAmount.fromRawAmount(nativeOnChain(SupportedChainId.ARBITRUM_ONE), 10e18), [ChainId.ARBITRUM_ONE]: CurrencyAmount.fromRawAmount(nativeOnChain(ChainId.ARBITRUM_ONE), 10e18),
[SupportedChainId.OPTIMISM]: CurrencyAmount.fromRawAmount(nativeOnChain(SupportedChainId.OPTIMISM), 10e18), [ChainId.OPTIMISM]: CurrencyAmount.fromRawAmount(nativeOnChain(ChainId.OPTIMISM), 10e18),
[SupportedChainId.POLYGON]: CurrencyAmount.fromRawAmount(nativeOnChain(SupportedChainId.POLYGON), 10_000e18), [ChainId.POLYGON]: CurrencyAmount.fromRawAmount(nativeOnChain(ChainId.POLYGON), 10_000e18),
[SupportedChainId.CELO]: CurrencyAmount.fromRawAmount(nativeOnChain(SupportedChainId.CELO), 10e18), [ChainId.CELO]: CurrencyAmount.fromRawAmount(nativeOnChain(ChainId.CELO), 10e18),
} }
function useETHValue(currencyAmount?: CurrencyAmount<Currency>): { function useETHValue(currencyAmount?: CurrencyAmount<Currency>): {
......
import { Interface } from '@ethersproject/abi' import { Interface } from '@ethersproject/abi'
import { Currency, CurrencyAmount } from '@uniswap/sdk-core' import { Currency, CurrencyAmount, V2_FACTORY_ADDRESSES } from '@uniswap/sdk-core'
import IUniswapV2PairJSON from '@uniswap/v2-core/build/IUniswapV2Pair.json' import IUniswapV2PairJSON from '@uniswap/v2-core/build/IUniswapV2Pair.json'
import { computePairAddress, Pair } from '@uniswap/v2-sdk' import { computePairAddress, Pair } from '@uniswap/v2-sdk'
import { useMultipleContractSingleData } from 'lib/hooks/multicall' import { useMultipleContractSingleData } from 'lib/hooks/multicall'
import { useMemo } from 'react' import { useMemo } from 'react'
import { V2_FACTORY_ADDRESSES } from '../constants/addresses'
const PAIR_INTERFACE = new Interface(IUniswapV2PairJSON.abi) const PAIR_INTERFACE = new Interface(IUniswapV2PairJSON.abi)
export enum PairState { export enum PairState {
......
import { Currency, Token } from '@uniswap/sdk-core' import { ChainId, Currency, Token } from '@uniswap/sdk-core'
import { FeeAmount, Pool } from '@uniswap/v3-sdk' import { FeeAmount, Pool } from '@uniswap/v3-sdk'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { SupportedChainId } from 'constants/chains'
import { useMemo } from 'react' import { useMemo } from 'react'
import { useAllCurrencyCombinations } from './useAllCurrencyCombinations' import { useAllCurrencyCombinations } from './useAllCurrencyCombinations'
...@@ -26,7 +25,7 @@ export function useV3SwapPools( ...@@ -26,7 +25,7 @@ export function useV3SwapPools(
const allCurrencyCombinationsWithAllFees: [Token, Token, FeeAmount][] = useMemo( const allCurrencyCombinationsWithAllFees: [Token, Token, FeeAmount][] = useMemo(
() => () =>
allCurrencyCombinations.reduce<[Token, Token, FeeAmount][]>((list, [tokenA, tokenB]) => { allCurrencyCombinations.reduce<[Token, Token, FeeAmount][]>((list, [tokenA, tokenB]) => {
return chainId === SupportedChainId.MAINNET return chainId === ChainId.MAINNET
? list.concat([ ? list.concat([
[tokenA, tokenB, FeeAmount.LOW], [tokenA, tokenB, FeeAmount.LOW],
[tokenA, tokenB, FeeAmount.MEDIUM], [tokenA, tokenB, FeeAmount.MEDIUM],
......
import { BigintIsh, CurrencyAmount, Token, TradeType } from '@uniswap/sdk-core' import { BigintIsh, CurrencyAmount, Token, TradeType } from '@uniswap/sdk-core'
// This file is lazy-loaded, so the import of smart-order-router is intentional. // This file is lazy-loaded, so the import of smart-order-router is intentional.
// eslint-disable-next-line no-restricted-imports // eslint-disable-next-line no-restricted-imports
import { AlphaRouter, AlphaRouterConfig, ChainId } from '@uniswap/smart-order-router' import { AlphaRouter, AlphaRouterConfig } from '@uniswap/smart-order-router'
import { SupportedChainId } from 'constants/chains'
import { nativeOnChain } from 'constants/tokens' import { nativeOnChain } from 'constants/tokens'
import JSBI from 'jsbi' import JSBI from 'jsbi'
import { GetQuoteArgs } from 'state/routing/slice' import { GetQuoteArgs } from 'state/routing/slice'
import { QuoteResult, QuoteState, SwapRouterNativeAssets } from 'state/routing/types' import { QuoteResult, QuoteState, SwapRouterNativeAssets } from 'state/routing/types'
import { transformSwapRouteToGetQuoteResult } from 'utils/transformSwapRouteToGetQuoteResult' import { transformSwapRouteToGetQuoteResult } from 'utils/transformSwapRouteToGetQuoteResult'
export function toSupportedChainId(chainId: ChainId): SupportedChainId | undefined {
const numericChainId: number = chainId
if (SupportedChainId[numericChainId]) return numericChainId
return undefined
}
export function isSupportedChainId(chainId: ChainId | undefined): boolean {
if (chainId === undefined) return false
return toSupportedChainId(chainId) !== undefined
}
async function getQuote( async function getQuote(
{ {
tradeType, tradeType,
......
import { TransactionReceipt } from '@ethersproject/abstract-provider' import { TransactionReceipt } from '@ethersproject/abstract-provider'
import { ChainId } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { SupportedChainId } from 'constants/chains'
import useCurrentBlockTimestamp from 'hooks/useCurrentBlockTimestamp' import useCurrentBlockTimestamp from 'hooks/useCurrentBlockTimestamp'
import useBlockNumber, { useFastForwardBlockNumber } from 'lib/hooks/useBlockNumber' import useBlockNumber, { useFastForwardBlockNumber } from 'lib/hooks/useBlockNumber'
import ms from 'ms.macro' import ms from 'ms.macro'
...@@ -35,10 +35,10 @@ export function shouldCheck(lastBlockNumber: number, tx: Transaction): boolean { ...@@ -35,10 +35,10 @@ export function shouldCheck(lastBlockNumber: number, tx: Transaction): boolean {
} }
const RETRY_OPTIONS_BY_CHAIN_ID: { [chainId: number]: RetryOptions } = { const RETRY_OPTIONS_BY_CHAIN_ID: { [chainId: number]: RetryOptions } = {
[SupportedChainId.ARBITRUM_ONE]: { n: 10, minWait: 250, maxWait: 1000 }, [ChainId.ARBITRUM_ONE]: { n: 10, minWait: 250, maxWait: 1000 },
[SupportedChainId.ARBITRUM_GOERLI]: { n: 10, minWait: 250, maxWait: 1000 }, [ChainId.ARBITRUM_GOERLI]: { n: 10, minWait: 250, maxWait: 1000 },
[SupportedChainId.OPTIMISM]: { n: 10, minWait: 250, maxWait: 1000 }, [ChainId.OPTIMISM]: { n: 10, minWait: 250, maxWait: 1000 },
[SupportedChainId.OPTIMISM_GOERLI]: { n: 10, minWait: 250, maxWait: 1000 }, [ChainId.OPTIMISM_GOERLI]: { n: 10, minWait: 250, maxWait: 1000 },
} }
const DEFAULT_RETRY_OPTIONS: RetryOptions = { n: 1, minWait: 0, maxWait: 0 } const DEFAULT_RETRY_OPTIONS: RetryOptions = { n: 1, minWait: 0, maxWait: 0 }
......
import { arrayify } from '@ethersproject/bytes' import { arrayify } from '@ethersproject/bytes'
import { parseBytes32String } from '@ethersproject/strings' import { parseBytes32String } from '@ethersproject/strings'
import { Currency, Token } from '@uniswap/sdk-core' import { ChainId, Currency, Token } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { isSupportedChain, SupportedChainId } from 'constants/chains' import { asSupportedChain, isSupportedChain } from 'constants/chains'
import { useBytes32TokenContract, useTokenContract } from 'hooks/useContract' import { useBytes32TokenContract, useTokenContract } from 'hooks/useContract'
import { NEVER_RELOAD, useSingleCallResult } from 'lib/hooks/multicall' import { NEVER_RELOAD, useSingleCallResult } from 'lib/hooks/multicall'
import useNativeCurrency from 'lib/hooks/useNativeCurrency' import useNativeCurrency from 'lib/hooks/useNativeCurrency'
...@@ -11,7 +11,6 @@ import { useMemo } from 'react' ...@@ -11,7 +11,6 @@ import { useMemo } from 'react'
import { DEFAULT_ERC20_DECIMALS } from '../../constants/tokens' import { DEFAULT_ERC20_DECIMALS } from '../../constants/tokens'
import { TOKEN_SHORTHANDS } from '../../constants/tokens' import { TOKEN_SHORTHANDS } from '../../constants/tokens'
import { isAddress } from '../../utils' import { isAddress } from '../../utils'
import { supportedChainId } from '../../utils/supportedChainId'
// parse a name or symbol from a token response // parse a name or symbol from a token response
const BYTES32_REGEX = /^0x[a-fA-F0-9]{64}$/ const BYTES32_REGEX = /^0x[a-fA-F0-9]{64}$/
...@@ -94,13 +93,13 @@ export function useTokenFromMapOrNetwork(tokens: TokenMap, tokenAddress?: string ...@@ -94,13 +93,13 @@ export function useTokenFromMapOrNetwork(tokens: TokenMap, tokenAddress?: string
*/ */
export function useCurrencyFromMap( export function useCurrencyFromMap(
tokens: TokenMap, tokens: TokenMap,
chainId: SupportedChainId | undefined, chainId: ChainId | undefined,
currencyId?: string | null currencyId?: string | null
): Currency | null | undefined { ): Currency | null | undefined {
const nativeCurrency = useNativeCurrency(chainId) const nativeCurrency = useNativeCurrency(chainId)
const isNative = Boolean(nativeCurrency && currencyId?.toUpperCase() === 'ETH') const isNative = Boolean(nativeCurrency && currencyId?.toUpperCase() === 'ETH')
const shorthandMatchAddress = useMemo(() => { const shorthandMatchAddress = useMemo(() => {
const chain = supportedChainId(chainId) const chain = asSupportedChain(chainId)
return chain && currencyId ? TOKEN_SHORTHANDS[currencyId.toUpperCase()]?.[chain] : undefined return chain && currencyId ? TOKEN_SHORTHANDS[currencyId.toUpperCase()]?.[chain] : undefined
}, [chainId, currencyId]) }, [chainId, currencyId])
......
import { SupportedChainId } from 'constants/chains' import { ChainId } from '@uniswap/sdk-core'
import useHttpLocations from 'hooks/useHttpLocations' import useHttpLocations from 'hooks/useHttpLocations'
import { useMemo } from 'react' import { useMemo } from 'react'
import { isAddress } from 'utils' import { isAddress } from 'utils'
import EthereumLogo from '../../assets/images/ethereum-logo.png' import EthereumLogo from '../../assets/images/ethereum-logo.png'
import AvaxLogo from '../../assets/svg/avax_logo.svg'
import BnbLogo from '../../assets/svg/bnb-logo.svg' import BnbLogo from '../../assets/svg/bnb-logo.svg'
import CeloLogo from '../../assets/svg/celo_logo.svg' import CeloLogo from '../../assets/svg/celo_logo.svg'
import MaticLogo from '../../assets/svg/matic-token-icon.svg' import MaticLogo from '../../assets/svg/matic-token-icon.svg'
import { isCelo, NATIVE_CHAIN_ID, nativeOnChain } from '../../constants/tokens' import { isCelo, NATIVE_CHAIN_ID, nativeOnChain } from '../../constants/tokens'
type Network = 'ethereum' | 'arbitrum' | 'optimism' | 'polygon' | 'smartchain' | 'celo' type Network = 'ethereum' | 'arbitrum' | 'optimism' | 'polygon' | 'smartchain' | 'celo' | 'avalanchec'
export function chainIdToNetworkName(networkId: SupportedChainId): Network { export function chainIdToNetworkName(networkId: ChainId): Network {
switch (networkId) { switch (networkId) {
case SupportedChainId.MAINNET: case ChainId.MAINNET:
return 'ethereum' return 'ethereum'
case SupportedChainId.ARBITRUM_ONE: case ChainId.ARBITRUM_ONE:
return 'arbitrum' return 'arbitrum'
case SupportedChainId.OPTIMISM: case ChainId.OPTIMISM:
return 'optimism' return 'optimism'
case SupportedChainId.POLYGON: case ChainId.POLYGON:
return 'polygon' return 'polygon'
case SupportedChainId.BNB: case ChainId.BNB:
return 'smartchain' return 'smartchain'
case SupportedChainId.CELO: case ChainId.CELO:
return 'celo' return 'celo'
case ChainId.AVALANCHE:
return 'avalanchec'
default: default:
return 'ethereum' return 'ethereum'
} }
} }
export function getNativeLogoURI(chainId: SupportedChainId = SupportedChainId.MAINNET): string { export function getNativeLogoURI(chainId: ChainId = ChainId.MAINNET): string {
switch (chainId) { switch (chainId) {
case SupportedChainId.POLYGON: case ChainId.POLYGON:
case SupportedChainId.POLYGON_MUMBAI: case ChainId.POLYGON_MUMBAI:
return MaticLogo return MaticLogo
case SupportedChainId.BNB: case ChainId.BNB:
return BnbLogo return BnbLogo
case SupportedChainId.CELO: case ChainId.CELO:
case SupportedChainId.CELO_ALFAJORES: case ChainId.CELO_ALFAJORES:
return CeloLogo return CeloLogo
case ChainId.AVALANCHE:
return AvaxLogo
default: default:
return EthereumLogo return EthereumLogo
} }
} }
function getTokenLogoURI(address: string, chainId: SupportedChainId = SupportedChainId.MAINNET): string | void { function getTokenLogoURI(address: string, chainId: ChainId = ChainId.MAINNET): string | void {
const networkName = chainIdToNetworkName(chainId) const networkName = chainIdToNetworkName(chainId)
const networksWithUrls = [ const networksWithUrls = [ChainId.ARBITRUM_ONE, ChainId.MAINNET, ChainId.OPTIMISM, ChainId.BNB, ChainId.AVALANCHE]
SupportedChainId.ARBITRUM_ONE,
SupportedChainId.MAINNET,
SupportedChainId.OPTIMISM,
SupportedChainId.BNB,
]
if (isCelo(chainId) && address === nativeOnChain(chainId).wrapped.address) { if (isCelo(chainId) && address === nativeOnChain(chainId).wrapped.address) {
return CeloLogo return CeloLogo
} }
......
import { NativeCurrency, Token } from '@uniswap/sdk-core' import { ChainId, NativeCurrency, Token } from '@uniswap/sdk-core'
import { SupportedChainId } from 'constants/chains'
import { nativeOnChain } from 'constants/tokens' import { nativeOnChain } from 'constants/tokens'
import { useMemo } from 'react' import { useMemo } from 'react'
export default function useNativeCurrency(chainId: SupportedChainId | null | undefined): NativeCurrency | Token { export default function useNativeCurrency(chainId: ChainId | null | undefined): NativeCurrency | Token {
return useMemo( return useMemo(
() => () =>
chainId chainId
? nativeOnChain(chainId) ? nativeOnChain(chainId)
: // display mainnet when not connected : // display mainnet when not connected
nativeOnChain(SupportedChainId.MAINNET), nativeOnChain(ChainId.MAINNET),
[chainId] [chainId]
) )
} }
import { createMulticall, ListenerOptions } from '@uniswap/redux-multicall' import { createMulticall, ListenerOptions } from '@uniswap/redux-multicall'
import { ChainId } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { SupportedChainId } from 'constants/chains'
import { useInterfaceMulticall } from 'hooks/useContract' import { useInterfaceMulticall } from 'hooks/useContract'
import useBlockNumber from 'lib/hooks/useBlockNumber' import useBlockNumber from 'lib/hooks/useBlockNumber'
import { useMemo } from 'react' import { useMemo } from 'react'
...@@ -9,14 +9,21 @@ const multicall = createMulticall() ...@@ -9,14 +9,21 @@ const multicall = createMulticall()
export default multicall export default multicall
/**
*
* @param chainId
* @returns The approximate whole number of blocks written to the corresponding chainId per Ethereum mainnet epoch.
*/
function getBlocksPerFetchForChainId(chainId: number | undefined): number { function getBlocksPerFetchForChainId(chainId: number | undefined): number {
// TODO(WEB-2437): See if these numbers need to be updated
switch (chainId) { switch (chainId) {
case SupportedChainId.ARBITRUM_ONE: case ChainId.ARBITRUM_ONE:
case SupportedChainId.OPTIMISM: case ChainId.OPTIMISM:
return 15 return 15
case SupportedChainId.BNB: case ChainId.AVALANCHE:
case SupportedChainId.CELO: case ChainId.BNB:
case SupportedChainId.CELO_ALFAJORES: case ChainId.CELO:
case ChainId.CELO_ALFAJORES:
return 5 return 5
default: default:
return 1 return 1
......
import { BigNumber } from '@ethersproject/bignumber' import { BigNumber } from '@ethersproject/bignumber'
import { parseEther } from '@ethersproject/units' import { parseEther } from '@ethersproject/units'
import { CurrencyAmount, Percent, SupportedChainId } from '@uniswap/sdk-core' import { ChainId, CurrencyAmount, Percent } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { nativeOnChain } from 'constants/tokens' import { nativeOnChain } from 'constants/tokens'
import { useNftUniversalRouterAddress } from 'graphql/data/nft/NftUniversalRouterAddress' import { useNftUniversalRouterAddress } from 'graphql/data/nft/NftUniversalRouterAddress'
...@@ -86,7 +86,7 @@ describe('BagFooter.tsx', () => { ...@@ -86,7 +86,7 @@ describe('BagFooter.tsx', () => {
allowedSlippage: new Percent(10, 100), allowedSlippage: new Percent(10, 100),
}) })
mocked(usePayWithAnyTokenSwap).mockReturnValue() mocked(usePayWithAnyTokenSwap).mockReturnValue()
mocked(useCurrency).mockReturnValue(nativeOnChain(SupportedChainId.MAINNET)) mocked(useCurrency).mockReturnValue(nativeOnChain(ChainId.MAINNET))
mocked(useTokenInput).mockReturnValue({ mocked(useTokenInput).mockReturnValue({
inputCurrency: undefined, inputCurrency: undefined,
setInputCurrency: () => undefined, setInputCurrency: () => undefined,
......
...@@ -3,7 +3,7 @@ import { formatEther, parseEther } from '@ethersproject/units' ...@@ -3,7 +3,7 @@ import { formatEther, parseEther } from '@ethersproject/units'
import { t, Trans } from '@lingui/macro' import { t, Trans } from '@lingui/macro'
import { sendAnalyticsEvent, TraceEvent } from '@uniswap/analytics' import { sendAnalyticsEvent, TraceEvent } from '@uniswap/analytics'
import { BrowserEvent, InterfaceElementName, NFTEventName } from '@uniswap/analytics-events' import { BrowserEvent, InterfaceElementName, NFTEventName } from '@uniswap/analytics-events'
import { Currency, CurrencyAmount, Token } from '@uniswap/sdk-core' import { ChainId, Currency, CurrencyAmount, Token } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { useToggleAccountDrawer } from 'components/AccountDrawer' import { useToggleAccountDrawer } from 'components/AccountDrawer'
import Column from 'components/Column' import Column from 'components/Column'
...@@ -13,7 +13,7 @@ import Row from 'components/Row' ...@@ -13,7 +13,7 @@ import Row from 'components/Row'
import CurrencySearchModal from 'components/SearchModal/CurrencySearchModal' import CurrencySearchModal from 'components/SearchModal/CurrencySearchModal'
import { LoadingBubble } from 'components/Tokens/loading' import { LoadingBubble } from 'components/Tokens/loading'
import { MouseoverTooltip } from 'components/Tooltip' import { MouseoverTooltip } from 'components/Tooltip'
import { isSupportedChain, SupportedChainId } from 'constants/chains' import { isSupportedChain } from 'constants/chains'
import { useNftUniversalRouterAddress } from 'graphql/data/nft/NftUniversalRouterAddress' import { useNftUniversalRouterAddress } from 'graphql/data/nft/NftUniversalRouterAddress'
import { useCurrency } from 'hooks/Tokens' import { useCurrency } from 'hooks/Tokens'
import { AllowanceState } from 'hooks/usePermit2Allowance' import { AllowanceState } from 'hooks/usePermit2Allowance'
...@@ -297,7 +297,7 @@ export const BagFooter = ({ setModalIsOpen, eventProperties }: BagFooterProps) = ...@@ -297,7 +297,7 @@ export const BagFooter = ({ setModalIsOpen, eventProperties }: BagFooterProps) =
const [tokenSelectorOpen, setTokenSelectorOpen] = useState(false) const [tokenSelectorOpen, setTokenSelectorOpen] = useState(false)
const isPending = PENDING_BAG_STATUSES.includes(bagStatus) const isPending = PENDING_BAG_STATUSES.includes(bagStatus)
const activeCurrency = inputCurrency ?? defaultCurrency const activeCurrency = inputCurrency ?? defaultCurrency
const usingPayWithAnyToken = !!inputCurrency && chainId === SupportedChainId.MAINNET const usingPayWithAnyToken = !!inputCurrency && chainId === ChainId.MAINNET
const { universalRouterAddress, universalRouterAddressIsLoading } = useNftUniversalRouterAddress() const { universalRouterAddress, universalRouterAddressIsLoading } = useNftUniversalRouterAddress()
useSubscribeTransactionState(setModalIsOpen) useSubscribeTransactionState(setModalIsOpen)
...@@ -327,7 +327,7 @@ export const BagFooter = ({ setModalIsOpen, eventProperties }: BagFooterProps) = ...@@ -327,7 +327,7 @@ export const BagFooter = ({ setModalIsOpen, eventProperties }: BagFooterProps) =
const { balance: balanceInEth } = useWalletBalance() const { balance: balanceInEth } = useWalletBalance()
const sufficientBalance = useMemo(() => { const sufficientBalance = useMemo(() => {
if (!connected || chainId !== SupportedChainId.MAINNET) { if (!connected || chainId !== ChainId.MAINNET) {
return undefined return undefined
} }
...@@ -360,8 +360,8 @@ export const BagFooter = ({ setModalIsOpen, eventProperties }: BagFooterProps) = ...@@ -360,8 +360,8 @@ export const BagFooter = ({ setModalIsOpen, eventProperties }: BagFooterProps) =
handleClick, handleClick,
buttonColor, buttonColor,
} = useMemo((): BuyButtonStateData => { } = useMemo((): BuyButtonStateData => {
if (connected && chainId !== SupportedChainId.MAINNET) { if (connected && chainId !== ChainId.MAINNET) {
const handleClick = () => switchChain(connector, SupportedChainId.MAINNET) const handleClick = () => switchChain(connector, ChainId.MAINNET)
return getBuyButtonStateData(BuyButtonStates.NOT_SUPPORTED_CHAIN, theme, handleClick) return getBuyButtonStateData(BuyButtonStates.NOT_SUPPORTED_CHAIN, theme, handleClick)
} }
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { sendAnalyticsEvent, useTrace } from '@uniswap/analytics' import { sendAnalyticsEvent, useTrace } from '@uniswap/analytics'
import { InterfacePageName, NFTEventName } from '@uniswap/analytics-events' import { InterfacePageName, NFTEventName } from '@uniswap/analytics-events'
import { ChainId } from '@uniswap/smart-order-router' import { ChainId } from '@uniswap/sdk-core'
import { MouseoverTooltip } from 'components/Tooltip' import { MouseoverTooltip } from 'components/Tooltip'
import { NftActivityType, NftMarketplace, OrderStatus } from 'graphql/data/__generated__/types-and-hooks' import { NftActivityType, NftMarketplace, OrderStatus } from 'graphql/data/__generated__/types-and-hooks'
import { Box } from 'nft/components/Box' import { Box } from 'nft/components/Box'
......
import { sendAnalyticsEvent } from '@uniswap/analytics' import { sendAnalyticsEvent } from '@uniswap/analytics'
import { InterfaceEventName } from '@uniswap/analytics-events' import { InterfaceEventName } from '@uniswap/analytics-events'
import { CurrencyAmount, SupportedChainId, Token } from '@uniswap/sdk-core' import { ChainId, CurrencyAmount, Token } from '@uniswap/sdk-core'
import { UNIVERSAL_ROUTER_ADDRESS } from '@uniswap/universal-router-sdk' import { UNIVERSAL_ROUTER_ADDRESS } from '@uniswap/universal-router-sdk'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { isSupportedChain } from 'constants/chains' import { isSupportedChain } from 'constants/chains'
...@@ -12,7 +12,7 @@ function getURAddress(chainId?: number, nftURAddress?: string) { ...@@ -12,7 +12,7 @@ function getURAddress(chainId?: number, nftURAddress?: string) {
if (!chainId) return if (!chainId) return
// if mainnet and on NFT flow, use the contract address returned by GQL // if mainnet and on NFT flow, use the contract address returned by GQL
if (chainId === SupportedChainId.MAINNET) { if (chainId === ChainId.MAINNET) {
return nftURAddress ?? UNIVERSAL_ROUTER_ADDRESS(chainId) return nftURAddress ?? UNIVERSAL_ROUTER_ADDRESS(chainId)
} }
......
...@@ -3,7 +3,7 @@ import type { TransactionResponse } from '@ethersproject/providers' ...@@ -3,7 +3,7 @@ import type { TransactionResponse } from '@ethersproject/providers'
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { TraceEvent } from '@uniswap/analytics' import { TraceEvent } from '@uniswap/analytics'
import { BrowserEvent, InterfaceElementName, InterfaceEventName } from '@uniswap/analytics-events' import { BrowserEvent, InterfaceElementName, InterfaceEventName } from '@uniswap/analytics-events'
import { Currency, CurrencyAmount, Percent } from '@uniswap/sdk-core' import { Currency, CurrencyAmount, NONFUNGIBLE_POSITION_MANAGER_ADDRESSES, Percent } from '@uniswap/sdk-core'
import { FeeAmount, NonfungiblePositionManager } from '@uniswap/v3-sdk' import { FeeAmount, NonfungiblePositionManager } from '@uniswap/v3-sdk'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { useToggleAccountDrawer } from 'components/AccountDrawer' import { useToggleAccountDrawer } from 'components/AccountDrawer'
...@@ -42,7 +42,6 @@ import RateToggle from '../../components/RateToggle' ...@@ -42,7 +42,6 @@ import RateToggle from '../../components/RateToggle'
import Row, { AutoRow, RowBetween, RowFixed } from '../../components/Row' import Row, { AutoRow, RowBetween, RowFixed } from '../../components/Row'
import { SwitchLocaleLink } from '../../components/SwitchLocaleLink' import { SwitchLocaleLink } from '../../components/SwitchLocaleLink'
import TransactionConfirmationModal, { ConfirmationModalContent } from '../../components/TransactionConfirmationModal' import TransactionConfirmationModal, { ConfirmationModalContent } from '../../components/TransactionConfirmationModal'
import { NONFUNGIBLE_POSITION_MANAGER_ADDRESSES } from '../../constants/addresses'
import { ZERO_PERCENT } from '../../constants/misc' import { ZERO_PERCENT } from '../../constants/misc'
import { WRAPPED_NATIVE_CURRENCY } from '../../constants/tokens' import { WRAPPED_NATIVE_CURRENCY } from '../../constants/tokens'
import { useCurrency } from '../../hooks/Tokens' import { useCurrency } from '../../hooks/Tokens'
......
import { Contract } from '@ethersproject/contracts' import { Contract } from '@ethersproject/contracts'
import type { TransactionResponse } from '@ethersproject/providers' import type { TransactionResponse } from '@ethersproject/providers'
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { CurrencyAmount, Fraction, Percent, Price, Token } from '@uniswap/sdk-core' import { CurrencyAmount, Fraction, Percent, Price, Token, V2_FACTORY_ADDRESSES } from '@uniswap/sdk-core'
import { FeeAmount, Pool, Position, priceToClosestTick, TickMath } from '@uniswap/v3-sdk' import { FeeAmount, Pool, Position, priceToClosestTick, TickMath } from '@uniswap/v3-sdk'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { sendEvent } from 'components/analytics' import { sendEvent } from 'components/analytics'
...@@ -38,7 +38,6 @@ import { AutoColumn } from '../../components/Column' ...@@ -38,7 +38,6 @@ import { AutoColumn } from '../../components/Column'
import FormattedCurrencyAmount from '../../components/FormattedCurrencyAmount' import FormattedCurrencyAmount from '../../components/FormattedCurrencyAmount'
import CurrencyLogo from '../../components/Logo/CurrencyLogo' import CurrencyLogo from '../../components/Logo/CurrencyLogo'
import { AutoRow, RowBetween, RowFixed } from '../../components/Row' import { AutoRow, RowBetween, RowFixed } from '../../components/Row'
import { V2_FACTORY_ADDRESSES } from '../../constants/addresses'
import { WRAPPED_NATIVE_CURRENCY } from '../../constants/tokens' import { WRAPPED_NATIVE_CURRENCY } from '../../constants/tokens'
import { useToken } from '../../hooks/Tokens' import { useToken } from '../../hooks/Tokens'
import { usePairContract, useV2MigratorContract } from '../../hooks/useContract' import { usePairContract, useV2MigratorContract } from '../../hooks/useContract'
......
import { getCreate2Address } from '@ethersproject/address' import { getCreate2Address } from '@ethersproject/address'
import { keccak256, pack } from '@ethersproject/solidity' import { keccak256, pack } from '@ethersproject/solidity'
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { Token } from '@uniswap/sdk-core' import { Token, V2_FACTORY_ADDRESSES } from '@uniswap/sdk-core'
import { Pair } from '@uniswap/v2-sdk' import { Pair } from '@uniswap/v2-sdk'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import MigrateSushiPositionCard from 'components/PositionCard/Sushi' import MigrateSushiPositionCard from 'components/PositionCard/Sushi'
...@@ -17,7 +17,6 @@ import { AutoColumn } from '../../components/Column' ...@@ -17,7 +17,6 @@ import { AutoColumn } from '../../components/Column'
import QuestionHelper from '../../components/QuestionHelper' import QuestionHelper from '../../components/QuestionHelper'
import { AutoRow } from '../../components/Row' import { AutoRow } from '../../components/Row'
import { Dots } from '../../components/swap/styleds' import { Dots } from '../../components/swap/styleds'
import { V2_FACTORY_ADDRESSES } from '../../constants/addresses'
import { useTokenBalancesWithLoadingIndicator } from '../../state/connection/hooks' import { useTokenBalancesWithLoadingIndicator } from '../../state/connection/hooks'
import { toV2LiquidityToken, useTrackedTokenPairs } from '../../state/user/hooks' import { toV2LiquidityToken, useTrackedTokenPairs } from '../../state/user/hooks'
import { BackArrowLink, StyledInternalLink, ThemedText } from '../../theme' import { BackArrowLink, StyledInternalLink, ThemedText } from '../../theme'
......
...@@ -4,7 +4,7 @@ import { Trans } from '@lingui/macro' ...@@ -4,7 +4,7 @@ import { Trans } from '@lingui/macro'
import { Trace } from '@uniswap/analytics' import { Trace } from '@uniswap/analytics'
import { InterfacePageName } from '@uniswap/analytics-events' import { InterfacePageName } from '@uniswap/analytics-events'
import { formatPrice, NumberType } from '@uniswap/conedison/format' import { formatPrice, NumberType } from '@uniswap/conedison/format'
import { Currency, CurrencyAmount, Fraction, Percent, Price, Token } from '@uniswap/sdk-core' import { ChainId, Currency, CurrencyAmount, Fraction, Percent, Price, Token } from '@uniswap/sdk-core'
import { NonfungiblePositionManager, Pool, Position } from '@uniswap/v3-sdk' import { NonfungiblePositionManager, Pool, Position } from '@uniswap/v3-sdk'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { sendEvent } from 'components/analytics' import { sendEvent } from 'components/analytics'
...@@ -19,7 +19,7 @@ import { RowBetween, RowFixed } from 'components/Row' ...@@ -19,7 +19,7 @@ import { RowBetween, RowFixed } from 'components/Row'
import { Dots } from 'components/swap/styleds' import { Dots } from 'components/swap/styleds'
import Toggle from 'components/Toggle' import Toggle from 'components/Toggle'
import TransactionConfirmationModal, { ConfirmationModalContent } from 'components/TransactionConfirmationModal' import TransactionConfirmationModal, { ConfirmationModalContent } from 'components/TransactionConfirmationModal'
import { CHAIN_IDS_TO_NAMES, isSupportedChain, SupportedChainId } from 'constants/chains' import { CHAIN_IDS_TO_NAMES, isSupportedChain } from 'constants/chains'
import { isGqlSupportedChain } from 'graphql/data/util' import { isGqlSupportedChain } from 'graphql/data/util'
import { useToken } from 'hooks/Tokens' import { useToken } from 'hooks/Tokens'
import { useV3NFTPositionManagerContract } from 'hooks/useContract' import { useV3NFTPositionManagerContract } from 'hooks/useContract'
...@@ -52,7 +52,7 @@ import { calculateGasMargin } from '../../utils/calculateGasMargin' ...@@ -52,7 +52,7 @@ import { calculateGasMargin } from '../../utils/calculateGasMargin'
import { ExplorerDataType, getExplorerLink } from '../../utils/getExplorerLink' import { ExplorerDataType, getExplorerLink } from '../../utils/getExplorerLink'
import { LoadingRows } from './styleds' import { LoadingRows } from './styleds'
const getTokenLink = (chainId: SupportedChainId, address: string) => { const getTokenLink = (chainId: ChainId, address: string) => {
if (isGqlSupportedChain(chainId)) { if (isGqlSupportedChain(chainId)) {
const chainName = CHAIN_IDS_TO_NAMES[chainId] const chainName = CHAIN_IDS_TO_NAMES[chainId]
return `${window.location.origin}/#/tokens/${chainName}/${address}` return `${window.location.origin}/#/tokens/${chainName}/${address}`
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { Trace, TraceEvent } from '@uniswap/analytics' import { Trace, TraceEvent } from '@uniswap/analytics'
import { BrowserEvent, InterfaceElementName, InterfaceEventName, InterfacePageName } from '@uniswap/analytics-events' import { BrowserEvent, InterfaceElementName, InterfaceEventName, InterfacePageName } from '@uniswap/analytics-events'
import { V2_FACTORY_ADDRESSES } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { useToggleAccountDrawer } from 'components/AccountDrawer' import { useToggleAccountDrawer } from 'components/AccountDrawer'
import { ButtonGray, ButtonPrimary, ButtonText } from 'components/Button' import { ButtonGray, ButtonPrimary, ButtonText } from 'components/Button'
...@@ -20,7 +21,6 @@ import styled, { css, useTheme } from 'styled-components/macro' ...@@ -20,7 +21,6 @@ import styled, { css, useTheme } from 'styled-components/macro'
import { HideSmall, ThemedText } from 'theme' import { HideSmall, ThemedText } from 'theme'
import { PositionDetails } from 'types/position' import { PositionDetails } from 'types/position'
import { V2_FACTORY_ADDRESSES } from '../../constants/addresses'
import CTACards from './CTACards' import CTACards from './CTACards'
import { LoadingRows } from './styleds' import { LoadingRows } from './styleds'
......
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
SwapEventName, SwapEventName,
} from '@uniswap/analytics-events' } from '@uniswap/analytics-events'
import { formatCurrencyAmount, NumberType } from '@uniswap/conedison/format' import { formatCurrencyAmount, NumberType } from '@uniswap/conedison/format'
import { Currency, CurrencyAmount, Percent, Token } from '@uniswap/sdk-core' import { ChainId, Currency, CurrencyAmount, Percent, Token } from '@uniswap/sdk-core'
import { UNIVERSAL_ROUTER_ADDRESS } from '@uniswap/universal-router-sdk' import { UNIVERSAL_ROUTER_ADDRESS } from '@uniswap/universal-router-sdk'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { useToggleAccountDrawer } from 'components/AccountDrawer' import { useToggleAccountDrawer } from 'components/AccountDrawer'
...@@ -21,7 +21,7 @@ import PriceImpactWarning from 'components/swap/PriceImpactWarning' ...@@ -21,7 +21,7 @@ import PriceImpactWarning from 'components/swap/PriceImpactWarning'
import SwapDetailsDropdown from 'components/swap/SwapDetailsDropdown' import SwapDetailsDropdown from 'components/swap/SwapDetailsDropdown'
import TokenSafetyModal from 'components/TokenSafety/TokenSafetyModal' import TokenSafetyModal from 'components/TokenSafety/TokenSafetyModal'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { isSupportedChain, SupportedChainId } from 'constants/chains' import { asSupportedChain, isSupportedChain } from 'constants/chains'
import useENSAddress from 'hooks/useENSAddress' import useENSAddress from 'hooks/useENSAddress'
import { useMaxAmountIn } from 'hooks/useMaxAmountIn' import { useMaxAmountIn } from 'hooks/useMaxAmountIn'
import usePermit2Allowance, { AllowanceState } from 'hooks/usePermit2Allowance' import usePermit2Allowance, { AllowanceState } from 'hooks/usePermit2Allowance'
...@@ -62,7 +62,6 @@ import { LinkStyledButton, ThemedText } from '../../theme' ...@@ -62,7 +62,6 @@ import { LinkStyledButton, ThemedText } from '../../theme'
import { computeFiatValuePriceImpact } from '../../utils/computeFiatValuePriceImpact' import { computeFiatValuePriceImpact } from '../../utils/computeFiatValuePriceImpact'
import { maxAmountSpend } from '../../utils/maxAmountSpend' import { maxAmountSpend } from '../../utils/maxAmountSpend'
import { computeRealizedPriceImpact, warningSeverity } from '../../utils/prices' import { computeRealizedPriceImpact, warningSeverity } from '../../utils/prices'
import { supportedChainId } from '../../utils/supportedChainId'
export const ArrowContainer = styled.div` export const ArrowContainer = styled.div`
display: inline-flex; display: inline-flex;
...@@ -173,7 +172,7 @@ export function Swap({ ...@@ -173,7 +172,7 @@ export function Swap({
}: { }: {
className?: string className?: string
prefilledState?: Partial<SwapState> prefilledState?: Partial<SwapState>
chainId?: SupportedChainId chainId?: ChainId
onCurrencyChange?: (selected: Pick<SwapState, Field.INPUT | Field.OUTPUT>) => void onCurrencyChange?: (selected: Pick<SwapState, Field.INPUT | Field.OUTPUT>) => void
disableTokenInputs?: boolean disableTokenInputs?: boolean
}) { }) {
...@@ -214,7 +213,7 @@ export function Swap({ ...@@ -214,7 +213,7 @@ export function Swap({
}) })
.filter((token: Token) => { .filter((token: Token) => {
// Any token addresses that are loaded from the shorthands map do not need to show the import URL // Any token addresses that are loaded from the shorthands map do not need to show the import URL
const supported = supportedChainId(chainId) const supported = asSupportedChain(chainId)
if (!supported) return true if (!supported) return true
return !Object.keys(TOKEN_SHORTHANDS).some((shorthand) => { return !Object.keys(TOKEN_SHORTHANDS).some((shorthand) => {
const shorthandTokenAddress = TOKEN_SHORTHANDS[shorthand][supported] const shorthandTokenAddress = TOKEN_SHORTHANDS[shorthand][supported]
......
import { createSlice, nanoid } from '@reduxjs/toolkit' import { createSlice, nanoid } from '@reduxjs/toolkit'
import { SupportedChainId } from 'constants/chains' import { ChainId } from '@uniswap/sdk-core'
import { DEFAULT_TXN_DISMISS_MS } from 'constants/misc' import { DEFAULT_TXN_DISMISS_MS } from 'constants/misc'
export type PopupContent = export type PopupContent =
...@@ -9,7 +9,7 @@ export type PopupContent = ...@@ -9,7 +9,7 @@ export type PopupContent =
} }
} }
| { | {
failedSwitchNetwork: SupportedChainId failedSwitchNetwork: ChainId
} }
export enum ApplicationModal { export enum ApplicationModal {
......
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { asSupportedChain } from 'constants/chains'
import useDebounce from 'hooks/useDebounce' import useDebounce from 'hooks/useDebounce'
import useIsWindowVisible from 'hooks/useIsWindowVisible' import useIsWindowVisible from 'hooks/useIsWindowVisible'
import { useEffect, useRef, useState } from 'react' import { useEffect, useRef, useState } from 'react'
import { useAppDispatch } from 'state/hooks' import { useAppDispatch } from 'state/hooks'
import { supportedChainId } from 'utils/supportedChainId'
import { useCloseModal } from './hooks' import { useCloseModal } from './hooks'
import { updateChainId } from './reducer' import { updateChainId } from './reducer'
...@@ -33,7 +33,7 @@ export default function Updater(): null { ...@@ -33,7 +33,7 @@ export default function Updater(): null {
const debouncedChainId = useDebounce(activeChainId, 100) const debouncedChainId = useDebounce(activeChainId, 100)
useEffect(() => { useEffect(() => {
const chainId = debouncedChainId ? supportedChainId(debouncedChainId) ?? null : null const chainId = debouncedChainId ? asSupportedChain(debouncedChainId) : null
dispatch(updateChainId({ chainId })) dispatch(updateChainId({ chainId }))
}, [dispatch, debouncedChainId]) }, [dispatch, debouncedChainId])
......
import type { TransactionResponse } from '@ethersproject/providers' import type { TransactionResponse } from '@ethersproject/providers'
import MerkleDistributorJSON from '@uniswap/merkle-distributor/build/MerkleDistributor.json' import MerkleDistributorJSON from '@uniswap/merkle-distributor/build/MerkleDistributor.json'
import { CurrencyAmount, Token } from '@uniswap/sdk-core' import { CurrencyAmount, MERKLE_DISTRIBUTOR_ADDRESS, Token } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { MERKLE_DISTRIBUTOR_ADDRESS } from 'constants/addresses'
import JSBI from 'jsbi' import JSBI from 'jsbi'
import { useSingleCallResult } from 'lib/hooks/multicall' import { useSingleCallResult } from 'lib/hooks/multicall'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
......
...@@ -8,15 +8,16 @@ import { toUtf8String, Utf8ErrorFuncs, Utf8ErrorReason } from '@ethersproject/st ...@@ -8,15 +8,16 @@ import { toUtf8String, Utf8ErrorFuncs, Utf8ErrorReason } from '@ethersproject/st
import { t } from '@lingui/macro' import { t } from '@lingui/macro'
import GovernorAlphaJSON from '@uniswap/governance/build/GovernorAlpha.json' import GovernorAlphaJSON from '@uniswap/governance/build/GovernorAlpha.json'
import UniJSON from '@uniswap/governance/build/Uni.json' import UniJSON from '@uniswap/governance/build/Uni.json'
import { CurrencyAmount, Token } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core'
import GOVERNOR_BRAVO_ABI from 'abis/governor-bravo.json'
import { import {
ChainId,
CurrencyAmount,
GOVERNANCE_ALPHA_V0_ADDRESSES, GOVERNANCE_ALPHA_V0_ADDRESSES,
GOVERNANCE_ALPHA_V1_ADDRESSES, GOVERNANCE_ALPHA_V1_ADDRESSES,
GOVERNANCE_BRAVO_ADDRESSES, GOVERNANCE_BRAVO_ADDRESSES,
} from 'constants/addresses' Token,
import { SupportedChainId } from 'constants/chains' } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core'
import GOVERNOR_BRAVO_ABI from 'abis/governor-bravo.json'
import { LATEST_GOVERNOR_INDEX } from 'constants/governance' import { LATEST_GOVERNOR_INDEX } from 'constants/governance'
import { POLYGON_PROPOSAL_TITLE } from 'constants/proposals/polygon_proposal_title' import { POLYGON_PROPOSAL_TITLE } from 'constants/proposals/polygon_proposal_title'
import { UNISWAP_GRANTS_PROPOSAL_DESCRIPTION } from 'constants/proposals/uniswap_grants_proposal_description' import { UNISWAP_GRANTS_PROPOSAL_DESCRIPTION } from 'constants/proposals/uniswap_grants_proposal_description'
...@@ -240,10 +241,10 @@ export function useAllProposalData(): { data: ProposalData[]; loading: boolean } ...@@ -240,10 +241,10 @@ export function useAllProposalData(): { data: ProposalData[]; loading: boolean }
const proposalCount2 = useProposalCount(gov2) const proposalCount2 = useProposalCount(gov2)
const gov0ProposalIndexes = useMemo(() => { const gov0ProposalIndexes = useMemo(() => {
return chainId === SupportedChainId.MAINNET ? V0_PROPOSAL_IDS : countToIndices(proposalCount0) return chainId === ChainId.MAINNET ? V0_PROPOSAL_IDS : countToIndices(proposalCount0)
}, [chainId, proposalCount0]) }, [chainId, proposalCount0])
const gov1ProposalIndexes = useMemo(() => { const gov1ProposalIndexes = useMemo(() => {
return chainId === SupportedChainId.MAINNET ? V1_PROPOSAL_IDS : countToIndices(proposalCount1) return chainId === ChainId.MAINNET ? V1_PROPOSAL_IDS : countToIndices(proposalCount1)
}, [chainId, proposalCount1]) }, [chainId, proposalCount1])
const gov2ProposalIndexes = useMemo(() => { const gov2ProposalIndexes = useMemo(() => {
return countToIndices(proposalCount2, 8) return countToIndices(proposalCount2, 8)
...@@ -344,7 +345,7 @@ export function useQuorum(governorIndex: number): CurrencyAmount<Token> | undefi ...@@ -344,7 +345,7 @@ export function useQuorum(governorIndex: number): CurrencyAmount<Token> | undefi
if ( if (
!latestGovernanceContract || !latestGovernanceContract ||
!quorumVotes || !quorumVotes ||
chainId !== SupportedChainId.MAINNET || chainId !== ChainId.MAINNET ||
!uni || !uni ||
governorIndex !== LATEST_GOVERNOR_INDEX governorIndex !== LATEST_GOVERNOR_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.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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