# `FluidLocker::_getUnlockingPercentage()` incorrectly divides one of the components of the formula by `S`, leading to always having `80%` penalty

FluidLocker's unlocking percentage formula divided a sqrt term by _SCALER, collapsing it to zero and forcing every unlock to a 20% payout (80% penalty).

- Payout: Audit contest
- Severity: high
- Program: Superfluid
- Found by: 056Security
- Disclosed: 2024-11-13
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-11-superfluid-locking-contract-judging/issues/20
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-11-superfluid-locking-contract%3AH-1
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:solidity technique:source-review vuln:accounting-error vuln:precision-loss

**Target:** FluidLocker.sol _getUnlockingPercentage()
**Root cause:** The term Math.sqrt(unlockPeriod * _SCALER) is divided by _SCALER, so for realistic unlockPeriod values the sqrt result is far smaller than _SCALER and the term truncates to 0, leaving only the constant 20*_SCALER.
**Steps:**
1. Read _getUnlockingPercentage in FluidLocker.sol line 384.
2. Observe formula: _PERCENT_TO_BP * (((80*_SCALER)/sqrt(540*_SCALER)) * (sqrt(unlockPeriod*_SCALER)/_SCALER) + 20*_SCALER) / _SCALER.
3. Note sqrt(unlockPeriod*_SCALER) <= sqrt(540*24*3600*1e18) ~ 6.8e12 while _SCALER=1e18, so the division truncates to 0.
4. Call unlock with any unlockPeriod > 0; unlockingPercentageBP resolves to 20% regardless of duration.
**How found:** Code reading of the percentage formula; noticing the extra _SCALER divisor and checking magnitude of sqrt(unlockPeriod*_SCALER) versus _SCALER to confirm truncation to zero.
**Exploitation:** Any user unlocking Fluid via the locker receives only 20% of their position; the remaining 80% is redistributed to stakers, regardless of chosen unlock duration.
**Insight:** When auditing fixed-point math, compare the magnitude of each sqrt/division term against the scaler: a sqrt of a scaled value is ~1e9, so dividing it by a 1e18 scaler silently truncates to zero and collapses the formula to its constant term.

