Skip to content
Merged
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
5 changes: 2 additions & 3 deletions src/RewardsDistributorWorkSubmission.sol
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,15 @@ contract RewardsDistributorWorkSubmission is IRewardsDistributor, AccessControlE
uint256 remaining = toRemove;
uint256 bucketIdx = nb.currentBucket;

// Remove from buckets, starting with the current one
// Remove from buckets, starting with the oldest one
for (uint256 i = 0; i < NUM_BUCKETS && remaining > 0; i++) {
bucketIdx = (bucketIdx + 1) % NUM_BUCKETS; // Move forward in the ring buffer
uint256 bucketAmount = nb.buckets[bucketIdx];
if (bucketAmount > 0) {
uint256 removeFromBucket = remaining > bucketAmount ? bucketAmount : remaining;
nb.buckets[bucketIdx] -= removeFromBucket;
remaining -= removeFromBucket;
}
// Move to previous bucket (circular)
bucketIdx = bucketIdx == 0 ? NUM_BUCKETS - 1 : bucketIdx - 1;
}

// Update totals
Expand Down