Skip to content

Commit

Permalink
feat: Add sepolia support (#8966)
Browse files Browse the repository at this point in the history
<!--
Before opening a pull request, please read the [contributing
guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md)
first
-->

<!-- start pr-codex -->

---

## PR-Codex overview
### Focus of this PR:
Add support for the Sepolia network and its associated tokens.

### Detailed summary:
- Added support for the Sepolia network in various files and
configurations.
- Added Sepolia tokens to the tokens/constants folder.
- Updated the NetworkSwitcher component to include Sepolia network.
- Updated the subgraphs file to include Sepolia

> The following files were skipped due to too many changes:
`packages/smart-router/evm/constants/gasModel/index.ts`,
`apps/web/src/config/constants/tokenLists/pancake-default.tokenlist.json`,
`packages/smart-router/evm/v3-router/providers/onChainQuoteProvider.ts`,
`packages/tokens/src/allTokens.ts`,
`apps/web/src/config/constants/contracts.ts`,
`apps/web/src/config/constants/exchange.ts`,
`packages/v3-sdk/src/constants.ts`,
`packages/swap-sdk/src/constants.ts`,
`packages/smart-router/evm/constants/exchange.ts`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
  • Loading branch information
0xjojoex authored Feb 6, 2024
1 parent c9e2d29 commit 91969f8
Show file tree
Hide file tree
Showing 29 changed files with 369 additions and 99 deletions.
9 changes: 9 additions & 0 deletions .changeset/fresh-drinks-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@pancakeswap/smart-router': patch
'@pancakeswap/sdk': patch
'@pancakeswap/chains': patch
'@pancakeswap/tokens': patch
'@pancakeswap/v3-sdk': patch
---

Add sepolia, base sepolia, arbitrum sepolia support
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"OPBNB",
"pancakeswap",
"tanstack",
"sepolia",
"vecake",
"wagmi",
"wbnb",
Expand Down
3 changes: 3 additions & 0 deletions apps/web/src/components/NetworkSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ const SHORT_SYMBOL = {
[ChainId.BASE]: 'Base',
[ChainId.BASE_TESTNET]: 'tBase',
[ChainId.SCROLL_SEPOLIA]: 'tScroll',
[ChainId.SEPOLIA]: 'sepolia',
[ChainId.BASE_SEPOLIA]: 'Base Sepolia',
[ChainId.ARBITRUM_SEPOLIA]: 'Arb Sepolia',
} as const satisfies Record<ChainId, string>

export const NetworkSwitcher = () => {
Expand Down
12 changes: 9 additions & 3 deletions apps/web/src/config/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import {
Chain,
arbitrum,
arbitrumGoerli,
arbitrumSepolia,
base,
baseGoerli,
baseSepolia,
bscTestnet,
bsc as bsc_,
goerli,
Expand All @@ -17,6 +19,7 @@ import {
polygonZkEvm,
polygonZkEvmTestnet,
scrollSepolia,
sepolia,
zkSync,
zkSyncTestnet,
} from 'wagmi/chains'
Expand Down Expand Up @@ -67,25 +70,28 @@ export const L2_CHAIN_IDS: ChainId[] = [
ChainId.BASE_TESTNET,
ChainId.OPBNB,
ChainId.OPBNB_TESTNET,
ChainId.ARBITRUM_SEPOLIA,
ChainId.BASE_SEPOLIA,
]

export const CHAINS = [
bsc,
mainnet,
bscTestnet,
mainnet,
goerli,
sepolia,
polygonZkEvm,
polygonZkEvmTestnet,
zkSync,
zkSyncTestnet,
arbitrum,
arbitrumGoerli,
arbitrumSepolia,
linea,
lineaTestnet,
arbitrumGoerli,
arbitrum,
base,
baseGoerli,
baseSepolia,
opBNB,
opBNBTestnet,
scrollSepolia,
Expand Down
23 changes: 3 additions & 20 deletions apps/web/src/config/constants/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GAUGES_ADDRESS, GAUGES_CALC_ADDRESS } from '@pancakeswap/gauges'
import { ICAKE } from '@pancakeswap/ifos'
import { CAKE_VAULT } from '@pancakeswap/pools'
import { V3_QUOTER_ADDRESSES } from '@pancakeswap/smart-router/evm'
import { DEPLOYER_ADDRESSES } from '@pancakeswap/v3-sdk'
import { DEPLOYER_ADDRESSES, NFT_POSITION_MANAGER_ADDRESSES } from '@pancakeswap/v3-sdk'

export default {
masterChef: {
Expand Down Expand Up @@ -168,25 +168,7 @@ export default {
[ChainId.BSC]: '0xa842a4AD40FEbbd034fbeF25C7a880464a90e695',
[ChainId.BSC_TESTNET]: '0x',
},
nftPositionManager: {
[ChainId.ETHEREUM]: '0x46A15B0b27311cedF172AB29E4f4766fbE7F4364',
[ChainId.GOERLI]: '0x427bF5b37357632377eCbEC9de3626C71A5396c1',
[ChainId.BSC]: '0x46A15B0b27311cedF172AB29E4f4766fbE7F4364',
[ChainId.BSC_TESTNET]: '0x427bF5b37357632377eCbEC9de3626C71A5396c1',
[ChainId.ZKSYNC_TESTNET]: '0xF84697CfE7c88F846e4ba5dAe14A6A8f67deF5c2',
[ChainId.ZKSYNC]: '0xa815e2eD7f7d5B0c49fda367F249232a1B9D2883',
[ChainId.POLYGON_ZKEVM]: '0x46A15B0b27311cedF172AB29E4f4766fbE7F4364',
[ChainId.POLYGON_ZKEVM_TESTNET]: '0x1f489dd5B559E976AE74303F939Cfd0aF1b62C2B',
[ChainId.ARBITRUM_ONE]: '0x46A15B0b27311cedF172AB29E4f4766fbE7F4364',
[ChainId.LINEA]: '0x46A15B0b27311cedF172AB29E4f4766fbE7F4364',
[ChainId.LINEA_TESTNET]: '0xacFa791C833120c769Fd3066c940B7D30Cd8BC73',
[ChainId.ARBITRUM_GOERLI]: '0xb10120961f7504766976A89E29802Fa00553da5b',
[ChainId.OPBNB]: '0x46A15B0b27311cedF172AB29E4f4766fbE7F4364',
[ChainId.OPBNB_TESTNET]: '0x9d4277f1D41CCB30C0e91f7d1bBA2A739E19032C',
[ChainId.BASE]: '0x46A15B0b27311cedF172AB29E4f4766fbE7F4364',
[ChainId.BASE_TESTNET]: '0x0F81fD8DaC20A21029B496D8F8E08385201B8ca0',
[ChainId.SCROLL_SEPOLIA]: '0x0F81fD8DaC20A21029B496D8F8E08385201B8ca0',
},
nftPositionManager: NFT_POSITION_MANAGER_ADDRESSES,
v3PoolDeployer: DEPLOYER_ADDRESSES,
v3Migrator: {
[ChainId.ETHEREUM]: '0xbC203d7f83677c7ed3F7acEc959963E7F4ECC5C2',
Expand All @@ -206,6 +188,7 @@ export default {
[ChainId.BASE]: '0xbC203d7f83677c7ed3F7acEc959963E7F4ECC5C2',
[ChainId.BASE_TESTNET]: '0x8Ae8592a24CD13b7E09D2763E7d6A39E3c0D6bad',
[ChainId.SCROLL_SEPOLIA]: '0x8Ae8592a24CD13b7E09D2763E7d6A39E3c0D6bad',
[ChainId.SEPOLIA]: '0xbC203d7f83677c7ed3F7acEc959963E7F4ECC5C2',
},
quoter: V3_QUOTER_ADDRESSES,
v3Airdrop: {
Expand Down
39 changes: 25 additions & 14 deletions apps/web/src/config/constants/exchange.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
import { Percent, Token, WNATIVE } from '@pancakeswap/sdk'
import { ChainId } from '@pancakeswap/chains'
import { Percent, Token, WNATIVE } from '@pancakeswap/sdk'
import {
bscTokens,
bscTestnetTokens,
BUSD,
USDC,
USDT,
BUSD,
WBTC_ETH,
arbSepoliaTokens,
arbitrumGoerliTokens,
arbitrumTokens,
polygonZkEvmTokens,
polygonZkEvmTestnetTokens,
zksyncTokens,
zkSyncTestnetTokens,
baseSepoliaTokens,
baseTestnetTokens,
baseTokens,
bscTestnetTokens,
bscTokens,
lineaTestnetTokens,
arbitrumGoerliTokens,
opBnbTokens,
lineaTokens,
opBnbTestnetTokens,
baseTokens,
baseTestnetTokens,
opBnbTokens,
polygonZkEvmTestnetTokens,
polygonZkEvmTokens,
scrollSepoliaTokens,
lineaTokens,
zkSyncTestnetTokens,
zksyncTokens,
} from '@pancakeswap/tokens'
import { ChainTokenList } from './types'

export {
ADDITIONAL_BASES,
V2_ROUTER_ADDRESS,
BASES_TO_CHECK_TRADES_AGAINST,
CUSTOM_BASES,
V2_ROUTER_ADDRESS,
} from '@pancakeswap/smart-router/evm'

export const CHAIN_REFRESH_TIME = {
Expand All @@ -48,6 +50,9 @@ export const CHAIN_REFRESH_TIME = {
[ChainId.BASE]: 6_000,
[ChainId.BASE_TESTNET]: 6_000,
[ChainId.SCROLL_SEPOLIA]: 6_000,
[ChainId.SEPOLIA]: 12_000,
[ChainId.BASE_SEPOLIA]: 6_000,
[ChainId.ARBITRUM_SEPOLIA]: 6_000,
} as const satisfies Record<ChainId, number>

// used for display in the default list when adding liquidity
Expand All @@ -74,6 +79,9 @@ export const SUGGESTED_BASES: ChainTokenList = {
[ChainId.BASE]: [baseTokens.usdc, baseTokens.weth],
[ChainId.BASE_TESTNET]: [baseTestnetTokens.usdc, baseTestnetTokens.weth],
[ChainId.SCROLL_SEPOLIA]: [scrollSepoliaTokens.usdc, scrollSepoliaTokens.weth],
[ChainId.SEPOLIA]: [scrollSepoliaTokens.usdc, scrollSepoliaTokens.weth],
[ChainId.ARBITRUM_SEPOLIA]: [arbSepoliaTokens.usdc, arbSepoliaTokens.weth],
[ChainId.BASE_SEPOLIA]: [baseSepoliaTokens.usdc, baseSepoliaTokens.weth],
}

// used to construct the list of all pairs we consider by default in the frontend
Expand All @@ -95,6 +103,9 @@ export const BASES_TO_TRACK_LIQUIDITY_FOR: ChainTokenList = {
[ChainId.BASE]: [baseTokens.usdc, baseTokens.weth],
[ChainId.BASE_TESTNET]: [baseTestnetTokens.usdc, baseTestnetTokens.weth],
[ChainId.SCROLL_SEPOLIA]: [scrollSepoliaTokens.usdc, scrollSepoliaTokens.weth],
[ChainId.SEPOLIA]: [scrollSepoliaTokens.usdc, scrollSepoliaTokens.weth],
[ChainId.ARBITRUM_SEPOLIA]: [arbSepoliaTokens.usdc, arbSepoliaTokens.weth],
[ChainId.BASE_SEPOLIA]: [baseSepoliaTokens.usdc, baseSepoliaTokens.weth],
}

export const PINNED_PAIRS: { readonly [chainId in ChainId]?: [Token, Token][] } = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,30 @@
"chainId": 1,
"logoURI": "https://tokens.pancakeswap.finance/images/symbol/weth.png"
},
{
"name": "Wrapped Ether",
"address": "0x4200000000000000000000000000000000000006",
"symbol": "WETH",
"decimals": 18,
"chainId": 84532,
"logoURI": "https://tokens.pancakeswap.finance/images/symbol/weth.png"
},
{
"name": "Wrapped Ether",
"address": "0x1bdc540dEB9Ed1fA29964DeEcCc524A8f5e2198e",
"symbol": "WETH",
"decimals": 18,
"chainId": 421614,
"logoURI": "https://tokens.pancakeswap.finance/images/symbol/weth.png"
},
{
"name": "Wrapped Ether",
"address": "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14",
"symbol": "WETH",
"decimals": 18,
"chainId": 11155111,
"logoURI": "https://tokens.pancakeswap.finance/images/symbol/weth.png"
},
{
"name": "Wrapped Ether",
"address": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
Expand Down Expand Up @@ -322,6 +346,30 @@
"chainId": 534351,
"logoURI": "https://tokens.pancakeswap.finance/images/symbol/usdc.png"
},
{
"name": "USD Coin",
"address": "0x6f14C02Fc1F78322cFd7d707aB90f18baD3B54f5",
"symbol": "USDC",
"decimals": 6,
"chainId": 11155111,
"logoURI": "https://tokens.pancakeswap.finance/images/symbol/usdc.png"
},
{
"name": "USD Coin",
"address": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"symbol": "USDC",
"decimals": 6,
"chainId": 84532,
"logoURI": "https://tokens.pancakeswap.finance/images/symbol/usdc.png"
},
{
"name": "USD Coin",
"address": "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
"symbol": "USDC",
"decimals": 6,
"chainId": 421614,
"logoURI": "https://tokens.pancakeswap.finance/images/symbol/usdc.png"
},
{
"name": "Tether USD",
"address": "0x1E4a5963aBFD975d8c9021ce480b42188849D41d",
Expand Down
9 changes: 9 additions & 0 deletions apps/web/src/config/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import { getGroveUrl } from 'utils/node/pokt'
import {
arbitrum,
arbitrumGoerli,
arbitrumSepolia,
base,
baseGoerli,
baseSepolia,
linea,
opBNB,
opBNBTestnet,
polygonZkEvm,
polygonZkEvmTestnet,
scrollSepolia,
sepolia,
zkSync,
zkSyncTestnet,
} from 'wagmi/chains'
Expand Down Expand Up @@ -76,6 +79,9 @@ export const SERVER_NODES = {
],
[ChainId.BASE_TESTNET]: baseGoerli.rpcUrls.public.http,
[ChainId.SCROLL_SEPOLIA]: scrollSepolia.rpcUrls.public.http,
[ChainId.SEPOLIA]: sepolia.rpcUrls.public.http,
[ChainId.ARBITRUM_SEPOLIA]: arbitrumSepolia.rpcUrls.public.http,
[ChainId.BASE_SEPOLIA]: baseSepolia.rpcUrls.public.http,
} satisfies Record<ChainId, readonly string[]>

export const PUBLIC_NODES = {
Expand Down Expand Up @@ -145,4 +151,7 @@ export const PUBLIC_NODES = {
].filter(Boolean),
[ChainId.BASE_TESTNET]: baseGoerli.rpcUrls.public.http,
[ChainId.SCROLL_SEPOLIA]: scrollSepolia.rpcUrls.public.http,
[ChainId.SEPOLIA]: sepolia.rpcUrls.public.http,
[ChainId.ARBITRUM_SEPOLIA]: arbitrumSepolia.rpcUrls.public.http,
[ChainId.BASE_SEPOLIA]: baseSepolia.rpcUrls.public.http,
} satisfies Record<ChainId, readonly string[]>
9 changes: 9 additions & 0 deletions apps/web/src/config/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export const POOLS_FAST_REVALIDATE = {
[ChainId.BASE]: 10_000,
[ChainId.BASE_TESTNET]: 10_000,
[ChainId.SCROLL_SEPOLIA]: 10_000,
[ChainId.SEPOLIA]: 20_000,
[ChainId.ARBITRUM_SEPOLIA]: 10_000,
[ChainId.BASE_SEPOLIA]: 10_000,
} as const satisfies Record<ChainId, number>

// Revalidate interval in milliseconds
Expand All @@ -40,6 +43,9 @@ export const POOLS_NORMAL_REVALIDATE = {
[ChainId.BASE]: 15_000,
[ChainId.BASE_TESTNET]: 15_000,
[ChainId.SCROLL_SEPOLIA]: 15_000,
[ChainId.SEPOLIA]: 20_000,
[ChainId.ARBITRUM_SEPOLIA]: 15_000,
[ChainId.BASE_SEPOLIA]: 15_000,
} as const satisfies Record<ChainId, number>

export const POOLS_SLOW_REVALIDATE = {
Expand All @@ -60,4 +66,7 @@ export const POOLS_SLOW_REVALIDATE = {
[ChainId.BASE]: 20_000,
[ChainId.BASE_TESTNET]: 20_000,
[ChainId.SCROLL_SEPOLIA]: 20_000,
[ChainId.SEPOLIA]: 40_000,
[ChainId.ARBITRUM_SEPOLIA]: 20_000,
[ChainId.BASE_SEPOLIA]: 20_000,
} as const satisfies Record<ChainId, number>
4 changes: 3 additions & 1 deletion apps/web/src/hooks/useGetENSAddressByName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { useActiveChainId } from 'hooks/useActiveChainId'
import { useMemo } from 'react'
import { useEnsAddress } from 'wagmi'

const ENS_SUPPORT_CHAIN_IDS = CHAINS.filter((c) => 'ensUniversalResolver' in c.contracts).map((c) => c.id)
const ENS_SUPPORT_CHAIN_IDS = CHAINS.filter((c) => 'contracts' in c && 'ensUniversalResolver' in c.contracts).map(
(c) => c.id,
)

const ENS_NAME_REGEX = /^[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)?$/

Expand Down
3 changes: 3 additions & 0 deletions apps/web/src/state/swap/fetch/fetchDerivedPriceData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ const SWAP_INFO_BY_CHAIN = {
[ChainId.SCROLL_SEPOLIA]: {
v3: V3_SUBGRAPH_URLS[ChainId.SCROLL_SEPOLIA],
},
[ChainId.SEPOLIA]: {},
[ChainId.ARBITRUM_SEPOLIA]: {},
[ChainId.BASE_SEPOLIA]: {},
} satisfies Record<ChainId, Partial<ProtocolEndpoint>>

export const getTokenBestTvlProtocol = async (tokenAddress: string, chainId: ChainId): Promise<Protocol | null> => {
Expand Down
6 changes: 6 additions & 0 deletions packages/chains/src/chainId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ export enum ChainId {
POLYGON_ZKEVM_TESTNET = 1442,
ARBITRUM_ONE = 42161,
ARBITRUM_GOERLI = 421613,
ARBITRUM_SEPOLIA = 421614,
SCROLL_SEPOLIA = 534351,
LINEA = 59144,
LINEA_TESTNET = 59140,
BASE = 8453,
BASE_TESTNET = 84531,
BASE_SEPOLIA = 84532,
SEPOLIA = 11155111,
}

export const testnetChainIds = [
Expand All @@ -28,4 +31,7 @@ export const testnetChainIds = [
ChainId.SCROLL_SEPOLIA,
ChainId.LINEA_TESTNET,
ChainId.BASE_TESTNET,
ChainId.SEPOLIA,
ChainId.ARBITRUM_SEPOLIA,
ChainId.BASE_SEPOLIA,
]
6 changes: 6 additions & 0 deletions packages/chains/src/chainNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const chainNames: Record<ChainId, string> = {
[ChainId.BASE]: 'base',
[ChainId.BASE_TESTNET]: 'baseTestnet',
[ChainId.SCROLL_SEPOLIA]: 'scrollSepolia',
[ChainId.SEPOLIA]: 'sepolia',
[ChainId.ARBITRUM_SEPOLIA]: 'arbSepolia',
[ChainId.BASE_SEPOLIA]: 'baseSepolia',
}

export const chainNameToChainId = Object.entries(chainNames).reduce((acc, [chainId, chainName]) => {
Expand Down Expand Up @@ -47,4 +50,7 @@ export const defiLlamaChainNames: Record<ChainId, string> = {
[ChainId.SCROLL_SEPOLIA]: '',
[ChainId.LINEA]: 'linea',
[ChainId.BASE]: 'base',
[ChainId.SEPOLIA]: '',
[ChainId.ARBITRUM_SEPOLIA]: '',
[ChainId.BASE_SEPOLIA]: '',
}
Loading

0 comments on commit 91969f8

Please sign in to comment.