Core Contracts

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

Incorrect Scaling in calculateHealthFactor Function: Returns Health Factor in 1e18 Instead of RAY (1e27) as doucmented in natspec

Summary

The LendingPool::calculateHealthFactor function is intended to calculate the health factor of a user, which is a measure of the user's collateralization level relative to their debt. The function is documented to return the health factor in RAY (1e27), but the implementation returns the value scaled by 1e18 instead. This discrepancy between the documentation and the implementation can lead to incorrect calculations and misinterpretation of the health factor.

Vulnerability Details

The Natspec explicitly states that the return value is in RAY (1e27).

/**
* @notice Calculates the user's health factor
* @param userAddress The address of the user
* @return The health factor (in RAY)
*/
return (collateralThreshold * 1e18) / userDebt; // Returns value scaled by 1e18, not 1e27

The calculation multiplies collateralThreshold by 1e18 and divides it by userDebt. This results in a value scaled by 1e18, not 1e27 as documented.

Impact

Users or external systems relying on the health factor may misinterpret the risk level of a position, since all values are stores in ray.

Tools Used

manual review

Recommendations

return the health factor in RAY (1e27) as documented.

Updates

Lead Judging Commences

inallhonesty Lead Judge
7 months ago
inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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

Give us feedback!