{
    "Function": "slitherConstructorConstantVariables",
    "File": "contracts/legacy/MetaVault.sol",
    "Parent Contracts": [
        "contracts/legacy/IMetaVault.sol",
        "node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol",
        "node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol",
        "node_modules/@openzeppelin/contracts/GSN/Context.sol"
    ],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "contract MetaVault is ERC20, IMetaVault {\n    using Address for address;\n    using SafeMath for uint;\n    using SafeERC20 for IERC20;\n\n    IERC20[4] public inputTokens; // DAI, USDC, USDT, 3Crv\n\n    IERC20 public token3CRV;\n    IERC20 public tokenYAX;\n\n    uint public min = 9500;\n    uint public constant max = 10000;\n\n    uint public earnLowerlimit = 5 ether; // minimum to invest is 5 3CRV\n    uint public totalDepositCap = 10000000 ether; // initial cap set at 10 million dollar\n\n    address public governance;\n    address public controller;\n    uint public insurance;\n    IVaultManager public vaultManager;\n    IConverter public converter;\n\n    bool public acceptContractDepositor = false; // dont accept contract at beginning\n\n    struct UserInfo {\n        uint amount;\n        uint yaxRewardDebt;\n        uint accEarned;\n    }\n\n    uint public lastRewardBlock;\n    uint public accYaxPerShare;\n\n    uint public yaxPerBlock;\n\n    mapping(address => UserInfo) public userInfo;\n\n    address public treasuryWallet = 0x362Db1c17db4C79B51Fe6aD2d73165b1fe9BaB4a;\n\n    uint public constant BLOCKS_PER_WEEK = 46500;\n\n    // Block number when each epoch ends.\n    uint[5] public epochEndBlocks;\n\n    // Reward multipler for each of 5 epoches (epochIndex: reward multipler)\n    uint[6] public epochRewardMultiplers = [86000, 64000, 43000, 21000, 10000, 1];\n\n    /**\n     * @notice Emitted when a user deposits funds\n     */\n    event Deposit(address indexed user, uint amount);\n\n    /**\n     * @notice Emitted when a user withdraws funds\n     */\n    event Withdraw(address indexed user, uint amount);\n\n    /**\n     * @notice Emitted when YAX is paid to a user\n     */\n    event RewardPaid(address indexed user, uint reward);\n\n    /**\n     * @param _tokenDAI The address of the DAI token\n     * @param _tokenUSDC The address of the USDC token\n     * @param _tokenUSDT The address of the USDT token\n     * @param _token3CRV The address of the 3CRV token\n     * @param _tokenYAX The address of the YAX token\n     * @param _yaxPerBlock The amount of YAX rewarded per block\n     * @param _startBlock The starting block for rewards\n     */\n    constructor (IERC20 _tokenDAI, IERC20 _tokenUSDC, IERC20 _tokenUSDT, IERC20 _token3CRV, IERC20 _tokenYAX,\n        uint _yaxPerBlock, uint _startBlock) public ERC20(\"yAxis.io:MetaVault:3CRV\", \"MVLT\") {\n        inputTokens[0] = _tokenDAI;\n        inputTokens[1] = _tokenUSDC;\n        inputTokens[2] = _tokenUSDT;\n        inputTokens[3] = _token3CRV;\n        token3CRV = _token3CRV;\n        tokenYAX = _tokenYAX;\n        yaxPerBlock = _yaxPerBlock; // supposed to be 0.000001 YAX (1000000000000 = 1e12 wei)\n        lastRewardBlock = (_startBlock > block.number) ? _startBlock : block.number; // supposed to be 11,163,000 (Sat Oct 31 2020 06:30:00 GMT+0)\n        epochEndBlocks[0] = lastRewardBlock + BLOCKS_PER_WEEK * 2; // weeks 1-2\n        epochEndBlocks[1] = epochEndBlocks[0] + BLOCKS_PER_WEEK * 2; // weeks 3-4\n        epochEndBlocks[2] = epochEndBlocks[1] + BLOCKS_PER_WEEK * 4; // month 2\n        epochEndBlocks[3] = epochEndBlocks[2] + BLOCKS_PER_WEEK * 8; // month 3-4\n        epochEndBlocks[4] = epochEndBlocks[3] + BLOCKS_PER_WEEK * 8; // month 5-6\n        governance = msg.sender;\n    }\n\n    /**\n     * @dev Throws if called by a contract and we are not allowing.\n     */\n    modifier checkContract() {\n        if (!acceptContractDepositor) {\n            require(!address(msg.sender).isContract() && msg.sender == tx.origin, \"Sorry we do not accept contract!\");\n        }\n        _;\n    }\n\n    /**\n     * @notice Returns the current token3CRV balance of the vault and controller, minus insurance\n     * @dev Ignore insurance fund for balance calculations\n     */\n    function balance() public override view returns (uint) {\n        uint bal = token3CRV.balanceOf(address(this));\n        if (controller != address(0)) bal = bal.add(IController(controller).balanceOf(address(token3CRV)));\n        return bal.sub(insurance);\n    }\n\n    /**\n     * @notice Called by Governance to set the value for min\n     * @param _min The new min value\n     */\n    function setMin(uint _min) external {\n        require(msg.sender == governance, \"!governance\");\n        min = _min;\n    }\n\n    /**\n     * @notice Called by Governance to set the value for the governance address\n     * @param _governance The new governance value\n     */\n    function setGovernance(address _governance) public {\n        require(msg.sender == governance, \"!governance\");\n        governance = _governance;\n    }\n\n    /**\n     * @notice Called by Governance to set the value for the controller address\n     * @param _controller The new controller value\n     */\n    function setController(address _controller) public override {\n        require(msg.sender == governance, \"!governance\");\n        controller = _controller;\n    }\n\n    /**\n     * @notice Called by Governance to set the value for the converter address\n     * @param _converter The new converter value\n     * @dev Requires that the return address of token() from the converter is the\n     * same as token3CRV\n     */\n    function setConverter(IConverter _converter) public {\n        require(msg.sender == governance, \"!governance\");\n        require(_converter.token() == address(token3CRV), \"!token3CRV\");\n        converter = _converter;\n    }\n\n    /**\n     * @notice Called by Governance to set the value for the vaultManager address\n     * @param _vaultManager The new vaultManager value\n     */\n    function setVaultManager(IVaultManager _vaultManager) public {\n        require(msg.sender == governance, \"!governance\");\n        vaultManager = _vaultManager;\n    }\n\n    /**\n     * @notice Called by Governance to set the value for the earnLowerlimit\n     * @dev earnLowerlimit determines the minimum balance of this contract for earn\n     * to be called\n     * @param _earnLowerlimit The new earnLowerlimit value\n     */\n    function setEarnLowerlimit(uint _earnLowerlimit) public {\n        require(msg.sender == governance, \"!governance\");\n        earnLowerlimit = _earnLowerlimit;\n    }\n\n    /**\n     * @notice Called by Governance to set 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(uint _totalDepositCap) public {\n        require(msg.sender == governance, \"!governance\");\n        totalDepositCap = _totalDepositCap;\n    }\n\n    /**\n     * @notice Called by Governance to set the value for acceptContractDepositor\n     * @dev acceptContractDepositor allows the metavault to accept deposits from\n     * smart contract addresses\n     * @param _acceptContractDepositor The new acceptContractDepositor value\n     */\n    function setAcceptContractDepositor(bool _acceptContractDepositor) public {\n        require(msg.sender == governance, \"!governance\");\n        acceptContractDepositor = _acceptContractDepositor;\n    }\n\n    /**\n     * @notice Called by Governance to set the value for yaxPerBlock\n     * @dev Makes a call to updateReward()\n     * @param _yaxPerBlock The new yaxPerBlock value\n     */\n    function setYaxPerBlock(uint _yaxPerBlock) public {\n        require(msg.sender == governance, \"!governance\");\n        updateReward();\n        yaxPerBlock = _yaxPerBlock;\n    }\n\n    /**\n     * @notice Called by Governance to set the value for epochEndBlocks at the given index\n     * @dev Throws if _index >= 5\n     * @dev Throws if _epochEndBlock > the current block.number\n     * @dev Throws if the stored block.number at the given index is > the current block.number\n     * @param _index The index to set of epochEndBlocks\n     * @param _epochEndBlock The new epochEndBlocks value at the index\n     */\n    function setEpochEndBlock(uint8 _index, uint256 _epochEndBlock) public {\n        require(msg.sender == governance, \"!governance\");\n        require(_index < 5, \"_index out of range\");\n        require(_epochEndBlock > block.number, \"Too late to update\");\n        require(epochEndBlocks[_index] > block.number, \"Too late to update\");\n        epochEndBlocks[_index] = _epochEndBlock;\n    }\n\n    /**\n     * @notice Called by Governance to set the value for epochRewardMultiplers at the given index\n     * @dev Throws if _index < 1 or > 5\n     * @dev Throws if the stored block.number at the previous index is > the current block.number\n     * @param _index The index to set of epochRewardMultiplers\n     * @param _epochRewardMultipler The new epochRewardMultiplers value at the index\n     */\n    function setEpochRewardMultipler(uint8 _index, uint256 _epochRewardMultipler) public {\n        require(msg.sender == governance, \"!governance\");\n        require(_index > 0 && _index < 6, \"Index out of range\");\n        require(epochEndBlocks[_index - 1] > block.number, \"Too late to update\");\n        epochRewardMultiplers[_index] = _epochRewardMultipler;\n    }\n\n    /**\n     * @notice Return reward multiplier over the given _from to _to block.\n     * @param _from The from block\n     * @param _to The to block\n     */\n    function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) {\n        // start at the end of the epochs\n        for (uint8 epochId = 5; epochId >= 1; --epochId) {\n            // if _to (the current block number if called within this contract) is after the previous epoch ends\n            if (_to >= epochEndBlocks[epochId - 1]) {\n                // if the last reward block is after the previous epoch: return the number of blocks multiplied by this epochs multiplier\n                if (_from >= epochEndBlocks[epochId - 1]) return _to.sub(_from).mul(epochRewardMultiplers[epochId]);\n                // get the multiplier amount for the remaining reward of the current epoch\n                uint256 multiplier = _to.sub(epochEndBlocks[epochId - 1]).mul(epochRewardMultiplers[epochId]);\n                // if epoch is 1: return the remaining current epoch reward with the first epoch reward\n                if (epochId == 1) return multiplier.add(epochEndBlocks[0].sub(_from).mul(epochRewardMultiplers[0]));\n                // for all epochs in between the first and current epoch\n                for (epochId = epochId - 1; epochId >= 1; --epochId) {\n                    // if the last reward block is after the previous epoch: return the current remaining reward with the previous epoch\n                    if (_from >= epochEndBlocks[epochId - 1]) return multiplier.add(epochEndBlocks[epochId].sub(_from).mul(epochRewardMultiplers[epochId]));\n                    // accumulate the multipler with the reward from the epoch\n                    multiplier = multiplier.add(epochEndBlocks[epochId].sub(epochEndBlocks[epochId - 1]).mul(epochRewardMultiplers[epochId]));\n                }\n                // return the accumulated multiplier with the reward from the first epoch\n                return multiplier.add(epochEndBlocks[0].sub(_from).mul(epochRewardMultiplers[0]));\n            }\n        }\n        // return the reward amount between _from and _to in the first epoch\n        return _to.sub(_from).mul(epochRewardMultiplers[0]);\n    }\n\n    /**\n     * @notice Called by Governance to set the value for the treasuryWallet\n     * @param _treasuryWallet The new treasuryWallet value\n     */\n    function setTreasuryWallet(address _treasuryWallet) public {\n        require(msg.sender == governance, \"!governance\");\n        treasuryWallet = _treasuryWallet;\n    }\n\n    /**\n     * @notice Called by Governance or the controller to claim the amount stored in the insurance fund\n     * @dev If called by the controller, insurance will auto compound the vault, increasing getPricePerFullShare\n     */\n    function claimInsurance() external override {\n        // if claim by controller for auto-compounding (current insurance will stay to increase sharePrice)\n        // otherwise send the fund to treasuryWallet\n        if (msg.sender != controller) {\n            // claim by governance for insurance\n            require(msg.sender == governance, \"!governance\");\n            token3CRV.safeTransfer(treasuryWallet, insurance);\n        }\n        insurance = 0;\n    }\n\n    /**\n     * @notice Get the address of the 3CRV token\n     */\n    function token() public override view returns (address) {\n        return address(token3CRV);\n    }\n\n    /**\n     * @notice Get the amount that the metavault allows to be borrowed\n     * @dev min and max are used to keep small withdrawals cheap\n     */\n    function available() public override view returns (uint) {\n        return token3CRV.balanceOf(address(this)).mul(min).div(max);\n    }\n\n    /**\n     * @notice If the controller is set, returns the withdrawFee of the 3CRV token for the given _amount\n     * @param _amount The amount being queried to withdraw\n     */\n    function withdrawFee(uint _amount) public override view returns (uint) {\n        return (controller == address(0)) ? 0 : IController(controller).withdrawFee(address(token3CRV), _amount);\n    }\n\n    /**\n     * @notice Sends accrued 3CRV tokens on the metavault to the controller to be deposited to strategies\n     */\n    function earn() public override {\n        if (controller != address(0)) {\n            IController _contrl = IController(controller);\n            if (_contrl.investEnabled()) {\n                uint _bal = available();\n                token3CRV.safeTransfer(controller, _bal);\n                _contrl.earn(address(token3CRV), _bal);\n            }\n        }\n    }\n\n    /**\n     * @notice Returns the amount of 3CRV given for the amounts deposited\n     * @param amounts The stablecoin amounts being deposited\n     */\n    function calc_token_amount_deposit(uint[3] calldata amounts) external override view returns (uint) {\n        return converter.calc_token_amount(amounts, true);\n    }\n\n    /**\n     * @notice Returns the amount given in the desired token for the given shares\n     * @param _shares The amount of shares to withdraw\n     * @param _output The desired token to withdraw\n     */\n    function calc_token_amount_withdraw(uint _shares, address _output) external override view returns (uint) {\n        uint _withdrawFee = withdrawFee(_shares);\n        if (_withdrawFee > 0) {\n            _shares = _shares.mul(10000 - _withdrawFee).div(10000);\n        }\n        uint r = (balance().mul(_shares)).div(totalSupply());\n        if (_output == address(token3CRV)) {\n            return r;\n        }\n        return converter.calc_token_amount_withdraw(r, _output);\n    }\n\n    /**\n     * @notice Returns the amount of 3CRV that would be given for the amount of input tokens\n     * @param _input The stablecoin to convert to 3CRV\n     * @param _amount The amount of stablecoin to convert\n     */\n    function convert_rate(address _input, uint _amount) external override view returns (uint) {\n        return converter.convert_rate(_input, address(token3CRV), _amount);\n    }\n\n    /**\n     * @notice Deposit a single stablecoin to the metavault\n     * @dev Users must approve the metavault to spend their stablecoin\n     * @param _amount The amount of the stablecoin to deposit\n     * @param _input The address of the stablecoin being deposited\n     * @param _min_mint_amount The expected amount of shares to receive\n     * @param _isStake Stakes shares or not\n     */\n    function deposit(uint _amount, address _input, uint _min_mint_amount, bool _isStake) external override checkContract {\n        require(_amount > 0, \"!_amount\");\n        uint _pool = balance();\n        uint _before = token3CRV.balanceOf(address(this));\n        if (_input == address(token3CRV)) {\n            token3CRV.safeTransferFrom(msg.sender, address(this), _amount);\n        } else if (converter.convert_rate(_input, address(token3CRV), _amount) > 0) {\n            IERC20(_input).safeTransferFrom(msg.sender, address(converter), _amount);\n            converter.convert(_input, address(token3CRV), _amount);\n        }\n        uint _after = token3CRV.balanceOf(address(this));\n        require(totalDepositCap == 0 || _after <= totalDepositCap, \">totalDepositCap\");\n        _amount = _after.sub(_before); // Additional check for deflationary tokens\n        require(_amount >= _min_mint_amount, \"slippage\");\n        if (_amount > 0) {\n            if (!_isStake) {\n                _deposit(msg.sender, _pool, _amount);\n            } else {\n                uint _shares = _deposit(address(this), _pool, _amount);\n                _stakeShares(_shares);\n            }\n        }\n    }\n\n    /**\n     * @notice Deposits multiple stablecoins simultaneously to the metavault\n     * @dev 0: DAI, 1: USDC, 2: USDT, 3: 3CRV\n     * @dev Users must approve the metavault to spend their stablecoin\n     * @param _amounts The amounts of each stablecoin being deposited\n     * @param _min_mint_amount The expected amount of shares to receive\n     * @param _isStake Stakes shares or not\n     */\n    function depositAll(uint[4] calldata _amounts, uint _min_mint_amount, bool _isStake) external checkContract {\n        uint _pool = balance();\n        uint _before = token3CRV.balanceOf(address(this));\n        bool hasStables = false;\n        for (uint8 i = 0; i < 4; i++) {\n            uint _inputAmount = _amounts[i];\n            if (_inputAmount > 0) {\n                if (i == 3) {\n                    inputTokens[i].safeTransferFrom(msg.sender, address(this), _inputAmount);\n                } else if (converter.convert_rate(address(inputTokens[i]), address(token3CRV), _inputAmount) > 0) {\n                    inputTokens[i].safeTransferFrom(msg.sender, address(converter), _inputAmount);\n                    hasStables = true;\n                }\n            }\n        }\n        if (hasStables) {\n            uint[3] memory _stablesAmounts;\n            _stablesAmounts[0] = _amounts[0];\n            _stablesAmounts[1] = _amounts[1];\n            _stablesAmounts[2] = _amounts[2];\n            converter.convert_stables(_stablesAmounts);\n        }\n        uint _after = token3CRV.balanceOf(address(this));\n        require(totalDepositCap == 0 || _after <= totalDepositCap, \">totalDepositCap\");\n        uint _totalDepositAmount = _after.sub(_before); // Additional check for deflationary tokens\n        require(_totalDepositAmount >= _min_mint_amount, \"slippage\");\n        if (_totalDepositAmount > 0) {\n            if (!_isStake) {\n                _deposit(msg.sender, _pool, _totalDepositAmount);\n            } else {\n                uint _shares = _deposit(address(this), _pool, _totalDepositAmount);\n                _stakeShares(_shares);\n            }\n        }\n    }\n\n    /**\n     * @notice Stakes metavault shares\n     * @param _shares The amount of shares to stake\n     */\n    function stakeShares(uint _shares) external {\n        uint _before = balanceOf(address(this));\n        IERC20(address(this)).transferFrom(msg.sender, address(this), _shares);\n        uint _after = balanceOf(address(this));\n        _shares = _after.sub(_before);\n        // Additional check for deflationary tokens\n        _stakeShares(_shares);\n    }\n\n    function _deposit(address _mintTo, uint _pool, uint _amount) internal returns (uint _shares) {\n        if (address(vaultManager) != address(0)) {\n            // expected 0.1% of deposits go into an insurance fund (or auto-compounding if called by controller) in-case of negative profits to protect withdrawals\n            // it is updated by governance (community vote)\n            uint _insuranceFee = vaultManager.insuranceFee();\n            if (_insuranceFee > 0) {\n                uint _insurance = _amount.mul(_insuranceFee).div(10000);\n                _amount = _amount.sub(_insurance);\n                insurance = insurance.add(_insurance);\n            }\n        }\n\n        if (totalSupply() == 0) {\n            _shares = _amount;\n        } else {\n            _shares = (_amount.mul(totalSupply())).div(_pool);\n        }\n        if (_shares > 0) {\n            if (token3CRV.balanceOf(address(this)) > earnLowerlimit) {\n                earn();\n            }\n            _mint(_mintTo, _shares);\n        }\n    }\n\n    function _stakeShares(uint _shares) internal {\n        UserInfo storage user = userInfo[msg.sender];\n        updateReward();\n        _getReward();\n        user.amount = user.amount.add(_shares);\n        user.yaxRewardDebt = user.amount.mul(accYaxPerShare).div(1e12);\n        emit Deposit(msg.sender, _shares);\n    }\n\n    /**\n     * @notice Returns the pending YAXs for a given account\n     * @param _account The address to query\n     */\n    function pendingYax(address _account) public view returns (uint _pending) {\n        UserInfo storage user = userInfo[_account];\n        uint _accYaxPerShare = accYaxPerShare;\n        uint lpSupply = balanceOf(address(this));\n        if (block.number > lastRewardBlock && lpSupply != 0) {\n            uint256 _multiplier = getMultiplier(lastRewardBlock, block.number);\n            _accYaxPerShare = accYaxPerShare.add(_multiplier.mul(yaxPerBlock).mul(1e12).div(lpSupply));\n        }\n        _pending = user.amount.mul(_accYaxPerShare).div(1e12).sub(user.yaxRewardDebt);\n    }\n\n    /**\n     * @notice Sets the lastRewardBlock and accYaxPerShare\n     */\n    function updateReward() public {\n        if (block.number <= lastRewardBlock) {\n            return;\n        }\n        uint lpSupply = balanceOf(address(this));\n        if (lpSupply == 0) {\n            lastRewardBlock = block.number;\n            return;\n        }\n        uint256 _multiplier = getMultiplier(lastRewardBlock, block.number);\n        accYaxPerShare = accYaxPerShare.add(_multiplier.mul(yaxPerBlock).mul(1e12).div(lpSupply));\n        lastRewardBlock = block.number;\n    }\n\n    function _getReward() internal {\n        UserInfo storage user = userInfo[msg.sender];\n        uint _pendingYax = user.amount.mul(accYaxPerShare).div(1e12).sub(user.yaxRewardDebt);\n        if (_pendingYax > 0) {\n            user.accEarned = user.accEarned.add(_pendingYax);\n            safeYaxTransfer(msg.sender, _pendingYax);\n            emit RewardPaid(msg.sender, _pendingYax);\n        }\n    }\n\n    /**\n     * @notice Withdraw the entire balance for an account\n     * @param _output The address of the desired stablecoin to receive\n     */\n    function withdrawAll(address _output) external {\n        unstake(userInfo[msg.sender].amount);\n        withdraw(balanceOf(msg.sender), _output);\n    }\n\n    /**\n     * @notice Used to swap any borrowed reserve over the debt limit to liquidate to 'token'\n     * @param reserve The address of the token to swap to 3CRV\n     * @param amount The amount to swap\n     */\n    function harvest(address reserve, uint amount) external override {\n        require(msg.sender == controller, \"!controller\");\n        require(reserve != address(token3CRV), \"token3CRV\");\n        IERC20(reserve).safeTransfer(controller, amount);\n    }\n\n    /**\n     * @notice Unstakes the given shares from the metavault\n     * @dev call unstake(0) to only receive the reward\n     * @param _amount The amount to unstake\n     */\n    function unstake(uint _amount) public {\n        updateReward();\n        _getReward();\n        UserInfo storage user = userInfo[msg.sender];\n        if (_amount > 0) {\n            require(user.amount >= _amount, \"stakedBal < _amount\");\n            user.amount = user.amount.sub(_amount);\n            IERC20(address(this)).transfer(msg.sender, _amount);\n        }\n        user.yaxRewardDebt = user.amount.mul(accYaxPerShare).div(1e12);\n        emit Withdraw(msg.sender, _amount);\n    }\n\n    /**\n     * @notice Withdraws an amount of shares to a given output stablecoin\n     * @dev No rebalance implementation for lower fees and faster swaps\n     * @param _shares The amount of shares to withdraw\n     * @param _output The address of the stablecoin to receive\n     */\n    function withdraw(uint _shares, address _output) public override {\n        uint _userBal = balanceOf(msg.sender);\n        if (_shares > _userBal) {\n            uint _need = _shares.sub(_userBal);\n            require(_need <= userInfo[msg.sender].amount, \"_userBal+staked < _shares\");\n            unstake(_need);\n        }\n        uint r = (balance().mul(_shares)).div(totalSupply());\n        _burn(msg.sender, _shares);\n\n        if (address(vaultManager) != address(0)) {\n            // expected 0.1% of withdrawal go back to vault (for auto-compounding) to protect withdrawals\n            // it is updated by governance (community vote)\n            uint _withdrawalProtectionFee = vaultManager.withdrawalProtectionFee();\n            if (_withdrawalProtectionFee > 0) {\n                uint _withdrawalProtection = r.mul(_withdrawalProtectionFee).div(10000);\n                r = r.sub(_withdrawalProtection);\n            }\n        }\n\n        // Check balance\n        uint b = token3CRV.balanceOf(address(this));\n        if (b < r) {\n            uint _toWithdraw = r.sub(b);\n            if (controller != address(0)) {\n                IController(controller).withdraw(address(token3CRV), _toWithdraw);\n            }\n            uint _after = token3CRV.balanceOf(address(this));\n            uint _diff = _after.sub(b);\n            if (_diff < _toWithdraw) {\n                r = b.add(_diff);\n            }\n        }\n\n        if (_output == address(token3CRV)) {\n            token3CRV.safeTransfer(msg.sender, r);\n        } else {\n            require(converter.convert_rate(address(token3CRV), _output, r) > 0, \"rate=0\");\n            token3CRV.safeTransfer(address(converter), r);\n            uint _outputAmount = converter.convert(address(token3CRV), _output, r);\n            IERC20(_output).safeTransfer(msg.sender, _outputAmount);\n        }\n    }\n\n    /**\n     * @notice Returns the address of the 3CRV token\n     */\n    function want() external override view returns (address) {\n        return address(token3CRV);\n    }\n\n    /**\n     * @notice Returns the rate of earnings of a single share\n     */\n    function getPricePerFullShare() external override view returns (uint) {\n        return balance().mul(1e18).div(totalSupply());\n    }\n\n    /**\n     * @notice Transfers YAX from the metavault to a given address\n     * @dev Ensures the metavault has enough balance to transfer\n     * @param _to The address to transfer to\n     * @param _amount The amount to transfer\n     */\n    function safeYaxTransfer(address _to, uint _amount) internal {\n        uint _tokenBal = tokenYAX.balanceOf(address(this));\n        tokenYAX.safeTransfer(_to, (_tokenBal < _amount) ? _tokenBal : _amount);\n    }\n\n    /**\n     * @notice Converts non-3CRV stablecoins held in the metavault to 3CRV\n     * @param _token The address to convert\n     */\n    function earnExtra(address _token) public {\n        require(msg.sender == governance, \"!governance\");\n        require(address(_token) != address(token3CRV), \"3crv\");\n        require(address(_token) != address(this), \"mlvt\");\n        uint _amount = IERC20(_token).balanceOf(address(this));\n        require(converter.convert_rate(_token, address(token3CRV), _amount) > 0, \"rate=0\");\n        IERC20(_token).safeTransfer(address(converter), _amount);\n        converter.convert(_token, address(token3CRV), _amount);\n    }\n}"
}