@venusprotocol/isolated-pools 1.0.0-dev.2 → 1.0.0-dev.3

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 (47) hide show
  1. package/dist/deploy/001-deploy-mock-tokens.d.ts +3 -0
  2. package/dist/deploy/001-deploy-mock-tokens.js +23 -0
  3. package/dist/deploy/002-price-oracle.d.ts +2 -0
  4. package/dist/deploy/002-price-oracle.js +9 -0
  5. package/dist/deploy/003-price-oracle-configure-feeds.d.ts +2 -0
  6. package/dist/deploy/003-price-oracle-configure-feeds.js +9 -0
  7. package/{deploy/004-swap-router.ts → dist/deploy/004-swap-router.d.ts} +0 -3
  8. package/dist/deploy/004-swap-router.js +8 -0
  9. package/dist/deploy/005-access-control.d.ts +3 -0
  10. package/dist/deploy/005-access-control.js +16 -0
  11. package/dist/deploy/006-deploy-factories.d.ts +3 -0
  12. package/dist/deploy/006-deploy-factories.js +68 -0
  13. package/dist/deploy/007-access-control-configure.d.ts +3 -0
  14. package/dist/deploy/007-access-control-configure.js +73 -0
  15. package/dist/deploy/008-deploy-pool-lens.d.ts +3 -0
  16. package/dist/deploy/008-deploy-pool-lens.js +15 -0
  17. package/dist/deploy/009-deploy-pools.d.ts +3 -0
  18. package/dist/deploy/009-deploy-pools.js +125 -0
  19. package/dist/deploy/010-rewards.d.ts +3 -0
  20. package/dist/deploy/010-rewards.js +76 -0
  21. package/dist/deploy/011-transfer-pools-ownership.d.ts +3 -0
  22. package/dist/deploy/011-transfer-pools-ownership.js +75 -0
  23. package/dist/deploy/012-riskfund-protocolshare.d.ts +3 -0
  24. package/dist/deploy/012-riskfund-protocolshare.js +139 -0
  25. package/dist/deploy/013-transfer-funds-ownership.d.ts +3 -0
  26. package/dist/deploy/013-transfer-funds-ownership.js +46 -0
  27. package/dist/hardhat.config.d.ts +14 -0
  28. package/dist/hardhat.config.js +237 -0
  29. package/dist/helpers/deploymentConfig.d.ts +59 -0
  30. package/dist/helpers/deploymentConfig.js +836 -0
  31. package/dist/helpers/utils.d.ts +3 -0
  32. package/dist/helpers/utils.js +28 -0
  33. package/package.json +2 -10
  34. package/deploy/001-deploy-mock-tokens.ts +0 -29
  35. package/deploy/002-price-oracle.ts +0 -7
  36. package/deploy/003-price-oracle-configure-feeds.ts +0 -7
  37. package/deploy/005-access-control.ts +0 -20
  38. package/deploy/006-deploy-factories.ts +0 -82
  39. package/deploy/007-access-control-configure.ts +0 -142
  40. package/deploy/008-deploy-pool-lens.ts +0 -19
  41. package/deploy/009-deploy-pools.ts +0 -171
  42. package/deploy/010-rewards.ts +0 -84
  43. package/deploy/011-transfer-pools-ownership.ts +0 -93
  44. package/deploy/012-riskfund-protocolshare.ts +0 -140
  45. package/deploy/013-transfer-funds-ownership.ts +0 -63
  46. package/helpers/deploymentConfig.ts +0 -897
  47. package/helpers/utils.ts +0 -24
