@venusprotocol/isolated-pools 2.0.0 → 2.1.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 (31) hide show
  1. package/deployments/bscmainnet/ProtocolShareReserve.json +643 -0
  2. package/deployments/bscmainnet/ProtocolShareReserve_Implementation.json +711 -0
  3. package/deployments/bscmainnet/ProtocolShareReserve_Proxy.json +257 -0
  4. package/deployments/bscmainnet/RiskFund.json +1037 -0
  5. package/deployments/bscmainnet/RiskFund_Implementation.json +1256 -0
  6. package/deployments/bscmainnet/RiskFund_Proxy.json +277 -0
  7. package/deployments/bscmainnet/Shortfall.json +1192 -0
  8. package/deployments/bscmainnet/Shortfall_Implementation.json +1641 -0
  9. package/deployments/bscmainnet/Shortfall_Proxy.json +267 -0
  10. package/deployments/bscmainnet/solcInputs/394b060e0e484d4aa39aea929deecf07.json +210 -0
  11. package/deployments/bscmainnet.json +5815 -793
  12. package/deployments/bsctestnet/ProtocolShareReserve.json +643 -0
  13. package/deployments/bsctestnet/ProtocolShareReserve_Implementation.json +711 -0
  14. package/deployments/bsctestnet/ProtocolShareReserve_Proxy.json +257 -0
  15. package/deployments/bsctestnet/RiskFund.json +1037 -0
  16. package/deployments/bsctestnet/RiskFund_Implementation.json +1256 -0
  17. package/deployments/bsctestnet/RiskFund_Proxy.json +277 -0
  18. package/deployments/bsctestnet/Shortfall.json +1192 -0
  19. package/deployments/bsctestnet/Shortfall_Implementation.json +1641 -0
  20. package/deployments/bsctestnet/Shortfall_Proxy.json +267 -0
  21. package/deployments/bsctestnet/solcInputs/394b060e0e484d4aa39aea929deecf07.json +210 -0
  22. package/deployments/bsctestnet.json +21555 -10486
  23. package/dist/deploy/004-swap-router.d.ts +1 -1
  24. package/dist/deploy/004-swap-router.js +4 -3
  25. package/dist/deploy/014-riskfund-protocolshare.js +36 -76
  26. package/dist/deploy/015-funds-config.js +38 -0
  27. package/dist/hardhat.config.js +7 -9
  28. package/dist/helpers/deploymentConfig.js +5 -3
  29. package/package.json +2 -2
  30. package/dist/deploy/015-transfer-funds-ownership.js +0 -30
  31. /package/dist/deploy/{015-transfer-funds-ownership.d.ts → 015-funds-config.d.ts} +0 -0
@@ -1,2 +1,2 @@
1
- import deploySwapRouter from "@venusprotocol/venus-protocol/deploy/005-deploy-swaprouter";
1
+ import deploySwapRouter from "@venusprotocol/venus-protocol/dist/deploy/006-deploy-swaprouter";
2
2
  export default deploySwapRouter;
@@ -3,6 +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 _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;
6
+ const _006_deploy_swaprouter_1 = __importDefault(require("@venusprotocol/venus-protocol/dist/deploy/006-deploy-swaprouter"));
7
+ _006_deploy_swaprouter_1.default.tags = ["SwapRouter", "il"];
8
+ _006_deploy_swaprouter_1.default.skip = async (hre) => hre.network.live;
9
+ exports.default = _006_deploy_swaprouter_1.default;
@@ -1,82 +1,22 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
- const ERC20 = __importStar(require("@openzeppelin/contracts/build/contracts/ERC20.json"));
27
3
  const hardhat_1 = require("hardhat");
28
4
  const deploymentConfig_1 = require("../helpers/deploymentConfig");
5
+ const deploymentUtils_1 = require("../helpers/deploymentUtils");
29
6
  const utils_1 = require("../helpers/utils");
30
7
  const MIN_AMOUNT_TO_CONVERT = (0, utils_1.convertToUnit)(10, 18);
31
8
  const MIN_POOL_BAD_DEBT = (0, utils_1.convertToUnit)(1000, 18);
