@venusprotocol/isolated-pools 3.7.0 → 3.8.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +10 -0
  2. package/dist/deploy/001-deploy-mock-tokens.js +2 -1
  3. package/dist/deploy/004-swap-router.js +7 -7
  4. package/dist/deploy/006-deploy-pool-registry.js +3 -3
  5. package/dist/deploy/007-deploy-pool-lens.js +1 -1
  6. package/dist/deploy/008-deploy-comptrollers.js +4 -5
  7. package/dist/deploy/009-deploy-vtokens.js +7 -8
  8. package/dist/deploy/010-deploy-reward-distributors.js +5 -5
  9. package/dist/deploy/011-initial-liquidity.js +12 -15
  10. package/dist/deploy/012-transfer-pools-ownership.js +18 -18
  11. package/dist/deploy/013-vip-based-config.js +30 -30
  12. package/dist/deploy/014-riskfund-protocolshare.d.ts +1 -1
  13. package/dist/deploy/014-riskfund-protocolshare.js +4 -4
  14. package/dist/deploy/014-shortfall-protocolshare.js +8 -3
  15. package/dist/deploy/015-funds-config.js +0 -5
  16. package/dist/deploy/018-native-token-gateway.js +3 -3
  17. package/dist/deploy/019-deploy-ir-models.js +3 -5
  18. package/dist/hardhat.config.js +44 -2
  19. package/dist/helpers/deploymentConfig.js +2 -2
  20. package/dist/helpers/deploymentUtils.d.ts +4 -5
  21. package/dist/helpers/deploymentUtils.js +9 -14
  22. package/dist/type-extensions.d.ts +6 -0
  23. package/dist/type-extensions.js +3 -0
  24. package/dist/typechain/factories/IVToken__factory.d.ts +5 -1
  25. package/dist/typechain/factories/IVToken__factory.js +201 -1
  26. package/package.json +5 -4
  27. package/typechain/IVToken.d.ts +341 -4
  28. package/typechain/factories/IVToken__factory.ts +201 -1
  29. package/dist/deploy/016-deploy-beacon-implementations.d.ts +0 -3
  30. package/dist/deploy/016-deploy-beacon-implementations.js +0 -32
  31. package/dist/deploy/017-update-pool-registry.d.ts +0 -3
  32. package/dist/deploy/017-update-pool-registry.js +0 -28
package/README.md CHANGED
@@ -127,6 +127,16 @@ npx hardhat deploy
127
127
  - In the deployment scripts you have added `tags` for example: - `func.tags = ["MockTokens"];`
128
128
  - Once this is done, adding `--tags "<tag_name>,<tag_name>..."` to the deployment command will execute only the scripts containing the tags.
129
129
 
130
+ ### Dry Run / Forked Deployments
131
+
132
+ To simulate what contracts would be deployed on a given network the deployment scripts support running on a forked network. To run the deployment scripts on a forked network the `HARDHAT_FORK_NETWORK` env variable needs to be set.
133
+
134
+ For example
135
+
136
+ ```bash
137
+ HARDHAT_FORK_NETWORK=ethereum npx hardhat deploy
138
+ ```
139
+
130
140
  ### Deployed Contracts
131
141
 
132
142
  Deployed contract abis and addresses are exported in the `deployments` directory. To create a summary export of all contracts deployed to a network run
