The FeeCollector performs direct token transfers to the Treasury address instead of utilizing the Treasury's deposit function, resulting in a complete bypass of the Treasury's accounting system. This creates a significant discrepancy between actual token balances and recorded balances in the Treasury contract and stuck funds that can't be withdrawn anymore.
As far as I can tell the Treasury contract is responsible to receive funds from the FeeCollectorbut the FeeCollector transfers tokens directly to the Treasury without calling the desired deposit() function.
The FeeCollector has a storage variable treasury which receives tokens with a safeTransfer() function call instead of the desired deposit() function:
Treasury's Tracking System is handled only via deposit():
If the treasury address is set to the Treasury contract and not an Externaly Owner Account this will result in locked funds because there is no way to withdraw the tokens from the Treasury contract anymore.
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
Loss of funds for protocol (no way to access those tokens anymore)
Protocol needs to redeploy and fix the FeeCollector contract and all related contracts
Foundry
Manual Review
Update FeeCollector Implementation:
You could also add an emergency withdraw function to the Treasury if needed
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.