# Inconsistent use of epochBegin could lock user funds

Boundary mismatch between triggerNullEpoch and epochHasNotStarted lets a deposit land after null-epoch finalTVL is set, locking funds and misdistributing emissions.

- Payout: Contest reward
- Severity: medium
- Program: Y2K
- Credited: Inspex
- Disclosed: 2023-03-06
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/480
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-03-Y2K%3AM-14
- Tags: domain:web3 impact:dos impact:funds-loss kind:contest platform:sherlock sev:medium technique:source-review vuln:accounting-error vuln:business-logic

**Target:** Carousel/ControllerPeggedAssetV2 vault epoch logic
**Root cause:** triggerNullEpoch uses `block.timestamp < epochBegin` while epochHasNotStarted uses `block.timestamp > epochBegin`, so both are callable at exactly epochBegin; a deposit in that same block is excluded from finalTVL.
**Steps:**
1. At block.timestamp == epochBegin, call `ControllerPeggedAssetV2.triggerNullEpoch` which sets epochNull and finalTVL from current TVL
2. In the same block, call `Carousel.deposit` which passes epochHasNotStarted since timestamp is not > epochBegin
3. Deposit is accepted but not counted in finalTVL
4. Emissions distributed against stale finalTVL; withdraw computes previewEmissionsWithdraw with mismatched denominator
5. If finalTVL==0, previewEmissionsWithdraw divides by zero and reverts, locking funds
**How found:** Code review comparing timestamp comparators across triggerNullEpoch and the epochHasNotStarted modifier, spotting the off-by-one boundary where both conditions hold.
**Exploitation:** Same-block sequencing of triggerNullEpoch and deposit at the exact epochBegin timestamp causes finalTVL to omit the new deposit, corrupting emission accounting and reverting withdrawals.
**Insight:** When auditing epoch/round-based vaults, diff every timestamp comparator across entry and settlement functions; equality boundaries where two guards both pass are prime spots for accounting desync.
