# LeverageManager closeFee is only collected for pTKN, which can be easily bypassed.

LeverageManager charges closeFee only on returned pTKN, so users swap pTKN to borrowedTKN via large _podSwapAmtOutMin to avoid the fee.

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

**Target:** LeverageManager removeLeverage callback
**Root cause:** closeFee is applied only to _ptknToUserAmt in the REMOVE callback; leftover borrowedTKN (_pairedLpToUser) is transferred to the owner without any fee.
**Steps:**
1. Call removeLeverage with a large `_podSwapAmtOutMin` so the pTKN->borrowedTKN swap in step 3 converts most/all pTKN.
2. Flashloan repays FraxlendPair, collateral withdrawn, pTKN swapped to borrowedTKN.
3. In callback REMOVE branch, _ptknToUserAmt is near zero so closeFeePerc fee is negligible.
4. Leftover borrowedTKN (_pairedLpToUser) is transferred to owner with no fee deduction.
**How found:** Code reading of the REMOVE callback: noticed closeFee is only applied to _ptknToUserAmt while _pairedLpToUser is transferred without fee, then traced the swap in _swapPodForBorrowToken to see the user controls how much pTKN remains.
**Exploitation:** Position owner sets a high `_podSwapAmtOutMin` on the pTKN->borrowedTKN swap so nearly all pTKN is converted to borrowedTKN before the callback; the fee is only taken from the small remaining pTKN, and the borrowedTKN refund is sent fee-free.
**Insight:** When a protocol fee is charged on one output token of a multi-token refund, check whether the user can shift value into the untaxed token via a user-controlled swap parameter.

