{
    "Function": "slitherConstructorConstantVariables",
    "File": "contracts/v3/strategies/GeneralConvexStrategy.sol",
    "Parent Contracts": [
        "contracts/v3/strategies/BaseStrategy.sol",
        "contracts/v3/interfaces/IStrategy.sol"
    ],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "contract GeneralConvexStrategy is BaseStrategy {\n    using SafeMath for uint8;\n\n    address public immutable crv;\n    address public immutable cvx;\n\n    uint256 public immutable pid;\n    IConvexVault public immutable convexVault;\n    address public immutable cvxDepositLP;\n    IConvexRewards public immutable crvRewards;\n    address public immutable stableSwapPool;\n\n    address[] public tokens;\n    uint8[] public decimalMultiples;\n\n    /**\n     * @param _name The strategy name\n     * @param _want The desired token of the strategy\n     * @param _crv The address of CRV\n     * @param _cvx The address of CVX\n     * @param _weth The address of WETH\n     * @param _pid The pool id of convex\n     * @param _coinCount The number of coins in the pool\n     * @param _convexVault The address of the convex vault\n     * @param _stableSwapPool The address of the stable swap pool\n     * @param _controller The address of the controller\n     * @param _manager The address of the manager\n     * @param _router The address of the router for swapping tokens\n     */\n    constructor(\n        string memory _name,\n        address _want,\n        address _crv,\n        address _cvx,\n        address _weth,\n        uint256 _pid,\n        uint256 _coinCount,\n        IConvexVault _convexVault,\n        address _stableSwapPool,\n        address _controller,\n        address _manager,\n        address _router\n    ) public BaseStrategy(_name, _controller, _manager, _want, _weth, _router) {\n        require(_coinCount == 2 || _coinCount == 3, '_coinCount should be 2 or 3');\n        require(address(_crv) != address(0), '!_crv');\n        require(address(_cvx) != address(0), '!_cvx');\n        require(address(_convexVault) != address(0), '!_convexVault');\n        require(address(_stableSwapPool) != address(0), '!_stableSwapPool');\n\n        (, address _token, , address _crvRewards, , ) = _convexVault.poolInfo(_pid);\n        crv = _crv;\n        cvx = _cvx;\n        pid = _pid;\n        convexVault = _convexVault;\n        cvxDepositLP = _token;\n        crvRewards = IConvexRewards(_crvRewards);\n        stableSwapPool = _stableSwapPool;\n\n        for (uint256 i = 0; i < _coinCount; i++) {\n            tokens.push(IStableSwapPool(_stableSwapPool).coins(i));\n            decimalMultiples.push(18 - ExtendedIERC20(tokens[i]).decimals());\n            IERC20(tokens[i]).safeApprove(_stableSwapPool, type(uint256).max);\n        }\n\n        IERC20(_want).safeApprove(address(_convexVault), type(uint256).max);\n        IERC20(_crv).safeApprove(address(_router), type(uint256).max);\n        IERC20(_cvx).safeApprove(address(_router), type(uint256).max);\n        IERC20(_want).safeApprove(address(_stableSwapPool), type(uint256).max);\n    }\n\n    function _deposit() internal override {\n        convexVault.depositAll(pid, true);\n    }\n\n    function _claimReward() internal {\n        crvRewards.getReward(address(this), true);\n    }\n\n    function _addLiquidity() internal {\n        if (tokens.length == 2) {\n            uint256[2] memory amounts;\n            amounts[0] = IERC20(tokens[0]).balanceOf(address(this));\n            amounts[1] = IERC20(tokens[1]).balanceOf(address(this));\n            IStableSwap2Pool(stableSwapPool).add_liquidity(amounts, 1);\n            return;\n        }\n\n        uint256[3] memory amounts;\n        amounts[0] = IERC20(tokens[0]).balanceOf(address(this));\n        amounts[1] = IERC20(tokens[1]).balanceOf(address(this));\n        amounts[2] = IERC20(tokens[2]).balanceOf(address(this));\n        IStableSwap3Pool(stableSwapPool).add_liquidity(amounts, 1);\n    }\n\n    function getMostPremium() public view returns (address, uint256) {\n        uint256 balance0 = IStableSwap3Pool(stableSwapPool).balances(0).mul(\n            10**(decimalMultiples[0])\n        );\n        uint256 balance1 = IStableSwap3Pool(stableSwapPool).balances(1).mul(\n            10**(decimalMultiples[1])\n        );\n\n        if (tokens.length == 2) {\n            if (balance0 > balance1) {\n                return (tokens[1], 1);\n            }\n\n            return (tokens[0], 0);\n        }\n\n        uint256 balance2 = IStableSwap3Pool(stableSwapPool).balances(2).mul(\n            10**(decimalMultiples[2])\n        );\n\n        if (balance0 < balance1 && balance0 < balance2) {\n            return (tokens[0], 0);\n        }\n\n        if (balance1 < balance0 && balance1 < balance2) {\n            return (tokens[1], 1);\n        }\n\n        if (balance2 < balance0 && balance2 < balance1) {\n            return (tokens[2], 2);\n        }\n\n        return (tokens[0], 0);\n    }\n\n    function _harvest(uint256 _estimatedWETH, uint256 _estimatedYAXIS) internal override {\n        _claimReward();\n        uint256 _cvxBalance = IERC20(cvx).balanceOf(address(this));\n        if (_cvxBalance > 0) {\n            _swapTokens(cvx, crv, _cvxBalance, 1);\n        }\n\n        uint256 _extraRewardsLength = crvRewards.extraRewardsLength();\n        for (uint256 i = 0; i < _extraRewardsLength; i++) {\n            address _rewardToken = IConvexRewards(crvRewards.extraRewards(i)).rewardToken();\n            uint256 _extraRewardBalance = IERC20(_rewardToken).balanceOf(address(this));\n            if (_extraRewardBalance > 0) {\n                _swapTokens(_rewardToken, weth, _extraRewardBalance, 1);\n            }\n        }\n\n        uint256 _remainingWeth = _payHarvestFees(crv, _estimatedWETH, _estimatedYAXIS);\n        if (_remainingWeth > 0) {\n            (address _targetCoin, ) = getMostPremium();\n            _swapTokens(weth, _targetCoin, _remainingWeth, 1);\n            _addLiquidity();\n\n            if (balanceOfWant() > 0) {\n                _deposit();\n            }\n        }\n    }\n\n    function _withdrawAll() internal override {\n        convexVault.withdrawAll(pid);\n    }\n\n    function _withdraw(uint256 _amount) internal override {\n        convexVault.withdraw(pid, _amount);\n    }\n\n    function balanceOfPool() public view override returns (uint256) {\n        return IERC20(cvxDepositLP).balanceOf(address(this));\n    }\n}"
}