@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.
- package/dist/deploy/001-deploy-mock-tokens.d.ts +3 -0
- package/dist/deploy/001-deploy-mock-tokens.js +23 -0
- package/dist/deploy/002-price-oracle.d.ts +2 -0
- package/dist/deploy/002-price-oracle.js +9 -0
- package/dist/deploy/003-price-oracle-configure-feeds.d.ts +2 -0
- package/dist/deploy/003-price-oracle-configure-feeds.js +9 -0
- package/{deploy/004-swap-router.ts → dist/deploy/004-swap-router.d.ts} +0 -3
- package/dist/deploy/004-swap-router.js +8 -0
- package/dist/deploy/005-access-control.d.ts +3 -0
- package/dist/deploy/005-access-control.js +16 -0
- package/dist/deploy/006-deploy-factories.d.ts +3 -0
- package/dist/deploy/006-deploy-factories.js +68 -0
- package/dist/deploy/007-access-control-configure.d.ts +3 -0
- package/dist/deploy/007-access-control-configure.js +73 -0
- package/dist/deploy/008-deploy-pool-lens.d.ts +3 -0
- package/dist/deploy/008-deploy-pool-lens.js +15 -0
- package/dist/deploy/009-deploy-pools.d.ts +3 -0
- package/dist/deploy/009-deploy-pools.js +125 -0
- package/dist/deploy/010-rewards.d.ts +3 -0
- package/dist/deploy/010-rewards.js +76 -0
- package/dist/deploy/011-transfer-pools-ownership.d.ts +3 -0
- package/dist/deploy/011-transfer-pools-ownership.js +75 -0
- package/dist/deploy/012-riskfund-protocolshare.d.ts +3 -0
- package/dist/deploy/012-riskfund-protocolshare.js +139 -0
- package/dist/deploy/013-transfer-funds-ownership.d.ts +3 -0
- package/dist/deploy/013-transfer-funds-ownership.js +46 -0
- package/dist/hardhat.config.d.ts +14 -0
- package/dist/hardhat.config.js +237 -0
- package/dist/helpers/deploymentConfig.d.ts +59 -0
- package/dist/helpers/deploymentConfig.js +836 -0
- package/dist/helpers/utils.d.ts +3 -0
- package/dist/helpers/utils.js +28 -0
- package/package.json +2 -10
- package/deploy/001-deploy-mock-tokens.ts +0 -29
- package/deploy/002-price-oracle.ts +0 -7
- package/deploy/003-price-oracle-configure-feeds.ts +0 -7
- package/deploy/005-access-control.ts +0 -20
- package/deploy/006-deploy-factories.ts +0 -82
- package/deploy/007-access-control-configure.ts +0 -142
- package/deploy/008-deploy-pool-lens.ts +0 -19
- package/deploy/009-deploy-pools.ts +0 -171
- package/deploy/010-rewards.ts +0 -84
- package/deploy/011-transfer-pools-ownership.ts +0 -93
- package/deploy/012-riskfund-protocolshare.ts +0 -140
- package/deploy/013-transfer-funds-ownership.ts +0 -63
- package/helpers/deploymentConfig.ts +0 -897
- package/helpers/utils.ts +0 -24
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
exports.AddressOne = exports.scaleDownBy = exports.convertToUnit = void 0;
|
|
7
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
+
bignumber_js_1.default.config({
|
|
9
|
+
FORMAT: {
|
|
10
|
+
decimalSeparator: ".",
|
|
11
|
+
groupSize: 0,
|
|
12
|
+
groupSeparator: "",
|
|
13
|
+
secondaryGroupSize: 0,
|
|
14
|
+
fractionGroupSeparator: "",
|
|
15
|
+
fractionGroupSize: 0,
|
|
16
|
+
},
|
|
17
|
+
ROUNDING_MODE: bignumber_js_1.default.ROUND_DOWN,
|
|
18
|
+
EXPONENTIAL_AT: 1e9,
|
|
19
|
+
});
|
|
20
|
+
const convertToUnit = (amount, decimals) => {
|
|
21
|
+
return new bignumber_js_1.default(amount).times(new bignumber_js_1.default(10).pow(decimals)).toString();
|
|
22
|
+
};
|
|
23
|
+
exports.convertToUnit = convertToUnit;
|
|
24
|
+
const scaleDownBy = (amount, decimals) => {
|
|
25
|
+
return new bignumber_js_1.default(amount).dividedBy(new bignumber_js_1.default(10).pow(decimals)).toString();
|
|
26
|
+
};
|
|
27
|
+
exports.scaleDownBy = scaleDownBy;
|
|
28
|
+
exports.AddressOne = "0x0000000000000000000000000000000000000001";
|
package/package.json
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venusprotocol/isolated-pools",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"files": [
|
|
6
6
|
"artifacts",
|
|
7
|
-
"
|
|
8
|
-
"helpers",
|
|
7
|
+
"dist",
|
|
9
8
|
"contracts",
|
|
10
9
|
"deployments"
|
|
11
10
|
],
|
|
12
|
-
"exports": {
|
|
13
|
-
"deploy": "./dist/deploy",
|
|
14
|
-
"artifacts": "./artifacts",
|
|
15
|
-
"helpers": "./helpers",
|
|
16
|
-
"contracts": "./contracts",
|
|
17
|
-
"deployments": "./deployments"
|
|
18
|
-
},
|
|
19
11
|
"scripts": {
|
|
20
12
|
"test": "hardhat test",
|
|
21
13
|
"test:integration": "hardhat test tests/integration/index.ts",
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { DeployFunction } from "hardhat-deploy/types";
|
|
2
|
-
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
|
3
|
-
|
|
4
|
-
import { getConfig } from "../helpers/deploymentConfig";
|
|
5
|
-
|
|
6
|
-
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
|
7
|
-
const { deployments, getNamedAccounts }: any = hre;
|
|
8
|
-
const { deploy } = deployments;
|
|
9
|
-
const { deployer } = await getNamedAccounts();
|
|
10
|
-
|
|
11
|
-
const { tokensConfig } = await getConfig(hre.network.name);
|
|
12
|
-
|
|
13
|
-
for (const token of tokensConfig) {
|
|
14
|
-
if (token.isMock) {
|
|
15
|
-
const contractName = `Mock${token.symbol}`;
|
|
16
|
-
await deploy(contractName, {
|
|
17
|
-
from: deployer,
|
|
18
|
-
contract: "MockToken",
|
|
19
|
-
args: [token.name, token.symbol, token.decimals],
|
|
20
|
-
log: true,
|
|
21
|
-
autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
func.tags = ["MockTokens"];
|
|
28
|
-
|
|
29
|
-
export default func;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import deployOracle from "@venusprotocol/oracle/dist/deploy/1-deploy-oracles";
|
|
2
|
-
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
|
3
|
-
|
|
4
|
-
deployOracle.tags = ["OracleDeploy"];
|
|
5
|
-
deployOracle.skip = async (hre: HardhatRuntimeEnvironment) => hre.network.live;
|
|
6
|
-
|
|
7
|
-
export default deployOracle;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import configureOracleFeeds from "@venusprotocol/oracle/dist/deploy/2-configure-feeds";
|
|
2
|
-
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
|
3
|
-
|
|
4
|
-
configureOracleFeeds.tags = ["Oracle"];
|
|
5
|
-
configureOracleFeeds.skip = async (hre: HardhatRuntimeEnvironment) => hre.network.live;
|
|
6
|
-
|
|
7
|
-
export default configureOracleFeeds;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { DeployFunction } from "hardhat-deploy/types";
|
|
2
|
-
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
|
3
|
-
|
|
4
|
-
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
|
5
|
-
const { deployments, getNamedAccounts } = hre;
|
|
6
|
-
const { deploy } = deployments;
|
|
7
|
-
const { deployer } = await getNamedAccounts();
|
|
8
|
-
|
|
9
|
-
await deploy("AccessControlManager", {
|
|
10
|
-
from: deployer,
|
|
11
|
-
args: [],
|
|
12
|
-
log: true,
|
|
13
|
-
autoMine: true,
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
func.tags = ["AccessControl", "il"];
|
|
18
|
-
func.skip = async (hre: HardhatRuntimeEnvironment) => hre.network.live;
|
|
19
|
-
|
|
20
|
-
export default func;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { ethers } from "hardhat";
|
|
2
|
-
import { DeployResult } from "hardhat-deploy/dist/types";
|
|
3
|
-
import { DeployFunction } from "hardhat-deploy/types";
|
|
4
|
-
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
|
5
|
-
|
|
6
|
-
const ADDRESS_ONE = "0x0000000000000000000000000000000000000001";
|
|
7
|
-
const treasuryAddresses: { [network: string]: string } = {
|
|
8
|
-
hardhat: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", // signer[1] from hardhat mnemonic
|
|
9
|
-
bsctestnet: "0xFEA1c651A47FE29dB9b1bf3cC1f224d8D9CFF68C", // one of testnet admin accounts
|
|
10
|
-
bscmainnet: "0xF322942f644A996A617BD29c16bd7d231d9F35E9", // Venus Treasury
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type AcmAddresses = {
|
|
14
|
-
bsctestnet: string;
|
|
15
|
-
bscmainnet: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const acmAddresses: AcmAddresses = {
|
|
19
|
-
bsctestnet: "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA",
|
|
20
|
-
bscmainnet: "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555",
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
|
24
|
-
const { deployments, getNamedAccounts } = hre;
|
|
25
|
-
const { deploy } = deployments;
|
|
26
|
-
const { deployer } = await getNamedAccounts();
|
|
27
|
-
let accessControlManager;
|
|
28
|
-
if (hre.network.live) {
|
|
29
|
-
const networkName = hre.network.name === "bscmainnet" ? "bscmainnet" : "bsctestnet";
|
|
30
|
-
accessControlManager = await ethers.getContractAt("AccessControlManager", acmAddresses[networkName]);
|
|
31
|
-
} else {
|
|
32
|
-
accessControlManager = await ethers.getContract("AccessControlManager");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const vBep20Factory: DeployResult = await deploy("VTokenProxyFactory", {
|
|
36
|
-
from: deployer,
|
|
37
|
-
args: [],
|
|
38
|
-
log: true,
|
|
39
|
-
autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const jumpRateModelFactory: DeployResult = await deploy("JumpRateModelFactory", {
|
|
43
|
-
from: deployer,
|
|
44
|
-
args: [],
|
|
45
|
-
log: true,
|
|
46
|
-
autoMine: true,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const whitePaperRateFactory: DeployResult = await deploy("WhitePaperInterestRateModelFactory", {
|
|
50
|
-
from: deployer,
|
|
51
|
-
args: [],
|
|
52
|
-
log: true,
|
|
53
|
-
autoMine: true,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
await deploy("PoolRegistry", {
|
|
57
|
-
from: deployer,
|
|
58
|
-
contract: "PoolRegistry",
|
|
59
|
-
proxy: {
|
|
60
|
-
owner: deployer,
|
|
61
|
-
proxyContract: "OpenZeppelinTransparentProxy",
|
|
62
|
-
execute: {
|
|
63
|
-
methodName: "initialize",
|
|
64
|
-
args: [
|
|
65
|
-
vBep20Factory.address,
|
|
66
|
-
jumpRateModelFactory.address,
|
|
67
|
-
whitePaperRateFactory.address,
|
|
68
|
-
ADDRESS_ONE,
|
|
69
|
-
treasuryAddresses[hre.network.name],
|
|
70
|
-
accessControlManager.address,
|
|
71
|
-
],
|
|
72
|
-
},
|
|
73
|
-
upgradeIndex: 0,
|
|
74
|
-
},
|
|
75
|
-
autoMine: true,
|
|
76
|
-
log: true,
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
func.tags = ["Factories", "il"];
|
|
81
|
-
|
|
82
|
-
export default func;
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { ethers } from "hardhat";
|
|
2
|
-
import { DeployFunction } from "hardhat-deploy/types";
|
|
3
|
-
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
|
4
|
-
|
|
5
|
-
type AcmAddresses = {
|
|
6
|
-
bsctestnet: string;
|
|
7
|
-
bscmainnet: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const ADDRESSES: AcmAddresses = {
|
|
11
|
-
bsctestnet: "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA",
|
|
12
|
-
bscmainnet: "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555",
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
|
16
|
-
const { deployments, getNamedAccounts } = hre;
|
|
17
|
-
const { deploy } = deployments;
|
|
18
|
-
const { deployer } = await getNamedAccounts();
|
|
19
|
-
const poolRegistry = await ethers.getContract("PoolRegistry");
|
|
20
|
-
const vBep20Factory = await ethers.getContract("VTokenProxyFactory");
|
|
21
|
-
let accessControlManager;
|
|
22
|
-
if (hre.network.live) {
|
|
23
|
-
const networkName = hre.network.name === "bscmainnet" ? "bscmainnet" : "bsctestnet";
|
|
24
|
-
accessControlManager = await ethers.getContractAt("AccessControlManager", ADDRESSES[networkName]);
|
|
25
|
-
} else {
|
|
26
|
-
await deploy("AccessControlManager", {
|
|
27
|
-
from: deployer,
|
|
28
|
-
args: [],
|
|
29
|
-
log: true,
|
|
30
|
-
autoMine: true,
|
|
31
|
-
});
|
|
32
|
-
accessControlManager = await ethers.getContract("AccessControlManager");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
console.log("==================================================");
|
|
36
|
-
console.log("Access Control Initial Configuration: ");
|
|
37
|
-
console.log("==================================================");
|
|
38
|
-
console.log(" Role | Contract | Function Sig");
|
|
39
|
-
console.log("--------------------------------------------------");
|
|
40
|
-
let tx = await accessControlManager.giveCallPermission(
|
|
41
|
-
ethers.constants.AddressZero,
|
|
42
|
-
"setCollateralFactor(address,uint256,uint256)",
|
|
43
|
-
poolRegistry.address,
|
|
44
|
-
);
|
|
45
|
-
await tx.wait();
|
|
46
|
-
|
|
47
|
-
console.log("DEFAULT_ADMIN | PoolRegistry | setCollateralFactor(address,uint256,uint256)");
|
|
48
|
-
|
|
49
|
-
tx = await accessControlManager.giveCallPermission(
|
|
50
|
-
ethers.constants.AddressZero,
|
|
51
|
-
"setMarketSupplyCaps(address[],uint256[])",
|
|
52
|
-
poolRegistry.address,
|
|
53
|
-
);
|
|
54
|
-
await tx.wait();
|
|
55
|
-
|
|
56
|
-
console.log("DEFAULT_ADMIN | PoolRegistry | setMarketSupplyCaps(address[],uint256[])");
|
|
57
|
-
|
|
58
|
-
tx = await accessControlManager.giveCallPermission(
|
|
59
|
-
ethers.constants.AddressZero,
|
|
60
|
-
"setMarketBorrowCaps(address[],uint256[])",
|
|
61
|
-
poolRegistry.address,
|
|
62
|
-
);
|
|
63
|
-
await tx.wait();
|
|
64
|
-
console.log("DEFAULT_ADMIN | PoolRegistry | setMarketBorrowCaps(address[],uint256[])");
|
|
65
|
-
|
|
66
|
-
tx = await accessControlManager.giveCallPermission(
|
|
67
|
-
ethers.constants.AddressZero,
|
|
68
|
-
"setLiquidationIncentive(uint256)",
|
|
69
|
-
poolRegistry.address,
|
|
70
|
-
);
|
|
71
|
-
await tx.wait();
|
|
72
|
-
console.log("DEFAULT_ADMIN | PoolRegistry | setLiquidationIncentive(uint256)");
|
|
73
|
-
|
|
74
|
-
tx = await accessControlManager.giveCallPermission(
|
|
75
|
-
ethers.constants.AddressZero,
|
|
76
|
-
"setCloseFactor(uint256)",
|
|
77
|
-
poolRegistry.address,
|
|
78
|
-
);
|
|
79
|
-
await tx.wait();
|
|
80
|
-
console.log("DEFAULT_ADMIN | PoolRegistry | setCloseFactor(uint256)");
|
|
81
|
-
|
|
82
|
-
tx = await accessControlManager.giveCallPermission(
|
|
83
|
-
ethers.constants.AddressZero,
|
|
84
|
-
"setMinLiquidatableCollateral(uint256)",
|
|
85
|
-
poolRegistry.address,
|
|
86
|
-
);
|
|
87
|
-
await tx.wait();
|
|
88
|
-
console.log("DEFAULT_ADMIN | PoolRegistry | setMinLiquidatableCollateral(uint256)");
|
|
89
|
-
|
|
90
|
-
tx = await accessControlManager.giveCallPermission(
|
|
91
|
-
ethers.constants.AddressZero,
|
|
92
|
-
"supportMarket(address)",
|
|
93
|
-
poolRegistry.address,
|
|
94
|
-
);
|
|
95
|
-
await tx.wait();
|
|
96
|
-
console.log("DEFAULT_ADMIN | PoolRegistry | supportMarket(address)");
|
|
97
|
-
|
|
98
|
-
tx = await accessControlManager.giveCallPermission(
|
|
99
|
-
ethers.constants.AddressZero,
|
|
100
|
-
"setInterestRateModel(address)",
|
|
101
|
-
vBep20Factory.address,
|
|
102
|
-
);
|
|
103
|
-
await tx.wait();
|
|
104
|
-
console.log("DEFAULT_ADMIN | VTokenProxyFactory | setInterestRateModel(address)");
|
|
105
|
-
|
|
106
|
-
tx = await accessControlManager.giveCallPermission(
|
|
107
|
-
ethers.constants.AddressZero,
|
|
108
|
-
"swapPoolsAssets(address[],uint256[],address[][])",
|
|
109
|
-
deployer,
|
|
110
|
-
);
|
|
111
|
-
await tx.wait();
|
|
112
|
-
console.log("DEFAULT_ADMIN | Deployer | swapPoolsAssets(address[],uint256[])");
|
|
113
|
-
|
|
114
|
-
tx = await accessControlManager.giveCallPermission(
|
|
115
|
-
poolRegistry.address,
|
|
116
|
-
"createRegistryPool(string,address,uint256,uint256,uint256,address,uint256,address)",
|
|
117
|
-
deployer,
|
|
118
|
-
);
|
|
119
|
-
await tx.wait();
|
|
120
|
-
console.log(
|
|
121
|
-
"PoolRegistry | Deployer | createRegistryPool(string,address,uint256,uint256,uint256,address,uint256,address)",
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
tx = await accessControlManager.giveCallPermission(poolRegistry.address, "addMarket(AddMarketInput)", deployer);
|
|
125
|
-
await tx.wait();
|
|
126
|
-
console.log("PoolRegistry | Deployer | addMarket(AddMarketInput)");
|
|
127
|
-
|
|
128
|
-
tx = await accessControlManager.giveCallPermission(
|
|
129
|
-
ethers.constants.AddressZero,
|
|
130
|
-
"setRewardTokenSpeeds(address[],uint256[],uint256[])",
|
|
131
|
-
deployer,
|
|
132
|
-
);
|
|
133
|
-
await tx.wait();
|
|
134
|
-
console.log("DEFAULT_ADMIN | Deployer | setRewardTokenSpeeds(address[],uint256[],uint256[])");
|
|
135
|
-
|
|
136
|
-
console.log("--------------------------------------------------");
|
|
137
|
-
console.log("Access Control setup ended successfully");
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
func.tags = ["AccessControlConfig", "il"];
|
|
141
|
-
|
|
142
|
-
export default func;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { DeployFunction } from "hardhat-deploy/types";
|
|
2
|
-
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
|
3
|
-
|
|
4
|
-
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
|
5
|
-
const { deployments, getNamedAccounts } = hre;
|
|
6
|
-
const { deploy } = deployments;
|
|
7
|
-
const { deployer } = await getNamedAccounts();
|
|
8
|
-
|
|
9
|
-
await deploy("PoolLens", {
|
|
10
|
-
from: deployer,
|
|
11
|
-
args: [],
|
|
12
|
-
log: true,
|
|
13
|
-
autoMine: true,
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
func.tags = ["PoolLens", "il"];
|
|
18
|
-
|
|
19
|
-
export default func;
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { ethers } from "hardhat";
|
|
2
|
-
import { DeployResult } from "hardhat-deploy/dist/types";
|
|
3
|
-
import { DeployFunction } from "hardhat-deploy/types";
|
|
4
|
-
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
|
5
|
-
|
|
6
|
-
import { getConfig, getTokenConfig } from "../helpers/deploymentConfig";
|
|
7
|
-
|
|
8
|
-
const treasuryAddresses: { [network: string]: string } = {
|
|
9
|
-
bsctestnet: "0xFEA1c651A47FE29dB9b1bf3cC1f224d8D9CFF68C", // one of testnet admin accounts
|
|
10
|
-
bscmainnet: "0xF322942f644A996A617BD29c16bd7d231d9F35E9", // Venus Treasury
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type AcmAddresses = {
|
|
14
|
-
bsctestnet: string;
|
|
15
|
-
bscmainnet: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const acmAddresses: AcmAddresses = {
|
|
19
|
-
bsctestnet: "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA",
|
|
20
|
-
bscmainnet: "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555",
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
|
24
|
-
const { deployments, getNamedAccounts } = hre;
|
|
25
|
-
const { deploy } = deployments;
|
|
26
|
-
const { deployer } = await getNamedAccounts();
|
|
27
|
-
let tx;
|
|
28
|
-
const priceOracle = await ethers.getContract("ResilientOracle");
|
|
29
|
-
const poolRegistry = await ethers.getContract("PoolRegistry");
|
|
30
|
-
let accessControlManager;
|
|
31
|
-
if (hre.network.live) {
|
|
32
|
-
const networkName = hre.network.name === "bscmainnet" ? "bscmainnet" : "bsctestnet";
|
|
33
|
-
accessControlManager = await ethers.getContractAt("AccessControlManager", acmAddresses[networkName]);
|
|
34
|
-
} else {
|
|
35
|
-
accessControlManager = await ethers.getContract("AccessControlManager");
|
|
36
|
-
}
|
|
37
|
-
const maxLoopsLimit = 150;
|
|
38
|
-
|
|
39
|
-
// Comptroller Beacon
|
|
40
|
-
const comptrollerImpl: DeployResult = await deploy("ComptrollerImpl", {
|
|
41
|
-
contract: "Comptroller",
|
|
42
|
-
from: deployer,
|
|
43
|
-
args: [poolRegistry.address],
|
|
44
|
-
log: true,
|
|
45
|
-
autoMine: true,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const ComptrollerBeacon: DeployResult = await deploy("ComptrollerBeacon", {
|
|
49
|
-
contract: "Beacon",
|
|
50
|
-
from: deployer,
|
|
51
|
-
args: [comptrollerImpl.address],
|
|
52
|
-
log: true,
|
|
53
|
-
autoMine: true,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// VToken Beacon
|
|
57
|
-
const vTokenImpl: DeployResult = await deploy("VtokenImpl", {
|
|
58
|
-
contract: "VToken",
|
|
59
|
-
from: deployer,
|
|
60
|
-
args: [],
|
|
61
|
-
log: true,
|
|
62
|
-
autoMine: true,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const vTokenBeacon: DeployResult = await deploy("VTokenBeacon", {
|
|
66
|
-
contract: "Beacon",
|
|
67
|
-
from: deployer,
|
|
68
|
-
args: [vTokenImpl.address],
|
|
69
|
-
log: true,
|
|
70
|
-
autoMine: true,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const { tokensConfig, poolConfig } = await getConfig(hre.network.name);
|
|
74
|
-
let pools = await poolRegistry.callStatic.getAllPools();
|
|
75
|
-
|
|
76
|
-
for (let i = 0; i < poolConfig.length; i++) {
|
|
77
|
-
const pool = poolConfig[i];
|
|
78
|
-
let comptrollerProxy;
|
|
79
|
-
|
|
80
|
-
if (i >= pools.length) {
|
|
81
|
-
// Create pool
|
|
82
|
-
console.log("Registering new pool with name " + pool.name);
|
|
83
|
-
tx = await poolRegistry.createRegistryPool(
|
|
84
|
-
pool.name,
|
|
85
|
-
ComptrollerBeacon.address,
|
|
86
|
-
pool.closeFactor,
|
|
87
|
-
pool.liquidationIncentive,
|
|
88
|
-
pool.minLiquidatableCollateral,
|
|
89
|
-
priceOracle.address,
|
|
90
|
-
maxLoopsLimit,
|
|
91
|
-
accessControlManager.address,
|
|
92
|
-
);
|
|
93
|
-
await tx.wait();
|
|
94
|
-
console.log("New Pool Registered");
|
|
95
|
-
pools = await poolRegistry.callStatic.getAllPools();
|
|
96
|
-
comptrollerProxy = await ethers.getContractAt("Comptroller", pools[i].comptroller);
|
|
97
|
-
tx = await comptrollerProxy.acceptOwnership();
|
|
98
|
-
await tx.wait();
|
|
99
|
-
} else {
|
|
100
|
-
comptrollerProxy = await ethers.getContractAt("Comptroller", pools[i].comptroller);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Add Markets
|
|
104
|
-
for (const vtoken of pool.vtokens) {
|
|
105
|
-
const {
|
|
106
|
-
name,
|
|
107
|
-
asset,
|
|
108
|
-
symbol,
|
|
109
|
-
rateModel,
|
|
110
|
-
baseRatePerYear,
|
|
111
|
-
multiplierPerYear,
|
|
112
|
-
jumpMultiplierPerYear,
|
|
113
|
-
kink_,
|
|
114
|
-
collateralFactor,
|
|
115
|
-
liquidationThreshold,
|
|
116
|
-
reserveFactor,
|
|
117
|
-
initialSupply,
|
|
118
|
-
supplyCap,
|
|
119
|
-
borrowCap,
|
|
120
|
-
} = vtoken;
|
|
121
|
-
|
|
122
|
-
const token = getTokenConfig(asset, tokensConfig);
|
|
123
|
-
let tokenContract;
|
|
124
|
-
if (token.isMock) {
|
|
125
|
-
tokenContract = await ethers.getContract(`Mock${token.symbol}`);
|
|
126
|
-
console.log("Minting " + initialSupply + " mock tokens to owner");
|
|
127
|
-
tx = await tokenContract.faucet(initialSupply);
|
|
128
|
-
await tx.wait(1);
|
|
129
|
-
} else {
|
|
130
|
-
tokenContract = await ethers.getContractAt(
|
|
131
|
-
"@openzeppelin/contracts/token/ERC20/ERC20.sol:ERC20",
|
|
132
|
-
token.tokenAddress,
|
|
133
|
-
);
|
|
134
|
-
// Make sure that deployer has at least `initialSupply` balance of the token
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
console.log("Approving PoolRegistry for: " + initialSupply);
|
|
138
|
-
tx = await tokenContract.approve(poolRegistry.address, initialSupply);
|
|
139
|
-
await tx.wait(1);
|
|
140
|
-
console.log("Adding market " + name + " to pool " + pool.name);
|
|
141
|
-
tx = await poolRegistry.addMarket({
|
|
142
|
-
comptroller: comptrollerProxy.address,
|
|
143
|
-
asset: tokenContract.address,
|
|
144
|
-
decimals: 8,
|
|
145
|
-
name: name,
|
|
146
|
-
symbol: symbol,
|
|
147
|
-
rateModel: rateModel,
|
|
148
|
-
baseRatePerYear: baseRatePerYear,
|
|
149
|
-
multiplierPerYear: multiplierPerYear,
|
|
150
|
-
jumpMultiplierPerYear: jumpMultiplierPerYear,
|
|
151
|
-
kink_: kink_,
|
|
152
|
-
collateralFactor: collateralFactor,
|
|
153
|
-
liquidationThreshold: liquidationThreshold,
|
|
154
|
-
reserveFactor: reserveFactor,
|
|
155
|
-
accessControlManager: accessControlManager.address,
|
|
156
|
-
beaconAddress: vTokenBeacon.address,
|
|
157
|
-
initialSupply: initialSupply,
|
|
158
|
-
vTokenReceiver: hre.network.name === "hardhat" ? deployer : treasuryAddresses[hre.network.name],
|
|
159
|
-
supplyCap: supplyCap,
|
|
160
|
-
borrowCap: borrowCap,
|
|
161
|
-
});
|
|
162
|
-
await tx.wait();
|
|
163
|
-
console.log(`Market ${name} added to pool ${pool.name}`);
|
|
164
|
-
console.log(`-----------------------------------------`);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
func.tags = ["Pools", "il"];
|
|
170
|
-
|
|
171
|
-
export default func;
|
package/deploy/010-rewards.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { ethers } from "hardhat";
|
|
2
|
-
import { DeployFunction } from "hardhat-deploy/types";
|
|
3
|
-
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
|
4
|
-
|
|
5
|
-
import { getConfig, getTokenAddress, getTokenConfig } from "../helpers/deploymentConfig";
|
|
6
|
-
|
|
7
|
-
type AcmAddresses = {
|
|
8
|
-
bsctestnet: string;
|
|
9
|
-
bscmainnet: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const acmAddresses: AcmAddresses = {
|
|
13
|
-
bsctestnet: "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA",
|
|
14
|
-
bscmainnet: "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555",
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
|
18
|
-
const { deployments, getNamedAccounts } = hre;
|
|
19
|
-
const { deploy } = deployments;
|
|
20
|
-
const { deployer } = await getNamedAccounts();
|
|
21
|
-
const maxLoopsLimit = 150;
|
|
22
|
-
const poolRegistry = await ethers.getContract("PoolRegistry");
|
|
23
|
-
let accessControl;
|
|
24
|
-
if (hre.network.live) {
|
|
25
|
-
const networkName = hre.network.name === "bscmainnet" ? "bscmainnet" : "bsctestnet";
|
|
26
|
-
accessControl = await ethers.getContractAt("AccessControlManager", acmAddresses[networkName]);
|
|
27
|
-
} else {
|
|
28
|
-
accessControl = await ethers.getContract("AccessControlManager");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const { tokensConfig, poolConfig } = await getConfig(hre.network.name);
|
|
32
|
-
const pools = await poolRegistry.callStatic.getAllPools();
|
|
33
|
-
for (let i = 0; i < poolConfig.length; i++) {
|
|
34
|
-
const rewards = poolConfig[i].rewards;
|
|
35
|
-
if (!rewards) continue;
|
|
36
|
-
for (const reward of rewards) {
|
|
37
|
-
const comptrollerAddress = pools[i].comptroller;
|
|
38
|
-
// Get reward token address
|
|
39
|
-
const tokenConfig = getTokenConfig(reward.asset, tokensConfig);
|
|
40
|
-
const rewardTokenAddress = await getTokenAddress(tokenConfig, deployments);
|
|
41
|
-
// Custom contract name so we can obtain the proxy after that easily
|
|
42
|
-
const contractName = "Rewards" + reward.asset + poolConfig[i].name;
|
|
43
|
-
await deploy(contractName, {
|
|
44
|
-
from: deployer,
|
|
45
|
-
contract: "RewardsDistributor",
|
|
46
|
-
proxy: {
|
|
47
|
-
owner: deployer,
|
|
48
|
-
proxyContract: "OpenZeppelinTransparentProxy",
|
|
49
|
-
execute: {
|
|
50
|
-
methodName: "initialize",
|
|
51
|
-
args: [comptrollerAddress, rewardTokenAddress, maxLoopsLimit, accessControl.address],
|
|
52
|
-
},
|
|
53
|
-
upgradeIndex: 0,
|
|
54
|
-
},
|
|
55
|
-
autoMine: true,
|
|
56
|
-
log: true,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const rewardsDistributor = await ethers.getContract(contractName);
|
|
60
|
-
const vTokens: string[] = [];
|
|
61
|
-
for (const marketUnderlying of reward.markets) {
|
|
62
|
-
const assetConfig = getTokenConfig(marketUnderlying, tokensConfig);
|
|
63
|
-
const tokenAddress = await getTokenAddress(assetConfig, deployments);
|
|
64
|
-
const marketAddress = await poolRegistry.getVTokenForAsset(comptrollerAddress, tokenAddress);
|
|
65
|
-
vTokens.push(marketAddress);
|
|
66
|
-
}
|
|
67
|
-
let tx = await rewardsDistributor.setRewardTokenSpeeds(vTokens, reward.supplySpeeds, reward.borrowSpeeds);
|
|
68
|
-
await tx.wait(1);
|
|
69
|
-
const comptrollerProxy = await ethers.getContractAt("Comptroller", pools[i].comptroller);
|
|
70
|
-
try {
|
|
71
|
-
console.log("Adding reward distributor to comptroller " + comptrollerAddress);
|
|
72
|
-
tx = await comptrollerProxy.addRewardsDistributor(rewardsDistributor.address);
|
|
73
|
-
await tx.wait(1);
|
|
74
|
-
console.log("Added rewards distributor sucessfully");
|
|
75
|
-
} catch (e) {
|
|
76
|
-
console.log("Rewards distributor already added.");
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
func.tags = ["Rewards", "il"];
|
|
84
|
-
export default func;
|