Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 630c927

Browse files
authored
feat: Add Base support to Uniswap widget (#619)
* Add Base support to Uniswap widget * Remove Base Goerli until routing supports it: Uniswap/interface#7238 * Bump uniswap/default-token-lists to 11.6.0 * update blockWaitMs and rpc endpoints * Add Multicall and Swap Souter address * Fix linting * Additional fixes * Bump smart-order-router to v3.16.25 * Bump deps * Ran yarn deduplicate
1 parent f4b04af commit 630c927

15 files changed

Lines changed: 273 additions & 461 deletions

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@
6666
"@uniswap/permit2-sdk": "^1.2.0",
6767
"@uniswap/redux-multicall": "^1.1.8",
6868
"@uniswap/router-sdk": "^1.6.0",
69-
"@uniswap/sdk-core": "^4.0.6",
70-
"@uniswap/smart-order-router": "^3.13.7",
69+
"@uniswap/sdk-core": "^4.0.7",
70+
"@uniswap/smart-order-router": "^3.16.25",
7171
"@uniswap/token-lists": "^1.0.0-beta.30",
72-
"@uniswap/universal-router-sdk": "^1.5.6",
73-
"@uniswap/v2-sdk": "^3.2.0",
72+
"@uniswap/universal-router-sdk": "^1.5.7",
73+
"@uniswap/v2-sdk": "^3.2.1",
7474
"@uniswap/v3-sdk": "^3.10.0",
7575
"@web3-react/core": "^8.2.0",
7676
"@web3-react/eip1193": "^8.2.0",
@@ -166,7 +166,7 @@
166166
"@types/wcag-contrast": "^3.0.0",
167167
"@typescript-eslint/eslint-plugin": "^5.21.0",
168168
"@typescript-eslint/parser": "^5.21.0",
169-
"@uniswap/default-token-list": "^9.0.0",
169+
"@uniswap/default-token-list": "^11.6.0",
170170
"@uniswap/v2-core": "1.0.0",
171171
"@uniswap/v3-core": "1.0.0",
172172
"@uniswap/v3-periphery": "^1.1.1",

src/assets/svg/base_logo.svg

Lines changed: 11 additions & 0 deletions
Loading

src/components/Logo/util.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { SupportedChainId } from 'constants/chains'
22
import { isAddress } from 'utils'
33

44
import EthereumLogo from '../../assets/images/ethereum-logo.png'
5+
import BaseLogo from '../../assets/svg/base_logo.svg'
56
import BnbLogo from '../../assets/svg/bnb-logo.svg'
67
import CeloLogo from '../../assets/svg/celo_logo.svg'
78
import MaticLogo from '../../assets/svg/matic-token-icon.svg'
89
import { LogoTableInput } from './LogoTable'
910

10-
type Network = 'ethereum' | 'arbitrum' | 'optimism' | 'polygon' | 'celo' | 'smartchain'
11+
type Network = 'ethereum' | 'arbitrum' | 'optimism' | 'polygon' | 'celo' | 'smartchain' | 'base'
1112

1213
function chainIdToNetworkName(networkId: SupportedChainId): Network | undefined {
1314
switch (networkId) {
@@ -23,6 +24,8 @@ function chainIdToNetworkName(networkId: SupportedChainId): Network | undefined
2324
return 'celo'
2425
case SupportedChainId.BNB:
2526
return 'smartchain'
27+
case SupportedChainId.BASE:
28+
return 'base'
2629
default:
2730
return 'ethereum'
2831
}
@@ -51,6 +54,8 @@ export function getNativeLogoURI(chainId: SupportedChainId = SupportedChainId.MA
5154
return CeloLogo
5255
case SupportedChainId.BNB:
5356
return BnbLogo
57+
case SupportedChainId.BASE:
58+
return BaseLogo
5459
default:
5560
return EthereumLogo
5661
}

src/constants/addresses.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const MULTICALL_ADDRESS: AddressMap = {
1616
[SupportedChainId.ARBITRUM_RINKEBY]: '0xa501c031958F579dB7676fF1CE78AD305794d579',
1717
[SupportedChainId.CELO]: '0x633987602DE5C4F337e3DbF265303A1080324204',
1818
[SupportedChainId.CELO_ALFAJORES]: '0x633987602DE5C4F337e3DbF265303A1080324204',
19+
[SupportedChainId.BASE]: '0x091e99cb1C49331a94dD62755D168E941AbD0693',
1920
}
2021

2122
export const SWAP_ROUTER_ADDRESSES: AddressMap = {
@@ -29,6 +30,7 @@ export const SWAP_ROUTER_ADDRESSES: AddressMap = {
2930
]),
3031
[SupportedChainId.CELO]: '0x5615CDAb10dc425a742d643d949a7F474C01abc4',
3132
[SupportedChainId.CELO_ALFAJORES]: '0x5615CDAb10dc425a742d643d949a7F474C01abc4',
33+
[SupportedChainId.BASE]: '0x2626664c2603336E57B271c5C0b26F421741e481',
3234
}
3335

3436
export const ARGENT_WALLET_DETECTOR_ADDRESS: AddressMap = {

src/constants/chainInfo.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ethereumLogoUrl from 'assets/images/ethereum-logo.png'
22
import arbitrumLogoUrl from 'assets/svg/arbitrum_logo.svg'
3+
import baseLogo from 'assets/svg/base_logo.svg'
34
import bnbLogo from 'assets/svg/bnb-logo.svg'
45
import celoLogo from 'assets/svg/celo_logo.svg'
56
import optimismLogoUrl from 'assets/svg/optimism_logo.svg'
@@ -237,6 +238,19 @@ const CHAIN_INFO: ChainInfoMap = {
237238
color: '#F0B90B',
238239
backgroundColor: '#F0B90B',
239240
},
241+
[SupportedChainId.BASE]: {
242+
networkType: NetworkType.L2,
243+
blockWaitMsBeforeWarning: ms`25m`,
244+
bridge: 'https://bridge.base.org/',
245+
docs: 'https://docs.base.org/',
246+
explorer: 'https://basescan.org/',
247+
infoLink: 'https://info.uniswap.org/#/base/',
248+
label: 'Base',
249+
logoUrl: baseLogo,
250+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
251+
color: '#0152ff',
252+
backgroundColor: '#0152ff',
253+
},
240254
}
241255

242256
export function getChainInfo(chainId: SupportedL1ChainId): L1ChainInfo

src/constants/chains.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export enum SupportedChainId {
2121
CELO_ALFAJORES = 44787,
2222

2323
BNB = 56,
24+
25+
BASE = 8453,
2426
}
2527

2628
export enum ChainName {
@@ -38,6 +40,7 @@ export enum ChainName {
3840
CELO = 'celo',
3941
CELO_ALFAJORES = 'celo-alfajores',
4042
BNB = 'bnb',
43+
BASE = 'base',
4144
}
4245

4346
export const CHAIN_NAMES_TO_IDS: { [chainName: string]: SupportedChainId } = {
@@ -55,6 +58,7 @@ export const CHAIN_NAMES_TO_IDS: { [chainName: string]: SupportedChainId } = {
5558
[ChainName.CELO]: SupportedChainId.CELO,
5659
[ChainName.CELO_ALFAJORES]: SupportedChainId.CELO_ALFAJORES,
5760
[ChainName.BNB]: SupportedChainId.BNB,
61+
[ChainName.BASE]: SupportedChainId.BASE,
5862
}
5963

6064
/**
@@ -71,6 +75,7 @@ export const SUPPORTED_GAS_ESTIMATE_CHAIN_IDS = [
7175
SupportedChainId.ARBITRUM_ONE,
7276
SupportedChainId.CELO,
7377
SupportedChainId.BNB,
78+
SupportedChainId.BASE,
7479
]
7580

7681
/**
@@ -99,6 +104,7 @@ export const L2_CHAIN_IDS = [
99104
SupportedChainId.ARBITRUM_RINKEBY,
100105
SupportedChainId.OPTIMISM,
101106
SupportedChainId.OPTIMISM_GOERLI,
107+
SupportedChainId.BASE,
102108
] as const
103109

104110
export type SupportedL2ChainId = typeof L2_CHAIN_IDS[number]

src/constants/jsonRpcEndpoints.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,13 @@ export const JSON_RPC_FALLBACK_ENDPOINTS: Record<SupportedChainId, string[]> = {
8686
'https://bsc-dataseed4.defibit.io',
8787
'https://rpc.ankr.com/bsc',
8888
],
89+
[SupportedChainId.BASE]: [
90+
// "Safe" URLs
91+
'https://mainnet.base.org',
92+
'https://base.gateway.tenderly.co',
93+
'https://base.publicnode.com',
94+
// "Fallback" URLs
95+
'https://1rpc.io/base',
96+
'https://base.meowrpc.com',
97+
],
8998
}

src/constants/routing.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
CUSD_CELO,
1010
DAI,
1111
DAI_ARBITRUM_ONE,
12+
DAI_BASE,
1213
DAI_OPTIMISM,
1314
DAI_POLYGON,
1415
ETH2X_FLI,
@@ -23,6 +24,7 @@ import {
2324
sETH2,
2425
SWISE,
2526
TRIBE,
27+
USDC_BASE,
2628
USDC_BNB_CHAIN,
2729
USDC_MAINNET,
2830
USDC_POLYGON,
@@ -92,6 +94,7 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
9294
USDT_BNB_CHAIN,
9395
...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.BNB],
9496
],
97+
[SupportedChainId.BASE]: [...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.BASE], DAI_BASE, USDC_BASE],
9598
}
9699
export const ADDITIONAL_BASES: { [chainId: number]: { [tokenAddress: string]: Token[] } } = {
97100
[SupportedChainId.MAINNET]: {

src/constants/tokens.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ export const USDC_BNB_CHAIN = new Token(
130130
'USDC',
131131
'USDC'
132132
)
133+
export const USDC_BASE = new Token(
134+
SupportedChainId.BASE,
135+
'0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
136+
6,
137+
'USDC',
138+
'USD Coin'
139+
)
133140
export const USDC: { [chainId in SupportedChainId]: Token } = {
134141
[SupportedChainId.MAINNET]: USDC_MAINNET,
135142
[SupportedChainId.ARBITRUM_ONE]: USDC_ARBITRUM,
@@ -145,6 +152,7 @@ export const USDC: { [chainId in SupportedChainId]: Token } = {
145152
[SupportedChainId.KOVAN]: USDC_KOVAN,
146153
[SupportedChainId.ROPSTEN]: USDC_ROPSTEN,
147154
[SupportedChainId.BNB]: USDC_BNB_CHAIN,
155+
[SupportedChainId.BASE]: USDC_BASE,
148156
}
149157
export const DAI_POLYGON = new Token(
150158
SupportedChainId.POLYGON,
@@ -407,6 +415,14 @@ export const DAI_BNB_CHAIN = new Token(
407415
'DAI'
408416
)
409417

418+
export const DAI_BASE = new Token(
419+
SupportedChainId.BASE,
420+
'0x50c5725949a6f0c72e6c4a641f24049a917db0cb',
421+
18,
422+
'DAI',
423+
'Dai Stablecoin'
424+
)
425+
410426
function isBnbChain(chainId: number): chainId is SupportedChainId.BNB {
411427
return chainId === SupportedChainId.BNB
412428
}
@@ -490,6 +506,13 @@ export const WRAPPED_NATIVE_CURRENCY: { [chainId: number]: Token | undefined } =
490506
'WBNB',
491507
'Wrapped BNB'
492508
),
509+
[SupportedChainId.BASE]: new Token(
510+
SupportedChainId.BASE,
511+
'0x4200000000000000000000000000000000000006',
512+
18,
513+
'WETH',
514+
'Wrapped Ether'
515+
),
493516
}
494517

495518
export function isCelo(chainId: number): chainId is SupportedChainId.CELO | SupportedChainId.CELO_ALFAJORES {
@@ -574,5 +597,6 @@ export const TOKEN_SHORTHANDS: { [shorthand: string]: { [chainId in SupportedCha
574597
[SupportedChainId.ROPSTEN]: USDC_ROPSTEN.address,
575598
[SupportedChainId.CELO]: PORTAL_USDC_CELO.address,
576599
[SupportedChainId.CELO_ALFAJORES]: USDC_CELO_ALFAJORES.address,
600+
[SupportedChainId.BASE]: USDC_BASE.address,
577601
},
578602
}

src/hooks/transactions/updater.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const RETRY_OPTIONS_BY_CHAIN_ID: { [chainId: number]: RetryOptions } = {
3535
[SupportedChainId.ARBITRUM_RINKEBY]: { n: 10, minWait: 250, maxWait: 1000 },
3636
[SupportedChainId.OPTIMISM_GOERLI]: { n: 10, minWait: 250, maxWait: 1000 },
3737
[SupportedChainId.OPTIMISM]: { n: 10, minWait: 250, maxWait: 1000 },
38+
[SupportedChainId.BASE]: { n: 10, minWait: 250, maxWait: 1000 },
3839
}
3940
const DEFAULT_RETRY_OPTIONS: RetryOptions = { n: 1, minWait: 0, maxWait: 0 }
4041

0 commit comments

Comments
 (0)