# The `RiskParameter.liquidationFee` variable is not treated and validated as a percentage value, leading to breaking protocol invariants.

Perennial v2.3 liquidationFee became a percentage but is still validated against absolute maxFeeAbsolute, letting coordinators set fees exceeding protocol caps.

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

**Target:** Perennial V2 risk parameter validation (RiskParameter.sol, VersionLib.sol)
**Root cause:** liquidationFee changed from fixed amount to percentage in v2.3, but RiskParameterStorageLib still compares it to absolute protocolParameter.maxFeeAbsolute and per-market minMaintenance, so percentage values pass checks meant for absolute amounts.
**Steps:**
1. Read RiskParameter.sol L139: `if (self.liquidationFee.gt(protocolParameter.maxFeeAbsolute)) revert` — compares percentage to absolute USD value.
2. Read RiskParameter.sol L155: `if (self.minMaintenance.lt(self.liquidationFee)) revert` — compares absolute maintenance to percentage.
3. Set maxFeeAbsolute=$50; liquidationFee can then be up to 5000% of settlementFee.
4. In VersionLib._accumulateLiquidationFee, fee = settlementFee.mul(liquidationFee), so fee can exceed maxFeeAbsolute.
5. Coordinator sets minMaintenance=minMargin=0, liquidationFee=maxLiquidationFee, opens tiny positions at ~0 collateral, liquidates them for profit exceeding settlement fee, leaving accounts in bad debt.
**How found:** Code review of the v2.2→v2.3 migration: noticed liquidationFee semantics changed to percentage but validation code still treated it as absolute, comparing against maxFeeAbsolute and minMaintenance.
**Exploitation:** Malicious coordinator configures minMaintenance=minMargin=0 and liquidationFee at protocol max, opens many tiny positions funded only by settlement fee, then liquidates them; liquidation fee exceeds settlement fee paid, yielding profit while accounts go into bad debt.
**Escalation:** Chains parameter misconfiguration into repeated profitable self-liquidation draining market collateral.
**Insight:** When a variable's unit changes across versions, grep every comparison and multiplication site for stale unit assumptions — especially fee caps compared against percentages.

