Skip to content

Commit

Permalink
fix: allocation with no deallocations queued
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Sep 17, 2024
1 parent 0e122f9 commit 78cac23
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/contracts/core/AllocationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -750,17 +750,23 @@ contract AllocationManager is
uint256[] memory indices =
_queuedDeallocationIndices[operator][strategy][_encodeOperatorSet(operatorSets[i])];
uint256 length = indices.length;
uint256 deallocationIndex = indices[length - 1];
PendingFreeMagnitude memory latestPendingMagnitude =
_pendingFreeMagnitude[operator][strategy][deallocationIndex];
if (latestPendingMagnitude.completableTimestamp > block.timestamp) {
pendingMagnitudeDiff[i] = latestPendingMagnitude.magnitudeDiff;
timestamps[i] = latestPendingMagnitude.completableTimestamp;
} else {
// There is no pending deallocation, so we set the pending magnitude and timestamp to 0
if (length == 0) {
// If there is no deallocations queued for this operator set
pendingMagnitudeDiff[i] = 0;
timestamps[i] = 0;
}
} else {
uint256 deallocationIndex = indices[length - 1];
PendingFreeMagnitude memory latestPendingMagnitude =
_pendingFreeMagnitude[operator][strategy][deallocationIndex];
if (latestPendingMagnitude.completableTimestamp > block.timestamp) {
pendingMagnitudeDiff[i] = latestPendingMagnitude.magnitudeDiff;
timestamps[i] = latestPendingMagnitude.completableTimestamp;
} else {
// There is no pending deallocation, so we set the pending magnitude and timestamp to 0
pendingMagnitudeDiff[i] = 0;
timestamps[i] = 0;
}
}
}
return (pendingMagnitudeDiff, timestamps);
}
Expand Down

0 comments on commit 78cac23

Please sign in to comment.