# Stale timestamp reward accrual

Per-item accrual reusing a shared last-updated timestamp that only advances on a special item or condition

_Area: DeFi accounting and math bugs. Seen in 2 disclosed reports; latest 2026-05-18. Updated 2026-11-16._

## How it works
Accrual math assumes a shared "last updated" timestamp advances once per period, so each accrual covers a fresh, non-overlapping interval. The bug: the timestamp is refreshed only on a special item (the base asset) or only under a condition (rewards > 0), while fees/rewards are still computed per item or per report. Every other item then recomputes against the same stale timestamp, so the same interval is paid out repeatedly, or a gap is never measured and later averaged over [E1](https://bugbountylibrary.com/r/sherlock%3A2025-07-mellow-flexible-vaults%3AH-4.md)[E3](https://bugbountylibrary.com/r/c4%3A2026-01-olas%3AM-10.md). A sibling shape: global config setters mutate epoch/block-time parameters without forcing all lazily-updated markets to sync, so new values apply retroactively to stale markets [E2](https://bugbountylibrary.com/r/c4%3A2024-03-neobase%3AM-04.md).

## Where it shows up
- A batch loop calling a per-item fee/interest/reward accrual that reads a shared `lastUpdated`/`tsCheckpoint` [E1](https://bugbountylibrary.com/r/sherlock%3A2025-07-mellow-flexible-vaults%3AH-4.md)[E3](https://bugbountylibrary.com/r/c4%3A2026-01-olas%3AM-10.md)
- An early return in the update function for non-base assets, so the timestamp only moves on one item [E1](https://bugbountylibrary.com/r/sherlock%3A2025-07-mellow-flexible-vaults%3AH-4.md)
- Accrual gated on a condition like `lastAvailableRewards > 0`, freezing the timestamp during droughts or pauses [E3](https://bugbountylibrary.com/r/c4%3A2026-01-olas%3AM-10.md)
- Global setters (`setRewards`, `setBlockTimeParameters`) alongside per-market lazy `update_market` [E2](https://bugbountylibrary.com/r/c4%3A2024-03-neobase%3AM-04.md)
- Activity/liveness ratios averaged over a timestamp that is only conditionally advanced [E3](https://bugbountylibrary.com/r/c4%3A2026-01-olas%3AM-10.md)

## How to review
Find every write to the shared timestamp and confirm it happens before or with each accrual that reads it. The invariant: for each accrual, the elapsed interval since the timestamp must be non-zero and must not overlap any prior accrual's interval. In a batch loop, check whether the timestamp is refreshed inside the loop or only on a special item — ordering matters [E1](https://bugbountylibrary.com/r/sherlock%3A2025-07-mellow-flexible-vaults%3AH-4.md). For config setters, confirm they either force all markets to update in the same block or are applied per-market at update time, never retroactively [E2](https://bugbountylibrary.com/r/c4%3A2024-03-neobase%3AM-04.md). For conditional checkpoints, confirm the timestamp advances even when the payout is zero, so gaps are measured [E3](https://bugbountylibrary.com/r/c4%3A2026-01-olas%3AM-10.md).

## How finders spotted it
- Read the interaction between batch submission and the fee update's early return for non-base assets; noticed the timestamp advances once per batch while fees compute per report [E1](https://bugbountylibrary.com/r/sherlock%3A2025-07-mellow-flexible-vaults%3AH-4.md)
- Read the approximation system and an in-code warning in `update_market`; noticed `setRewards` lacked the same warning and retroactive application occurs when markets are stale [E2](https://bugbountylibrary.com/r/c4%3A2024-03-neobase%3AM-04.md)
- Read the checkpoint guard, saw `tsCheckpoint` only updates when rewards exist, then traced the activity ratio to the stale timestamp, exposing an unmeasured gap [E3](https://bugbountylibrary.com/r/c4%3A2026-01-olas%3AM-10.md)

## Variants seen
- Per-report fee accrual in a batch against one stale timestamp, minting excess shares [E1](https://bugbountylibrary.com/r/sherlock%3A2025-07-mellow-flexible-vaults%3AH-4.md)
- Retroactive config change applied to markets not synced in the same block [E2](https://bugbountylibrary.com/r/c4%3A2024-03-neobase%3AM-04.md)
- Conditional checkpoint skip during zero-reward periods diluting a liveness ratio [E3](https://bugbountylibrary.com/r/c4%3A2026-01-olas%3AM-10.md)

## Impact and severity
Excess shares minted to the fee recipient [E1](https://bugbountylibrary.com/r/sherlock%3A2025-07-mellow-flexible-vaults%3AH-4.md); mis-measured lender rewards [E2](https://bugbountylibrary.com/r/c4%3A2024-03-neobase%3AM-04.md); undeserved payouts to inactive services [E3](https://bugbountylibrary.com/r/c4%3A2026-01-olas%3AM-10.md). Severity rises with how many items share the stale timestamp and how long the gap persists — a whole batch [E1](https://bugbountylibrary.com/r/sherlock%3A2025-07-mellow-flexible-vaults%3AH-4.md) or an entire drought [E3](https://bugbountylibrary.com/r/c4%3A2026-01-olas%3AM-10.md) compounds the error.

## Evidence
- E1: https://bugbountylibrary.com/r/sherlock%3A2025-07-mellow-flexible-vaults%3AH-4.md
- E2: https://bugbountylibrary.com/r/c4%3A2024-03-neobase%3AM-04.md
- E3: https://bugbountylibrary.com/r/c4%3A2026-01-olas%3AM-10.md
