diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json index f0c48fcb..79484392 100644 --- a/data/addresses.testnet.json +++ b/data/addresses.testnet.json @@ -256,48 +256,6 @@ "chain_name": "btc_testnet", "type": "tss" }, - { - "address": "0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32", - "category": "messaging", - "chain_id": 80001, - "chain_name": "mumbai_testnet", - "type": "uniswapV2Factory" - }, - { - "address": "0x8954AfA98594b838bda56FE4C12a09D7739D179b", - "category": "messaging", - "chain_id": 80001, - "chain_name": "mumbai_testnet", - "type": "uniswapV2Router02" - }, - { - "address": "0x1F98431c8aD98523631AE4a59f267346ea31F984", - "category": "messaging", - "chain_id": 80001, - "chain_name": "mumbai_testnet", - "type": "uniswapV3Factory" - }, - { - "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", - "category": "messaging", - "chain_id": 80001, - "chain_name": "mumbai_testnet", - "type": "uniswapV3Router" - }, - { - "address": "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889", - "category": "messaging", - "chain_id": 80001, - "chain_name": "mumbai_testnet", - "type": "weth9" - }, - { - "address": "0x7e792f3736751e168864106AdbAC50152641A927", - "category": "messaging", - "chain_id": 80001, - "chain_name": "mumbai_testnet", - "type": "zetaTokenConsumerUniV3" - }, { "address": "0x3963341dad121c9CD33046089395D66eBF20Fb03", "category": "messaging", diff --git a/hardhat.config.ts b/hardhat.config.ts index d213ab3f..f9a48e09 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -17,13 +17,26 @@ const config: HardhatUserConfig = { //@ts-ignore etherscan: { apiKey: { + amoy_testnet: process.env.POLYGONSCAN_API_KEY || "", // BSC bsc: process.env.BSCSCAN_API_KEY || "", + bscTestnet: process.env.BSCSCAN_API_KEY || "", // ETH goerli: process.env.ETHERSCAN_API_KEY || "", mainnet: process.env.ETHERSCAN_API_KEY || "", }, + //@ts-ignore + customChains: [ + { + chainId: 80002, + network: "amoy_testnet", + urls: { + apiURL: "https://api-amoy.polygonscan.com/api", + browserURL: "https://amoy.polygonscan.com", + }, + }, + ], }, networks: { ...getHardhatConfigNetworks(), diff --git a/lib/address.tools.ts b/lib/address.tools.ts index 8d8aabe0..ccf0d8a5 100644 --- a/lib/address.tools.ts +++ b/lib/address.tools.ts @@ -31,6 +31,7 @@ export declare type ZetaZEVMAddress = | "zrc20"; export declare type ZetaProtocolTestNetwork = + | "amoy_testnet" | "baobab_testnet" | "bsc_testnet" | "btc_testnet" @@ -47,6 +48,7 @@ export const zetaProtocolTestNetworks: ZetaProtocolTestNetwork[] = [ "sepolia_testnet", "mumbai_testnet", "zeta_testnet", + "amoy_testnet", ]; export declare type NonZetaAddress = @@ -83,14 +85,6 @@ export const isMainnetNetwork = (network: ZetaProtocolTestNetwork): boolean => { return false; }; -// export const getAddress = (address: ZetaProtocolAddress | ZetaZEVMAddress, network: ZetaProtocolNetwork): string => { -// if (isZetaProtocolAddress(address)) { -// return (addresses["ccm"] as any)[network][address]; -// } - -// return (addresses["zevm"] as any)[network][address]; -// }; - export const getZRC20Address = (network: ZetaProtocolNetwork): string => { return (addresses["zevm"] as any)[network]["zrc20"]; }; diff --git a/lib/contracts.helpers.ts b/lib/contracts.helpers.ts index e215e005..f1ded15e 100644 --- a/lib/contracts.helpers.ts +++ b/lib/contracts.helpers.ts @@ -1,4 +1,6 @@ import { + ERC20Custody, + ERC20Custody__factory as ERC20CustodyFactory, ImmutableCreate2Factory, ImmutableCreate2Factory__factory, ZetaConnectorBase, @@ -63,6 +65,16 @@ export const deployZetaConnectorNonEth = async ({ return zetaConnectorContract; }; +export const deployERC20Custody = async ({ args }: { args: Parameters }) => { + const Factory = (await ethers.getContractFactory("ERC20Custody")) as ERC20CustodyFactory; + + const ERC20CustodyContract = (await Factory.deploy(...args)) as ERC20Custody; + + await ERC20CustodyContract.deployed(); + + return ERC20CustodyContract; +}; + export const deployZetaReceiverMock = async () => { const Factory = (await ethers.getContractFactory("ZetaReceiverMock")) as ZetaReceiverMockFactory; diff --git a/lib/types.ts b/lib/types.ts index 28738b51..5d2b5423 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -19,7 +19,6 @@ export type ParamChainName = | "btc_mainnet" | "btc_testnet" | "eth_mainnet" - | "mumbai_testnet" | "sepolia_testnet" | "zeta_mainnet" | "zeta_testnet"; diff --git a/package.json b/package.json index dc382d1c..9a069fac 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": "6.0.0", + "@zetachain/networks": "8.0.0-rc1", "axios": "^1.6.5", "chai": "^4.3.6", "cpx": "^1.5.0", diff --git a/scripts/deployments/core/deploy-deterministic.ts b/scripts/deployments/core/deploy-deterministic.ts new file mode 100644 index 00000000..eb3bc268 --- /dev/null +++ b/scripts/deployments/core/deploy-deterministic.ts @@ -0,0 +1,23 @@ +import { network } from "hardhat"; + +import { isProtocolNetworkName } from "../../../lib/address.tools"; +import { deterministicDeployERC20Custody } from "./deterministic-deploy-erc20-custody"; +import { deterministicDeployZetaConnector } from "./deterministic-deploy-zeta-connector"; +import { deterministicDeployZetaToken } from "./deterministic-deploy-zeta-token"; + +const networkName = network.name; + +async function main() { + if (!isProtocolNetworkName(networkName)) throw new Error("Invalid network name"); + + await deterministicDeployZetaToken(); + await deterministicDeployZetaConnector(); + await deterministicDeployERC20Custody(); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/scripts/deployments/core/deploy-erc20-custody.ts b/scripts/deployments/core/deploy-erc20-custody.ts new file mode 100644 index 00000000..da0df5fd --- /dev/null +++ b/scripts/deployments/core/deploy-erc20-custody.ts @@ -0,0 +1,36 @@ +import { Contract } from "ethers"; +import { ethers, network } from "hardhat"; +import { getAddress, isProtocolNetworkName } from "lib"; + +import { ERC20_CUSTODY_ZETA_FEE, ERC20_CUSTODY_ZETA_MAX_FEE } from "../../../lib/contracts.constants"; +import { deployERC20Custody as deployERC20CustodyHelper } from "../../../lib/contracts.helpers"; + +export async function deployERC20Custody(zetaTokenAddress: string) { + if (!isProtocolNetworkName(network.name)) { + throw new Error(`network.name: ${network.name} isn't supported.`); + } + const accounts = await ethers.getSigners(); + const [signer] = accounts; + const initialBalance = await signer.getBalance(); + + const tssAddress = getAddress("tss", network.name); + const tssUpdaterAddress = getAddress("tssUpdater", network.name); + + const zetaFee = ERC20_CUSTODY_ZETA_FEE; + const zetaMaxFee = ERC20_CUSTODY_ZETA_MAX_FEE; + + let contract: Contract; + console.log(`Deploying ERC20Custody to ${network.name}`); + + const constructorArgs = [tssAddress, tssUpdaterAddress, zetaFee.toString(), zetaMaxFee.toString(), zetaTokenAddress]; + contract = await deployERC20CustodyHelper({ + args: constructorArgs, + }); + + const finalBalance = await signer.getBalance(); + console.log("Deployed ERC20Custody. Address:", contract.address); + console.log("Constructor Args", constructorArgs); + console.log("ETH spent:", initialBalance.sub(finalBalance).toString()); + + return contract.address; +} diff --git a/scripts/deployments/core/deploy-zeta-connector.ts b/scripts/deployments/core/deploy-zeta-connector.ts index 8d27b507..dd3555a5 100644 --- a/scripts/deployments/core/deploy-zeta-connector.ts +++ b/scripts/deployments/core/deploy-zeta-connector.ts @@ -1,31 +1,37 @@ import { Contract } from "ethers"; -import { network } from "hardhat"; -import { getAddress, isProtocolNetworkName } from "lib/address.tools"; +import { ethers, network } from "hardhat"; +import { getAddress, isProtocolNetworkName } from "lib"; import { deployZetaConnectorEth, deployZetaConnectorNonEth, isEthNetworkName } from "../../../lib/contracts.helpers"; -export async function deployZetaConnector() { +export async function deployZetaConnector(zetaTokenAddress: string) { if (!isProtocolNetworkName(network.name)) { throw new Error(`network.name: ${network.name} isn't supported.`); } + const accounts = await ethers.getSigners(); + const [signer] = accounts; + const initialBalance = await signer.getBalance(); - const zetaTokenAddress = getAddress("zetaToken", network.name); const tssAddress = getAddress("tss", network.name); const tssUpdaterAddress = getAddress("tssUpdater", network.name); + const constructorArgs = [zetaTokenAddress, tssAddress, tssUpdaterAddress, tssUpdaterAddress]; let contract: Contract; console.log(`Deploying ZetaConnector to ${network.name}`); if (isEthNetworkName(network.name)) { contract = await deployZetaConnectorEth({ - args: [zetaTokenAddress, tssAddress, tssUpdaterAddress, tssUpdaterAddress], + args: constructorArgs, }); } else { contract = await deployZetaConnectorNonEth({ - args: [zetaTokenAddress, tssAddress, tssUpdaterAddress, tssUpdaterAddress], + args: constructorArgs, }); } + const finalBalance = await signer.getBalance(); console.log("Deployed ZetaConnector. Address:", contract.address); + console.log("Constructor Args", constructorArgs); + console.log("ETH spent:", initialBalance.sub(finalBalance).toString()); return contract.address; } diff --git a/scripts/deployments/core/deploy-zeta-token.ts b/scripts/deployments/core/deploy-zeta-token.ts index fbb974c2..b5aee77b 100644 --- a/scripts/deployments/core/deploy-zeta-token.ts +++ b/scripts/deployments/core/deploy-zeta-token.ts @@ -12,6 +12,7 @@ export async function deployZetaToken() { const accounts = await ethers.getSigners(); const [signer] = accounts; + const initialBalance = await signer.getBalance(); const DEPLOYER_ADDRESS = process.env.DEPLOYER_ADDRESS || signer.address; @@ -19,17 +20,24 @@ export async function deployZetaToken() { const tssUpdaterAddress = getAddress("tssUpdater", network.name); let contract: Contract; + let constructorArgs: any; + console.log(`Deploying ZetaToken to ${network.name}`); if (isEthNetworkName(network.name)) { + constructorArgs = [DEPLOYER_ADDRESS, ZETA_INITIAL_SUPPLY]; contract = await deployZetaEth({ - args: [DEPLOYER_ADDRESS, ZETA_INITIAL_SUPPLY], + args: constructorArgs, }); } else { + constructorArgs = [tssAddress, tssUpdaterAddress]; contract = await deployZetaNonEth({ - args: [tssAddress, tssUpdaterAddress], + args: constructorArgs, }); } - console.log("Deployed Zeta to:", contract.address); + const finalBalance = await signer.getBalance(); + console.log("Deployed ZetaToken. Address:", contract.address); + console.log("Constructor Args", constructorArgs); + console.log("ETH spent:", initialBalance.sub(finalBalance).toString()); return contract.address; } diff --git a/scripts/deployments/core/deploy.ts b/scripts/deployments/core/deploy.ts index eb3bc268..4d0736f0 100644 --- a/scripts/deployments/core/deploy.ts +++ b/scripts/deployments/core/deploy.ts @@ -1,18 +1,18 @@ import { network } from "hardhat"; import { isProtocolNetworkName } from "../../../lib/address.tools"; -import { deterministicDeployERC20Custody } from "./deterministic-deploy-erc20-custody"; -import { deterministicDeployZetaConnector } from "./deterministic-deploy-zeta-connector"; -import { deterministicDeployZetaToken } from "./deterministic-deploy-zeta-token"; +import { deployERC20Custody } from "./deploy-erc20-custody"; +import { deployZetaConnector } from "./deploy-zeta-connector"; +import { deployZetaToken } from "./deploy-zeta-token"; const networkName = network.name; async function main() { if (!isProtocolNetworkName(networkName)) throw new Error("Invalid network name"); - await deterministicDeployZetaToken(); - await deterministicDeployZetaConnector(); - await deterministicDeployERC20Custody(); + const zetaTokenAddress = await deployZetaToken(); + await deployZetaConnector(zetaTokenAddress); + await deployERC20Custody(zetaTokenAddress); } main() diff --git a/tasks/addresses.testnet.json b/tasks/addresses.testnet.json index 9eec198e..be6c8c8a 100644 --- a/tasks/addresses.testnet.json +++ b/tasks/addresses.testnet.json @@ -1,11 +1,4 @@ [ - { - "address": "0x7e792f3736751e168864106AdbAC50152641A927", - "category": "messaging", - "chain_id": 80001, - "chain_name": "mumbai_testnet", - "type": "zetaTokenConsumerUniV3" - }, { "address": "0xFB2fCE3CCca19F0f764Ed8aa26C62181E3dA04C5", "category": "messaging", @@ -27,20 +20,6 @@ "chain_name": "zeta_testnet", "type": "zetaTokenConsumerUniV3" }, - { - "address": "0x8954AfA98594b838bda56FE4C12a09D7739D179b", - "category": "messaging", - "chain_id": 80001, - "chain_name": "mumbai_testnet", - "type": "uniswapV2Router02" - }, - { - "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", - "category": "messaging", - "chain_id": 80001, - "chain_name": "mumbai_testnet", - "type": "uniswapV3Router" - }, { "address": "0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E", "category": "messaging", diff --git a/yarn.lock b/yarn.lock index ff02271f..2915388b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2164,10 +2164,10 @@ "@uniswap/v3-core" "1.0.0" base64-sol "1.0.1" -"@zetachain/networks@6.0.0": - version "6.0.0" - resolved "https://registry.npmjs.org/@zetachain/networks/-/networks-6.0.0.tgz" - integrity sha512-yKFVP/yJDp76Q5lBGfZSpY/KO3TZ9ldo0lhE4MpBW43EsBxOZWixg6sqb56mcU/gg1lbWG8sHHWtYFK51SByjQ== +"@zetachain/networks@8.0.0-rc1": + version "8.0.0-rc1" + resolved "https://registry.yarnpkg.com/@zetachain/networks/-/networks-8.0.0-rc1.tgz#3ad8891a7e2120509ef560720c6fa573a0a0b73f" + integrity sha512-rw09aariRcNItoNYClHq6Gm2IUNoBOFHOO3VHNyN7krapbY0Jy4HCQQj8iq7oNWZyNfwDIxIqkiQURPvIfpsMw== dependencies: dotenv "^16.1.4"