From 5c1120e7eaf8fcb33292d4ab9e468ebae60a4076 Mon Sep 17 00:00:00 2001 From: gpsanant Date: Sun, 22 Sep 2024 22:47:28 -0700 Subject: [PATCH] add view func --- src/contracts/core/StakeRootCompendium.sol | 9 +++++++++ src/contracts/interfaces/IStakeRootCompendium.sol | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/contracts/core/StakeRootCompendium.sol b/src/contracts/core/StakeRootCompendium.sol index 5f2bb0eb98..14f2a137cf 100644 --- a/src/contracts/core/StakeRootCompendium.sol +++ b/src/contracts/core/StakeRootCompendium.sol @@ -473,6 +473,15 @@ contract StakeRootCompendium is StakeRootCompendiumStorage { return operatorSets.length; } + /// @inheritdoc IStakeRootCompendium + function getOperatorSetIndexAtTimestamp(OperatorSet memory operatorSet, uint32 timestamp) + external + view + returns (uint224) + { + return operatorSetToIndex[operatorSet.avs][operatorSet.operatorSetId].upperLookup(timestamp); + } + /// @inheritdoc IStakeRootCompendium function getStakes( OperatorSet calldata operatorSet, diff --git a/src/contracts/interfaces/IStakeRootCompendium.sol b/src/contracts/interfaces/IStakeRootCompendium.sol index 5c0083b8ea..35588204c7 100644 --- a/src/contracts/interfaces/IStakeRootCompendium.sol +++ b/src/contracts/interfaces/IStakeRootCompendium.sol @@ -119,6 +119,17 @@ interface IStakeRootCompendium { /// @notice the number of stake root submissions function getNumStakeRootSubmissions() external view returns (uint256); + /** + * @notice returns the operatorSet at the given timestamp + * @param operatorSet the operatorSet to get the indec for + * @param timestamp the timestamp to get the index for + * @return index the index of the operatorSet + */ + function getOperatorSetIndexAtTimestamp(OperatorSet memory operatorSet, uint32 timestamp) + external + view + returns (uint224); + /** * @notice returns the delegated and slashable stakes for an operator in an operatorSet * @param operatorSet the operatorSet to get the stakes for