@@ -44,7 +44,7 @@ contract RocketDepositPool is RocketBase, RocketDepositPoolInterface, RocketVaul
4444 event FundsRequested (address indexed receiver , uint256 validatorId , uint256 amount , bool expressQueue , uint256 time );
4545 event FundsAssigned (address indexed receiver , uint256 amount , uint256 time );
4646 event QueueExited (address indexed nodeAddress , uint256 time );
47- event CreditWithdrawn (address indexed receiver , uint256 amount , uint256 time );
47+ event CreditWithdrawn (address indexed nodeAddress , uint256 amount , uint256 time );
4848
4949 // Structs
5050 struct MinipoolAssignment {
@@ -563,27 +563,43 @@ contract RocketDepositPool is RocketBase, RocketDepositPoolInterface, RocketVaul
563563 /// @notice Allows node operator to withdraw any ETH credit they have as rETH
564564 /// @param _amount Amount in ETH to withdraw
565565 function withdrawCredit (uint256 _amount ) override external onlyRegisteredNode (msg .sender ) onlyThisLatestContract {
566+ address withdrawalAddress = rocketStorage.getNodeWithdrawalAddress (msg .sender );
567+ _withdrawCreditFor (msg .sender , withdrawalAddress, _amount);
568+ }
569+
570+ /// @notice Allows node operator to withdraw any ETH credit they have as rETH from their withdrawal address
571+ /// @param _nodeAddress Address of the node operator
572+ /// @param _amount Amount in ETH to withdraw
573+ function withdrawCreditFor (address _nodeAddress , uint256 _amount ) override public onlyRegisteredNode (_nodeAddress) onlyThisLatestContract {
574+ // Check caller
575+ address withdrawalAddress = rocketStorage.getNodeWithdrawalAddress (_nodeAddress);
576+ require (msg .sender == withdrawalAddress, "Must be called from withdrawal address " );
577+ // Withdraw credit
578+ _withdrawCreditFor (_nodeAddress, withdrawalAddress, _amount);
579+ }
580+
581+ /// @dev Withdraws credit from a given node operator as rETH
582+ function _withdrawCreditFor (address _nodeAddress , address _recipient , uint256 _amount ) internal {
566583 // Check deposits are enabled
567584 RocketDAOProtocolSettingsDepositInterface rocketDAOProtocolSettingsDeposit = RocketDAOProtocolSettingsDepositInterface (getContractAddress ("rocketDAOProtocolSettingsDeposit " ));
568585 require (rocketDAOProtocolSettingsDeposit.getDepositEnabled (), "Deposits into Rocket Pool are currently disabled " );
569586 // Check node operator has sufficient credit
570- uint256 credit = getUint (keccak256 (abi.encodePacked ("node.deposit.credit.balance " , msg . sender )));
587+ uint256 credit = getUint (keccak256 (abi.encodePacked ("node.deposit.credit.balance " , _nodeAddress )));
571588 require (credit >= _amount, "Amount exceeds credit available " );
572589 // Account for balance changes
573- subUint (keccak256 (abi.encodePacked ("node.deposit.credit.balance " , msg . sender )), _amount);
590+ subUint (keccak256 (abi.encodePacked ("node.deposit.credit.balance " , _nodeAddress )), _amount);
574591 // Note: The funds are already stored in RocketVault under RocketDepositPool so no ETH transfer is required
575592 // Get the node operator's withdrawal address
576593 RocketNodeManagerInterface rocketNodeManager = RocketNodeManagerInterface (getContractAddress ("rocketNodeManager " ));
577- address nodeWithdrawalAddress = rocketNodeManager.getNodeWithdrawalAddress (msg .sender );
578594 // Calculate deposit fee
579595 unchecked { // depositFee < msg.value
580596 uint256 depositFee = _amount * rocketDAOProtocolSettingsDeposit.getDepositFee () / calcBase;
581597 uint256 depositNet = _amount - depositFee;
582- // Mint rETH to node
583- rocketTokenRETH.mint (depositNet, nodeWithdrawalAddress );
598+ // Mint rETH to recipient address
599+ rocketTokenRETH.mint (depositNet, _recipient );
584600 }
585601 // Emit event
586- emit CreditWithdrawn (msg . sender , _amount, block .timestamp );
602+ emit CreditWithdrawn (_nodeAddress , _amount, block .timestamp );
587603 }
588604
589605 /// @notice Gets the receiver next to be assigned and whether it can be assigned immediately
0 commit comments