-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path005_deploy_reward_controllers.js
55 lines (49 loc) · 2.08 KB
/
005_deploy_reward_controllers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const CONFIG = require("../config.js");
const { network } = require("hardhat");
const func = async function (hre) {
const config = CONFIG[network.name];
const { deployments, getNamedAccounts } = hre;
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
const rewardControllers = [];
const rewardControllerImplementations = [];
let i = 1;
for (const rewardControllerConfig of config["rewardControllersConf"]) {
let startBlock = rewardControllerConfig["startBlock"];
if (!startBlock) {
startBlock = await ethers.provider.getBlockNumber();
}
let epochLength = rewardControllerConfig["epochLength"];
let epochRewardPerBlock = rewardControllerConfig["epochRewardPerBlock"];
let rewardToken = rewardControllerConfig["rewardToken"];
if (!rewardToken || rewardToken === "HATToken") {
rewardToken = (await deployments.get('HATToken')).address;
}
// TODO: This also deploys new implementation every time, need to find out how to only deploy a new proxy but not new implementation
await deploy('RewardController_' + i, {
contract: "RewardController",
from: deployer,
log: true,
proxy: {
proxyContract: "OpenZeppelinTransparentProxy",
execute: {
init: {
methodName: "initialize",
args: [
rewardToken,
(await deployments.get('HATTimelockController')).address,
startBlock,
epochLength,
epochRewardPerBlock
],
}
}
}
});
rewardControllers.push((await deployments.get('RewardController_' + i)).address);
rewardControllerImplementations.push((await deployments.get('RewardController_' + i)).implementation);
i++;
}
};
module.exports = func;
func.tags = ['RewardControllers'];