Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove bscmainnet deployments from hardhat deployments #119

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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"];
// These are mock tokens
func.skip = async hre => hre.network.name !== "hardhat";

export default func;
32 changes: 24 additions & 8 deletions deploy/000-psr.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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");
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
21 changes: 14 additions & 7 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 @@ -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
Loading