Incorrect use of amountToMint instead of amountScaled in the mint function leads to incorrect minting.
amount represents the amount of reserve.reserveRTokenAddress transferred by msg.sender, and amountScaled is the amount of mint RToken, but in the RToken contract code, _mint(onBehalfOf, amountToMint.toUint128()) is incorrect.
Assume that the amount is 100e18 and the index is 1.2e27. The amountScaled is 83,33333333333334e+18.However, according to the incorrect calculation method above, amountToMint is always the number of underlying tokens 100e18.
If mint uses amountToMint directly instead of amountScaled, reserve.liquidityIndex will have no effect and the result will be wrong.
Manual review
should use amountScaled to mint tokens instead of the original amountToMint, because amountScaled is the actual amount to be minted after adjusting the liquidity index. So the correct code should be:
Considering that balanceIncrease has not been used yet, the calculation of amountToMint should be
amountToMint = amountScaled + balanceIncrease;
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.