{
    "Function": "withdraw",
    "File": "contracts/v3/Vault.sol",
    "Parent Contracts": [
        "contracts/v3/interfaces/IVault.sol"
    ],
    "High-Level Calls": [
        "IController",
        "SafeMath",
        "SafeMath",
        "SafeMath",
        "SafeMath",
        "IController",
        "SafeMath",
        "IERC20",
        "IERC20",
        "SafeERC20",
        "IManager",
        "SafeMath",
        "SafeMath",
        "IManager",
        "IERC20",
        "IVaultToken"
    ],
    "Internal Calls": [
        "balance"
    ],
    "Library Calls": [
        "sub",
        "mul",
        "safeTransfer",
        "sub",
        "div",
        "mul",
        "sub",
        "div"
    ],
    "Low-Level Calls": [],
    "Code": "function withdraw(\n        uint256 _shares\n    )\n        public\n        override\n    {\n        uint256 _amount = (balance().mul(_shares)).div(IERC20(address(vaultToken)).totalSupply());\n        vaultToken.burn(msg.sender, _shares);\n\n        uint256 _withdrawalProtectionFee = manager.withdrawalProtectionFee();\n        if (_withdrawalProtectionFee > 0) {\n            uint256 _withdrawalProtection = _amount.mul(_withdrawalProtectionFee).div(MAX);\n            _amount = _amount.sub(_withdrawalProtection);\n        }\n\n        uint256 _balance = token.balanceOf(address(this));\n        if (_balance < _amount) {\n            IController _controller = IController(manager.controllers(address(this)));\n            uint256 _toWithdraw = _amount.sub(_balance);\n            if (_controller.strategies() > 0) {\n                _controller.withdraw(address(token), _toWithdraw);\n            }\n            uint256 _after = token.balanceOf(address(this));\n            uint256 _diff = _after.sub(_balance);\n            if (_diff < _toWithdraw) {\n                _amount = _after;\n            }\n        }\n\n        token.safeTransfer(msg.sender, _amount);\n        emit Withdraw(msg.sender, _amount);\n    }"
}