The tick function incorrectly increases the excessTokens variable when minting tokens to the Stability Pool. This creates a discrepancy in the accounting of excessTokens, as the contract assumes it holds these tokens when they have already been minted and transferred to the Stability Pool.
Additionally, the mintRewards function uses excessTokens to reduce the amount of tokens that need to be minted. However, due to the incorrect accounting in tick, the excessTokens variable may not accurately reflect the tokens held by the contract, leading to a revert when using safeTransferdue to insufficent funds.
Impact:
The protocol may inefficiently distribute tokens, leading to potential loss of funds or unfair advantages for certain users.
Code Reference:
Steps to Reproduce:
Initial Setup
Deploy the RAACMinter contract.
Set the emission rate to 100 RAAC per block.
Assume the Stability Pool is empty initially, and excessTokens is 0.
Step 1: Bob Deposits into Stability Pool
Bob deposits 1000 crvUSD into the Stability Pool.
The Stability Pool now has 1000 crvUSD in total deposits.
Step 2: Call tick to Mint Tokens
The tick function is called after 10 blocks.
The amount to mint is calculated as:
The tick function increases excessTokens by 1000 RAAC:
The function mints 1000 RAAC directly to the Stability Pool:
Step 3: Stability Pool Requests Bobs Rewards
Stability Pool** **calls mintRewards to claim Bobs rewards.
The Stability Pool requests 500 RAAC to distribute to Bob.
The mintRewards function calculates:
Since toMint = 0, the function does not mint any additional tokens.
The function attempts to transfer 500 RAAC to Bob from the RAACMinter contract:
What Happens Next?
The RAACMinter contract does not hold any RAAC tokens because they were minted directly to the Stability Pool.
The call to raacToken.safeTransfer(Bob, 500 RAAC) will revert because the RAACMinter contract has an insufficient balance of RAAC tokens.
Remove excessTokens Entirely:
Since tokens are minted directly to the Stability Pool, the excessTokens variable is not needed.
Modify the mintRewards function to always mint the full amount of tokens requested and transfer them to the recipient.
Pros of This Approach:
Simpler logic, as excessTokens is no longer needed.
Tokens are minted on-demand when rewards are requested.
Cons of This Approach:
This approach may lead to more frequent minting operations, which could increase gas costs.
It removes the optimization of using excessTokens to reduce the number of minting operations.
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.