From fc2ccab22c16f1713b17db2f3632f1670e2ddd76 Mon Sep 17 00:00:00 2001 From: Gleiser Oliveira Date: Mon, 16 Dec 2024 12:31:45 -0600 Subject: [PATCH 1/3] feat: add Base network metadata --- apps/evm/src/config/rpcUrls.ts | 2 ++ apps/evm/src/config/subgraphUrls.ts | 8 ++++++++ apps/evm/src/constants/layerZero.ts | 2 ++ apps/evm/src/constants/prime.ts | 2 ++ apps/evm/src/libs/contracts/config/index.ts | 4 ++++ .../tokens/infos/commonTokens/baseMainnet.ts | 13 +++++++++++++ .../tokens/infos/commonTokens/baseSepolia.ts | 13 +++++++++++++ .../libs/tokens/infos/commonTokens/index.ts | 4 ++++ .../infos/disabledTokenActions/baseMainnet.ts | 3 +++ .../infos/disabledTokenActions/baseSepolia.ts | 3 +++ .../tokens/infos/disabledTokenActions/index.ts | 4 ++++ .../infos/pancakeSwapTokens/baseMainnet.ts | 3 +++ .../infos/pancakeSwapTokens/baseSepolia.ts | 3 +++ .../tokens/infos/pancakeSwapTokens/index.tsx | 4 ++++ apps/evm/src/libs/wallet/chains.ts | 4 ++++ packages/chains/src/chainMetadata.ts | 18 ++++++++++++++++++ packages/chains/src/img/chains/base.svg | 3 +++ packages/chains/src/types.ts | 2 ++ 18 files changed, 95 insertions(+) create mode 100644 apps/evm/src/libs/tokens/infos/commonTokens/baseMainnet.ts create mode 100644 apps/evm/src/libs/tokens/infos/commonTokens/baseSepolia.ts create mode 100644 apps/evm/src/libs/tokens/infos/disabledTokenActions/baseMainnet.ts create mode 100644 apps/evm/src/libs/tokens/infos/disabledTokenActions/baseSepolia.ts create mode 100644 apps/evm/src/libs/tokens/infos/pancakeSwapTokens/baseMainnet.ts create mode 100644 apps/evm/src/libs/tokens/infos/pancakeSwapTokens/baseSepolia.ts create mode 100644 packages/chains/src/img/chains/base.svg diff --git a/apps/evm/src/config/rpcUrls.ts b/apps/evm/src/config/rpcUrls.ts index e3afb7c74d..ccc766f3da 100644 --- a/apps/evm/src/config/rpcUrls.ts +++ b/apps/evm/src/config/rpcUrls.ts @@ -18,4 +18,6 @@ export const rpcUrls: { [ChainId.ZKSYNC_SEPOLIA]: 'https://sepolia.era.zksync.dev', [ChainId.OPTIMISM_MAINNET]: `https://opt-mainnet.nodereal.io/v1/${envVariables.VITE_NODE_REAL_API_KEY}`, [ChainId.OPTIMISM_SEPOLIA]: 'https://sepolia.optimism.io', + [ChainId.BASE_MAINNET]: `https://open-platform.nodereal.io/${envVariables.VITE_NODE_REAL_API_KEY}/base`, + [ChainId.BASE_SEPOLIA]: 'https://sepolia.base.org', }; diff --git a/apps/evm/src/config/subgraphUrls.ts b/apps/evm/src/config/subgraphUrls.ts index 25d37ed5e1..7fef79c943 100644 --- a/apps/evm/src/config/subgraphUrls.ts +++ b/apps/evm/src/config/subgraphUrls.ts @@ -27,6 +27,10 @@ export const getIsolatedPoolsSubgraphUrls = ({ [ChainId.OPTIMISM_MAINNET]: `https://gateway.thegraph.com/api/${theGraphApiKey}/deployments/id/QmZqvM6BRz1nNvK41SbfcafW2sbLZpnDMmubpQ5phkmPD8`, [ChainId.OPTIMISM_SEPOLIA]: 'https://api.studio.thegraph.com/query/64786/venus-il-optimism-sepolia/version/latest', + // TODO: add BASE_MAINNET once it's deployed + [ChainId.BASE_MAINNET]: '', + [ChainId.BASE_SEPOLIA]: + 'https://api.studio.thegraph.com/query/64786/venus-isolated-pools-base-sepolia/latest', }; return subgraphUrls; @@ -59,6 +63,10 @@ export const getGovernanceSubgraphUrls = ({ [ChainId.OPTIMISM_MAINNET]: `https://gateway.thegraph.com/api/${theGraphApiKey}/deployments/id/QmdTVnzZrFhVn3Q158b3E2rNPFPmEEfyQwgN3im2GbCQLy`, [ChainId.OPTIMISM_SEPOLIA]: 'https://api.studio.thegraph.com/query/64786/venus-governance-opsepolia/version/latest', + // TODO: add BASE_MAINNET once it's deployed + [ChainId.BASE_MAINNET]: '', + [ChainId.BASE_SEPOLIA]: + 'https://api.studio.thegraph.com/query/64786/venus-governance-base-sepolia/latest', }; return subgraphUrls; diff --git a/apps/evm/src/constants/layerZero.ts b/apps/evm/src/constants/layerZero.ts index 871a8cdce6..0b74b64479 100644 --- a/apps/evm/src/constants/layerZero.ts +++ b/apps/evm/src/constants/layerZero.ts @@ -13,6 +13,8 @@ export const LAYER_ZERO_CHAIN_IDS: Record = { [ChainId.ZKSYNC_SEPOLIA]: 10248, [ChainId.OPTIMISM_MAINNET]: 111, [ChainId.OPTIMISM_SEPOLIA]: 10232, + [ChainId.BASE_MAINNET]: 184, + [ChainId.BASE_SEPOLIA]: 10245, }; export const CHAIN_IDS_ON_LAYER_ZERO = Object.entries(LAYER_ZERO_CHAIN_IDS).reduce< diff --git a/apps/evm/src/constants/prime.ts b/apps/evm/src/constants/prime.ts index 5c0ff3207b..7c779d3f19 100644 --- a/apps/evm/src/constants/prime.ts +++ b/apps/evm/src/constants/prime.ts @@ -129,4 +129,6 @@ export const primeAveragesForNetwork: Record< [ChainId.ZKSYNC_SEPOLIA]: undefined, [ChainId.OPTIMISM_MAINNET]: undefined, [ChainId.OPTIMISM_SEPOLIA]: undefined, + [ChainId.BASE_MAINNET]: undefined, + [ChainId.BASE_SEPOLIA]: undefined, }; diff --git a/apps/evm/src/libs/contracts/config/index.ts b/apps/evm/src/libs/contracts/config/index.ts index 73406e78c2..858b373c27 100644 --- a/apps/evm/src/libs/contracts/config/index.ts +++ b/apps/evm/src/libs/contracts/config/index.ts @@ -532,6 +532,8 @@ export const contracts: ContractConfig[] = [ [ChainId.ZKSYNC_MAINNET]: {}, [ChainId.OPTIMISM_MAINNET]: {}, [ChainId.OPTIMISM_SEPOLIA]: {}, + [ChainId.BASE_MAINNET]: {}, + [ChainId.BASE_SEPOLIA]: {}, }, }, // NativeTokenGateway contract addresses for each supported pool @@ -600,6 +602,8 @@ export const contracts: ContractConfig[] = [ [isolatedPoolsOptimismSepoliaDeployments.addresses.Comptroller_Core.toLowerCase()]: isolatedPoolsOptimismSepoliaDeployments.addresses.NativeTokenGateway_vWETH_Core, }, + [ChainId.BASE_MAINNET]: {}, + [ChainId.BASE_SEPOLIA]: {}, }, }, ]; diff --git a/apps/evm/src/libs/tokens/infos/commonTokens/baseMainnet.ts b/apps/evm/src/libs/tokens/infos/commonTokens/baseMainnet.ts new file mode 100644 index 0000000000..83ba1f61f2 --- /dev/null +++ b/apps/evm/src/libs/tokens/infos/commonTokens/baseMainnet.ts @@ -0,0 +1,13 @@ +import { NATIVE_TOKEN_ADDRESS } from 'constants/address'; +import ethLogo from 'libs/tokens/img/eth.svg'; +import type { Token } from 'types'; + +const ethToken: Token = { + address: NATIVE_TOKEN_ADDRESS, + decimals: 18, + symbol: 'ETH', + asset: ethLogo, + isNative: true, +}; + +export const tokens: Token[] = [ethToken]; diff --git a/apps/evm/src/libs/tokens/infos/commonTokens/baseSepolia.ts b/apps/evm/src/libs/tokens/infos/commonTokens/baseSepolia.ts new file mode 100644 index 0000000000..83ba1f61f2 --- /dev/null +++ b/apps/evm/src/libs/tokens/infos/commonTokens/baseSepolia.ts @@ -0,0 +1,13 @@ +import { NATIVE_TOKEN_ADDRESS } from 'constants/address'; +import ethLogo from 'libs/tokens/img/eth.svg'; +import type { Token } from 'types'; + +const ethToken: Token = { + address: NATIVE_TOKEN_ADDRESS, + decimals: 18, + symbol: 'ETH', + asset: ethLogo, + isNative: true, +}; + +export const tokens: Token[] = [ethToken]; diff --git a/apps/evm/src/libs/tokens/infos/commonTokens/index.ts b/apps/evm/src/libs/tokens/infos/commonTokens/index.ts index 0f588cd116..63564cc54c 100644 --- a/apps/evm/src/libs/tokens/infos/commonTokens/index.ts +++ b/apps/evm/src/libs/tokens/infos/commonTokens/index.ts @@ -3,6 +3,8 @@ import { ChainId } from 'types'; import { tokens as arbitrumOneTokens } from './arbitrumOne'; import { tokens as arbitrumSepoliaTokens } from './arbitrumSepolia'; +import { tokens as baseMainnetTokens } from './baseMainnet'; +import { tokens as baseSepoliaTokens } from './baseSepolia'; import { tokens as bscMainnetTokens } from './bscMainnet'; import { tokens as bscTestnetTokens } from './bscTestnet'; import { tokens as ethereumTokens } from './ethereum'; @@ -27,4 +29,6 @@ export const tokens: TokenMapping = { [ChainId.ZKSYNC_SEPOLIA]: zkSyncSepoliaTokens, [ChainId.OPTIMISM_MAINNET]: optimismMainnetTokens, [ChainId.OPTIMISM_SEPOLIA]: optimismSepoliaTokens, + [ChainId.BASE_MAINNET]: baseMainnetTokens, + [ChainId.BASE_SEPOLIA]: baseSepoliaTokens, }; diff --git a/apps/evm/src/libs/tokens/infos/disabledTokenActions/baseMainnet.ts b/apps/evm/src/libs/tokens/infos/disabledTokenActions/baseMainnet.ts new file mode 100644 index 0000000000..2b5e2d9620 --- /dev/null +++ b/apps/evm/src/libs/tokens/infos/disabledTokenActions/baseMainnet.ts @@ -0,0 +1,3 @@ +import type { DisabledTokenAction } from '../../types'; + +export const disabledTokenActions: DisabledTokenAction[] = []; diff --git a/apps/evm/src/libs/tokens/infos/disabledTokenActions/baseSepolia.ts b/apps/evm/src/libs/tokens/infos/disabledTokenActions/baseSepolia.ts new file mode 100644 index 0000000000..2b5e2d9620 --- /dev/null +++ b/apps/evm/src/libs/tokens/infos/disabledTokenActions/baseSepolia.ts @@ -0,0 +1,3 @@ +import type { DisabledTokenAction } from '../../types'; + +export const disabledTokenActions: DisabledTokenAction[] = []; diff --git a/apps/evm/src/libs/tokens/infos/disabledTokenActions/index.ts b/apps/evm/src/libs/tokens/infos/disabledTokenActions/index.ts index 0c3b301299..836e20f1b4 100644 --- a/apps/evm/src/libs/tokens/infos/disabledTokenActions/index.ts +++ b/apps/evm/src/libs/tokens/infos/disabledTokenActions/index.ts @@ -3,6 +3,8 @@ import { ChainId } from 'types'; import type { DisabledTokenActionMapping } from '../../types'; import { disabledTokenActions as arbitrumOneDisabledTokenActions } from './arbitrumOne'; import { disabledTokenActions as arbitrumSepoliaDisabledTokenActions } from './arbitrumSepolia'; +import { disabledTokenActions as baseMainnetDisabledTokenActions } from './baseMainnet'; +import { disabledTokenActions as baseSepoliaDisabledTokenActions } from './baseSepolia'; import { disabledTokenActions as bscMainnetDisabledTokenActions } from './bscMainnet'; import { disabledTokenActions as bscTestnetDisabledTokenActions } from './bscTestnet'; import { disabledTokenActions as ethereumDisabledTokenActions } from './ethereum'; @@ -27,6 +29,8 @@ const disabledTokenActions: DisabledTokenActionMapping = { [ChainId.ZKSYNC_SEPOLIA]: zkSyncSepoliaDisabledTokenActions, [ChainId.OPTIMISM_MAINNET]: optimismMainnetDisabledTokenActions, [ChainId.OPTIMISM_SEPOLIA]: optimismSepoliaDisabledTokenActions, + [ChainId.BASE_MAINNET]: baseMainnetDisabledTokenActions, + [ChainId.BASE_SEPOLIA]: baseSepoliaDisabledTokenActions, }; export default disabledTokenActions; diff --git a/apps/evm/src/libs/tokens/infos/pancakeSwapTokens/baseMainnet.ts b/apps/evm/src/libs/tokens/infos/pancakeSwapTokens/baseMainnet.ts new file mode 100644 index 0000000000..3f6cabc9e4 --- /dev/null +++ b/apps/evm/src/libs/tokens/infos/pancakeSwapTokens/baseMainnet.ts @@ -0,0 +1,3 @@ +import type { Token } from 'types'; + +export const tokens: Token[] = []; diff --git a/apps/evm/src/libs/tokens/infos/pancakeSwapTokens/baseSepolia.ts b/apps/evm/src/libs/tokens/infos/pancakeSwapTokens/baseSepolia.ts new file mode 100644 index 0000000000..3f6cabc9e4 --- /dev/null +++ b/apps/evm/src/libs/tokens/infos/pancakeSwapTokens/baseSepolia.ts @@ -0,0 +1,3 @@ +import type { Token } from 'types'; + +export const tokens: Token[] = []; diff --git a/apps/evm/src/libs/tokens/infos/pancakeSwapTokens/index.tsx b/apps/evm/src/libs/tokens/infos/pancakeSwapTokens/index.tsx index 3f075fb9fe..7812f078e7 100644 --- a/apps/evm/src/libs/tokens/infos/pancakeSwapTokens/index.tsx +++ b/apps/evm/src/libs/tokens/infos/pancakeSwapTokens/index.tsx @@ -4,6 +4,8 @@ import { ChainId } from 'types'; import { tokens as arbitrumOneTokens } from './arbitrumOne'; import { tokens as arbitrumSepoliaTokens } from './arbitrumSepolia'; +import { tokens as baseMainnetTokens } from './baseMainnet'; +import { tokens as baseSepoliaTokens } from './baseSepolia'; import { tokens as bscTestnetTokens } from './bscTestnet'; import { tokens as ethereumTokens } from './ethereum'; import { tokens as opBnbMainnetTokens } from './opBnbMainnet'; @@ -27,4 +29,6 @@ export const pancakeSwapTokens: TokenMapping = { [ChainId.ZKSYNC_MAINNET]: zkSyncMainnetTokens, [ChainId.OPTIMISM_MAINNET]: optimismMainnetTokens, [ChainId.OPTIMISM_SEPOLIA]: optimismSepoliaTokens, + [ChainId.BASE_MAINNET]: baseMainnetTokens, + [ChainId.BASE_SEPOLIA]: baseSepoliaTokens, }; diff --git a/apps/evm/src/libs/wallet/chains.ts b/apps/evm/src/libs/wallet/chains.ts index f2800a891f..e69a328173 100644 --- a/apps/evm/src/libs/wallet/chains.ts +++ b/apps/evm/src/libs/wallet/chains.ts @@ -3,6 +3,8 @@ import { type Chain, arbitrum as arbitrumOne, arbitrumSepolia, + base, + baseSepolia, bsc as bscMainnet, bscTestnet, mainnet as ethereum, @@ -31,6 +33,8 @@ const chainMapping = { [ChainId.ZKSYNC_SEPOLIA]: zksyncSepoliaTestnet, [ChainId.OPTIMISM_MAINNET]: optimismMainnet, [ChainId.OPTIMISM_SEPOLIA]: optimismSepolia, + [ChainId.BASE_MAINNET]: base, + [ChainId.BASE_SEPOLIA]: baseSepolia, } as const satisfies Record; const getSupportedChains = () => { diff --git a/packages/chains/src/chainMetadata.ts b/packages/chains/src/chainMetadata.ts index 1374cf3366..db71f9ec7c 100644 --- a/packages/chains/src/chainMetadata.ts +++ b/packages/chains/src/chainMetadata.ts @@ -1,4 +1,5 @@ import arbitrumLogo from './img/chains/arbitrum.svg'; +import baseLogo from './img/chains/base.svg'; import bscLogo from './img/chains/bsc.svg'; import ethLogo from './img/chains/eth.svg'; import opbnbLogo from './img/chains/opbnb.svg'; @@ -144,4 +145,21 @@ export const chainMetadata: { corePoolComptrollerContractAddress: '0x59d10988974223B042767aaBFb6D926863069535', nativeToken: ethToken, }, + [ChainId.BASE_MAINNET]: { + name: 'Base', + logoSrc: baseLogo, + explorerUrl: 'https://basescan.org', + layerZeroScanUrl: 'https://testnet.layerzeroscan.com', + // add BASE_MAINNET core comptroller address + corePoolComptrollerContractAddress: '', + nativeToken: ethToken, + }, + [ChainId.BASE_SEPOLIA]: { + name: 'Base Sepolia', + logoSrc: baseLogo, + explorerUrl: 'https://sepolia.basescan.org', + layerZeroScanUrl: 'https://testnet.layerzeroscan.com', + corePoolComptrollerContractAddress: '0x272795dd6c5355CF25765F36043F34014454Eb5b', + nativeToken: ethToken, + }, }; diff --git a/packages/chains/src/img/chains/base.svg b/packages/chains/src/img/chains/base.svg new file mode 100644 index 0000000000..22d89358f6 --- /dev/null +++ b/packages/chains/src/img/chains/base.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/chains/src/types.ts b/packages/chains/src/types.ts index fde6c4e69a..2fa09afb38 100644 --- a/packages/chains/src/types.ts +++ b/packages/chains/src/types.ts @@ -11,6 +11,8 @@ export enum ChainId { ZKSYNC_SEPOLIA = 300, OPTIMISM_MAINNET = 10, OPTIMISM_SEPOLIA = 11155420, + BASE_MAINNET = 8453, + BASE_SEPOLIA = 84532, } export enum MainnetChainId { From c5ba62e9384c8898541851ae67c5645baed5251e Mon Sep 17 00:00:00 2001 From: Gleiser Oliveira Date: Mon, 16 Dec 2024 12:32:36 -0600 Subject: [PATCH 2/3] chore: add changeset --- .changeset/soft-peas-argue.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/soft-peas-argue.md diff --git a/.changeset/soft-peas-argue.md b/.changeset/soft-peas-argue.md new file mode 100644 index 0000000000..4d28ede8ec --- /dev/null +++ b/.changeset/soft-peas-argue.md @@ -0,0 +1,5 @@ +--- +"@venusprotocol/evm": minor +--- + +add Base network metadata From c3cb6b1457360928d1b691e07d167f8302ad7ad6 Mon Sep 17 00:00:00 2001 From: Gleiser Oliveira Date: Mon, 16 Dec 2024 13:03:28 -0600 Subject: [PATCH 3/3] test: update user settings snapshot --- .../__tests__/__snapshots__/index.spec.ts.snap | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/apps/evm/src/store/__tests__/__snapshots__/index.spec.ts.snap b/apps/evm/src/store/__tests__/__snapshots__/index.spec.ts.snap index 9178fbe365..a7a72bc5bd 100644 --- a/apps/evm/src/store/__tests__/__snapshots__/index.spec.ts.snap +++ b/apps/evm/src/store/__tests__/__snapshots__/index.spec.ts.snap @@ -35,6 +35,12 @@ exports[`store > setUserSettings > updates user settings correctly 1`] = ` "5611": { "gaslessTransactions": false, }, + "8453": { + "gaslessTransactions": false, + }, + "84532": { + "gaslessTransactions": false, + }, "97": { "gaslessTransactions": false, }, @@ -76,6 +82,12 @@ exports[`store > setUserSettings > updates user settings correctly when passing "5611": { "gaslessTransactions": true, }, + "8453": { + "gaslessTransactions": true, + }, + "84532": { + "gaslessTransactions": true, + }, "97": { "gaslessTransactions": false, }, @@ -117,6 +129,12 @@ exports[`store > userSettings > sets correct initial user settings 1`] = ` "5611": { "gaslessTransactions": true, }, + "8453": { + "gaslessTransactions": true, + }, + "84532": { + "gaslessTransactions": true, + }, "97": { "gaslessTransactions": true, },