@@ -0,0 +1,3 @@
1
+ import { DeployFunction } from "hardhat-deploy/types";
2
+ declare const func: DeployFunction;
3
+ export default func;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const deploymentConfig_1 = require("../helpers/deploymentConfig");
4
+ const func = async function (hre) {
5
+ const { deployments, getNamedAccounts } = hre;
6
+ const { deploy } = deployments;
7
+ const { deployer } = await getNamedAccounts();
8
+ const { tokensConfig } = await (0, deploymentConfig_1.getConfig)(hre.network.name);
9
+ for (const token of tokensConfig) {
10
+ if (token.isMock) {
11
+ const contractName = `Mock${token.symbol}`;
12
+ await deploy(contractName, {
13
+ from: deployer,
14
+ contract: "MockToken",
15
+ args: [token.name, token.symbol, token.decimals],
16
+ log: true,
17
+ autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks
18
+ });
19
+ }
20
+ }
21
+ };
22
+ func.tags = ["MockTokens"];
23
+ exports.default = func;
@@ -0,0 +1,2 @@
1
+ import deployOracle from "@venusprotocol/oracle/dist/deploy/1-deploy-oracles";
2
+ export default deployOracle;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const _1_deploy_oracles_1 = __importDefault(require("@venusprotocol/oracle/dist/deploy/1-deploy-oracles"));
7
+ _1_deploy_oracles_1.default.tags = ["OracleDeploy"];
8
+ _1_deploy_oracles_1.default.skip = async (hre) => hre.network.live;
9
+ exports.default = _1_deploy_oracles_1.default;
@@ -0,0 +1,2 @@
1
+ import configureOracleFeeds from "@venusprotocol/oracle/dist/deploy/2-configure-feeds";
2
+ export default configureOracleFeeds;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const _2_configure_feeds_1 = __importDefault(require("@venusprotocol/oracle/dist/deploy/2-configure-feeds"));
7
+ _2_configure_feeds_1.default.tags = ["Oracle"];
8
+ _2_configure_feeds_1.default.skip = async (hre) => hre.network.live;
9
+ exports.default = _2_configure_feeds_1.default;
@@ -1,5 +1,2 @@
1
1
  import deployOracle from "@venusprotocol/venus-protocol/deploy/005-deploy-swaprouter";
2
-
3
- deployOracle.tags = ["SwapRouter", "il"];
4
-
5
2
  export default deployOracle;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const _005_deploy_swaprouter_1 = __importDefault(require("@venusprotocol/venus-protocol/deploy/005-deploy-swaprouter"));
