@@ -641,13 +641,27 @@ contract AllocationManager is
641641 return (operatorSets, _allocations);
642642 }
643643
644+ /// @inheritdoc IAllocationManager
645+ function getEncumberedMagnitude (address operator , IStrategy strategy ) external view returns (uint64 ) {
646+ (uint64 curEncumberedMagnitude , ) = _getFreeAndUsedMagnitude (operator, strategy);
647+ return curEncumberedMagnitude;
648+ }
649+
644650 /// @inheritdoc IAllocationManager
645651 function getAllocatableMagnitude (address operator , IStrategy strategy ) external view returns (uint64 ) {
652+ (, uint64 curAllocatableMagnitude ) = _getFreeAndUsedMagnitude (operator, strategy);
653+ return curAllocatableMagnitude;
654+ }
655+
656+ function _getFreeAndUsedMagnitude (
657+ address operator ,
658+ IStrategy strategy
659+ ) internal view returns (uint64 curEncumberedMagnitude , uint64 curAllocatableMagnitude ) {
646660 // This method needs to simulate clearing any pending deallocations.
647661 // This roughly mimics the calculations done in `_clearDeallocationQueue` and
648662 // `_getUpdatedAllocation`, while operating on a `curEncumberedMagnitude`
649663 // rather than continually reading/updating state.
650- uint64 curEncumberedMagnitude = encumberedMagnitude[operator][strategy];
664+ curEncumberedMagnitude = encumberedMagnitude[operator][strategy];
651665
652666 uint256 length = deallocationQueue[operator][strategy].length ();
653667 for (uint256 i = 0 ; i < length; ++ i) {
@@ -668,7 +682,8 @@ contract AllocationManager is
668682
669683 // The difference between the operator's max magnitude and its encumbered magnitude
670684 // is the magnitude that can be allocated.
671- return _maxMagnitudeHistory[operator][strategy].latest () - curEncumberedMagnitude;
685+ curAllocatableMagnitude = _maxMagnitudeHistory[operator][strategy].latest () - curEncumberedMagnitude;
686+ return (curEncumberedMagnitude, curAllocatableMagnitude);
672687 }
673688
674689 /// @inheritdoc IAllocationManager
0 commit comments