{
    "Function": "_buyPath",
    "File": "contracts/routers/StrategyRouter.sol",
    "Parent Contracts": [
        "contracts/helpers/StrategyTypes.sol",
        "contracts/interfaces/IStrategyRouter.sol"
    ],
    "High-Level Calls": [
        "IERC20"
    ],
    "Internal Calls": [
        "_delegateSwap"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function _buyPath(\n        TradeData memory data,\n        uint256 amount,\n        address token,\n        address strategy,\n        address from\n    ) internal {\n        if (amount > 0) {\n            for (uint256 i = 0; i < data.adapters.length; i++) {\n                uint256 _amount;\n                address _tokenIn;\n                address _tokenOut;\n                address _from;\n                address _to;\n                if (i == 0) {\n                    _tokenIn = weth;\n                    _amount = amount;\n                    _from = from;\n                } else {\n                    _tokenIn = data.path[i-1];\n                    _from = address(this);\n                    _amount = IERC20(_tokenIn).balanceOf(_from);\n                }\n                if (i == data.adapters.length-1) {\n                    _tokenOut = token;\n                    _to = strategy;\n                } else {\n                    _tokenOut = data.path[i];\n                    _to = address(this);\n                }\n                _delegateSwap(\n                    data.adapters[i],\n                    _amount,\n                    1,\n                    _tokenIn,\n                    _tokenOut,\n                    _from,\n                    _to\n                );\n            }\n        }\n    }"
}