Skip to content

Commit

Permalink
Simplify rewards deposit (#73)
Browse files Browse the repository at this point in the history
Co-authored-by: ksatyarth2 <erkumar@protonmail.ch>
Co-authored-by: ksatyarth2 <ksatyarth2@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 4, 2024
1 parent 2b5fc42 commit 35b4759
Show file tree
Hide file tree
Showing 10 changed files with 495 additions and 320 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ 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_REVENUE_DEPOSITOR } from "../../script/Roles.sol";
import { ROLE_ID_DAO, ROLE_ID_REVENUE_DEPOSITOR, ROLE_ID_OPERATIONS_MULTISIG } 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;
bytes4[] memory daoSelectors = new bytes4[](1);
daoSelectors[0] = PufferRevenueDepositor.setRewardsDistributionWindow.selector;

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

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

calldatas[1] = abi.encodeCall(
AccessManager.setTargetFunctionRole,
Expand All @@ -31,13 +30,12 @@ contract GenerateRevenueDepositorCalldata is Script {

calldatas[3] = abi.encodeCall(AccessManager.labelRole, (ROLE_ID_REVENUE_DEPOSITOR, "Revenue Depositor"));

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

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

bytes memory encodedMulticall = abi.encodeCall(Multicall.multicall, (calldatas));
Expand Down
21 changes: 6 additions & 15 deletions mainnet-contracts/script/DeployEverything.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { GuardiansDeployment, PufferProtocolDeployment, BridgingDeployment } fro
import { PufferRevenueDepositor } from "src/PufferRevenueDepositor.sol";
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import { GenerateRevenueDepositorCalldata } from
"script/AccessManagerMigrations/05_GenerateRevenueDepositorCalldata.s.sol";
"script/AccessManagerMigrations/06_GenerateRevenueDepositorCalldata.s.sol";
import { MockAeraVault } from "test/mocks/MockAeraVault.sol";

/**
* @title Deploy all protocol contracts
Expand Down Expand Up @@ -107,30 +108,20 @@ contract DeployEverything is BaseScript {

// script/DeployRevenueDepositor.s.sol It should match the one in the script
function _deployRevenueDepositor(PufferDeployment memory puffETHDeployment) internal returns (address) {
MockAeraVault mockAeraVault = new MockAeraVault();

PufferRevenueDepositor revenueDepositorImpl = new PufferRevenueDepositor({
vault: address(puffETHDeployment.pufferVault),
weth: address(puffETHDeployment.weth),
treasury: makeAddr("Treasury")
aeraVault: address(mockAeraVault)
});

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 revenueDepositor = PufferRevenueDepositor(
(
payable(
new ERC1967Proxy{ salt: bytes32("revenueDepositor") }(
address(revenueDepositorImpl),
abi.encodeCall(
PufferRevenueDepositor.initialize,
(address(puffETHDeployment.accessManager), operatorsAddresses)
)
abi.encodeCall(PufferRevenueDepositor.initialize, (address(puffETHDeployment.accessManager)))
)
)
)
Expand Down
18 changes: 3 additions & 15 deletions mainnet-contracts/script/DeployRevenueDepositor.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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";
import { GenerateRevenueDepositorCalldata } from "./AccessManagerMigrations/06_GenerateRevenueDepositorCalldata.s.sol";

/**
* forge script script/DeployRevenueDepositor.s.sol:DeployRevenueDepositor --rpc-url=$RPC_URL --private-key $PK
Expand All @@ -20,27 +20,15 @@ contract DeployRevenueDepositor is DeployerHelper {

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() });
new PufferRevenueDepositor({ vault: _getPufferVault(), weth: _getWETH(), aeraVault: _getAeraVault() });

revenueDepositor = PufferRevenueDepositor(
(
payable(
new ERC1967Proxy{ salt: bytes32("RevenueDepositor") }(
address(revenueDepositorImpl),
abi.encodeCall(
PufferRevenueDepositor.initialize, (address(_getAccessManager()), operatorsAddresses)
)
abi.encodeCall(PufferRevenueDepositor.initialize, (address(_getAccessManager())))
)
)
)
Expand Down
27 changes: 27 additions & 0 deletions mainnet-contracts/script/DeployerHelper.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -432,4 +432,31 @@ abstract contract DeployerHelper is Script {

revert("OPSMultisig not available for this chain");
}

function _getAeraVault() internal view returns (address) {
if (block.chainid == mainnet) {
// https://etherscan.io/address/0x6c25aE178aC3466A63A552d4D6509c3d7385A0b8
return 0x6c25aE178aC3466A63A552d4D6509c3d7385A0b8;
}

revert("AeraVault not available for this chain");
}

function _getAeraAssetRegistry() internal view returns (address) {
if (block.chainid == mainnet) {
// https://etherscan.io/address/0xc71C52425969286dAAd647e4088394C572d64fd9
return 0xc71C52425969286dAAd647e4088394C572d64fd9;
}

revert("AeraAssetRegistry not available for this chain");
}

function _getAeraVaultHooks() internal view returns (address) {
if (block.chainid == mainnet) {
// https://etherscan.io/address/0x933AD39feb35793B4d6B0A543db39b033Eb5D2C1
return 0x933AD39feb35793B4d6B0A543db39b033Eb5D2C1;
}

revert("AeraVaultHooks not available for this chain");
}
}
Loading

0 comments on commit 35b4759

Please sign in to comment.