In the `IncentiveGauge._upsertIncentive()` function, `_updatePoolByPid()` should be called outside the `if` statement
In the IncentiveGauge contract, when a new incentive is added while the existing reward rate is zero, the pool accounting update is skipped, so the pool's last-updated timestamp stays stale. The next update then counts reward time from that older timestamp, over-allocating rewards and potentially leaving too little for claims and blocking liquidity removal.
Source: https://github.com/sherlock-audit/2025-09-bmx-deli-swap-judging/issues/240
Found by
0xpetern, ami, cpsec, jayjoshix, maigadoh, oct0pwn, x15
Summary
In the IncentiveGauge._upsertIncentive() function, if rewardRate == 0, then _updatePoolByPid() is not executed. This results in the lastUpdated timestamp of the pool remaining at its original, older timestamp. Meanwhile, the reward token being upserted begins its release from the current timestamp.
Consequently, during the next update, the released reward amount for the token will be inaccurately calculated. The released amount is determined by the timestamp difference between the pool's lastUpdated and the moment of the update, incorrectly assuming that the reward started its release at the pool's lastUpdated timestamp.
Root Cause
As shown at line 486, the function IncentiveGauge._upsertIncentive() calls _updatePoolByPid() only if info.rewardRate > 0.
function _upsertIncentive(PoolId pid, IERC20 token, uint256 amount) internal returns (uint128 rate) {
IncentiveInfo storage info = incentives[pid][token];
uint256 total = amount;
if (info.rewardRate > 0) {
// For active schedules, first update pool accounting, then add leftover budget
486 _updatePoolByPid(pid);
if (block.timestamp < info.periodFinish) {
uint256 remainingTime = info.periodFinish - block.timestamp;
uint256 leftover = remainingTime * info.rewardRate;
if (amount <= leftover) revert DeliErrors.InsufficientIncentive();
total += leftover;
}
}
rate = SafeCast.toUint128(total / TimeLibrary.WEEK);
info.rewardRate = rate;
497 info.periodFinish = uint64(block.timestamp + TimeLibrary.WEEK);
info.lastUpdate = uint64(block.timestamp);
info.remaining = SafeCast.toUint128(total);
}
Consider the case where info.rewardRate == 0:
-
_updatePoolByPid()is not called. Since the pool is not updated, the pool'slastUpdatedremains an older timestamp. -
As indicated at line 497, the release of the reward token begins from the current timestamp.
-
During the next update:
The released reward amount is calculated using active seconds:
endTs - poolLast, but this is incorrect becausepoolLastis an older timestamp that predates the reward token's release.Solidity function _updatePool(PoolId pid, int24 currentTick) internal { ... if (info.rewardRate > 0) { uint256 endTs = nowTs < info.periodFinish ? nowTs : info.periodFinish; if (endTs > poolLast) { @> uint256 activeSeconds = endTs - poolLast; amt = uint256(info.rewardRate) * activeSeconds; } } ...
As a result, a larger amount is incorrectly captured as the released amount.
Internal pre-conditions
External pre-conditions
Attack Path
Impact
This issue leads to an excess reward amount being allocated to the pool, which can result in a lack of available rewards for claiming, hinder position burning, and make it impossible to remove liquidity.
PoC
Mitigation
_updatePoolByPid() should be called outside the if statement:
function _upsertIncentive(PoolId pid, IERC20 token, uint256 amount) internal returns (uint128 rate) {
IncentiveInfo storage info = incentives[pid][token];
+ _updatePoolByPid(pid);
uint256 total = amount;
if (info.rewardRate > 0) {
// For active schedules, first update pool accounting, then add leftover budget
- _updatePoolByPid(pid);
if (block.timestamp < info.periodFinish) {
uint256 remainingTime = info.periodFinish - block.timestamp;
uint256 leftover = remainingTime * info.rewardRate;
if (amount <= leftover) revert DeliErrors.InsufficientIncentive();
total += leftover;
}
}
...
}
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/morphex-labs/deli-swap-contracts/pull/21
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The pool accounting update is placed inside the branch that only runs when an existing reward rate is positive, so a zero-rate upsert leaves the pool's last-updated timestamp stale.
Impact
An excess reward amount could be allocated to the pool, which may leave too few rewards for claiming, hinder position burning and make it impossible to remove liquidity.
What the attacker needed
An incentive added while reward rate is zero
The fix
The pool accounting update should be moved outside the conditional so it always runs before the new schedule is set; the protocol team fixed this issue.
How it was found
- Add an incentive for a pool whose current reward rate is zero.
- Observe that the pool accounting update is skipped and the pool's last-updated timestamp stays old.
- Trigger the next pool update and see the released reward calculated from the stale timestamp.
- Note the inflated released amount allocated to the pool.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A staking pool tracks rewards by remembering the last time it did its maths. When someone adds a new reward while the old rate is zero, the code forgets to refresh that timestamp. Later it thinks the reward has been running since the old timestamp, so it hands out too much and can run short.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.