In the BaseGauge
contract, the _applyBoost
function uses an incorrect scaling factor when applying the boost multiplier to the base weight. The function divides by 1e18 instead of the basis points precision (10_000), resulting in severely reduced rewards and potential complete nullification for smaller amounts due to precision loss.
The _applyBoost
function in BaseGauge.sol
calculates a user's boosted weight by multiplying their base weight with a boost multiplier. However, the function uses incorrect scaling:
The boost value is meant to be in basis points (where 10_000 = 1x, 25_000 = 2.5x), but the function divides by 1e18. This mismatch in scaling factors causes the final weight to be reduced by a factor of 1e14 (1e18/10_000).
The calculateBoost() function returns a value in basis points and thus the value should be divided by 10_000. [https://github.com/Cyfrin/2025-02-raac/blob/89ccb062e2b175374d40d824263a4c0b601bcb7f/contracts/libraries/governance/BoostCalculator.sol#L74]
In order to run the test you need to:
Run foundryup
to get the latest version of Foundry
Install hardhat-foundry: npm install --save-dev @nomicfoundation/hardhat-foundry
Import it in your Hardhat config: require("@nomicfoundation/hardhat-foundry");
Make sure you've set the BASE_RPC_URL
in the .env
file or comment out the forking
option in the hardhat config.
Run npx hardhat init-foundry
There is one file in the test folder that will throw an error during compilation so rename the file in test/unit/libraries/ReserveLibraryMock.sol
to => ReserveLibraryMock.sol_broken
so it doesn't get compiled anymore (we don't need it anyways).
Create a new folder test/foundry
Paste the below code into a new test file i.e.: FoundryTest.t.sol
Run the test: forge test --mc FoundryTest -vvvv
⚠️ Fix the BaseGauge constructor first, otherwise you'll receive an arithmetic underflow revert because it sets 1e18 to the minBoost value which should be in basis points as you can easily verify by checking the BoostCalculator library
constructor(...) {- boostState.minBoost = 1e18;+ boostState.minBoost = 10_000;}
Users receive drastically reduced rewards (by a factor of ~1e14)
For smaller stake amounts, rewards might be completely nullified due to precision loss
The boost mechanism's effectiveness is significantly diminished
All stakers are affected, with smaller stakers potentially receiving zero rewards
Manual code review
Foundry
The _applyBoost function should be modified to use the correct scaling factor:
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.