# _ineligible() redemptionEligible is miscalculated

Vault._ineligible() subtracts the in-flight depositAssets from totalCollateral even though it isn't yet counted, understating redemptionEligible and over-allocating collateral to positions.

- Payout: Audit contest
- Severity: medium
- Program: Perennial
- Found by: bin2chen
- Disclosed: 2024-08-17
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-08-perennial-v2-update-3-judging/issues/36
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-perennial-v2-update-3%3AM-6
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:accounting-error

**Target:** Perennial V2 Vault contract (_ineligible/redemptionEligible accounting)
**Root cause:** _ineligible() computes redemptionEligible = totalCollateral - (global.assets + withdrawal) - global.deposit, but global.deposit already includes the current update()'s depositAssets, which is not yet part of totalCollateral, so it is double-subtracted.
**Steps:**
1. Set context.totalCollateral=100, global.assets=0, global.deposit=0
2. Call update(depositAssets=10); global.deposit becomes 10
3. Observe redemptionEligible = 100 - (0+0) - 10 = 90 instead of 100
4. Because ineligible is understated, more collateral is treated as allocatable and positions are opened against assets that should be reserved
**How found:** Code reading of the _ineligible() formula; noticed global.deposit already contains the current depositAssets while totalCollateral does not, indicating a double subtraction.
**Insight:** When auditing accounting formulas, check whether each subtracted term is already reflected in the base total; in-flight deposits/withdrawals not yet in totalCollateral must be excluded from the subtraction to avoid double-counting.

