# _deployedAmount not updated on StrategySupplyBase.undeploy, preventing performance fees from being collected

StrategySupplyBase.undeploy fails to decrement _deployedAmount, so post-withdrawal harvests report a loss and performance fees are never collected.

- Payout: Audit contest
- Severity: high
- Program: BakerFi
- Found by: klau5
- Disclosed: 2025-02-26
- Write-up quality: 6/10
- Original: https://code4rena.com/reports/2024-12-bakerfi-invitational#h-03
- Library page: https://bugbountylibrary.com/r/c4%3A2024-12-bakerfi-invitational%3AH-03
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:solidity technique:source-review vuln:accounting-error vuln:fee-bypass

**Target:** StrategySupplyBase.sol (yield strategy contract)
**Root cause:** undeploy transfers assets out but never subtracts the withdrawn amount from _deployedAmount, leaving the accounting baseline stale.
**Steps:**
1. Deploy 10 ether into strategy via `deploy(deployAmount)`.
2. Simulate profit by minting 1 ether of aTokens to the strategy (`mintAtokensArbitrarily`).
3. Call `undeploy(2 ether)` — _deployedAmount stays at 10.
4. Call `harvest()`: newBalance = 10+1-2 = 9, balanceChange = 9-10 = -1, emits StrategyLoss instead of StrategyProfit.
**How found:** Code review of undeploy vs harvest accounting: noticed undeploy updates local `balance` but not the storage `_deployedAmount` used as harvest's baseline, then reasoned that withdrawals exceeding profit flip balanceChange negative.
**Exploitation:** Any withdrawal larger than accrued interest makes subsequent harvest compute a negative balanceChange, so the protocol skips performance-fee minting; repeated withdrawals suppress fee collection entirely.
**Insight:** When a contract tracks a storage baseline for profit/loss (e.g. _deployedAmount) and also has a local balance variable, check every path that moves funds out — if only the local var is updated, harvest math silently misclassifies withdrawals as losses.

