Skip to content

Commit

Permalink
Add Base support to widget
Browse files Browse the repository at this point in the history
  • Loading branch information
abarthell committed Sep 14, 2023
1 parent f4b04af commit a649be7
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/assets/svg/base_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions src/constants/chainInfo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ethereumLogoUrl from 'assets/images/ethereum-logo.png'
import arbitrumLogoUrl from 'assets/svg/arbitrum_logo.svg'
import baseLogo from 'assets/svg/base_logo.svg'
import bnbLogo from 'assets/svg/bnb-logo.svg'
import celoLogo from 'assets/svg/celo_logo.svg'
import optimismLogoUrl from 'assets/svg/optimism_logo.svg'
Expand Down Expand Up @@ -237,6 +238,32 @@ const CHAIN_INFO: ChainInfoMap = {
color: '#F0B90B',
backgroundColor: '#F0B90B',
},
[SupportedChainId.BASE]: {
networkType: NetworkType.L2,
blockWaitMsBeforeWarning: ms`10m`,
bridge: 'https://bridge.base.org/',
docs: 'https://docs.base.org/',
explorer: 'https://basescan.org/',
infoLink: 'https://info.uniswap.org/#/base/',
label: 'Base',
logoUrl: baseLogo,
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
color: '#F0B90B',
backgroundColor: '#F0B90B',
},
[SupportedChainId.BASE_GOERLI]: {
networkType: NetworkType.L2,
blockWaitMsBeforeWarning: ms`10m`,
bridge: 'https://goerli-bridge.base.org/',
docs: 'https://docs.base.org/',
explorer: 'https://goerli.basescan.org/',
infoLink: 'https://info.uniswap.org/#/base/',
label: 'Base Goerli',
logoUrl: baseLogo,
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
color: '#F0B90B',
backgroundColor: '#F0B90B',
},
}

export function getChainInfo(chainId: SupportedL1ChainId): L1ChainInfo
Expand Down
12 changes: 12 additions & 0 deletions src/constants/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export enum SupportedChainId {
CELO_ALFAJORES = 44787,

BNB = 56,

BASE = 8453,
BASE_GOERLI = 84531,
}

