The BoostController contract exhibits inconsistent behavior between its public calculateBoost()
and internal _calculateBoost()
functions, leading to different boost amounts being calculated for the same inputs.
The contract uses two different methods to calculate boosts:
The issue arises because:
_calculateBoost()
uses raw token balances (used by updateUserBoost()
calculateBoost()
uses voting power calculations
These different calculation methods result in inconsistent boost amounts
Users cannot accurately predict their boost amount using the public view function
Test Results:
amount calculated by _calculateBoost(): 25000
amount calculated by calculateBoost(): 24589
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
Users receive different boost amounts than what the public calculation function predicts
Difficulty in accurately forecasting boost amounts
Possible exploitation of the difference between calculation methods => especially when other parts of the protocol rely on this information
Foundry
Manual Review
Standardize the calculation method by using voting power or the token balance in both functions and add documentation for explaining the calculation method.
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.