@@ -217,7 +217,7 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
217
217
* a staker from their operator. Undelegation immediately removes ALL active shares/strategies from
218
218
* both the staker and operator, and places the shares and strategies in the withdrawal queue
219
219
*/
220
- function undelegate (address staker ) external onlyWhenNotPaused (PAUSED_ENTER_WITHDRAWAL_QUEUE) returns (bytes32 ) {
220
+ function undelegate (address staker ) external onlyWhenNotPaused (PAUSED_ENTER_WITHDRAWAL_QUEUE) returns (bytes32 [] memory withdrawalRoots ) {
221
221
require (isDelegated (staker), "DelegationManager.undelegate: staker must be delegated to undelegate " );
222
222
require (! isOperator (staker), "DelegationManager.undelegate: operators cannot be undelegated " );
223
223
require (staker != address (0 ), "DelegationManager.undelegate: cannot undelegate zero address " );
@@ -230,32 +230,36 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
230
230
);
231
231
232
232
// Gather strategies and shares to remove from staker/operator during undelegation
233
- // Undelegation removes ALL currently-active strategies and shares
234
- (IStrategy[] memory strategies , uint256 [] memory shares )
235
- = getDelegatableShares (staker);
233
+ (IStrategy[] memory strategies , uint256 [] memory shares ) = getDelegatableShares (staker);
236
234
237
- // emit an event if this action was not initiated by the staker themselves
238
235
if (msg .sender != staker) {
239
236
emit StakerForceUndelegated (staker, operator);
240
237
}
241
238
242
- // undelegate the staker
243
239
emit StakerUndelegated (staker, operator);
244
240
delegatedTo[staker] = address (0 );
245
241
246
- // if no delegatable shares, return zero root, and don't queue a withdrawal
247
242
if (strategies.length == 0 ) {
248
- return bytes32 (0 );
243
+ withdrawalRoots = new bytes32 [] (0 );
249
244
} else {
250
- // Remove all strategies/shares from staker and operator and place into queue
251
- return _removeSharesAndQueueWithdrawal ({
252
- staker: staker,
253
- operator: operator,
254
- withdrawer: staker,
255
- strategies: strategies,
256
- shares: shares
257
- });
245
+ withdrawalRoots = new bytes32 [](strategies.length );
246
+ for (uint i = 0 ; i < strategies.length ; i++ ) {
247
+ IStrategy[] memory singleStrategy = new IStrategy [](1 );
248
+ uint256 [] memory singleShare = new uint256 [](1 );
249
+ singleStrategy[0 ] = strategies[i];
250
+ singleShare[0 ] = shares[i];
251
+
252
+ withdrawalRoots[i] = _removeSharesAndQueueWithdrawal ({
253
+ staker: staker,
254
+ operator: operator,
255
+ withdrawer: staker,
256
+ strategies: singleStrategy,
257
+ shares: singleShare
258
+ });
259
+ }
258
260
}
261
+
262
+ return withdrawalRoots;
259
263
}
260
264
261
265
/**
0 commit comments