diff --git a/mainnet-contracts/script/GenerateAccessManagerCallData.sol b/mainnet-contracts/script/GenerateAccessManagerCallData.sol index 6a87ff3..15a31de 100644 --- a/mainnet-contracts/script/GenerateAccessManagerCallData.sol +++ b/mainnet-contracts/script/GenerateAccessManagerCallData.sol @@ -21,14 +21,13 @@ import { PUBLIC_ROLE, ROLE_ID_DAO, ROLE_ID_PUFFER_PROTOCOL, ROLE_ID_OPERATIONS_M */ contract GenerateAccessManagerCallData is Script { function run(address pufferVaultProxy, address pufferDepositorProxy) public pure returns (bytes memory) { - bytes[] memory calldatas = new bytes[](5); + bytes[] memory calldatas = new bytes[](4); // Combine the two calldatas calldatas[0] = _getPublicSelectorsCalldata({ pufferVaultProxy: pufferVaultProxy }); - calldatas[1] = _getDaoSelectorsCalldataCalldata({ pufferVaultProxy: pufferVaultProxy }); - calldatas[2] = _getProtocolSelectorsCalldata({ pufferVaultProxy: pufferVaultProxy }); - calldatas[3] = _getOperationsSelectorsCalldata({ pufferVaultProxy: pufferVaultProxy }); - calldatas[4] = _getPublicSelectorsForDepositor({ pufferDepositorProxy: pufferDepositorProxy }); + calldatas[1] = _getProtocolSelectorsCalldata({ pufferVaultProxy: pufferVaultProxy }); + calldatas[2] = _getOperationsSelectorsCalldata({ pufferVaultProxy: pufferVaultProxy }); + calldatas[3] = _getPublicSelectorsForDepositor({ pufferDepositorProxy: pufferDepositorProxy }); bytes memory encodedMulticall = abi.encodeCall(Multicall.multicall, (calldatas)); @@ -52,16 +51,6 @@ contract GenerateAccessManagerCallData is Script { ); } - function _getDaoSelectorsCalldataCalldata(address pufferVaultProxy) internal pure returns (bytes memory) { - // DAO selectors - bytes4[] memory daoSelectors = new bytes4[](1); - daoSelectors[0] = PufferVaultV2.setDailyWithdrawalLimit.selector; - - return abi.encodeWithSelector( - AccessManager.setTargetFunctionRole.selector, pufferVaultProxy, daoSelectors, ROLE_ID_DAO - ); - } - function _getProtocolSelectorsCalldata(address pufferVaultProxy) internal pure returns (bytes memory) { // Puffer Protocol only // PufferProtocol will get `ROLE_ID_PUFFER_PROTOCOL` when it's deployed diff --git a/mainnet-contracts/script/SetupAccess.s.sol b/mainnet-contracts/script/SetupAccess.s.sol index d93abb5..af4118d 100644 --- a/mainnet-contracts/script/SetupAccess.s.sol +++ b/mainnet-contracts/script/SetupAccess.s.sol @@ -86,7 +86,7 @@ contract SetupAccess is BaseScript { bytes[] memory coordinatorAccess, bytes[] memory validatorTicketAccess ) internal view returns (bytes[] memory calldatas) { - calldatas = new bytes[](31); + calldatas = new bytes[](30); calldatas[0] = _setupGuardianModuleRoles(); calldatas[1] = _setupEnclaveVerifierRoles(); calldatas[2] = rolesCalldatas[0]; @@ -105,27 +105,26 @@ contract SetupAccess is BaseScript { calldatas[13] = validatorTicketRoles[1]; calldatas[14] = vaultMainnetAccess[0]; - calldatas[15] = vaultMainnetAccess[1]; - calldatas[16] = pufferOracleAccess[0]; - calldatas[17] = pufferOracleAccess[1]; - calldatas[18] = pufferOracleAccess[2]; + calldatas[15] = pufferOracleAccess[0]; + calldatas[16] = pufferOracleAccess[1]; + calldatas[17] = pufferOracleAccess[2]; - calldatas[19] = moduleManagerAccess[0]; - calldatas[20] = moduleManagerAccess[1]; + calldatas[18] = moduleManagerAccess[0]; + calldatas[19] = moduleManagerAccess[1]; - calldatas[21] = roleLabels[0]; - calldatas[22] = roleLabels[1]; - calldatas[23] = roleLabels[2]; - calldatas[24] = roleLabels[3]; + calldatas[20] = roleLabels[0]; + calldatas[21] = roleLabels[1]; + calldatas[22] = roleLabels[2]; + calldatas[23] = roleLabels[3]; - calldatas[25] = coordinatorAccess[0]; - calldatas[26] = coordinatorAccess[1]; + calldatas[24] = coordinatorAccess[0]; + calldatas[25] = coordinatorAccess[1]; - calldatas[27] = validatorTicketAccess[0]; - calldatas[28] = validatorTicketAccess[1]; - calldatas[29] = validatorTicketAccess[2]; - calldatas[30] = validatorTicketAccess[3]; + calldatas[26] = validatorTicketAccess[0]; + calldatas[27] = validatorTicketAccess[1]; + calldatas[28] = validatorTicketAccess[2]; + calldatas[29] = validatorTicketAccess[3]; } function _labelRoles() internal pure returns (bytes[] memory) { @@ -219,22 +218,12 @@ contract SetupAccess is BaseScript { } function _setupPufferVaultMainnetAccess() internal view returns (bytes[] memory) { - bytes[] memory calldatas = new bytes[](2); - - bytes4[] memory operationsSelectors = new bytes4[](1); - operationsSelectors[0] = PufferVaultV2.setDailyWithdrawalLimit.selector; - - calldatas[0] = abi.encodeWithSelector( - AccessManager.setTargetFunctionRole.selector, - pufferDeployment.pufferVault, - operationsSelectors, - ROLE_ID_OPERATIONS_MULTISIG - ); + bytes[] memory calldatas = new bytes[](1); bytes4[] memory protocolSelectors = new bytes4[](1); protocolSelectors[0] = PufferVaultV2.transferETH.selector; - calldatas[1] = abi.encodeWithSelector( + calldatas[0] = abi.encodeWithSelector( AccessManager.setTargetFunctionRole.selector, pufferDeployment.pufferVault, protocolSelectors, diff --git a/mainnet-contracts/src/PufferVaultStorage.sol b/mainnet-contracts/src/PufferVaultStorage.sol index f64829f..c463550 100644 --- a/mainnet-contracts/src/PufferVaultStorage.sol +++ b/mainnet-contracts/src/PufferVaultStorage.sol @@ -27,9 +27,9 @@ abstract contract PufferVaultStorage { EnumerableSet.Bytes32Set deprecated_eigenLayerWithdrawals; // Not in use anymore EnumerableMap.UintToUintMap lidoWithdrawalAmounts; // 1 Slot for daily withdrawal limits - uint96 dailyAssetsWithdrawalLimit; - uint96 assetsWithdrawnToday; - uint64 lastWithdrawalDay; + uint96 deprecated_dailyAssetsWithdrawalLimit; + uint96 deprecated_assetsWithdrawnToday; + uint64 deprecated_lastWithdrawalDay; // 1 slot for withdrawal fee uint256 exitFeeBasisPoints; // ETH rewards amount diff --git a/mainnet-contracts/src/PufferVaultV2.sol b/mainnet-contracts/src/PufferVaultV2.sol index fb82f3a..8a8c451 100644 --- a/mainnet-contracts/src/PufferVaultV2.sol +++ b/mainnet-contracts/src/PufferVaultV2.sol @@ -59,9 +59,6 @@ contract PufferVaultV2 is PufferVault, IPufferVaultV2 { PUFFER_ORACLE = oracle; ERC4626Storage storage erc4626Storage = _getERC4626StorageInternal(); erc4626Storage._asset = _WETH; - // This redundant code is for the Echidna fuzz testing - _setDailyWithdrawalLimit(100 ether); - _updateDailyWithdrawals(0); _setExitFeeBasisPoints(100); // 1% _disableInitializers(); } @@ -76,8 +73,6 @@ contract PufferVaultV2 is PufferVault, IPufferVaultV2 { // In this initialization, we swap out the underlying stETH with WETH ERC4626Storage storage erc4626Storage = _getERC4626StorageInternal(); erc4626Storage._asset = _WETH; - _setDailyWithdrawalLimit(100 ether); - _updateDailyWithdrawals(0); _setExitFeeBasisPoints(100); // 1% // Return pufETH to Puffers @@ -144,8 +139,6 @@ contract PufferVaultV2 is PufferVault, IPufferVaultV2 { revert ERC4626ExceededMaxWithdraw(owner, assets, maxAssets); } - _updateDailyWithdrawals(assets); - _wrapETH(assets); uint256 shares = previewWithdraw(assets); @@ -179,8 +172,6 @@ contract PufferVaultV2 is PufferVault, IPufferVaultV2 { uint256 assets = previewRedeem(shares); - _updateDailyWithdrawals(assets); - _wrapETH(assets); _withdraw({ caller: _msgSender(), receiver: receiver, owner: owner, assets: assets, shares: shares }); @@ -370,16 +361,6 @@ contract PufferVaultV2 is PufferVault, IPufferVaultV2 { return _convertToShares(assets, Math.Rounding.Ceil); } - /** - * @notice Sets a new daily withdrawal limit - * @dev Restricted to the DAO - * @param newLimit The new daily limit to be set - */ - function setDailyWithdrawalLimit(uint96 newLimit) external restricted { - _setDailyWithdrawalLimit(newLimit); - _resetDailyWithdrawals(); - } - /** * @param newExitFeeBasisPoints is the new exit fee basis points * @dev Restricted to the DAO @@ -388,48 +369,6 @@ contract PufferVaultV2 is PufferVault, IPufferVaultV2 { _setExitFeeBasisPoints(newExitFeeBasisPoints); } - /** - * @inheritdoc IPufferVaultV2 - */ - function getRemainingAssetsDailyWithdrawalLimit() public view virtual returns (uint256) { - VaultStorage storage $ = _getPufferVaultStorage(); - uint96 dailyAssetsWithdrawalLimit = $.dailyAssetsWithdrawalLimit; - uint96 assetsWithdrawnToday = $.assetsWithdrawnToday; - - // If we are in a new day, return the full daily limit - if ($.lastWithdrawalDay < block.timestamp / 1 days) { - return dailyAssetsWithdrawalLimit; - } - - return dailyAssetsWithdrawalLimit - assetsWithdrawnToday; - } - - /** - * @notice Calculates the maximum amount of assets (WETH) that can be withdrawn by the `owner`. - * @dev This function considers both the remaining daily withdrawal limit and the `owner`'s balance. - * See {IERC4626-maxWithdraw} - * @param owner The address of the owner for which the maximum withdrawal amount is calculated. - * @return maxAssets The maximum amount of assets that can be withdrawn by the `owner`. - */ - function maxWithdraw(address owner) public view virtual override returns (uint256 maxAssets) { - uint256 remainingAssets = getRemainingAssetsDailyWithdrawalLimit(); - uint256 maxUserAssets = previewRedeem(balanceOf(owner)); - return remainingAssets < maxUserAssets ? remainingAssets : maxUserAssets; - } - - /** - * @notice Calculates the maximum amount of shares (pufETH) that can be redeemed by the `owner`. - * @dev This function considers both the remaining daily withdrawal limit in terms of assets and converts it to shares, and the `owner`'s share balance. - * See {IERC4626-maxRedeem} - * @param owner The address of the owner for which the maximum redeemable shares are calculated. - * @return maxShares The maximum amount of shares that can be redeemed by the `owner`. - */ - function maxRedeem(address owner) public view virtual override returns (uint256 maxShares) { - uint256 remainingShares = previewWithdraw(getRemainingAssetsDailyWithdrawalLimit()); - uint256 userShares = balanceOf(owner); - return remainingShares < userShares ? remainingShares : userShares; - } - /** * @dev Preview adding an exit fee on withdraw. See {IERC4626-previewWithdraw}. */ @@ -483,31 +422,6 @@ contract PufferVaultV2 is PufferVault, IPufferVaultV2 { } } - /** - * @notice Updates the amount of assets (WETH) withdrawn today - * @param withdrawalAmount is the assets (WETH) amount - */ - function _updateDailyWithdrawals(uint256 withdrawalAmount) internal virtual { - VaultStorage storage $ = _getPufferVaultStorage(); - - // Check if it's a new day to reset the withdrawal count - if ($.lastWithdrawalDay < block.timestamp / 1 days) { - _resetDailyWithdrawals(); - } - $.assetsWithdrawnToday += uint96(withdrawalAmount); - emit AssetsWithdrawnToday($.assetsWithdrawnToday); - } - - /** - * @notice Updates the maximum amount of assets (WETH) that can be withdrawn daily - * @param newLimit is the assets (WETH) amount - */ - function _setDailyWithdrawalLimit(uint96 newLimit) internal virtual { - VaultStorage storage $ = _getPufferVaultStorage(); - emit DailyWithdrawalLimitSet($.dailyAssetsWithdrawalLimit, newLimit); - $.dailyAssetsWithdrawalLimit = newLimit; - } - /** * @notice Updates the exit fee basis points * @dev 200 Basis points = 2% is the maximum exit fee @@ -542,13 +456,6 @@ contract PufferVaultV2 is PufferVault, IPufferVaultV2 { _; } - function _resetDailyWithdrawals() internal virtual { - VaultStorage storage $ = _getPufferVaultStorage(); - $.lastWithdrawalDay = uint64(block.timestamp / 1 days); - $.assetsWithdrawnToday = 0; - emit DailyWithdrawalLimitReset(); - } - function _authorizeUpgrade(address newImplementation) internal virtual override restricted { } function _getERC4626StorageInternal() private pure returns (ERC4626Storage storage $) { diff --git a/mainnet-contracts/src/interface/IPufferVaultV2.sol b/mainnet-contracts/src/interface/IPufferVaultV2.sol index 5b19d46..fcdc909 100644 --- a/mainnet-contracts/src/interface/IPufferVaultV2.sol +++ b/mainnet-contracts/src/interface/IPufferVaultV2.sol @@ -24,24 +24,6 @@ interface IPufferVaultV2 is IPufferVault { */ error InvalidExitFeeBasisPoints(); - /** - * Emitted when assets (WETH) are withdrawn - * @dev Signature: 0x139f9ee0762f3b0c92a4b8c7b8fe8be6b12aaece4b9b22de6bf1ba1094dcd998 - */ - event AssetsWithdrawnToday(uint256 withdrawalAmount); - - /** - * Emitted daily withdrawal limit is reset - * @dev Signature: 0x190567136e3dd93d29bef98a7c7c87cff34ee88e71d634b52f5fb3b531085f40 - */ - event DailyWithdrawalLimitReset(); - - /** - * Emitted when the daily withdrawal limit is set - * @dev Signature: 0x8d5f7487ce1fd25059bd15204a55ea2c293160362b849a6f9244aec7d5a3700b - */ - event DailyWithdrawalLimitSet(uint96 oldLimit, uint96 newLimit); - /** * Emitted when the Vault transfers ETH to a specified address * @dev Signature: 0xba7bb5aa419c34d8776b86cc0e9d41e72d74a893a511f361a11af6c05e920c3d @@ -65,12 +47,6 @@ interface IPufferVaultV2 is IPufferVault { */ function getExitFeeBasisPoints() external view returns (uint256); - /** - * @notice Returns the remaining assets that can be withdrawn today - * @return The remaining assets that can be withdrawn today - */ - function getRemainingAssetsDailyWithdrawalLimit() external view returns (uint256); - /** * @notice Deposits native ETH into the Puffer Vault * @param receiver The recipient of pufETH tokens diff --git a/mainnet-contracts/test/Integration/PufferTest.integration.t.sol b/mainnet-contracts/test/Integration/PufferTest.integration.t.sol index 49f26ea..b1f4273 100644 --- a/mainnet-contracts/test/Integration/PufferTest.integration.t.sol +++ b/mainnet-contracts/test/Integration/PufferTest.integration.t.sol @@ -279,8 +279,6 @@ contract PufferTest is Test { assertEq(pufferVault.totalAssets(), assetsBefore + 10 ether, "Previous assets should increase"); - PufferVaultV2(payable(address(pufferVault))).getRemainingAssetsDailyWithdrawalLimit(); - pufferVault.balanceOf(eve); uint256 maxWithdraw = pufferVault.maxWithdraw(eve); diff --git a/mainnet-contracts/test/Integration/PufferVaultV2.fork.t.sol b/mainnet-contracts/test/Integration/PufferVaultV2.fork.t.sol index fc57913..358da6e 100644 --- a/mainnet-contracts/test/Integration/PufferVaultV2.fork.t.sol +++ b/mainnet-contracts/test/Integration/PufferVaultV2.fork.t.sol @@ -50,7 +50,6 @@ contract PufferVaultV2ForkTest is MainnetForkTestHelper { assertEq(pufferVault.asset(), address(_WETH), "asset"); assertEq(pufferVault.getPendingLidoETHAmount(), 0, "0 pending lido eth"); assertEq(pufferVault.totalAssets(), 368072.286049064583783628 ether, "total assets"); - assertEq(pufferVault.getRemainingAssetsDailyWithdrawalLimit(), 100 ether, "daily withdrawal limit"); assertEq(pufferVault.getExitFeeBasisPoints(), 100, "1% withdrawal fee"); } @@ -138,38 +137,6 @@ contract PufferVaultV2ForkTest is MainnetForkTestHelper { assertEq(pufferVault.maxRedeem(pufferWhale), 100.595147442558494386 ether, "max redeem"); } - function test_setDailyWithdrawalLimit() public { - // Get withdrawal liquidity - _withdraw_stETH_from_lido(); - - address dao = makeAddr("dao"); - - // Grant DAO role to 'dao' address - vm.startPrank(address(timelock)); - accessManager.grantRole(ROLE_ID_DAO, dao, 0); - - // Whale has more than 100 ether, but the limit is 100 eth - assertEq(pufferVault.maxWithdraw(pufferWhale), 100 ether, "max withdraw"); - - vm.startPrank(pufferWhale); - pufferVault.withdraw(pufferVault.maxWithdraw(pufferWhale), pufferWhale, pufferWhale); - - assertEq(pufferVault.getRemainingAssetsDailyWithdrawalLimit(), 0, "remaining assets daily withdrawal limit"); - - // Set the new limit - uint96 newLimit = 1000 ether; - vm.startPrank(dao); - vm.expectEmit(true, true, true, true); - emit IPufferVaultV2.DailyWithdrawalLimitReset(); - pufferVault.setDailyWithdrawalLimit(newLimit); - - assertEq(pufferVault.getRemainingAssetsDailyWithdrawalLimit(), newLimit, "daily withdrawal limit"); - // Shares amount - uint256 maxRedeem = pufferVault.maxRedeem(pufferWhale); - // If we convert shares to assets, it should be equal to the new limit + 10 (1% is the withdrawal fee) - assertEq(pufferVault.convertToAssets(maxRedeem), 1010 ether, "max redeem converted to assets"); - } - function test_withdraw_fee() public { // Get withdrawal liquidity _withdraw_stETH_from_lido(); @@ -238,32 +205,6 @@ contract PufferVaultV2ForkTest is MainnetForkTestHelper { uint256 recipientBalance = _WETH.balanceOf(recipient); assertGt(recipientBalance, 20 ether, "+10 weth"); - - // Assert the daily withdrawal limit - assertEq( - pufferVault.getRemainingAssetsDailyWithdrawalLimit(), 100 ether - recipientBalance, "daily withdrawal limit" - ); - } - - function test_daily_limit_reset() public { - _withdraw_stETH_from_lido(); - - vm.startPrank(pufferWhale); - assertEq(pufferVault.getRemainingAssetsDailyWithdrawalLimit(), 100 ether, "daily withdrawal limit"); - - assertEq(pufferVault.maxWithdraw(pufferWhale), 100 ether, "max withdraw"); - pufferVault.withdraw(50 ether, pufferWhale, pufferWhale); - - assertEq(pufferVault.getRemainingAssetsDailyWithdrawalLimit(), 50 ether, "daily withdrawal limit reduced"); - - vm.warp(block.timestamp + 1 days); - - assertEq(pufferVault.getRemainingAssetsDailyWithdrawalLimit(), 100 ether, "daily withdrawal limit reduced"); - - assertEq(pufferVault.maxWithdraw(pufferWhale), 100 ether, "max withdraw"); - pufferVault.withdraw(22 ether, pufferWhale, pufferWhale); - - assertEq(pufferVault.getRemainingAssetsDailyWithdrawalLimit(), 78 ether, "daily withdrawal limit reduced"); } function test_withdrawal() public { @@ -271,17 +212,14 @@ contract PufferVaultV2ForkTest is MainnetForkTestHelper { _withdraw_stETH_from_lido(); vm.startPrank(pufferWhale); - assertEq(pufferVault.getRemainingAssetsDailyWithdrawalLimit(), 100 ether, "daily withdrawal limit"); assertEq(pufferVault.maxWithdraw(pufferWhale), 100 ether, "max withdraw"); pufferVault.withdraw(50 ether, pufferWhale, pufferWhale); - assertEq(pufferVault.getRemainingAssetsDailyWithdrawalLimit(), 50 ether, "daily withdrawal limit reduced"); assertEq(pufferVault.maxWithdraw(pufferWhale), 50 ether, "leftover max withdraw"); pufferVault.withdraw(50 ether, pufferWhale, pufferWhale); assertEq(pufferVault.maxWithdraw(pufferWhale), 0 ether, "no leftover max withdraw"); - assertEq(pufferVault.getRemainingAssetsDailyWithdrawalLimit(), 0 ether, "everything withdrawn"); } function test_withdrawal_transfers_to_receiver() public { @@ -385,29 +323,6 @@ contract PufferVaultV2ForkTest is MainnetForkTestHelper { pufferVault.depositStETH(100 ether + 1, alice); } - function test_change_withdrawal_limit() public { - _withdraw_stETH_from_lido(); - - address dao = makeAddr("dao"); - - // Grant DAO role to 'dao' address - vm.startPrank(address(timelock)); - accessManager.grantRole(ROLE_ID_DAO, dao, 0); - - vm.startPrank(pufferWhale); - pufferVault.withdraw(20 ether, pufferWhale, pufferWhale); - - assertEq(pufferVault.getRemainingAssetsDailyWithdrawalLimit(), 80 ether, "daily withdrawal limit"); - - // Set the new limit - uint96 newLimit = 10 ether; - vm.startPrank(dao); - pufferVault.setDailyWithdrawalLimit(newLimit); - - // The remaining limit is reset in `setDailyWithdrawalLimit` - assertEq(pufferVault.getRemainingAssetsDailyWithdrawalLimit(), 10 ether, "10 ether left - limit is reset"); - } - function test_burn() public withCaller(pufferWhale) { vm.expectRevert(); pufferVault.burn(100 ether); diff --git a/mainnet-contracts/test/unit/PufferProtocol.t.sol b/mainnet-contracts/test/unit/PufferProtocol.t.sol index 1142eb0..192befd 100644 --- a/mainnet-contracts/test/unit/PufferProtocol.t.sol +++ b/mainnet-contracts/test/unit/PufferProtocol.t.sol @@ -68,9 +68,6 @@ contract PufferProtocolTest is UnitTestHelper { accessManager.grantRole(ROLE_ID_OPERATIONS_MULTISIG, address(this), 0); vm.stopPrank(); - // Set daily withdrawals limit - pufferVault.setDailyWithdrawalLimit(1000 ether); - _skipDefaultFuzzAddresses(); fuzzedAddressMapping[address(pufferProtocol)] = true; diff --git a/mainnet-contracts/test/unit/PufferWithdrawalManager.t.sol b/mainnet-contracts/test/unit/PufferWithdrawalManager.t.sol index bb8ab33..f6bdc90 100644 --- a/mainnet-contracts/test/unit/PufferWithdrawalManager.t.sol +++ b/mainnet-contracts/test/unit/PufferWithdrawalManager.t.sol @@ -697,8 +697,6 @@ contract PufferWithdrawalManagerTest is UnitTestHelper { function test_funds_returning_edge_case() public { assertEq(pufferVault.totalSupply(), 1000 ether, "totalSupply should be 1000 ETH"); - vm.startPrank(address(DAO)); - pufferVault.setDailyWithdrawalLimit(type(uint96).max); vm.startPrank(address(timelock)); pufferVault.setExitFeeBasisPoints(0);