Core Contracts

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

Wrong positions of parameteres in mint() function in RToken contract

Summary

In mint() function in RToken contract the positions of the second and fourth variables are swapped.

Vulnerability Details

The mint function in RToken contract expect to return:

  • bool: True if this is the first mint for the recipient, false otherwise

  • uint256: The amount of scaled tokens minted

  • uint256: The new total supply after minting

  • uint256: The amount of underlying tokens minted

it retruns:

return (isFirstMint, amountToMint, totalSupply(), amountScaled);

Second param (amountToMint) is in non-scaled units.
Fourth param (amountScaled) is in underlying units.

Impact

The function is expected to return for second position the amount of scaled tokens and for fourth position - minted amount of tokens in underlying units. It returns the opposites
In ReserveLibrary contract deposit() function returns amountMinted tokens. It expects to be in in scaled units, at row 337:

// Mint RToken to the depositor (scaling handled inside RToken)
(bool isFirstMint, uint256 amountScaled, uint256 newTotalSupply, uint256 amountUnderlying) = IRToken(reserve.reserveRTokenAddress).mint(
address(this), // caller
depositor, // onBehalfOf
amount, // amount
reserve.liquidityIndex // index
);
amountMinted = amountScaled;
// Update the total liquidity and interest rates
updateInterestRatesAndLiquidity(reserve, rateData, 0, amountUnderlying);
emit Withdraw(recipient, amountUnderlying, burnedScaledAmount);
return (amountUnderlying, burnedScaledAmount, amountUnderlying);

It will update the liquidity and return wrong values.

Recommendations

To fix the issue you should change the position for the returned values in mint() function like this:

return (isFirstMint, amountScaled, totalSupply(), amountToMint);
Updates

Lead Judging Commences

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

RToken::mint doesn't return data in the right order, making the protocol emit wrong events

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

RToken::mint doesn't return data in the right order, making the protocol emit wrong events

Support

FAQs

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