From 485a8697a1ee6b3157a6f01a5498c606ada03b31 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Wed, 27 Mar 2024 23:12:05 +0900 Subject: [PATCH] feat: Add Sepolia support (#135) --- data/addresses.mainnet.json | 9 +- data/addresses.testnet.json | 187 ++++++++++++++++++----------------- lib/types.ts | 5 +- package.json | 3 +- tasks/addresses.testnet.json | 35 +++---- tasks/addresses.ts | 19 +++- yarn.lock | 8 +- 7 files changed, 137 insertions(+), 129 deletions(-) diff --git a/data/addresses.mainnet.json b/data/addresses.mainnet.json index e05e4dff..ef880a3e 100644 --- a/data/addresses.mainnet.json +++ b/data/addresses.mainnet.json @@ -56,7 +56,7 @@ "type": "uniswapV2Router02" }, { - "address": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", + "address": "0x1F98431c8aD98523631AE4a59f267346ea31F984", "category": "messaging", "chain_id": 1, "chain_name": "eth_mainnet", @@ -174,13 +174,6 @@ "chain_name": "zeta_mainnet", "type": "uniswapV2Router02" }, - { - "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", - "category": "messaging", - "chain_id": 7000, - "chain_name": "zeta_mainnet", - "type": "uniswapV3Factory" - }, { "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "category": "omnichain", diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json index 132b2965..67ac2690 100644 --- a/data/addresses.testnet.json +++ b/data/addresses.testnet.json @@ -1,88 +1,4 @@ [ - { - "address": "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea", - "category": "messaging", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "connector" - }, - { - "address": "0x000047f11c6e42293f433c82473532e869ce4ec5", - "category": "omnichain", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "erc20Custody" - }, - { - "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", - "category": "messaging", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "pauser" - }, - { - "address": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e", - "category": "omnichain", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "tss" - }, - { - "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", - "category": "omnichain", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "tssUpdater" - }, - { - "address": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", - "category": "messaging", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "uniswapV2Factory" - }, - { - "address": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", - "category": "messaging", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "uniswapV2Router02" - }, - { - "address": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", - "category": "messaging", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "uniswapV3Factory" - }, - { - "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", - "category": "messaging", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "uniswapV3Router" - }, - { - "address": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", - "category": "messaging", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "weth9" - }, - { - "address": "0x0000c304d2934c00db1d51995b9f6996affd17c0", - "category": "messaging", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "zetaToken" - }, - { - "address": "0x8eAc517b92eeE82177a83851268F13109878f8c4", - "category": "messaging", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "zetaTokenConsumerUniV2" - }, { "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", "category": "messaging", @@ -133,7 +49,7 @@ "type": "uniswapV2Router02" }, { - "address": "0xB7926C0430Afb07AA7DEfDE6DA862aE0Bde767bc", + "address": "0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865", "category": "messaging", "chain_id": 97, "chain_name": "bsc_testnet", @@ -210,18 +126,24 @@ "type": "uniswapV2Router02" }, { - "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", - "category": "messaging", + "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", + "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "type": "uniswapV3Factory" + "type": "zetaToken" }, { - "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", + "address": "0x05BA149A7bd6dC1F937fA9046A9e05C05f3b18b0", + "asset": "", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "type": "zetaToken" + "coin_type": "gas", + "decimals": 18, + "description": "ZetaChain ZRC20 sETH-sepolia_testnet", + "foreign_chain_id": "11155111", + "symbol": "sETH.SEPOLIA", + "type": "zrc20" }, { "address": "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a", @@ -301,6 +223,19 @@ "symbol": "USDC", "type": "zrc20" }, + { + "address": "0xcC683A782f4B30c138787CB5576a86AF66fdc31d", + "asset": "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238", + "category": "omnichain", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "coin_type": "erc20", + "decimals": 18, + "description": "ZetaChain ZRC20 USDC on SEPOLIA", + "foreign_chain_id": "11155111", + "symbol": "USDC.SEPOLIA", + "type": "zrc20" + }, { "address": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891", "asset": "", @@ -371,7 +306,7 @@ "type": "uniswapV2Router02" }, { - "address": "0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32", + "address": "0x1F98431c8aD98523631AE4a59f267346ea31F984", "category": "messaging", "chain_id": 80001, "chain_name": "mumbai_testnet", @@ -404,5 +339,75 @@ "chain_id": 80001, "chain_name": "mumbai_testnet", "type": "zetaTokenConsumerUniV3" + }, + { + "address": "0x3963341dad121c9CD33046089395D66eBF20Fb03", + "category": "messaging", + "chain_id": 11155111, + "chain_name": "sepolia_testnet", + "type": "connector" + }, + { + "address": "0x84725b70a239d3Faa7C6EF0C6C8E8b6c8e28338b", + "category": "omnichain", + "chain_id": 11155111, + "chain_name": "sepolia_testnet", + "type": "erc20Custody" + }, + { + "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "category": "messaging", + "chain_id": 11155111, + "chain_name": "sepolia_testnet", + "type": "pauser" + }, + { + "address": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e", + "category": "omnichain", + "chain_id": 11155111, + "chain_name": "sepolia_testnet", + "type": "tss" + }, + { + "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "category": "omnichain", + "chain_id": 11155111, + "chain_name": "sepolia_testnet", + "type": "tssUpdater" + }, + { + "address": "0x0227628f3F023bb0B980b67D528571c95c6DaC1c", + "category": "messaging", + "chain_id": 11155111, + "chain_name": "sepolia_testnet", + "type": "uniswapV3Factory" + }, + { + "address": "0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E", + "category": "messaging", + "chain_id": 11155111, + "chain_name": "sepolia_testnet", + "type": "uniswapV3Router" + }, + { + "address": "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14", + "category": "messaging", + "chain_id": 11155111, + "chain_name": "sepolia_testnet", + "type": "weth9" + }, + { + "address": "0x0000c304D2934c00Db1d51995b9f6996AffD17c0", + "category": "messaging", + "chain_id": 11155111, + "chain_name": "sepolia_testnet", + "type": "zetaToken" + }, + { + "address": "0x301ED39771d8f1dD0b05F8C2D4327ce9C426E783", + "category": "messaging", + "chain_id": 11155111, + "chain_name": "sepolia_testnet", + "type": "zetaTokenConsumerUniV3" } ] diff --git a/lib/types.ts b/lib/types.ts index 6dbc5594..28738b51 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -3,11 +3,13 @@ export type ParamSymbol = | "BTC.BTC" | "ETH.ETH" | "gETH" + | "sETH.SEPOLIA" | "tBNB" | "tBTC" | "tMATIC" | "USDC.BSC" | "USDC.ETH" + | "USDC.SEPOLIA" | "USDC" | "USDT.BSC" | "USDT.ETH"; @@ -17,8 +19,8 @@ export type ParamChainName = | "btc_mainnet" | "btc_testnet" | "eth_mainnet" - | "goerli_testnet" | "mumbai_testnet" + | "sepolia_testnet" | "zeta_mainnet" | "zeta_testnet"; export type ParamType = @@ -35,6 +37,5 @@ export type ParamType = | "uniswapV3Router" | "weth9" | "zetaToken" - | "zetaTokenConsumerUniV2" | "zetaTokenConsumerUniV3" | "zrc20"; diff --git a/package.json b/package.json index 83fd2a42..8f3d95cd 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@uniswap/v2-core": "^1.0.1", "@uniswap/v2-periphery": "^1.1.0-beta.0", "@uniswap/v3-periphery": "^1.4.3", - "@zetachain/networks": "4.0.0-rc1", + "@zetachain/networks": "6.0.0", "axios": "^1.6.5", "chai": "^4.3.6", "cpx": "^1.5.0", @@ -46,6 +46,7 @@ "hardhat-abi-exporter": "^2.10.1", "hardhat-gas-reporter": "^1.0.9", "inquirer": "^8.2.4", + "lodash": "^4.17.21", "mocha": "^10.2.0", "solidity-coverage": "^0.8.2", "ts-mocha": "^10.0.0", diff --git a/tasks/addresses.testnet.json b/tasks/addresses.testnet.json index 7793f0c8..a161fc67 100644 --- a/tasks/addresses.testnet.json +++ b/tasks/addresses.testnet.json @@ -1,11 +1,4 @@ [ - { - "address": "0x8eAc517b92eeE82177a83851268F13109878f8c4", - "category": "messaging", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "zetaTokenConsumerUniV2" - }, { "address": "0x7e792f3736751e168864106AdbAC50152641A927", "category": "messaging", @@ -20,6 +13,13 @@ "chain_name": "bsc_testnet", "type": "zetaTokenConsumerUniV3" }, + { + "address": "0x301ED39771d8f1dD0b05F8C2D4327ce9C426E783", + "category": "messaging", + "chain_id": 11155111, + "chain_name": "sepolia_testnet", + "type": "zetaTokenConsumerUniV3" + }, { "address": "0x8954AfA98594b838bda56FE4C12a09D7739D179b", "category": "messaging", @@ -34,6 +34,13 @@ "chain_name": "mumbai_testnet", "type": "uniswapV3Router" }, + { + "address": "0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E", + "category": "messaging", + "chain_id": 11155111, + "chain_name": "sepolia_testnet", + "type": "uniswapV3Router" + }, { "address": "0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3", "category": "messaging", @@ -47,19 +54,5 @@ "chain_id": 97, "chain_name": "bsc_testnet", "type": "uniswapV3Router" - }, - { - "address": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", - "category": "messaging", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "uniswapV2Router02" - }, - { - "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", - "category": "messaging", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "uniswapV3Router" } ] diff --git a/tasks/addresses.ts b/tasks/addresses.ts index 5aa236f0..fc14f22d 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -1,8 +1,10 @@ import uniswapV2Router from "@uniswap/v2-periphery/build/IUniswapV2Router02.json"; +import SwapRouter from "@uniswap/v3-periphery/artifacts/contracts/SwapRouter.sol/SwapRouter.json"; import { getEndpoints } from "@zetachain/networks"; import axios, { AxiosResponse } from "axios"; import { task } from "hardhat/config"; import { HardhatRuntimeEnvironment } from "hardhat/types"; +import { isEqual } from "lodash"; import { ZetaConnectorBase__factory } from "../typechain-types"; import { ERC20Custody__factory } from "../typechain-types/factories/contracts/evm/ERC20Custody__factory"; @@ -283,16 +285,29 @@ const fetchFactoryV2 = async (addresses: any, hre: HardhatRuntimeEnvironment, ne }; const fetchFactoryV3 = async (addresses: any, hre: HardhatRuntimeEnvironment, network: Network) => { - const routers = addresses.filter((a: any) => a.type === "uniswapV2Router02"); + const routers = addresses.filter((a: any) => a.type === "uniswapV3Router"); for (const router of routers) { const rpc = getEndpoints("evm", router.chain_name)[0]?.url; const provider = new hre.ethers.providers.JsonRpcProvider(rpc); - const routerContract = new hre.ethers.Contract(router.address, uniswapV2Router.abi, provider); + const routerContract = new hre.ethers.Contract(router.address, SwapRouter.abi, provider); try { + const wethAddress = await routerContract.WETH9(); const factoryAddress = await routerContract.factory(); + const wethObj = { + address: wethAddress, + category: "messaging", + chain_id: router.chain_id, + chain_name: router.chain_name, + type: "weth9", + }; + + if (!addresses.some((e: any) => isEqual(e, wethObj))) { + addresses.push(wethObj); + } + addresses.push({ address: factoryAddress, category: "messaging", diff --git a/yarn.lock b/yarn.lock index 62ba3eb5..a7173b15 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2078,10 +2078,10 @@ "@uniswap/v3-core" "1.0.0" base64-sol "1.0.1" -"@zetachain/networks@4.0.0-rc1": - version "4.0.0-rc1" - resolved "https://registry.yarnpkg.com/@zetachain/networks/-/networks-4.0.0-rc1.tgz#0ec6efabaa78d7124f5adb9218f25d85e252087b" - integrity sha512-Zl8cZc5PdKI46KZqPeIu7DmpSqUkXN07L9Yxy/Lp233L9pZKWUVr7RnEq2HUaN9F6gqtxlofNtKBFopphm1pEQ== +"@zetachain/networks@6.0.0": + version "6.0.0" + resolved "https://registry.yarnpkg.com/@zetachain/networks/-/networks-6.0.0.tgz#ae5d3cd1678b32510edfaa71f8f4a6f4cbc1d9ab" + integrity sha512-yKFVP/yJDp76Q5lBGfZSpY/KO3TZ9ldo0lhE4MpBW43EsBxOZWixg6sqb56mcU/gg1lbWG8sHHWtYFK51SByjQ== dependencies: dotenv "^16.1.4"