Skip to content

Commit

Permalink
fix v3 fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Mar 26, 2024
1 parent b6f7d70 commit 4070c9e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 21 deletions.
9 changes: 1 addition & 8 deletions data/addresses.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"type": "uniswapV2Router02"
},
{
"address": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
"address": "0x1F98431c8aD98523631AE4a59f267346ea31F984",
"category": "messaging",
"chain_id": 1,
"chain_name": "eth_mainnet",
Expand Down Expand Up @@ -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",
Expand Down
27 changes: 17 additions & 10 deletions data/addresses.testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"type": "uniswapV2Router02"
},
{
"address": "0xB7926C0430Afb07AA7DEfDE6DA862aE0Bde767bc",
"address": "0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865",
"category": "messaging",
"chain_id": 97,
"chain_name": "bsc_testnet",
Expand Down Expand Up @@ -125,13 +125,6 @@
"chain_name": "zeta_testnet",
"type": "uniswapV2Router02"
},
{
"address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c",
"category": "messaging",
"chain_id": 7001,
"chain_name": "zeta_testnet",
"type": "uniswapV3Factory"
},
{
"address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf",
"category": "omnichain",
Expand Down Expand Up @@ -313,7 +306,7 @@
"type": "uniswapV2Router02"
},
{
"address": "0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32",
"address": "0x1F98431c8aD98523631AE4a59f267346ea31F984",
"category": "messaging",
"chain_id": 80001,
"chain_name": "mumbai_testnet",
Expand Down Expand Up @@ -383,12 +376,26 @@
"type": "tssUpdater"
},
{
"address": "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD",
"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",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tasks/addresses.testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"type": "uniswapV3Router"
},
{
"address": "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD",
"address": "0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E",
"category": "messaging",
"chain_id": 11155111,
"chain_name": "sepolia_testnet",
Expand Down
19 changes: 17 additions & 2 deletions tasks/addresses.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -282,16 +284,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",
Expand Down

0 comments on commit 4070c9e

Please sign in to comment.