The "ContestManager.sol" contract lacks a "Fund Withdraw" function which leads to loss of funds and incorrect manager and claimant cut calculation on closing the Pot.
The "ContestManager.sol" contract has a "fundContest" function which can be used by the Admin user to fund an already created contest Pot, however the "ContestManager.sol" contract does not have any fund withdraw function to reverse this operation. That means if the Admin user sends an excessive fund by mistake to a specific Pot, this excessive fund will be stuck on the Pot, and this operation cannot be reversed.
Lack of "Fund Withdraw" function leads to the following:
1- Loss of funds as excessive funds sent to specific Pot cannot be withdrawn by the Admin uesr.
2- Incorrect calculation of the manager cut and claimant cut on closing the Pot using the Pot::closePot
function which allows these actors to take more cut than they should when the Pot is closed.
Manual Code Review and Foundry
It is recommended to create a contestFundWithdraw function in the "ContestManager.sol" contract so that the Admin user can withdraw excessive funds that are sent by mistake to any create contest Pot. The proposed contestFundWithdraw
function will call another created function transferFund
within the "Pot.sol" contract.
An example simplified implementation can be as follows:
1- Create the following protected public and internal "contestFundWithdraw" functions in the "ContestManager.sol" contract as follows:
2- Add the following public and protected function "trasverFund" in the "Pot.sol" contract to send tokens back to the Admin user:
Please note that the above implementation is a simplified and reduced one just for demo purposes, and further constrains should be added such as the following:
1- Add additional logic to check if a specific Pot has started by Admin user
2- Add a function to allow Admin to mark a specific Pot started
3- Admin users can not withdraw funds from a Pot using the newly implemented "contestFundWithdraw" once the Pot has been started to avoid disrupting the Pot balance and the participating players
To demonstrate and test the newly added and simplified "contestFundWithdraw" function proposed in the recommendation section, add the following test in TestMyCut.t.sol
, and execute the following command:
forge test --mt testCanWithdrawPotFund -vv
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.