diff --git a/data/addresses.json b/data/addresses.json index 62f6d48b..a65554c6 100644 --- a/data/addresses.json +++ b/data/addresses.json @@ -9,6 +9,14 @@ "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "" }, + "bsc_mainnet": { + "connector": "", + "erc20Custody": "", + "immutableCreate2Factory": "0x095a03c6a68137fE9a566bBc3e552F299d8b886d", + "tss": "", + "tssUpdater": "", + "zetaToken": "" + }, "bsc_testnet": { "connector": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", "erc20Custody": "0x0000a7db254145767262c6a81a7ee1650684258e", @@ -28,7 +36,7 @@ "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "" }, - "ethereum_mainnet": { + "eth_mainnet": { "connector": "", "erc20Custody": "", "immutableCreate2Factory": "0x095a03c6a68137fE9a566bBc3e552F299d8b886d", @@ -73,13 +81,19 @@ "uniswapV3Router": "", "weth9": "" }, + "bsc_mainnet": { + "uniswapV2Router02": "", + "uniswapV3Factory": "", + "uniswapV3Router": "", + "weth9": "" + }, "bsc_testnet": { "uniswapV2Router02": "0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3", "uniswapV3Factory": "0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865", "uniswapV3Router": "0x9a489505a00cE272eAa5e07Dba6491314CaE3796", "weth9": "" }, - "ethereum_mainnet": { + "eth_mainnet": { "uniswapV2Router02": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", "uniswapV3Factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984", "uniswapV3Router": "0xE592427A0AEce92De3Edee1F18E0157C05861564", diff --git a/hardhat.config.ts b/hardhat.config.ts index 0486ed84..8ad93e86 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -10,11 +10,19 @@ import type { HardhatUserConfig } from "hardhat/types"; dotenv.config(); -const PRIVATE_KEYS = process.env.PRIVATE_KEY !== undefined ? [`0x${process.env.PRIVATE_KEY}`] : []; - const config: HardhatUserConfig = { + //@ts-ignore + etherscan: { + apiKey: { + // BSC + bscTestnet: process.env.BSCSCAN_API_KEY || "", + // ETH + goerli: process.env.ETHERSCAN_API_KEY || "", + mainnet: process.env.ETHERSCAN_API_KEY || "", + }, + }, networks: { - ...getHardhatConfigNetworks(PRIVATE_KEYS), + ...getHardhatConfigNetworks(), hardhat: { chainId: 1337, forking: { diff --git a/lib/address.helpers.ts b/lib/address.helpers.ts index 336471d9..420f4011 100644 --- a/lib/address.helpers.ts +++ b/lib/address.helpers.ts @@ -9,8 +9,9 @@ const MissingZetaNetworkError = new Error( export const ProtocolNetworkNetworkNameMap: Record = { baobab_testnet: "klaytn-baobab", + bsc_mainnet: "bsc-mainnet", bsc_testnet: "bsc-testnet", - ethereum_mainnet: "eth-mainnet", + eth_mainnet: "eth-mainnet", goerli_testnet: "goerli", mumbai_testnet: "polygon-mumbai", zeta_testnet: "athens", diff --git a/lib/address.tools.ts b/lib/address.tools.ts index 3a2c952c..22b68d00 100644 --- a/lib/address.tools.ts +++ b/lib/address.tools.ts @@ -49,8 +49,8 @@ export declare type NonZetaAddress = "uniswapV2Router02" | "uniswapV3Factory" | export const nonZetaAddress: NonZetaAddress[] = ["uniswapV2Router02", "uniswapV3Router", "uniswapV3Factory", "weth9"]; -export declare type ZetaProtocolMainNetwork = "ethereum_mainnet"; -export const zetaProtocolMainNetworks: ZetaProtocolMainNetwork[] = ["ethereum_mainnet"]; +export declare type ZetaProtocolMainNetwork = "bsc_mainnet" | "eth_mainnet"; +export const zetaProtocolMainNetworks: ZetaProtocolMainNetwork[] = ["eth_mainnet", "bsc_mainnet"]; export declare type ZetaProtocolNetwork = ZetaProtocolMainNetwork | ZetaProtocolTestNetwork; export const zetaProtocolNetworks: ZetaProtocolNetwork[] = [...zetaProtocolTestNetworks, ...zetaProtocolMainNetworks]; diff --git a/lib/contracts.helpers.ts b/lib/contracts.helpers.ts index d71337c1..565d5a78 100644 --- a/lib/contracts.helpers.ts +++ b/lib/contracts.helpers.ts @@ -24,7 +24,10 @@ import { BaseContract, ContractFactory } from "ethers"; import { ethers } from "hardhat"; export const isEthNetworkName = (networkName: string) => - networkName === "eth-localnet" || networkName === "goerli_testnet" || networkName === "ethereum_mainnet"; + networkName === "eth-localnet" || + networkName === "goerli_testnet" || + networkName === "eth_mainnet" || + networkName === "bsc_mainnet"; export const deployZetaConnectorBase = async ({ args }: { args: Parameters }) => { const Factory = (await ethers.getContractFactory("ZetaConnectorBase")) as ZetaConnectorBaseFactory; diff --git a/package.json b/package.json index fa51346a..c26a08c9 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ "@uniswap/v2-core": "^1.0.1", "@uniswap/v2-periphery": "^1.1.0-beta.0", "@uniswap/v3-periphery": "^1.4.3", - "@zetachain/addresses": "^0.0.9", - "@zetachain/networks": "^2.4.2", + "@zetachain/addresses": "^0.0.13", + "@zetachain/networks": "^2.4.3", "chai": "^4.3.6", "cpx": "^1.5.0", "del-cli": "^5.0.0", @@ -80,4 +80,4 @@ }, "types": "./dist/lib/index.d.ts", "version": "0.0.8" -} +} \ No newline at end of file diff --git a/test/ZetaTokenConsumer.spec.ts b/test/ZetaTokenConsumer.spec.ts index 77f85b36..1b592e4b 100644 --- a/test/ZetaTokenConsumer.spec.ts +++ b/test/ZetaTokenConsumer.spec.ts @@ -4,9 +4,6 @@ import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; import { IERC20, IERC20__factory, - INonfungiblePositionManager, - INonfungiblePositionManager__factory, - IPoolInitializer__factory, UniswapV2Router02__factory, ZetaTokenConsumer, ZetaTokenConsumerUniV2, @@ -57,64 +54,6 @@ describe("ZetaTokenConsumer tests", () => { await tx.wait(); }; - /** - * @todo (andy): WIP, not in use yet - */ - const createPoolV3 = async (signer: SignerWithAddress, tokenAddress: string) => { - const DAI = getExternalAddress("dai", { - customNetworkName: "ethereum_mainnet", - customZetaNetwork: "mainnet", - }); - - const UNI_NFT_MANAGER_V3 = getExternalAddress("uniswapV3NftManager", { - customNetworkName: "ethereum_mainnet", - customZetaNetwork: "mainnet", - }); - - const USDC = getExternalAddress("usdc", { - customNetworkName: "ethereum_mainnet", - customZetaNetwork: "mainnet", - }); - - await swapToken(signer, DAI, parseUnits("10000", 18)); - - const token = IERC20__factory.connect(USDC, signer); - const tx1 = await token.approve(UNI_NFT_MANAGER_V3, MaxUint256); - await tx1.wait(); - - const token2 = IERC20__factory.connect(DAI, signer); - const tx2 = await token2.approve(UNI_NFT_MANAGER_V3, MaxUint256); - await tx2.wait(); - - const uniswapRouter = INonfungiblePositionManager__factory.connect(UNI_NFT_MANAGER_V3, signer); - - const uniswapNFTManager = IPoolInitializer__factory.connect(UNI_NFT_MANAGER_V3, signer); - const tx3 = await uniswapNFTManager.createAndInitializePoolIfNecessary( - USDC, - DAI, - 3000, - "80000000000000000000000000000" - ); - await tx3.wait(); - - const params: INonfungiblePositionManager.MintParamsStruct = { - amount0Desired: parseEther("10"), - amount0Min: 0, - amount1Desired: parseEther("10"), - amount1Min: 0, - deadline: (await getNow()) + 360, - fee: 3000, - recipient: signer.address, - tickLower: 193, - tickUpper: 194, - token0: USDC, - token1: DAI, - }; - - const tx4 = await uniswapRouter.mint(params); - await tx4.wait(); - }; - beforeEach(async () => { accounts = await ethers.getSigners(); [tssUpdater, tssSigner, randomSigner] = accounts; @@ -124,22 +63,22 @@ describe("ZetaTokenConsumer tests", () => { }); const DAI = getExternalAddress("dai", { - customNetworkName: "ethereum_mainnet", + customNetworkName: "eth_mainnet", customZetaNetwork: "mainnet", }); USDCAddr = getExternalAddress("usdc", { - customNetworkName: "ethereum_mainnet", + customNetworkName: "eth_mainnet", customZetaNetwork: "mainnet", }); - uniswapV2RouterAddr = getNonZetaAddress("uniswapV2Router02", "ethereum_mainnet"); + uniswapV2RouterAddr = getNonZetaAddress("uniswapV2Router02", "eth_mainnet"); - const UNI_FACTORY_V3 = getNonZetaAddress("uniswapV3Factory", "ethereum_mainnet"); + const UNI_FACTORY_V3 = getNonZetaAddress("uniswapV3Factory", "eth_mainnet"); - const UNI_ROUTER_V3 = getNonZetaAddress("uniswapV3Router", "ethereum_mainnet"); + const UNI_ROUTER_V3 = getNonZetaAddress("uniswapV3Router", "eth_mainnet"); - const WETH9 = getNonZetaAddress("weth9", "ethereum_mainnet"); + const WETH9 = getNonZetaAddress("weth9", "eth_mainnet"); // For testing purposes we use an existing uni v3 pool await swapToken(tssUpdater, DAI, parseEther("10000")); diff --git a/yarn.lock b/yarn.lock index f09852c4..ecb1b642 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2076,15 +2076,15 @@ "@uniswap/v3-core" "1.0.0" base64-sol "1.0.1" -"@zetachain/addresses@^0.0.9": - version "0.0.9" - resolved "https://registry.yarnpkg.com/@zetachain/addresses/-/addresses-0.0.9.tgz#d8ad93242590c0a6d028be8f515ad9f84fd588c2" - integrity sha512-MA/kD8a2NY5xJMFjwPj1oph6P3O7l0g23QB3QTgcBs4DdmwubvTVH6S6/e8CWzLFojTP5qBiqIWBsU0iHP/HFg== - -"@zetachain/networks@^2.4.2": - version "2.4.2" - resolved "https://registry.yarnpkg.com/@zetachain/networks/-/networks-2.4.2.tgz#611986d2a7cfd45505c2f61cdbc403aeeff14812" - integrity sha512-Md2SbP9YPIbzkbzWa9853/L8tB1DwdPXmN7uPg2KrbxQk5AEqzSh/RuMq8hXaH14CunbiSqXmEuTq0mOtMsfZw== +"@zetachain/addresses@^0.0.13": + version "0.0.13" + resolved "https://registry.yarnpkg.com/@zetachain/addresses/-/addresses-0.0.13.tgz#cbe56d3916e62d36e1d82e15a79404e84ed49176" + integrity sha512-hqCsEH+a3IqYR0cx9tlV0Rwk22i0MUpll81aLynxUkjoKQx5BaO3+5Mp/o62W8ZqYJICVbHPqb28DhmfoNQffg== + +"@zetachain/networks@^2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@zetachain/networks/-/networks-2.4.3.tgz#870b2cda4b91f913be990246831378f60688d452" + integrity sha512-ZoqN8M6+59OkujZCl3FcSEgSftIN1tw5bpuFwI/2+f0SlKH+8ztAk7aF1QHmzrPqolIJKt29ogsfvIjiynXNkg== dependencies: dotenv "^16.1.4"