{
    "Function": "slitherConstructorConstantVariables",
    "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": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "contract Vault is VaultToken, IVault {\n    using Address for address;\n    using SafeMath for uint256;\n    using SafeERC20 for IERC20;\n\n    uint256 public constant MAX = 10000;\n\n    IManager public immutable override manager;\n\n    // Strategist-updated variables\n    address public override gauge;\n    uint256 public min;\n    uint256 public totalDepositCap;\n\n    event Deposit(address indexed account, uint256 amount);\n    event Withdraw(address indexed account, uint256 amount);\n    event Earn(address indexed token, uint256 amount);\n\n    /**\n     * @param _name The name of the vault token for depositors\n     * @param _symbol The symbol of the vault token for depositors\n     * @param _manager The address of the vault manager contract\n     */\n    constructor(\n        string memory _name,\n        string memory _symbol,\n        address _manager\n    )\n        public\n        VaultToken(_name, _symbol)\n    {\n        manager = IManager(_manager);\n        min = 9500;\n        totalDepositCap = 10000000 ether;\n    }\n\n    /**\n     * STRATEGIST-ONLY FUNCTIONS\n     */\n\n    /**\n     * @notice Sets the value of this vault's gauge\n     * @dev Allow to be unset with the zero address\n     * @param _gauge The address of the gauge\n     */\n    function setGauge(\n        address _gauge\n    )\n        external\n        notHalted\n        onlyStrategist\n    {\n        gauge = _gauge;\n    }\n\n    /**\n     * @notice Sets the value for min\n     * @dev min is the minimum percent of funds to keep small withdrawals cheap\n     * @param _min The new min value\n     */\n    function setMin(\n        uint256 _min\n    )\n        external\n        notHalted\n        onlyStrategist\n    {\n        require(_min <= MAX, \"!_min\");\n        min = _min;\n    }\n\n    /**\n     * @notice Sets the value for the totalDepositCap\n     * @dev totalDepositCap is the maximum amount of value that can be deposited\n     * to the metavault at a time\n     * @param _totalDepositCap The new totalDepositCap value\n     */\n    function setTotalDepositCap(\n        uint256 _totalDepositCap\n    )\n        external\n        notHalted\n        onlyStrategist\n    {\n        totalDepositCap = _totalDepositCap;\n    }\n\n    /**\n     * @notice Swaps tokens held within the vault\n     * @param _token0 The token address to swap out\n     * @param _token1 The token address to to\n     * @param _expectedAmount The expected amount of _token1 to receive\n     */\n    function swap(\n        address _token0,\n        address _token1,\n        uint256 _expectedAmount\n    )\n        external\n        override\n        notHalted\n        onlyStrategist\n        returns (uint256 _balance)\n    {\n        IConverter _converter = IConverter(IController(manager.controllers(address(this))).converter(address(this)));\n        _balance = IERC20(_token0).balanceOf(address(this));\n        IERC20(_token0).safeTransfer(address(_converter), _balance);\n        _balance = _converter.convert(_token0, _token1, _balance, _expectedAmount);\n    }\n\n    /**\n     * HARVESTER-ONLY FUNCTIONS\n     */\n\n    /**\n     * @notice Sends accrued 3CRV tokens on the metavault to the controller to be deposited to strategies\n     */\n    function earn(\n        address _token,\n        address _strategy\n    )\n        external\n        override\n        checkToken(_token)\n        notHalted\n        onlyHarvester\n    {\n        require(manager.allowedStrategies(_strategy), \"!_strategy\");\n        IController _controller = IController(manager.controllers(address(this)));\n        if (_controller.investEnabled()) {\n            uint256 _balance = available(_token);\n            IERC20(_token).safeTransfer(address(_controller), _balance);\n            _controller.earn(_strategy, _token, _balance);\n            emit Earn(_token, _balance);\n        }\n    }\n\n    /**\n     * USER-FACING FUNCTIONS\n     */\n\n    /**\n     * @notice Deposits the given token into the vault\n     * @param _token The address of the token\n     * @param _amount The amount of tokens to deposit\n     */\n     function deposit(\n        address _token,\n        uint256 _amount\n     )\n        public\n        override\n        checkToken(_token)\n        notHalted\n        returns (uint256 _shares)\n    {\n        require(_amount > 0, \"!_amount\");\n\n        uint256 _balance = balance();\n\n        uint256 _before = IERC20(_token).balanceOf(address(this));\n        IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);\n        _amount = IERC20(_token).balanceOf(address(this)).sub(_before);\n\n        if (_amount > 0) {\n            _amount = _normalizeDecimals(_token, _amount);\n\n            if (totalSupply() > 0) {\n                _amount = (_amount.mul(totalSupply())).div(_balance);\n            }\n\n            _shares = _amount;\n        }\n\n        if (_shares > 0) {\n            _mint(msg.sender, _shares);\n            require(totalSupply() <= totalDepositCap, \">totalDepositCap\");\n            emit Deposit(msg.sender, _shares);\n        }\n    }\n\n    /**\n     * @notice Deposits multiple tokens simultaneously to the vault\n     * @dev Users must approve the vault to spend their stablecoin\n     * @param _tokens The addresses of each token being deposited\n     * @param _amounts The amounts of each token being deposited\n     */\n    function depositMultiple(\n        address[] calldata _tokens,\n        uint256[] calldata _amounts\n    )\n        external\n        override\n        returns (uint256 _shares)\n    {\n        require(_tokens.length == _amounts.length, \"!length\");\n\n        for (uint8 i; i < _amounts.length; i++) {\n            _shares = _shares.add(deposit(_tokens[i], _amounts[i]));\n        }\n    }\n\n    /**\n     * @notice Withdraws an amount of shares to a given output token\n     * @param _shares The amount of shares to withdraw\n     * @param _output The address of the token to receive\n     */\n    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    }\n\n    /**\n     * @notice Withdraw the entire balance for an account\n     * @param _output The address of the desired token to receive\n     */\n    function withdrawAll(\n        address _output\n    )\n        external\n        override\n    {\n        withdraw(balanceOf(msg.sender), _output);\n    }\n\n    /**\n     * VIEWS\n     */\n\n    /**\n     * @notice Returns the amount of tokens available to be sent to strategies\n     * @dev Custom logic in here for how much the vault allows to be borrowed\n     * @dev Sets minimum required on-hand to keep small withdrawals cheap\n     * @param _token The address of the token\n     */\n    function available(\n        address _token\n    )\n        public\n        view\n        override\n        returns (uint256)\n    {\n        return IERC20(_token).balanceOf(address(this)).mul(min).div(MAX);\n    }\n\n    /**\n     * @notice Returns the total balance of the vault, including strategies\n     */\n    function balance()\n        public\n        view\n        override\n        returns (uint256 _balance)\n    {\n        return balanceOfThis().add(IController(manager.controllers(address(this))).balanceOf());\n    }\n\n    /**\n     * @notice Returns the balance of allowed tokens present on the vault only\n     */\n    function balanceOfThis()\n        public\n        view\n        returns (uint256 _balance)\n    {\n        address[] memory _tokens = manager.getTokens(address(this));\n        for (uint8 i; i < _tokens.length; i++) {\n            address _token = _tokens[i];\n            _balance = _balance.add(_normalizeDecimals(_token, IERC20(_token).balanceOf(address(this))));\n        }\n    }\n\n    /**\n     * @notice Returns the rate of vault shares\n     */\n    function getPricePerFullShare()\n        external\n        view\n        override\n        returns (uint256)\n    {\n        if (totalSupply() > 0) {\n            return balance().mul(1e18).div(totalSupply());\n        } else {\n            return balance();\n        }\n    }\n\n    /**\n     * @notice Returns an array of the tokens for this vault\n     */\n    function getTokens()\n        external\n        view\n        override\n        returns (address[] memory)\n    {\n        return manager.getTokens(address(this));\n    }\n\n    /**\n     * @notice Returns the fee for withdrawing the given amount\n     * @param _amount The amount to withdraw\n     */\n    function withdrawFee(\n        uint256 _amount\n    )\n        external\n        view\n        override\n        returns (uint256)\n    {\n        return manager.withdrawalProtectionFee().mul(_amount).div(MAX);\n    }\n\n    function _normalizeDecimals(\n        address _token,\n        uint256 _amount\n    )\n        internal\n        view\n        returns (uint256)\n    {\n        uint256 _decimals = uint256(ExtendedIERC20(_token).decimals());\n        if (_decimals < 18) {\n            _amount = _amount.mul(10**(18-_decimals));\n        }\n        return _amount;\n    }\n\n    /**\n     * MODIFIERS\n     */\n\n    modifier checkToken(address _token) {\n        require(manager.allowedTokens(_token) && manager.vaults(_token) == address(this), \"!_token\");\n        _;\n    }\n\n    modifier notHalted() {\n        require(!manager.halted(), \"halted\");\n        _;\n    }\n\n    modifier onlyHarvester() {\n        require(msg.sender == manager.harvester(), \"!harvester\");\n        _;\n    }\n\n    modifier onlyStrategist() {\n        require(msg.sender == manager.strategist(), \"!strategist\");\n        _;\n    }\n}"
}