32
9
  const maxLoopsLimit = 100;
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
10
  const func = async function (hre) {
57
11
  const { deployments, getNamedAccounts } = hre;
58
12
  const { deploy } = deployments;
59
13
  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
- }
14
+ const { tokensConfig, preconfiguredAddresses } = await (0, deploymentConfig_1.getConfig)(hre.network.name);
15
+ const usdt = await (0, deploymentUtils_1.getUnderlyingToken)("USDT", tokensConfig);
69
16
  const poolRegistry = await hardhat_1.ethers.getContract("PoolRegistry");
70
17
  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
- }
18
+ const swapRouterAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.SwapRouter_CorePool || "SwapRouter", hre);
19
+ const accessControlManagerAddress = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.AccessControlManager || "AccessControlManager", hre);
80
20
  const proxyAdmin = await hardhat_1.ethers.getContract("DefaultProxyAdmin");
81
21
  const owner = await proxyAdmin.owner();
82
22
  await deploy("RiskFund", {
@@ -87,7 +27,7 @@ const func = async function (hre) {
87
27
  proxyContract: "OpenZeppelinTransparentProxy",
88
28
  execute: {
89
29
  methodName: "initialize",
90
- args: [swapRouter.address, MIN_AMOUNT_TO_CONVERT, BUSD.address, accessControl.address, maxLoopsLimit],
30
+ args: [swapRouterAddress, MIN_AMOUNT_TO_CONVERT, usdt.address, accessControlManagerAddress, maxLoopsLimit],
91
31
  },
92
32
  upgradeIndex: 0,
93
33
  },
@@ -103,7 +43,7 @@ const func = async function (hre) {
103
43
  proxyContract: "OpenZeppelinTransparentProxy",
104
44
  execute: {
105
45
  methodName: "initialize",
106
- args: [riskFund.address, MIN_POOL_BAD_DEBT, accessControl.address],
46
+ args: [riskFund.address, MIN_POOL_BAD_DEBT, accessControlManagerAddress],
107
47
  },
108
48
  upgradeIndex: 0,
109
49
  },
@@ -111,11 +51,18 @@ const func = async function (hre) {
111
51
  log: true,
112
52
  });
113
53
  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", {
54
+ if ((await shortfall.poolRegistry()) !== poolRegistry.address) {
55
+ console.log("Setting PoolRegistry address in Shortfall contract");
56
+ const tx = await shortfall.connect(deployerSigner).updatePoolRegistry(poolRegistry.address);
57
+ await tx.wait();
58
+ }
59
+ if ((await riskFund.shortfall()) !== shortfall.address) {
60
+ console.log("Setting Shortfall contract address in RiskFund");
61
+ const tx = await riskFund.setShortfallContractAddress(shortfallDeployment.address);
62
+ await tx.wait(1);
63
+ }
64
+ const protocolIncomeReceiver = await (0, deploymentUtils_1.toAddress)(preconfiguredAddresses.VTreasury, hre);
65
+ await deploy("ProtocolShareReserve", {
119
66
  from: deployer,
120
67
  contract: "ProtocolShareReserve",
121
68
  proxy: {
@@ -123,16 +70,29 @@ const func = async function (hre) {
123
70
  proxyContract: "OpenZeppelinTransparentProxy",
124
71
  execute: {
125
72
  methodName: "initialize",
126
- args: [deployer, riskFund.address],
73
+ args: [protocolIncomeReceiver, riskFund.address],
127
74
  },
128
75
  upgradeIndex: 0,
129
76
  },
130
77
  autoMine: true,
131
78
  log: true,
132
79
  });
133
- const allMarkets = await getAllMarkets(poolRegistry);
134
- for (const market of allMarkets) {
135
- await configureVToken(market, shortfallDeployment.address, protocolShareReserveDeployment.address);
80
+ for (const contractName of ["ProtocolShareReserve", "RiskFund"]) {
81
+ const contract = await hardhat_1.ethers.getContract(contractName);
82
+ if ((await contract.poolRegistry()) !== poolRegistry.address) {
83
+ console.log(`Setting PoolRegistry address in ${contractName} contract`);
84
+ const tx = await contract.setPoolRegistry(poolRegistry.address);
85
+ await tx.wait();
86
+ }
87
+ }
88
+ const targetOwner = preconfiguredAddresses.NormalTimelock || deployer;
89
+ for (const contractName of ["RiskFund", "Shortfall", "ProtocolShareReserve"]) {
90
+ const contract = await hardhat_1.ethers.getContract(contractName);
91
+ if ((await contract.owner()) !== targetOwner && (await contract.pendingOwner()) !== targetOwner) {
92
+ console.log(`Transferring ownership of ${contractName} to ${targetOwner}`);
93
+ const tx = await contract.transferOwnership(targetOwner);
94
+ await tx.wait();
95
+ }
136
96
  }
137
97
  };
138
98
  func.tags = ["RiskFund", "il"];
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const hardhat_1 = require("hardhat");
4
+ const getAllMarkets = async (poolRegistry) => {
5
+ const pools = await poolRegistry.getAllPools();
6
+ const markets = await Promise.all(pools.map(async ({ comptroller }) => {
7
+ const poolComptroller = await hardhat_1.ethers.getContractAt("Comptroller", comptroller);
8
+ const vTokenAddresses = await poolComptroller.getAllMarkets();
9
+ const vTokens = await Promise.all(vTokenAddresses.map((vTokenAddress) => hardhat_1.ethers.getContractAt("VToken", vTokenAddress)));
10
+ return vTokens;
11
+ }));
12
+ return markets.flat();
13
+ };
14
+ const setShortfallAddress = async (vToken, shortfallAddress) => {
15
+ if ((await vToken.shortfall()) !== shortfallAddress) {
16
+ const tx = await vToken.setShortfallContract(shortfallAddress);
17
+ await tx.wait();
18
+ }
19
+ };
20
+ const setProtocolShareReserveAddress = async (vToken, protocolShareReserveAddress) => {
21
+ if ((await vToken.protocolShareReserve()) !== protocolShareReserveAddress) {
22
+ const tx = await vToken.setProtocolShareReserve(protocolShareReserveAddress);
23
+ await tx.wait();
24
+ }
25
+ };
26
+ const func = async function (_) {
27
+ const poolRegistry = await hardhat_1.ethers.getContract("PoolRegistry");
28
+ const vTokens = await getAllMarkets(poolRegistry);
29
+ const protocolShareReserve = await hardhat_1.ethers.getContract("ProtocolShareReserve");
30
+ const shortfall = await hardhat_1.ethers.getContract("Shortfall");
31
+ for (const vToken of vTokens) {
32
+ await setShortfallAddress(vToken, shortfall.address);
33
+ await setProtocolShareReserveAddress(vToken, protocolShareReserve.address);
34
+ }
35
+ };
36
+ func.tags = ["FundsConfig", "il"];
37
+ func.skip = async (hre) => hre.network.live;
38
+ exports.default = func;
@@ -162,17 +162,12 @@ const config = {
162
162
  chainId: 97,
163
163
  live: true,
164
164
  gasPrice: 20000000000,
165
- accounts: {
166
- mnemonic: process.env.MNEMONIC || "",
167
- },
165
+ accounts: process.env.TESTNET_PRIVATE_KEY ? [process.env.TESTNET_PRIVATE_KEY] : [],
168
166
  },
169
167
  bscmainnet: {
170
- url: "https://bsc-dataseed.binance.org/",
168
+ url: "http://127.0.0.1:1248",
171
169
  chainId: 56,
172
- live: true,
173
- accounts: {
174
- mnemonic: process.env.MNEMONIC || "",
175
- },
170
+ timeout: 1200000,
176
171
  },
177
172
  },
178
173
  gasReporter: {
@@ -229,7 +224,10 @@ const config = {
229
224
  },
230
225
  ],
231
226
  deployments: {
232
- bsctestnet: ["node_modules/@venusprotocol/oracle/deployments/bsctestnet"],
227
+ bsctestnet: [
228
+ "node_modules/@venusprotocol/oracle/deployments/bsctestnet",
229
+ "node_modules/@venusprotocol/venus-protocol/deployments/bsctestnet",
230
+ ],
233
231
  },
234
232
  },
