Skip to content

Commit

Permalink
refactor: remove bscmainnet deployments from hardhat deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Dec 18, 2024
1 parent 9f3aa01 commit 35fdee7
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 39 deletions.
33 changes: 33 additions & 0 deletions deploy/000-1-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import timelocksDeployment from '@venusprotocol/governance-contracts/dist/deploy/001-source-timelocks'
import accessControlManagerDeployment from '@venusprotocol/governance-contracts/dist/deploy/002-access-control'
import comptrollerDeployment from '@venusprotocol/venus-protocol/dist/deploy/001-comptroller'
import resilientOracleDeployment from '@venusprotocol/oracle/dist/deploy/1-deploy-oracles'
import interestRateModelDeployment from '@venusprotocol/venus-protocol/dist/deploy/002-interest-rate-model'
import mockTokensDeployment from '@venusprotocol/venus-protocol/dist/deploy/003-deploy-VBep20'
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 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'

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"];
// These are mock tokens
func.skip = async hre => hre.network.name !== "hardhat";

export default func;
33 changes: 25 additions & 8 deletions deploy/000-psr.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
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;
Expand Down Expand Up @@ -41,7 +51,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");
Expand Down
2 changes: 1 addition & 1 deletion deploy/001-risk-fund-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
6 changes: 5 additions & 1 deletion deploy/002-risk-fund-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion deploy/004-single-token-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function getBaseAssets(network: NETWORK): Promise<BaseAssets> {
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,
}),
Expand Down
55 changes: 31 additions & 24 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -104,24 +98,24 @@ task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
function isFork() {
return process.env.FORK === "true"
? {
allowUnlimitedContractSize: false,
loggingEnabled: false,
forking: {
url:
process.env[`ARCHIVE_NODE_${process.env.FORKED_NETWORK}`] ||
"https://data-seed-prebsc-1-s1.binance.org:8545",
blockNumber: 21068448,
},
accounts: {
accountsBalance: "1000000000000000000",
},
live: false,
}
allowUnlimitedContractSize: false,
loggingEnabled: false,
forking: {
url:
process.env[`ARCHIVE_NODE_${process.env.FORKED_NETWORK}`] ||
"https://data-seed-prebsc-1-s1.binance.org:8545",
blockNumber: 21068448,
},
accounts: {
accountsBalance: "1000000000000000000",
},
live: false,
}
: {
allowUnlimitedContractSize: true,
loggingEnabled: false,
live: false,
};
allowUnlimitedContractSize: true,
loggingEnabled: false,
live: false,
};
}

const config: HardhatUserConfig = {
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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",
Expand Down

0 comments on commit 35fdee7

Please sign in to comment.