@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,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const ERC20 = __importStar(require("@openzeppelin/contracts/build/contracts/ERC20.json"));
|
|
27
|
+
const hardhat_1 = require("hardhat");
|
|
28
|
+
const deploymentConfig_1 = require("../helpers/deploymentConfig");
|
|
29
|
+
const utils_1 = require("../helpers/utils");
|
|
30
|
+
const MIN_AMOUNT_TO_CONVERT = (0, utils_1.convertToUnit)(10, 18);
|
|
31
|
+
const MIN_POOL_BAD_DEBT = (0, utils_1.convertToUnit)(1000, 18);
|
|
32
|
+
const maxLoopsLimit = 150;
|
|
33
|
+
const getAllMarkets = async (poolRegistry) => {
|
|
34
|
+
const pools = await poolRegistry.getAllPools();
|
|
35
|
+
const markets = await Promise.all(pools.map(async ({ comptroller }) => {
|
|
36
|
+
const poolComptroller = await hardhat_1.ethers.getContractAt("Comptroller", comptroller);
|
|
37
|
+
const vTokenAddresses = await poolComptroller.getAllMarkets();
|
|
38
|
+
const vTokens = await Promise.all(vTokenAddresses.map((vTokenAddress) => hardhat_1.ethers.getContractAt("VToken", vTokenAddress)));
|
|
39
|
+
return vTokens;
|
|
40
|
+
}));
|
|
41
|
+
return markets.flat();
|
|
42
|
+
};
|
|
43
|
+
const configureVToken = async (vToken, shortfallAddress, protocolShareReserveAddress) => {
|
|
44
|
+
console.log("Setting shortfall contract for vToken: ", vToken.address);
|
|
45
|
+
const tx1 = await vToken.setShortfallContract(shortfallAddress);
|
|
46
|
+
await tx1.wait();
|
|
47
|
+
console.log("Setting protocol share reserve for vToken: ", vToken.address);
|
|
48
|
+
const tx2 = await vToken.setProtocolShareReserve(protocolShareReserveAddress);
|
|
49
|
+
await tx2.wait();
|
|
50
|
+
console.log("Finished configuring vToken: ", vToken.address);
|
|
51
|
+
};
|
|
52
|
+
const acmAddresses = {
|
|
53
|
+
bsctestnet: "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA",
|
|
54
|
+
bscmainnet: "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555",
|
|
55
|
+
};
|
|
56
|
+
const func = async function (hre) {
|
|
57
|
+
const { deployments, getNamedAccounts } = hre;
|
|
58
|
+
const { deploy } = deployments;
|
|
59
|
+
const { deployer } = await getNamedAccounts();
|
|
60
|
+
const { tokensConfig } = await (0, deploymentConfig_1.getConfig)(hre.network.name);
|
|
61
|
+
const busdConfig = (0, deploymentConfig_1.getTokenConfig)("BUSD", tokensConfig);
|
|
62
|
+
let BUSD;
|
|
63
|
+
if (busdConfig.isMock) {
|
|
64
|
+
BUSD = await hardhat_1.ethers.getContract("MockBUSD");
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
BUSD = await hardhat_1.ethers.getContractAt(ERC20.abi, busdConfig.tokenAddress);
|
|
68
|
+
}
|
|
69
|
+
const poolRegistry = await hardhat_1.ethers.getContract("PoolRegistry");
|
|
70
|
+
const deployerSigner = hardhat_1.ethers.provider.getSigner(deployer);
|
|
71
|
+
const swapRouter = await hardhat_1.ethers.getContract("SwapRouter");
|
|
72
|
+
let accessControl;
|
|
73
|
+
if (hre.network.live) {
|
|
74
|
+
const networkName = hre.network.name === "bscmainnet" ? "bscmainnet" : "bsctestnet";
|
|
75
|
+
accessControl = await hardhat_1.ethers.getContractAt("AccessControlManager", acmAddresses[networkName]);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
accessControl = await hardhat_1.ethers.getContract("AccessControlManager");
|
|
79
|
+
}
|
|
80
|
+
const proxyAdmin = await hardhat_1.ethers.getContract("DefaultProxyAdmin");
|
|
81
|
+
const owner = await proxyAdmin.owner();
|
|
82
|
+
await deploy("RiskFund", {
|
|
83
|
+
from: deployer,
|
|
84
|
+
contract: "RiskFund",
|
|
85
|
+
proxy: {
|
|
86
|
+
owner: owner,
|
|
87
|
+
proxyContract: "OpenZeppelinTransparentProxy",
|
|
88
|
+
execute: {
|
|
89
|
+
methodName: "initialize",
|
|
90
|
+
args: [swapRouter.address, MIN_AMOUNT_TO_CONVERT, BUSD.address, accessControl.address, maxLoopsLimit],
|
|
91
|
+
},
|
|
92
|
+
upgradeIndex: 0,
|
|
93
|
+
},
|
|
94
|
+
autoMine: true,
|
|
95
|
+
log: true,
|
|
96
|
+
});
|
|
97
|
+
const riskFund = await hardhat_1.ethers.getContract("RiskFund");
|
|
98
|
+
const shortfallDeployment = await deploy("Shortfall", {
|
|
99
|
+
from: deployer,
|
|
100
|
+
contract: "Shortfall",
|
|
101
|
+
proxy: {
|
|
102
|
+
owner: owner,
|
|
103
|
+
proxyContract: "OpenZeppelinTransparentProxy",
|
|
104
|
+
execute: {
|
|
105
|
+
methodName: "initialize",
|
|
106
|
+
args: [BUSD.address, riskFund.address, MIN_POOL_BAD_DEBT, accessControl.address],
|
|
107
|
+
},
|
|
108
|
+
upgradeIndex: 0,
|
|
109
|
+
},
|
|
110
|
+
autoMine: true,
|
|
111
|
+
log: true,
|
|
112
|
+
});
|
|
113
|
+
const shortfall = await hardhat_1.ethers.getContract("Shortfall");
|
|
114
|
+
const tx1 = await shortfall.connect(deployerSigner).updatePoolRegistry(poolRegistry.address);
|
|
115
|
+
await tx1.wait();
|
|
116
|
+
const tx2 = await riskFund.setShortfallContractAddress(shortfallDeployment.address);
|
|
117
|
+
await tx2.wait(1);
|
|
118
|
+
const protocolShareReserveDeployment = await deploy("ProtocolShareReserve", {
|
|
119
|
+
from: deployer,
|
|
120
|
+
contract: "ProtocolShareReserve",
|
|
121
|
+
proxy: {
|
|
122
|
+
owner: owner,
|
|
123
|
+
proxyContract: "OpenZeppelinTransparentProxy",
|
|
124
|
+
execute: {
|
|
125
|
+
methodName: "initialize",
|
|
126
|
+
args: [deployer, riskFund.address],
|
|
127
|
+
},
|
|
128
|
+
upgradeIndex: 0,
|
|
129
|
+
},
|
|
130
|
+
autoMine: true,
|
|
131
|
+
log: true,
|
|
132
|
+
});
|
|
133
|
+
const allMarkets = await getAllMarkets(poolRegistry);
|
|
134
|
+
for (const market of allMarkets) {
|
|
135
|
+
await configureVToken(market, shortfallDeployment.address, protocolShareReserveDeployment.address);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
func.tags = ["RiskFund", "il"];
|
|
139
|
+
exports.default = func;
|
|
@@ -0,0 +1,46 @@
|
|
|
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 = ["RiskFund", "Shortfall", "ProtocolShareReserve"];
|
|
10
|
+
const func = async function (hre) {
|
|
11
|
+
await transfer2StepOwnerships(contracts, hre.network.name);
|
|
12
|
+
// Transfer ownership to the already added pools
|
|
13
|
+
const poolRegistry = await hardhat_1.ethers.getContract("PoolRegistry");
|
|
14
|
+
const pools = await poolRegistry.callStatic.getAllPools();
|
|
15
|
+
for (const pool of pools) {
|
|
16
|
+
const comptrollerProxy = await hardhat_1.ethers.getContractAt("Comptroller", pool.comptroller);
|
|
17
|
+
const owner = await comptrollerProxy.owner();
|
|
18
|
+
if (owner !== targetOwners[hre.network.name]) {
|
|
19
|
+
const tx = await comptrollerProxy.transferOwnership(targetOwners[hre.network.name]);
|
|
20
|
+
await tx.wait(1);
|
|
21
|
+
const pendingOwner = await comptrollerProxy.pendingOwner();
|
|
22
|
+
console.log(`Comptroller ${comptrollerProxy.address} owner ${owner} sucessfully changed to ${pendingOwner}. Please accept the ownership.`);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
console.error(`Comptroller ${comptrollerProxy} owner ${owner} is equal to target ownership address ${targetOwners[hre.network.name]}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const transfer2StepOwnerships = async (contractNames, networkName) => {
|
|
30
|
+
for (const contractName of contractNames) {
|
|
31
|
+
const contract = await hardhat_1.ethers.getContract(contractName);
|
|
32
|
+
const owner = await contract.owner();
|
|
33
|
+
let tx;
|
|
34
|
+
if (owner !== targetOwners[networkName]) {
|
|
35
|
+
tx = await contract.transferOwnership(targetOwners[networkName]);
|
|
36
|
+
await tx.wait(1);
|
|
37
|
+
const pendingOwner = await contract.pendingOwner();
|
|
38
|
+
console.log(`${contractName} owner ${owner} sucessfully changed to ${pendingOwner}. Please accept the ownership.`);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.error(`${contractName} owner ${owner} is equal to target ownership address ${targetOwners[networkName]}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
func.tags = ["TransferFundsOwnership"];
|
|
46
|
+
exports.default = func;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "module-alias/register";
|
|
2
|
+
import "@nomicfoundation/hardhat-chai-matchers";
|
|
3
|
+
import "@nomicfoundation/hardhat-toolbox";
|
|
4
|
+
import "@nomiclabs/hardhat-ethers";
|
|
5
|
+
import "@nomiclabs/hardhat-etherscan";
|
|
6
|
+
import "@openzeppelin/hardhat-upgrades";
|
|
7
|
+
import "@typechain/hardhat";
|
|
8
|
+
import "hardhat-deploy";
|
|
9
|
+
import "hardhat-gas-reporter";
|
|
10
|
+
import { HardhatUserConfig } from "hardhat/config";
|
|
11
|
+
import "solidity-coverage";
|
|
12
|
+
import "solidity-docgen";
|
|
13
|
+
declare const config: HardhatUserConfig;
|
|
14
|
+
export default config;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
require("module-alias/register");
|
|
27
|
+
require("@nomicfoundation/hardhat-chai-matchers");
|
|
28
|
+
require("@nomicfoundation/hardhat-toolbox");
|
|
29
|
+
require("@nomiclabs/hardhat-ethers");
|
|
30
|
+
require("@nomiclabs/hardhat-etherscan");
|
|
31
|
+
require("@openzeppelin/hardhat-upgrades");
|
|
32
|
+
require("@typechain/hardhat");
|
|
33
|
+
const dotenv = __importStar(require("dotenv"));
|
|
34
|
+
require("hardhat-deploy");
|
|
35
|
+
require("hardhat-gas-reporter");
|
|
36
|
+
const config_1 = require("hardhat/config");
|
|
37
|
+
require("solidity-coverage");
|
|
38
|
+
require("solidity-docgen");
|
|
39
|
+
const utils_1 = require("./helpers/utils");
|
|
40
|
+
dotenv.config();
|
|
41
|
+
// This is a sample Hardhat task. To learn how to create your own go to
|
|
42
|
+
// https://hardhat.org/guides/create-task.html
|
|
43
|
+
(0, config_1.task)("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
|
|
44
|
+
const accounts = await hre.ethers.getSigners();
|
|
45
|
+
for (const account of accounts) {
|
|
46
|
+
console.log(account.address);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
(0, config_1.task)("addMarket", "Add a market to an existing pool")
|
|
50
|
+
.addParam("proxyAdmin", "Admin of vToken proxy")
|
|
51
|
+
.addParam("poolid", "ID of pool to add a market", 1, config_1.types.int)
|
|
52
|
+
.addParam("asset", "asset (ERC20) address", "0x0000000000000000000000000000000000000000", config_1.types.string)
|
|
53
|
+
.addParam("decimals", "asset decimal places", 8, config_1.types.int)
|
|
54
|
+
.addParam("name", "name of the market", undefined, config_1.types.string)
|
|
55
|
+
.addParam("symbol", "symbol of market", undefined, config_1.types.string)
|
|
56
|
+
.addParam("rateModel", "0 - WhitePaper ; 1- JumpRate", 0, config_1.types.int)
|
|
57
|
+
.addParam("baseRate", "base rate per year", 0, config_1.types.int)
|
|
58
|
+
.addParam("multiplier", "multiplier per year", "40000000000000000", config_1.types.string)
|
|
59
|
+
.addParam("jumpMul", "jump multiplier per yer", 0, config_1.types.int)
|
|
60
|
+
.addParam("kink", "kink rate", 0, config_1.types.int)
|
|
61
|
+
.addParam("collFactor", "collateral factor is exonented to 18 decimals (e.g input = input*10**18)", 0.7, config_1.types.float)
|
|
62
|
+
.setAction(async (taskArgs, hre) => {
|
|
63
|
+
const VBep20Immutable = await hre.ethers.getContractFactory("VBep20Immutable");
|
|
64
|
+
const tokenImplementation = await VBep20Immutable.deploy();
|
|
65
|
+
await tokenImplementation.deployed();
|
|
66
|
+
const poolRegistry = await hre.ethers.getContract("PoolRegistry");
|
|
67
|
+
const accessControl = await hre.ethers.getContract("AccessControlManager");
|
|
68
|
+
await poolRegistry.addMarket({
|
|
69
|
+
comptroller: taskArgs.comptroller,
|
|
70
|
+
asset: taskArgs.asset,
|
|
71
|
+
decimals: taskArgs.decimals,
|
|
72
|
+
name: taskArgs.name,
|
|
73
|
+
symbol: taskArgs.symbol,
|
|
74
|
+
rateModel: taskArgs.rateModel,
|
|
75
|
+
baseRatePerYear: taskArgs.baseRate,
|
|
76
|
+
multiplierPerYear: taskArgs.multiplier,
|
|
77
|
+
jumpMultiplierPerYear: taskArgs.jumpMul,
|
|
78
|
+
kink_: taskArgs.kink,
|
|
79
|
+
collateralFactor: (0, utils_1.convertToUnit)(taskArgs.collFactor, 18),
|
|
80
|
+
accessControlManager: accessControl.address,
|
|
81
|
+
vTokenProxyAdmin: taskArgs.proxyAdmin,
|
|
82
|
+
tokenImplementation_: tokenImplementation.address,
|
|
83
|
+
});
|
|
84
|
+
console.log("Market " + taskArgs.name + " added successfully to pool " + taskArgs.comptroller);
|
|
85
|
+
});
|
|
86
|
+
(0, config_1.task)("deployComptroller", "Deploys a Comptroller Implementation")
|
|
87
|
+
.addParam("contractName", "Contract name, later we can load contracts by name")
|
|
88
|
+
.addParam("poolRegistry", "Address of PoolRegistry Contract")
|
|
89
|
+
.addParam("accessControl", "Address of AccessControlManager contract")
|
|
90
|
+
.setAction(async (taskArgs, hre) => {
|
|
91
|
+
const { deployer } = await hre.getNamedAccounts();
|
|
92
|
+
const Comptroller = await hre.deployments.deploy(taskArgs.contractName, {
|
|
93
|
+
contract: "Comptroller",
|
|
94
|
+
from: deployer,
|
|
95
|
+
args: [taskArgs.poolRegistry, taskArgs.accessControl],
|
|
96
|
+
log: true,
|
|
97
|
+
});
|
|
98
|
+
console.log("Comptroller implementation deployed with address: " + Comptroller.address);
|
|
99
|
+
});
|
|
100
|
+
(0, config_1.task)("createPool", "Creates a pool via PoolRegistry")
|
|
101
|
+
.addParam("poolName", "Name of the pool")
|
|
102
|
+
.addParam("comptroller", "Address of comptroller implementation")
|
|
103
|
+
.addParam("oracle", "Contract name, later we can load contracts by name")
|
|
104
|
+
.addParam("closeFactor", "Close factor for pool")
|
|
105
|
+
.addParam("liquidationIncentive", "Liquidation incentive for pool")
|
|
106
|
+
.setAction(async (taskArgs, hre) => {
|
|
107
|
+
const poolRegistry = await hre.ethers.getContract("PoolRegistry");
|
|
108
|
+
await poolRegistry.createRegistryPool(taskArgs.poolName, taskArgs.comptroller, taskArgs.closeFactor, taskArgs.liquidationIncentive, taskArgs.minLiquidatableCollateral, taskArgs.oracle);
|
|
109
|
+
const pools = await poolRegistry.callStatic.getAllPools();
|
|
110
|
+
await hre.ethers.getContractAt("Comptroller", pools[0].comptroller);
|
|
111
|
+
const unitroller = await hre.ethers.getContractAt("Unitroller", pools[0].comptroller);
|
|
112
|
+
await unitroller._acceptAdmin();
|
|
113
|
+
console.log("Pool " + taskArgs.poolName + " has been sucessfully created");
|
|
114
|
+
});
|
|
115
|
+
// You need to export an object to set up your config
|
|
116
|
+
// Go to https://hardhat.org/config/ to learn more
|
|
117
|
+
const config = {
|
|
118
|
+
solidity: {
|
|
119
|
+
compilers: [
|
|
120
|
+
{
|
|
121
|
+
version: "0.8.13",
|
|
122
|
+
settings: {
|
|
123
|
+
optimizer: {
|
|
124
|
+
enabled: true,
|
|
125
|
+
details: {
|
|
126
|
+
yul: !process.env.CI,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
outputSelection: {
|
|
130
|
+
"*": {
|
|
131
|
+
"*": ["storageLayout"],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
version: "0.6.6",
|
|
138
|
+
settings: {
|
|
139
|
+
optimizer: {
|
|
140
|
+
enabled: true,
|
|
141
|
+
details: {
|
|
142
|
+
yul: !process.env.CI,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
outputSelection: {
|
|
146
|
+
"*": {
|
|
147
|
+
"*": ["storageLayout"],
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
networks: {
|
|
155
|
+
hardhat: isFork(),
|
|
156
|
+
development: {
|
|
157
|
+
url: "http://127.0.0.1:8545/",
|
|
158
|
+
chainId: 31337,
|
|
159
|
+
live: false,
|
|
160
|
+
},
|
|
161
|
+
bsctestnet: {
|
|
162
|
+
url: "https://bsc-testnet.public.blastapi.io",
|
|
163
|
+
chainId: 97,
|
|
164
|
+
live: true,
|
|
165
|
+
gasPrice: 20000000000,
|
|
166
|
+
accounts: {
|
|
167
|
+
mnemonic: process.env.MNEMONIC || "",
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
gasReporter: {
|
|
172
|
+
enabled: process.env.REPORT_GAS !== undefined,
|
|
173
|
+
currency: "USD",
|
|
174
|
+
},
|
|
175
|
+
etherscan: {
|
|
176
|
+
customChains: [
|
|
177
|
+
{
|
|
178
|
+
network: "testnet",
|
|
179
|
+
chainId: 97,
|
|
180
|
+
urls: {
|
|
181
|
+
apiURL: "https://api-testnet.bscscan.com/api",
|
|
182
|
+
browserURL: "https://testnet.bscscan.com",
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
paths: {
|
|
188
|
+
tests: "./tests",
|
|
189
|
+
},
|
|
190
|
+
// Hardhat deploy
|
|
191
|
+
namedAccounts: {
|
|
192
|
+
deployer: 0,
|
|
193
|
+
acc1: 1,
|
|
194
|
+
acc2: 2,
|
|
195
|
+
proxyAdmin: 3,
|
|
196
|
+
acc3: 4,
|
|
197
|
+
},
|
|
198
|
+
docgen: {
|
|
199
|
+
outputDir: "./docs",
|
|
200
|
+
pages: "files",
|
|
201
|
+
templates: "./docgen-templates",
|
|
202
|
+
},
|
|
203
|
+
external: {
|
|
204
|
+
contracts: [
|
|
205
|
+
{
|
|
206
|
+
artifacts: "node_modules/@venusprotocol/oracle/artifacts",
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
artifacts: "node_modules/@venusprotocol/venus-protocol/artifacts",
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
deployments: {
|
|
213
|
+
bsctestnet: ["node_modules/@venusprotocol/oracle/deployments/bsctestnet"],
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
function isFork() {
|
|
218
|
+
return process.env.FORK_MAINNET === "true"
|
|
219
|
+
? {
|
|
220
|
+
allowUnlimitedContractSize: false,
|
|
221
|
+
loggingEnabled: false,
|
|
222
|
+
forking: {
|
|
223
|
+
url: `https://white-ultra-silence.bsc.discover.quiknode.pro/${process.env.QUICK_NODE_KEY}/`,
|
|
224
|
+
blockNumber: 21068448,
|
|
225
|
+
},
|
|
226
|
+
accounts: {
|
|
227
|
+
accountsBalance: "1000000000000000000",
|
|
228
|
+
},
|
|
229
|
+
live: false,
|
|
230
|
+
}
|
|
231
|
+
: {
|
|
232
|
+
allowUnlimitedContractSize: true,
|
|
233
|
+
loggingEnabled: false,
|
|
234
|
+
live: false,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
exports.default = config;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DeploymentsExtension } from "hardhat-deploy/types";
|
|
2
|
+
export type NetworkConfig = {
|
|
3
|
+
hardhat: DeploymentConfig;
|
|
4
|
+
bsctestnet: DeploymentConfig;
|
|
5
|
+
bscmainnet: DeploymentConfig;
|
|
6
|
+
};
|
|
7
|
+
export type DeploymentConfig = {
|
|
8
|
+
tokensConfig: TokenConfig[];
|
|
9
|
+
poolConfig: PoolConfig[];
|
|
10
|
+
};
|
|
11
|
+
export type TokenConfig = {
|
|
12
|
+
isMock: boolean;
|
|
13
|
+
name?: string;
|
|
14
|
+
symbol: string;
|
|
15
|
+
decimals?: number;
|
|
16
|
+
tokenAddress: string;
|
|
17
|
+
};
|
|
18
|
+
export type PoolConfig = {
|
|
19
|
+
name: string;
|
|
20
|
+
closeFactor: string;
|
|
21
|
+
liquidationIncentive: string;
|
|
22
|
+
minLiquidatableCollateral: string;
|
|
23
|
+
vtokens: VTokenConfig[];
|
|
24
|
+
rewards?: RewardConfig[];
|
|
25
|
+
};
|
|
26
|
+
export type RewardConfig = {
|
|
27
|
+
asset: string;
|
|
28
|
+
markets: string[];
|
|
29
|
+
supplySpeeds: string[];
|
|
30
|
+
borrowSpeeds: string[];
|
|
31
|
+
};
|
|
32
|
+
export type SpeedConfig = {
|
|
33
|
+
borrowSpeed: string;
|
|
34
|
+
supplySpeed: string;
|
|
35
|
+
};
|
|
36
|
+
export type VTokenConfig = {
|
|
37
|
+
name: string;
|
|
38
|
+
symbol: string;
|
|
39
|
+
asset: string;
|
|
40
|
+
rateModel: string;
|
|
41
|
+
baseRatePerYear: string;
|
|
42
|
+
multiplierPerYear: string;
|
|
43
|
+
jumpMultiplierPerYear: string;
|
|
44
|
+
kink_: string;
|
|
45
|
+
collateralFactor: string;
|
|
46
|
+
liquidationThreshold: string;
|
|
47
|
+
reserveFactor: string;
|
|
48
|
+
initialSupply: string;
|
|
49
|
+
supplyCap: string;
|
|
50
|
+
borrowCap: string;
|
|
51
|
+
};
|
|
52
|
+
export declare enum InterestRateModels {
|
|
53
|
+
WhitePaper = 0,
|
|
54
|
+
JumpRate = 1
|
|
55
|
+
}
|
|
56
|
+
export declare const globalConfig: NetworkConfig;
|
|
57
|
+
export declare function getConfig(networkName: string): Promise<DeploymentConfig>;
|
|
58
|
+
export declare function getTokenConfig(tokenSymbol: string, tokens: TokenConfig[]): TokenConfig;
|
|
59
|
+
export declare function getTokenAddress(tokenConfig: TokenConfig, deployments: DeploymentsExtension): Promise<string>;
|