Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegate shares fix #1045

Open
wants to merge 5 commits into
base: slashing-magnitudes-fixes
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions src/contracts/core/DelegationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,10 @@ contract DelegationManager is
delegatedTo[staker] = operator;
emit StakerDelegated(staker, operator);

// read staker's deposited shares and strategies to add to operator's shares
// read staker's delegatable shares and strategies to add to operator's shares
// and also update the staker depositScalingFactor for each strategy
(IStrategy[] memory strategies, uint256[] memory depositedShares) = getDepositedShares(staker);
uint256[] memory slashingFactors = _getSlashingFactors(staker, operator, strategies);
(IStrategy[] memory strategies, uint256[] memory depositedShares) = getDelegatableShares(staker);
uint64[] memory slashingFactors = allocationManager.getMaxMagnitudes(operator, strategies);

for (uint256 i = 0; i < strategies.length; ++i) {
// forgefmt: disable-next-item
Expand Down Expand Up @@ -904,6 +904,36 @@ contract DelegationManager is
return (strategies, shares);
}

/// TODO: add to IDelegationManager
function getDelegatableShares(
address staker
) public view returns (IStrategy[] memory, uint256[] memory) {
// Get a list of the staker's deposited strategies/shares in the strategy manager
(IStrategy[] memory tokenStrategies, uint256[] memory tokenDeposits) = strategyManager.getDeposits(staker);

// If the staker has no beacon chain ETH shares, return any shares from the strategy manager
uint256 podOwnerShares = eigenPodManager.stakerDepositShares(staker, beaconChainETHStrategy);
if (podOwnerShares == 0) {
return (tokenStrategies, tokenDeposits);
}

// Allocate extra space for beaconChainETHStrategy and shares and get BCSF
IStrategy[] memory strategies = new IStrategy[](tokenStrategies.length + 1);
uint256[] memory shares = new uint256[](tokenStrategies.length + 1);
uint64 beaconChainSlashingFactor = eigenPodManager.beaconChainSlashingFactor(staker);

strategies[tokenStrategies.length] = beaconChainETHStrategy;
shares[tokenStrategies.length] = podOwnerShares.mulWad(beaconChainSlashingFactor);

// Copy any strategy manager shares to complete array
for (uint256 i = 0; i < tokenStrategies.length; i++) {
strategies[i] = tokenStrategies[i];
shares[i] = tokenDeposits[i];
}

return (strategies, shares);
}

/// @inheritdoc IDelegationManager
function getQueuedWithdrawal(
bytes32 withdrawalRoot
Expand Down
Loading