# Usage of lastEligibleStatus can cause user to miss out on rewards on manualStopEmissionsFor invocation

LoopFi's eligibility cache skips balance refresh for other vaults after manualStopEmissionsFor zeroes them, so newly eligible users lose rewards on those vaults.

- Payout: Audit contest
- Severity: medium
- Program: LoopFi
- Found by: hash
- Disclosed: 2025-02-17
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-07-loopfi-findings/issues/121
- Library page: https://bugbountylibrary.com/r/c4%3A2024-07-loopfi%3AM-30
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** Eligibility/rewards accounting contract (handleActionAfter, manualStopEmissionsFor)
**Root cause:** handleActionAfter assumes that if lastEligibleStatus and isCurrentlyEligible are both true, all other vault balances are already current, so it only updates the triggering vault. manualStopEmissionsFor zeroes per-vault balances without updating eligibility state, breaking that invariant.
**Steps:**
1. User is eligible; balances tracked across multiple vaults.
2. Whitelisted caller invokes `manualStopEmissionsFor(user, tokens)` which sets `user.amount = 0` and `rewardDebt = 0` for each listed vault.
3. User's position in one vault changes, triggering `handleActionAfter`; `lastEligibleStatus` and `refresh` both return true.
4. Code takes the `_handleActionAfterForToken` branch, updating only `msg.sender` vault; other vaults remain at 0 and never re-registered.
5. User loses rewards on the zeroed vaults despite being eligible.
**How found:** Code reading of the eligibility caching optimization: noticed the invariant assumption that all balances are current when both eligibility flags are true, then checked manualStopEmissionsFor which mutates balances outside that assumption.
**Insight:** When a contract caches 'already up to date' state to skip recomputation, enumerate every other function that mutates the underlying data outside the cache-update path; admin/whitelisted maintenance functions are common invariant breakers.

