Core Contracts

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

Incorrect Division on Ray Values Leads to Precision Issues in `LendingPool::calculateHealthFactor`.

Vulnerability Details

Throughout the protocol, any arithmetic on RAY and WAD precision values are handled by using functions from
WadRayMath.sol for efficiently handling the fixed-point math intricacies of ray values.

function calculateHealthFactor(address userAddress) public view returns (uint256) {
uint256 collateralValue = getUserCollateralValue(userAddress);
uint256 userDebt = getUserDebt(userAddress); // @ RAY precision
if (userDebt < 1) return type(uint256).max;
uint256 collateralThreshold = collateralValue.percentMul(liquidationThreshold);
@> return (collateralThreshold * 1e18) / userDebt; // @ audit No rayDiv?
}

However, the LendingPool::calculateHealthFactor implementation uses simple division operator (/) instead of the dedicated rayDiv
function from the WadRayMath library resulting in systematic inconsistencies, and precision loss.

Tools Used

Manual Review

Recommendations

Replace the use of the simple division operator for ray values with the rayDiv function from WadRayMath.

- return (collateralThreshold * 1e18) / userDebt;
+ uint256 rayVal = (collateralThreshold * 1e18);
+ return rayVal.rayDiv(userDebt);
Updates

Lead Judging Commences

inallhonesty Lead Judge
5 months ago
inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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