Skip to content

Commit

Permalink
feat: view func for avssync (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
8sunyuan authored Feb 6, 2024
1 parent 607f69a commit 5b15e1e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/contracts/core/DelegationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,18 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
return _operatorDetails[operator].stakerOptOutWindowBlocks;
}

/// @notice Given array of strategies, returns array of shares for the operator
function getOperatorShares(
address operator,
IStrategy[] memory strategies
) public view returns (uint256[] memory) {
uint256[] memory shares = new uint256[](strategies.length);
for (uint256 i = 0; i < strategies.length; ++i) {
shares[i] = operatorShares[operator][strategies[i]];
}
return shares;
}

/**
* @notice Returns the number of actively-delegatable shares a staker has across all strategies.
* @dev Returns two empty arrays in the case that the Staker has no actively-delegateable shares.
Expand Down
8 changes: 8 additions & 0 deletions src/contracts/interfaces/IDelegationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,14 @@ interface IDelegationManager is ISignatureUtils {
*/
function stakerOptOutWindowBlocks(address operator) external view returns (uint256);

/**
* @notice Given array of strategies, returns array of shares for the operator
*/
function getOperatorShares(
address operator,
IStrategy[] memory strategies
) external view returns (uint256[] memory);

/**
* @notice Given a list of strategies, return the minimum number of blocks that must pass to withdraw
* from all the inputted strategies. Return value is >= minWithdrawalDelayBlocks as this is the global min withdrawal delay.
Expand Down
5 changes: 5 additions & 0 deletions src/test/mocks/DelegationManagerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ contract DelegationManagerMock is IDelegationManager, Test {
function strategyWithdrawalDelayBlocks(IStrategy /*strategy*/) external pure returns (uint256) {
return 0;
}

function getOperatorShares(
address operator,
IStrategy[] memory strategies
) external view returns (uint256[] memory) {}

function getWithdrawalDelay(IStrategy[] calldata /*strategies*/) public pure returns (uint256) {
return 0;
Expand Down

0 comments on commit 5b15e1e

Please sign in to comment.