Skip to content

Commit a6434fa

Browse files
Gajesh2007gpsanant
authored andcommitted
changes
1 parent 134c3e8 commit a6434fa

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

src/contracts/core/DelegationManager.sol

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
217217
* a staker from their operator. Undelegation immediately removes ALL active shares/strategies from
218218
* both the staker and operator, and places the shares and strategies in the withdrawal queue
219219
*/
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) {
221221
require(isDelegated(staker), "DelegationManager.undelegate: staker must be delegated to undelegate");
222222
require(!isOperator(staker), "DelegationManager.undelegate: operators cannot be undelegated");
223223
require(staker != address(0), "DelegationManager.undelegate: cannot undelegate zero address");
@@ -230,32 +230,36 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
230230
);
231231

232232
// 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);
236234

237-
// emit an event if this action was not initiated by the staker themselves
238235
if (msg.sender != staker) {
239236
emit StakerForceUndelegated(staker, operator);
240237
}
241238

242-
// undelegate the staker
243239
emit StakerUndelegated(staker, operator);
244240
delegatedTo[staker] = address(0);
245241

246-
// if no delegatable shares, return zero root, and don't queue a withdrawal
247242
if (strategies.length == 0) {
248-
return bytes32(0);
243+
withdrawalRoots = new bytes32[](0);
249244
} 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+
}
258260
}
261+
262+
return withdrawalRoots;
259263
}
260264

261265
/**

src/contracts/interfaces/IDelegationManager.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ interface IDelegationManager is ISignatureUtils {
249249
* @dev Reverts if the caller is not the staker, nor the operator who the staker is delegated to, nor the operator's specified "delegationApprover"
250250
* @dev Reverts if the `staker` is already undelegated.
251251
*/
252-
function undelegate(address staker) external returns (bytes32 withdrawalRoot);
252+
function undelegate(address staker) external returns (bytes32[] memory withdrawalRoot);
253253

254254
/**
255255
* Allows a staker to withdraw some shares. Withdrawn shares/strategies are immediately removed

src/test/mocks/DelegationManagerMock.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ contract DelegationManagerMock is IDelegationManager, Test {
4141
bytes32 /*approverSalt*/
4242
) external pure {}
4343

44-
function undelegate(address staker) external returns (bytes32 withdrawalRoot) {
44+
function undelegate(address staker) external returns (bytes32[] memory withdrawalRoot) {
4545
delegatedTo[staker] = address(0);
4646
return withdrawalRoot;
4747
}

0 commit comments

Comments
 (0)