{
    "Function": "_batchSell",
    "File": "contracts/routers/LoopRouter.sol",
    "Parent Contracts": [
        "contracts/routers/StrategyRouter.sol",
        "contracts/helpers/StrategyTypes.sol",
        "contracts/interfaces/IStrategyRouter.sol"
    ],
    "High-Level Calls": [
        "IERC20",
        "StrategyLibrary",
        "IStrategy",
        "IStrategy"
    ],
    "Internal Calls": [
        "_sellPath",
        "_sellToken"
    ],
    "Library Calls": [
        "getExpectedTokenValue"
    ],
    "Low-Level Calls": [],
    "Code": "function _batchSell(\n        address strategy,\n        uint256 total,\n        int256[] memory estimates,\n        address[] memory strategyItems\n    ) internal {\n        for (uint256 i = 0; i < strategyItems.length; i++) {\n            // Convert funds into Ether\n            address strategyItem = strategyItems[i];\n            if (IStrategy(strategy).getPercentage(strategyItem) == 0) {\n                //Sell all tokens that have 0 percentage\n                _sellPath(\n                    IStrategy(strategy).getTradeData(strategyItem),\n                    IERC20(strategyItem).balanceOf(strategy),\n                    strategyItem,\n                    strategy\n                );\n            } else {\n                //Only sell if above rebalance threshold\n                _sellToken(\n                    strategy,\n                    strategyItem,\n                    estimates[i],\n                    StrategyLibrary.getExpectedTokenValue(total, strategy, strategyItem)\n                );\n            }\n        }\n    }"
}