Assessment reports>Anzen and protocol-v2>Threat Model>emergencyWithdraw

Function: emergencyWithdraw()

This function allows users to withdraw their entire staked amount in an emergency, regardless of any pending rewards.

Branches and code coverage

Intended branches

  • Get the total amount of the user's current stake, user.amount, and sets the user's stake to zero.

  • Iterate through all rewardPools and reset the user's rewardDebt in each pool to zero. This means that the user will no longer have any pending rewards after an emergency withdrawal.

  • Transfer the entire amount of the user's stake from the contract back to the user.

Negative behavior

  • Revert if the current time (block.timestamp) is less than the user's lastStakeTime + unstakingFrozenTime.

Zellic © 2025Back to top ↑