From d35fb7576920e163945a932b366f71dbe6d1cdfb Mon Sep 17 00:00:00 2001 From: Corey Rice Date: Wed, 18 Dec 2024 09:57:54 -0300 Subject: [PATCH 1/2] refactor: remove bscmainnet deployments from hardhat deployments --- deploy/000-1-setup.ts | 33 ++++++++++++++++++++++++++++ deploy/000-psr.ts | 32 ++++++++++++++++++++------- deploy/001-risk-fund-v2.ts | 2 +- deploy/002-risk-fund-converter.ts | 6 ++++- deploy/004-single-token-converter.ts | 2 +- hardhat.config.ts | 21 ++++++++++++------ package.json | 8 +++---- 7 files changed, 82 insertions(+), 22 deletions(-) create mode 100644 deploy/000-1-setup.ts diff --git a/deploy/000-1-setup.ts b/deploy/000-1-setup.ts new file mode 100644 index 0000000..a9dcdd7 --- /dev/null +++ b/deploy/000-1-setup.ts @@ -0,0 +1,33 @@ +import timelocksDeployment from "@venusprotocol/governance-contracts/dist/deploy/001-source-timelocks"; +import accessControlManagerDeployment from "@venusprotocol/governance-contracts/dist/deploy/002-access-control"; +import mockTokensILDeployment from "@venusprotocol/isolated-pools/dist/deploy/001-deploy-mock-tokens"; +import poolRegistryDeployment from "@venusprotocol/isolated-pools/dist/deploy/006-deploy-pool-registry"; +import resilientOracleDeployment from "@venusprotocol/oracle/dist/deploy/1-deploy-oracles"; +import comptrollerDeployment from "@venusprotocol/venus-protocol/dist/deploy/001-comptroller"; +import interestRateModelDeployment from "@venusprotocol/venus-protocol/dist/deploy/002-interest-rate-model"; +import mockTokensDeployment from "@venusprotocol/venus-protocol/dist/deploy/003-deploy-VBep20"; +import xvsDeployment from "@venusprotocol/venus-protocol/dist/deploy/007-deploy-xvs"; +import vaultsDeployment from "@venusprotocol/venus-protocol/dist/deploy/008-deploy-vaults"; +import primeConverterDeployment from "@venusprotocol/venus-protocol/dist/deploy/012-deploy-prime"; +import { DeployFunction } from "hardhat-deploy/types"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; + +const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { + await timelocksDeployment(hre); + await accessControlManagerDeployment(hre); + await comptrollerDeployment(hre); + await resilientOracleDeployment(hre); + await interestRateModelDeployment(hre); + await mockTokensDeployment(hre); + await mockTokensILDeployment(hre); + await poolRegistryDeployment(hre); + await xvsDeployment(hre); + await vaultsDeployment(hre); + await primeConverterDeployment(hre); +}; + +func.tags = ["Setup"]; + +func.skip = async hre => hre.network.name !== "hardhat"; + +export default func; diff --git a/deploy/000-psr.ts b/deploy/000-psr.ts index 15830be..f2d7e18 100644 --- a/deploy/000-psr.ts +++ b/deploy/000-psr.ts @@ -1,19 +1,28 @@ -import hre, { ethers } from "hardhat"; +import { ethers } from "hardhat"; import { DeployFunction } from "hardhat-deploy/types"; import { HardhatRuntimeEnvironment } from "hardhat/types"; import { ADDRESS_ONE, multisigs } from "../helpers/utils"; -const func: DeployFunction = async ({ - network: { live, name }, - getNamedAccounts, - deployments, -}: HardhatRuntimeEnvironment) => { +const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { + const { + network: { live, name }, + getNamedAccounts, + deployments, + } = hre; const { deploy } = deployments; const { deployer } = await getNamedAccounts(); const vBNBAddress = (await ethers.getContractOrNull("vBNB"))?.address || ADDRESS_ONE; - const comptrollerAddress = (await ethers.getContract("Unitroller"))?.address; + + // Support BSC and other networks + let comptrollerAddress = ADDRESS_ONE; + try { + comptrollerAddress = (await ethers.getContract("Unitroller"))?.address; + } catch (e) { + console.log("Unitroller not found, using AddressOne"); + } + const WBNBAddress = (await ethers.getContractOrNull("WBNB"))?.address || ADDRESS_ONE; const timelockAddress = (await ethers.getContract("NormalTimelock"))?.address || multisigs[name]; const acmAddress = (await ethers.getContract("AccessControlManager"))?.address; @@ -41,7 +50,14 @@ const func: DeployFunction = async ({ artifact: defaultProxyAdmin, }, } - : undefined, + : { + owner: deployer, + proxyContract: "OpenZeppelinTransparentProxy", + execute: { + methodName: "initialize", + args: [acmAddress, loopsLimit], + }, + }, }); const psr = await hre.ethers.getContract("ProtocolShareReserve"); diff --git a/deploy/001-risk-fund-v2.ts b/deploy/001-risk-fund-v2.ts index 46e2cf7..738247f 100644 --- a/deploy/001-risk-fund-v2.ts +++ b/deploy/001-risk-fund-v2.ts @@ -12,9 +12,9 @@ const func: DeployFunction = async ({ const { deploy } = deployments; const { deployer } = await getNamedAccounts(); - const proxyAdmin = await ethers.getContract("DefaultProxyAdmin"); let owner = deployer; if (live) { + const proxyAdmin = await ethers.getContract("DefaultProxyAdmin"); owner = await proxyAdmin.owner(); } diff --git a/deploy/002-risk-fund-converter.ts b/deploy/002-risk-fund-converter.ts index a586952..2f720ee 100644 --- a/deploy/002-risk-fund-converter.ts +++ b/deploy/002-risk-fund-converter.ts @@ -7,6 +7,10 @@ import { ADDRESS_ONE, multisigs } from "../helpers/utils"; const MIN_AMOUNT_TO_CONVERT = parseUnits("10", 18); +const getTokenOrMockName = (name: string, live: boolean) => { + return `${live ? "" : "Mock"}${name}`; +}; + const func: DeployFunction = async ({ network: { live, name }, getNamedAccounts, @@ -19,7 +23,7 @@ const func: DeployFunction = async ({ const oracleAddress = (await ethers.getContract("ResilientOracle"))?.address; const usdtAddress = (await ethers.getContract("USDT"))?.address; const corePoolAddress = (await ethers.getContract("Unitroller"))?.address; - const btcbAddress = (await ethers.getContract("BTCB"))?.address; + const btcbAddress = (await ethers.getContract(getTokenOrMockName("BTCB", live)))?.address; const ethAddress = (await ethers.getContract("ETH"))?.address; const vBNBAddress = (await ethers.getContractOrNull("vBNB"))?.address || ADDRESS_ONE; diff --git a/deploy/004-single-token-converter.ts b/deploy/004-single-token-converter.ts index cb1c2ee..3724278 100644 --- a/deploy/004-single-token-converter.ts +++ b/deploy/004-single-token-converter.ts @@ -17,7 +17,7 @@ async function getBaseAssets(network: NETWORK): Promise { hardhat: async () => ({ USDTPrimeConverter: (await ethers.getContract("USDT"))?.address, USDCPrimeConverter: (await ethers.getContract("USDC"))?.address, - BTCBPrimeConverter: (await ethers.getContract("BTCB"))?.address, + BTCBPrimeConverter: (await ethers.getContract("MockBTCB"))?.address, ETHPrimeConverter: (await ethers.getContract("ETH"))?.address, XVSVaultConverter: (await ethers.getContract("XVS"))?.address, }), diff --git a/hardhat.config.ts b/hardhat.config.ts index d19a598..0a27a94 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -24,12 +24,6 @@ const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY; // if we define the Oracle deployments at last then DefaultProxyAdmin of current repository will be overwritten by DefaultProxyAdmin of Oracle // when the export deployment command executes independently for each network. const externalDeployments = { - hardhat: [ - "node_modules/@venusprotocol/isolated-pools/deployments/bscmainnet", - "node_modules/@venusprotocol/venus-protocol/deployments/bscmainnet", - "node_modules/@venusprotocol/governance-contracts/deployments/bscmainnet", - "node_modules/@venusprotocol/oracle/deployments/bscmainnet", - ], bsctestnet: [ "node_modules/@venusprotocol/governance-contracts/deployments/bsctestnet", "node_modules/@venusprotocol/oracle/deployments/bsctestnet", @@ -347,7 +341,20 @@ const config: HardhatUserConfig = { artifacts: "./artifacts", }, external: { - deployments: {}, + contracts: [ + { + artifacts: "node_modules/@venusprotocol/governance-contracts/artifacts", + }, + { + artifacts: "node_modules/@venusprotocol/venus-protocol/artifacts", + }, + { + artifacts: "node_modules/@venusprotocol/isolated-pools/artifacts", + }, + { + artifacts: "node_modules/@venusprotocol/oracle/artifacts", + }, + ], }, mocha: { timeout: 200000000, diff --git a/package.json b/package.json index d1694c4..eedf54b 100644 --- a/package.json +++ b/package.json @@ -47,10 +47,13 @@ "@openzeppelin/contracts-upgradeable": "^4.8.3", "@openzeppelin/hardhat-upgrades": "^1.21.0", "@solidity-parser/parser": "^0.13.2", + "@venusprotocol/governance-contracts": "^2.6.0", + "@venusprotocol/isolated-pools": "^3.4.0", + "@venusprotocol/oracle": "^2.7.0", "@venusprotocol/solidity-utilities": "^2.0.3", "@venusprotocol/venus-protocol": "^9.1.0", "ethers": "^5.7.0", - "hardhat-deploy": "^0.11.14", + "hardhat-deploy": "^0.14.0", "module-alias": "^2.2.2" }, "devDependencies": { @@ -76,9 +79,6 @@ "@types/node": "^18.16.3", "@typescript-eslint/eslint-plugin": "^5.44.0", "@typescript-eslint/parser": "^5.44.0", - "@venusprotocol/governance-contracts": "^2.6.0", - "@venusprotocol/isolated-pools": "^3.4.0", - "@venusprotocol/oracle": "^2.7.0", "bignumber.js": "^9.1.1", "chai": "^4.3.7", "dotenv": "^16.0.3", From ff77c2eb93738c152780926d369283391dc425f6 Mon Sep 17 00:00:00 2001 From: Venus Tools Date: Thu, 19 Dec 2024 01:22:55 +0000 Subject: [PATCH 2/2] chore(release): 3.0.1-dev.1 [skip ci] ## [3.0.1-dev.1](https://github.com/VenusProtocol/protocol-reserve/compare/v3.0.0...v3.0.1-dev.1) (2024-12-19) --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d4978a..61e0ed3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## [3.0.1-dev.1](https://github.com/VenusProtocol/protocol-reserve/compare/v3.0.0...v3.0.1-dev.1) (2024-12-19) + ## [3.0.0](https://github.com/VenusProtocol/protocol-reserve/compare/v2.4.0...v3.0.0) (2024-12-18) diff --git a/package.json b/package.json index eedf54b..3e72ddd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@venusprotocol/protocol-reserve", "description": "Venus Protocol contracts to manage the income generated by the protocol", - "version": "3.0.0", + "version": "3.0.1-dev.1", "author": "Venus", "engines": { "node": ">=18.0.0"