export enum ChainName {
Expand All @@ -38,6 +41,8 @@ export enum ChainName {
CELO = 'celo',
CELO_ALFAJORES = 'celo-alfajores',
BNB = 'bnb',
BASE = 'base',
BASE_GOERLI = 'base-goerli',
}

export const CHAIN_NAMES_TO_IDS: { [chainName: string]: SupportedChainId } = {
Expand All @@ -55,6 +60,8 @@ export const CHAIN_NAMES_TO_IDS: { [chainName: string]: SupportedChainId } = {
[ChainName.CELO]: SupportedChainId.CELO,
[ChainName.CELO_ALFAJORES]: SupportedChainId.CELO_ALFAJORES,
[ChainName.BNB]: SupportedChainId.BNB,
[ChainName.BASE]: SupportedChainId.BASE,
[ChainName.BASE_GOERLI]: SupportedChainId.BASE_GOERLI,
}

/**
Expand All @@ -71,6 +78,7 @@ export const SUPPORTED_GAS_ESTIMATE_CHAIN_IDS = [
SupportedChainId.ARBITRUM_ONE,
SupportedChainId.CELO,
SupportedChainId.BNB,
SupportedChainId.BASE,
]

/**
Expand All @@ -86,6 +94,8 @@ export const L1_CHAIN_IDS = [
SupportedChainId.POLYGON_MUMBAI,
SupportedChainId.CELO,
SupportedChainId.CELO_ALFAJORES,
SupportedChainId.BASE,
SupportedChainId.BASE_GOERLI,
] as const

export type SupportedL1ChainId = typeof L1_CHAIN_IDS[number]
Expand All @@ -99,6 +109,8 @@ export const L2_CHAIN_IDS = [
SupportedChainId.ARBITRUM_RINKEBY,
SupportedChainId.OPTIMISM,
SupportedChainId.OPTIMISM_GOERLI,
SupportedChainId.BASE,
SupportedChainId.BASE_GOERLI,
] as const

export type SupportedL2ChainId = typeof L2_CHAIN_IDS[number]
Expand Down
8 changes: 8 additions & 0 deletions src/constants/jsonRpcEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,12 @@ export const JSON_RPC_FALLBACK_ENDPOINTS: Record<SupportedChainId, string[]> = {
'https://bsc-dataseed4.defibit.io',
'https://rpc.ankr.com/bsc',
],
[SupportedChainId.BASE]: [
// "Safe" URLs
'https://mainnet.base.org',
],
[SupportedChainId.BASE_GOERLI]: [
// "Safe" URLs
'https://goerli.base.org',
],
}
7 changes: 7 additions & 0 deletions src/constants/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
CUSD_CELO,
DAI,
DAI_ARBITRUM_ONE,
DAI_BASE,
DAI_OPTIMISM,
DAI_POLYGON,
ETH2X_FLI,
Expand All @@ -24,6 +25,7 @@ import {
SWISE,
TRIBE,
USDC_BNB_CHAIN,
USDC_BASE,
USDC_MAINNET,
USDC_POLYGON,
USDT,
Expand Down Expand Up @@ -92,6 +94,11 @@ export const BASES_TO_CHECK_TRADES_AGAINST: ChainTokenList = {
USDT_BNB_CHAIN,
...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.BNB],
],
[SupportedChainId.BASE]: [
...WRAPPED_NATIVE_CURRENCIES_ONLY[SupportedChainId.BASE],
DAI_BASE,
USDC_BASE,
],
}
export const ADDITIONAL_BASES: { [chainId: number]: { [tokenAddress: string]: Token[] } } = {
[SupportedChainId.MAINNET]: {
Expand Down
25 changes: 25 additions & 0 deletions src/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ export const USDC_BNB_CHAIN = new Token(
'USDC',
'USDC'
)
export const USDC_BASE = new Token(
SupportedChainId.BASE,
'0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
6,
'USDC',
'USD Coin'
)
export const USDC_BASE_GOERLI = new Token(
SupportedChainId.BASE,
'0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
6,
'USDC',
'USD Coin'
)
export const USDC: { [chainId in SupportedChainId]: Token } = {
[SupportedChainId.MAINNET]: USDC_MAINNET,
[SupportedChainId.ARBITRUM_ONE]: USDC_ARBITRUM,
Expand All @@ -145,6 +159,8 @@ export const USDC: { [chainId in SupportedChainId]: Token } = {
[SupportedChainId.KOVAN]: USDC_KOVAN,
[SupportedChainId.ROPSTEN]: USDC_ROPSTEN,
[SupportedChainId.BNB]: USDC_BNB_CHAIN,
[SupportedChainId.BASE]: USDC_BASE,
[SupportedChainId.BASE_GOERLI]: USDC_BASE_GOERLI,
}
export const DAI_POLYGON = new Token(
SupportedChainId.POLYGON,
Expand Down Expand Up @@ -407,6 +423,14 @@ export const DAI_BNB_CHAIN = new Token(
'DAI'
)

export const DAI_BASE = new Token(
SupportedChainId.BASE,
'0x50c5725949a6f0c72e6c4a641f24049a917db0cb',
18,
'DAI',
'Dai Stablecoin'
)

function isBnbChain(chainId: number): chainId is SupportedChainId.BNB {
return chainId === SupportedChainId.BNB
}
Expand Down Expand Up @@ -574,5 +598,6 @@ export const TOKEN_SHORTHANDS: { [shorthand: string]: { [chainId in SupportedCha
[SupportedChainId.ROPSTEN]: USDC_ROPSTEN.address,
[SupportedChainId.CELO]: PORTAL_USDC_CELO.address,
[SupportedChainId.CELO_ALFAJORES]: USDC_CELO_ALFAJORES.address,
[SupportedChainId.BASE]: USDC_BASE.address,
},
}
2 changes: 2 additions & 0 deletions src/utils/getExplorerLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const ETHERSCAN_PREFIXES: { [chainId: number]: string } = {
[SupportedChainId.CELO]: 'https://celoscan.io',
[SupportedChainId.CELO_ALFAJORES]: 'https://alfajores.celoscan.io',
[SupportedChainId.BNB]: 'https://bscscan.com',
[SupportedChainId.BASE]: 'https://basescan.org/',
[SupportedChainId.BASE_GOERLI]: 'https://goerli.basescan.org/',
}

export enum ExplorerDataType {
Expand Down

0 comments on commit a649be7

Please sign in to comment.