# `Strategy::checkPoolActivity()` does not look as far back as it should

Strategy::checkPoolActivity returns one observation too early, so TWAP validation checks a tick newer than lookAgo, allowing rebalance at a bad price.

- Payout: Audit contest
- Severity: medium
- Program: Yieldoor
- Found by: 0x73696d616f
- Disclosed: 2025-02-21
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2025-02-yieldoor-judging/issues/97
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-02-yieldoor%3AM-5
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:oracle-manipulation

**Target:** Strategy.sol TWAP pool activity check
**Root cause:** Loop compares lookAgo against the timestamp of the second-most-recent observation while evaluating the tick of the most recent one, so it exits one observation too early.
**Steps:**
1. Read Strategy.sol L335-337 loop computing tick from cumulative deltas.
2. Observe tick is derived from most recent observation but timestamp check uses nextTimestamp (second most recent).
3. Note loop returns before reaching an observation older than lookAgo.
4. Fix: check nextTimestamp before updating timestamp in loop.
**How found:** Compared security doc claim ('1 extra observation before lookAgo') against actual loop logic, spotting mismatch between which observation's tick is evaluated and which timestamp gates the exit.
**Insight:** When auditing TWAP/oracle lookback loops, verify the timestamp used for the window boundary belongs to the same observation whose cumulative tick was just evaluated; off-by-one in observation indexing silently shortens the window.

