From ba27567d201a2f1b7f513f0a672c3e29fd6cf900 Mon Sep 17 00:00:00 2001 From: Julian R Date: Thu, 26 Sep 2024 12:11:01 -0300 Subject: [PATCH] deployment scripts --- scripts/deploy.ts | 2 + .../deploy_ctokenv3_usdbc_collateral.ts | 6 +- .../deploy_ctokenv3_usdc_collateral.ts | 6 +- .../deploy_ctokenv3_usdt_collateral.ts | 101 ++++++++++++++++++ 4 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 scripts/deployment/phase2-assets/collaterals/deploy_ctokenv3_usdt_collateral.ts diff --git a/scripts/deploy.ts b/scripts/deploy.ts index cc2a51418b..7093ced874 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -61,6 +61,7 @@ async function main() { 'phase2-assets/collaterals/deploy_rocket_pool_reth_collateral.ts', 'phase2-assets/collaterals/deploy_flux_finance_collateral.ts', 'phase2-assets/collaterals/deploy_ctokenv3_usdc_collateral.ts', + 'phase2-assets/collaterals/deploy_ctokenv3_usdt_collateral.ts', 'phase2-assets/collaterals/deploy_convex_3pool_collateral.ts', 'phase2-assets/collaterals/deploy_convex_paypool_collateral.ts', 'phase2-assets/collaterals/deploy_convex_crvusd_usdc_collateral.ts', @@ -113,6 +114,7 @@ async function main() { 'phase2-assets/collaterals/deploy_aave_v3_usdc.ts', 'phase2-assets/collaterals/deploy_aave_v3_usdt.ts', 'phase2-assets/collaterals/deploy_ctokenv3_usdc_collateral.ts', + 'phase2-assets/collaterals/deploy_ctokenv3_usdt_collateral.ts', 'phase2-assets/collaterals/deploy_convex_crvusd_usdc_collateral.ts', 'phase2-assets/collaterals/deploy_convex_crvusd_usdt_collateral.ts', 'phase2-assets/collaterals/deploy_usdm.ts', diff --git a/scripts/deployment/phase2-assets/collaterals/deploy_ctokenv3_usdbc_collateral.ts b/scripts/deployment/phase2-assets/collaterals/deploy_ctokenv3_usdbc_collateral.ts index 0b2184a842..5039c42236 100644 --- a/scripts/deployment/phase2-assets/collaterals/deploy_ctokenv3_usdbc_collateral.ts +++ b/scripts/deployment/phase2-assets/collaterals/deploy_ctokenv3_usdbc_collateral.ts @@ -47,11 +47,13 @@ async function main() { /******** Deploy CompoundV3 USDC - cUSDbCv3 **************************/ - const WrapperFactory: ContractFactory = await hre.ethers.getContractFactory('CusdcV3Wrapper') + const WrapperFactory: ContractFactory = await hre.ethers.getContractFactory('CFiatV3Wrapper') const erc20 = await WrapperFactory.deploy( networkConfig[chainId].tokens.cUSDbCv3, networkConfig[chainId].COMET_REWARDS, - networkConfig[chainId].tokens.COMP + networkConfig[chainId].tokens.COMP, + 'Wrapped cUSDbCv3', + 'wcUSDbCv3' ) await erc20.deployed() diff --git a/scripts/deployment/phase2-assets/collaterals/deploy_ctokenv3_usdc_collateral.ts b/scripts/deployment/phase2-assets/collaterals/deploy_ctokenv3_usdc_collateral.ts index 0c81f7aa06..f47415fe6e 100644 --- a/scripts/deployment/phase2-assets/collaterals/deploy_ctokenv3_usdc_collateral.ts +++ b/scripts/deployment/phase2-assets/collaterals/deploy_ctokenv3_usdc_collateral.ts @@ -42,11 +42,13 @@ async function main() { /******** Deploy CompoundV3 USDC - cUSDCv3 **************************/ - const WrapperFactory: ContractFactory = await hre.ethers.getContractFactory('CusdcV3Wrapper') + const WrapperFactory: ContractFactory = await hre.ethers.getContractFactory('CFiatV3Wrapper') const erc20 = await WrapperFactory.deploy( networkConfig[chainId].tokens.cUSDCv3, networkConfig[chainId].COMET_REWARDS, - networkConfig[chainId].tokens.COMP + networkConfig[chainId].tokens.COMP, + 'Wrapped cUSDCv3', + 'wcUSDCv3' ) await erc20.deployed() diff --git a/scripts/deployment/phase2-assets/collaterals/deploy_ctokenv3_usdt_collateral.ts b/scripts/deployment/phase2-assets/collaterals/deploy_ctokenv3_usdt_collateral.ts new file mode 100644 index 0000000000..8f49176e9b --- /dev/null +++ b/scripts/deployment/phase2-assets/collaterals/deploy_ctokenv3_usdt_collateral.ts @@ -0,0 +1,101 @@ +import fs from 'fs' +import hre from 'hardhat' +import { getChainId } from '../../../../common/blockchain-utils' +import { baseL2Chains, networkConfig } from '../../../../common/configuration' +import { bn, fp } from '../../../../common/numbers' +import { expect } from 'chai' +import { CollateralStatus } from '../../../../common/constants' +import { + getDeploymentFile, + getAssetCollDeploymentFilename, + IAssetCollDeployments, + getDeploymentFilename, + fileExists, +} from '../../common' +import { getUsdtOracleError, priceTimeout, revenueHiding } from '../../utils' +import { CTokenV3Collateral } from '../../../../typechain' +import { ContractFactory } from 'ethers' + +async function main() { + // ==== Read Configuration ==== + const [deployer] = await hre.ethers.getSigners() + + const chainId = await getChainId(hre) + + console.log(`Deploying Collateral to network ${hre.network.name} (${chainId}) + with burner account: ${deployer.address}`) + + if (!networkConfig[chainId]) { + throw new Error(`Missing network configuration for ${hre.network.name}`) + } + + // Does not exist on Base L2 + if (baseL2Chains.includes(hre.network.name)) { + throw new Error(`Invalid network ${hre.network.name} - Not available on Base`) + } + + // Get phase1 deployment + const phase1File = getDeploymentFilename(chainId) + if (!fileExists(phase1File)) { + throw new Error(`${phase1File} doesn't exist yet. Run phase 1`) + } + // Check previous step completed + const assetCollDeploymentFilename = getAssetCollDeploymentFilename(chainId) + const assetCollDeployments = getDeploymentFile(assetCollDeploymentFilename) + + const deployedCollateral: string[] = [] + + /******** Deploy CompoundV3 USDT - cUSDTv3 **************************/ + + const WrapperFactory: ContractFactory = await hre.ethers.getContractFactory('CFiatV3Wrapper') + const erc20 = await WrapperFactory.deploy( + networkConfig[chainId].tokens.cUSDTv3, + networkConfig[chainId].COMET_REWARDS, + networkConfig[chainId].tokens.COMP, + 'Wrapped cUSDTv3', + 'wcUSDTv3' + ) + await erc20.deployed() + + console.log(`Deployed wrapper for cUSDTv3 on ${hre.network.name} (${chainId}): ${erc20.address} `) + + const CTokenV3Factory: ContractFactory = await hre.ethers.getContractFactory('CTokenV3Collateral') + + const usdtOracleTimeout = '86400' // 24 hr + const usdtOracleError = getUsdtOracleError(hre.network.name) + + const collateral = await CTokenV3Factory.connect(deployer).deploy( + { + priceTimeout: priceTimeout.toString(), + chainlinkFeed: networkConfig[chainId].chainlinkFeeds.USDT, + oracleError: usdtOracleError.toString(), + erc20: erc20.address, + maxTradeVolume: fp('1e6').toString(), // $1m, + oracleTimeout: usdtOracleTimeout, // 24h hr, + targetName: hre.ethers.utils.formatBytes32String('USD'), + defaultThreshold: fp('0.01').add(usdtOracleError).toString(), + delayUntilDefault: bn('86400').toString(), // 24h + }, + revenueHiding.toString() + ) + await collateral.deployed() + await (await collateral.refresh()).wait() + expect(await collateral.status()).to.equal(CollateralStatus.SOUND) + + console.log(`Deployed CompoundV3 USDT to ${hre.network.name} (${chainId}): ${collateral.address}`) + + assetCollDeployments.collateral.cUSDTv3 = collateral.address + assetCollDeployments.erc20s.cUSDTv3 = erc20.address + deployedCollateral.push(collateral.address.toString()) + + fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) + + console.log(`Deployed collateral to ${hre.network.name} (${chainId}) + New deployments: ${deployedCollateral} + Deployment file: ${assetCollDeploymentFilename}`) +} + +main().catch((error) => { + console.error(error) + process.exitCode = 1 +})