Core Contracts

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

Incorrect implementation of StabilityPool::calculateRcrvUSDAmount()

Summary

incorrect implemantation of StabilityPool::calculateRcrvUSDAmount() function

Vulnerability Details

StabilityPool::calculateRcrvUSDAmount() is used to calculating RcrvUSD amount with respect to deToken amount. However, this implementation is not correct. To caculate the right RToken in relation to deToken,

RTokenAmount = deTokenAmount * exchangeRate * RTokenDecimals / 10**18/ deTokenDecimals

Therefor the right caculation should be:

function calculateRcrvUSDAmount(uint256 deCRVUSDAmount) public view returns (uint256) {
uint256 scalingFactor = 10**(18 + rTokenDecimals - deTokenDecimals); //@audit
return (deCRVUSDAmount * scalingFactor) / getExchangeRate();
}

Altough when rTokenDecimals equals to deToeknDecimals, the results happen to be same. However if these two token have different decimals, this will result in error.

Impact

Will break protocol functionality if RToken and deToken have different decimals.

Tools Used

manual

Recommendations

consider revise the calculation terms.

Updates

Lead Judging Commences

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

Incorrect scaling factor formula in StabilityPool::calculateRcrvUSDAmount function

Both tokens have 18 decimals. Info

Support

FAQs

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

Give us feedback!