From bc9b5fdd40303c34dd65205a8f2f146246540f53 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Thu, 24 Oct 2024 17:06:19 +0200 Subject: [PATCH] rename RestakingRewardsDepositor --- ...ateRestakingRewardsDepositorCalldata.s.sol | 55 ------- .../05_GenerateRevenueDepositorCalldata.s.sol | 50 +++++++ .../script/DeployEverything.s.sol | 33 +++-- mainnet-contracts/script/DeployPuffer.s.sol | 2 +- .../DeployRestakingRewardsDepositor.s.sol | 72 ---------- .../script/DeployRevenueDepositor.s.sol | 67 +++++++++ .../script/DeploymentStructs.sol | 2 +- mainnet-contracts/script/UpgradePufETH.s.sol | 6 +- ...positor.sol => PufferRevenueDepositor.sol} | 48 +++---- ....sol => PufferRevenueDepositorStorage.sol} | 26 ++-- mainnet-contracts/src/PufferVaultV4.sol | 8 +- ...ositor.sol => IPufferRevenueDepositor.sol} | 10 +- .../test/MainnetForkTestHelper.sol | 4 +- .../test/helpers/UnitTestHelper.sol | 9 +- ...Depositor.sol => MockRevenueDepositor.sol} | 2 +- .../test/mocks/PufferVaultV4Tests.sol | 6 +- ...t.sol => PufferRevenueDepositorTest.t.sol} | 136 +++++++++--------- .../test/unit/PufferVaultV2Property.t.sol | 8 +- 18 files changed, 259 insertions(+), 285 deletions(-) delete mode 100644 mainnet-contracts/script/AccessManagerMigrations/05_GenerateRestakingRewardsDepositorCalldata.s.sol create mode 100644 mainnet-contracts/script/AccessManagerMigrations/05_GenerateRevenueDepositorCalldata.s.sol delete mode 100644 mainnet-contracts/script/DeployRestakingRewardsDepositor.s.sol create mode 100644 mainnet-contracts/script/DeployRevenueDepositor.s.sol rename mainnet-contracts/src/{PufferRestakingRewardsDepositor.sol => PufferRevenueDepositor.sol} (83%) rename mainnet-contracts/src/{PufferRestakingRewardsDepositorStorage.sol => PufferRevenueDepositorStorage.sol} (63%) rename mainnet-contracts/src/interface/{IPufferRestakingRewardsDepositor.sol => IPufferRevenueDepositor.sol} (90%) rename mainnet-contracts/test/mocks/{MockRestakingRewardsDepositor.sol => MockRevenueDepositor.sol} (80%) rename mainnet-contracts/test/unit/{PufferRestakingRewardsDepositor.t.sol => PufferRevenueDepositorTest.t.sol} (52%) diff --git a/mainnet-contracts/script/AccessManagerMigrations/05_GenerateRestakingRewardsDepositorCalldata.s.sol b/mainnet-contracts/script/AccessManagerMigrations/05_GenerateRestakingRewardsDepositorCalldata.s.sol deleted file mode 100644 index dfacd9d..0000000 --- a/mainnet-contracts/script/AccessManagerMigrations/05_GenerateRestakingRewardsDepositorCalldata.s.sol +++ /dev/null @@ -1,55 +0,0 @@ -// 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 { PufferRestakingRewardsDepositor } from "../../src/PufferRestakingRewardsDepositor.sol"; - -contract GenerateRestakingRewardsDepositorCalldata is Script { - function run(address restakingRewardsDepositorProxy, address operationsMultisig) - public - pure - returns (bytes memory) - { - bytes[] memory calldatas = new bytes[](5); - - bytes4[] memory daoSelectors = new bytes4[](3); - daoSelectors[0] = PufferRestakingRewardsDepositor.setRnoRewardsBps.selector; - daoSelectors[1] = PufferRestakingRewardsDepositor.setTreasuryRewardsBps.selector; - daoSelectors[2] = PufferRestakingRewardsDepositor.setRewardsDistributionWindow.selector; - - calldatas[0] = abi.encodeCall( - AccessManager.setTargetFunctionRole, (restakingRewardsDepositorProxy, daoSelectors, ROLE_ID_DAO) - ); - - bytes4[] memory restakingRewardsDepositorSelectors = new bytes4[](1); - restakingRewardsDepositorSelectors[0] = PufferRestakingRewardsDepositor.depositRestakingRewards.selector; - - calldatas[1] = abi.encodeCall( - AccessManager.setTargetFunctionRole, - (restakingRewardsDepositorProxy, restakingRewardsDepositorSelectors, 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] = PufferRestakingRewardsDepositor.removeRestakingOperator.selector; - opsMultisigSelectors[1] = PufferRestakingRewardsDepositor.addRestakingOperators.selector; - - calldatas[4] = abi.encodeCall( - AccessManager.setTargetFunctionRole, - (restakingRewardsDepositorProxy, opsMultisigSelectors, ROLE_ID_OPERATIONS_MULTISIG) - ); - - bytes memory encodedMulticall = abi.encodeCall(Multicall.multicall, (calldatas)); - - return encodedMulticall; - } -} diff --git a/mainnet-contracts/script/AccessManagerMigrations/05_GenerateRevenueDepositorCalldata.s.sol b/mainnet-contracts/script/AccessManagerMigrations/05_GenerateRevenueDepositorCalldata.s.sol new file mode 100644 index 0000000..61a012c --- /dev/null +++ b/mainnet-contracts/script/AccessManagerMigrations/05_GenerateRevenueDepositorCalldata.s.sol @@ -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; + } +} diff --git a/mainnet-contracts/script/DeployEverything.s.sol b/mainnet-contracts/script/DeployEverything.s.sol index 3508863..f92f2f4 100644 --- a/mainnet-contracts/script/DeployEverything.s.sol +++ b/mainnet-contracts/script/DeployEverything.s.sol @@ -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 @@ -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) { @@ -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") @@ -122,13 +122,13 @@ 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) ) ) @@ -136,15 +136,14 @@ contract DeployEverything is BaseScript { ) ); - 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); } } diff --git a/mainnet-contracts/script/DeployPuffer.s.sol b/mainnet-contracts/script/DeployPuffer.s.sol index d3fbe06..17a4b89 100644 --- a/mainnet-contracts/script/DeployPuffer.s.sol +++ b/mainnet-contracts/script/DeployPuffer.s.sol @@ -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 }); } diff --git a/mainnet-contracts/script/DeployRestakingRewardsDepositor.s.sol b/mainnet-contracts/script/DeployRestakingRewardsDepositor.s.sol deleted file mode 100644 index 21cf2ca..0000000 --- a/mainnet-contracts/script/DeployRestakingRewardsDepositor.s.sol +++ /dev/null @@ -1,72 +0,0 @@ -// 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 { PufferRestakingRewardsDepositor } from "../src/PufferRestakingRewardsDepositor.sol"; -import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; -import { GenerateRestakingRewardsDepositorCalldata } from - "./AccessManagerMigrations/05_GenerateRestakingRewardsDepositorCalldata.s.sol"; - -/** - * forge script script/DeployRestakingRewardsDepositor.s.sol:DeployRestakingRewardsDepositor --rpc-url=$RPC_URL --private-key $PK - */ -contract DeployRestakingRewardsDepositor is DeployerHelper { - PufferRestakingRewardsDepositor public restakingRewardsDepositor; - - bytes public encodedCalldata; - - function run() public { - GenerateRestakingRewardsDepositorCalldata calldataGenerator = new GenerateRestakingRewardsDepositorCalldata(); - - 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"); - - PufferRestakingRewardsDepositor restakingRewardsDepositorImpl = new PufferRestakingRewardsDepositor({ - vault: _getPufferVault(), - weth: _getWETH(), - treasury: _getTreasury() - }); - - restakingRewardsDepositor = PufferRestakingRewardsDepositor( - ( - payable( - new ERC1967Proxy{ salt: bytes32("restakingRewardsDepositor") }( - address(restakingRewardsDepositorImpl), - abi.encodeCall( - PufferRestakingRewardsDepositor.initialize, - (address(_getAccessManager()), operatorsAddresses) - ) - ) - ) - ) - ); - - vm.label(address(restakingRewardsDepositor), "PufferRestakingRewardsDepositorProxy"); - vm.label(address(restakingRewardsDepositorImpl), "PufferRestakingRewardsDepositorImplementation"); - - encodedCalldata = calldataGenerator.run({ - restakingRewardsDepositorProxy: address(restakingRewardsDepositor), - 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(); - } -} diff --git a/mainnet-contracts/script/DeployRevenueDepositor.s.sol b/mainnet-contracts/script/DeployRevenueDepositor.s.sol new file mode 100644 index 0000000..a414c41 --- /dev/null +++ b/mainnet-contracts/script/DeployRevenueDepositor.s.sol @@ -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(); + } +} diff --git a/mainnet-contracts/script/DeploymentStructs.sol b/mainnet-contracts/script/DeploymentStructs.sol index a9e0a89..5a399ed 100644 --- a/mainnet-contracts/script/DeploymentStructs.sol +++ b/mainnet-contracts/script/DeploymentStructs.sol @@ -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 { diff --git a/mainnet-contracts/script/UpgradePufETH.s.sol b/mainnet-contracts/script/UpgradePufETH.s.sol index 86b6faa..f07ddbc 100644 --- a/mainnet-contracts/script/UpgradePufETH.s.sol +++ b/mainnet-contracts/script/UpgradePufETH.s.sol @@ -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 @@ -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); @@ -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); diff --git a/mainnet-contracts/src/PufferRestakingRewardsDepositor.sol b/mainnet-contracts/src/PufferRevenueDepositor.sol similarity index 83% rename from mainnet-contracts/src/PufferRestakingRewardsDepositor.sol rename to mainnet-contracts/src/PufferRevenueDepositor.sol index 73f33f2..e20cbf4 100644 --- a/mainnet-contracts/src/PufferRestakingRewardsDepositor.sol +++ b/mainnet-contracts/src/PufferRevenueDepositor.sol @@ -10,19 +10,19 @@ import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableS import { AccessManagedUpgradeable } from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol"; import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; -import { PufferRestakingRewardsDepositorStorage } from "./PufferRestakingRewardsDepositorStorage.sol"; -import { IPufferRestakingRewardsDepositor } from "./interface/IPufferRestakingRewardsDepositor.sol"; +import { PufferRevenueDepositorStorage } from "./PufferRevenueDepositorStorage.sol"; +import { IPufferRevenueDepositor } from "./interface/IPufferRevenueDepositor.sol"; import { InvalidAddress } from "./Errors.sol"; /** - * @title PufferRestakingRewardsDepositor - * @notice This contract is used to "slowly" deposit restaking rewards into PufferVault. + * @title PufferRevenueDepositor + * @notice This contract is used to "slowly" deposit revenue into PufferVault. * @dev The funds are deposited immediately but the exchange rate change doesn't happen until the rewards distribution window is over. * @custom:security-contact security@puffer.fi */ -contract PufferRestakingRewardsDepositor is - IPufferRestakingRewardsDepositor, - PufferRestakingRewardsDepositorStorage, +contract PufferRevenueDepositor is + IPufferRevenueDepositor, + PufferRevenueDepositorStorage, AccessManagedUpgradeable, UUPSUpgradeable { @@ -92,10 +92,10 @@ contract PufferRestakingRewardsDepositor is receive() external payable { } /** - * @inheritdoc IPufferRestakingRewardsDepositor + * @inheritdoc IPufferRevenueDepositor */ function getPendingDistributionAmount() public view returns (uint256) { - RestakingRewardsDepositorStorage storage $ = _getRestakingRewardsDepositorStorage(); + RevenueDepositorStorage storage $ = _getRevenueDepositorStorage(); uint256 rewardsDistributionWindow = $.rewardsDistributionWindow; @@ -112,20 +112,20 @@ contract PufferRestakingRewardsDepositor is } /** - * @inheritdoc IPufferRestakingRewardsDepositor + * @inheritdoc IPufferRevenueDepositor */ function getRewardsDistributionWindow() public view returns (uint256) { - return _getRestakingRewardsDepositorStorage().rewardsDistributionWindow; + return _getRevenueDepositorStorage().rewardsDistributionWindow; } /** - * @notice Deposit restaking rewards into PufferVault. + * @notice Deposit revenue into PufferVault. * @dev Restricted access to `ROLE_ID_RESTAKING_REWARDS_DEPOSITOR` */ - function depositRestakingRewards() external restricted { + function depositRevenue() external restricted { require(getPendingDistributionAmount() == 0, VaultHasUndepositedRewards()); - RestakingRewardsDepositorStorage storage $ = _getRestakingRewardsDepositorStorage(); + RevenueDepositorStorage storage $ = _getRevenueDepositorStorage(); $.lastDepositTimestamp = uint48(block.timestamp); // Wrap any ETH sent to the contract @@ -155,7 +155,7 @@ contract PufferRestakingRewardsDepositor is $.lastDepositAmount = uint104(vaultRewards); WETH.transfer(address(PUFFER_VAULT), vaultRewards); - emit RestakingRewardsDeposited(vaultRewards); + emit RevenueDeposited(vaultRewards); } /** @@ -163,7 +163,7 @@ contract PufferRestakingRewardsDepositor is * @return The last deposit timestamp in seconds. */ function getLastDepositTimestamp() public view returns (uint256) { - return _getRestakingRewardsDepositorStorage().lastDepositTimestamp; + return _getRevenueDepositorStorage().lastDepositTimestamp; } /** @@ -171,7 +171,7 @@ contract PufferRestakingRewardsDepositor is * @return The addresses of the restaking operators. */ function getRestakingOperators() external view returns (address[] memory) { - return _getRestakingRewardsDepositorStorage().restakingOperators.values(); + return _getRevenueDepositorStorage().restakingOperators.values(); } /** @@ -179,7 +179,7 @@ contract PufferRestakingRewardsDepositor is * @return The RNO rewards in basis points. */ function getRnoRewardsBps() external view returns (uint128) { - return _getRestakingRewardsDepositorStorage().rNORewardsBps; + return _getRevenueDepositorStorage().rNORewardsBps; } /** @@ -187,7 +187,7 @@ contract PufferRestakingRewardsDepositor is * @return The RNO rewards in basis points. */ function getTreasuryRewardsBps() external view returns (uint128) { - return _getRestakingRewardsDepositorStorage().treasuryRewardsBps; + return _getRevenueDepositorStorage().treasuryRewardsBps; } /** @@ -199,7 +199,7 @@ contract PufferRestakingRewardsDepositor is require(getPendingDistributionAmount() == 0, CannotChangeDistributionWindow()); require(newRewardsDistributionWindow <= _MAXIMUM_DISTRIBUTION_WINDOW, InvalidDistributionWindow()); - RestakingRewardsDepositorStorage storage $ = _getRestakingRewardsDepositorStorage(); + RevenueDepositorStorage storage $ = _getRevenueDepositorStorage(); emit RewardsDistributionWindowChanged($.rewardsDistributionWindow, newRewardsDistributionWindow); $.rewardsDistributionWindow = newRewardsDistributionWindow; } @@ -216,7 +216,7 @@ contract PufferRestakingRewardsDepositor is function _setRnoRewardsBps(uint128 newBps) internal { require(newBps <= _MAX_REWARDS_BPS, InvalidBps()); - RestakingRewardsDepositorStorage storage $ = _getRestakingRewardsDepositorStorage(); + RevenueDepositorStorage storage $ = _getRevenueDepositorStorage(); emit RnoRewardsBpsChanged($.rNORewardsBps, newBps); $.rNORewardsBps = newBps; @@ -234,7 +234,7 @@ contract PufferRestakingRewardsDepositor is function _setTreasuryRewardsBps(uint128 newBps) internal { require(newBps <= _MAX_REWARDS_BPS, InvalidBps()); - RestakingRewardsDepositorStorage storage $ = _getRestakingRewardsDepositorStorage(); + RevenueDepositorStorage storage $ = _getRevenueDepositorStorage(); emit TreasuryRewardsBpsChanged($.treasuryRewardsBps, newBps); $.treasuryRewardsBps = newBps; @@ -246,7 +246,7 @@ contract PufferRestakingRewardsDepositor is * @param operatorAddress The address of the restaking operator. */ function removeRestakingOperator(address operatorAddress) external restricted { - RestakingRewardsDepositorStorage storage $ = _getRestakingRewardsDepositorStorage(); + RevenueDepositorStorage storage $ = _getRevenueDepositorStorage(); bool success = $.restakingOperators.remove(operatorAddress); require(success, RestakingOperatorNotSet()); @@ -263,7 +263,7 @@ contract PufferRestakingRewardsDepositor is } function _addRestakingOperators(address[] memory operatorsAddresses) internal { - RestakingRewardsDepositorStorage storage $ = _getRestakingRewardsDepositorStorage(); + RevenueDepositorStorage storage $ = _getRevenueDepositorStorage(); for (uint256 i = 0; i < operatorsAddresses.length; i++) { require(operatorsAddresses[i] != address(0), InvalidAddress()); diff --git a/mainnet-contracts/src/PufferRestakingRewardsDepositorStorage.sol b/mainnet-contracts/src/PufferRevenueDepositorStorage.sol similarity index 63% rename from mainnet-contracts/src/PufferRestakingRewardsDepositorStorage.sol rename to mainnet-contracts/src/PufferRevenueDepositorStorage.sol index 6a86f9c..eeec00d 100644 --- a/mainnet-contracts/src/PufferRestakingRewardsDepositorStorage.sol +++ b/mainnet-contracts/src/PufferRevenueDepositorStorage.sol @@ -4,22 +4,22 @@ pragma solidity >=0.8.0 <0.9.0; import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; /** - * @title PufferRestakingRewardsDepositorStorage + * @title PufferRevenueDepositorStorage * @author Puffer Finance * @custom:security-contact security@puffer.fi */ -abstract contract PufferRestakingRewardsDepositorStorage { +abstract contract PufferRevenueDepositorStorage { using EnumerableSet for EnumerableSet.AddressSet; /** - * @custom:storage-location erc7201:RestakingRewardsDepositor.storage + * @custom:storage-location erc7201:RevenueDepositor.storage * @dev +-----------------------------------------------------------+ * | | * | DO NOT CHANGE, REORDER, REMOVE EXISTING STORAGE VARIABLES | * | | * +-----------------------------------------------------------+ */ - struct RestakingRewardsDepositorStorage { + struct RevenueDepositorStorage { /** * @notice Restaking operators. */ @@ -47,21 +47,17 @@ abstract contract PufferRestakingRewardsDepositorStorage { } /** - * @dev Storage slot location for RestakingRewardsDepositorStorage - * @custom:storage-location erc7201:RestakingRewardsDepositor.storage - * keccak256(abi.encode(uint256(keccak256("RestakingRewardsDepositor.storage")) - 1)) & ~bytes32(uint256(0xff)) + * @dev Storage slot location for RevenueDepositorStorage + * @custom:storage-location erc7201:RevenueDepositor.storage + * keccak256(abi.encode(uint256(keccak256("RevenueDepositor.storage")) - 1)) & ~bytes32(uint256(0xff)) */ - bytes32 private constant _RESTAKE_REWARDS_DEPOSITOR_STORAGE = - 0xf06bc84d5dffe01f6559e934f5a062e2abca02c8f0e842bc9b567621039cd300; + bytes32 private constant _REVENUE_DEPOSITOR_STORAGE = + 0x4a89cef1c30d36c0ff2c9fb23c831a9c153cf25feb747c6591cde6a5261b4000; - function _getRestakingRewardsDepositorStorage() - internal - pure - returns (RestakingRewardsDepositorStorage storage $) - { + function _getRevenueDepositorStorage() internal pure returns (RevenueDepositorStorage storage $) { // solhint-disable-next-line no-inline-assembly assembly { - $.slot := _RESTAKE_REWARDS_DEPOSITOR_STORAGE + $.slot := _REVENUE_DEPOSITOR_STORAGE } } } diff --git a/mainnet-contracts/src/PufferVaultV4.sol b/mainnet-contracts/src/PufferVaultV4.sol index 07a4104..bcb6036 100644 --- a/mainnet-contracts/src/PufferVaultV4.sol +++ b/mainnet-contracts/src/PufferVaultV4.sol @@ -12,7 +12,7 @@ import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import { PufferVaultV3 } from "./PufferVaultV3.sol"; import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol"; -import { IPufferRestakingRewardsDepositor } from "./interface/IPufferRestakingRewardsDepositor.sol"; +import { IPufferRevenueDepositor } from "./interface/IPufferRevenueDepositor.sol"; /** * @title PufferVaultV4 @@ -27,7 +27,7 @@ contract PufferVaultV4 is PufferVaultV3 { /** * @notice The restaking rewards depositor contract. */ - IPufferRestakingRewardsDepositor public immutable RESTAKING_REWARDS_DEPOSITOR; + IPufferRevenueDepositor public immutable RESTAKING_REWARDS_DEPOSITOR; /** * @notice Initializes the PufferVaultV3 contract. @@ -48,9 +48,9 @@ contract PufferVaultV4 is PufferVaultV3 { IEigenLayer eigenStrategyManager, IPufferOracle oracle, IDelegationManager delegationManager, - IPufferRestakingRewardsDepositor restakingRewardsDepositor + IPufferRevenueDepositor revenueDepositor ) PufferVaultV3(stETH, weth, lidoWithdrawalQueue, stETHStrategy, eigenStrategyManager, oracle, delegationManager) { - RESTAKING_REWARDS_DEPOSITOR = restakingRewardsDepositor; + RESTAKING_REWARDS_DEPOSITOR = revenueDepositor; _disableInitializers(); } diff --git a/mainnet-contracts/src/interface/IPufferRestakingRewardsDepositor.sol b/mainnet-contracts/src/interface/IPufferRevenueDepositor.sol similarity index 90% rename from mainnet-contracts/src/interface/IPufferRestakingRewardsDepositor.sol rename to mainnet-contracts/src/interface/IPufferRevenueDepositor.sol index f9421a5..4916117 100644 --- a/mainnet-contracts/src/interface/IPufferRestakingRewardsDepositor.sol +++ b/mainnet-contracts/src/interface/IPufferRevenueDepositor.sol @@ -2,11 +2,11 @@ pragma solidity >=0.8.0 <0.9.0; /** - * @title IPufferRestakingRewardsDepositor - * @notice Interface for the PufferRestakingRewardsDepositor contract. + * @title IPufferRevenueDepositor + * @notice Interface for the PufferRevenueDepositor contract. * @custom:security-contact security@puffer.fi */ -interface IPufferRestakingRewardsDepositor { +interface IPufferRevenueDepositor { /** * @notice Thrown when the restaking operator is already set. */ @@ -43,9 +43,9 @@ interface IPufferRestakingRewardsDepositor { error InvalidDistributionWindow(); /** - * @notice Emitted when the rewards are deposited to the PufferVault + * @notice Emitted when the revenue is deposited to the PufferVault */ - event RestakingRewardsDeposited(uint256 amount); + event RevenueDeposited(uint256 amount); /** * @notice Emitted when the rewards distribution window is changed diff --git a/mainnet-contracts/test/MainnetForkTestHelper.sol b/mainnet-contracts/test/MainnetForkTestHelper.sol index 7e3fea0..c0fd9b7 100644 --- a/mainnet-contracts/test/MainnetForkTestHelper.sol +++ b/mainnet-contracts/test/MainnetForkTestHelper.sol @@ -27,7 +27,7 @@ import { Permit } from "../src/structs/Permit.sol"; import { ERC1967Utils } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; import { IDelegationManager } from "../src/interface/EigenLayer/IDelegationManager.sol"; import { DeployerHelper } from "../script/DeployerHelper.s.sol"; -import { IPufferRestakingRewardsDepositor } from "../src/interface/IPufferRestakingRewardsDepositor.sol"; +import { IPufferRevenueDepositor } from "../src/interface/IPufferRevenueDepositor.sol"; contract MainnetForkTestHelper is Test, DeployerHelper { /** @@ -232,7 +232,7 @@ contract MainnetForkTestHelper is Test, DeployerHelper { eigenStrategyManager: IEigenLayer(_getEigenLayerStrategyManager()), oracle: IPufferOracle(_getPufferOracle()), delegationManager: IDelegationManager(_getEigenDelegationManager()), - restakingRewardsDepositor: IPufferRestakingRewardsDepositor(address(0)) + revenueDepositor: IPufferRevenueDepositor(address(0)) }); // Simulate that our deployed oracle becomes active and starts posting results of Puffer staking diff --git a/mainnet-contracts/test/helpers/UnitTestHelper.sol b/mainnet-contracts/test/helpers/UnitTestHelper.sol index 70766be..6442a7c 100644 --- a/mainnet-contracts/test/helpers/UnitTestHelper.sol +++ b/mainnet-contracts/test/helpers/UnitTestHelper.sol @@ -29,8 +29,7 @@ import { OperationsCoordinator } from "../../src/OperationsCoordinator.sol"; import { xPufETH } from "src/l2/xPufETH.sol"; import { XERC20Lockbox } from "src/XERC20Lockbox.sol"; import { L1RewardManager } from "src/L1RewardManager.sol"; -import { PufferRestakingRewardsDepositor } from "src/PufferRestakingRewardsDepositor.sol"; -import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; +import { PufferRevenueDepositor } from "src/PufferRevenueDepositor.sol"; import { L2RewardManager } from "l2-contracts/src/L2RewardManager.sol"; import { ConnextMock } from "../mocks/ConnextMock.sol"; import { @@ -108,7 +107,7 @@ contract UnitTestHelper is Test, BaseScript { XERC20Lockbox public lockBox; L1RewardManager public l1RewardManager; L2RewardManager public l2RewardManager; - PufferRestakingRewardsDepositor public restakingRewardsDepositor; + PufferRevenueDepositor public revenueDepositor; ConnextMock public connext; address public DAO = makeAddr("DAO"); @@ -141,8 +140,6 @@ contract UnitTestHelper is Test, BaseScript { address public RNO6 = makeAddr("RNO6"); address public RNO7 = makeAddr("RNO7"); - bytes public restakingRewardsAccessManagerCalldata; - modifier fuzzedAddress(address addr) virtual { vm.assume(fuzzedAddressMapping[addr] == false); _; @@ -220,7 +217,7 @@ contract UnitTestHelper is Test, BaseScript { l1RewardManager = L1RewardManager(payable(bridgingDeployment.l1RewardManager)); l2RewardManager = L2RewardManager(payable(bridgingDeployment.l2RewardManager)); connext = ConnextMock(payable(bridgingDeployment.connext)); - restakingRewardsDepositor = PufferRestakingRewardsDepositor(payable(pufferDeployment.restakingRewardsDepositor)); + revenueDepositor = PufferRevenueDepositor(payable(pufferDeployment.revenueDepositor)); // pufETH dependencies pufferVault = PufferVaultV3(payable(pufferDeployment.pufferVault)); diff --git a/mainnet-contracts/test/mocks/MockRestakingRewardsDepositor.sol b/mainnet-contracts/test/mocks/MockRevenueDepositor.sol similarity index 80% rename from mainnet-contracts/test/mocks/MockRestakingRewardsDepositor.sol rename to mainnet-contracts/test/mocks/MockRevenueDepositor.sol index 6a3efc9..a866e74 100644 --- a/mainnet-contracts/test/mocks/MockRestakingRewardsDepositor.sol +++ b/mainnet-contracts/test/mocks/MockRevenueDepositor.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.8.0 <0.9.0; -contract MockRestakingRewardsDepositor { +contract MockRevenueDepositor { function getPendingDistributionAmount() external pure returns (uint256) { return 0; } diff --git a/mainnet-contracts/test/mocks/PufferVaultV4Tests.sol b/mainnet-contracts/test/mocks/PufferVaultV4Tests.sol index c9f6dce..1f596dd 100644 --- a/mainnet-contracts/test/mocks/PufferVaultV4Tests.sol +++ b/mainnet-contracts/test/mocks/PufferVaultV4Tests.sol @@ -9,7 +9,7 @@ import { IStrategy } from "src/interface/EigenLayer/IStrategy.sol"; import { IWETH } from "src/interface/Other/IWETH.sol"; import { IPufferOracle } from "src/interface/IPufferOracle.sol"; import { IDelegationManager } from "src/interface/EigenLayer/IDelegationManager.sol"; -import { IPufferRestakingRewardsDepositor } from "src/interface/IPufferRestakingRewardsDepositor.sol"; +import { IPufferRevenueDepositor } from "src/interface/IPufferRevenueDepositor.sol"; contract PufferVaultV4Tests is PufferVaultV4 { constructor( @@ -20,7 +20,7 @@ contract PufferVaultV4Tests is PufferVaultV4 { IEigenLayer eigenStrategyManager, IPufferOracle oracle, IDelegationManager delegationManager, - IPufferRestakingRewardsDepositor restakingRewardsDepositor + IPufferRevenueDepositor revenueDepositor ) PufferVaultV4( stETH, @@ -30,7 +30,7 @@ contract PufferVaultV4Tests is PufferVaultV4 { eigenStrategyManager, oracle, delegationManager, - restakingRewardsDepositor + revenueDepositor ) { _disableInitializers(); diff --git a/mainnet-contracts/test/unit/PufferRestakingRewardsDepositor.t.sol b/mainnet-contracts/test/unit/PufferRevenueDepositorTest.t.sol similarity index 52% rename from mainnet-contracts/test/unit/PufferRestakingRewardsDepositor.t.sol rename to mainnet-contracts/test/unit/PufferRevenueDepositorTest.t.sol index fa12ada..dfe42eb 100644 --- a/mainnet-contracts/test/unit/PufferRestakingRewardsDepositor.t.sol +++ b/mainnet-contracts/test/unit/PufferRevenueDepositorTest.t.sol @@ -2,90 +2,86 @@ pragma solidity >=0.8.0 <0.9.0; import { UnitTestHelper } from "../helpers/UnitTestHelper.sol"; -import { IPufferRestakingRewardsDepositor } from "src/interface/IPufferRestakingRewardsDepositor.sol"; +import { IPufferRevenueDepositor } from "src/interface/IPufferRevenueDepositor.sol"; import { InvalidAddress } from "src/Errors.sol"; /** - * @title PufferRestakingRewardsDepositorTest - * @dev Test contract for PufferRestakingRewardsDepositor + * @title PufferRevenueDepositorTest + * @dev Test contract for PufferRevenueDepositor * * @dev Run the following command to execute the tests: - * forge test --mc PufferRestakingRewardsDepositorTest -vvvv + * forge test --mc PufferRevenueDepositorTest -vvvv */ -contract PufferRestakingRewardsDepositorTest is UnitTestHelper { +contract PufferRevenueDepositorTest is UnitTestHelper { /** * @dev Modifier to set the rewards distribution window for the test */ modifier withRewardsDistributionWindow(uint24 newRewardsDistributionWindow) { vm.startPrank(DAO); - restakingRewardsDepositor.setRewardsDistributionWindow(newRewardsDistributionWindow); + revenueDepositor.setRewardsDistributionWindow(newRewardsDistributionWindow); _; vm.stopPrank(); } function test_sanity() public view { - assertEq(restakingRewardsDepositor.getRnoRewardsBps(), 400, "RNO rewards bps should be 400"); - assertEq(restakingRewardsDepositor.getTreasuryRewardsBps(), 500, "Treasury rewards bps should be 500"); - assertEq(restakingRewardsDepositor.getRestakingOperators().length, 7, "Should have 7 restaking operators"); - assertTrue(restakingRewardsDepositor.TREASURY() != address(0), "Treasury should not be 0"); - assertTrue(address(restakingRewardsDepositor.WETH()) != address(0), "WETH should not be 0"); - assertTrue(address(restakingRewardsDepositor.PUFFER_VAULT()) != address(0), "PufferVault should not be 0"); + assertEq(revenueDepositor.getRnoRewardsBps(), 400, "RNO rewards bps should be 400"); + assertEq(revenueDepositor.getTreasuryRewardsBps(), 500, "Treasury rewards bps should be 500"); + assertEq(revenueDepositor.getRestakingOperators().length, 7, "Should have 7 restaking operators"); + assertTrue(revenueDepositor.TREASURY() != address(0), "Treasury should not be 0"); + assertTrue(address(revenueDepositor.WETH()) != address(0), "WETH should not be 0"); + assertTrue(address(revenueDepositor.PUFFER_VAULT()) != address(0), "PufferVault should not be 0"); } function test_setRewardsDistributionWindow() public { - assertEq(restakingRewardsDepositor.getRewardsDistributionWindow(), 0, "Rewards distribution window should be 0"); + assertEq(revenueDepositor.getRewardsDistributionWindow(), 0, "Rewards distribution window should be 0"); vm.startPrank(DAO); vm.expectEmit(true, true, true, true); - emit IPufferRestakingRewardsDepositor.RewardsDistributionWindowChanged(0, 1 days); - restakingRewardsDepositor.setRewardsDistributionWindow(1 days); + emit IPufferRevenueDepositor.RewardsDistributionWindowChanged(0, 1 days); + revenueDepositor.setRewardsDistributionWindow(1 days); assertEq( - restakingRewardsDepositor.getRewardsDistributionWindow(), - 1 days, - "Rewards distribution window should be 1 days" + revenueDepositor.getRewardsDistributionWindow(), 1 days, "Rewards distribution window should be 1 days" ); } function testRevert_setRewardsDistributionWindow_InvalidWindow() public { vm.startPrank(DAO); - vm.expectRevert(IPufferRestakingRewardsDepositor.InvalidDistributionWindow.selector); - restakingRewardsDepositor.setRewardsDistributionWindow(15 days); + vm.expectRevert(IPufferRevenueDepositor.InvalidDistributionWindow.selector); + revenueDepositor.setRewardsDistributionWindow(15 days); } function testRevert_setRewardsDistributionWhenAlreadyDepositing() public withRewardsDistributionWindow(1 days) { assertEq(block.timestamp, 1, "Timestamp should be 1"); - deal(address(restakingRewardsDepositor), 100 ether); + deal(address(revenueDepositor), 100 ether); vm.startPrank(OPERATIONS_MULTISIG); - restakingRewardsDepositor.depositRestakingRewards(); + revenueDepositor.depositRevenue(); vm.startPrank(DAO); - vm.expectRevert(IPufferRestakingRewardsDepositor.CannotChangeDistributionWindow.selector); - restakingRewardsDepositor.setRewardsDistributionWindow(1 days); + vm.expectRevert(IPufferRevenueDepositor.CannotChangeDistributionWindow.selector); + revenueDepositor.setRewardsDistributionWindow(1 days); } function test_smallRewardsAmount() public withRewardsDistributionWindow(1 days) { - vm.deal(address(restakingRewardsDepositor), 1); // 1 wei + vm.deal(address(revenueDepositor), 1); // 1 wei vm.startPrank(OPERATIONS_MULTISIG); - vm.expectRevert(IPufferRestakingRewardsDepositor.NothingToDistribute.selector); - restakingRewardsDepositor.depositRestakingRewards(); + vm.expectRevert(IPufferRevenueDepositor.NothingToDistribute.selector); + revenueDepositor.depositRevenue(); - vm.deal(address(restakingRewardsDepositor), 20); // 20 wei - restakingRewardsDepositor.depositRestakingRewards(); + vm.deal(address(revenueDepositor), 20); // 20 wei + revenueDepositor.depositRevenue(); // 1 wei went to the treasury - assertEq( - restakingRewardsDepositor.getPendingDistributionAmount(), 19, "Pending distribution amount should be 19" - ); + assertEq(revenueDepositor.getPendingDistributionAmount(), 19, "Pending distribution amount should be 19"); // After half of the distribution window, the pending distribution amount is half of the total amount vm.warp(block.timestamp + 12 hours); // 19/2 = 9.5, rounded down to 9 - assertEq(restakingRewardsDepositor.getPendingDistributionAmount(), 9, "Pending distribution amount should be 9"); + assertEq(revenueDepositor.getPendingDistributionAmount(), 9, "Pending distribution amount should be 9"); } function test_distributeRewards() public withRewardsDistributionWindow(1 days) { @@ -93,15 +89,15 @@ contract PufferRestakingRewardsDepositorTest is UnitTestHelper { uint256 totalAssetsBefore = pufferVault.totalAssets(); - vm.deal(address(restakingRewardsDepositor), amount); + vm.deal(address(revenueDepositor), amount); vm.startPrank(OPERATIONS_MULTISIG); - restakingRewardsDepositor.depositRestakingRewards(); + revenueDepositor.depositRevenue(); // 4 Wei precision loss // Right away, the pending distribution amount is the amount deposited to the Vault assertApproxEqAbs( - restakingRewardsDepositor.getPendingDistributionAmount(), + revenueDepositor.getPendingDistributionAmount(), 91 ether, 4, "Pending distribution amount should be the amount deposited" @@ -116,7 +112,7 @@ contract PufferRestakingRewardsDepositorTest is UnitTestHelper { ); // After the distribution window, the pending distribution amount is 0 assertApproxEqAbs( - restakingRewardsDepositor.getPendingDistributionAmount(), 0, 4, "Pending distribution amount should be 0" + revenueDepositor.getPendingDistributionAmount(), 0, 4, "Pending distribution amount should be 0" ); vm.warp(block.timestamp + 10 days); @@ -126,65 +122,65 @@ contract PufferRestakingRewardsDepositorTest is UnitTestHelper { ); // After the distribution window, the pending distribution amount is 0 assertApproxEqAbs( - restakingRewardsDepositor.getPendingDistributionAmount(), 0, 4, "Pending distribution amount should be 0" + revenueDepositor.getPendingDistributionAmount(), 0, 4, "Pending distribution amount should be 0" ); } function testRevert_nothingToDistribute() public { vm.startPrank(OPERATIONS_MULTISIG); - vm.expectRevert(IPufferRestakingRewardsDepositor.NothingToDistribute.selector); - restakingRewardsDepositor.depositRestakingRewards(); + vm.expectRevert(IPufferRevenueDepositor.NothingToDistribute.selector); + revenueDepositor.depositRevenue(); } function testRevert_vaultHasUndepositedRewards() public withRewardsDistributionWindow(1 days) { assertEq(block.timestamp, 1, "Timestamp should be 1"); - deal(address(restakingRewardsDepositor), 100 ether); + deal(address(revenueDepositor), 100 ether); vm.startPrank(OPERATIONS_MULTISIG); - restakingRewardsDepositor.depositRestakingRewards(); + revenueDepositor.depositRevenue(); - deal(address(restakingRewardsDepositor), 100 ether); + deal(address(revenueDepositor), 100 ether); - vm.expectRevert(IPufferRestakingRewardsDepositor.VaultHasUndepositedRewards.selector); - restakingRewardsDepositor.depositRestakingRewards(); + vm.expectRevert(IPufferRevenueDepositor.VaultHasUndepositedRewards.selector); + revenueDepositor.depositRevenue(); } function test_setRnoRewardsBps() public { - uint256 oldFeeBps = restakingRewardsDepositor.getRnoRewardsBps(); + uint256 oldFeeBps = revenueDepositor.getRnoRewardsBps(); uint256 newFeeBps = 100; vm.startPrank(DAO); vm.expectEmit(true, true, true, true); - emit IPufferRestakingRewardsDepositor.RnoRewardsBpsChanged(oldFeeBps, newFeeBps); - restakingRewardsDepositor.setRnoRewardsBps(uint128(newFeeBps)); + emit IPufferRevenueDepositor.RnoRewardsBpsChanged(oldFeeBps, newFeeBps); + revenueDepositor.setRnoRewardsBps(uint128(newFeeBps)); } function test_setTreasuryRewardsBps() public { - uint256 oldFeeBps = restakingRewardsDepositor.getTreasuryRewardsBps(); + uint256 oldFeeBps = revenueDepositor.getTreasuryRewardsBps(); uint256 newFeeBps = 100; vm.startPrank(DAO); vm.expectEmit(true, true, true, true); - emit IPufferRestakingRewardsDepositor.TreasuryRewardsBpsChanged(oldFeeBps, newFeeBps); - restakingRewardsDepositor.setTreasuryRewardsBps(uint128(newFeeBps)); + emit IPufferRevenueDepositor.TreasuryRewardsBpsChanged(oldFeeBps, newFeeBps); + revenueDepositor.setTreasuryRewardsBps(uint128(newFeeBps)); } function testRevert_setRnoRewardsBps_InvalidBps() public { vm.startPrank(DAO); - vm.expectRevert(IPufferRestakingRewardsDepositor.InvalidBps.selector); - restakingRewardsDepositor.setRnoRewardsBps(uint128(1001)); + vm.expectRevert(IPufferRevenueDepositor.InvalidBps.selector); + revenueDepositor.setRnoRewardsBps(uint128(1001)); } function testRevert_setTreasuryRewardsBps_InvalidBps() public { vm.startPrank(DAO); - vm.expectRevert(IPufferRestakingRewardsDepositor.InvalidBps.selector); - restakingRewardsDepositor.setTreasuryRewardsBps(uint128(2000)); + vm.expectRevert(IPufferRevenueDepositor.InvalidBps.selector); + revenueDepositor.setTreasuryRewardsBps(uint128(2000)); } function testRevert_removeRestakingOperator_NotOperator() public { vm.startPrank(OPERATIONS_MULTISIG); - vm.expectRevert(IPufferRestakingRewardsDepositor.RestakingOperatorNotSet.selector); - restakingRewardsDepositor.removeRestakingOperator(address(1)); + vm.expectRevert(IPufferRevenueDepositor.RestakingOperatorNotSet.selector); + revenueDepositor.removeRestakingOperator(address(1)); } function testRevert_addRestakingOperators_InvalidOperatorZeroAddress() public { @@ -194,7 +190,7 @@ contract PufferRestakingRewardsDepositorTest is UnitTestHelper { operators[0] = address(0); vm.expectRevert(InvalidAddress.selector); - restakingRewardsDepositor.addRestakingOperators(operators); + revenueDepositor.addRestakingOperators(operators); } function test_addAndRemoveRestakingOperator() public { @@ -206,15 +202,15 @@ contract PufferRestakingRewardsDepositorTest is UnitTestHelper { operators[0] = newOperator; vm.expectEmit(true, true, true, true); - emit IPufferRestakingRewardsDepositor.RestakingOperatorAdded(operators[0]); - restakingRewardsDepositor.addRestakingOperators(operators); + emit IPufferRevenueDepositor.RestakingOperatorAdded(operators[0]); + revenueDepositor.addRestakingOperators(operators); - vm.expectRevert(IPufferRestakingRewardsDepositor.RestakingOperatorAlreadySet.selector); - restakingRewardsDepositor.addRestakingOperators(operators); + vm.expectRevert(IPufferRevenueDepositor.RestakingOperatorAlreadySet.selector); + revenueDepositor.addRestakingOperators(operators); vm.expectEmit(true, true, true, true); - emit IPufferRestakingRewardsDepositor.RestakingOperatorRemoved(newOperator); - restakingRewardsDepositor.removeRestakingOperator(newOperator); + emit IPufferRevenueDepositor.RestakingOperatorRemoved(newOperator); + revenueDepositor.removeRestakingOperator(newOperator); } function test_depositRestakingRewardsInstantly() public { @@ -223,8 +219,8 @@ contract PufferRestakingRewardsDepositorTest is UnitTestHelper { weth.deposit{ value: 90 ether }(); // Transfer 90 WETH and 10 ETH, the contract should wrap the 10 ETH - weth.transfer(address(restakingRewardsDepositor), 90 ether); - (bool success,) = address(restakingRewardsDepositor).call{ value: 10 ether }(""); + weth.transfer(address(revenueDepositor), 90 ether); + (bool success,) = address(revenueDepositor).call{ value: 10 ether }(""); require(success, "Transfer failed"); uint256 totalAssetsBefore = pufferVault.totalAssets(); @@ -233,12 +229,10 @@ contract PufferRestakingRewardsDepositorTest is UnitTestHelper { vm.startPrank(OPERATIONS_MULTISIG); // Trigger deposit of restaking rewards - restakingRewardsDepositor.depositRestakingRewards(); + revenueDepositor.depositRevenue(); assertEq( - restakingRewardsDepositor.getLastDepositTimestamp(), - 1, - "Last deposit timestamp should be the current timestamp 1" + revenueDepositor.getLastDepositTimestamp(), 1, "Last deposit timestamp should be the current timestamp 1" ); // We have precision loss from the RNO rewards distribution, 4 wei is going to the Vault because of the rounding @@ -246,7 +240,7 @@ contract PufferRestakingRewardsDepositorTest is UnitTestHelper { pufferVault.totalAssets(), totalAssetsBefore + 91 ether, 4, "Total assets should be 91 ETH more" ); - assertEq(weth.balanceOf(address(restakingRewardsDepositor.TREASURY())), 5 ether, "Treasury should have 5 WETH"); + assertEq(weth.balanceOf(address(revenueDepositor.TREASURY())), 5 ether, "Treasury should have 5 WETH"); assertEq(weth.balanceOf(RNO1), 0.571428571428571428 ether, "RNO1 should have 0.571428571428571428 WETH"); assertEq(weth.balanceOf(RNO2), 0.571428571428571428 ether, "RNO1 should have 0.571428571428571428 WETH"); assertEq(weth.balanceOf(RNO3), 0.571428571428571428 ether, "RNO3 should have 0.571428571428571428 WETH"); diff --git a/mainnet-contracts/test/unit/PufferVaultV2Property.t.sol b/mainnet-contracts/test/unit/PufferVaultV2Property.t.sol index 6723e6a..c6d19c6 100644 --- a/mainnet-contracts/test/unit/PufferVaultV2Property.t.sol +++ b/mainnet-contracts/test/unit/PufferVaultV2Property.t.sol @@ -17,7 +17,7 @@ import { MockPufferOracle } from "../mocks/MockPufferOracle.sol"; import { WETH9 } from "../mocks/WETH9.sol"; import { ROLE_ID_DAO } from "../../script/Roles.sol"; import { GenerateAccessManagerCallData } from "script/GenerateAccessManagerCallData.sol"; -import { MockRestakingRewardsDepositor } from "../mocks/MockRestakingRewardsDepositor.sol"; +import { MockRevenueDepositor } from "../mocks/MockRevenueDepositor.sol"; contract PufferVaultV2Property is ERC4626Test { PufferDepositor public pufferDepositor; @@ -62,13 +62,11 @@ contract PufferVaultV2Property is ERC4626Test { PufferDeployment memory deployment = new DeployPufETH().run(); MockPufferOracle mockOracle = new MockPufferOracle(); - MockRestakingRewardsDepositor mockRestakingRewardsDepositor = new MockRestakingRewardsDepositor(); + MockRevenueDepositor mockRevenueDepositor = new MockRevenueDepositor(); BridgingDeployment memory bridgingDeployment = new DeployPufETHBridging().run(deployment); - new UpgradePufETH().run( - deployment, bridgingDeployment, address(mockOracle), address(mockRestakingRewardsDepositor) - ); + new UpgradePufETH().run(deployment, bridgingDeployment, address(mockOracle), address(mockRevenueDepositor)); pufferDepositor = PufferDepositor(payable(deployment.pufferDepositor)); pufferVault = PufferVaultV2(payable(deployment.pufferVault));