-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from yieldnest/feature/WithdrawalsProcessor-w…
…rapper add src/WithdrawalsProcessor.sol convenience to bundle processing and…
- Loading branch information
Showing
7 changed files
with
569 additions
and
27 deletions.
There are no files selected for viewing
228 changes: 228 additions & 0 deletions
228
broadcast/DeployYnETHWithdrawals.s.sol/17000/run-1728146182.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"DEPLOYER": "0xd7d4A7f14265B0A69AE482b85B0a8496c3F99fb9", | ||
"implementation-stakingNodesManager": "0x0000000000000000000000000000000000000000", | ||
"implementation-withdrawalQueueManager": "0x0000000000000000000000000000000000000000", | ||
"implementation-withdrawalsProcessor": "0x36a38AA91947DbE6539e19512E6FF26576015Bb2", | ||
"implementation-ynETH": "0x0000000000000000000000000000000000000000", | ||
"implementation-ynETHRedemptionAssetsVault": "0x0000000000000000000000000000000000000000", | ||
"proxy-withdrawalQueueManager": "0x0000000000000000000000000000000000000000", | ||
"proxy-withdrawalsProcessor": "0x48E3FdCE3E2d5A3Fa34bdEd9eb9dEeBB48217ba3", | ||
"proxy-ynETHRedemptionAssetsVault": "0x0000000000000000000000000000000000000000", | ||
"proxyAdmin-withdrawalQueueManager": "0x0000000000000000000000000000000000000000", | ||
"proxyAdmin-withdrawalsProcessor": "0x22D9bc7555875af63a51c20026f02E752781A8c0", | ||
"proxyAdmin-ynETHRedemptionAssetsVault": "0x0000000000000000000000000000000000000000", | ||
"stakingNodeImplementation": "0x0000000000000000000000000000000000000000" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// SPDX-License-Identifier: BSD 3-Clause License | ||
pragma solidity ^0.8.24; | ||
|
||
import {IStakingNodesManager} from "./interfaces/IStakingNodesManager.sol"; | ||
import {IDelegationManager} from "lib/eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; | ||
import {IStakingNodesManager, IStakingNodesManager as WithdrawalAction} from "./interfaces/IStakingNodesManager.sol"; | ||
import {Initializable} from "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol"; | ||
import {AccessControlUpgradeable} from "lib/openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol"; | ||
|
||
interface IWithdrawalsProcessorEvents { | ||
event WithdrawalsCompletedAndProcessed( | ||
IStakingNodesManager.WithdrawalAction withdrawalAction, | ||
uint256 withdrawalsCount | ||
); | ||
} | ||
|
||
contract WithdrawalsProcessor is Initializable, AccessControlUpgradeable, IWithdrawalsProcessorEvents { | ||
|
||
//-------------------------------------------------------------------------------------- | ||
//---------------------------------- ERRORS ------------------------------------------ | ||
//-------------------------------------------------------------------------------------- | ||
|
||
error ZeroAddress(); | ||
|
||
//-------------------------------------------------------------------------------------- | ||
//---------------------------------- ROLES ------------------------------------------- | ||
//-------------------------------------------------------------------------------------- | ||
|
||
bytes32 public constant WITHDRAWAL_MANAGER_ROLE = keccak256("WITHDRAWAL_MANAGER_ROLE"); | ||
|
||
//-------------------------------------------------------------------------------------- | ||
//---------------------------------- VARIABLES --------------------------------------- | ||
//-------------------------------------------------------------------------------------- | ||
|
||
IStakingNodesManager public stakingNodesManager; | ||
|
||
//-------------------------------------------------------------------------------------- | ||
//---------------------------------- INITIALIZATION ---------------------------------- | ||
//-------------------------------------------------------------------------------------- | ||
|
||
|
||
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
function initialize( | ||
IStakingNodesManager _stakingNodesManager, | ||
address _admin, | ||
address _withdrawalManager | ||
) public initializer | ||
notZeroAddress(address(_stakingNodesManager)) | ||
notZeroAddress(_withdrawalManager) | ||
{ | ||
__AccessControl_init(); | ||
|
||
stakingNodesManager = _stakingNodesManager; | ||
_grantRole(DEFAULT_ADMIN_ROLE, _admin); | ||
_grantRole(WITHDRAWAL_MANAGER_ROLE, _withdrawalManager); | ||
} | ||
|
||
/** | ||
* @notice Bundles the completion of queued withdrawals and processing of principal withdrawals for a single node | ||
* @param withdrawalAction The withdrawal action containing node ID and withdrawal amounts | ||
* @param withdrawals Array of withdrawals to complete | ||
* @param middlewareTimesIndexes Array of middleware times indexes for the withdrawals | ||
*/ | ||
function completeAndProcessWithdrawalsForNode( | ||
IStakingNodesManager.WithdrawalAction memory withdrawalAction, | ||
IDelegationManager.Withdrawal[] memory withdrawals, | ||
uint256[] memory middlewareTimesIndexes | ||
) external onlyRole(WITHDRAWAL_MANAGER_ROLE) { | ||
// Complete queued withdrawals | ||
stakingNodesManager.nodes(withdrawalAction.nodeId).completeQueuedWithdrawals(withdrawals, middlewareTimesIndexes); | ||
|
||
// Process principal withdrawal | ||
IStakingNodesManager.WithdrawalAction[] memory actions = new IStakingNodesManager.WithdrawalAction[](1); | ||
actions[0] = withdrawalAction; | ||
stakingNodesManager.processPrincipalWithdrawals(actions); | ||
|
||
// Emit an event for the completed and processed withdrawals | ||
emit WithdrawalsCompletedAndProcessed( | ||
withdrawalAction, | ||
withdrawals.length | ||
); | ||
} | ||
|
||
//-------------------------------------------------------------------------------------- | ||
//---------------------------------- MODIFIERS --------------------------------------- | ||
//-------------------------------------------------------------------------------------- | ||
|
||
/** | ||
* @notice Ensure that the given address is not the zero address. | ||
* @param _address The address to check. | ||
*/ | ||
modifier notZeroAddress(address _address) { | ||
if (_address == address(0)) { | ||
revert ZeroAddress(); | ||
} | ||
_; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.