The delegateBoost() function in the BoostController contract incorrectly handles the boost delegation flow. Instead of allowing users to delegate their existing boost to another address, it creates a new boost entry without properly linking or transferring the user's existing boost.
Doesn't check if user has existing boost to delegate
Creates new boost entry instead of transferring existing boost
No reduction in delegator's boost amount
No proper linking between delegator and delegate (The boost isn't actually applied to any pool's calculations)
Doesn't handle pool working supplies correctly
If we look at the removeBoostDelegation() function we can see that it tries to do some arithmetics based on the poolBoost mapping which never got updated in the delegateBoost function:
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 can delegate non-existent boosts
Original boost remains unchanged
Double-counting of boost amounts
Incorrect boost accounting in the system
Potential for boost amount manipulation
Foundry
Manual Review
Check if delegator has an existing boost
Check if recipient already has delegated boost
Reduce delegators boost
Delegate boost to recipient
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.