The RToken.mint function computes a scaled amount using the rayDiv function but fails to utilize it during the actual minting process. Instead of minting tokens based on the scaled amount, the function mints tokens using the unscaled amountToMint. This discrepancy results in minted token amounts that do not accurately reflect the intended scaled value.
Incorrect Usage of Unscaled Amount:
In the mint function, the following scaling calculation is performed:
However, when calling the internal mint function, the contract uses:
Instead of minting based on amountScaled, it mints using amountToMint, effectively bypassing the scaling.
Neglected Balance Increase Calculation:
The function also computes a balanceIncrease:
However, this calculated increase is not incorporated into the minting process or the final token balance update.
Inconsistent Token Minting:
Due to the incorrect use of the unscaled amountToMint, the minted token amount does not represent the scaled value that accounts for the current liquidity index. This inconsistency can lead to discrepancies in user balances, affecting further interest accruals and reserve state calculations.
Incorrect User Balances:
Users receive a token amount that does not reflect the intended scaling, causing a mismatch between the deposited asset value and the minted RToken balance.
Normal Scenario:
A user intends to mint tokens by depositing 100 underlying units.
Given a certain liquidity index, the correct scaled amount should be:
The expected behavior is that the user receives amountScaled RTokens.
Issue Manifestation:
The mint function, however, executes:
This results in the user receiving 100 RTokens (the unscaled value) instead of the intended amountScaled.
Result:
The minted amount deviates from the scaled value, leading to incorrect token balances and reserve state calculations.
Manual review
Use Scaled Amount for Minting:
Modify the mint function to use amountScaled in the _mint call. For example:
This ensures that the minted tokens accurately reflect the scaling based on the current liquidity index.
Incorporate Balance Increase (if Applicable):
Review and, if necessary, integrate the balanceIncrease calculation into the user’s balance update to ensure all state changes are accounted for.
The balanceIncrease is the interest that has already accrued on the user's existing scaledBalance since their last interaction. It's not something you mint as new tokens in the _mint function.
The balanceIncrease is the interest that has already accrued on the user's existing scaledBalance since their last interaction. It's not something you mint as new tokens in the _mint function.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.