235
233
  };
@@ -14,7 +14,7 @@ const preconfiguredAddresses = {
14
14
  VTreasury: "account:deployer",
15
15
  },
16
16
  bsctestnet: {
17
- VTreasury: "0x8b293600c50d6fbdc6ed4251cc75ece29880276f",
17
+ VTreasury: "0x8b293600C50D6fbdc6Ed4251cc75ECe29880276f",
18
18
  NormalTimelock: "0xce10739590001705F7FF231611ba4A48B2820327",
19
19
  FastTrackTimelock: "0x3CFf21b7AF8390fE68799D58727d3b4C25a83cb6",
20
20
  CriticalTimelock: "0x23B893a7C45a5Eb8c8C062b9F32d0D2e43eD286D",
@@ -23,6 +23,7 @@ const preconfiguredAddresses = {
23
23
  PancakeFactory: "0x182859893230dC89b114d6e2D547BFFE30474a21",
24
24
  WBNB: "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd",
25
25
  VBNB_CorePool: "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c",
26
+ SwapRouter_CorePool: "0x83edf1deE1B730b7e8e13C00ba76027D63a51ac0",
26
27
  },
27
28
  bscmainnet: {
28
29
  VTreasury: "0xF322942f644A996A617BD29c16bd7d231d9F35E9",
@@ -34,6 +35,7 @@ const preconfiguredAddresses = {
34
35
  PancakeFactory: "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73",
35
36
  WBNB: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
36
37
  VBNB_CorePool: "0xA07c5b74C9B40447a954e1466938b865b6BBea36",
38
+ SwapRouter_CorePool: "0x8938E6dA30b59c1E27d5f70a94688A89F7c815a4",
37
39
  },
38
40
  };
39
41
  const poolRegistryPermissions = () => {
@@ -123,7 +125,7 @@ exports.globalConfig = {
123
125
  },
124
126
  {
125
127
  isMock: true,
126
- name: "Tether",
128
+ name: "Binance-Peg BSC-USD",
127
129
  symbol: "USDT",
128
130
  decimals: 18,
129
131
  tokenAddress: hardhat_1.ethers.constants.AddressZero,
@@ -1167,7 +1169,7 @@ exports.globalConfig = {
1167
1169
  {
1168
1170
  isMock: false,
1169
1171
  name: "Binance-Peg BSC-USD",
1170
- symbol: "BUSD",
1172
+ symbol: "USDT",
1171
1173
  decimals: 18,
1172
1174
  tokenAddress: "0x55d398326f99059fF775485246999027B3197955",
1173
1175
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@venusprotocol/isolated-pools",
3
- "version": "2.0.0",
3
+ "version": "2.1.0-dev.1",
4
4
  "description": "",
5
5
  "files": [
6
6
  "artifacts",
@@ -70,7 +70,7 @@
70
70
  "@typescript-eslint/parser": "^5.27.1",
71
71
  "@venusprotocol/governance-contracts": "^1.0.0",
72
72
  "@venusprotocol/oracle": "1.7.2",
73
- "@venusprotocol/venus-protocol": "^0.6.0",
73
+ "@venusprotocol/venus-protocol": "3.0.0-dev.18",
74
74
  "bignumber.js": "9.0.0",
75
75
  "chai": "^4.3.6",
76
76
  "dotenv": "^10.0.0",
@@ -1,30 +0,0 @@
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
- };
13
- const transfer2StepOwnerships = async (contractNames, networkName) => {
14
- for (const contractName of contractNames) {
15
- const contract = await hardhat_1.ethers.getContract(contractName);
16
- const owner = await contract.owner();
17
- let tx;
18
- if (owner !== targetOwners[networkName]) {
19
- tx = await contract.transferOwnership(targetOwners[networkName]);
20
- await tx.wait(1);
21
- const pendingOwner = await contract.pendingOwner();
22
- console.log(`${contractName} owner ${owner} sucessfully changed to ${pendingOwner}. Please accept the ownership.`);
23
- }
24
- else {
25
- console.error(`${contractName} owner ${owner} is equal to target ownership address ${targetOwners[networkName]}`);
26
- }
27
- }
28
- };
29
- func.tags = ["TransferFundsOwnership"];
30
- exports.default = func;