From 742221c630e759710ff868e685bd649f8955a2ef Mon Sep 17 00:00:00 2001 From: Andres Aiello Date: Fri, 22 Dec 2023 13:11:12 -0300 Subject: [PATCH 1/4] feat: simplify protocol contracts deployment --- lib/contracts.constants.ts | 68 ++++++++++++++++--- lib/contracts.helpers.ts | 5 +- scripts/deployments/core/deploy.ts | 23 ++----- .../deterministic-deploy-erc20-custody.ts | 11 +-- .../deterministic-deploy-zeta-connector.ts | 11 ++- .../core/deterministic-deploy-zeta-token.ts | 14 ++-- 6 files changed, 80 insertions(+), 52 deletions(-) diff --git a/lib/contracts.constants.ts b/lib/contracts.constants.ts index 1ea515fd..9aba37d5 100644 --- a/lib/contracts.constants.ts +++ b/lib/contracts.constants.ts @@ -5,16 +5,66 @@ export const ZETA_INITIAL_SUPPLY = 2_100_000_000; export const MAX_ETH_ADDRESS = "0xffffffffffffffffffffffffffffffffffffffff"; // dev: this values should be calculated using get-salt script -export const ZETA_TOKEN_SALT_NUMBER_ETH = "84108"; -export const ZETA_TOKEN_SALT_NUMBER_NON_ETH = "29265"; +const SALT_NUMBERS = { + baobab_testnet: { + zetaConnector: "71733", + zetaConsumer: "0", + zetaERC20Custody: "195084", + zetaToken: "29265", + }, + bsc_mainnet: { + zetaConnector: "71733", + zetaConsumer: "0", + zetaERC20Custody: "195084", + zetaToken: "29265", + }, + bsc_testnet: { + zetaConnector: "71733", + zetaConsumer: "0", + zetaERC20Custody: "195084", + zetaToken: "29265", + }, + btc_testnet: { + zetaConnector: "", + zetaConsumer: "", + zetaERC20Custody: "", + zetaToken: "", + }, + eth_mainnet: { + zetaConnector: "1414", + zetaConsumer: "0", + zetaERC20Custody: "87967", + zetaToken: "84108", + }, + goerli_testnet: { + zetaConnector: "1414", + zetaConsumer: "0", + zetaERC20Custody: "87967", + zetaToken: "84108", + }, + mumbai_testnet: { + zetaConnector: "71733", + zetaConsumer: "0", + zetaERC20Custody: "195084", + zetaToken: "29265", + }, + zeta_testnet: { + zetaConnector: "71733", + zetaConsumer: "0", + zetaERC20Custody: "195084", + zetaToken: "29265", + }, +}; -// dev: this values should be calculated using get-salt script -export const ZETA_CONNECTOR_SALT_NUMBER_ETH = "1414"; -export const ZETA_CONNECTOR_SALT_NUMBER_NON_ETH = "71733"; +export const getSaltNumber = (contractName: string, networkName: string) => { + const saltNumber = SALT_NUMBERS[networkName][contractName]; + + if (!saltNumber) { + throw new Error(`Salt number for ${contractName} on ${networkName} is not defined.`); + } + + return saltNumber; +}; -export const ERC20_CUSTODY_SALT_NUMBER_ETH = "87967"; -export const ERC20_CUSTODY_SALT_NUMBER_NON_ETH = "195084"; export const ERC20_CUSTODY_ZETA_FEE = "0"; export const ERC20_CUSTODY_ZETA_MAX_FEE = parseEther("1000"); - -export const ZETA_CONSUMER_SALT_NUMBER = "0"; diff --git a/lib/contracts.helpers.ts b/lib/contracts.helpers.ts index 565d5a78..5508789b 100644 --- a/lib/contracts.helpers.ts +++ b/lib/contracts.helpers.ts @@ -24,10 +24,7 @@ import { BaseContract, ContractFactory } from "ethers"; import { ethers } from "hardhat"; export const isEthNetworkName = (networkName: string) => - networkName === "eth-localnet" || - networkName === "goerli_testnet" || - networkName === "eth_mainnet" || - networkName === "bsc_mainnet"; + networkName === "eth-localnet" || networkName === "goerli_testnet" || networkName === "eth_mainnet"; export const deployZetaConnectorBase = async ({ args }: { args: Parameters }) => { const Factory = (await ethers.getContractFactory("ZetaConnectorBase")) as ZetaConnectorBaseFactory; diff --git a/scripts/deployments/core/deploy.ts b/scripts/deployments/core/deploy.ts index c144016d..eb3bc268 100644 --- a/scripts/deployments/core/deploy.ts +++ b/scripts/deployments/core/deploy.ts @@ -1,29 +1,18 @@ import { network } from "hardhat"; import { isProtocolNetworkName } from "../../../lib/address.tools"; -import { isEthNetworkName } from "../../../lib/contracts.helpers"; -import { setZetaAddresses } from "../../tools/set-zeta-token-addresses"; -import { deployZetaConnector } from "./deploy-zeta-connector"; -import { deployZetaToken } from "./deploy-zeta-token"; +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"); - const zetaTokenAddress = await deployZetaToken(); - const connectorAddress = await deployZetaConnector(); - - /** - * @description The Eth implementation of Zeta token doesn't need any address - */ - if (isEthNetworkName(network.name)) return; - - /** - * @description Avoid setting Zeta addresses for local network, - * since it must be done after starting the local Zeta node - */ - await setZetaAddresses(connectorAddress, zetaTokenAddress); + await deterministicDeployZetaToken(); + await deterministicDeployZetaConnector(); + await deterministicDeployERC20Custody(); } main() diff --git a/scripts/deployments/core/deterministic-deploy-erc20-custody.ts b/scripts/deployments/core/deterministic-deploy-erc20-custody.ts index 75ddef57..c822c11d 100644 --- a/scripts/deployments/core/deterministic-deploy-erc20-custody.ts +++ b/scripts/deployments/core/deterministic-deploy-erc20-custody.ts @@ -2,13 +2,7 @@ import { BigNumber } from "ethers"; import { ethers, network } from "hardhat"; import { getAddress, isProtocolNetworkName } from "lib"; -import { - ERC20_CUSTODY_SALT_NUMBER_ETH, - ERC20_CUSTODY_SALT_NUMBER_NON_ETH, - ERC20_CUSTODY_ZETA_FEE, - ERC20_CUSTODY_ZETA_MAX_FEE, -} from "../../../lib/contracts.constants"; -import { isEthNetworkName } from "../../../lib/contracts.helpers"; +import { ERC20_CUSTODY_ZETA_FEE, ERC20_CUSTODY_ZETA_MAX_FEE, getSaltNumber } from "../../../lib/contracts.constants"; import { deployContractToAddress, saltToHex, @@ -30,7 +24,7 @@ export const deterministicDeployERC20Custody = async () => { const tssUpdaterAddress = getAddress("tssUpdater", network.name); const immutableCreate2FactoryAddress = getAddress("immutableCreate2Factory", network.name); - const saltNumber = isEthNetworkName(network.name) ? ERC20_CUSTODY_SALT_NUMBER_ETH : ERC20_CUSTODY_SALT_NUMBER_NON_ETH; + const saltNumber = getSaltNumber(network.name, "zetaERC20Custody"); const saltStr = BigNumber.from(saltNumber).toHexString(); const zetaFee = ERC20_CUSTODY_ZETA_FEE; @@ -54,6 +48,7 @@ export const deterministicDeployERC20Custody = async () => { console.log("Deployed ERC20 Custody. Address:", address); console.log("Constructor Args", constructorArgs); + return address; }; if (!process.env.EXECUTE_PROGRAMMATICALLY) { diff --git a/scripts/deployments/core/deterministic-deploy-zeta-connector.ts b/scripts/deployments/core/deterministic-deploy-zeta-connector.ts index 7918ef3b..aacab938 100644 --- a/scripts/deployments/core/deterministic-deploy-zeta-connector.ts +++ b/scripts/deployments/core/deterministic-deploy-zeta-connector.ts @@ -2,7 +2,7 @@ import { BigNumber } from "ethers"; import { ethers, network } from "hardhat"; import { getAddress, isProtocolNetworkName } from "lib"; -import { ZETA_CONNECTOR_SALT_NUMBER_ETH, ZETA_CONNECTOR_SALT_NUMBER_NON_ETH } from "../../../lib/contracts.constants"; +import { getSaltNumber } from "../../../lib/contracts.constants"; import { isEthNetworkName } from "../../../lib/contracts.helpers"; import { deployContractToAddress, @@ -10,7 +10,7 @@ import { } from "../../../lib/ImmutableCreate2Factory/ImmutableCreate2Factory.helpers"; import { ZetaConnectorEth__factory, ZetaConnectorNonEth__factory } from "../../../typechain-types"; -export async function deterministicDeployZetaConnector() { +export const deterministicDeployZetaConnector = async () => { if (!isProtocolNetworkName(network.name)) { throw new Error(`network.name: ${network.name} isn't supported.`); } @@ -25,9 +25,7 @@ export async function deterministicDeployZetaConnector() { const tssUpdaterAddress = getAddress("tssUpdater", network.name); const immutableCreate2FactoryAddress = getAddress("immutableCreate2Factory", network.name); - const saltNumber = isEthNetworkName(network.name) - ? ZETA_CONNECTOR_SALT_NUMBER_ETH - : ZETA_CONNECTOR_SALT_NUMBER_NON_ETH; + const saltNumber = getSaltNumber(network.name, "zetaConnector"); const saltStr = BigNumber.from(saltNumber).toHexString(); const salthex = saltToHex(saltStr, DEPLOYER_ADDRESS); @@ -52,7 +50,8 @@ export async function deterministicDeployZetaConnector() { console.log("Deployed ZetaConnector. Address:", address); console.log("Constructor Args", constructorArgs); -} + return address; +}; if (!process.env.EXECUTE_PROGRAMMATICALLY) { deterministicDeployZetaConnector() diff --git a/scripts/deployments/core/deterministic-deploy-zeta-token.ts b/scripts/deployments/core/deterministic-deploy-zeta-token.ts index f55284af..ad6692ef 100644 --- a/scripts/deployments/core/deterministic-deploy-zeta-token.ts +++ b/scripts/deployments/core/deterministic-deploy-zeta-token.ts @@ -2,11 +2,7 @@ import { BigNumber } from "ethers"; import { ethers, network } from "hardhat"; import { getAddress, isProtocolNetworkName } from "lib"; -import { - ZETA_INITIAL_SUPPLY, - ZETA_TOKEN_SALT_NUMBER_ETH, - ZETA_TOKEN_SALT_NUMBER_NON_ETH, -} from "../../../lib/contracts.constants"; +import { getSaltNumber, ZETA_INITIAL_SUPPLY } from "../../../lib/contracts.constants"; import { isEthNetworkName } from "../../../lib/contracts.helpers"; import { deployContractToAddress, @@ -14,7 +10,7 @@ import { } from "../../../lib/ImmutableCreate2Factory/ImmutableCreate2Factory.helpers"; import { ZetaEth__factory, ZetaNonEth__factory } from "../../../typechain-types"; -export async function deterministicDeployZetaToken() { +export const deterministicDeployZetaToken = async () => { if (!isProtocolNetworkName(network.name)) { throw new Error(`network.name: ${network.name} isn't supported.`); } @@ -28,7 +24,7 @@ export async function deterministicDeployZetaToken() { const tssUpdaterAddress = getAddress("tssUpdater", network.name); const immutableCreate2FactoryAddress = getAddress("immutableCreate2Factory", network.name); - const saltNumber = isEthNetworkName(network.name) ? ZETA_TOKEN_SALT_NUMBER_ETH : ZETA_TOKEN_SALT_NUMBER_NON_ETH; + const saltNumber = getSaltNumber(network.name, "zetaToken"); const saltStr = BigNumber.from(saltNumber).toHexString(); const salthex = saltToHex(saltStr, DEPLOYER_ADDRESS); @@ -59,7 +55,9 @@ export async function deterministicDeployZetaToken() { console.log("Deployed zetaToken. Address:", address); console.log("Constructor Args", constructorArgs); -} + + return address; +}; if (!process.env.EXECUTE_PROGRAMMATICALLY) { deterministicDeployZetaToken() From bfb137ce2010a42929003494394e44f72f985922 Mon Sep 17 00:00:00 2001 From: Andres Aiello Date: Thu, 18 Jan 2024 14:09:47 -0500 Subject: [PATCH 2/4] update salt generators --- lib/deterministic-deploy.helpers.ts | 8 ++++--- .../deterministic-get-salt-erc20-custody.ts | 23 +++++++++++-------- .../deterministic-get-salt-zeta-connector.ts | 23 +++++++++++-------- .../deterministic-get-salt-zeta-token.ts | 23 +++++++++++-------- 4 files changed, 47 insertions(+), 30 deletions(-) diff --git a/lib/deterministic-deploy.helpers.ts b/lib/deterministic-deploy.helpers.ts index 7527b5e9..b2d3ce96 100644 --- a/lib/deterministic-deploy.helpers.ts +++ b/lib/deterministic-deploy.helpers.ts @@ -1,21 +1,23 @@ import { BigNumber } from "ethers"; +import { getAddress } from "lib"; -import { getAddress } from "../lib/address.helpers"; import { MAX_ETH_ADDRESS } from "../lib/contracts.constants"; import { buildBytecode, buildCreate2Address, saltToHex, } from "../lib/ImmutableCreate2Factory/ImmutableCreate2Factory.helpers"; +import { ZetaProtocolNetwork } from "./address.tools"; export const calculateBestSalt = async ( maxIterations: BigNumber, deployerAddress: string, constructorTypes: string[], constructorArgs: string[], - contractBytecode: string + contractBytecode: string, + network: ZetaProtocolNetwork ) => { - const immutableCreate2Factory = getAddress("immutableCreate2Factory"); + const immutableCreate2Factory = getAddress("immutableCreate2Factory", network); let minAddress = MAX_ETH_ADDRESS; let minAddressSalt = ""; diff --git a/scripts/deployments/tools/deterministic-get-salt-erc20-custody.ts b/scripts/deployments/tools/deterministic-get-salt-erc20-custody.ts index d22a602a..195f2a6f 100644 --- a/scripts/deployments/tools/deterministic-get-salt-erc20-custody.ts +++ b/scripts/deployments/tools/deterministic-get-salt-erc20-custody.ts @@ -29,14 +29,19 @@ export const deterministicDeployGetSaltERC20Custody = async () => { const constructorArgs = [tssAddress, tssUpdaterAddress, zetaFee.toString(), zetaMaxFee.toString(), zetaTokenAddress]; const contractBytecode = ERC20Custody__factory.bytecode; - calculateBestSalt(MAX_ITERATIONS, DEPLOYER_ADDRESS, constructorTypes, constructorArgs, contractBytecode); + await calculateBestSalt( + MAX_ITERATIONS, + DEPLOYER_ADDRESS, + constructorTypes, + constructorArgs, + contractBytecode, + network.name + ); }; -if (!process.env.EXECUTE_PROGRAMMATICALLY) { - deterministicDeployGetSaltERC20Custody() - .then(() => process.exit(0)) - .catch((error) => { - console.error(error); - process.exit(1); - }); -} +deterministicDeployGetSaltERC20Custody() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/scripts/deployments/tools/deterministic-get-salt-zeta-connector.ts b/scripts/deployments/tools/deterministic-get-salt-zeta-connector.ts index 73252f6f..dfbb3105 100644 --- a/scripts/deployments/tools/deterministic-get-salt-zeta-connector.ts +++ b/scripts/deployments/tools/deterministic-get-salt-zeta-connector.ts @@ -34,14 +34,19 @@ export async function deterministicDeployGetSaltZetaConnector() { contractBytecode = ZetaConnectorNonEth__factory.bytecode; } - calculateBestSalt(MAX_ITERATIONS, DEPLOYER_ADDRESS, constructorTypes, constructorArgs, contractBytecode); + await calculateBestSalt( + MAX_ITERATIONS, + DEPLOYER_ADDRESS, + constructorTypes, + constructorArgs, + contractBytecode, + network.name + ); } -if (!process.env.EXECUTE_PROGRAMMATICALLY) { - deterministicDeployGetSaltZetaConnector() - .then(() => process.exit(0)) - .catch((error) => { - console.error(error); - process.exit(1); - }); -} +deterministicDeployGetSaltZetaConnector() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/scripts/deployments/tools/deterministic-get-salt-zeta-token.ts b/scripts/deployments/tools/deterministic-get-salt-zeta-token.ts index e988ee2c..b627d2fa 100644 --- a/scripts/deployments/tools/deterministic-get-salt-zeta-token.ts +++ b/scripts/deployments/tools/deterministic-get-salt-zeta-token.ts @@ -34,14 +34,19 @@ export async function deterministicDeployGetSaltZetaToken() { constructorArgs = [tssAddress, tssUpdaterAddress]; contractBytecode = ZetaNonEth__factory.bytecode; } - calculateBestSalt(MAX_ITERATIONS, DEPLOYER_ADDRESS, constructorTypes, constructorArgs, contractBytecode); + await calculateBestSalt( + MAX_ITERATIONS, + DEPLOYER_ADDRESS, + constructorTypes, + constructorArgs, + contractBytecode, + network.name + ); } -if (!process.env.EXECUTE_PROGRAMMATICALLY) { - deterministicDeployGetSaltZetaToken() - .then(() => process.exit(0)) - .catch((error) => { - console.error(error); - process.exit(1); - }); -} +deterministicDeployGetSaltZetaToken() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); From 3f7f62f881d1ffc3ccdd7daa36e57e9a49d63214 Mon Sep 17 00:00:00 2001 From: Andres Aiello Date: Thu, 18 Jan 2024 14:37:41 -0500 Subject: [PATCH 3/4] add support to verify bsc --- hardhat.config.ts | 3 +- package.json | 2 +- yarn.lock | 106 +++++++++++++++++++++++++++++++++------------- 3 files changed, 79 insertions(+), 32 deletions(-) diff --git a/hardhat.config.ts b/hardhat.config.ts index d584c051..b6c9cf2e 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -1,5 +1,5 @@ import "@nomiclabs/hardhat-waffle"; -import "@nomiclabs/hardhat-etherscan"; +import "@nomicfoundation/hardhat-verify"; import "@typechain/hardhat"; import "tsconfig-paths/register"; import "hardhat-abi-exporter"; @@ -15,6 +15,7 @@ const config: HardhatUserConfig = { etherscan: { apiKey: { // BSC + bsc: process.env.BSCSCAN_API_KEY || "", bscTestnet: process.env.BSCSCAN_API_KEY || "", // ETH goerli: process.env.ETHERSCAN_API_KEY || "", diff --git a/package.json b/package.json index 9e7bde0a..85de1c12 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "@nomicfoundation/hardhat-network-helpers": "^1.0.0", "@nomicfoundation/hardhat-toolbox": "^2.0.0", "@nomiclabs/hardhat-ethers": "^2.0.5", - "@nomiclabs/hardhat-etherscan": "3.0.3", + "@nomicfoundation/hardhat-verify": "2.0.3", "@nomiclabs/hardhat-waffle": "^2.0.3", "@openzeppelin/contracts": "^4.8.3", "@typechain/ethers-v5": "^10.1.0", diff --git a/yarn.lock b/yarn.lock index 6a8cfffc..7636a3eb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1443,6 +1443,21 @@ resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-toolbox/-/hardhat-toolbox-2.0.2.tgz#ec95f23b53cb4e71a1a7091380fa223aad18f156" integrity sha512-vnN1AzxbvpSx9pfdRHbUzTRIXpMLPXnUlkW855VaDk6N1pwRaQ2gNzEmFAABk4lWf11E00PKwFd/q27HuwYrYg== +"@nomicfoundation/hardhat-verify@2.0.3": + version "2.0.3" + resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-verify/-/hardhat-verify-2.0.3.tgz#173557f8cfa53c8c9da23a326f54d24fe459ae68" + integrity sha512-ESbRu9by53wu6VvgwtMtm108RSmuNsVqXtzg061D+/4R7jaWh/Wl/8ve+p6SdDX7vA1Z3L02hDO1Q3BY4luLXQ== + dependencies: + "@ethersproject/abi" "^5.1.2" + "@ethersproject/address" "^5.0.2" + cbor "^8.1.0" + chalk "^2.4.2" + debug "^4.1.1" + lodash.clonedeep "^4.5.0" + semver "^6.3.0" + table "^6.8.0" + undici "^5.14.0" + "@nomicfoundation/solidity-analyzer-darwin-arm64@0.1.1": version "0.1.1" resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-darwin-arm64/-/solidity-analyzer-darwin-arm64-0.1.1.tgz#4c858096b1c17fe58a474fe81b46815f93645c15" @@ -1514,19 +1529,6 @@ resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-ethers/-/hardhat-ethers-2.2.3.tgz#b41053e360c31a32c2640c9a45ee981a7e603fe0" integrity sha512-YhzPdzb612X591FOe68q+qXVXGG2ANZRvDo0RRUtimev85rCrAlv/TLMEZw5c+kq9AbzocLTVX/h2jVIFPL9Xg== -"@nomiclabs/hardhat-etherscan@3.0.3": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-3.0.3.tgz#ca54a03351f3de41f9f5240e37bea9d64fa24e64" - integrity sha512-OfNtUKc/ZwzivmZnnpwWREfaYncXteKHskn3yDnz+fPBZ6wfM4GR+d5RwjREzYFWE+o5iR9ruXhWw/8fejWM9g== - dependencies: - "@ethersproject/abi" "^5.1.2" - "@ethersproject/address" "^5.0.2" - cbor "^5.0.2" - debug "^4.1.1" - fs-extra "^7.0.1" - semver "^6.3.0" - undici "^4.14.1" - "@nomiclabs/hardhat-waffle@^2.0.3": version "2.0.5" resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-waffle/-/hardhat-waffle-2.0.5.tgz#97c217f1db795395c04404291937edb528f3f218" @@ -2215,6 +2217,16 @@ ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4: json-schema-traverse "^0.4.1" uri-js "^4.2.2" +ajv@^8.0.1: + version "8.12.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.12.0.tgz#d1a0527323e22f53562c567c00991577dfbe19d1" + integrity sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA== + dependencies: + fast-deep-equal "^3.1.1" + json-schema-traverse "^1.0.0" + require-from-string "^2.0.2" + uri-js "^4.2.2" + amdefine@>=0.0.4: version "1.0.1" resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" @@ -2443,6 +2455,11 @@ assign-symbols@^1.0.0: resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" integrity sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw== +astral-regex@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" + integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== + async-each@^1.0.0: version "1.0.6" resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.6.tgz#52f1d9403818c179b7561e11a5d1b77eb2160e77" @@ -2564,7 +2581,7 @@ bigint-crypto-utils@^3.0.23: resolved "https://registry.yarnpkg.com/bigint-crypto-utils/-/bigint-crypto-utils-3.2.2.tgz#e30a49ec38357c6981cd3da5aaa6480b1f752ee4" integrity sha512-U1RbE3aX9ayCUVcIPHuPDPKcK3SFOXf93J1UK/iHlJuQB7bhagPIX06/CLpLEsDThJ7KA4Dhrnzynl+d2weTiw== -bignumber.js@^9.0.0, bignumber.js@^9.0.1: +bignumber.js@^9.0.0: version "9.1.1" resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.1.tgz#c4df7dc496bd849d4c9464344c1aa74228b4dac6" integrity sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig== @@ -2858,13 +2875,12 @@ catering@^2.0.0, catering@^2.1.0, catering@^2.1.1: resolved "https://registry.yarnpkg.com/catering/-/catering-2.1.1.tgz#66acba06ed5ee28d5286133982a927de9a04b510" integrity sha512-K7Qy8O9p76sL3/3m7/zLKbRkyOlSZAgzEaLhyj2mXS8PsCud2Eo4hAb8aLtZqHh0QGqLcb9dlJSu6lHRVENm1w== -cbor@^5.0.2: - version "5.2.0" - resolved "https://registry.yarnpkg.com/cbor/-/cbor-5.2.0.tgz#4cca67783ccd6de7b50ab4ed62636712f287a67c" - integrity sha512-5IMhi9e1QU76ppa5/ajP1BmMWZ2FHkhAhjeVKQ/EFCgYSEaeVaoGtL7cxJskf9oCCk+XjzaIdc3IuU/dbA/o2A== +cbor@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/cbor/-/cbor-8.1.0.tgz#cfc56437e770b73417a2ecbfc9caf6b771af60d5" + integrity sha512-DwGjNW9omn6EwP70aXsn7FQJx5kO12tX0bZkaTjzdVFM6/7nhA4t0EENocKGx6D2Bch9PE2KzCUf5SceBdeijg== dependencies: - bignumber.js "^9.0.1" - nofilter "^1.0.4" + nofilter "^3.1.0" chai-as-promised@^7.1.1: version "7.1.1" @@ -5759,6 +5775,11 @@ json-schema-traverse@^0.4.1: resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== +json-schema-traverse@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" + integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== + json-schema@0.4.0, json-schema@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.4.0.tgz#f7de4cf6efab838ebaeb3236474cbba5a1930ab5" @@ -6070,6 +6091,11 @@ lodash.camelcase@^4.3.0: resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" integrity sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA== +lodash.clonedeep@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" + integrity sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ== + lodash.merge@^4.6.2: version "4.6.2" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" @@ -6080,6 +6106,11 @@ lodash.startcase@^4.4.0: resolved "https://registry.yarnpkg.com/lodash.startcase/-/lodash.startcase-4.4.0.tgz#9436e34ed26093ed7ffae1936144350915d9add8" integrity sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg== +lodash.truncate@^4.4.2: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193" + integrity sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw== + lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.16, lodash@^4.17.19, lodash@^4.17.21: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" @@ -6639,10 +6670,10 @@ node-gyp-build@^4.2.0, node-gyp-build@^4.3.0: resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.6.0.tgz#0c52e4cbf54bbd28b709820ef7b6a3c2d6209055" integrity sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ== -nofilter@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/nofilter/-/nofilter-1.0.4.tgz#78d6f4b6a613e7ced8b015cec534625f7667006e" - integrity sha512-N8lidFp+fCz+TD51+haYdbDGrcBWwuHX40F5+z0qkUjMJ5Tp+rdSuAkMJ9N9eoolDlEVTf6u5icM+cNKkKW2mA== +nofilter@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/nofilter/-/nofilter-3.1.0.tgz#c757ba68801d41ff930ba2ec55bab52ca184aa66" + integrity sha512-l2NNj07e9afPnhAhvgVrCD/oy2Ai1yfLpuo3EpiO1jFTsB4sFz6oIfAfSZyQzVpkZQ9xS8ZS5g1jCBgq4Hwo0g== nopt@3.x: version "3.0.6" @@ -7434,7 +7465,7 @@ require-directory@^2.1.1: resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== -require-from-string@^2.0.0: +require-from-string@^2.0.0, require-from-string@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== @@ -7810,6 +7841,15 @@ slash@^4.0.0: resolved "https://registry.yarnpkg.com/slash/-/slash-4.0.0.tgz#2422372176c4c6c5addb5e2ada885af984b396a7" integrity sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew== +slice-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-4.0.0.tgz#500e8dd0fd55b05815086255b3195adf2a45fe6b" + integrity sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ== + dependencies: + ansi-styles "^4.0.0" + astral-regex "^2.0.0" + is-fullwidth-code-point "^3.0.0" + smartwrap@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/smartwrap/-/smartwrap-2.0.2.tgz#7e25d3dd58b51c6ca4aba3a9e391650ea62698a4" @@ -8247,6 +8287,17 @@ table-layout@^1.0.2: typical "^5.2.0" wordwrapjs "^4.0.0" +table@^6.8.0: + version "6.8.1" + resolved "https://registry.yarnpkg.com/table/-/table-6.8.1.tgz#ea2b71359fe03b017a5fbc296204471158080bdf" + integrity sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA== + dependencies: + ajv "^8.0.1" + lodash.truncate "^4.4.2" + slice-ansi "^4.0.0" + string-width "^4.2.3" + strip-ansi "^6.0.1" + term-size@^2.1.0: version "2.2.1" resolved "https://registry.yarnpkg.com/term-size/-/term-size-2.2.1.tgz#2a6a54840432c2fb6320fea0f415531e90189f54" @@ -8585,11 +8636,6 @@ unbox-primitive@^1.0.2: has-symbols "^1.0.3" which-boxed-primitive "^1.0.2" -undici@^4.14.1: - version "4.16.0" - resolved "https://registry.yarnpkg.com/undici/-/undici-4.16.0.tgz#469bb87b3b918818d3d7843d91a1d08da357d5ff" - integrity sha512-tkZSECUYi+/T1i4u+4+lwZmQgLXd4BLGlrc7KZPcLIW7Jpq99+Xpc30ONv7nS6F5UNOxp/HBZSSL9MafUrvJbw== - undici@^5.14.0: version "5.21.2" resolved "https://registry.yarnpkg.com/undici/-/undici-5.21.2.tgz#329f628aaea3f1539a28b9325dccc72097d29acd" From 13aafe17fee32f55efcd22856816fc3f82963250 Mon Sep 17 00:00:00 2001 From: Andres Aiello Date: Tue, 23 Jan 2024 12:08:49 -0500 Subject: [PATCH 4/4] deploy to mainnet --- data/addresses.json | 10 +++++----- lib/contracts.constants.ts | 6 +++--- .../core/deterministic-deploy-erc20-custody.ts | 6 +++++- .../core/deterministic-deploy-zeta-connector.ts | 6 +++++- .../core/deterministic-deploy-zeta-token.ts | 5 ++++- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/data/addresses.json b/data/addresses.json index 0a384f00..a8c7fc36 100644 --- a/data/addresses.json +++ b/data/addresses.json @@ -37,12 +37,12 @@ "zetaTokenConsumerUniV3": "" }, "eth_mainnet": { - "connector": "0x054197b11aA98E6d842073F9362b64b10F2c24A7", - "erc20Custody": "0xb77277Cf4c734894d4f2471492B184E5C71C32a9", + "connector": "0x000007Cf399229b2f5A4D043F20E90C9C98B7C6a", + "erc20Custody": "0x000001b91C19A31809e769110d35FAd2C15BCeA7", "immutableCreate2Factory": "0x095a03c6a68137fE9a566bBc3e552F299d8b886d", - "tss": "0x6F28967E382765cEF6149fa02Cd0Ba0753B01A6b", - "tssUpdater": "0xfCA0392567D5eb77681843b2608dE9C625F57948", - "zetaToken": "0x5CDf9f824526Bf2A4638BF6879591F635Bb8f0B8" + "tss": "0xaeB6dDB7708467814D557e340283248be8E43124", + "tssUpdater": "0xaeB6dDB7708467814D557e340283248be8E43124", + "zetaToken": "0xf091867EC603A6628eD83D274E835539D82e9cc8" }, "goerli_testnet": { "connector": "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea", diff --git a/lib/contracts.constants.ts b/lib/contracts.constants.ts index 9aba37d5..9458905a 100644 --- a/lib/contracts.constants.ts +++ b/lib/contracts.constants.ts @@ -31,10 +31,10 @@ const SALT_NUMBERS = { zetaToken: "", }, eth_mainnet: { - zetaConnector: "1414", + zetaConnector: "84286", zetaConsumer: "0", - zetaERC20Custody: "87967", - zetaToken: "84108", + zetaERC20Custody: "926526", + zetaToken: "0", }, goerli_testnet: { zetaConnector: "1414", diff --git a/scripts/deployments/core/deterministic-deploy-erc20-custody.ts b/scripts/deployments/core/deterministic-deploy-erc20-custody.ts index c822c11d..370fc145 100644 --- a/scripts/deployments/core/deterministic-deploy-erc20-custody.ts +++ b/scripts/deployments/core/deterministic-deploy-erc20-custody.ts @@ -16,6 +16,7 @@ export const deterministicDeployERC20Custody = async () => { const accounts = await ethers.getSigners(); const [signer] = accounts; + const initialBalance = await signer.getBalance(); const DEPLOYER_ADDRESS = process.env.DEPLOYER_ADDRESS || signer.address; @@ -24,7 +25,7 @@ export const deterministicDeployERC20Custody = async () => { const tssUpdaterAddress = getAddress("tssUpdater", network.name); const immutableCreate2FactoryAddress = getAddress("immutableCreate2Factory", network.name); - const saltNumber = getSaltNumber(network.name, "zetaERC20Custody"); + const saltNumber = getSaltNumber("zetaERC20Custody", network.name); const saltStr = BigNumber.from(saltNumber).toHexString(); const zetaFee = ERC20_CUSTODY_ZETA_FEE; @@ -46,8 +47,11 @@ export const deterministicDeployERC20Custody = async () => { signer, }); + const finalBalance = await signer.getBalance(); console.log("Deployed ERC20 Custody. Address:", address); console.log("Constructor Args", constructorArgs); + console.log("ETH spent:", initialBalance.sub(finalBalance).toString()); + return address; }; diff --git a/scripts/deployments/core/deterministic-deploy-zeta-connector.ts b/scripts/deployments/core/deterministic-deploy-zeta-connector.ts index aacab938..dcb116db 100644 --- a/scripts/deployments/core/deterministic-deploy-zeta-connector.ts +++ b/scripts/deployments/core/deterministic-deploy-zeta-connector.ts @@ -17,6 +17,7 @@ export const deterministicDeployZetaConnector = async () => { const accounts = await ethers.getSigners(); const [signer] = accounts; + const initialBalance = await signer.getBalance(); const DEPLOYER_ADDRESS = process.env.DEPLOYER_ADDRESS || signer.address; @@ -25,7 +26,7 @@ export const deterministicDeployZetaConnector = async () => { const tssUpdaterAddress = getAddress("tssUpdater", network.name); const immutableCreate2FactoryAddress = getAddress("immutableCreate2Factory", network.name); - const saltNumber = getSaltNumber(network.name, "zetaConnector"); + const saltNumber = getSaltNumber("zetaConnector", network.name); const saltStr = BigNumber.from(saltNumber).toHexString(); const salthex = saltToHex(saltStr, DEPLOYER_ADDRESS); @@ -48,8 +49,11 @@ export const deterministicDeployZetaConnector = async () => { signer, }); + const finalBalance = await signer.getBalance(); console.log("Deployed ZetaConnector. Address:", address); console.log("Constructor Args", constructorArgs); + console.log("ETH spent:", initialBalance.sub(finalBalance).toString()); + return address; }; diff --git a/scripts/deployments/core/deterministic-deploy-zeta-token.ts b/scripts/deployments/core/deterministic-deploy-zeta-token.ts index ad6692ef..4ff01072 100644 --- a/scripts/deployments/core/deterministic-deploy-zeta-token.ts +++ b/scripts/deployments/core/deterministic-deploy-zeta-token.ts @@ -17,6 +17,7 @@ export const deterministicDeployZetaToken = async () => { const accounts = await ethers.getSigners(); const [signer] = accounts; + const initialBalance = await signer.getBalance(); const DEPLOYER_ADDRESS = process.env.DEPLOYER_ADDRESS || signer.address; @@ -24,7 +25,7 @@ export const deterministicDeployZetaToken = async () => { const tssUpdaterAddress = getAddress("tssUpdater", network.name); const immutableCreate2FactoryAddress = getAddress("immutableCreate2Factory", network.name); - const saltNumber = getSaltNumber(network.name, "zetaToken"); + const saltNumber = getSaltNumber("zetaToken", network.name); const saltStr = BigNumber.from(saltNumber).toHexString(); const salthex = saltToHex(saltStr, DEPLOYER_ADDRESS); @@ -53,8 +54,10 @@ export const deterministicDeployZetaToken = async () => { signer, }); + const finalBalance = await signer.getBalance(); console.log("Deployed zetaToken. Address:", address); console.log("Constructor Args", constructorArgs); + console.log("ETH spent:", initialBalance.sub(finalBalance).toString()); return address; };