# Transaction may revert unexpectedly due to missing allowance for the lending pair asset

Peapods LeverageManager computes repay shares after addInterest that may not accrue, so repayAsset reverts on insufficient allowance, blocking deleverage and risking liquidation.

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

**Target:** LeverageManager.removeLeverage / Fraxlend pair repayAsset
**Root cause:** removeLeverage calls addInterest(false) which only accrues if utilization change exceeds a threshold, then computes borrow shares via totalBorrow().toShares; repayAsset later forces full interest accrual, requiring more assets than the allowance increased.
**Steps:**
1. User calls removeLeverage on a position near liquidation threshold.
2. LeverageManager calls `IFraxlendPair(_lendingPair).addInterest(false)` which skips accrual if utilization delta below threshold.
3. Computes `_borrowSharesToRepay = IFraxlendPair(_lendingPair).totalBorrow().toShares(_borrowAssetAmt, false)`.
4. Increases allowance by `_borrowAssetAmt` only.
5. Flash callback calls `repayAsset(_borrowSharesToRepay, custodian)` which accrues interest, needing more assets than allowance.
6. Call reverts; deleverage fails.
**How found:** Code reading of removeLeverage vs repayAsset: noticed addInterest(false) is conditional on utilization threshold while repayAsset guarantees accrual, causing share/asset mismatch.
**Escalation:** Position remains leveraged and can be liquidated on price fluctuation because the safety deleverage reverts.
**Insight:** When a protocol pre-computes share amounts from a lending pair, check whether the interest-accrual call used is conditional (threshold-gated) versus the accrual forced inside the repay function; mismatches cause allowance/balance reverts.

