# `_accumulateFunding()` maker will get the wrong amount of funding fee.

Perennial's _accumulateFunding miscomputes maker funding share using skew ratio, letting maker capture nearly all funding when long/short imbalance exceeds maker size.

- Payout: Contest reward
- Severity: medium
- Program: Perennial
- Credited: WATCHPUG
- Disclosed: 2023-07-17
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-07-perennial-judging/issues/139
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-07-perennial%3AM-8
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:accounting-error vuln:reward-distribution

**Target:** Version.sol _accumulateFunding funding distribution
**Root cause:** fundingMaker is computed as fundingMinor * abs(skew) instead of the correct ratio min(maker, major-minor)/min(major, minor+maker), so the maker's share is overstated whenever abs(long-short) exceeds maker size.
**Steps:**
1. Set long/major=1000, short/minor=1, maker=1.
2. Call _accumulateFunding; skew()=999/1000.
3. Observe fundingMaker=0.999 of funding and fundingShort=0.001, though maker only matches 1 of major and half the short side.
4. Compare against correct ratio min(maker,major-minor)/min(major,minor+maker).
**How found:** Code review of the funding redistribution formula in Version#_accumulateFunding, testing edge case where skew exceeds maker size.
**Insight:** When a formula splits a pool proportionally, test extreme imbalance cases where the matched/maker size is smaller than the skew; ratio denominators often assume skew <= maker.
