# Market coordinator can set proportional and adiabatic fees much higher than limited by protocol due to fixed point truncation

Market coordinator sets makerLimit and takerFee.scale just below integers; validation passes pre-truncation but storage truncation breaks the enforced ratio, charging users up to 1.5x higher fees.

- Payout: Audit contest
- Severity: medium
- Program: Perennial
- Found by: panprog
- Disclosed: 2024-08-17
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-08-perennial-v2-update-3-judging/issues/41
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-perennial-v2-update-3%3AM-7
- 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:precision-loss

**Target:** RiskParameter validation/storage in Perennial market contracts
**Root cause:** RiskParameter validation compares scale against makerLimit using full-precision values, but both are truncated to integers when written to storage, so the stored ratio can violate the protocol-enforced minimum scale ratio.
**Steps:**
1. Set protocolParameter.minScale=50%, minEfficiency=100%
2. Coordinator sets makerLimit=3.9 WBTC and takerFee.scale=1.95 WBTC (passes validation as 50% ratio)
3. On storage, both truncate to makerLimit=3 and scale=1, giving 33% ratio
4. Resulting proportional fee is up to 1.5x higher than protocol intended
**How found:** Reading the README's stated acceptable-risk boundary (coordinator must not exceed protocol parameter bounds), the researcher compared the validation code path against the storage truncation path in RiskParameter.sol and noticed validation runs on pre-truncation values.
**Exploitation:** A malicious market coordinator picks makerLimit and scale values just below integer boundaries so validation passes at the intended ratio, but truncation on storage lowers the effective scale ratio, inflating fees charged to takers/makers.
**Insight:** When a value is validated then stored with reduced precision, check whether the invariant holds on the stored value, not the input; pick inputs just below the truncation boundary to maximize the post-truncation deviation.

