Skip to content

Commit

Permalink
Update 005_deploy_reward_controllers.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-kaufman committed Jan 5, 2023
1 parent dfd0f05 commit 5837abb
Showing 1 changed file with 28 additions and 31 deletions.
59 changes: 28 additions & 31 deletions deploy/005_deploy_reward_controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ const { network } = require("hardhat");
const func = async function (hre) {
const config = CONFIG[network.name];
const { deployments, getNamedAccounts } = hre;
const { deploy, execute } = deployments;
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) {
Expand All @@ -18,37 +20,32 @@ const func = async function (hre) {
let epochLength = rewardControllerConfig["epochLength"];
let epochRewardPerBlock = rewardControllerConfig["epochRewardPerBlock"];

// console.log(await deploy('RewardController', {
// from: deployer,
// args: [
// (await deployments.get('HATToken')).address,
// (await deployments.get('HATTimelockController')).address,
// startBlock,
// epochLength,
// epochRewardPerBlock
// ],
// log: true,
// proxy: "OptimizedTransparentProxy"
// }));

// const rewardController = await upgrades.deployProxy(RewardController, [
// hatToken,
// governance,
// startBlock,
// epochLength,
// epochRewardPerBlock
// ]);

// await rewardController.deployed();

// const rewardControllerImplementation = RewardController.attach(
// await getImplementationAddress(ethers.provider, rewardController.address)
// );

// rewardControllers.push(rewardController);
// rewardControllerImplementations.push(rewardControllerImplementation);

// 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: [
(await deployments.get('HATToken')).address, // TODO: Allow to set token in the config
(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'];

0 comments on commit 5837abb

Please sign in to comment.