The RToken::mint
function fails to properly implement scaling as indicated by its comments, leading to incorrect values being returned and tokens being minted with unscaled amounts.
LendingPool::deposit
calls ReserveLibrary::deposit
which in turn calls RToken::mint
function. Just before calling mint function, we are informed by the comment above it that the scaling is handled inside RToken.
In RToken::mint function there are a couple of issues:
amountScaled is defined but is not being used apart from this check
scaledBalance and balanceIncrease are defined, but are not used. They just take space inside the function but do not change the state or are returned in any way:
I mean, balanceIncrease is defined, and then calculated in the if clause, but after the calculation nothing is done with it. It’s just there, taking space in the code block, doing nothing. But let’s continue.
these are the return values from the mint function
Now, first of all, remember that in the ReserveLibrary::deposit
function that called this RToken::mint
function, we had this comment indicating that some scaling had to be done :
*// Mint RToken to the depositor (scaling handled inside RToken)*
Now let’s compare two codeblocks to understand it better:
In the returns in ReserveLibrary, we see that it returns and uses uint256 amountScaled,
but it never returned the scaled amount from RToken::mint
, it just returned the amount that is passed in the params. No scaling ever happened or returned there.
So, wrong values are minted.
Incorrect accounting of deposited amounts throughout the protocol
Mismatch between actual minted tokens and what the system believes was minted
Potential economic exploits if users can receive more tokens than they should
Integrity issues with protocol's state and total supply calculations
Correct the return values to match what the caller expects, or adjust the caller to expect the values in the correct order.
Use the scaled amount for minting:
Clean up or properly utilize the balanceIncrease
calculation.
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.