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

* add common bases to L2s

* pr feedback
This commit is contained in:
Jordan Frankfurt 2021-09-23 15:29:18 -04:00 committed by GitHub
parent 8de6bb6d51
commit 384f674e48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 88 additions and 19 deletions

@ -1,4 +1,5 @@
import { Currency } from '@uniswap/sdk-core'
import { SupportedChainId } from 'constants/chains'
import React, { useMemo } from 'react'
import styled from 'styled-components/macro'
@ -7,8 +8,31 @@ import useHttpLocations from '../../hooks/useHttpLocations'
import { WrappedTokenInfo } from '../../state/lists/wrappedTokenInfo'
import Logo from '../Logo'
export const getTokenLogoURL = (address: string) =>
`https://raw.githubusercontent.com/uniswap/assets/master/blockchains/ethereum/assets/${address}/logo.png`
type Network = 'ethereum' | 'arbitrum' | 'optimism'
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 }>`
width: ${({ size }) => size};
@ -41,7 +65,11 @@ export default function CurrencyLogo({
if (!currency || currency.isNative) return []
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) {
return [...uriLocations, ...defaultUrls]
}

@ -1,14 +1,13 @@
import { Trans } from '@lingui/macro'
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 styled from 'styled-components/macro'
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'
import { currencyId } from 'utils/currencyId'
const MobileWrapper = styled(AutoColumn)`
${({ theme }) => theme.mediaWidth.upToSmall`

@ -5,6 +5,7 @@ import { SupportedChainId } from './chains'
import {
AMPL,
DAI,
DAI_ARBITRUM_ONE,
DAI_OPTIMISM,
ETH2X_FLI,
ExtendedEther,
@ -15,8 +16,10 @@ import {
TRIBE,
USDC,
USDT,
USDT_ARBITRUM_ONE,
USDT_OPTIMISM,
WBTC,
WBTC_ARBITRUM_ONE,
WBTC_OPTIMISM,
WETH9_EXTENDED,
} from './tokens'
@ -38,6 +41,12 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
...WETH_ONLY,
[SupportedChainId.MAINNET]: [...WETH_ONLY[SupportedChainId.MAINNET], DAI, USDC, USDT, WBTC],
[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[] } } = {
[SupportedChainId.MAINNET]: {
@ -84,14 +93,26 @@ export const COMMON_BASES: ChainCurrencyList = {
[SupportedChainId.KOVAN]: [ExtendedEther.onChain(SupportedChainId.KOVAN), WETH9_EXTENDED[SupportedChainId.KOVAN]],
[SupportedChainId.ARBITRUM_ONE]: [
ExtendedEther.onChain(SupportedChainId.ARBITRUM_ONE),
DAI_ARBITRUM_ONE,
USDT_ARBITRUM_ONE,
WBTC_ARBITRUM_ONE,
WETH9_EXTENDED[SupportedChainId.ARBITRUM_ONE],
],
[SupportedChainId.ARBITRUM_RINKEBY]: [
ExtendedEther.onChain(SupportedChainId.ARBITRUM_RINKEBY),
WETH9_EXTENDED[SupportedChainId.ARBITRUM_RINKEBY],
],
[SupportedChainId.OPTIMISM]: [ExtendedEther.onChain(SupportedChainId.OPTIMISM)],
[SupportedChainId.OPTIMISTIC_KOVAN]: [ExtendedEther.onChain(SupportedChainId.OPTIMISTIC_KOVAN)],
[SupportedChainId.OPTIMISM]: [
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

@ -17,6 +17,20 @@ export const DAI = new Token(
'DAI',
'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(
SupportedChainId.MAINNET,
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
@ -31,13 +45,6 @@ export const USDC_ARBITRUM = new Token(
'USDC',
'USD//C'
)
export const DAI_OPTIMISM = new Token(
SupportedChainId.OPTIMISM,
'0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
18,
'DAI',
'Dai stable coin'
)
export const USDT = new Token(
SupportedChainId.MAINNET,
'0xdAC17F958D2ee523a2206206994597C13D831ec7',
@ -45,6 +52,13 @@ export const USDT = new Token(
'USDT',
'Tether USD'
)
export const USDT_ARBITRUM_ONE = new Token(
SupportedChainId.ARBITRUM_ONE,
'0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',
6,
'USDT',
'Tether USD'
)
export const USDT_OPTIMISM = new Token(
SupportedChainId.OPTIMISM,
'0x94b008aA00579c1307B0EF2c499aD98a8ce58e58',
@ -59,6 +73,13 @@ export const WBTC = new Token(
'WBTC',
'Wrapped BTC'
)
export const WBTC_ARBITRUM_ONE = new Token(
SupportedChainId.ARBITRUM_ONE,
'0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f',
8,
'WBTC',
'Wrapped BTC'
)
export const WBTC_OPTIMISM = new Token(
SupportedChainId.OPTIMISM,
'0x68f180fcCe6836688e9084f035309E29Bf0A2095',