Core Contracts

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

Wrong Utilization Formula: Underestimating the Utilization of the Fund Pool

Summary

Wrong Utilization Formula: Underestimating the Utilization of the Fund Pool

Vulnerability Details

uint256 utilizationRate = calculateUtilizationRate(reserve.totalLiquidity, reserve.totalUsage);
function calculateUtilizationRate(uint256 totalLiquidity, uint256 totalDebt) internal pure returns (uint256) {
if (totalLiquidity < 1) {
return WadRayMath.RAY; // 100% utilization if no liquidity
}
uint256 utilizationRate = totalDebt.rayDiv(totalLiquidity + totalDebt).toUint128();
return utilizationRate;
}

Total Liquidity is the total pool size, including the funds available for borrowing. And totalDebt is the funds that have been borrowed. Utilization should be the ratio of totalDebt to totalLiquidity, not totalDebt / (totalDebt + totalLiquidity).
Adding totalDebt will cause the formula to calculate the ratio of borrowing to the sum of borrowing and liquidity, which is not the utilization you want to calculate. In fact, the sum of totalDebt + totalLiquidity does not represent the actual pool size, but a mixed value.

Assumptions:

Total Liquidity = 1000 units
, Total Debt = 400 units

Using the wrong formula:

Formula: Utilization Rate = totalDebt / (totalDebt + totalLiquidity)

Substitute the numerical calculation:
Utilization Rate = 400 / (400 + 1000)
So, the utilization rate = 28.57%.

The utilization rate obtained by the wrong formula is only 28.57%, which is far lower than the actual 40%(totalDebt / totalLiquidity
)

Let's use an extreme example to prove that this formula is wrong:

Assumptions:

• Total Liquidity = 1000 units

• Total Debt = 1000 units

This means that all liquidity has been borrowed and the platform's capital pool is fully utilized. In this case, let's compare the utilization calculated by the correct formula and the incorrect formula.

Use the correct formula:

Utilization Rate = totalDebt / totalLiquidity

Substitute the numerical value for calculation:
Utilization Rate = 1000/1000 = 1 = 100%

Result analysis:
Utilization rate = 100%, which means that all liquidity of the platform has been borrowed and the capital pool has been fully utilized.

Using the wrong formula:

Formula: Utilization Rate = totalDebt / (totalDebt + totalLiquidity)

Substituting numerical values ​​for calculation:

Utilization Rate = 1000/1000 + 1000 = 1000/2000 = 0.5 = 50%

Result analysis:
Utilization rate = 50%, this result means that the platform mistakenly believes that only 50% of the fund pool is lent out.

Reference link:

Utilization Rate = Total Borrowed / Total Liquidity

Impact

The utilization rate calculated using the wrong formula is too low, which causes the platform to underestimate the utilization of the fund pool.

Tools Used

Manual review

Recommendations

Modify the formula of calculateUtilizationRate function to use the correct totalLiquidity as the denominator instead of totalDebt + totalLiquidity.

function calculateUtilizationRate(uint256 totalLiquidity, uint256 totalDebt) internal pure returns (uint256) {
if (totalLiquidity < 1) {
return WadRayMath.RAY; // 100% utilization if no liquidity
}
uint256 utilizationRate = totalDebt.rayDiv(totalLiquidity).toUint128();
return utilizationRate;
}
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Design choice
inallhonesty Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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