Skip to content

Commit

Permalink
chore: Add support for linea testnet (#7204)
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
-->

<!--
copilot:all
-->
### <samp>🤖 Generated by Copilot at 58fd408</samp>

### Summary
🌐🔄🛠️

<!--
1. 🌐 - This emoji represents the addition of new networks and chains to
the app, such as Arbitrum, Polygon ZK-EVM, and zkSync. It also
represents the improvement of the network switcher and the menu
configuration to support different features across different chains.
2. 🔄 - This emoji represents the update of the exchange configuration,
the token list, the subgraph URLs, and the router address to support the
latest exchange contract and the cross-farming feature on various
chains. It also represents the refactoring of the pools hook to use
loading states and version-specific data.
3. 🛠️ - This emoji represents the improvement of the code quality and
the error handling for various cases, such as the native currency logo,
the unsupported and wrong network modals, the subgraph URL prefix, the
contract address validation, and the token and constant existence
checks. It also represents the linting exceptions and the type
specification for the farms API.
-->
The pull request adds support for various L2 networks and improves the
exchange feature across different EVM-compatible chains. It updates the
contracts, tokens, pools, subgraphs, and nodes configuration for the new
chains, and adds some checks and conditions to handle chain-specific
logic and compatibility issues. It also refactors some hooks and
components to use loading states and version-specific data, and fixes
some minor bugs and errors. It affects files such as `v3.ts`,
`config.ts`, `NetworkSwitcher.tsx`, `chains.ts`, `contracts.ts`,
`endpoints.ts`, `exchange.ts`, `pancake-default.tokenlist.json`,
`nodes.ts`, `pools.ts`, `useApproveCallback.ts`, `useBUSDPrice.ts`,
`useCommonPools.ts`, `CurrencyLogo.tsx`, `NetworkModal.tsx`,
`FloatingSubgraphHealthIndicators.tsx`, `contracts.test.ts`, `lists.ts`,
`useDomain.ts`, and `useInfoUserSavedTokensAndPoolsList.ts`.

> _We're sailing across the EVM seas_
> _With new chains and features to please_
> _We'll swap and farm with ease_
> _On the count of three, heave ho `pancake`!_

### Walkthrough
* Add support for new chains for the exchange, farms, and pools features
([link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-0e56562b1a287487ad933f04eb8867f8afbccfc461716cc24e9ddad41d614126L1-R3),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-e0daeed87867fc4fc6b0b1a9c2d52c9bfbd175cd1822e100f43300c4046484adL20-R20),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-e0daeed87867fc4fc6b0b1a9c2d52c9bfbd175cd1822e100f43300c4046484adL47-R236),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-5b02b946734e39568c018763a8445fe22e5633c04fa393f78eaec1947165713dL45-R49),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-870705bc610c873933b2d04d9a57db54345cab8d9ad2af707454ac577b21f6e4L3-R15),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-870705bc610c873933b2d04d9a57db54345cab8d9ad2af707454ac577b21f6e4L11-R40),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-870705bc610c873933b2d04d9a57db54345cab8d9ad2af707454ac577b21f6e4L35-R138),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-6ccab19ffbec70686dc2221f7b79432ece4302c36067c91063d258209c09ec07R189-R196),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-6ccab19ffbec70686dc2221f7b79432ece4302c36067c91063d258209c09ec07R204-R211),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-7238357db46da6bb48ca41841457ac0e832ee21fb8fd76a6b3c9dbf701ce8c62R45-R46),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-7238357db46da6bb48ca41841457ac0e832ee21fb8fd76a6b3c9dbf701ce8c62L59-R70),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-6c1ab0c7f31ca2b1900f09bca08f47eb81d6df582ebc368bdcc1000dbf59659fL2-R25),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-6c1ab0c7f31ca2b1900f09bca08f47eb81d6df582ebc368bdcc1000dbf59659fL10-R39),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-6c1ab0c7f31ca2b1900f09bca08f47eb81d6df582ebc368bdcc1000dbf59659fR46-R52),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-6c1ab0c7f31ca2b1900f09bca08f47eb81d6df582ebc368bdcc1000dbf59659fR61-R67),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-6c1ab0c7f31ca2b1900f09bca08f47eb81d6df582ebc368bdcc1000dbf59659fR81-R89),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-9560b1a30bda8cc12c421b07b679e4dd58b888242ad19086c9e8e38c96709edcL13-R13),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-55ee773d94e57d4fe20f6463bc02307f5d9747933c77b517fa31a90375d2af7eL62-L117),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-55ee773d94e57d4fe20f6463bc02307f5d9747933c77b517fa31a90375d2af7eL158-R157),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-55ee773d94e57d4fe20f6463bc02307f5d9747933c77b517fa31a90375d2af7eL198-R213),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-55ee773d94e57d4fe20f6463bc02307f5d9747933c77b517fa31a90375d2af7eR222-R229),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-17218d64565ce12e09953351575126053d6b30541c3605f7ee38a34374a7daecR2),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-17218d64565ce12e09953351575126053d6b30541c3605f7ee38a34374a7daecL20-R35),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-17218d64565ce12e09953351575126053d6b30541c3605f7ee38a34374a7daecL39-R68),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-6ddce95e802c6a0d90c11aede57b78c496812dc5c4b41ad90624e555af6bde95L9-R16),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-6ddce95e802c6a0d90c11aede57b78c496812dc5c4b41ad90624e555af6bde95L17-R31),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-6ddce95e802c6a0d90c11aede57b78c496812dc5c4b41ad90624e555af6bde95L24-R45),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-30f4e9bda6809aacb9da9383d87f8a61a75ccbdae15da50c832e913381e30fb0L6-R6),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-30f4e9bda6809aacb9da9383d87f8a61a75ccbdae15da50c832e913381e30fb0L171-R171),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-5b34b1fc6cf61851f079c808fdf2ae746784a9471f898b9cac7f8ead870489aaL50-R52),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-5b34b1fc6cf61851f079c808fdf2ae746784a9471f898b9cac7f8ead870489aaL60-R62),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-5b34b1fc6cf61851f079c808fdf2ae746784a9471f898b9cac7f8ead870489aaR262-R264),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-15ed992def68801de075c1f54a3654cdda25fb6f9bb5bc1975579cdd61995ba4L43),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-15ed992def68801de075c1f54a3654cdda25fb6f9bb5bc1975579cdd61995ba4L74-R88),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-d8d2e80f999905e1bd9986d3e969db239634d3022e41fc1471625e64ec294a54R24-R51))
* Change the type of the `zChainId` variable to use the
`FarmSupportedChainId` constant from `@pancakeswap/farms`
([link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-0e56562b1a287487ad933f04eb8867f8afbccfc461716cc24e9ddad41d614126L24-R26))
* Change the path of the native currency logo from `chains` to `native`
in the `ASSET_CDN` URL
([link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-e4d60339c52e33653f8806738d0332de2e480bbb86597c2288be5ca62a87604fL50-R50))
* Swap the order of the conditions for rendering the
`UnsupportedNetworkModal` and the `WrongNetworkModal` in the
`NetworkModal` component
([link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-a9ce57e529d7413179d4dde396ab3cc88885ba094fab1ab62d46e7db0c1d0d2eL48-R61))
* Add a new constant `SHORT_SYMBOL` to map the chain IDs to their short
symbols and use it for displaying the native currency logo with the
symbol in the `NetworkSwitcher` component
([link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-5b02b946734e39568c018763a8445fe22e5633c04fa393f78eaec1947165713dR139-R152),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-5b02b946734e39568c018763a8445fe22e5633c04fa393f78eaec1947165713dL147-R165))
* Add a condition to check if the subgraph URL contains the
`https://api.thegraph.com/subgraphs/name/` prefix before replacing it
with an empty string in the `FloatingSubgraphHealthIndicators` component
([link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-a8f99e5f4e69d35778497b7fe5b2dfa26da8c67a2731b50f0bde548c80b4ceefL27-R32))
* Add a condition to check if the contract has a valid address for the
BSC mainnet before testing for duplicates in the `contracts.test.ts`
file
([link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-a6ef8267b83dcda4d8d9b047fa01f6adada5e581595a2612645b2a3be7937b58L7-R10))
* Remove the BSC mainnet addresses for the `nonBscVault` and
`crossFarmingSender` contracts in the `contracts.ts` file
([link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-6ccab19ffbec70686dc2221f7b79432ece4302c36067c91063d258209c09ec07L163-R166))
* Change the import of the `ROUTER_ADDRESS` constant to
`V2_ROUTER_ADDRESS` and use it for the approve callback hooks in the
`useApproveCallback.ts` file
([link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-30f4e9bda6809aacb9da9383d87f8a61a75ccbdae15da50c832e913381e30fb0L6-R6),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-30f4e9bda6809aacb9da9383d87f8a61a75ccbdae15da50c832e913381e30fb0L171-R171))
* Add some conditions to check if the currency and stable coin variables
are defined before using them for fetching the price in the
`useBUSDPrice.ts` file
([link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-5b34b1fc6cf61851f079c808fdf2ae746784a9471f898b9cac7f8ead870489aaL50-R52),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-5b34b1fc6cf61851f079c808fdf2ae746784a9471f898b9cac7f8ead870489aaL60-R62),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-5b34b1fc6cf61851f079c808fdf2ae746784a9471f898b9cac7f8ead870489aaR262-R264))
* Change the logic for determining the pools data in the
`commonPoolsHookCreator` hook in the `useCommonPools.ts` file
([link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-15ed992def68801de075c1f54a3654cdda25fb6f9bb5bc1975579cdd61995ba4L43),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-15ed992def68801de075c1f54a3654cdda25fb6f9bb5bc1975579cdd61995ba4L74-R88))
* Change the `chainId` argument for the `useEnsName` and `useEnsAvatar`
hooks to use the Goerli chain ID if the current chain ID is Goerli in
the `useDomain.ts` file
([link](https://github.com/pancakeswap/pancake-frontend/pull/7204/files?diff=unified&w=0#diff-eaf278af1e252c50795b1e1288593d10523d442f05f28a79dbfb499314889bd1L17-R22))

---------

Co-authored-by: ChefJoJo <[email protected]>
  • Loading branch information
chefjackson and 0xjojoex authored Jun 26, 2023
1 parent f1ec1b3 commit 41a58ca
Show file tree
Hide file tree
Showing 103 changed files with 1,277 additions and 469 deletions.
6 changes: 4 additions & 2 deletions apis/farms/src/v3.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { masterChefV3Addresses } from '@pancakeswap/farms'
/* eslint-disable no-await-in-loop */
/* eslint-disable no-param-reassign */
import { masterChefV3Addresses, FarmSupportedChainId } from '@pancakeswap/farms'
import { ChainId, ERC20Token } from '@pancakeswap/sdk'
import { CurrencyAmount } from '@pancakeswap/swap-sdk-core'
import { PositionMath } from '@pancakeswap/v3-sdk'
Expand All @@ -21,7 +23,7 @@ export const V3_SUBGRAPH_CLIENTS = {
[ChainId.BSC_TESTNET]: new GraphQLClient('https://api.thegraph.com/subgraphs/name/pancakeswap/exchange-v3-chapel', {
fetch,
}),
} satisfies Record<ChainId, GraphQLClient>
} satisfies Record<FarmSupportedChainId, GraphQLClient>

const zChainId = z.enum(['56', '1', '5', '97'])

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Logo/CurrencyLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function CurrencyLogo({ currency, size = '24px', style }: LogoPro
return <BinanceIcon width={size} style={style} />
}
return (
<StyledLogo size={size} srcs={[`${ASSET_CDN}/web/chains/${currency.chainId}.png`]} width={size} style={style} />
<StyledLogo size={size} srcs={[`${ASSET_CDN}/web/native/${currency.chainId}.png`]} width={size} style={style} />
)
}

