From eb94e34d0002df099592d52d45110297b0490640 Mon Sep 17 00:00:00 2001 From: Ankur Dubey Date: Sat, 25 Feb 2023 18:53:40 +0530 Subject: [PATCH] Update scripts for zkevm testnet deployment --- .env.example | 3 + hardhat.config.ts | 16 +- .../set-all-token-config.ts | 2 +- .../testnet/deposit-config-polygon-zkevm.ts | 164 +++++++++++++ scripts/deploy/testnet/deploy-zkevm-mango.ts | 229 ++++++++++++++++++ 5 files changed, 412 insertions(+), 2 deletions(-) create mode 100644 scripts/backend-api-script/testnet/deposit-config-polygon-zkevm.ts create mode 100644 scripts/deploy/testnet/deploy-zkevm-mango.ts diff --git a/.env.example b/.env.example index 35a366a..b1e7437 100644 --- a/.env.example +++ b/.env.example @@ -6,6 +6,8 @@ OPTIMISM_ETHERSCAN_API_KEY= OPTIMISM_KOVAN_ETHERSCAN_API_KEY= ARBITRUM_ETHERSCAN_API_KEY= ARBITRUM_RINKEBY_ETHERSCAN_API_KEY= +POLYGON_ZKEVM_BLOCKNATIVE_API_KEY=RANDOMSTRING + BSC_URL=https://bsc-dataseed.binance.org/ BSC_TESTNET_URL=https://data-seed-prebsc-1-s1.binance.org:8545/ ROPSTEN_URL=https://eth-ropsten.alchemyapi.io/v2/ @@ -16,6 +18,7 @@ ARBITRUM_URL= ARBITRUM_RINKEBY_URL= OPTIMISM_KOVAN_URL= OPTIMISM_ETHEREUM_URL= +ZKEVM_MANGO_TESTNET_URL=https://rpc.public.zkevm-test.net STAGING_API_URL=https://hyphen-v2-staging-api.biconomy.io STAGING_API_USERNAME= diff --git a/hardhat.config.ts b/hardhat.config.ts index 096e988..12c42a1 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -115,6 +115,10 @@ const config: HardhatUserConfig = { accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [], gas: 250000000, }, + zkevmMangoTestnet: { + url: process.env.ZKEVM_MANGO_TESTNET_URL || "", + accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [], + } }, gasReporter: { enabled: process.env.REPORT_GAS !== undefined, @@ -131,10 +135,20 @@ const config: HardhatUserConfig = { bsc: process.env.BSCSCAN_API_KEY || "", bscTestnet: process.env.BSCSCAN_API_KEY || "", optimisticEthereum: process.env.OPTIMISM_ETHERSCAN_API_KEY || "", - optimisticKovan: process.env.OPTIMISM_KOVAN_ETHERSCAN_API_KEY || "", arbitrumOne: process.env.ARBITRUM_ETHERSCAN_API_KEY || "", arbitrumTestnet: process.env.ARBITRUM_RINKEBY_ETHERSCAN_API_KEY || "", + zkevmMangoTestnet: process.env.POLYGON_ZKEVM_BLOCKNATIVE_API_KEY || "", }, + customChains: [ + { + network: "zkevmMangoTestnet", + chainId: 1422, + urls: { + apiURL: "https://explorer.public.zkevm-test.net/api", + browserURL: "https://explorer.public.zkevm-test.net/" + } + } + ] }, contractSizer: { alphaSort: true, diff --git a/scripts/backend-api-script/set-all-token-config.ts b/scripts/backend-api-script/set-all-token-config.ts index bdcfa98..a1e481c 100644 --- a/scripts/backend-api-script/set-all-token-config.ts +++ b/scripts/backend-api-script/set-all-token-config.ts @@ -3,7 +3,7 @@ import { setTokenConfig } from "./add-supported-token"; import { getBackendConfig } from "./utils"; (async () => { - const backendConfig = getBackendConfig("staging"); + const backendConfig = getBackendConfig("integration"); const tokenData = (await axios.get(`${backendConfig.baseUrl}/api/v1/configuration/tokens`)).data.message as any; const promises = []; for (const token of tokenData) { diff --git a/scripts/backend-api-script/testnet/deposit-config-polygon-zkevm.ts b/scripts/backend-api-script/testnet/deposit-config-polygon-zkevm.ts new file mode 100644 index 0000000..9ed9712 --- /dev/null +++ b/scripts/backend-api-script/testnet/deposit-config-polygon-zkevm.ts @@ -0,0 +1,164 @@ +import { setConfig } from "../set-deposit-config"; +import { getBackendConfig } from "../utils"; + +(async () => { + let deposit_config = [ + { + chainId: 5, + depositConfig: { + toChainIds: [1422, 1422, 1422], + tokenAddresses: [ + "0xb5B640E6414b6DeF4FC9B3C1EeF373925effeCcF", // USDC + "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // ETH + "0xDdc47b0cA071682e8dc373391aCA18dA0Fe28699", // BICO + ], + tokenConfigs: [ + { + min: "100000000", + max: "52000000000", + }, + { + min: "20000000000000000", + max: "135000000000000000000", + }, + { + min: "10000000000000000000", + max: "500000000000000000000000", + }, + ], + }, + }, + { + chainId: 80001, + depositConfig: { + toChainIds: [1422, 1422, 1422], + tokenAddresses: [ + "0xdA5289fCAAF71d52a80A254da614a192b693e977", // USDC + "0xa6fa4fb5f76172d178d61b04b0ecd319c5d1c0aa", // ETH + "0xac42d8319ce458b22a72b45f58c0dcfeee824691", // BICO + ], + tokenConfigs: [ + { + min: "100000000", + max: "52000000000", + }, + { + min: "3900000000000000", + max: "135000000000000000000", + }, + { + min: "10000000000000000000", + max: "500000000000000000000000", + }, + ], + }, + }, + { + chainId: 43113, + depositConfig: { + toChainIds: [1422], + tokenAddresses: [ + "0x7fcdc2c1ef3e4a0bcc8155a558bb20a7218f2b05", // ETH + ], + tokenConfigs: [ + { + min: "3900000000000000", + max: "135000000000000000000", + }, + ], + }, + }, + { + chainId: 420, + depositConfig: { + toChainIds: [1422, 1422, 1422], + tokenAddresses: [ + "0x359a5ECa3Af6db9b04dF09Bb417f97890219Fe5D", // USDC + "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", // ETH + "0x2D138B861a6c3DE6Ec1d4Dbc69cd4AeF36F0Cf43", // Bico + ], + tokenConfigs: [ + { + min: "100000000", + max: "52000000000", + }, + { + min: "3900000000000000", + max: "135000000000000000000", + }, + { + min: "10000000000000000000", + max: "500000000000000000000000", + }, + ], + }, + }, + { + chainId: 97, + depositConfig: { + toChainIds: [1422], + tokenAddresses: [ + "0x756289346D2b3C867966899c6D0467EdEb4Da3C4", // Bico + ], + tokenConfigs: [ + { + min: "10000000000000000000", + max: "500000000000000000000000", + }, + ], + }, + }, + { + chainId: 421613, + depositConfig: { + toChainIds: [1422, 1422, 1422], + tokenAddresses: [ + "0xc84c9BD3898f9c167915FE945f8C722709018d24", // USDC + "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", // ETH + "0x2B30269b3c73Cb69C44453fC41BE82c5EC046836", // Bico + ], + tokenConfigs: [ + { + min: "100000000", + max: "52000000000", + }, + { + min: "3900000000000000", + max: "135000000000000000000", + }, + { + min: "10000000000000000000", + max: "500000000000000000000000", + }, + ], + }, + }, + { + chainId: 4002, + depositConfig: { + toChainIds: [1422, 1422, 1422], + tokenAddresses: [ + "0x7f61a8ee767585c6075e3c084e57e020d734f3aa", // USDC + "0x7af97a21978c4ba05e4ab03a86190fdd3f739866", // ETH + "0x85f09b027310c8efeba4ef3786e7c10e64e9942c", // Bico + ], + tokenConfigs: [ + { + min: "100000000", + max: "52000000000", + }, + { + min: "3900000000000000", + max: "135000000000000000000", + }, + { + min: "10000000000000000000", + max: "500000000000000000000000", + }, + ], + }, + }, + ]; + + setConfig(deposit_config, getBackendConfig("integration")); +})(); diff --git a/scripts/deploy/testnet/deploy-zkevm-mango.ts b/scripts/deploy/testnet/deploy-zkevm-mango.ts new file mode 100644 index 0000000..f405687 --- /dev/null +++ b/scripts/deploy/testnet/deploy-zkevm-mango.ts @@ -0,0 +1,229 @@ +import { ethers } from "hardhat"; +import { parseUnits } from "ethers/lib/utils"; +import { deploy, deployToken } from "../deploy-utils"; +import type { IDeployConfig } from "../../types"; + +/* +Deployed contracts: { + "executorManager": "0xB159363e0531C581b817a2C35c2be362bFAe15c3", + "tokenManager": "0x9E1B9472c01fEdAa1425CC7aF95Eb39CF20Afc06", + "lpToken": "0x9dc1D35f83EB20A52d3dC6c95f844CE139e7F0a6", + "liquidityProviders": "0x0fE5A54707a87b31B06302D830009ab073d93cea", + "liquidityPool": "0x15352F509809dD2A1E34d30bfB535A6e3D0ac785", + "whitelistPeriodManager": "0x3Fb4a6eaA24527CD5e0B233CBF82113c7b69d537", + "liquidityFarming": "0xaA02b9E819321838c932B0eD3e1dBE75F0CFAD5a", + "svgHelpers": { + "0x0D2143c56781d79bfa0C4De56A952f70f8F92e55": "0x205d6a9eb6585B0411795ECe2Ed53c8642B3787e", + "0x4E686Fd412FA0894287B06d4Ca6b900130A734bC": "0x677c335A1CCFd40aeb2ee3aC2cdfb2fCaD1a03F6", + "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE": "0xE76D3AfBa0854482b0D845138a25b06ccAFd8849" + } +} +*/ + +(async () => { + const usdc = await deployToken( + "USDC", + "USDC", + 6, + ["0xDA861C9DccFf6d1fEf7Cae71B5b538AF25063404"], + ethers.BigNumber.from(10).pow(20) + ); + const bico = await deployToken( + "BICO", + "BICO", + 18, + ["0xDA861C9DccFf6d1fEf7Cae71B5b538AF25063404"], + ethers.BigNumber.from(10).pow(30) + ); + + const config: IDeployConfig = { + // We don't support gasless on Optimism Yet + trustedForwarder: bico.address, + + bicoOwner: "0x501b9BF108456d7d67d4C3D1928802dE58292C22", + pauser: "0x501b9BF108456d7d67d4C3D1928802dE58292C22", + tokens: [ + // USDC + { + tokenAddress: usdc.address, + minCap: parseUnits("100", 6), + maxCap: parseUnits("58160", 6), + depositConfigs: [ + { + chainId: 5, + minCap: parseUnits("10", 6), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: parseUnits("50000", 6), + }, + { + chainId: 80001, + minCap: parseUnits("10", 6), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: parseUnits("50000", 6), + }, + { + chainId: 43113, + minCap: parseUnits("10", 6), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: parseUnits("50000", 6), + }, + { + chainId: 97, + minCap: parseUnits("10", 6), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: parseUnits("50000", 6), + }, + { + chainId: 420, + minCap: parseUnits("10", 6), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: parseUnits("50000", 6), + }, + { + chainId: 421613, + minCap: parseUnits("10", 6), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: parseUnits("50000", 6), + }, + { + chainId: 4002, + minCap: parseUnits("10", 6), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: parseUnits("50000", 6), + }, + ], + equilibriumFee: parseUnits("0.1", 8), + maxFee: parseUnits("2.5", 8), + transferOverhead: 82491, + maxWalletLiquidityCap: parseUnits("10000", 6), + maxLiquidityCap: parseUnits("578829", 6), + svgHelper: await ethers.getContractFactory("OPTUSDC"), + decimals: 6, + rewardTokenAddress: bico.address, + rewardRatePerSecond: parseUnits("0.003662", 18), + excessStateTransferFeePer: parseUnits("0.045", 8), + }, + // BICO + { + tokenAddress: bico.address, + minCap: parseUnits("50", 18), + maxCap: parseUnits("123220", 18), + depositConfigs: [ + { + chainId: 5, + minCap: parseUnits("10", 18), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: parseUnits("100000", 18), + }, + { + chainId: 80001, + minCap: parseUnits("10", 18), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: parseUnits("100000", 18), + }, + { + chainId: 43113, + minCap: parseUnits("10", 18), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: parseUnits("100000", 18), + }, + { + chainId: 97, + minCap: parseUnits("10", 18), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: parseUnits("100000", 18), + }, + { + chainId: 420, + minCap: parseUnits("10", 18), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: parseUnits("100000", 18), + }, + { + chainId: 421613, + minCap: parseUnits("10", 18), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: parseUnits("100000", 18), + }, + { + chainId: 4002, + minCap: parseUnits("10", 18), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: parseUnits("100000", 18), + }, + ], + equilibriumFee: ethers.utils.parseUnits("0.1", 8), + maxFee: ethers.utils.parseUnits("2.5", 8), + transferOverhead: 85949, + maxWalletLiquidityCap: parseUnits("8474.57", 18), + maxLiquidityCap: parseUnits("610350", 18), + svgHelper: await ethers.getContractFactory("OPTBICO"), + decimals: 18, + rewardTokenAddress: bico.address, + rewardRatePerSecond: parseUnits("0.01", 18), + excessStateTransferFeePer: parseUnits("0.045", 8), + }, + // ETH + { + tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + minCap: ethers.BigNumber.from(10).pow(18 - 2), + maxCap: ethers.BigNumber.from(10).pow(18 + 2), + depositConfigs: [ + { + chainId: 43113, + minCap: ethers.BigNumber.from(10).pow(18 - 2), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: ethers.BigNumber.from(97).mul(ethers.BigNumber.from(10).pow(18)), + }, + { + chainId: 80001, + minCap: ethers.BigNumber.from(10).pow(18 - 2), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: ethers.BigNumber.from(97).mul(ethers.BigNumber.from(10).pow(18)), + }, + { + chainId: 97, + minCap: ethers.BigNumber.from(10).pow(18 - 2), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: ethers.BigNumber.from(97).mul(ethers.BigNumber.from(10).pow(18)), + }, + { + chainId: 4002, + minCap: ethers.BigNumber.from(10).pow(18 - 2), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: ethers.BigNumber.from(97).mul(ethers.BigNumber.from(10).pow(18)), + }, + { + chainId: 421613, + minCap: ethers.BigNumber.from(10).pow(18 - 2), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: ethers.BigNumber.from(97).mul(ethers.BigNumber.from(10).pow(18)), + }, + { + chainId: 4002, + minCap: ethers.BigNumber.from(10).pow(18 - 2), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: ethers.BigNumber.from(97).mul(ethers.BigNumber.from(10).pow(18)), + }, + { + chainId: 5, + minCap: ethers.BigNumber.from(10).pow(18 - 2), + // Max Cap needs to be less than the maxTransfer Fee on destination chain id to cover for incentive amount + maxCap: ethers.BigNumber.from(97).mul(ethers.BigNumber.from(10).pow(18)), + }, + ], + equilibriumFee: 10000000, + maxFee: 200000000, + transferOverhead: 0, + maxWalletLiquidityCap: ethers.BigNumber.from(10).pow(18 + 4), + maxLiquidityCap: ethers.BigNumber.from(10).pow(18 + 5), + svgHelper: await ethers.getContractFactory("OPTETH"), + decimals: 18, + rewardRatePerSecond: 100, + rewardTokenAddress: bico.address, + excessStateTransferFeePer: parseUnits("0.045", 8), + }, + ], + }; + await deploy(config); +})();