Core Contracts

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

Incorrect Emission Rate Calculation Due to Decimal Mismatch

Summary

The RAACMinter::getUtilizationRate() function returns an incorrect utilization rate due to a mismatch in the decimal places of totalBorrowed and totalDeposits. This results in the utilizationRate > utilizationTarget condition always evaluating to false, causing the emission rate to always be adjusted in the same direction, leading to incorrect reward distributions in the StabilityPool.

Vulnerability Details

The RAACMinter::getUtilizationRate() function calculates the utilization rate as a percentage (0-100) using the formula (totalBorrowed * 100) / totalDeposits. However, totalBorrowed is in WadRayMath.RAY basis (27 decimals), while totalDeposits is in 18 decimals.

In the calculateNewEmissionRate() function, the condition utilizationRate > utilizationTarget is always evaluated as true because of the incorrect calculation of utilizationRate. As a result, the emission rate is always adjusted according to the first branch of the conditional logic, which leads to incorrect emission rates being applied.

RAACMinter.sol

41: > uint256 public utilizationTarget = 70; // 70% target utilization
...
220: function calculateNewEmissionRate() internal view returns (uint256) {
221:> uint256 utilizationRate = getUtilizationRate();
222: uint256 adjustment = (emissionRate * adjustmentFactor) / 100;
223:
224:> if (utilizationRate > utilizationTarget) {
225: uint256 increasedRate = emissionRate + adjustment;
226: uint256 maxRate = increasedRate > benchmarkRate ? increasedRate : benchmarkRate;
227: return maxRate < maxEmissionRate ? maxRate : maxEmissionRate;
228:> } else if (utilizationRate < utilizationTarget) {
229: uint256 decreasedRate = emissionRate > adjustment ? emissionRate - adjustment : 0;
230: uint256 minRate = decreasedRate < benchmarkRate ? decreasedRate : benchmarkRate;
231: return minRate > minEmissionRate ? minRate : minEmissionRate;
232: }
233:
234: return emissionRate;
235: }
...
237: /**
238: * @dev Calculates the current system utilization rate
239:> * @return The utilization rate as a percentage (0-100)
240: */
241: function getUtilizationRate() internal view returns (uint256) {
242:> uint256 totalBorrowed = lendingPool.getNormalizedDebt();
243: uint256 totalDeposits = stabilityPool.getTotalDeposits();
244: if (totalDeposits == 0) return 0;
245: return (totalBorrowed * 100) / totalDeposits;
246: }

Impact

The incorrect calculation of the utilization rate results in the emission rate always being adjusted incorrectly, which leads to distorted reward distributions for users in the StabilityPool.

Tools Used

vscode

Recommendations

Ensure that the decimal precision of totalBorrowed and totalDeposits are aligned before performing the utilization rate calculation.

Updates

Lead Judging Commences

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

RAACMinter::getUtilizationRate incorrectly mixes stability pool deposits with lending pool debt index instead of using proper lending pool metrics

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

RAACMinter::getUtilizationRate incorrectly mixes stability pool deposits with lending pool debt index instead of using proper lending pool metrics

Support

FAQs

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

Give us feedback!