Expand Down
4 changes: 3 additions & 1 deletion apps/web/src/components/Menu/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ContextApi } from '@pancakeswap/localization'
import { SUPPORTED_CHAIN_IDS as POOL_SUPPORTED_CHAINS } from '@pancakeswap/pools'
import { nftsBaseUrl } from 'views/Nft/market/constants'
import { getPerpetualUrl } from 'utils/getPerpetualUrl'
import { SUPPORT_ONLY_BSC } from 'config/constants/supportChains'
import { SUPPORT_FARMS, SUPPORT_ONLY_BSC } from 'config/constants/supportChains'
import { NewIconButton } from 'views/BuyCrypto/components/NewIcon'

export type ConfigMenuDropDownItemsType = DropdownMenuItems & { hideSubNav?: boolean }
Expand Down Expand Up @@ -95,10 +95,12 @@ const config: (
icon: EarnIcon,
fillIcon: EarnFillIcon,
image: '/images/decorations/pe2.png',
supportChainIds: SUPPORT_FARMS,
items: [
{
label: t('Farms'),
href: '/farms',
supportChainIds: SUPPORT_FARMS,
},
{
label: t('Pools'),
Expand Down
16 changes: 8 additions & 8 deletions apps/web/src/components/NetworkModal/NetworkModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ export const NetworkModal = ({ pageSupportedChains = SUPPORT_ONLY_BSC }: { pageS
)
}

if ((chain?.unsupported ?? false) || isPageNotSupported) {
if (isWrongNetwork && !dismissWrongNetwork && !isPageNotSupported) {
const currentChain = chains.find((c) => c.id === chainId)
if (!currentChain) return null
return (
<ModalV2 isOpen closeOnOverlayClick={false}>
<UnsupportedNetworkModal pageSupportedChains={pageSupportedChains?.length ? pageSupportedChains : CHAIN_IDS} />
<ModalV2 isOpen={isWrongNetwork} closeOnOverlayClick onDismiss={() => setDismissWrongNetwork(true)}>
<WrongNetworkModal currentChain={currentChain} onDismiss={() => setDismissWrongNetwork(true)} />
</ModalV2>
)
}

if (isWrongNetwork && !dismissWrongNetwork) {
const currentChain = chains.find((c) => c.id === chainId)
if (!currentChain) return null
if ((chain?.unsupported ?? false) || isPageNotSupported) {
return (
<ModalV2 isOpen={isWrongNetwork} closeOnOverlayClick onDismiss={() => setDismissWrongNetwork(true)}>
<WrongNetworkModal currentChain={currentChain} onDismiss={() => setDismissWrongNetwork(true)} />
<ModalV2 isOpen closeOnOverlayClick={false}>
<UnsupportedNetworkModal pageSupportedChains={pageSupportedChains?.length ? pageSupportedChains : CHAIN_IDS} />
</ModalV2>
)
}
Expand Down
22 changes: 20 additions & 2 deletions apps/web/src/components/NetworkSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ const NetworkSelect = ({ switchNetwork, chainId }) => {
</Box>
<UserMenuDivider />
{chains
.filter((chain) => !('testnet' in chain && chain.testnet) || chain.id === chainId)
.filter(
(chain) =>
// chain.id === ChainId.LINEA_TESTNET ||
!('testnet' in chain && chain.testnet) || chain.id === chainId,
)
.map((chain) => (
<UserMenuItem
key={chain.id}
Expand Down Expand Up @@ -132,6 +136,20 @@ const WrongNetworkSelect = ({ switchNetwork, chainId }) => {
)
}

const SHORT_SYMBOL = {
[ChainId.ETHEREUM]: 'ETH',
[ChainId.BSC]: 'BNB',
[ChainId.BSC_TESTNET]: 'tBNB',
[ChainId.GOERLI]: 'GOR',
[ChainId.ARBITRUM_ONE]: 'ARB',
[ChainId.ARBITRUM_GOERLI]: 'tARB',
[ChainId.POLYGON_ZKEVM]: 'Polygon zkEVM',
[ChainId.POLYGON_ZKEVM_TESTNET]: 'tZkEVM',
[ChainId.ZKSYNC]: 'zkSync',
[ChainId.ZKSYNC_TESTNET]: 'tZkSync',
[ChainId.LINEA_TESTNET]: 'tLinea',
} as const satisfies Record<ChainId, string>

export const NetworkSwitcher = () => {
const { t } = useTranslation()
const { chainId, isWrongNetwork, isNotMatched } = useActiveChainId()
Expand All @@ -144,7 +162,7 @@ export const NetworkSwitcher = () => {
() => chains.find((c) => c.id === (isLoading ? pendingChainId || chainId : chainId)),
[isLoading, pendingChainId, chainId],
)
const symbol = NATIVE[foundChain?.id]?.symbol ?? foundChain?.nativeCurrency?.symbol
const symbol = SHORT_SYMBOL[foundChain?.id] ?? NATIVE[foundChain?.id]?.symbol ?? foundChain?.nativeCurrency?.symbol
const { targetRef, tooltip, tooltipVisible } = useTooltip(
t('Unable to switch network. Please try it on your wallet'),
{ placement: 'bottom' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ export function subgraphHealthIndicatorFactory({ getSubgraphName }: FactoryParam
}

export const V3SubgraphHealthIndicator = subgraphHealthIndicatorFactory({
getSubgraphName: (chainId) =>
V3_SUBGRAPH_URLS[chainId]?.replace('https://api.thegraph.com/subgraphs/name/', '') || '',
getSubgraphName: (chainId) => {
if (V3_SUBGRAPH_URLS[chainId]?.startsWith('https://api.thegraph.com/subgraphs/name/')) {
return V3_SUBGRAPH_URLS[chainId].replace('https://api.thegraph.com/subgraphs/name/', '') || ''
}
return ''
},
})

export const LotterySubgraphHealthIndicator = subgraphHealthIndicatorFactory({
Expand Down
6 changes: 4 additions & 2 deletions apps/web/src/config/__tests__/contracts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import contracts from 'config/constants/contracts'

describe('Config contracts', () => {
it.each(map(contracts, (contract, key) => [key, contract]))('Contract %s has a unique address', (key, contract) => {
const duplicates = filter(contracts, (c) => contract[56] === c[56])
expect(duplicates).toHaveLength(1)
if (contract[56]) {
const duplicates = filter(contracts, (c) => contract[56] === c[56])
expect(duplicates).toHaveLength(1)
}
})
})
109 changes: 102 additions & 7 deletions apps/web/src/config/chains.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,43 @@
import { ChainId } from '@pancakeswap/sdk'
import memoize from 'lodash/memoize'
import invert from 'lodash/invert'
import { bsc as bsc_, bscTestnet, goerli, mainnet, Chain } from 'wagmi/chains'
import {
bsc as bsc_,
bscTestnet,
goerli,
mainnet,
// zkSync as zkSync_,
// zkSyncTestnet as zkSyncTestnet_,
// polygonZkEvmTestnet as polygonZkEvmTestnet_,
// polygonZkEvm as polygonZkEvm_,
lineaTestnet as lineaTestnet_,
// arbitrumGoerli,
Chain,
} from 'wagmi/chains'

export const CHAIN_QUERY_NAME = {
[ChainId.ETHEREUM]: 'eth',
[ChainId.GOERLI]: 'goerli',
[ChainId.BSC]: 'bsc',
[ChainId.BSC_TESTNET]: 'bscTestnet',
[ChainId.ARBITRUM_ONE]: 'arb',
[ChainId.ARBITRUM_GOERLI]: 'arbGoerli',
[ChainId.POLYGON_ZKEVM]: 'polygonZkEVM',
[ChainId.POLYGON_ZKEVM_TESTNET]: 'polygonZkEVMTestnet',
[ChainId.ZKSYNC]: 'zkSync',
[ChainId.ZKSYNC_TESTNET]: 'zkSyncTestnet',
[ChainId.LINEA_TESTNET]: 'lineaTestnet',
} as const satisfies Record<ChainId, string>

const CHAIN_QUERY_NAME_TO_ID = invert(CHAIN_QUERY_NAME)
const CHAIN_QUERY_NAME_TO_ID = Object.entries(CHAIN_QUERY_NAME).reduce((acc, [chainId, chainName]) => {
return {
[chainName.toLowerCase()]: chainId as unknown as ChainId,
...acc,
}
}, {} as Record<string, ChainId>)

export const getChainId = memoize((chainName: string) => {
if (!chainName) return undefined
return CHAIN_QUERY_NAME_TO_ID[chainName] ? +CHAIN_QUERY_NAME_TO_ID[chainName] : undefined
return CHAIN_QUERY_NAME_TO_ID[chainName.toLowerCase()] ? +CHAIN_QUERY_NAME_TO_ID[chainName.toLowerCase()] : undefined
})

const bsc = {
Expand All @@ -32,12 +55,84 @@ const bsc = {
},
} satisfies Chain

export const CHAINS = [bsc, mainnet, bscTestnet, goerli]
// const zkSync = {
// ...zkSync_,
// contracts: {
// multicall3: {
// address: '0x47898B2C52C957663aE9AB46922dCec150a2272c',
// blockCreated: 1536804,
// },
// },
// } as const satisfies Chain

// const zkSyncTestnet = {
// ...zkSyncTestnet_,
// contracts: {
// multicall3: {
// address: '0x5640049C9e2d33127B34F1bef5C070509f14B5D0',
// blockCreated: 5137723,
// },
// },
// } as const satisfies Chain

// const polygonZkEvm = {
// ...polygonZkEvm_,
// contracts: {
// multicall3: {
// address: '0xcA11bde05977b3631167028862bE2a173976CA11',
// blockCreated: 57746,
// },
// },
// } as const satisfies Chain

// const polygonZkEvmTestnet = {
// ...polygonZkEvmTestnet_,
// contracts: {
// multicall3: {
// address: '0xcA11bde05977b3631167028862bE2a173976CA11',
// blockCreated: 525686,
// },
// },
// } as const satisfies Chain

const lineaTestnet = {
...lineaTestnet_,
blockExplorers: {
etherscan: {
name: 'LineaScan',
url: 'https://goerli.lineascan.build',
},
default: {
name: 'LineaScan',
url: 'https://goerli.lineascan.build',
},
},
} as const satisfies Chain

/**
* Controls some L2 specific behavior, e.g. slippage tolerance, special UI behavior.
* The expectation is that all of these networks have immediate transaction confirmation.
*/
export const L2_CHAIN_IDS: ChainId[] = []
export const L2_CHAIN_IDS: ChainId[] = [
ChainId.ARBITRUM_ONE,
ChainId.ARBITRUM_GOERLI,
ChainId.POLYGON_ZKEVM,
ChainId.POLYGON_ZKEVM_TESTNET,
ChainId.ZKSYNC,
ChainId.ZKSYNC_TESTNET,
ChainId.LINEA_TESTNET,
]

export const MAINNET_CHAINS = [bsc, mainnet]
export const CHAINS = [
bsc,
mainnet,
bscTestnet,
goerli,
// zkSync,
// zkSyncTestnet,
// polygonZkEvm,
// polygonZkEvmTestnet,
lineaTestnet,
// arbitrumGoerli,
// arbitrum,
]
18 changes: 16 additions & 2 deletions apps/web/src/config/constants/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,10 @@ export default {
97: '0x56666300A1E25624489b661f3C6c456c159a109a',
},
nonBscVault: {
56: '0xE6c904424417D03451fADd6E3f5b6c26BcC43841', // Only for pass contracts test
1: '0x2e71B2688019ebdFDdE5A45e6921aaebb15b25fb',
5: '0xE6c904424417D03451fADd6E3f5b6c26BcC43841',
},
crossFarmingSender: {
56: '0x327d26dE30f92600620A99043034e0A5FD9402C8', // Only for pass contracts test
1: '0x8EA90Ef07f37c77137453C7A1B72B7886d51eCFb',
5: '0x327d26dE30f92600620A99043034e0A5FD9402C8',
},
Expand All @@ -188,13 +186,29 @@ export default {
5: '0x427bF5b37357632377eCbEC9de3626C71A5396c1',
56: '0x46A15B0b27311cedF172AB29E4f4766fbE7F4364',
97: '0x427bF5b37357632377eCbEC9de3626C71A5396c1',
// TODO: new chains
280: '0x1ede0FF9b7Bd6DC0625e3ba579d5FD697e6698b2',
324: '0x',
1101: '0x46A15B0b27311cedF172AB29E4f4766fbE7F4364',
1442: '0x1f489dd5B559E976AE74303F939Cfd0aF1b62C2B',
42161: '0x46A15B0b27311cedF172AB29E4f4766fbE7F4364',
59140: '0xacFa791C833120c769Fd3066c940B7D30Cd8BC73',
421613: '0xb10120961f7504766976A89E29802Fa00553da5b',
},
v3PoolDeployer: DEPLOYER_ADDRESSES,
v3Migrator: {
1: '0xbC203d7f83677c7ed3F7acEc959963E7F4ECC5C2',
5: '0x46A15B0b27311cedF172AB29E4f4766fbE7F4364',
56: '0xbC203d7f83677c7ed3F7acEc959963E7F4ECC5C2',
97: '0x46A15B0b27311cedF172AB29E4f4766fbE7F4364',
// TODO: new chains
280: '0x612662964B5bd12111504C13D694eeEF566f3916',
324: '0x',
1101: '0xbC203d7f83677c7ed3F7acEc959963E7F4ECC5C2',
1442: '0x4A3902773F947ce028969db670E568fFC9524E8C',
42161: '0xbC203d7f83677c7ed3F7acEc959963E7F4ECC5C2',
59140: '0x3652Fc6EDcbD76161b8554388867d3dAb65eCA93',
421613: '0xCcf770BdBD8ccC57a7a7ABff53825fD895a06238',
},
quoter: V3_QUOTER_ADDRESSES,
v3Airdrop: {
Expand Down
13 changes: 12 additions & 1 deletion apps/web/src/config/constants/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export const CELER_API = 'https://api.celerscan.com/scan'
export const INFO_CLIENT_WITH_CHAIN = {
[ChainId.BSC]: INFO_CLIENT,
[ChainId.ETHEREUM]: INFO_CLIENT_ETH,
[ChainId.LINEA_TESTNET]: 'https://thegraph.goerli.zkevm.consensys.net/subgraphs/name/pancakeswap/exhange-eth/',
[ChainId.ARBITRUM_ONE]: 'https://thegraph.com/hosted-service/subgraph/chef-jojo/exchange-v2-arb',
}

export const BLOCKS_CLIENT_WITH_CHAIN = {
Expand All @@ -56,7 +58,16 @@ export const V3_SUBGRAPH_URLS = {
[ChainId.GOERLI]: 'https://api.thegraph.com/subgraphs/name/pancakeswap/exchange-v3-goerli',
[ChainId.BSC]: `https://api.thegraph.com/subgraphs/name/pancakeswap/exchange-v3-bsc`,
[ChainId.BSC_TESTNET]: 'https://api.thegraph.com/subgraphs/name/pancakeswap/exchange-v3-chapel',
} satisfies Record<ChainId, string>
// TODO: new chains
[ChainId.ARBITRUM_ONE]: 'https://thegraph.com/hosted-service/subgraph/chef-jojo/exchange-v3-arb',
[ChainId.ARBITRUM_GOERLI]: 'https://api.thegraph.com/subgraphs/name/chef-jojo/exhange-v3-arb-goerli',
[ChainId.POLYGON_ZKEVM]: 'https://api.studio.thegraph.com/query/45376/exchange-v3-polygon-zkevm/v0.0.0',
[ChainId.POLYGON_ZKEVM_TESTNET]: null,
[ChainId.ZKSYNC]: null,
[ChainId.ZKSYNC_TESTNET]: 'https://api.studio.thegraph.com/query/45376/exchange-v3-zksync-testnet/v0.0.1',
[ChainId.LINEA_TESTNET]:
'https://thegraph.goerli.zkevm.consensys.net/subgraphs/name/pancakeswap/exchange-v3-linea-goerli',
} satisfies Record<ChainId, string | null>

export const TRADING_REWARD_API = 'https://pancake-trading-fee-rebate-api.pancake.run/api/v1'

Expand Down
Loading

0 comments on commit 41a58ca

Please sign in to comment.