Perpetual - withdraw should only be available in NORMAL state  Pending
According to the specification `withdraw` can only be called in `NORMAL` state. However, the implementation allows it to be called in `NORMAL` and `SETTLED` mode.\\nWithdraw only checks for `!SETTLING` state which resolves to `NORMAL` and `SETTLED`.\\n```\\nfunction withdraw(uint256 amount) public {\\n    withdrawFromAccount(msg.sender, amount);\\n}\\n```\\n\\n```\\nfunction withdrawFromAccount(address payable guy, uint256 amount) private {\\n    require(guy != address(0), "invalid guy");\\n    require(status != LibTypes.Status.SETTLING, "wrong perpetual status");\\n\\n    uint256 currentMarkPrice = markPrice();\\n    require(isSafeWithPrice(guy, currentMarkPrice), "unsafe before withdraw");\\n    remargin(guy, currentMarkPrice);\\n    address broker = currentBroker(guy);\\n    bool forced = broker == address(amm.perpetualProxy()) || broker == address(0);\\n    withdraw(guy, amount, forced);\\n\\n    require(isSafeWithPrice(guy, currentMarkPrice), "unsafe after withdraw");\\n    require(availableMarginWithPrice(guy, currentMarkPrice) >= 0, "withdraw margin");\\n}\\n```\\n\\nIn contrast, `withdrawFor` requires the state to be NORMAL:\\n```\\nfunction withdrawFor(address payable guy, uint256 amount) public onlyWhitelisted {\\n    require(status == LibTypes.Status.NORMAL, "wrong perpetual status");\\n    withdrawFromAccount(guy, amount);\\n}\\n```\\n
Resolution\\nThis issue was resolved by requiring `status == LibTypes.Status.NORMAL`.\\n`withdraw` should only be available in the `NORMAL` operation mode.
```\\nfunction withdraw(uint256 amount) public {\\n    withdrawFromAccount(msg.sender, amount);\\n}\\n```\\n