{
    "Function": "_batchSwapExactIn",
    "File": "contracts/adapters/exchanges/BalancerAdapter.sol",
    "Parent Contracts": [
        "contracts/adapters/BaseAdapter.sol",
        "contracts/interfaces/IBaseAdapter.sol"
    ],
    "High-Level Calls": [
        "PoolInterface",
        "IERC20",
        "SafeERC20",
        "SafeERC20",
        "SafeERC20",
        "SafeERC20",
        "IERC20",
        "SafeERC20",
        "SafeMath"
    ],
    "Internal Calls": [
        "require(bool,string)"
    ],
    "Library Calls": [
        "safeApprove",
        "safeTransferFrom",
        "safeTransfer",
        "safeApprove",
        "add",
        "safeTransfer"
    ],
    "Low-Level Calls": [],
    "Code": "function _batchSwapExactIn(\n        Swap[] memory swaps,\n        IERC20 tokenIn,\n        IERC20 tokenOut,\n        address from,\n        address to,\n        uint totalAmountIn,\n        uint minTotalAmountOut\n    )\n        internal\n        returns (uint totalAmountOut)\n    {\n        if (from != address(this))\n            tokenIn.safeTransferFrom(from, address(this), totalAmountIn);\n\n        for (uint i = 0; i < swaps.length; i++) {\n            Swap memory _swap = swaps[i];\n            IERC20 SwapTokenIn = IERC20(_swap.tokenIn);\n            PoolInterface pool = PoolInterface(_swap.pool);\n\n            if (SwapTokenIn.allowance(address(this), _swap.pool) != 0) {\n                SwapTokenIn.safeApprove(_swap.pool, 0);\n            }\n            SwapTokenIn.safeApprove(_swap.pool, _swap.swapAmount);\n\n            (uint tokenAmountOut,) = pool.swapExactAmountIn(\n                                        _swap.tokenIn,\n                                        _swap.swapAmount,\n                                        _swap.tokenOut,\n                                        _swap.limitReturnAmount,\n                                        _swap.maxPrice\n                                    );\n            totalAmountOut = tokenAmountOut.add(totalAmountOut);\n        }\n\n        require(totalAmountOut >= minTotalAmountOut, \"ERR_LIMIT_OUT\");\n\n        if (to != address(this))\n            tokenOut.safeTransfer(to, totalAmountOut);\n        if (from != address(this))\n            tokenIn.safeTransfer(from, tokenIn.balanceOf(address(this))); //Return unused funds\n    }"
}