{
    "Function": "_batchBuy",
    "File": "contracts/routers/LoopRouter.sol",
    "Parent Contracts": [
        "contracts/routers/StrategyRouter.sol",
        "contracts/helpers/StrategyTypes.sol",
        "contracts/interfaces/IStrategyRouter.sol"
    ],
    "High-Level Calls": [
        "SafeMath",
        "StrategyLibrary",
        "SafeERC20",
        "SafeMath",
        "IERC20",
        "IStrategy",
        "SafeERC20"
    ],
    "Internal Calls": [
        "_buyToken"
    ],
    "Library Calls": [
        "mul",
        "getExpectedTokenValue",
        "safeTransfer",
        "div",
        "safeTransferFrom"
    ],
    "Low-Level Calls": [],
    "Code": "function _batchBuy(\n        address strategy,\n        address from,\n        uint256 total,\n        int256[] memory estimates,\n        address[] memory strategyItems\n    ) internal {\n        for (uint256 i = 0; i < strategyItems.length; i++) {\n            address strategyItem = strategyItems[i];\n            _buyToken(\n                strategy,\n                from,\n                strategyItem,\n                estimates[i],\n                StrategyLibrary.getExpectedTokenValue(total, strategy, strategyItem)\n            );\n        }\n        int256 percentage = IStrategy(strategy).getPercentage(weth);\n        if (percentage > 0 && from != strategy) {\n            if (from == address(this)) {\n              // Send all WETH\n              IERC20(weth).safeTransfer(strategy, IERC20(weth).balanceOf(from));\n            } else {\n              // Calculate remaining WETH\n              // Since from is not address(this), we know this is a deposit, so estimated value not relevant\n              uint256 amount =\n                  total.mul(uint256(percentage))\n                       .div(DIVISOR);\n              IERC20(weth).safeTransferFrom(\n                  from,\n                  strategy,\n                  amount\n              );\n            }\n        }\n    }"
}