Skip to content

Commit

Permalink
feat: replace getSlashableMagnitudes with general purpose allocation …
Browse files Browse the repository at this point in the history
…info query
  • Loading branch information
wadealexc committed Oct 10, 2024
1 parent 1f6c66e commit 8f090f4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 41 deletions.
40 changes: 13 additions & 27 deletions src/contracts/core/AllocationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,23 @@ contract AllocationManager is
});
}

/// @inheritdoc IAllocationManager
function getAllocationInfo(
address operator,
IStrategy strategy
) external view returns (OperatorSet[] memory, MagnitudeInfo[] memory) {
OperatorSet[] memory operatorSets = avsDirectory.getOperatorSetsOfOperator(operator, 0, type(uint256).max);
MagnitudeInfo[] memory infos = getAllocationInfo(operator, strategy, operatorSets);

return (operatorSets, infos);
}

/// @inheritdoc IAllocationManager
function getAllocationInfo(
address operator,
IStrategy strategy,
OperatorSet[] calldata operatorSets
) external view returns (MagnitudeInfo[] memory) {
OperatorSet[] memory operatorSets
) public view returns (MagnitudeInfo[] memory) {
MagnitudeInfo[] memory infos = new MagnitudeInfo[](operatorSets.length);

for (uint256 i = 0; i < operatorSets.length; ++i) {
Expand All @@ -405,31 +416,6 @@ contract AllocationManager is
return infos;
}

/// @inheritdoc IAllocationManager
function getSlashableMagnitudes(
address operator,
IStrategy[] calldata strategies
) external view returns (OperatorSet[] memory, uint64[][] memory) {
OperatorSet[] memory operatorSets = avsDirectory.getOperatorSetsOfOperator(operator, 0, type(uint256).max);
uint64[][] memory slashableMagnitudes = new uint64[][](strategies.length);

for (uint256 i = 0; i < strategies.length; ++i) {
slashableMagnitudes[i] = new uint64[](operatorSets.length);

for (uint256 j = 0; j < operatorSets.length; ++j) {
PendingMagnitudeInfo memory info = _getPendingMagnitudeInfo({
operator: operator,
strategy: strategies[i],
operatorSetKey: _encodeOperatorSet(operatorSets[j])
});

slashableMagnitudes[i][j] = info.currentMagnitude;
}
}

return (operatorSets, slashableMagnitudes);
}

/// @inheritdoc IAllocationManager
function getAllocatableMagnitude(address operator, IStrategy strategy) external view returns (uint64) {
// This method needs to simulate clearing any pending allocation modifications.
Expand Down
29 changes: 15 additions & 14 deletions src/contracts/interfaces/IAllocationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,21 @@ interface IAllocationManager is ISignatureUtils, IAllocationManagerErrors, IAllo
*
*/

/**
* @notice Returns the effective magnitude info for each of an operator's operator sets.
* This method fetches the complete list of an operator's operator sets, then applies any
* completable allocation modifications to return the effective, up-to-date current and
* pending magnitude allocations for each operator set.
* @param operator the operator to query
* @param strategy the strategy to get allocation info for
* @return the list of the operator's operator sets
* @return the corresponding allocation details for each operator set
*/
function getAllocationInfo(
address operator,
IStrategy strategy
) external view returns (OperatorSet[] memory, MagnitudeInfo[] memory);

/**
* @notice Returns the effective magnitude info for each operator set. This method
* automatically applies any completable modifications, returning the effective
Expand All @@ -193,20 +208,6 @@ interface IAllocationManager is ISignatureUtils, IAllocationManagerErrors, IAllo
OperatorSet[] calldata operatorSets
) external view returns (MagnitudeInfo[] memory);

/**
* @notice Returns the currently-allocated, slashable magnitude allocated from each strategy to
* an operator's operator sets
* @param operator the operator to query
* @param strategies the strategies to get the slashable magnitude for
*
* @return operatorSets the operator sets the operator is a member of
* @return slashableMagnitudes the current slashable magnitudes for each (operator set, strategy)
*/
function getSlashableMagnitudes(
address operator,
IStrategy[] calldata strategies
) external view returns (OperatorSet[] memory, uint64[][] memory);

/**
* @notice For a strategy, get the amount of magnitude not currently allocated to any operator set
* @param operator the operator to query
Expand Down

0 comments on commit 8f090f4

Please sign in to comment.