Commit 384f674e authored by Jordan Frankfurt's avatar Jordan Frankfurt Committed by GitHub

fix(L2): add common bases to L2s (#2428)

* add common bases to L2s

* pr feedback
parent 8de6bb6d
import { Currency } from '@uniswap/sdk-core' import { Currency } from '@uniswap/sdk-core'
import { SupportedChainId } from 'constants/chains'
import React, { useMemo } from 'react' import React, { useMemo } from 'react'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
...@@ -7,8 +8,31 @@ import useHttpLocations from '../../hooks/useHttpLocations' ...@@ -7,8 +8,31 @@ import useHttpLocations from '../../hooks/useHttpLocations'
import { WrappedTokenInfo } from '../../state/lists/wrappedTokenInfo' import { WrappedTokenInfo } from '../../state/lists/wrappedTokenInfo'
import Logo from '../Logo' import Logo from '../Logo'
export const getTokenLogoURL = (address: string) => type Network = 'ethereum' | 'arbitrum' | 'optimism'
`https://raw.githubusercontent.com/uniswap/assets/master/blockchains/ethereum/assets/${address}/logo.png`
function chainIdToNetworkName(networkId: SupportedChainId): Network {
switch (networkId) {
case SupportedChainId.MAINNET:
return 'ethereum'
case SupportedChainId.ARBITRUM_ONE:
return 'arbitrum'
case SupportedChainId.OPTIMISM:
return 'optimism'
default:
return 'ethereum'
}
}
export const getTokenLogoURL = (
address: string,
chainId: SupportedChainId = SupportedChainId.MAINNET
): string | void => {
const networkName = chainIdToNetworkName(chainId)
const networksWithUrls = [SupportedChainId.ARBITRUM_ONE, SupportedChainId.MAINNET, SupportedChainId.OPTIMISM]
if (networksWithUrls.includes(chainId)) {
return `https://raw.githubusercontent.com/Uniswap/assets/master/blockchains/${networkName}/assets/${address}/logo.png`
}
}
const StyledEthereumLogo = styled.img<{ size: string }>` const StyledEthereumLogo = styled.img<{ size: string }>`
width: ${({ size }) => size}; width: ${({ size }) => size};
...@@ -41,7 +65,11 @@ export default function CurrencyLogo({ ...@@ -41,7 +65,11 @@ export default function CurrencyLogo({
if (!currency || currency.isNative) return [] if (!currency || currency.isNative) return []
if (currency.isToken) { if (currency.isToken) {
const defaultUrls = currency.chainId === 1 ? [getTokenLogoURL(currency.address)] : [] const defaultUrls = []
const url = getTokenLogoURL(currency.address, currency.chainId)
if (url) {
defaultUrls.push(url)
}
if (currency instanceof WrappedTokenInfo) { if (currency instanceof WrappedTokenInfo) {
return [...uriLocations, ...defaultUrls] return [...uriLocations, ...defaultUrls]
} }
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { Currency } from '@uniswap/sdk-core' import { Currency } from '@uniswap/sdk-core'
import { AutoColumn } from 'components/Column'
import CurrencyLogo from 'components/CurrencyLogo'
import QuestionHelper from 'components/QuestionHelper'
import { AutoRow } from 'components/Row'
import { COMMON_BASES } from 'constants/routing'
import { Text } from 'rebass' import { Text } from 'rebass'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { currencyId } from 'utils/currencyId'
import { COMMON_BASES } from '../../constants/routing'
import { currencyId } from '../../utils/currencyId'
import { AutoColumn } from '../Column'
import CurrencyLogo from '../CurrencyLogo'
import QuestionHelper from '../QuestionHelper'
import { AutoRow } from '../Row'
const MobileWrapper = styled(AutoColumn)` const MobileWrapper = styled(AutoColumn)`
${({ theme }) => theme.mediaWidth.upToSmall` ${({ theme }) => theme.mediaWidth.upToSmall`
......
...@@ -5,6 +5,7 @@ import { SupportedChainId } from './chains' ...@@ -5,6 +5,7 @@ import { SupportedChainId } from './chains'
import { import {
AMPL, AMPL,
DAI, DAI,
DAI_ARBITRUM_ONE,
DAI_OPTIMISM, DAI_OPTIMISM,
ETH2X_FLI, ETH2X_FLI,
ExtendedEther, ExtendedEther,
...@@ -15,8 +16,10 @@ import { ...@@ -15,8 +16,10 @@ import {
TRIBE, TRIBE,
USDC, USDC,
USDT, USDT,
USDT_ARBITRUM_ONE,
USDT_OPTIMISM, USDT_OPTIMISM,
WBTC, WBTC,
WBTC_ARBITRUM_ONE,
WBTC_OPTIMISM, WBTC_OPTIMISM,
WETH9_EXTENDED, WETH9_EXTENDED,
} from './tokens' } from './tokens'
...@@ -38,6 +41,12 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = { ...@@ -38,6 +41,12 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
...WETH_ONLY, ...WETH_ONLY,
[SupportedChainId.MAINNET]: [...WETH_ONLY[SupportedChainId.MAINNET], DAI, USDC, USDT, WBTC], [SupportedChainId.MAINNET]: [...WETH_ONLY[SupportedChainId.MAINNET], DAI, USDC, USDT, WBTC],
[SupportedChainId.OPTIMISM]: [...WETH_ONLY[SupportedChainId.OPTIMISM], DAI_OPTIMISM, USDT_OPTIMISM, WBTC_OPTIMISM], [SupportedChainId.OPTIMISM]: [...WETH_ONLY[SupportedChainId.OPTIMISM], DAI_OPTIMISM, USDT_OPTIMISM, WBTC_OPTIMISM],
[SupportedChainId.ARBITRUM_ONE]: [
...WETH_ONLY[SupportedChainId.ARBITRUM_ONE],
DAI_ARBITRUM_ONE,
USDT_ARBITRUM_ONE,
WBTC_ARBITRUM_ONE,
],
} }
export const ADDITIONAL_BASES: { [chainId: number]: { [tokenAddress: string]: Token[] } } = { export const ADDITIONAL_BASES: { [chainId: number]: { [tokenAddress: string]: Token[] } } = {
[SupportedChainId.MAINNET]: { [SupportedChainId.MAINNET]: {
...@@ -84,14 +93,26 @@ export const COMMON_BASES: ChainCurrencyList = { ...@@ -84,14 +93,26 @@ export const COMMON_BASES: ChainCurrencyList = {
[SupportedChainId.KOVAN]: [ExtendedEther.onChain(SupportedChainId.KOVAN), WETH9_EXTENDED[SupportedChainId.KOVAN]], [SupportedChainId.KOVAN]: [ExtendedEther.onChain(SupportedChainId.KOVAN), WETH9_EXTENDED[SupportedChainId.KOVAN]],
[SupportedChainId.ARBITRUM_ONE]: [ [SupportedChainId.ARBITRUM_ONE]: [
ExtendedEther.onChain(SupportedChainId.ARBITRUM_ONE), ExtendedEther.onChain(SupportedChainId.ARBITRUM_ONE),
DAI_ARBITRUM_ONE,
USDT_ARBITRUM_ONE,
WBTC_ARBITRUM_ONE,
WETH9_EXTENDED[SupportedChainId.ARBITRUM_ONE], WETH9_EXTENDED[SupportedChainId.ARBITRUM_ONE],
], ],
[SupportedChainId.ARBITRUM_RINKEBY]: [ [SupportedChainId.ARBITRUM_RINKEBY]: [
ExtendedEther.onChain(SupportedChainId.ARBITRUM_RINKEBY), ExtendedEther.onChain(SupportedChainId.ARBITRUM_RINKEBY),
WETH9_EXTENDED[SupportedChainId.ARBITRUM_RINKEBY], WETH9_EXTENDED[SupportedChainId.ARBITRUM_RINKEBY],
], ],
[SupportedChainId.OPTIMISM]: [ExtendedEther.onChain(SupportedChainId.OPTIMISM)], [SupportedChainId.OPTIMISM]: [
[SupportedChainId.OPTIMISTIC_KOVAN]: [ExtendedEther.onChain(SupportedChainId.OPTIMISTIC_KOVAN)], ExtendedEther.onChain(SupportedChainId.OPTIMISM),
DAI_OPTIMISM,
USDT_OPTIMISM,
WBTC_OPTIMISM,
WETH9_EXTENDED[SupportedChainId.OPTIMISM],
],
[SupportedChainId.OPTIMISTIC_KOVAN]: [
ExtendedEther.onChain(SupportedChainId.OPTIMISTIC_KOVAN),
WETH9_EXTENDED[SupportedChainId.OPTIMISTIC_KOVAN],
],
} }
// 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
......
...@@ -17,6 +17,20 @@ export const DAI = new Token( ...@@ -17,6 +17,20 @@ export const DAI = new Token(
'DAI', 'DAI',
'Dai Stablecoin' 'Dai Stablecoin'
) )
export const DAI_ARBITRUM_ONE = new Token(
SupportedChainId.ARBITRUM_ONE,
'0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
18,
'DAI',
'Dai stable coin'
)
export const DAI_OPTIMISM = new Token(
SupportedChainId.OPTIMISM,
'0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
18,
'DAI',
'Dai stable coin'
)
export const USDC = new Token( export const USDC = new Token(
SupportedChainId.MAINNET, SupportedChainId.MAINNET,
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
...@@ -31,13 +45,6 @@ export const USDC_ARBITRUM = new Token( ...@@ -31,13 +45,6 @@ export const USDC_ARBITRUM = new Token(
'USDC', 'USDC',
'USD//C' 'USD//C'
) )
export const DAI_OPTIMISM = new Token(
SupportedChainId.OPTIMISM,
'0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
18,
'DAI',
'Dai stable coin'
)
export const USDT = new Token( export const USDT = new Token(
SupportedChainId.MAINNET, SupportedChainId.MAINNET,
'0xdAC17F958D2ee523a2206206994597C13D831ec7', '0xdAC17F958D2ee523a2206206994597C13D831ec7',
...@@ -45,6 +52,13 @@ export const USDT = new Token( ...@@ -45,6 +52,13 @@ export const USDT = new Token(
'USDT', 'USDT',
'Tether USD' 'Tether USD'
) )
export const USDT_ARBITRUM_ONE = new Token(
SupportedChainId.ARBITRUM_ONE,
'0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',
6,
'USDT',
'Tether USD'
)
export const USDT_OPTIMISM = new Token( export const USDT_OPTIMISM = new Token(
SupportedChainId.OPTIMISM, SupportedChainId.OPTIMISM,
'0x94b008aA00579c1307B0EF2c499aD98a8ce58e58', '0x94b008aA00579c1307B0EF2c499aD98a8ce58e58',
...@@ -59,6 +73,13 @@ export const WBTC = new Token( ...@@ -59,6 +73,13 @@ export const WBTC = new Token(
'WBTC', 'WBTC',
'Wrapped BTC' 'Wrapped BTC'
) )
export const WBTC_ARBITRUM_ONE = new Token(
SupportedChainId.ARBITRUM_ONE,
'0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f',
8,
'WBTC',
'Wrapped BTC'
)
export const WBTC_OPTIMISM = new Token( export const WBTC_OPTIMISM = new Token(
SupportedChainId.OPTIMISM, SupportedChainId.OPTIMISM,
'0x68f180fcCe6836688e9084f035309E29Bf0A2095', '0x68f180fcCe6836688e9084f035309E29Bf0A2095',
......
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