Skip to content

Commit

Permalink
rename RestakingRewardsDepositor
Browse files Browse the repository at this point in the history
  • Loading branch information
bxmmm1 committed Oct 24, 2024
1 parent c961abe commit bc9b5fd
Show file tree
Hide file tree
Showing 18 changed files with 259 additions and 285 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0 <0.9.0;

import { Script } from "forge-std/Script.sol";
import { AccessManager } from "@openzeppelin/contracts/access/manager/AccessManager.sol";
import { Multicall } from "@openzeppelin/contracts/utils/Multicall.sol";
import { ROLE_ID_DAO, ROLE_ID_OPERATIONS_MULTISIG, ROLE_ID_RESTAKING_REWARDS_DEPOSITOR } from "../../script/Roles.sol";
import { PufferRevenueDepositor } from "../../src/PufferRevenueDepositor.sol";

contract GenerateRevenueDepositorCalldata is Script {
function run(address revenueDepositorProxy, address operationsMultisig) public pure returns (bytes memory) {
bytes[] memory calldatas = new bytes[](5);

bytes4[] memory daoSelectors = new bytes4[](3);
daoSelectors[0] = PufferRevenueDepositor.setRnoRewardsBps.selector;
daoSelectors[1] = PufferRevenueDepositor.setTreasuryRewardsBps.selector;
daoSelectors[2] = PufferRevenueDepositor.setRewardsDistributionWindow.selector;

calldatas[0] =
abi.encodeCall(AccessManager.setTargetFunctionRole, (revenueDepositorProxy, daoSelectors, ROLE_ID_DAO));

bytes4[] memory revenueDepositorSelectors = new bytes4[](1);
revenueDepositorSelectors[0] = PufferRevenueDepositor.depositRevenue.selector;

calldatas[1] = abi.encodeCall(
AccessManager.setTargetFunctionRole,
(revenueDepositorProxy, revenueDepositorSelectors, ROLE_ID_RESTAKING_REWARDS_DEPOSITOR)
);

calldatas[2] =
abi.encodeCall(AccessManager.grantRole, (ROLE_ID_RESTAKING_REWARDS_DEPOSITOR, operationsMultisig, 0));

calldatas[3] = abi.encodeCall(
AccessManager.labelRole, (ROLE_ID_RESTAKING_REWARDS_DEPOSITOR, "Restaking Rewards Depositor")
);

bytes4[] memory opsMultisigSelectors = new bytes4[](2);
opsMultisigSelectors[0] = PufferRevenueDepositor.removeRestakingOperator.selector;
opsMultisigSelectors[1] = PufferRevenueDepositor.addRestakingOperators.selector;

calldatas[4] = abi.encodeCall(
AccessManager.setTargetFunctionRole,
(revenueDepositorProxy, opsMultisigSelectors, ROLE_ID_OPERATIONS_MULTISIG)
);

bytes memory encodedMulticall = abi.encodeCall(Multicall.multicall, (calldatas));

return encodedMulticall;
}
}
33 changes: 16 additions & 17 deletions mainnet-contracts/script/DeployEverything.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { UpgradePufETH } from "../script/UpgradePufETH.s.sol";
import { DeployPufETHBridging } from "../script/DeployPufETHBridging.s.sol";
import { DeployPufferOracle } from "script/DeployPufferOracle.s.sol";
import { GuardiansDeployment, PufferProtocolDeployment, BridgingDeployment } from "./DeploymentStructs.sol";
import { PufferRestakingRewardsDepositor } from "src/PufferRestakingRewardsDepositor.sol";
import { PufferRevenueDepositor } from "src/PufferRevenueDepositor.sol";
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import { GenerateRestakingRewardsDepositorCalldata } from
"script/AccessManagerMigrations/05_GenerateRestakingRewardsDepositorCalldata.s.sol";
import { GenerateRevenueDepositorCalldata } from
"script/AccessManagerMigrations/05_GenerateRevenueDepositorCalldata.s.sol";

