{
    "Function": "slitherConstructorConstantVariables",
    "File": "contracts/v3/Vault.sol",
    "Parent Contracts": [
        "contracts/v3/interfaces/IVault.sol"
    ],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "contract Vault is 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    IERC20 public immutable token;\n    IVaultToken public immutable vaultToken;\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 _depositToken The address of the deposit token of the vault\n     * @param _vaultToken The address of the share token for the vault\n     * @param _manager The address of the vault manager contract\n     */\n    constructor(\n        address _depositToken,\n        address _vaultToken,\n        address _manager\n    )\n        public\n    {\n        manager = IManager(_manager);\n        token = IERC20(_depositToken);\n        vaultToken = IVaultToken(_vaultToken);\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     * 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 _strategy\n    )\n        external\n        override\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();\n            token.safeTransfer(address(_controller), _balance);\n            _controller.earn(_strategy, address(token), _balance);\n            emit Earn(address(token), _balance);\n        }\n    }\n\n    /**\n     * USER-FACING FUNCTIONS\n     */\n\n    /**\n     * @notice Deposits the given token into the vault\n     * @param _amount The amount of tokens to deposit\n     */\n     function deposit(\n        uint256 _amount\n     )\n        public\n        override\n        notHalted\n        returns (uint256 _shares)\n    {\n        require(_amount > 0, \"!_amount\");\n\n        uint256 _balance = balance();\n\n        uint256 _before = token.balanceOf(address(this));\n        token.safeTransferFrom(msg.sender, address(this), _amount);\n        _amount = token.balanceOf(address(this)).sub(_before);\n        uint256 _supply = IERC20(address(vaultToken)).totalSupply();\n\n        _amount = _normalizeDecimals(_amount);\n\n        if (_supply > 0) {\n            _amount = (_amount.mul(_supply)).div(_balance);\n        }\n\n        _shares = _amount;\n\n        require(_shares > 0, \"shares=0\");\n        require(_supply.add(_shares) <= totalDepositCap, \">totalDepositCap\");\n        vaultToken.mint(msg.sender, _shares);\n        emit Deposit(msg.sender, _shares);\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     */\n    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    }\n\n    /**\n     * @notice Withdraw the entire balance for an account\n     */\n    function withdrawAll()\n        external\n        override\n    {\n        withdraw(IERC20(address(vaultToken)).balanceOf(msg.sender));\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     */\n    function available()\n        public\n        view\n        override\n        returns (uint256)\n    {\n        return 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)\n    {\n        return _normalizeDecimals(token.balanceOf(address(this)));\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        uint256 _supply = IERC20(address(vaultToken)).totalSupply();\n        if (_supply > 0) {\n            return balance().mul(1e18).div(_supply);\n        } else {\n            return balance();\n        }\n    }\n\n    /**\n     * @notice Returns the deposit token for the vault\n     */\n    function getToken()\n        public\n        view\n        override\n        returns (address)\n    {\n        return address(token);\n    }\n\n    function getLPToken()\n        external\n        view\n        override\n        returns (address)\n    {\n        return address(vaultToken);\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        uint256 _amount\n    )\n        internal\n        view\n        returns (uint256)\n    {\n        uint256 _decimals = uint256(ExtendedIERC20(address(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 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}"
}