7
+ _005_deploy_swaprouter_1.default.tags = ["SwapRouter", "il"];
8
+ exports.default = _005_deploy_swaprouter_1.default;
@@ -0,0 +1,3 @@
1
+ import { DeployFunction } from "hardhat-deploy/types";
2
+ declare const func: DeployFunction;
3
+ export default func;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async function (hre) {
4
+ const { deployments, getNamedAccounts } = hre;
5
+ const { deploy } = deployments;
6
+ const { deployer } = await getNamedAccounts();
7
+ await deploy("AccessControlManager", {
8
+ from: deployer,
9
+ args: [],
10
+ log: true,
11
+ autoMine: true,
12
+ });
13
+ };
14
+ func.tags = ["AccessControl", "il"];
15
+ func.skip = async (hre) => hre.network.live;
16
+ exports.default = func;
@@ -0,0 +1,3 @@
1
+ import { DeployFunction } from "hardhat-deploy/types";
2
+ declare const func: DeployFunction;
3
+ export default func;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const hardhat_1 = require("hardhat");
4
+ const ADDRESS_ONE = "0x0000000000000000000000000000000000000001";
5
+ const treasuryAddresses = {
6
+ hardhat: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
7
+ bsctestnet: "0xFEA1c651A47FE29dB9b1bf3cC1f224d8D9CFF68C",
8
+ bscmainnet: "0xF322942f644A996A617BD29c16bd7d231d9F35E9", // Venus Treasury
9
+ };
10
+ const acmAddresses = {
11
+ bsctestnet: "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA",
12
+ bscmainnet: "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555",
13
+ };
14
+ const func = async function (hre) {
15
+ const { deployments, getNamedAccounts } = hre;
16
+ const { deploy } = deployments;
17
+ const { deployer } = await getNamedAccounts();
18
+ let accessControlManager;
19
+ if (hre.network.live) {
20
+ const networkName = hre.network.name === "bscmainnet" ? "bscmainnet" : "bsctestnet";
21
+ accessControlManager = await hardhat_1.ethers.getContractAt("AccessControlManager", acmAddresses[networkName]);
22
+ }
23
+ else {
24
+ accessControlManager = await hardhat_1.ethers.getContract("AccessControlManager");
25
+ }
26
+ const vBep20Factory = await deploy("VTokenProxyFactory", {
27
+ from: deployer,
28
+ args: [],
29
+ log: true,
30
+ autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks
31
+ });
32
+ const jumpRateModelFactory = await deploy("JumpRateModelFactory", {
33
+ from: deployer,
34
+ args: [],
35
+ log: true,
36
+ autoMine: true,
37
+ });
38
+ const whitePaperRateFactory = await deploy("WhitePaperInterestRateModelFactory", {
39
+ from: deployer,
40
+ args: [],
41
+ log: true,
42
+ autoMine: true,
43
+ });
44
+ await deploy("PoolRegistry", {
45
+ from: deployer,
46
+ contract: "PoolRegistry",
47
+ proxy: {
48
+ owner: deployer,
49
+ proxyContract: "OpenZeppelinTransparentProxy",
50
+ execute: {
51
+ methodName: "initialize",
52
+ args: [
53
+ vBep20Factory.address,
54
+ jumpRateModelFactory.address,
55
+ whitePaperRateFactory.address,
56
+ ADDRESS_ONE,
57
+ treasuryAddresses[hre.network.name],
58
+ accessControlManager.address,
59
+ ],
60
+ },
61
+ upgradeIndex: 0,
62
+ },
63
+ autoMine: true,
64
+ log: true,
65
+ });
66
+ };
67
+ func.tags = ["Factories", "il"];
68
+ exports.default = func;
@@ -0,0 +1,3 @@
1
+ import { DeployFunction } from "hardhat-deploy/types";
2
+ declare const func: DeployFunction;
3
+ export default func;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const hardhat_1 = require("hardhat");
4
+ const ADDRESSES = {
5
+ bsctestnet: "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA",
6
+ bscmainnet: "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555",
7
+ };
8
+ const func = async function (hre) {
9
+ const { deployments, getNamedAccounts } = hre;
10
+ const { deploy } = deployments;
11
+ const { deployer } = await getNamedAccounts();
12
+ const poolRegistry = await hardhat_1.ethers.getContract("PoolRegistry");
13
+ const vBep20Factory = await hardhat_1.ethers.getContract("VTokenProxyFactory");
14
+ let accessControlManager;
15
+ if (hre.network.live) {
16
+ const networkName = hre.network.name === "bscmainnet" ? "bscmainnet" : "bsctestnet";
17
+ accessControlManager = await hardhat_1.ethers.getContractAt("AccessControlManager", ADDRESSES[networkName]);
18
+ }
19
+ else {
20
+ await deploy("AccessControlManager", {
21
+ from: deployer,
22
+ args: [],
23
+ log: true,
24
+ autoMine: true,
25
+ });
26
+ accessControlManager = await hardhat_1.ethers.getContract("AccessControlManager");
27
+ }
28
+ console.log("==================================================");
29
+ console.log("Access Control Initial Configuration: ");
30
+ console.log("==================================================");
31
+ console.log(" Role | Contract | Function Sig");
32
+ console.log("--------------------------------------------------");
33
+ let tx = await accessControlManager.giveCallPermission(hardhat_1.ethers.constants.AddressZero, "setCollateralFactor(address,uint256,uint256)", poolRegistry.address);
34
+ await tx.wait();
35
+ console.log("DEFAULT_ADMIN | PoolRegistry | setCollateralFactor(address,uint256,uint256)");
36
+ tx = await accessControlManager.giveCallPermission(hardhat_1.ethers.constants.AddressZero, "setMarketSupplyCaps(address[],uint256[])", poolRegistry.address);
37
+ await tx.wait();
38
+ console.log("DEFAULT_ADMIN | PoolRegistry | setMarketSupplyCaps(address[],uint256[])");
39
+ tx = await accessControlManager.giveCallPermission(hardhat_1.ethers.constants.AddressZero, "setMarketBorrowCaps(address[],uint256[])", poolRegistry.address);
40
+ await tx.wait();
41
+ console.log("DEFAULT_ADMIN | PoolRegistry | setMarketBorrowCaps(address[],uint256[])");
42
+ tx = await accessControlManager.giveCallPermission(hardhat_1.ethers.constants.AddressZero, "setLiquidationIncentive(uint256)", poolRegistry.address);
43
+ await tx.wait();
44
+ console.log("DEFAULT_ADMIN | PoolRegistry | setLiquidationIncentive(uint256)");
45
+ tx = await accessControlManager.giveCallPermission(hardhat_1.ethers.constants.AddressZero, "setCloseFactor(uint256)", poolRegistry.address);
46
+ await tx.wait();
47
+ console.log("DEFAULT_ADMIN | PoolRegistry | setCloseFactor(uint256)");
48
+ tx = await accessControlManager.giveCallPermission(hardhat_1.ethers.constants.AddressZero, "setMinLiquidatableCollateral(uint256)", poolRegistry.address);
49
+ await tx.wait();
50
+ console.log("DEFAULT_ADMIN | PoolRegistry | setMinLiquidatableCollateral(uint256)");
51
+ tx = await accessControlManager.giveCallPermission(hardhat_1.ethers.constants.AddressZero, "supportMarket(address)", poolRegistry.address);
52
+ await tx.wait();
53
+ console.log("DEFAULT_ADMIN | PoolRegistry | supportMarket(address)");
54
+ tx = await accessControlManager.giveCallPermission(hardhat_1.ethers.constants.AddressZero, "setInterestRateModel(address)", vBep20Factory.address);
55
+ await tx.wait();
56
+ console.log("DEFAULT_ADMIN | VTokenProxyFactory | setInterestRateModel(address)");
57
+ tx = await accessControlManager.giveCallPermission(hardhat_1.ethers.constants.AddressZero, "swapPoolsAssets(address[],uint256[],address[][])", deployer);
58
+ await tx.wait();
59
+ console.log("DEFAULT_ADMIN | Deployer | swapPoolsAssets(address[],uint256[])");
60
+ tx = await accessControlManager.giveCallPermission(poolRegistry.address, "createRegistryPool(string,address,uint256,uint256,uint256,address,uint256,address)", deployer);
61
+ await tx.wait();
62
+ console.log("PoolRegistry | Deployer | createRegistryPool(string,address,uint256,uint256,uint256,address,uint256,address)");
63
+ tx = await accessControlManager.giveCallPermission(poolRegistry.address, "addMarket(AddMarketInput)", deployer);
64
+ await tx.wait();
65
+ console.log("PoolRegistry | Deployer | addMarket(AddMarketInput)");
66
+ tx = await accessControlManager.giveCallPermission(hardhat_1.ethers.constants.AddressZero, "setRewardTokenSpeeds(address[],uint256[],uint256[])", deployer);
67
+ await tx.wait();
68
+ console.log("DEFAULT_ADMIN | Deployer | setRewardTokenSpeeds(address[],uint256[],uint256[])");
69
+ console.log("--------------------------------------------------");
70
+ console.log("Access Control setup ended successfully");
71
+ };
72
+ func.tags = ["AccessControlConfig", "il"];
73
+ exports.default = func;
@@ -0,0 +1,3 @@
1
+ import { DeployFunction } from "hardhat-deploy/types";
2
+ declare const func: DeployFunction;
3
+ export default func;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const func = async function (hre) {
4
+ const { deployments, getNamedAccounts } = hre;
5
+ const { deploy } = deployments;
6
+ const { deployer } = await getNamedAccounts();
7
+ await deploy("PoolLens", {
8
+ from: deployer,
9
+ args: [],
10
+ log: true,
11
+ autoMine: true,
12
+ });
13
+ };
14
+ func.tags = ["PoolLens", "il"];
15
+ exports.default = func;
@@ -0,0 +1,3 @@
1
+ import { DeployFunction } from "hardhat-deploy/types";
2
+ declare const func: DeployFunction;
3
+ export default func;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const hardhat_1 = require("hardhat");
4
+ const deploymentConfig_1 = require("../helpers/deploymentConfig");
5
+ const treasuryAddresses = {
6
+ bsctestnet: "0xFEA1c651A47FE29dB9b1bf3cC1f224d8D9CFF68C",
7
+ bscmainnet: "0xF322942f644A996A617BD29c16bd7d231d9F35E9", // Venus Treasury
8
+ };
9
+ const acmAddresses = {
10
+ bsctestnet: "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA",
11
+ bscmainnet: "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555",
12
+ };
13
+ const func = async function (hre) {
14
+ const { deployments, getNamedAccounts } = hre;
15
+ const { deploy } = deployments;
16
+ const { deployer } = await getNamedAccounts();
17
+ let tx;
18
+ const priceOracle = await hardhat_1.ethers.getContract("ResilientOracle");
19
+ const poolRegistry = await hardhat_1.ethers.getContract("PoolRegistry");
20
+ let accessControlManager;
21
+ if (hre.network.live) {
22
+ const networkName = hre.network.name === "bscmainnet" ? "bscmainnet" : "bsctestnet";
23
+ accessControlManager = await hardhat_1.ethers.getContractAt("AccessControlManager", acmAddresses[networkName]);
24
+ }
25
+ else {
26
+ accessControlManager = await hardhat_1.ethers.getContract("AccessControlManager");
27
+ }
28
+ const maxLoopsLimit = 150;
29
+ // Comptroller Beacon
30
+ const comptrollerImpl = await deploy("ComptrollerImpl", {
31
+ contract: "Comptroller",
32
+ from: deployer,
33
+ args: [poolRegistry.address],
34
+ log: true,
35
+ autoMine: true,
36
+ });
37
+ const ComptrollerBeacon = await deploy("ComptrollerBeacon", {
38
+ contract: "Beacon",
39
+ from: deployer,
40
+ args: [comptrollerImpl.address],
41
+ log: true,
42
+ autoMine: true,
43
+ });
44
+ // VToken Beacon
45
+ const vTokenImpl = await deploy("VtokenImpl", {
46
+ contract: "VToken",
47
+ from: deployer,
48
+ args: [],
49
+ log: true,
50
+ autoMine: true,
51
+ });
52
+ const vTokenBeacon = await deploy("VTokenBeacon", {
53
+ contract: "Beacon",
54
+ from: deployer,
55
+ args: [vTokenImpl.address],
56
+ log: true,
57
+ autoMine: true,
58
+ });
59
+ const { tokensConfig, poolConfig } = await (0, deploymentConfig_1.getConfig)(hre.network.name);
60
+ let pools = await poolRegistry.callStatic.getAllPools();
61
+ for (let i = 0; i < poolConfig.length; i++) {
62
+ const pool = poolConfig[i];
63
+ let comptrollerProxy;
64
+ if (i >= pools.length) {
65
+ // Create pool
66
+ console.log("Registering new pool with name " + pool.name);
67
+ tx = await poolRegistry.createRegistryPool(pool.name, ComptrollerBeacon.address, pool.closeFactor, pool.liquidationIncentive, pool.minLiquidatableCollateral, priceOracle.address, maxLoopsLimit, accessControlManager.address);
68
+ await tx.wait();
69
+ console.log("New Pool Registered");
70
+ pools = await poolRegistry.callStatic.getAllPools();
71
+ comptrollerProxy = await hardhat_1.ethers.getContractAt("Comptroller", pools[i].comptroller);
72
+ tx = await comptrollerProxy.acceptOwnership();
73
+ await tx.wait();
74
+ }
75
+ else {
76
+ comptrollerProxy = await hardhat_1.ethers.getContractAt("Comptroller", pools[i].comptroller);
77
+ }
78
+ // Add Markets
79
+ for (const vtoken of pool.vtokens) {
80
+ const { name, asset, symbol, rateModel, baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_, collateralFactor, liquidationThreshold, reserveFactor, initialSupply, supplyCap, borrowCap, } = vtoken;
81
+ const token = (0, deploymentConfig_1.getTokenConfig)(asset, tokensConfig);
82
+ let tokenContract;
83
+ if (token.isMock) {
84
+ tokenContract = await hardhat_1.ethers.getContract(`Mock${token.symbol}`);
85
+ console.log("Minting " + initialSupply + " mock tokens to owner");
86
+ tx = await tokenContract.faucet(initialSupply);
87
+ await tx.wait(1);
88
+ }
89
+ else {
90
+ tokenContract = await hardhat_1.ethers.getContractAt("@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20", token.tokenAddress);
91
+ // Make sure that deployer has at least `initialSupply` balance of the token
92
+ }
93
+ console.log("Approving PoolRegistry for: " + initialSupply);
94
+ tx = await tokenContract.approve(poolRegistry.address, initialSupply);
95
+ await tx.wait(1);
96
+ console.log("Adding market " + name + " to pool " + pool.name);
97
+ tx = await poolRegistry.addMarket({
98
+ comptroller: comptrollerProxy.address,
99
+ asset: tokenContract.address,
100
+ decimals: 8,
101
+ name: name,
102
+ symbol: symbol,
103
+ rateModel: rateModel,
104
+ baseRatePerYear: baseRatePerYear,
105
+ multiplierPerYear: multiplierPerYear,
106
+ jumpMultiplierPerYear: jumpMultiplierPerYear,
107
+ kink_: kink_,
108
+ collateralFactor: collateralFactor,
109
+ liquidationThreshold: liquidationThreshold,
110
+ reserveFactor: reserveFactor,
111
+ accessControlManager: accessControlManager.address,
112
+ beaconAddress: vTokenBeacon.address,
113
+ initialSupply: initialSupply,
114
+ vTokenReceiver: hre.network.name === "hardhat" ? deployer : treasuryAddresses[hre.network.name],
115
+ supplyCap: supplyCap,
116
+ borrowCap: borrowCap,
117
+ });
118
+ await tx.wait();
119
+ console.log(`Market ${name} added to pool ${pool.name}`);
120
+ console.log(`-----------------------------------------`);
121
+ }
122
+ }
123
+ };
124
+ func.tags = ["Pools", "il"];
125
+ exports.default = func;
@@ -0,0 +1,3 @@
1
+ import { DeployFunction } from "hardhat-deploy/types";
2
+ declare const func: DeployFunction;
3
+ export default func;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const hardhat_1 = require("hardhat");
4
+ const deploymentConfig_1 = require("../helpers/deploymentConfig");
5
+ const acmAddresses = {
6
+ bsctestnet: "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA",
7
+ bscmainnet: "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555",
8
+ };
9
+ const func = async function (hre) {
10
+ const { deployments, getNamedAccounts } = hre;
11
+ const { deploy } = deployments;
12
+ const { deployer } = await getNamedAccounts();
13
+ const maxLoopsLimit = 150;
14
+ const poolRegistry = await hardhat_1.ethers.getContract("PoolRegistry");
15
+ let accessControl;
16
+ if (hre.network.live) {
17
+ const networkName = hre.network.name === "bscmainnet" ? "bscmainnet" : "bsctestnet";
18
+ accessControl = await hardhat_1.ethers.getContractAt("AccessControlManager", acmAddresses[networkName]);
19
+ }
20
+ else {
21
+ accessControl = await hardhat_1.ethers.getContract("AccessControlManager");
22
+ }
23
+ const { tokensConfig, poolConfig } = await (0, deploymentConfig_1.getConfig)(hre.network.name);
24
+ const pools = await poolRegistry.callStatic.getAllPools();
25
+ for (let i = 0; i < poolConfig.length; i++) {
26
+ const rewards = poolConfig[i].rewards;
27
+ if (!rewards)
28
+ continue;
29
+ for (const reward of rewards) {
30
+ const comptrollerAddress = pools[i].comptroller;
31
+ // Get reward token address
32
+ const tokenConfig = (0, deploymentConfig_1.getTokenConfig)(reward.asset, tokensConfig);
33
+ const rewardTokenAddress = await (0, deploymentConfig_1.getTokenAddress)(tokenConfig, deployments);
34
+ // Custom contract name so we can obtain the proxy after that easily
35
+ const contractName = "Rewards" + reward.asset + poolConfig[i].name;
36
+ await deploy(contractName, {
37
+ from: deployer,
38
+ contract: "RewardsDistributor",
39
+ proxy: {
40
+ owner: deployer,
41
+ proxyContract: "OpenZeppelinTransparentProxy",
42
+ execute: {
43
+ methodName: "initialize",
44
+ args: [comptrollerAddress, rewardTokenAddress, maxLoopsLimit, accessControl.address],
45
+ },
46
+ upgradeIndex: 0,
47
+ },
48
+ autoMine: true,
49
+ log: true,
50
+ });
51
+ const rewardsDistributor = await hardhat_1.ethers.getContract(contractName);
52
+ const vTokens = [];
53
+ for (const marketUnderlying of reward.markets) {
54
+ const assetConfig = (0, deploymentConfig_1.getTokenConfig)(marketUnderlying, tokensConfig);
55
+ const tokenAddress = await (0, deploymentConfig_1.getTokenAddress)(assetConfig, deployments);
56
+ const marketAddress = await poolRegistry.getVTokenForAsset(comptrollerAddress, tokenAddress);
57
+ vTokens.push(marketAddress);
58
+ }
59
+ let tx = await rewardsDistributor.setRewardTokenSpeeds(vTokens, reward.supplySpeeds, reward.borrowSpeeds);
60
+ await tx.wait(1);
61
+ const comptrollerProxy = await hardhat_1.ethers.getContractAt("Comptroller", pools[i].comptroller);
62
+ try {
63
+ console.log("Adding reward distributor to comptroller " + comptrollerAddress);
64
+ tx = await comptrollerProxy.addRewardsDistributor(rewardsDistributor.address);
65
+ await tx.wait(1);
66
+ console.log("Added rewards distributor sucessfully");
67
+ }
68
+ catch (e) {
69
+ console.log("Rewards distributor already added.");
70
+ continue;
71
+ }
72
+ }
73
+ }
74
+ };
75
+ func.tags = ["Rewards", "il"];
76
+ exports.default = func;
@@ -0,0 +1,3 @@
1
+ import { DeployFunction } from "hardhat-deploy/types";
2
+ declare const func: DeployFunction;
3
+ export default func;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const hardhat_1 = require("hardhat");
4
+ const targetOwners = {
5
+ hardhat: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
6
+ bsctestnet: "0xFA747c4a62c4D168276329F822d004026A1c05E9",
7
+ mainnet: "0x939bD8d64c0A9583A7Dcea9933f7b21697ab6396", // NORMAL VIP Timelock
8
+ };
9
+ const contracts = {
10
+ singleStepOwnership: ["ComptrollerBeacon", "VTokenBeacon", "DefaultProxyAdmin"],
11
+ twoStepOwnership: [
12
+ "PoolRegistry",
13
+ "RewardsBNXPool 1",
14
+ "RewardsXVSPool 1",
15
+ "RewardsANKRPool 2",
16
+ "RewardsXVSPool 2",
17
+ "RewardsMBOXPool 2",
18
+ "RewardsNFTPool 2",
19
+ "RewardsRACAPool 2",
20
+ ],
21
+ };
22
+ const func = async function (hre) {
23
+ await transferSingleStepOwnerships(contracts.singleStepOwnership, hre.network.name);
24
+ await transfer2StepOwnerships(contracts.twoStepOwnership, hre.network.name);
25
+ // Transfer ownership to the already added pools
26
+ const poolRegistry = await hardhat_1.ethers.getContract("PoolRegistry");
27
+ const pools = await poolRegistry.callStatic.getAllPools();
28
+ for (const pool of pools) {
29
+ const comptrollerProxy = await hardhat_1.ethers.getContractAt("Comptroller", pool.comptroller);
30
+ const owner = await comptrollerProxy.owner();
31
+ if (owner !== targetOwners[hre.network.name]) {
32
+ const tx = await comptrollerProxy.transferOwnership(targetOwners[hre.network.name]);
33
+ await tx.wait(1);
34
+ const pendingOwner = await comptrollerProxy.pendingOwner();
35
+ console.log(`Comptroller ${comptrollerProxy.address} owner ${owner} sucessfully changed to ${pendingOwner}. Please accept the ownership.`);
36
+ }
37
+ else {
38
+ console.error(`Comptroller ${comptrollerProxy} owner ${owner} is equal to target ownership address ${targetOwners[hre.network.name]}`);
39
+ }
40
+ }
41
+ };
42
+ const transfer2StepOwnerships = async (contractNames, networkName) => {
43
+ for (const contractName of contractNames) {
44
+ const contract = await hardhat_1.ethers.getContract(contractName);
45
+ const owner = await contract.owner();
46
+ let tx;
47
+ if (owner !== targetOwners[networkName]) {
48
+ tx = await contract.transferOwnership(targetOwners[networkName]);
49
+ await tx.wait(1);
50
+ const pendingOwner = await contract.pendingOwner();
51
+ console.log(`${contractName} owner ${owner} sucessfully changed to ${pendingOwner}. Please accept the ownership.`);
52
+ }
53
+ else {
54
+ console.error(`${contractName} owner ${owner} is equal to target ownership address ${targetOwners[networkName]}`);
55
+ }
56
+ }
57
+ };
58
+ const transferSingleStepOwnerships = async (contractNames, networkName) => {
59
+ for (const contractName of contractNames) {
60
+ const contract = await hardhat_1.ethers.getContract(contractName);
61
+ const owner = await contract.owner();
62
+ let tx;
63
+ if (owner !== targetOwners[networkName]) {
64
+ tx = await contract.transferOwnership(targetOwners[networkName]);
65
+ await tx.wait(1);
66
+ const newOwner = await contract.owner();
67
+ console.log(`${contractName} owner ${owner} sucessfully changed to ${newOwner}.`);
68
+ }
69
+ else {
70
+ console.error(`${contractName} owner ${owner} is equal to target ownership address ${targetOwners[networkName]}`);
71
+ }
72
+ }
73
+ };
74
+ func.tags = ["TransferPoolsOwnership"];
75
+ exports.default = func;
@@ -0,0 +1,3 @@
1
+ import { DeployFunction } from "hardhat-deploy/types";
2
+ declare const func: DeployFunction;
3
+ export default func;