/**
* @title Deploy all protocol contracts
Expand Down Expand Up @@ -60,10 +60,10 @@ contract DeployEverything is BaseScript {
pufferDeployment.timelock = puffETHDeployment.timelock;

BridgingDeployment memory bridgingDeployment = new DeployPufETHBridging().run(puffETHDeployment);
address restakingRewardsDepositor = _deployRestakingRewardsDepositor(puffETHDeployment);
pufferDeployment.restakingRewardsDepositor = restakingRewardsDepositor;
address revenueDepositor = _deployRevenueDepositor(puffETHDeployment);
pufferDeployment.revenueDepositor = revenueDepositor;

new UpgradePufETH().run(puffETHDeployment, bridgingDeployment, pufferOracle, restakingRewardsDepositor);
new UpgradePufETH().run(puffETHDeployment, bridgingDeployment, pufferOracle, revenueDepositor);

// `anvil` in the terminal
if (_localAnvil) {
Expand Down Expand Up @@ -105,9 +105,9 @@ contract DeployEverything is BaseScript {
vm.writeJson(finalJson, "./output/puffer.json");
}

// script/DeployRestakingRewardsDepositor.s.sol It should match the one in the script
function _deployRestakingRewardsDepositor(PufferDeployment memory puffETHDeployment) internal returns (address) {
PufferRestakingRewardsDepositor restakingRewardsDepositorImpl = new PufferRestakingRewardsDepositor({
// script/DeployRevenueDepositor.s.sol It should match the one in the script
function _deployRevenueDepositor(PufferDeployment memory puffETHDeployment) internal returns (address) {
PufferRevenueDepositor revenueDepositorImpl = new PufferRevenueDepositor({
vault: address(puffETHDeployment.pufferVault),
weth: address(puffETHDeployment.weth),
treasury: makeAddr("Treasury")
Expand All @@ -122,29 +122,28 @@ contract DeployEverything is BaseScript {
operatorsAddresses[5] = makeAddr("RNO6");
operatorsAddresses[6] = makeAddr("RNO7");

PufferRestakingRewardsDepositor restakingRewardsDepositor = PufferRestakingRewardsDepositor(
PufferRevenueDepositor revenueDepositor = PufferRevenueDepositor(
(
payable(
new ERC1967Proxy{ salt: bytes32("restakingRewardsDepositor") }(
address(restakingRewardsDepositorImpl),
new ERC1967Proxy{ salt: bytes32("revenueDepositor") }(
address(revenueDepositorImpl),
abi.encodeCall(
PufferRestakingRewardsDepositor.initialize,
PufferRevenueDepositor.initialize,
(address(puffETHDeployment.accessManager), operatorsAddresses)
)
)
)
)
);

bytes memory accessManagerCd = new GenerateRestakingRewardsDepositorCalldata().run(
address(restakingRewardsDepositor), makeAddr("operationsMultisig")
);
bytes memory accessManagerCd =
new GenerateRevenueDepositorCalldata().run(address(revenueDepositor), makeAddr("operationsMultisig"));

vm.startPrank(puffETHDeployment.timelock);
(bool success,) = address(puffETHDeployment.accessManager).call(accessManagerCd);
require(success, "AccessManager.call failed");
vm.stopPrank();

return address(restakingRewardsDepositor);
return address(revenueDepositor);
}
}
2 changes: 1 addition & 1 deletion mainnet-contracts/script/DeployPuffer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ contract DeployPuffer is BaseScript {
pufferVault: address(0), // overwritten in DeployEverything
pufferDepositor: address(0), // overwritten in DeployEverything
weth: address(0), // overwritten in DeployEverything
restakingRewardsDepositor: address(0) // overwritten in DeployEverything
revenueDepositor: address(0) // overwritten in DeployEverything
});
}

Expand Down
72 changes: 0 additions & 72 deletions mainnet-contracts/script/DeployRestakingRewardsDepositor.s.sol

This file was deleted.

67 changes: 67 additions & 0 deletions mainnet-contracts/script/DeployRevenueDepositor.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0 <0.9.0;

import "forge-std/Script.sol";
import { DeployerHelper } from "./DeployerHelper.s.sol";
import { PufferRevenueDepositor } from "../src/PufferRevenueDepositor.sol";
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import { GenerateRevenueDepositorCalldata } from "./AccessManagerMigrations/05_GenerateRevenueDepositorCalldata.s.sol";

/**
* forge script script/DeployRevenueDepositor.s.sol:DeployRevenueDepositor --rpc-url=$RPC_URL --private-key $PK
*/
contract DeployRevenueDepositor is DeployerHelper {
PufferRevenueDepositor public revenueDepositor;

bytes public encodedCalldata;

function run() public {
GenerateRevenueDepositorCalldata calldataGenerator = new GenerateRevenueDepositorCalldata();

vm.startBroadcast();

//@todo Get from RNOs
address[] memory operatorsAddresses = new address[](7);
operatorsAddresses[0] = makeAddr("RNO1");
operatorsAddresses[1] = makeAddr("RNO2");
operatorsAddresses[2] = makeAddr("RNO3");
operatorsAddresses[3] = makeAddr("RNO4");
operatorsAddresses[4] = makeAddr("RNO5");
operatorsAddresses[5] = makeAddr("RNO6");
operatorsAddresses[6] = makeAddr("RNO7");

PufferRevenueDepositor revenueDepositorImpl =
new PufferRevenueDepositor({ vault: _getPufferVault(), weth: _getWETH(), treasury: _getTreasury() });

revenueDepositor = PufferRevenueDepositor(
(
payable(
new ERC1967Proxy{ salt: bytes32("RevenueDepositor") }(
address(revenueDepositorImpl),
abi.encodeCall(
PufferRevenueDepositor.initialize, (address(_getAccessManager()), operatorsAddresses)
)
)
)
)
);

vm.label(address(revenueDepositor), "PufferRevenueDepositorProxy");
vm.label(address(revenueDepositorImpl), "PufferRevenueDepositorImplementation");

encodedCalldata = calldataGenerator.run({
revenueDepositorProxy: address(revenueDepositor),
operationsMultisig: _getOPSMultisig()
});

console.log("Queue from Timelock -> AccessManager", _getAccessManager());
console.logBytes(encodedCalldata);

if (block.chainid == holesky) {
(bool success,) = address(_getAccessManager()).call(encodedCalldata);
require(success, "AccessManager.call failed");
}

vm.stopBroadcast();
}
}
2 changes: 1 addition & 1 deletion mainnet-contracts/script/DeploymentStructs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct PufferProtocolDeployment {
address stETH; // from pufETH repository (dependency)
address weth; // from pufETH repository (dependency)
address timelock; // from pufETH repository (dependency)
address restakingRewardsDepositor;
address revenueDepositor;
}

