Skip to content

Commit

Permalink
Remove useless stake updates and fix issue where operator was set inc…
Browse files Browse the repository at this point in the history
…orrectly for withdrawal processing
  • Loading branch information
wadealexc committed Oct 16, 2023
1 parent dad75a4 commit fb44fef
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/contracts/core/DelegationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,6 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
(IStrategy[] memory strategies, uint256[] memory shares)
= getDelegatableShares(staker);

// push the operator's new stake to the StakeRegistry
_pushOperatorStakeUpdate(operator);

// emit an event if this action was not initiated by the staker themselves
if (msg.sender != staker) {
emit StakerForceUndelegated(staker, operator);
Expand Down Expand Up @@ -607,16 +604,19 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
podOwner: staker,
shares: withdrawal.shares[i]
});
currentOperator = delegatedTo[staker];
address podOwnerOperator = delegatedTo[staker];
// Similar to `isDelegated` logic
if (currentOperator != address(0)) {
if (podOwnerOperator != address(0)) {
_increaseOperatorShares({
operator: currentOperator,
operator: podOwnerOperator,
// the 'staker' here is the address receiving new shares
staker: staker,
strategy: withdrawal.strategies[i],
shares: increaseInDelegateableShares
});

// push the operator's new stake to the StakeRegistry
_pushOperatorStakeUpdate(podOwnerOperator);
}
} else {
strategyManager.addShares(msg.sender, withdrawal.strategies[i], withdrawal.shares[i]);
Expand Down Expand Up @@ -687,9 +687,6 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
strategy: strategies[i],
shares: shares[i]
});

// push the operator's new stake to the StakeRegistry
_pushOperatorStakeUpdate(operator);
}

// Remove active shares from EigenPodManager/StrategyManager
Expand All @@ -709,6 +706,11 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
unchecked { ++i; }
}

// Push the operator's new stake to the StakeRegistry
if (operator != address(0)) {
_pushOperatorStakeUpdate(operator);
}

// Create queue entry and increment withdrawal nonce
uint256 nonce = cumulativeWithdrawalsQueued[staker];
cumulativeWithdrawalsQueued[staker]++;
Expand Down

0 comments on commit fb44fef

Please sign in to comment.