# `_protocolFees` can be applied multiple times in `AutoCompoundingPodLp` contract

Failed PAIRED_LP_TOKEN-to-pod swap leaves tokens in AutoCompoundingPodLp, so next reward processing charges protocol fee again on the stranded balance, over-taxing users.

- Payout: Audit contest
- Severity: medium
- Program: Peapods Finance
- Found by: X77
- Disclosed: 2025-01-08
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2025-01-peapods-finance-judging/issues/157
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-01-peapods-finance%3AM-3
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error

**Target:** AutoCompoundingPodLp reward-processing contract
**Root cause:** _processRewardsToPodLp computes protocol fee from full balanceOf(PAIRED_LP_TOKEN) minus _protocolFees, so PAIRED_LP_TOKEN left behind by a failed swap to pod/StakingPoolToken is counted again and fee is re-applied.
**Steps:**
1. Set RewardsTokens = [PAIRED_LP_TOKEN, dai, lpRewardsToken].
2. Call _processRewardsToPodLp: lpRewardsToken swaps to 50 PAIRED_LP_TOKEN, 5 taken as protocol fee, remaining 45 swap to pod fails, leaving 45 in contract.
3. 40 more PAIRED_LP_TOKEN distributed to contract, balance becomes 85.
4. Next _processRewardsToPodLp call swaps 80 (=85-_protocolFees) and charges fee again on the stranded 45.
5. Observe total fee 9.5 instead of correct 4 for the 40 newly distributed tokens.
**How found:** Code reading of _processRewardsToPodLp: noticed failed swap leaves PAIRED_LP_TOKEN in contract and that the PAIRED_LP_TOKEN branch uses balanceOf minus _protocolFees, so stranded amount is re-taxed on the next call.
**Insight:** When a fee is computed from balanceOf minus a stored accumulator, any tokens stranded by a failed swap get re-taxed on the next invocation; check whether fee accounting uses deltas or raw balances.

