# AutoCompoundingPodLp `_swapV2()` may lead to leftover tokens in multihops.

AutoCompoundingPodLp's two-hop _swapV2 caps intermediate token by maxSwap, leaving excess intermediate tokens permanently stuck in the contract.

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

**Target:** AutoCompoundingPodLp._swapV2 / DEX_ADAPTER UniV2 multihop swap
**Root cause:** In two-hop swaps, the intermediate token amount is capped by maxSwap[_path[1]] before the second swap, so any excess intermediate tokens received from the first swap remain in the contract and are never swept.
**Steps:**
1. Configure swapMaps[tokenA][tokenC] with a two-hop path tokenA->tokenB->tokenC.
2. Set maxSwap[tokenB] to a value smaller than the first-hop output.
3. Trigger autocompounding so _tokenToPairedLpToken calls _swap -> _swapV2 with the 3-address path.
4. First swap yields e.g. 10000 tokenB; code caps _intermediateBal to maxSwap[tokenB]=1000 and swaps only 1000.
5. Remaining 9000 tokenB stays in contract; subsequent swaps only consume new output, never the leftover.
**How found:** Code reading of _swapV2 two-hop branch: noticed _intermediateBal is clamped to maxSwap[_path[1]] and only that amount is swapped, with no sweep of the residual balance.
**Insight:** When a swap helper clamps an intermediate amount for slippage/limit reasons, check whether the unswapped remainder is ever recovered; any cap applied mid-path strands tokens since later calls only handle fresh output.

