# Borrowers can not extend loans which has maximum duration less than 24 hours

DebitaV3Loan.extendLoan underflows when loan and offer max durations are under 24h, blocking borrowers from extending short loans.

- Payout: Audit contest
- Severity: medium
- Program: Debita
- Found by: 0x37
- Disclosed: 2024-10-31
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-10-debita-judging/issues/153
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-10-debita%3AM-2
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:accounting-error vuln:dos

**Target:** DebitaV3Loan.extendLoan() fee calculation
**Root cause:** feeOfMaxDeadline is floored at feePerDay (0.04%) instead of minFEE (0.2%), so for sub-24h durations it is smaller than PorcentageOfFeePaid (floored at minFEE), making misingBorrowFee = feeOfMaxDeadline - PorcentageOfFeePaid underflow and revert.
**Steps:**
1. Create borrow offer with duration 5 hours.
2. Create lend offer with min duration 3h, max duration 12h; match offers.
3. After 4 hours call `extendLoan()`; PorcentageOfFeePaid = minFEE = 20, feeOfMaxDeadline = feePerDay = 4.
4. `misingBorrowFee = 4 - 20` underflows, transaction reverts.
**How found:** Code reading of extendLoan fee logic: noticed feeOfMaxDeadline clamped to feePerDay while PorcentageOfFeePaid clamped to minFEE, and reasoned that for durations under 24h the former is smaller, causing subtraction underflow.
**Insight:** When two fee values are each clamped to different bounds (minFEE vs feePerDay), check whether the subtraction between them can invert ordering for small time windows; sub-day durations expose the mismatch.

