The RAACMinter
contract is repsonsible for managing the minting and distribution of RAAC reward tokens.
The contract uses a utilizationRate
to determine the emissionRate
-> which is then used to determine amount of tokens that are to be minted. The amount of tokens that do get minted completely rely on the emissionRate
to determine the amount that gets minted.
The issue is that utilizationRate
is miscalculated and will always lead to the wrong emissionRate
value , and unintended amounts of minted tokens.
Before we dive into the issue causing the miscalculation of utilizationRate
-> lets understand where it is used, and how it is depended on for the minting of RAAC Tokens:
stabilityPool
calls the RAACMinter
contract to update and mint new RAAC tokens and then uses the total balance of the minted RAAC tokens whenever its needed to determine rewards for users:
RaacMinter::tick
updates and calculates the emissionRate
: TheemissionRate
is calculated using the new utilizationRate
.
RAACMinter::tick
then uses the emission rate to calculate amoountToMint
and mints that amount of new RAAC Tokens
The new tokens are minted to the StabilityPool
and the total balance of RAACTokens are used to determine how many reward tokens a user should receive and then, StabilityPool
transfers the rewards to the user.
**** utilizationRate
miscalculation. :
The utilizationRate
is calculated by comparing the totalBorrowed
amount (total rTokens issued by LendingPool
) and the totalDeposits
(total amount of rTokens deposited into the StabilityPool
).
totalBorrowed
-> is going to be a greater amount than totalDeposits
because not all users that receive rTOkens from the lendingPool will go and deposit them into the StabilityPool.
This will always lead to an inflated amount that will not be the intended value for utilizationRate
that the protocol expects.
The protocol is expecting a calculated value between 0-100
, representing a utilizationRate percentage.
But this will never be achieved, for example:
totalBorrowed
-> will most likely always be larger than totalDeposits
totalBorrowed.
=. 300
totalDeposits.
= 150
The utilizationRate
should be 50 , representing a 50% utilizationRate
But the return value will be 200
300 * 100 / 150 = 200
The wrong value for utilzation rate is calculated
Becasue of the wrong utilizationRate
-> only 1 scenario will be used for calculating the emissionRate
The function has 2 seperate blocks of logic to handle times when the utilzationRate
is below 70 (70%) and when its above 70 (70%).
But becasue of the wrong calculation, as seen above, the value of utilzationRate
will most likely always be greater than utilizationTarget
(70).
As a result, only 1 block of logic will be executed, which increases the rate until the maxRate is reached. And then, it will always stay at maxRate.
This will lead to the unintended emission amounts and the unintended minting amount of new RAACTokens. This is then used to transfer RAAC token rewards to users, which can be more rewards than it should be. Leading to users getting more rewards or unintended amounts of rewards.
Manual Review
Change the utilizationRate
calculation, taking into consideration that totalBorrowed
will be greater than totalDeposits
:
In the scenario above, with this change, the utilizationRate
will be the expected and correct 50 (50%)
150 * 100 / 300 = 50
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.