In the mint (Rtoken) function, a variable balanceIncrease is calculated to represent the accrued tokens that should be added due to an increase in the liquidity index. However, this calculated value is not added to the amountToMint when minting new tokens. As a result, the user receives fewer tokens than intended because the minting does not account for the accrued balance increase.
The root cause is that the function computes balanceIncrease to capture the difference between the scaled balances at the current index and the previous index. However, this computed value is not incorporated into the final minted amount. Instead, the function mints only the original amountToMint, thereby neglecting the necessary adjustment for accrued interest or index growth.
Imagine a scenario where:
A user has an existing scaled balance of 1,000 tokens.
Their previous index was 1.0, and the current index has increased to 1.1.
The accrued increase should then be calculated as:
If the user mints an additional amountToMint of 500 tokens based on the underlying asset, the correct adjusted mint should be:
However, since balanceIncrease is not added, only 500 tokens are minted. This discrepancy of 100 tokens per transaction (or proportional shortfall in each mint) leads to cumulative losses for the user and can distort the token’s total supply over time.
Because the accrued increase is omitted, users end up with a token balance that is lower than it should be, given the current liquidity index. This miscalculation can lead to:
Incorrect User Balances: Users receive less than the correct amount of tokens, reducing their expected rewards or stake.
Discrepancies in Total Supply: The overall token supply might be underrepresented relative to the accrued values, leading to accounting errors.
Unfair Reward Distribution: Over time, this can accumulate, causing systemic inaccuracies that may unfairly penalize users who have been active longer.
To correct the error, the function should add the balanceIncrease to the amountToMint when minting tokens. For instance, modify the minting process as follows:
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.