# Staker.sol: Wrong values returned in edge cases of _calculateFloatPerSecond()

Edge-case branches in Staker._calculateFloatPerSecond returned reward rates 1e18 times too large, causing massive float token issuance when all rewards go to one side.

- Payout: Audit contest
- Severity: medium
- Program: Float Capital
- Found by: hickuphh3
- Disclosed: 2021-09-16
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2021-08-floatcapital-findings/issues/6
- Library page: https://bugbountylibrary.com/r/c4%3A2021-08-floatcapital%3AM-04
- Tags: area:web3 domain:web3 impact:integrity kind:contest platform:code4rena sev:medium tech:solidity technique:source-review vuln:accounting-error

**Target:** Staker.sol reward rate calculation (_calculateFloatPerSecond)
**Root cause:** Edge-case return branches omitted the /1e18 scaling applied in the normal-case branch, returning (1e18 * k * longPrice, 0) instead of (k * longPrice, 0).
**Steps:**
1. Read `_calculateFloatPerSecond()` and note two early-return edge cases: `return (1e18 * k * longPrice, 0);` and `return (0, 1e18 * k * shortPrice);`
2. Compare to normal-case return `((longRewardUnscaled * k * longPrice) / 1e18, (shortRewardUnscaled * k * shortPrice) / 1e18)`
3. Substitute longRewardUnscaled=0, shortRewardUnscaled=1e18 into normal case: yields `(0, k * shortPrice)`
4. Observe edge case returns `1e18 * k * shortPrice`, i.e. 1e18x larger
5. Trigger the edge case (all rewards to one side) to inflate float token issuance rate
**How found:** Code review of the reward-rate function; verified the edge-case branches by plugging boundary values (0 and 1e18) into the normal-case formula and comparing outputs.
**Exploitation:** Reach the edge-case branch where rewards are fully allocated to long or short holders; the returned rate is 1e18x too large, causing an extremely large float token issuance rate.
**Insight:** When a function has fast-path/edge-case early returns, re-derive them by substituting boundary inputs into the general formula to catch missing scaling factors.

