In the manageUsersInPrivatePool
function within the Distribution.sol, there is a condition check for staking and withdrawal based on the conditions deposited_ < amount_
and deposited_ > amount_
respectively. However, when deposited_
is equal to amount_
, both conditions evaluate to false, resulting in no action being taken. Although this does not pose a direct security risk, it may lead to confusion for the admin, as the intended staking action is not processed. To enhance clarity, it is recommended to handle this scenario by emitting an event in the else block.
In the current implementation, the staking and withdrawal conditions are as follows:
The issue arises when deposited_
is equal to amount_
. In such cases, both conditions are false, and neither the _stake
nor _withdraw
functions are called. This leads to a situation where the admin's intended action to stake the same amount is not processed, causing potential confusion.
The impact of this issue is that admin attempting to stake the same amount as previously deposited are unable to do so. The current conditions do not account for this scenario, resulting in unexpected behavior. Admins interacting with the contract may face confusion due to the lack of feedback on the equality of the deposited amount and the target amount.
Copy the below test and run it via cmd forge test --match-test testManageUsersInPrivatePool -vvvv
In the test admin give shares to 3 user by staking. Now the same amount is added again by calling stake but this time neither the stake will happen nor withdrawal because the both conditions will get false when deposited == amount_
Test:
Result:
To address this issue, it is recommended to add an event in the else block to provide clarity and feedback in the case where deposited_
is equal to amount_
:
This event will inform the admin that the specified amounts were already equal, ensuring transparency and aiding in debugging and monitoring efforts. By emitting this event, the contract becomes more resilient to potential confusion and offers a clearer communication channel for admins interacting with the contract.
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.