Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: high
Invalid

Incorrect calculation in LendingPool.sol

Summary

The _repay function handles debt repayment in the smart contract, updating the reserve state and reducing the debt of a specified user. However, there is a critical issue in the calculation of actualRepayAmount, which could lead to incorrect debt repayments.

Vulnerability Details

Issue: Incorrect Calculation of actualRepayAmount

Currently, the function calculates the repayable amount using:

uint256 actualRepayAmount = amount > userScaledDebt ? userScaledDebt : amount;

This is incorrect because userScaledDebt is derived using rayDiv(reserve.usageIndex), meaning it represents a scaled value, not the actual debt amount.

Impact

Users will pay more than necessary, leading to discrepancies in the reserve and user balances

Tools Used

Manual code review

Recommendations

- uint256 actualRepayAmount = amount > userScaledDebt ? userScaledDebt : amount;
+ uint256 actualRepayAmount = amount > userDebt ? userDebt : amount;
Updates

Lead Judging Commences

inallhonesty Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

LendingPool::_repay caps actualRepayAmount at userScaledDebt instead of userDebt, preventing users from repaying full debt with interest in one transaction

That amount is not actually used.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.