Skip to content

Commit 58cd918

Browse files
committed
feat(wip): fix getAllocatedStrategies to return up to date view
1 parent cbe0467 commit 58cd918

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/contracts/core/AllocationManager.sol

+19-1
Original file line numberDiff line numberDiff line change
@@ -623,12 +623,30 @@ contract AllocationManager is
623623
OperatorSet memory operatorSet
624624
) external view returns (IStrategy[] memory) {
625625
address[] memory values = allocatedStrategies[operator][operatorSet.key()].values();
626+
626627
IStrategy[] memory strategies;
627-
628628
assembly {
629629
strategies := values
630630
}
631631

632+
/// Iterate over allocatedStrategies and keep only the strategies for which we have active allocations
633+
IStrategy[] memory results = new IStrategy[](values.length);
634+
uint resultIdx = 0;
635+
for (uint i = 0; i < strategies.length; i++) {
636+
Allocation memory allocation = getAllocation(operator, operatorSet, strategies[i]);
637+
638+
/// Skip if there is NEITHER a current NOR a pending allocation
639+
/// TODO - do we want to keep ONLY current allocations, and expose pending in a different
640+
/// method? This also brings into question _updateAllocationInfo marking things allocated
641+
/// when they are in fact pending?
642+
if (allocation.currentMagnitude == 0 && allocation.pendingDiff == 0) {
643+
continue;
644+
}
645+
646+
results[resultIdx] = strategies[i];
647+
resultIdx++;
648+
}
649+
632650
return strategies;
633651
}
634652

0 commit comments

Comments
 (0)