{
    "Function": "swapTokensForExactAVAX",
    "File": "src/LBRouter.sol",
    "Parent Contracts": [
        "src/interfaces/ILBRouter.sol"
    ],
    "High-Level Calls": [
        "TokenHelper",
        "IWAVAX"
    ],
    "Internal Calls": [
        "revert LBRouter__InsufficientAmountOut(uint256,uint256)",
        "revert LBRouter__InvalidTokenPath(address)",
        "_swapTokensForExactTokens",
        "verifyInputs",
        "ensure",
        "_getAmountsIn",
        "_safeTransferAVAX",
        "_getPairs",
        "revert LBRouter__MaxAmountInExceeded(uint256,uint256)"
    ],
    "Library Calls": [
        "safeTransferFrom"
    ],
    "Low-Level Calls": [],
    "Code": "function swapTokensForExactAVAX(\n        uint256 _amountAVAXOut,\n        uint256 _amountInMax,\n        uint256[] memory _pairBinSteps,\n        IERC20[] memory _tokenPath,\n        address payable _to,\n        uint256 _deadline\n    ) external override ensure(_deadline) verifyInputs(_pairBinSteps, _tokenPath) returns (uint256[] memory amountsIn) {\n        if (_tokenPath[_pairBinSteps.length] != IERC20(wavax))\n            revert LBRouter__InvalidTokenPath(address(_tokenPath[_pairBinSteps.length]));\n\n        address[] memory _pairs = _getPairs(_pairBinSteps, _tokenPath);\n        amountsIn = _getAmountsIn(_pairBinSteps, _pairs, _tokenPath, _amountAVAXOut);\n\n        if (amountsIn[0] > _amountInMax) revert LBRouter__MaxAmountInExceeded(_amountInMax, amountsIn[0]);\n\n        _tokenPath[0].safeTransferFrom(msg.sender, _pairs[0], amountsIn[0]);\n\n        uint256 _amountOutReal = _swapTokensForExactTokens(_pairs, _pairBinSteps, _tokenPath, amountsIn, address(this));\n\n        if (_amountOutReal < _amountAVAXOut) revert LBRouter__InsufficientAmountOut(_amountAVAXOut, _amountOutReal);\n\n        wavax.withdraw(_amountOutReal);\n        _safeTransferAVAX(_to, _amountOutReal);\n    }"
}