Skip to content

Commit

Permalink
feat: add restakeable strategies to service manager for indexing (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
ypatil12 authored Dec 15, 2023
1 parent dde7c8f commit 7f90be1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/ServiceManagerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,36 @@ contract ServiceManagerBase is IServiceManager, OwnableUpgradeable {
delegationManager.deregisterOperatorFromAVS(operator);
}

/**
* @notice Returns the list of strategies that the AVS supports for restaking
* @dev This function is intended to be called off-chain
* @dev No guarantee is made on uniqueness of each element in the returned array.
* The off-chain service should do that validation separately
*/
function getRestakeableStrategies() external view returns (address[] memory) {
uint256 quorumCount = registryCoordinator.quorumCount();

if (quorumCount == 0) {
return new address[](0);
}

uint256 strategyCount;
for(uint256 i = 0; i < quorumCount; i++) {
strategyCount += stakeRegistry.strategyParamsLength(uint8(i));
}

address[] memory restakedStrategies = new address[](strategyCount);
uint256 index = 0;
for(uint256 i = 0; i < registryCoordinator.quorumCount(); i++) {
uint256 strategyParamsLength = stakeRegistry.strategyParamsLength(uint8(i));
for (uint256 j = 0; j < strategyParamsLength; j++) {
restakedStrategies[index] = address(stakeRegistry.strategyParamsByIndex(uint8(i), j).strategy);
index++;
}
}
return restakedStrategies;
}

/**
* @notice Returns the list of strategies that the operator has potentially restaked on the AVS
* @param operator The address of the operator to get restaked strategies for
Expand Down
8 changes: 8 additions & 0 deletions src/interfaces/IServiceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,12 @@ interface IServiceManager {
* of each element in the returned array. The off-chain service should do that validation separately
*/
function getOperatorRestakedStrategies(address operator) external view returns (address[] memory);

/**
* @notice Returns the list of strategies that the AVS supports for restaking
* @dev This function is intended to be called off-chain
* @dev No guarantee is made on uniqueness of each element in the returned array.
* The off-chain service should do that validation separately
*/
function getRestakeableStrategies() external view returns (address[] memory);
}

0 comments on commit 7f90be1

Please sign in to comment.