{
    "Function": "withdraw",
    "File": "contracts/v3/Vault.sol",
    "Parent Contracts": [
        "contracts/v3/interfaces/IVault.sol",
        "contracts/v3/VaultToken.sol",
        "contracts/vendor/LinkToken/ERC677Token.sol",
        "contracts/vendor/LinkToken/token/ERC677.sol",
        "contracts/vendor/LinkToken/token/LinkERC20.sol",
        "node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol",
        "node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol",
        "node_modules/@openzeppelin/contracts/utils/Context.sol"
    ],
    "High-Level Calls": [
        "IController",
        "SafeMath",
        "IERC20",
        "IController",
        "IERC20",
        "SafeMath",
        "SafeERC20",
        "SafeMath",
        "IManager",
        "SafeMath",
        "SafeMath",
        "SafeMath",
        "SafeMath",
        "IManager"
    ],
    "Internal Calls": [
        "balance",
        "_burn",
        "totalSupply",
        "checkToken"
    ],
    "Library Calls": [
        "div",
        "sub",
        "div",
        "mul",
        "sub",
        "safeTransfer",
        "sub",
        "mul"
    ],
    "Low-Level Calls": [],
    "Code": "function withdraw(\n        uint256 _shares,\n        address _output\n    )\n        public\n        override\n        checkToken(_output)\n    {\n        uint256 _amount = (balance().mul(_shares)).div(totalSupply());\n        _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 = IERC20(_output).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(_output, _toWithdraw);\n            }\n            uint256 _after = IERC20(_output).balanceOf(address(this));\n            uint256 _diff = _after.sub(_balance);\n            if (_diff < _toWithdraw) {\n                _amount = _after;\n            }\n        }\n\n        IERC20(_output).safeTransfer(msg.sender, _amount);\n        emit Withdraw(msg.sender, _amount);\n    }"
}