# Pause and window duration miscounting

Deadlines, timeouts, or state checks that count paused time or resolve to the wrong period

_Area: DeFi accounting and math bugs. Seen in 3 disclosed reports; latest 2024-05-10. Updated 2026-10-29._

## How it works
A contract derives a deadline, timeout, or status from `block.timestamp` or from ordered boolean checks, but the arithmetic assumes time and state advance in lockstep. When a pause, an epoch boundary, or a terminal condition intervenes, the computed window no longer matches the period it is meant to guard. The result is an action that fires too early, too late, or never.

## Where it shows up
- Delay checks like `block.timestamp >= receivedAt + delay` in contracts that can be paused [E2](https://bugbountylibrary.com/r/c4%3A2024-03-taiko%3AM-12.md)
- Timeout functions that add a period to an epoch/draw id rather than to the earliest legal execution time [E3](https://bugbountylibrary.com/r/sherlock%3A2024-05-pooltogether%3AM-2.md)
- Status functions that test a terminal condition (expired) before a transitional one (late) [E1](https://bugbountylibrary.com/r/sherlock%3A2023-02-carapace%3AH-4.md)
- State machines with a transition table that lacks an edge the status function can produce [E1](https://bugbountylibrary.com/r/sherlock%3A2023-02-carapace%3AH-4.md)
- Any cooldown, cliff, or preferred-actor advantage measured in raw timestamps

## How to review
For each deadline, ask: what is the earliest block at which the guarded action can legally run, and does the deadline sit at or after it? For each status function, enumerate every (prior state, new status) pair and confirm the transition table has a matching edge. For pause-aware protocols, confirm whether paused duration should count toward the window and that the code matches that intent. The invariant: a window must measure only the time it is meant to measure, and every status the code can return must be reachable in the transition table.

## Variants seen
- Terminal check short-circuits a transitional state, locking capital and skipping default detection [E1](https://bugbountylibrary.com/r/sherlock%3A2023-02-carapace%3AH-4.md)
- Pause duration silently consumed by a timestamp delay, eroding a time-locked advantage [E2](https://bugbountylibrary.com/r/c4%3A2024-03-taiko%3AM-12.md)
- Off-by-one epoch arithmetic makes a shutdown timestamp land one period early, blocking awards [E3](https://bugbountylibrary.com/r/sherlock%3A2024-05-pooltogether%3AM-2.md)

## Impact and severity
Consequences ranged from locked capital and skipped default compensation [E1](https://bugbountylibrary.com/r/sherlock%3A2023-02-carapace%3AH-4.md), to loss of a fee advantage to a front-runner [E2](https://bugbountylibrary.com/r/c4%3A2024-03-taiko%3AM-12.md), to premature shutdown blocking prizes [E3](https://bugbountylibrary.com/r/sherlock%3A2024-05-pooltogether%3AM-2.md). Severity rises when the miscount is silent (no revert) and when it gates fund release or actor priority.

## Evidence
- E1: https://bugbountylibrary.com/r/sherlock%3A2023-02-carapace%3AH-4.md
- E2: https://bugbountylibrary.com/r/c4%3A2024-03-taiko%3AM-12.md
- E3: https://bugbountylibrary.com/r/sherlock%3A2024-05-pooltogether%3AM-2.md