struct BridgingDeployment {
Expand Down
6 changes: 3 additions & 3 deletions mainnet-contracts/script/UpgradePufETH.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable
import { AccessManager } from "@openzeppelin/contracts/access/manager/AccessManager.sol";
import { PufferDeployment } from "../src/structs/PufferDeployment.sol";
import { BridgingDeployment } from "./DeploymentStructs.sol";
import { IPufferRestakingRewardsDepositor } from "../src/interface/IPufferRestakingRewardsDepositor.sol";
import { IPufferRevenueDepositor } from "../src/interface/IPufferRevenueDepositor.sol";

/**
* @title UpgradePufETH
Expand Down Expand Up @@ -56,7 +56,7 @@ contract UpgradePufETH is BaseScript {
PufferDeployment memory deployment,
BridgingDeployment memory bridgingDeployment,
address pufferOracle,
address restakingRewardsDepositor
address revenueDepositor
) public broadcast {
//@todo this is for tests only
AccessManager(deployment.accessManager).grantRole(1, _broadcaster, 0);
Expand All @@ -69,7 +69,7 @@ contract UpgradePufETH is BaseScript {
IEigenLayer(deployment.eigenStrategyManagerMock),
IPufferOracle(pufferOracle),
_DELEGATION_MANAGER,
IPufferRestakingRewardsDepositor(restakingRewardsDepositor)
IPufferRevenueDepositor(revenueDepositor)
);

vm.expectEmit(true, true, true, true);
Expand Down
Loading

0 comments on commit bc9b5fd

Please sign in to comment.