# The amount of shares needed for redemption of borrow tokens is underquoted during the removal of leverage process leading to reverting.

Fraxlend convertToShares rounds down when quoting shares needed to repay flash loan during leverage removal, so redemption yields too few borrow tokens and repayment reverts.

- 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/256
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-01-peapods-finance%3AM-8
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:dos

**Target:** LeverageManager._acquireBorrowTokenForRepayment / Fraxlend pair redeem
**Root cause:** convertToShares rounds down when computing shares to swap for borrow tokens, and redeem's toAmount rounds down again, so acquired borrow tokens fall short of the flash loan repay amount.
**Steps:**
1. User calls remove leverage on a self-lending position.
2. _acquireBorrowTokenForRepayment computes shares via `convertToShares(_borrowAmtNeededToSwap)` which rounds down.
3. Swap pod for those shares, then `redeem(balanceOf(this))` converts shares to assets rounding down again.
4. Acquired borrow tokens < `_repayAmount - _pairedAmtReceived`, so flash loan repayment transfer reverts.
**How found:** Code reading of the self-lending branch: noticed convertToShares uses roundUp=false and redeem's toAmount also rounds down, compounding shortfall against exact flash loan repay amount.
**Insight:** When a contract quotes shares to cover an exact debt repayment, check whether the share conversion rounds down and whether a second conversion (redeem) rounds down again—double rounding can leave a shortfall that reverts repayment.

