Core Contracts

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

Missing update totalUsage timely when lenders deposit funds into the lending pool

Summary

Missing update totalUsage timely when lenders deposit funds into the lending pool. This will cause the incorrect utilization rate and borrow rate.

Vulnerability Details

In LendingPool, users deposit funds to earn some interest. In deposit, the total liquidity will increase because of the deposit. So we need to trigger updateInterestRatesAndLiquidity to update the latest utilization rate/borrow rate/liquidate rate. In the next time period, we will use the updated currentUsageRate/currentLiquidityRate to calculate the borrowers' interest.

The utilization rate is related with totalLiquidity and totalUsage. In deposit, we update the totalLiquidity, but we don't get the latest totalUsage. This will cause that the calculated utilization rate is less than expected. Borrowers will pay less interest than expected, and lenders will lose some expected interest.

For example:

  1. Alice deposits 1000 crvUSD in timestamp X.

  2. Bob borrows 200 crvUSD in timestamp X + 100.

  3. Cathy deposits 1000 crvUSD in timestamp X + 200. Assume there are 2 crvUSD's borrowing interest generated between timestamp X + 100 and timestamp X + 200. After cathy's deposit, the utilization rate should be (200 + 2)/ (200 + 2 + 2000). But in current implementation, the utilization rate is (200)/(200 + 2000).

function deposit(ReserveData storage reserve,ReserveRateData storage rateData,uint256 amount,address depositor) internal returns (uint256 amountMinted) {
updateInterestRatesAndLiquidity(reserve, rateData, amount, 0);
}
function updateInterestRatesAndLiquidity(ReserveData storage reserve,ReserveRateData storage rateData,uint256 liquidityAdded,uint256 liquidityTaken) internal {
uint256 utilizationRate = calculateUtilizationRate(reserve.totalLiquidity, reserve.totalUsage);
rateData.currentUsageRate = calculateBorrowRate(
rateData.primeRate, // primeRate is related with the borrow rate.
rateData.baseRate,
rateData.optimalRate,
rateData.maxRate,
rateData.optimalUtilizationRate,
utilizationRate
);
...
}

Impact

Borrowers can pay less interest than expected. And lenders will lose some expected interest.

Tools Used

Manual

Recommendations

Get the latest totalUsage according to the debt token.

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

LendingPool's utilization calculations use stale totalUsage when deposits occur, failing to account for accrued interest since last borrow/repay action, resulting in artificially lower rates

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

LendingPool's utilization calculations use stale totalUsage when deposits occur, failing to account for accrued interest since last borrow/repay action, resulting in artificially lower rates

Support

FAQs

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