Furry Rusty Monkey
High
Treasury::withdraw function contains a logic error in its require condition for verifying withdrawal eligibility. The condition incorrectly checks if the withdrawed flag is true, which blocks legitimate withdrawals for new deposits.
Since the default value of withdrawed is false, any new deposit will initially have withdrawed = false.
require(depositDetails.withdrawed, "Already withdrawn");The require statement above essentially requires the value to be true to proceed. If withdrawed is false (default), the statement fails, and the function reverts with the message "Already withdrawn" and blocking legitimate withdrawals.
But the expected behaviour is that withdrawals should only be allowed if the withdrawed flag is false, indicating that the deposit has not yet been withdrawn.
Users cannot withdraw their collateral from new deposits because the require condition fails for all deposits where withdrawed = false (default).
Manual Review
- Change the logic in the require statement to ensure withdrawals are allowed only when
withdrawedisfalse:
require(!depositDetails.withdrawed, "Already withdrawn");This ensures withdrawals are possible for new deposits.
- Set the withdrawed flag to true after a successful withdrawal:
depositDetails.withdrawed = true;