# Some accounts using Intents to trade might be liquidated while healthy or be unliquidatable while being unhealthy.

Perennial's liquidation check ignores pending intent price PnL, letting healthy accounts be liquidated or unhealthy ones avoid liquidation.

- Payout: Audit contest
- Severity: medium
- Program: Perennial
- Found by: panprog
- Disclosed: 2025-01-14
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2025-01-perennial-v2-4-update-judging/issues/29
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-01-perennial-v2-4-update%3AM-2
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:accounting-error vuln:business-logic vuln:liquidation

**Target:** Perennial V2 core InvariantLib liquidation validation
**Root cause:** InvariantLib.validate checks only account collateral when validating protection, omitting the price adjustment from pending intent orders that is added when opening positions.
**Steps:**
1. Set margin ratio 0.5%, maintenance 0.3%, fee 0.1%.
2. User has collateral=350, settled long=1000 at oracle price 100 (margin 0.35%).
3. User signs intent to close 500 at price 101; pending long=500, intent profit = 500*(101-100)=500.
4. Liquidator commits unrequested price 99.9; collateral becomes 350+1000*(99.9-100)=250.
5. Expected margin with intent profit = (250+500)/(1000*100)=0.75% (safe), but liquidation ignores it and succeeds.
6. User pays close fee 500*100*0.1%=50, ending collateral 700 instead of 750.
**How found:** Code reading of InvariantLib: noticed intent price adjustment added to collateral at position open (L92) but not included in the protection/liquidation validation (L127).
**Exploitation:** Liquidator commits an unrequested oracle price move against a near-liquidation account; the liquidation check ignores pending intent price PnL, so a healthy account is liquidated and the user loses fees (~6.7% of funds).
**Insight:** When a protocol credits pending-order price adjustments in one margin path, check every other margin/liquidation path for the same adjustment; asymmetry between open and protect checks yields unfair liquidations.

