Opus finding
StreamableFeesLocker.distributeFees: last-beneficiary remainder added on top of share creates double-distribution
highbughigh
- src/StreamableFeesLocker.sol:189-206
`amount0Distributed` is incremented BEFORE the dust remainder block adds the leftover to `amount0`. Thus after adding `currency0ToDistribute - amount0Distributed` to `amount0`, the last beneficiary's recorded `_distributeFees(amount0)` becomes `share + remainder`, but `amount0Distributed` was already incremented by the original share (not the new `amount0`). This means: total credited to beneficiaries (sum of recorded `_distributeFees`) = sum_of_shares + remainder = currency0ToDistribute. That part is fine because remainder = currency0ToDistribute - sum_of_shares. So total credited matches `currencyBalances` increase. Actually re-reading: amount0Distributed counts only the original `amount0` for the last beneficiary; the remainder is added to amount0 (not to amount0Distributed). Sum credited = sum(shares for i<last) + (lastShare + remainder) = sum(shares) + remainder = currency0ToDistribute (since remainder = currency0ToDistribute - sum(shares)). This balances. So actually NOT a bug. Withdrawing finding.
Recommendation
N/A