Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/contracts/core/AllocationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ contract AllocationManager is
/// @inheritdoc IAllocationManagerActions
function modifyAllocations(
address operator,
AllocateParams[] memory params
AllocateParams[] calldata params
) external onlyWhenNotPaused(PAUSED_MODIFY_ALLOCATIONS) {
// Check that the caller is allowed to modify allocations on behalf of the operator
// We do not use a modifier to avoid `stack too deep` errors
Expand All @@ -91,6 +91,13 @@ contract AllocationManager is
operatorAllocationDelay = delay;
}

uint256 totalStrategies;
for (uint256 i = 0; i < params.length; i++) {
totalStrategies += params[i].strategies.length;
}
IStrategy[] memory seenStrategies = new IStrategy[](totalStrategies);
uint256 seenStrategiesCount;

for (uint256 i = 0; i < params.length; i++) {
require(params[i].strategies.length == params[i].newMagnitudes.length, InputArrayLengthMismatch());

Expand All @@ -110,7 +117,17 @@ contract AllocationManager is
// 1. If the operator has any pending deallocations for this strategy, clear them
// to free up magnitude for allocation. Fetch the operator's up to date allocation
// info and ensure there is no remaining pending modification.
_clearDeallocationQueue(operator, strategy, type(uint16).max);
bool alreadyCleared;
for (uint256 k = 0; k < seenStrategiesCount; ++k) {
if (seenStrategies[k] == strategy) {
alreadyCleared = true;
break;
}
}
if (!alreadyCleared) {
_clearDeallocationQueue(operator, strategy, type(uint16).max);
seenStrategies[seenStrategiesCount++] = strategy;
}

(StrategyInfo memory info, Allocation memory allocation) =
_getUpdatedAllocation(operator, operatorSet.key(), strategy);
Expand Down