@@ -5,7 +5,7 @@ const func = async function (hre) {
5
5
  const { deployments, getNamedAccounts } = hre;
6
6
  const { deploy } = deployments;
7
7
  const { deployer } = await getNamedAccounts();
8
- const { tokensConfig } = await (0, deploymentConfig_1.getConfig)(hre.network.name);
8
+ const { tokensConfig } = await (0, deploymentConfig_1.getConfig)(hre.getNetworkName());
9
9
  for (const token of tokensConfig) {
10
10
  if (token.isMock) {
11
11
  const contractName = `Mock${token.symbol}`;
@@ -21,4 +21,5 @@ const func = async function (hre) {
21
21
  }
22
22
  };
23
23
  func.tags = ["MockTokens"];
24
+ func.skip = async (hre) => hre.network.live;
24
25
  exports.default = func;
@@ -15,7 +15,7 @@ const func = async function (hre) {
15
15
  const wBNBAddress = (await deployments.get("WBNB")).address;
16
16
  const vbnbAddress = (await deployments.get("vBNB")).address;
17
17
  // Pancake Factory doesn't exist on hardhat so we are using the testnet address
18
- const pancakeFactoryAddress = hre.network.name === "bscmainnet"
18
+ const pancakeFactoryAddress = hre.getNetworkName() === "bscmainnet"
19
19
  ? bscmainnet_json_1.default.contracts.pancakeFactory.address
20
20
  : bsctestnet_json_1.default.contracts.pancakeFactory.address;
21
21
  await deploy("SwapRouter_DeFi", {
@@ -44,7 +44,7 @@ const func = async function (hre) {
44
44
  autoMine: true,
45
45
  skipIfAlreadyDeployed: true,
46
46
  });
47
- if (hre.network.name !== "bsctestnet") {
47
+ if (hre.getNetworkName() !== "bsctestnet") {
48
48
  const comptrollerStablecoinsAddresses = (await deployments.get("Comptroller_Stablecoins")).address;
49
49
  await deploy("SwapRouter_Stablecoins", {
50
50
  contract: "SwapRouter",
@@ -86,9 +86,9 @@ const func = async function (hre) {
86
86
  func.tags = ["SwapRouter", "il"];
87
87
  // deploySwapRouter.skip = async (hre: HardhatRuntimeEnvironment) => hre.network.live;
88
88
  // Pancake Factory is not deployed on the local network
89
- func.skip = async (hre) => hre.network.name === "sepolia" ||
90
- hre.network.name === "hardhat" ||
91
- hre.network.name === "opbnbtestnet" ||
92
- hre.network.name === "opbnbmainnet" ||
93
- hre.network.name === "ethereum";
89
+ func.skip = async (hre) => hre.getNetworkName() === "sepolia" ||
90
+ hre.getNetworkName() === "hardhat" ||
91
+ hre.getNetworkName() === "opbnbtestnet" ||
92
+ hre.getNetworkName() === "opbnbmainnet" ||
93
+ hre.getNetworkName() === "ethereum";
94
94
  exports.default = func;
@@ -6,9 +6,9 @@ const func = async function (hre) {
6
6
  const { deployments, getNamedAccounts } = hre;
7
7
  const { deploy } = deployments;
8
8
  const { deployer } = await getNamedAccounts();
9
- const { preconfiguredAddresses } = await (0, deploymentConfig_1.getConfig)(hre.network.name);
10
- const accessControlManagerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.AccessControlManager || "AccessControlManager", hre);
11
- const proxyOwnerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.NormalTimelock || "account:deployer", hre);
9
+ const { preconfiguredAddresses } = await (0, deploymentConfig_1.getConfig)(hre.getNetworkName());
10
+ const accessControlManagerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.AccessControlManager || "AccessControlManager");
11
+ const proxyOwnerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.NormalTimelock || "account:deployer");
12
12
  // The reason for this is that the contracts `OptimizedTransparentUpgradeableProxy` and `DefaultProxyAdmin` that the hardhat-deploy
13
13
  // plugin fetches from the artifact is not zk compatible causing the deployments to fail. So we bought it one level up to our repo,
14
14
  // added them to compile using zksync compiler. It is compatible for all networks.
@@ -5,7 +5,7 @@ const func = async function (hre) {
5
5
  const { deployments, getNamedAccounts } = hre;
6
6
  const { deploy } = deployments;
7
7
  const { deployer } = await getNamedAccounts();
8
- const { isTimeBased, blocksPerYear } = (0, deploymentUtils_1.getBlockOrTimestampBasedDeploymentInfo)(hre.network.name);
8
+ const { isTimeBased, blocksPerYear } = (0, deploymentUtils_1.getBlockOrTimestampBasedDeploymentInfo)(hre.getNetworkName());
9
9
  await deploy("PoolLens", {
10
10
  from: deployer,
11
11
  args: [isTimeBased, blocksPerYear],
@@ -7,10 +7,10 @@ const func = async function (hre) {
7
7
  const { deployments, getNamedAccounts } = hre;
8
8
  const { deploy } = deployments;
9
9
  const { deployer } = await getNamedAccounts();
10
- const deploymentConfig = await (0, deploymentConfig_1.getConfig)(hre.network.name);
10
+ const deploymentConfig = await (0, deploymentConfig_1.getConfig)(hre.getNetworkName());
11
11
  const { poolConfig, preconfiguredAddresses } = deploymentConfig;
12
12
  const poolRegistry = await hardhat_1.ethers.getContract("PoolRegistry");
13
- const accessControlManagerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.AccessControlManager || "AccessControlManager", hre);
13
+ const accessControlManagerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.AccessControlManager || "AccessControlManager");
14
14
  const maxLoopsLimit = 100;
15
15
  const comptrollerImpl = await deploy("ComptrollerImpl", {
16
16
  contract: "Comptroller",
@@ -28,11 +28,10 @@ const func = async function (hre) {
28
28
  autoMine: true,
29
29
  skipIfAlreadyDeployed: true,
30
30
  });
31
- const unregisteredPools = await (0, deploymentUtils_1.getUnregisteredPools)(poolConfig, hre);
31
+ const unregisteredPools = await (0, deploymentUtils_1.getUnregisteredPools)(poolConfig);
32
32
  for (const pool of unregisteredPools) {
33
- // Deploying a proxy for Comptroller
34
- console.log(`Deploying a proxy for Comptroller of the pool ${pool.name}`);
35
33
  const Comptroller = await hardhat_1.ethers.getContractFactory("Comptroller");
34
+ // Deploying a proxy for Comptroller
36
35
  await deploy(`Comptroller_${pool.id}`, {
37
36
  from: deployer,
38
37
  contract: "BeaconProxy",
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const _001_psr_1 = __importDefault(require("@venusprotocol/protocol-reserve/dist/deploy/001-psr"));
6
+ const _001_source_timelocks_1 = __importDefault(require("@venusprotocol/governance-contracts/dist/deploy/001-source-timelocks"));
7
+ const _000_psr_1 = __importDefault(require("@venusprotocol/protocol-reserve/dist/deploy/000-psr"));
7
8
  const ethers_1 = require("ethers");
8
9
  const utils_1 = require("ethers/lib/utils");
9
10
  const hardhat_1 = require("hardhat");
@@ -18,10 +19,11 @@ const func = async function (hre) {
18
19
  const { deployments, getNamedAccounts } = hre;
19
20
  const { deploy } = deployments;
20
21
  const { deployer } = await getNamedAccounts();
21
- const { tokensConfig, poolConfig, preconfiguredAddresses } = await (0, deploymentConfig_1.getConfig)(hre.network.name);
22
+ const { tokensConfig, poolConfig, preconfiguredAddresses } = await (0, deploymentConfig_1.getConfig)(hre.getNetworkName());
22
23
  const { isTimeBased, blocksPerYear } = (0, deploymentUtils_1.getBlockOrTimestampBasedDeploymentInfo)(hre.network.name);
23
24
  const maxBorrowRateMantissa = (0, deploymentConfig_1.getMaxBorrowRateMantissa)(hre.network.name);
24
- const accessControlManagerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.AccessControlManager || "AccessControlManager", hre);
25
+ await (0, _001_source_timelocks_1.default)(hre);
26
+ const accessControlManagerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.AccessControlManager || "AccessControlManager");
25
27
  // VToken Beacon
26
28
  const vTokenImpl = await deploy("VTokenImpl", {
27
29
  contract: "VToken",
@@ -39,7 +41,7 @@ const func = async function (hre) {
39
41
  autoMine: true,
40
42
  skipIfAlreadyDeployed: true,
41
43
  });
42
- const poolsWithUnregisteredVTokens = await (0, deploymentUtils_1.getUnregisteredVTokens)(poolConfig, hre);
44
+ const poolsWithUnregisteredVTokens = await (0, deploymentUtils_1.getUnregisteredVTokens)(poolConfig);
43
45
  for (const pool of poolsWithUnregisteredVTokens) {
44
46
  const comptrollerProxy = await hardhat_1.ethers.getContract(`Comptroller_${pool.id}`);
45
47
  // Deploy Markets
@@ -57,7 +59,6 @@ const func = async function (hre) {
57
59
  if (rateModel === deploymentConfig_2.InterestRateModels.JumpRate.toString()) {
58
60
  const [b, m, j, k] = [baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_].map(mantissaToBps);
59
61
  const rateModelName = `JumpRateModelV2_base${b}bps_slope${m}bps_jump${j}bps_kink${k}bps`;
60
- console.log(`Deploying interest rate model ${rateModelName}`);
61
62
  const result = await deploy(rateModelName, {
62
63
  from: deployer,
63
64
  contract: "JumpRateModelV2",
@@ -79,7 +80,6 @@ const func = async function (hre) {
79
80
  else {
80
81
  const [b, m] = [baseRatePerYear, multiplierPerYear].map(mantissaToBps);
81
82
  const rateModelName = `WhitePaperInterestRateModel_base${b}bps_slope${m}bps`;
82
- console.log(`Deploying interest rate model ${rateModelName}`);
83
83
  const result = await deploy(rateModelName, {
84
84
  from: deployer,
85
85
  contract: "WhitePaperInterestRateModel",
@@ -90,7 +90,6 @@ const func = async function (hre) {
90
90
  });
91
91
  rateModelAddress = result.address;
92
92
  }
93
- console.log(`Deploying VToken proxy for ${symbol}`);
94
93
  const VToken = await hardhat_1.ethers.getContractFactory("VToken");
95
94
  const underlyingDecimals = Number(await tokenContract.decimals());
96
95
  const vTokenDecimals = 8;
@@ -101,7 +100,7 @@ const func = async function (hre) {
101
100
  catch (e) {
102
101
  if (!hre.network.live) {
103
102
  console.warn("ProtocolShareReserve contract not found. Deploying address");
104
- await (0, _001_psr_1.default)(hre);
103
+ await (0, _000_psr_1.default)(hre);
105
104
  protocolShareReserveAddress = (await hardhat_1.ethers.getContract("ProtocolShareReserve")).address;
106
105
  }
107
106
  else {
@@ -8,12 +8,12 @@ const func = async function (hre) {
8
8
  const { deploy } = deployments;
9
9
  const { deployer } = await getNamedAccounts();
10
10
  const maxLoopsLimit = 100;
11
- const { tokensConfig, poolConfig, preconfiguredAddresses } = await (0, deploymentConfig_1.getConfig)(hre.network.name);
12
- const { isTimeBased, blocksPerYear } = (0, deploymentUtils_1.getBlockOrTimestampBasedDeploymentInfo)(hre.network.name);
13
- const accessControlAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.AccessControlManager || "AccessControlManager", hre);
14
- const proxyOwnerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.NormalTimelock || "account:deployer", hre);
11
+ const { tokensConfig, poolConfig, preconfiguredAddresses } = await (0, deploymentConfig_1.getConfig)(hre.getNetworkName());
12
+ const { isTimeBased, blocksPerYear } = (0, deploymentUtils_1.getBlockOrTimestampBasedDeploymentInfo)(hre.getNetworkName());
13
+ const accessControlAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.AccessControlManager || "AccessControlManager");
14
+ const proxyOwnerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.NormalTimelock || "account:deployer");
15
15
  const defaultProxyAdmin = await hre.artifacts.readArtifact("hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol:ProxyAdmin");
16
- const pools = await (0, deploymentUtils_1.getUnregisteredRewardsDistributors)(poolConfig, hre);
16
+ const pools = await (0, deploymentUtils_1.getUnregisteredRewardsDistributors)(poolConfig);
17
17
  await deploy("RewardsDistributorImpl", {
18
18
  contract: "RewardsDistributor",
19
19
  from: deployer,
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ethers_1 = require("ethers");
4
+ const hardhat_1 = require("hardhat");
4
5
  const deploymentConfig_1 = require("../helpers/deploymentConfig");
5
6
  const deploymentUtils_1 = require("../helpers/deploymentUtils");
6
7
  const sumAmounts = async (tokens) => {
@@ -10,9 +11,9 @@ const sumAmounts = async (tokens) => {
10
11
  }
11
12
  return amounts;
12
13
  };
13
- const faucetTokens = async (deploymentConfig, hre) => {
14
+ const faucetTokens = async (deploymentConfig) => {
14
15
  const { poolConfig, tokensConfig } = deploymentConfig;
15
- const unregisteredVTokens = await (0, deploymentUtils_1.getUnregisteredVTokens)(poolConfig, hre);
16
+ const unregisteredVTokens = await (0, deploymentUtils_1.getUnregisteredVTokens)(poolConfig);
16
17
  const vTokenConfigs = unregisteredVTokens.map((p) => p.vtokens).flat();
17
18
  const assetsToFaucet = vTokenConfigs
18
19
  .map((v) => (0, deploymentConfig_1.getTokenConfig)(v.asset, tokensConfig))
@@ -30,15 +31,14 @@ const faucetTokens = async (deploymentConfig, hre) => {
30
31
  const tx = await tokenContract.faucet(amount, { gasLimit: 5000000 });
31
32
  await tx.wait(1);
32
33
  }
34
+ return vTokensToFaucet;
33
35
  };
34
- const sendInitialLiquidityToTreasury = async (deploymentConfig, hre) => {
35
- if (hre.network.name == "bscmainnet" || hre.network.name == "ethereum") {
36
+ const sendInitialLiquidityToTreasury = async (deploymentConfig, tokensToFaucet) => {
37
+ if ((0, hardhat_1.getNetworkName)() == "bscmainnet" || (0, hardhat_1.getNetworkName)() == "ethereum") {
36
38
  return;
37
39
  }
38
- const { poolConfig, tokensConfig, preconfiguredAddresses } = deploymentConfig;
39
- const unregisteredVTokens = await (0, deploymentUtils_1.getUnregisteredVTokens)(poolConfig, hre);
40
- const vTokenConfigs = unregisteredVTokens.map((p) => p.vtokens).flat();
41
- const amounts = vTokenConfigs.map((token) => ({
40
+ const { tokensConfig, preconfiguredAddresses } = deploymentConfig;
41
+ const amounts = tokensToFaucet.map((token) => ({
42
42
  symbol: token.asset,
43
43
  amount: ethers_1.BigNumber.from(token.initialSupply),
44
44
  }));
@@ -46,18 +46,15 @@ const sendInitialLiquidityToTreasury = async (deploymentConfig, hre) => {
46
46
  for (const [symbol, amount] of Object.entries(totalAmounts)) {
47
47
  const tokenContract = await (0, deploymentUtils_1.getUnderlyingToken)(symbol, tokensConfig);
48
48
  console.log(`Sending ${amount} ${symbol} to VTreasury`);
49
- console.log(`Token Contract: ${tokenContract.address}`);
50
- console.log(`Token Contract: ${amount.toString()}`);
51
- const treasuryAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.VTreasury || "VTreasury", hre);
52
- console.log(`Token Contract: ${treasuryAddress}`);
49
+ const treasuryAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.VTreasury || "VTreasury");
53
50
  const tx = await tokenContract.transfer(treasuryAddress, amount, { gasLimit: 5000000 });
54
51
  await tx.wait(1);
55
52
  }
56
53
  };
57
54
  const func = async function (hre) {
58
- const deploymentConfig = await (0, deploymentConfig_1.getConfig)(hre.network.name);
59
- await faucetTokens(deploymentConfig, hre);
60
- await sendInitialLiquidityToTreasury(deploymentConfig, hre);
55
+ const deploymentConfig = await (0, deploymentConfig_1.getConfig)(hre.getNetworkName());
56
+ const assetsToFaucet = await faucetTokens(deploymentConfig);
57
+ await sendInitialLiquidityToTreasury(deploymentConfig, assetsToFaucet);
61
58
  };
62
59
  func.tags = ["InitialLiquidity", "il"];
63
60
  exports.default = func;
@@ -2,24 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const hardhat_1 = require("hardhat");
4
4
  const deploymentConfig_1 = require("../helpers/deploymentConfig");
5
- const func = async function (hre) {
6
- const { deployer } = await (0, hardhat_1.getNamedAccounts)();
7
- const { poolConfig, preconfiguredAddresses } = await (0, deploymentConfig_1.getConfig)(hre.network.name);
8
- const targetOwner = preconfiguredAddresses.NormalTimelock || deployer;
9
- const rewardsDistributors = poolConfig
10
- .map((pool) => {
11
- const rewards = pool.rewards || [];
12
- return rewards.map((_, idx) => `RewardsDistributor_${pool.id}_${idx}`);
13
- })
14
- .flat();
15
- const comptrollers = poolConfig.map((pool) => `Comptroller_${pool.id}`);
16
- const contracts = {
17
- singleStepOwnership: ["ComptrollerBeacon", "VTokenBeacon"],
18
- twoStepOwnership: ["PoolRegistry", ...comptrollers, ...rewardsDistributors],
19
- };
20
- await transferSingleStepOwnerships(contracts.singleStepOwnership, targetOwner);
21
- await transfer2StepOwnerships(contracts.twoStepOwnership, targetOwner);
22
- };
23
5
  const transfer2StepOwnerships = async (contractNames, targetOwner) => {
24
6
  const abi = [
25
7
  "function owner() view returns (address)",
@@ -59,6 +41,24 @@ const transferSingleStepOwnerships = async (contractNames, targetOwner) => {
59
41
  }
60
42
  }
61
43
  };
44
+ const func = async function (hre) {
45
+ const { deployer } = await (0, hardhat_1.getNamedAccounts)();
46
+ const { poolConfig, preconfiguredAddresses } = await (0, deploymentConfig_1.getConfig)(hre.getNetworkName());
47
+ const targetOwner = preconfiguredAddresses.NormalTimelock || deployer;
48
+ const rewardsDistributors = poolConfig
49
+ .map((pool) => {
50
+ const rewards = pool.rewards || [];
51
+ return rewards.map((_, idx) => `RewardsDistributor_${pool.id}_${idx}`);
52
+ })
53
+ .flat();
54
+ const comptrollers = poolConfig.map((pool) => `Comptroller_${pool.id}`);
55
+ const contracts = {
56
+ singleStepOwnership: ["ComptrollerBeacon", "VTokenBeacon"],
57
+ twoStepOwnership: ["PoolRegistry", ...comptrollers, ...rewardsDistributors],
58
+ };
59
+ await transferSingleStepOwnerships(contracts.singleStepOwnership, targetOwner);
60
+ await transfer2StepOwnerships(contracts.twoStepOwnership, targetOwner);
61
+ };
62
62
  func.tags = ["TransferPoolsOwnership", "il"];
63
63
  func.id = "transfer_pools_ownership"; // id required to prevent re-execution
64
64
  exports.default = func;
@@ -34,14 +34,14 @@ const setRewardSpeed = async (pool, rewardsDistributor, rewardConfig) => {
34
34
  value: 0,
35
35
  };
36
36
  };
37
- const configureRewards = async (unregisteredRewardDistributors, owner, hre) => {
37
+ const configureRewards = async (unregisteredRewardDistributors, owner) => {
38
38
  const commands = await Promise.all(unregisteredRewardDistributors.map(async (pool) => {
39
39
  const rewards = pool.rewards || [];
40
40
  const poolCommands = await Promise.all(rewards.map(async (rewardConfig, idx) => {
41
41
  const contractName = `RewardsDistributor_${pool.id}_${idx}`;
42
42
  const rewardsDistributor = await hardhat_1.ethers.getContract(contractName);
43
43
  return [
44
- ...(await acceptOwnership(contractName, owner, hre)),
44
+ ...(await acceptOwnership(contractName, owner)),
45
45
  await addRewardsDistributor(rewardsDistributor, pool, rewardConfig),
46
46
  await setRewardSpeed(pool, rewardsDistributor, rewardConfig),
47
47
  ];
@@ -50,12 +50,12 @@ const configureRewards = async (unregisteredRewardDistributors, owner, hre) => {
50
50
  }));
51
51
  return commands.flat();
52
52
  };
53
- const acceptOwnership = async (contractName, targetOwner, hre) => {
54
- if (!hre.network.live) {
53
+ const acceptOwnership = async (contractName, targetOwner) => {
54
+ if (!hardhat_1.network.live) {
55
55
  return [];
56
56
  }
57
57
  const abi = ["function owner() view returns (address)"];
58
- const deployment = await hre.deployments.get(contractName);
58
+ const deployment = await hardhat_1.deployments.get(contractName);
59
59
  const contract = await hardhat_1.ethers.getContractAt(abi, deployment.address);
60
60
  if ((await contract.owner()) === targetOwner) {
61
61
  return [];
@@ -98,20 +98,20 @@ const addPool = (poolRegistry, comptroller, pool) => {
98
98
  value: 0,
99
99
  };
100
100
  };
101
- const addPools = async (unregisteredPools, poolsOwner, hre) => {
101
+ const addPools = async (unregisteredPools, poolsOwner) => {
102
102
  const poolRegistry = await hardhat_1.ethers.getContract("PoolRegistry");
103
103
  const commands = await Promise.all(unregisteredPools.map(async (pool) => {
104
104
  const comptroller = await hardhat_1.ethers.getContract(`Comptroller_${pool.id}`);
105
105
  return [
106
- ...(await acceptOwnership(`Comptroller_${pool.id}`, poolsOwner, hre)),
106
+ ...(await acceptOwnership(`Comptroller_${pool.id}`, poolsOwner)),
107
107
  await setOracle(comptroller, pool),
108
108
  addPool(poolRegistry, comptroller, pool),
109
109
  ];
110
110
  }));
111
111
  return commands.flat();
112
112
  };
113
- const transferInitialLiquidity = async (vTokenConfig, deploymentConfig, hre) => {
114
- if (!hre.network.live) {
113
+ const transferInitialLiquidity = async (vTokenConfig, deploymentConfig) => {
114
+ if (!hardhat_1.network.live) {
115
115
  return [];
116
116
  }
117
117
  const { preconfiguredAddresses, tokensConfig } = deploymentConfig;
@@ -152,10 +152,10 @@ const approvePoolRegistry = async (poolRegistry, vTokenConfig, deploymentConfig)
152
152
  },
153
153
  ];
154
154
  };
155
- const addMarket = async (poolRegistry, vTokenAddress, vTokenConfig, hre) => {
155
+ const addMarket = async (poolRegistry, vTokenAddress, vTokenConfig) => {
156
156
  const { name, collateralFactor, liquidationThreshold, initialSupply, supplyCap, borrowCap } = vTokenConfig;
157
157
  console.log("Adding a command to register " + name + " to PoolRegistry");
158
- const receiver = await (0, deploymentUtils_1.toAddress)(vTokenConfig.vTokenReceiver, hre);
158
+ const receiver = await (0, deploymentUtils_1.toAddress)(vTokenConfig.vTokenReceiver);
159
159
  return {
160
160
  contract: poolRegistry.address,
161
161
  signature: "addMarket((address,uint256,uint256,uint256,address,uint256,uint256))",
@@ -177,7 +177,7 @@ const setReduceReservesBlockDelta = async (vTokenAddress, vTokenConfig) => {
177
177
  value: 0,
178
178
  };
179
179
  };
180
- const addMarkets = async (unregisteredVTokens, deploymentConfig, hre) => {
180
+ const addMarkets = async (unregisteredVTokens, deploymentConfig) => {
181
181
  const poolRegistry = await hardhat_1.ethers.getContract("PoolRegistry");
182
182
  const poolCommands = await Promise.all(unregisteredVTokens.map(async (pool) => {
183
183
  const vTokenCommands = await Promise.all(pool.vtokens.map(async (vTokenConfig) => {
@@ -185,10 +185,10 @@ const addMarkets = async (unregisteredVTokens, deploymentConfig, hre) => {
185
185
  const vToken = await hardhat_1.ethers.getContract(`VToken_${symbol}`);
186
186
  console.log("Adding market " + name + " to pool " + pool.name);
187
187
  return [
188
- ...(await transferInitialLiquidity(vTokenConfig, deploymentConfig, hre)),
188
+ ...(await transferInitialLiquidity(vTokenConfig, deploymentConfig)),
189
189
  ...(await approvePoolRegistry(poolRegistry, vTokenConfig, deploymentConfig)),
190
190
  await setReduceReservesBlockDelta(vToken.address, vTokenConfig),
191
- await addMarket(poolRegistry, vToken.address, vTokenConfig, hre),
191
+ await addMarket(poolRegistry, vToken.address, vTokenConfig),
192
192
  ];
193
193
  }));
194
194
  return vTokenCommands.flat();
@@ -201,19 +201,19 @@ const makeRole = (mainnetBehavior, targetContract, method) => {
201
201
  }
202
202
  return hardhat_1.ethers.utils.keccak256(hardhat_1.ethers.utils.solidityPack(["address", "string"], [targetContract, method]));
203
203
  };
204
- const hasPermission = async (accessControl, targetContract, method, caller, hre) => {
205
- const role = makeRole(hre.network.live, targetContract, method);
204
+ const hasPermission = async (accessControl, targetContract, method, caller) => {
205
+ const role = makeRole(hardhat_1.network.live, targetContract, method);
206
206
  return accessControl.hasRole(role, caller);
207
207
  };
208
- const configureAccessControls = async (deploymentConfig, hre) => {
208
+ const configureAccessControls = async (deploymentConfig) => {
209
209
  const { accessControlConfig, preconfiguredAddresses } = deploymentConfig;
210
- const accessControlManagerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.AccessControlManager || "AccessControlManager", hre);
210
+ const accessControlManagerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.AccessControlManager || "AccessControlManager");
211
211
  const accessControlManager = await hardhat_1.ethers.getContractAt("AccessControlManager", accessControlManagerAddress);
212
212
  const commands = await Promise.all(accessControlConfig.map(async (entry) => {
213
213
  const { caller, target, method } = entry;
214
- const callerAddress = await (0, deploymentUtils_1.toAddress)(caller, hre);
215
- const targetAddress = await (0, deploymentUtils_1.toAddress)(target, hre);
216
- if (await hasPermission(accessControlManager, targetAddress, method, callerAddress, hre)) {
214
+ const callerAddress = await (0, deploymentUtils_1.toAddress)(caller);
215
+ const targetAddress = await (0, deploymentUtils_1.toAddress)(target);
216
+ if (await hasPermission(accessControlManager, targetAddress, method, callerAddress)) {
217
217
  return [];
218
218
  }
219
219
  return [
@@ -253,18 +253,18 @@ const executeCommands = async (commands, hre) => {
253
253
  const func = async function (hre) {
254
254
  const { getNamedAccounts } = hre;
255
255
  const { deployer } = await getNamedAccounts();
256
- const deploymentConfig = await (0, deploymentConfig_1.getConfig)(hre.network.name);
256
+ const deploymentConfig = await (0, deploymentConfig_1.getConfig)(hre.getNetworkName());
257
257
  const { poolConfig, preconfiguredAddresses } = deploymentConfig;
258
- const unregisteredPools = await (0, deploymentUtils_1.getUnregisteredPools)(poolConfig, hre);
259
- const unregisteredVTokens = await (0, deploymentUtils_1.getUnregisteredVTokens)(poolConfig, hre);
260
- const unregisteredRewardsDistributors = await (0, deploymentUtils_1.getUnregisteredRewardsDistributors)(poolConfig, hre);
258
+ const unregisteredPools = await (0, deploymentUtils_1.getUnregisteredPools)(poolConfig);
259
+ const unregisteredVTokens = await (0, deploymentUtils_1.getUnregisteredVTokens)(poolConfig);
260
+ const unregisteredRewardsDistributors = await (0, deploymentUtils_1.getUnregisteredRewardsDistributors)(poolConfig);
261
261
  const owner = preconfiguredAddresses.NormalTimelock || deployer;
262
262
  const commands = [
263
- ...(await configureAccessControls(deploymentConfig, hre)),
264
- ...(await acceptOwnership("PoolRegistry", owner, hre)),
265
- ...(await addPools(unregisteredPools, owner, hre)),
266
- ...(await addMarkets(unregisteredVTokens, deploymentConfig, hre)),
267
- ...(await configureRewards(unregisteredRewardsDistributors, owner, hre)),
263
+ ...(await configureAccessControls(deploymentConfig)),
264
+ ...(await acceptOwnership("PoolRegistry", owner)),
265
+ ...(await addPools(unregisteredPools, owner)),
266
+ ...(await addMarkets(unregisteredVTokens, deploymentConfig)),
267
+ ...(await configureRewards(unregisteredRewardsDistributors, owner)),
268
268
  ];
269
269
  if (hre.network.live) {
270
270
  console.log("Please propose a VIP with the following commands:");
@@ -1,2 +1,2 @@
1
- import deployRiskFund from "@venusprotocol/protocol-reserve/dist/deploy/006-risk-fund-v2";
1
+ import deployRiskFund from "@venusprotocol/protocol-reserve/dist/deploy/001-risk-fund-v2";
2
2
  export default deployRiskFund;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const _006_risk_fund_v2_1 = __importDefault(require("@venusprotocol/protocol-reserve/dist/deploy/006-risk-fund-v2"));
7
- _006_risk_fund_v2_1.default.tags = ["RiskFund", "il"];
8
- _006_risk_fund_v2_1.default.skip = async (hre) => hre.network.live;
9
- exports.default = _006_risk_fund_v2_1.default;
6
+ const _001_risk_fund_v2_1 = __importDefault(require("@venusprotocol/protocol-reserve/dist/deploy/001-risk-fund-v2"));
7
+ _001_risk_fund_v2_1.default.tags = ["RiskFund", "il"];
8
+ _001_risk_fund_v2_1.default.skip = async (hre) => hre.network.live;
9
+ exports.default = _001_risk_fund_v2_1.default;
@@ -11,14 +11,14 @@ const func = async function (hre) {
11
11
  const { deployments, getNamedAccounts } = hre;
12
12
  const { deploy } = deployments;
13
13
  const { deployer } = await getNamedAccounts();
14
- const { preconfiguredAddresses } = await (0, deploymentConfig_1.getConfig)(hre.network.name);
14
+ const { preconfiguredAddresses } = await (0, deploymentConfig_1.getConfig)(hre.getNetworkName());
15
15
  const poolRegistry = await hardhat_1.ethers.getContract("PoolRegistry");
16
16
  const deployerSigner = hardhat_1.ethers.provider.getSigner(deployer);
17
- const accessControlManagerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.AccessControlManager || "AccessControlManager", hre);
17
+ const accessControlManagerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.AccessControlManager || "AccessControlManager");
18
18
  const proxyAdmin = await hardhat_1.ethers.getContract("DefaultProxyAdmin");
19
19
  const owner = await proxyAdmin.owner();
20
20
  const defaultProxyAdmin = await hre.artifacts.readArtifact("hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol:ProxyAdmin");
21
- const { isTimeBased, blocksPerYear } = (0, deploymentUtils_1.getBlockOrTimestampBasedDeploymentInfo)(hre.network.name);
21
+ const { isTimeBased, blocksPerYear } = (0, deploymentUtils_1.getBlockOrTimestampBasedDeploymentInfo)(hre.getNetworkName());
22
22
  const riskFund = await hardhat_1.ethers.getContract("RiskFundV2");
23
23
  await deploy("Shortfall", {
24
24
  from: deployer,
@@ -54,4 +54,9 @@ const func = async function (hre) {
54
54
  }
55
55
  };
56
56
  func.tags = ["Shortfall", "il"];
57
+ // RiskFund not deployed on these networks
58
+ func.skip = async (hre) => hre.getNetworkName() === "sepolia" ||
59
+ hre.getNetworkName() === "opbnbtestnet" ||
60
+ hre.getNetworkName() === "opbnbmainnet" ||
61
+ hre.getNetworkName() === "ethereum";
57
62
  exports.default = func;
@@ -1,9 +1,5 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const _001_psr_1 = __importDefault(require("@venusprotocol/protocol-reserve/dist/deploy/001-psr"));
7
3
  const hardhat_1 = require("hardhat");
8
4
  const getAllMarkets = async (poolRegistry) => {
9
5
  const pools = await poolRegistry.getAllPools();
@@ -37,7 +33,6 @@ const func = async function (hre) {
37
33
  catch (e) {
38
34
  if (!hre.network.live) {
39
35
  console.warn("ProtocolShareReserve contract not found. Deploying address");
40
- await (0, _001_psr_1.default)(hre);
41
36
  protocolShareReserveAddress = (await hardhat_1.ethers.getContract("ProtocolShareReserve")).address;
42
37
  }
43
38
  else {
@@ -129,8 +129,8 @@ const func = async function (hre) {
129
129
  const { deployments, getNamedAccounts } = hre;
130
130
  const { deploy } = deployments;
131
131
  const { deployer } = await getNamedAccounts();
132
- const { preconfiguredAddresses } = await (0, deploymentConfig_1.getConfig)(hre.network.name);
133
- const vWNativesInfo = getVWNativeTokens(hre.network.name);
132
+ const { preconfiguredAddresses } = await (0, deploymentConfig_1.getConfig)(hre.getNetworkName());
133
+ const vWNativesInfo = getVWNativeTokens(hre.getNetworkName());
134
134
  for (const vWNativeInfo of vWNativesInfo) {
135
135
  await deploy(`NativeTokenGateway_${vWNativeInfo.name}`, {
136
136
  contract: "NativeTokenGateway",
@@ -142,7 +142,7 @@ const func = async function (hre) {
142
142
  });
143
143
  const nativeTokenGateway = await hardhat_1.ethers.getContract(`NativeTokenGateway_${vWNativeInfo.name}`);
144
144
  const targetOwner = preconfiguredAddresses.NormalTimelock || deployer;
145
- if (hre.network.live) {
145
+ if (hre.network.live && (await nativeTokenGateway.owner()) !== targetOwner) {
146
146
  const tx = await nativeTokenGateway.transferOwnership(targetOwner);
147
147
  await tx.wait();
148
148
  console.log(`Transferred ownership of NativeTokenGateway_${vWNativeInfo.name} to Timelock`);
@@ -12,9 +12,9 @@ const func = async function (hre) {
12
12
  const { deployments, getNamedAccounts } = hre;
13
13
  const { deploy } = deployments;
14
14
  const { deployer } = await getNamedAccounts();
15
- const { poolConfig, preconfiguredAddresses } = await (0, deploymentConfig_1.getConfig)(hre.network.name);
16
- const { isTimeBased, blocksPerYear } = (0, deploymentUtils_1.getBlockOrTimestampBasedDeploymentInfo)(hre.network.name);
17
- const accessControlManagerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.AccessControlManager || "AccessControlManager", hre);
15
+ const { poolConfig, preconfiguredAddresses } = await (0, deploymentConfig_1.getConfig)(hre.getNetworkName());
16
+ const { isTimeBased, blocksPerYear } = (0, deploymentUtils_1.getBlockOrTimestampBasedDeploymentInfo)(hre.getNetworkName());
17
+ const accessControlManagerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.AccessControlManager || "AccessControlManager");
18
18
  for (const pool of poolConfig) {
19
19
  // Deploy IR Models
20
20
  for (const vtoken of pool.vtokens) {
@@ -22,7 +22,6 @@ const func = async function (hre) {
22
22
  if (rateModel === deploymentConfig_2.InterestRateModels.JumpRate.toString()) {
23
23
  const [b, m, j, k] = [baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_].map(mantissaToBps);
24
24
  const rateModelName = `JumpRateModelV2_base${b}bps_slope${m}bps_jump${j}bps_kink${k}bps`;
25
- console.log(`Deploying interest rate model ${rateModelName}`);
26
25
  await deploy(rateModelName, {
27
26
  from: deployer,
28
27
  contract: "JumpRateModelV2",
@@ -43,7 +42,6 @@ const func = async function (hre) {
43
42
  else {
44
43
  const [b, m] = [baseRatePerYear, multiplierPerYear].map(mantissaToBps);
45
44
  const rateModelName = `WhitePaperInterestRateModel_base${b}bps_slope${m}bps`;
46
- console.log(`Deploying interest rate model ${rateModelName}`);
47
45
  await deploy(rateModelName, {
48
46
  from: deployer,
49
47
  contract: "WhitePaperInterestRateModel",