In _repay
, if userDebt
is zero, the function allows a repayment attempt with amount > 0
, which reverts at the DebtToken level, wasting gas. The revert message (InvalidAmount
) is misleading.
It checks amount > 0
but fails to validate if there's any debt to repay before initiating complex operations.
This creates unnecessary contract calls and gas consumption for impossible operations.
Given the LendingPool's integration with:
DebtToken contract
Reserve asset transfers
Interest rate calculations
Each failed repayment could result in:
Up to 500,000 gas wasted (~0.5 ETH at 100 gwei)
Stuck token approvals requiring reset
Failed batch transactions in integrating protocols
Degraded protocol performance during high activity
This mirrors the Compound v2 repayment issues where users attempting to repay fully repaid loans caused transaction reversions and stuck approvals. The protocol's integration with Instadapp and similar platforms amplified the impact through failed batch transactions.
Initial State
Alice has fully repaid her loan in the LendingPool
Her userDebt
balance is 0
She still has NFT collateral deposited
The Issue Unfolds here.
Alice attempts to make an additional repayment:
The function continues execution despite zero debt
The critical flaw occurs at #L412
User funds may be locked in failed transactions.
vs
Add a check for userDebt == 0
early in _repay
and revert with a clear error (e.g., NoDebtToRepay
).
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.