The calculateRaacRewards
function calculates user rewards based on the total balance of the raacToken
held by the contract. However, this approach is flawed because not all tokens in the contract balance are intended for rewards. Some tokens may be allocated for other purposes, such as distributing to managers or other operational needs. This leads to inflated reward calculations, which can deplete funds meant for other uses and disrupt the protocol's intended functionality. The rewards should instead be tracked based on the tokens minted by the raacMinter and allocated specifically for user rewards.
Affected Code: StabilityPool::CalculateRaacReward
The calculateRaacRewards
function calculates rewards as follows:
Incorrect Reward Calculation:
The function uses the total balance of raacToken
in the contract (raacToken.balanceOf(address(this))
) to calculate rewards.
This includes tokens that are not intended for rewards, such as tokens allocated for managers or other operational purposes.
Inflated Rewards:
Users receive rewards based on the entire contract balance, leading to inflated rewards that deplete funds meant for other uses.
Impact on Other Functions:
The depositRAACFromPool
function deposits raacToken
into the contract for distribution to managers, but the inflated rewards calculation can consume these funds, disrupting the intended distribution.
Manual code review
To fix the issue, the calculateRaacRewards function should only consider the portion of the contract balance that is specifically allocated for rewards minted by the raacMinter. This can be achieved by maintaining a separate state variable to track reward-specific funds.
Updated Code:
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.