In the LendingPool contract, when a user repays more than their actual debt, the excess funds are not refunded back to the user. This issue arises because the contract transfers the full repayment amount without properly handling and returning any excess funds, violating the principle of minimal surprise and potentially causing user fund loss.
In the burn function of the DebtToken contract, when the repayment amount exceeds the user’s balance, the excess funds are not tracked or refunded.
contracts/core/tokens/DebtToken.sol:burn#L202-L204
In the ._repay function of the LendingPool.sol contract, the excess repayment amount is transferred without any refund mechanism.
contracts/core/pools/LendingPool/LendingPool.sol:_repay#L418-L422
Reproduction Steps:
Scenario:
User debt: 100 ETH
User repayment: 101 ETH
Result:
Only 100 ETH is used to repay the debt.
The excess 1 ETH is locked in the contract.
The user is unable to retrieve the excess 1 ETH.
Loss of User Funds: If a user repays more than their outstanding debt, the excess funds are locked in the contract, leading to a loss of funds.
Users Funds Permanently Locked: The excess repayment is not refunded, which could discourage users from overpaying or making additional repayments, potentially hindering liquidity.
Increased Risk of Repayment Failure: Users might refrain from making overpayments for fear of excess funds being lost, thus increasing the likelihood of repayment failures.
Manual code review
It is recommended to modify the burn function of the DebtToken.sol contract. Implement a refund mechanism to return any excess repayment amount to the user.
Modify LendingPool._repay: Transfer the actual repayment amount and refund the excess funds to the user.
Interest IS applied through the balanceOf() mechanism. The separate balanceIncrease calculation is redundant/wrong. Users pay full debt including interest via userBalance capping.
Interest IS applied through the balanceOf() mechanism. The separate balanceIncrease calculation is redundant/wrong. Users pay full debt including interest via userBalance capping.
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.