{
    "Function": "_swapTokensForExactTokens",
    "File": "src/LBRouter.sol",
    "Parent Contracts": [
        "src/interfaces/ILBRouter.sol"
    ],
    "High-Level Calls": [
        "IJoePair",
        "IJoePair",
        "ILBPair",
        "ILBPair"
    ],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function _swapTokensForExactTokens(\n        address[] memory _pairs,\n        uint256[] memory _pairBinSteps,\n        IERC20[] memory _tokenPath,\n        uint256[] memory _amountsIn,\n        address _to\n    ) private returns (uint256 amountOut) {\n        IERC20 _token;\n        uint256 _binStep;\n        address _recipient;\n        address _pair;\n\n        IERC20 _tokenNext = _tokenPath[0];\n\n        unchecked {\n            for (uint256 i; i < _pairs.length; ++i) {\n                _pair = _pairs[i];\n                _binStep = _pairBinSteps[i];\n\n                _token = _tokenNext;\n                _tokenNext = _tokenPath[i + 1];\n\n                _recipient = i + 1 == _pairs.length ? _to : _pairs[i + 1];\n\n                if (_binStep == 0) {\n                    amountOut = _amountsIn[i + 1];\n                    if (_token < _tokenNext) {\n                        IJoePair(_pair).swap(0, amountOut, _recipient, \"\");\n                    } else {\n                        IJoePair(_pair).swap(amountOut, 0, _recipient, \"\");\n                    }\n                } else {\n                    bool _swapForY = _tokenNext == ILBPair(_pair).tokenY();\n\n                    (uint256 _amountXOut, uint256 _amountYOut) = ILBPair(_pair).swap(_swapForY, _recipient);\n\n                    if (_swapForY) amountOut = _amountYOut;\n                    else amountOut = _amountXOut;\n                }\n            }\n        }\n    }"
}