From 69caa707168242bda0a84f2d1c794de8722fbc09 Mon Sep 17 00:00:00 2001 From: Alex Sedighi Date: Tue, 9 Jul 2024 03:34:55 +0000 Subject: [PATCH 1/2] feat(Rewards): add deploy script --- script/DeployNodlMigration.sol | 2 +- script/DeployRewards.sol | 46 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 script/DeployRewards.sol diff --git a/script/DeployNodlMigration.sol b/script/DeployNodlMigration.sol index 50894f06..e8ba57b8 100644 --- a/script/DeployNodlMigration.sol +++ b/script/DeployNodlMigration.sol @@ -7,7 +7,7 @@ import {Script, console} from "forge-std/Script.sol"; import {NODL} from "../src/NODL.sol"; import {NODLMigration} from "../src/bridge/NODLMigration.sol"; -contract DeployClick is Script { +contract DeployNodlMigration is Script { address[] internal voters; address internal withdrawer; diff --git a/script/DeployRewards.sol b/script/DeployRewards.sol new file mode 100644 index 00000000..9a8b350b --- /dev/null +++ b/script/DeployRewards.sol @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: BSD-3-Clause-Clear + +pragma solidity 0.8.23; + +import {Script, console} from "forge-std/Script.sol"; + +import {NODL} from "../src/NODL.sol"; +import {Rewards} from "../src/Rewards.sol"; + +contract DeployRewards is Script { + address internal nodlAddress; + address internal oracleAddress; + uint256 internal rewardQuotaPerPeriod; + uint256 internal rewardPeriod; + uint256 internal batchSubmitterIncentive; // in percentage of total rewards in a batch. 1 = 1% + + function setUp() public { + nodlAddress = vm.envOr("N_TOKEN_ADDR", address(0)); + oracleAddress = vm.envAddress("N_REWARDS_ORACLE_ADDR"); + rewardQuotaPerPeriod = vm.envUint("N_REWARDS_QUOTA"); + rewardPeriod = vm.envUint("N_REWARDS_PERIOD"); + batchSubmitterIncentive = vm.envUint("N_REWARDS_SUBMITTER_INCENTIVE"); + } + + function run() public { + vm.startBroadcast(); + + NODL nodl; + if (nodlAddress == address(0)) { + nodl = new NODL(); + nodlAddress = address(nodl); + console.log("Deployed NODL at %s", nodlAddress); + } else { + nodl = NODL(nodlAddress); + } + + Rewards rewards = new Rewards(nodl, rewardQuotaPerPeriod, rewardPeriod, oracleAddress, batchSubmitterIncentive); + address rewardsAddress = address(rewards); + + nodl.grantRole(nodl.MINTER_ROLE(), rewardsAddress); + + vm.stopBroadcast(); + + console.log("Deployed Rewards at %s", rewardsAddress); + } +} From 6509535108702ae04dcf94a7856b5dc3ef7a06f2 Mon Sep 17 00:00:00 2001 From: Eliott Teissonniere <10683430+ETeissonniere@users.noreply.github.com> Date: Mon, 15 Jul 2024 15:04:06 -0700 Subject: [PATCH 2/2] navigate forge quirks --- script/DeployRewards.sol | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/script/DeployRewards.sol b/script/DeployRewards.sol index 9a8b350b..0697a99e 100644 --- a/script/DeployRewards.sol +++ b/script/DeployRewards.sol @@ -24,19 +24,15 @@ contract DeployRewards is Script { function run() public { vm.startBroadcast(); - - NODL nodl; if (nodlAddress == address(0)) { - nodl = new NODL(); - nodlAddress = address(nodl); + NODL token = new NODL(); + nodlAddress = address(token); console.log("Deployed NODL at %s", nodlAddress); - } else { - nodl = NODL(nodlAddress); } + NODL nodl = NODL(nodlAddress); Rewards rewards = new Rewards(nodl, rewardQuotaPerPeriod, rewardPeriod, oracleAddress, batchSubmitterIncentive); address rewardsAddress = address(rewards); - nodl.grantRole(nodl.MINTER_ROLE(), rewardsAddress); vm.stopBroadcast();