creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/UniversalRouter.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.17;\n\n// Command implementations\nimport {Dispatcher} from \"./base/Dispatcher.sol\";\nimport {RewardsCollector} from \"./base/RewardsCollector.sol\";\nimport {RouterParameters, RouterImmutables} from \"./base/RouterImmutables.sol\";\nimport {Commands} from \"./libraries/Commands.sol\";\nimport {Constants} from \"./libraries/Constants.sol\";\nimport {IUniversalRouter} from \"./interfaces/IUniversalRouter.sol\";\nimport {StableSwapRouter} from \"./modules/pancakeswap/StableSwapRouter.sol\";\nimport {Pausable} from \"@openzeppelin/contracts/security/Pausable.sol\";\n\ncontract UniversalRouter is RouterImmutables, IUniversalRouter, Dispatcher, RewardsCollector, Pausable {\n    modifier checkDeadline(uint256 deadline) {\n        if (block.timestamp > deadline) revert TransactionDeadlinePassed();\n        _;\n    }\n\n    constructor(RouterParameters memory params)\n        RouterImmutables(params)\n        StableSwapRouter(params.stableFactory, params.stableInfo)\n    {}\n\n    /// @inheritdoc IUniversalRouter\n    function execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline)\n        external\n        payable\n        checkDeadline(deadline)\n    {\n        execute(commands, inputs);\n    }\n\n    /// @inheritdoc Dispatcher\n    function execute(bytes calldata commands, bytes[] calldata inputs)\n        public\n        payable\n        override\n        isNotLocked\n        whenNotPaused\n    {\n        bool success;\n        bytes memory output;\n        uint256 numCommands = commands.length;\n        if (inputs.length != numCommands) revert LengthMismatch();\n\n        // loop through all given commands, execute them and pass along outputs as defined\n        for (uint256 commandIndex = 0; commandIndex < numCommands;) {\n            bytes1 command = commands[commandIndex];\n\n            bytes calldata input = inputs[commandIndex];\n\n            (success, output) = dispatch(command, input);\n\n            if (!success && successRequired(command)) {\n                revert ExecutionFailed({commandIndex: commandIndex, message: output});\n            }\n\n            unchecked {\n                commandIndex++;\n            }\n        }\n\n        uint256 balance = address(this).balance;\n        if ((balance > 0) && (msg.sender != address(this))) sweep(Constants.ETH, msg.sender, balance);\n    }\n\n    function successRequired(bytes1 command) internal pure returns (bool) {\n        return command & Commands.FLAG_ALLOW_REVERT == 0;\n    }\n\n    /**\n     * @dev called by the owner to pause, triggers stopped state\n     */\n    function pause() external onlyOwner whenNotPaused {\n        _pause();\n    }\n\n    /**\n     * @dev called by the owner to unpause, returns to normal state\n     */\n    function unpause() external onlyOwner whenPaused {\n        _unpause();\n    }\n\n    /// @notice To receive ETH from WETH and NFT protocols\n    receive() external payable {}\n}\n"
      },
      "src/base/Dispatcher.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.17;\n\nimport {V2SwapRouter} from \"../modules/pancakeswap/v2/V2SwapRouter.sol\";\nimport {V3SwapRouter} from \"../modules/pancakeswap/v3/V3SwapRouter.sol\";\nimport {StableSwapRouter} from \"../modules/pancakeswap/StableSwapRouter.sol\";\nimport {Payments} from \"../modules/Payments.sol\";\nimport {RouterImmutables} from \"../base/RouterImmutables.sol\";\nimport {Callbacks} from \"../base/Callbacks.sol\";\nimport {BytesLib} from \"../libraries/BytesLib.sol\";\nimport {Commands} from \"../libraries/Commands.sol\";\nimport {LockAndMsgSender} from \"./LockAndMsgSender.sol\";\nimport {ERC721} from \"solmate/tokens/ERC721.sol\";\nimport {ERC1155} from \"solmate/tokens/ERC1155.sol\";\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\nimport {IAllowanceTransfer} from \"../permit2/src/interfaces/IAllowanceTransfer.sol\";\nimport {IPancakeNFTMarket} from \"../interfaces/IPancakeNFTMarket.sol\";\n\n/// @title Decodes and Executes Commands\n/// @notice Called by the UniversalRouter contract to efficiently decode and execute a singular command\nabstract contract Dispatcher is Payments, V2SwapRouter, V3SwapRouter, StableSwapRouter, Callbacks, LockAndMsgSender {\n    using BytesLib for bytes;\n\n    error InvalidCommandType(uint256 commandType);\n    error BuyPunkFailed();\n    error BuyPancakeNFTFailed();\n    error InvalidOwnerERC721();\n    error InvalidOwnerERC1155();\n    error BalanceTooLow();\n\n    /// @notice Decodes and executes the given command with the given inputs\n    /// @param commandType The command type to execute\n    /// @param inputs The inputs to execute the command with\n    /// @dev 2 masks are used to enable use of a nested-if statement in execution for efficiency reasons\n    /// @return success True on success of the command, false on failure\n    /// @return output The outputs or error messages, if any, from the command\n    function dispatch(bytes1 commandType, bytes calldata inputs) internal returns (bool success, bytes memory output) {\n        uint256 command = uint8(commandType & Commands.COMMAND_TYPE_MASK);\n\n        success = true;\n\n        if (command < Commands.FOURTH_IF_BOUNDARY) {\n            if (command < Commands.SECOND_IF_BOUNDARY) {\n                // 0x00 <= command < 0x08\n                if (command < Commands.FIRST_IF_BOUNDARY) {\n                    if (command == Commands.V3_SWAP_EXACT_IN) {\n                        // equivalent: abi.decode(inputs, (address, uint256, uint256, bytes, bool))\n                        address recipient;\n                        uint256 amountIn;\n                        uint256 amountOutMin;\n                        bool payerIsUser;\n                        assembly {\n                            recipient := calldataload(inputs.offset)\n                            amountIn := calldataload(add(inputs.offset, 0x20))\n                            amountOutMin := calldataload(add(inputs.offset, 0x40))\n                            // 0x60 offset is the path, decoded below\n                            payerIsUser := calldataload(add(inputs.offset, 0x80))\n                        }\n                        bytes calldata path = inputs.toBytes(3);\n                        address payer = payerIsUser ? lockedBy : address(this);\n                        v3SwapExactInput(map(recipient), amountIn, amountOutMin, path, payer);\n                    } else if (command == Commands.V3_SWAP_EXACT_OUT) {\n                        // equivalent: abi.decode(inputs, (address, uint256, uint256, bytes, bool))\n                        address recipient;\n                        uint256 amountOut;\n                        uint256 amountInMax;\n                        bool payerIsUser;\n                        assembly {\n                            recipient := calldataload(inputs.offset)\n                            amountOut := calldataload(add(inputs.offset, 0x20))\n                            amountInMax := calldataload(add(inputs.offset, 0x40))\n                            // 0x60 offset is the path, decoded below\n                            payerIsUser := calldataload(add(inputs.offset, 0x80))\n                        }\n                        bytes calldata path = inputs.toBytes(3);\n                        address payer = payerIsUser ? lockedBy : address(this);\n                        v3SwapExactOutput(map(recipient), amountOut, amountInMax, path, payer);\n                    } else if (command == Commands.PERMIT2_TRANSFER_FROM) {\n                        // equivalent: abi.decode(inputs, (address, address, uint160))\n                        address token;\n                        address recipient;\n                        uint160 amount;\n                        assembly {\n                            token := calldataload(inputs.offset)\n                            recipient := calldataload(add(inputs.offset, 0x20))\n                            amount := calldataload(add(inputs.offset, 0x40))\n                        }\n                        permit2TransferFrom(token, lockedBy, map(recipient), amount);\n                    } else if (command == Commands.PERMIT2_PERMIT_BATCH) {\n                        (IAllowanceTransfer.PermitBatch memory permitBatch,) =\n                            abi.decode(inputs, (IAllowanceTransfer.PermitBatch, bytes));\n                        bytes calldata data = inputs.toBytes(1);\n                        PERMIT2.permit(lockedBy, permitBatch, data);\n                    } else if (command == Commands.SWEEP) {\n                        // equivalent:  abi.decode(inputs, (address, address, uint256))\n                        address token;\n                        address recipient;\n                        uint160 amountMin;\n                        assembly {\n                            token := calldataload(inputs.offset)\n                            recipient := calldataload(add(inputs.offset, 0x20))\n                            amountMin := calldataload(add(inputs.offset, 0x40))\n                        }\n                        Payments.sweep(token, map(recipient), amountMin);\n                    } else if (command == Commands.TRANSFER) {\n                        // equivalent:  abi.decode(inputs, (address, address, uint256))\n                        address token;\n                        address recipient;\n                        uint256 value;\n                        assembly {\n                            token := calldataload(inputs.offset)\n                            recipient := calldataload(add(inputs.offset, 0x20))\n                            value := calldataload(add(inputs.offset, 0x40))\n                        }\n                        Payments.pay(token, map(recipient), value);\n                    } else if (command == Commands.PAY_PORTION) {\n                        // equivalent:  abi.decode(inputs, (address, address, uint256))\n                        address token;\n                        address recipient;\n                        uint256 bips;\n                        assembly {\n                            token := calldataload(inputs.offset)\n                            recipient := calldataload(add(inputs.offset, 0x20))\n                            bips := calldataload(add(inputs.offset, 0x40))\n                        }\n                        Payments.payPortion(token, map(recipient), bips);\n                    } else {\n                        // placeholder area for command 0x07\n                        revert InvalidCommandType(command);\n                    }\n                    // 0x08 <= command < 0x10\n                } else {\n                    if (command == Commands.V2_SWAP_EXACT_IN) {\n                        // equivalent: abi.decode(inputs, (address, uint256, uint256, bytes, bool))\n                        address recipient;\n                        uint256 amountIn;\n                        uint256 amountOutMin;\n                        bool payerIsUser;\n                        assembly {\n                            recipient := calldataload(inputs.offset)\n                            amountIn := calldataload(add(inputs.offset, 0x20))\n                            amountOutMin := calldataload(add(inputs.offset, 0x40))\n                            // 0x60 offset is the path, decoded below\n                            payerIsUser := calldataload(add(inputs.offset, 0x80))\n                        }\n                        address[] calldata path = inputs.toAddressArray(3);\n                        address payer = payerIsUser ? lockedBy : address(this);\n                        v2SwapExactInput(map(recipient), amountIn, amountOutMin, path, payer);\n                    } else if (command == Commands.V2_SWAP_EXACT_OUT) {\n                        // equivalent: abi.decode(inputs, (address, uint256, uint256, bytes, bool))\n                        address recipient;\n                        uint256 amountOut;\n                        uint256 amountInMax;\n                        bool payerIsUser;\n                        assembly {\n                            recipient := calldataload(inputs.offset)\n                            amountOut := calldataload(add(inputs.offset, 0x20))\n                            amountInMax := calldataload(add(inputs.offset, 0x40))\n                            // 0x60 offset is the path, decoded below\n                            payerIsUser := calldataload(add(inputs.offset, 0x80))\n                        }\n                        address[] calldata path = inputs.toAddressArray(3);\n                        address payer = payerIsUser ? lockedBy : address(this);\n                        v2SwapExactOutput(map(recipient), amountOut, amountInMax, path, payer);\n                    } else if (command == Commands.PERMIT2_PERMIT) {\n                        // equivalent: abi.decode(inputs, (IAllowanceTransfer.PermitSingle, bytes))\n                        IAllowanceTransfer.PermitSingle calldata permitSingle;\n                        assembly {\n                            permitSingle := inputs.offset\n                        }\n                        bytes calldata data = inputs.toBytes(6); // PermitSingle takes first 6 slots (0..5)\n                        PERMIT2.permit(lockedBy, permitSingle, data);\n                    } else if (command == Commands.WRAP_ETH) {\n                        // equivalent: abi.decode(inputs, (address, uint256))\n                        address recipient;\n                        uint256 amountMin;\n                        assembly {\n                            recipient := calldataload(inputs.offset)\n                            amountMin := calldataload(add(inputs.offset, 0x20))\n                        }\n                        Payments.wrapETH(map(recipient), amountMin);\n                    } else if (command == Commands.UNWRAP_WETH) {\n                        // equivalent: abi.decode(inputs, (address, uint256))\n                        address recipient;\n                        uint256 amountMin;\n                        assembly {\n                            recipient := calldataload(inputs.offset)\n                            amountMin := calldataload(add(inputs.offset, 0x20))\n                        }\n                        Payments.unwrapWETH9(map(recipient), amountMin);\n                    } else if (command == Commands.PERMIT2_TRANSFER_FROM_BATCH) {\n                        (IAllowanceTransfer.AllowanceTransferDetails[] memory batchDetails) =\n                            abi.decode(inputs, (IAllowanceTransfer.AllowanceTransferDetails[]));\n                        permit2TransferFrom(batchDetails, lockedBy);\n                    } else if (command == Commands.BALANCE_CHECK_ERC20) {\n                        // equivalent: abi.decode(inputs, (address, address, uint256))\n                        address owner;\n                        address token;\n                        uint256 minBalance;\n                        assembly {\n                            owner := calldataload(inputs.offset)\n                            token := calldataload(add(inputs.offset, 0x20))\n                            minBalance := calldataload(add(inputs.offset, 0x40))\n                        }\n                        success = (ERC20(token).balanceOf(owner) >= minBalance);\n                        if (!success) output = abi.encodePacked(BalanceTooLow.selector);\n                    } else {\n                        // placeholder area for command 0x0f\n                        revert InvalidCommandType(command);\n                    }\n                }\n                // 0x10 <= command < 0x20\n            } else {\n                // 0x10 <= command < 0x18\n                if (command < Commands.THIRD_IF_BOUNDARY) {\n                    if (command == Commands.OWNER_CHECK_721) {\n                        // equivalent: abi.decode(inputs, (address, address, uint256))\n                        address owner;\n                        address token;\n                        uint256 id;\n                        assembly {\n                            owner := calldataload(inputs.offset)\n                            token := calldataload(add(inputs.offset, 0x20))\n                            id := calldataload(add(inputs.offset, 0x40))\n                        }\n                        success = (ERC721(token).ownerOf(id) == owner);\n                        if (!success) output = abi.encodePacked(InvalidOwnerERC721.selector);\n                    } else if (command == Commands.OWNER_CHECK_1155) {\n                        // equivalent: abi.decode(inputs, (address, address, uint256, uint256))\n                        address owner;\n                        address token;\n                        uint256 id;\n                        uint256 minBalance;\n                        assembly {\n                            owner := calldataload(inputs.offset)\n                            token := calldataload(add(inputs.offset, 0x20))\n                            id := calldataload(add(inputs.offset, 0x40))\n                            minBalance := calldataload(add(inputs.offset, 0x60))\n                        }\n                        success = (ERC1155(token).balanceOf(owner, id) >= minBalance);\n                        if (!success) output = abi.encodePacked(InvalidOwnerERC1155.selector);\n                    } else if (command == Commands.SWEEP_ERC721) {\n                        // equivalent: abi.decode(inputs, (address, address, uint256))\n                        address token;\n                        address recipient;\n                        uint256 id;\n                        assembly {\n                            token := calldataload(inputs.offset)\n                            recipient := calldataload(add(inputs.offset, 0x20))\n                            id := calldataload(add(inputs.offset, 0x40))\n                        }\n                        Payments.sweepERC721(token, map(recipient), id);\n                    } else if (command == Commands.SWEEP_ERC1155) {\n                        // equivalent: abi.decode(inputs, (address, address, uint256, uint256))\n                        address token;\n                        address recipient;\n                        uint256 id;\n                        uint256 amount;\n                        assembly {\n                            token := calldataload(inputs.offset)\n                            recipient := calldataload(add(inputs.offset, 0x20))\n                            id := calldataload(add(inputs.offset, 0x40))\n                            amount := calldataload(add(inputs.offset, 0x60))\n                        }\n                        Payments.sweepERC1155(token, map(recipient), id, amount);\n                    } else {\n                        // placeholder area for command for 0x14-0x17\n                        revert InvalidCommandType(command);\n                    }\n                    // 0x18 <= command < 0x20\n                } else {\n                    if (command == Commands.SEAPORT_V1_5) {\n                        /// @dev Seaport 1.4 and 1.5 allow for orders to be created by contracts.\n                        ///     These orders pass control to the contract offerers during fufillment,\n                        ///         allowing them to perform any number of destructive actions as a holder of the NFT.\n                        ///     Integrators should be aware that in some scenarios: e.g. purchasing an NFT that allows the holder\n                        ///         to claim another NFT, the contract offerer can \"steal\" the claim during order fufillment.\n                        ///     For some such purchases, an OWNER_CHECK command can be prepended to ensure that all tokens have the desired owner at the end of the transaction.\n                        ///     This is also outlined in the Seaport documentation: https://github.com/ProjectOpenSea/seaport/blob/main/docs/SeaportDocumentation.md\n                        (uint256 value, bytes calldata data) = getValueAndData(inputs);\n                        (success, output) = SEAPORT_V1_5.call{value: value}(data);\n                    } else if (command == Commands.SEAPORT_V1_4) {\n                        /// @dev Seaport 1.4 and 1.5 allow for orders to be created by contracts.\n                        ///     These orders pass control to the contract offerers during fufillment,\n                        ///         allowing them to perform any number of destructive actions as a holder of the NFT.\n                        ///     Integrators should be aware that in some scenarios: e.g. purchasing an NFT that allows the holder\n                        ///         to claim another NFT, the contract offerer can \"steal\" the claim during order fufillment.\n                        ///     For some such purchases, an OWNER_CHECK command can be prepended to ensure that all tokens have the desired owner at the end of the transaction.\n                        ///     This is also outlined in the Seaport documentation: https://github.com/ProjectOpenSea/seaport/blob/main/docs/SeaportDocumentation.md\n                        (uint256 value, bytes calldata data) = getValueAndData(inputs);\n                        (success, output) = SEAPORT_V1_4.call{value: value}(data);\n                    } else if (command == Commands.LOOKS_RARE_V2) {\n                        // equivalent: abi.decode(inputs, (uint256, bytes))\n                        uint256 value;\n                        assembly {\n                            value := calldataload(inputs.offset)\n                        }\n                        bytes calldata data = inputs.toBytes(1);\n                        (success, output) = LOOKS_RARE_V2.call{value: value}(data);\n                    } else if (command == Commands.X2Y2_721) {\n                        (success, output) = callAndTransfer721(inputs, X2Y2);\n                    } else if (command == Commands.X2Y2_1155) {\n                        (success, output) = callAndTransfer1155(inputs, X2Y2);\n                    } else {\n                        // placeholder for command 0x1d-0x1f\n                        revert InvalidCommandType(command);\n                    }\n                }\n            }\n            // 0x20 <= command\n        } else {\n            if (command == Commands.EXECUTE_SUB_PLAN) {\n                bytes calldata _commands = inputs.toBytes(0);\n                bytes[] calldata _inputs = inputs.toBytesArray(1);\n                (success, output) =\n                    (address(this)).call(abi.encodeWithSelector(Dispatcher.execute.selector, _commands, _inputs));\n            } else if (command == Commands.APPROVE_ERC20) {\n                ERC20 token;\n                RouterImmutables.Spenders spender;\n                assembly {\n                    token := calldataload(inputs.offset)\n                    spender := calldataload(add(inputs.offset, 0x20))\n                }\n                Payments.approveERC20(token, spender);\n            } else if (command == Commands.STABLE_SWAP_EXACT_IN) {\n                // equivalent: abi.decode(inputs, (address, uint256, uint256, bytes, bytes, bool))\n                address recipient;\n                uint256 amountIn;\n                uint256 amountOutMin;\n                bool payerIsUser;\n                assembly {\n                    recipient := calldataload(inputs.offset)\n                    amountIn := calldataload(add(inputs.offset, 0x20))\n                    amountOutMin := calldataload(add(inputs.offset, 0x40))\n                    // 0x60 offset is the path and 0x80 is the flag, decoded below\n                    payerIsUser := calldataload(add(inputs.offset, 0xa0))\n                }\n                address[] calldata path = inputs.toAddressArray(3);\n                uint256[] calldata flag = inputs.toUintArray(4);\n                address payer = payerIsUser ? lockedBy : address(this);\n                stableSwapExactInput(map(recipient), amountIn, amountOutMin, path, flag, payer);\n            } else if (command == Commands.STABLE_SWAP_EXACT_OUT) {\n                // equivalent: abi.decode(inputs, (address, uint256, uint256, bytes, bytes, bool))\n                address recipient;\n                uint256 amountOut;\n                uint256 amountInMax;\n                bool payerIsUser;\n                assembly {\n                    recipient := calldataload(inputs.offset)\n                    amountOut := calldataload(add(inputs.offset, 0x20))\n                    amountInMax := calldataload(add(inputs.offset, 0x40))\n                    // 0x60 offset is the path and 0x80 is the flag, decoded below\n                    payerIsUser := calldataload(add(inputs.offset, 0xa0))\n                }\n                address[] calldata path = inputs.toAddressArray(3);\n                uint256[] calldata flag = inputs.toUintArray(4);\n                address payer = payerIsUser ? lockedBy : address(this);\n                stableSwapExactOutput(map(recipient), amountOut, amountInMax, path, flag, payer);\n            } else if (command == Commands.PANCAKE_NFT_BNB) {\n                // equivalent: abi.decode(inputs, (address, uint256, uint256))\n                address collection;\n                uint256 tokenId;\n                uint256 value;\n                assembly {\n                    collection := calldataload(inputs.offset)\n                    tokenId := calldataload(add(inputs.offset, 0x20))\n                    value := calldataload(add(inputs.offset, 0x40))\n                }\n                (success, output) = PANCAKESWAP_NFT_MARKET.call{value: value}(\n                    abi.encodeWithSelector(IPancakeNFTMarket.buyTokenUsingBNB.selector, collection, tokenId)\n                );\n                if (!success) output = abi.encodePacked(BuyPancakeNFTFailed.selector);\n            } else if (command == Commands.PANCAKE_NFT_WBNB) {\n                // equivalent: abi.decode(inputs, (address, uint256, uint256))\n                address collection;\n                uint256 tokenId;\n                uint256 price;\n                assembly {\n                    collection := calldataload(inputs.offset)\n                    tokenId := calldataload(add(inputs.offset, 0x20))\n                    price := calldataload(add(inputs.offset, 0x40))\n                }\n                IPancakeNFTMarket(PANCAKESWAP_NFT_MARKET).buyTokenUsingWBNB(collection, tokenId, price);\n            } else {\n                // placeholder area for commands 0x26-0x3f\n                revert InvalidCommandType(command);\n            }\n        }\n    }\n\n    /// @notice Executes encoded commands along with provided inputs.\n    /// @param commands A set of concatenated commands, each 1 byte in length\n    /// @param inputs An array of byte strings containing abi encoded inputs for each command\n    function execute(bytes calldata commands, bytes[] calldata inputs) external payable virtual;\n\n    /// @notice Performs a call to purchase an ERC721, then transfers the ERC721 to a specified recipient\n    /// @param inputs The inputs for the protocol and ERC721 transfer, encoded\n    /// @param protocol The protocol to pass the calldata to\n    /// @return success True on success of the command, false on failure\n    /// @return output The outputs or error messages, if any, from the command\n    function callAndTransfer721(bytes calldata inputs, address protocol)\n        internal\n        returns (bool success, bytes memory output)\n    {\n        // equivalent: abi.decode(inputs, (uint256, bytes, address, address, uint256))\n        (uint256 value, bytes calldata data) = getValueAndData(inputs);\n        address recipient;\n        address token;\n        uint256 id;\n        assembly {\n            // 0x00 and 0x20 offsets are value and data, above\n            recipient := calldataload(add(inputs.offset, 0x40))\n            token := calldataload(add(inputs.offset, 0x60))\n            id := calldataload(add(inputs.offset, 0x80))\n        }\n        (success, output) = protocol.call{value: value}(data);\n        if (success) ERC721(token).safeTransferFrom(address(this), map(recipient), id);\n    }\n\n    /// @notice Performs a call to purchase an ERC1155, then transfers the ERC1155 to a specified recipient\n    /// @param inputs The inputs for the protocol and ERC1155 transfer, encoded\n    /// @param protocol The protocol to pass the calldata to\n    /// @return success True on success of the command, false on failure\n    /// @return output The outputs or error messages, if any, from the command\n    function callAndTransfer1155(bytes calldata inputs, address protocol)\n        internal\n        returns (bool success, bytes memory output)\n    {\n        // equivalent: abi.decode(inputs, (uint256, bytes, address, address, uint256, uint256))\n        (uint256 value, bytes calldata data) = getValueAndData(inputs);\n        address recipient;\n        address token;\n        uint256 id;\n        uint256 amount;\n        assembly {\n            // 0x00 and 0x20 offsets are value and data, above\n            recipient := calldataload(add(inputs.offset, 0x40))\n            token := calldataload(add(inputs.offset, 0x60))\n            id := calldataload(add(inputs.offset, 0x80))\n            amount := calldataload(add(inputs.offset, 0xa0))\n        }\n        (success, output) = protocol.call{value: value}(data);\n        if (success) ERC1155(token).safeTransferFrom(address(this), map(recipient), id, amount, new bytes(0));\n    }\n\n    /// @notice Helper function to extract `value` and `data` parameters from input bytes string\n    /// @dev The helper assumes that `value` is the first parameter, and `data` is the second\n    /// @param inputs The bytes string beginning with value and data parameters\n    /// @return value The 256 bit integer value\n    /// @return data The data bytes string\n    function getValueAndData(bytes calldata inputs) internal pure returns (uint256 value, bytes calldata data) {\n        assembly {\n            value := calldataload(inputs.offset)\n        }\n        data = inputs.toBytes(1);\n    }\n}\n"
      },
      "src/base/RewardsCollector.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.15;\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\nimport {SafeTransferLib} from \"solmate/utils/SafeTransferLib.sol\";\nimport {RouterImmutables} from \"./RouterImmutables.sol\";\nimport {IRewardsCollector} from \"../interfaces/IRewardsCollector.sol\";\n\nabstract contract RewardsCollector is IRewardsCollector, RouterImmutables {\n    using SafeTransferLib for ERC20;\n\n    event RewardsSent(uint256 amount);\n\n    error UnableToClaim();\n\n    /// @inheritdoc IRewardsCollector\n    function collectRewards(bytes calldata looksRareClaim) external {\n        (bool success,) = LOOKS_RARE_REWARDS_DISTRIBUTOR.call(looksRareClaim);\n        if (!success) revert UnableToClaim();\n\n        uint256 balance = LOOKS_RARE_TOKEN.balanceOf(address(this));\n        LOOKS_RARE_TOKEN.safeTransfer(ROUTER_REWARDS_DISTRIBUTOR, balance);\n        emit RewardsSent(balance);\n    }\n}\n"
      },
      "src/base/RouterImmutables.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.17;\n\nimport {IAllowanceTransfer} from \"../permit2/src/interfaces/IAllowanceTransfer.sol\";\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\nimport {IWETH9} from \"../interfaces/IWETH9.sol\";\n\nstruct RouterParameters {\n    address permit2;\n    address weth9;\n    address seaportV1_5;\n    address seaportV1_4;\n    address openseaConduit;\n    address x2y2;\n    address looksRareV2;\n    address routerRewardsDistributor;\n    address looksRareRewardsDistributor;\n    address looksRareToken;\n    address v2Factory;\n    address v3Factory;\n    address v3Deployer;\n    bytes32 v2InitCodeHash;\n    bytes32 v3InitCodeHash;\n    address stableFactory;\n    address stableInfo;\n    address pancakeNFTMarket;\n}\n\n/// @title Router Immutable Storage contract\n/// @notice Used along with the `RouterParameters` struct for ease of cross-chain deployment\ncontract RouterImmutables {\n    /// @dev WETH9 address\n    IWETH9 internal immutable WETH9;\n\n    /// @dev Permit2 address\n    IAllowanceTransfer internal immutable PERMIT2;\n\n    /// @dev Seaport 1.5 address\n    address internal immutable SEAPORT_V1_5;\n\n    /// @dev Seaport 1.4 address\n    address internal immutable SEAPORT_V1_4;\n\n    /// @dev The address of OpenSea's conduit used in both Seaport 1.4 and Seaport 1.5\n    address internal immutable OPENSEA_CONDUIT;\n\n    /// @dev The address of X2Y2\n    address internal immutable X2Y2;\n\n    /// @dev The address of LooksRareV2\n    address internal immutable LOOKS_RARE_V2;\n\n    /// @dev The address of LooksRare token\n    ERC20 internal immutable LOOKS_RARE_TOKEN;\n\n    /// @dev The address of LooksRare rewards distributor\n    address internal immutable LOOKS_RARE_REWARDS_DISTRIBUTOR;\n\n    /// @dev The address of router rewards distributor\n    address internal immutable ROUTER_REWARDS_DISTRIBUTOR;\n\n    /// @dev The address of PancakeSwapV2Factory\n    address internal immutable PANCAKESWAP_V2_FACTORY;\n\n    /// @dev The PancakeSwapV2Pair initcodehash\n    bytes32 internal immutable PANCAKESWAP_V2_PAIR_INIT_CODE_HASH;\n\n    /// @dev The address of PancakeSwapV3Factory\n    address internal immutable PANCAKESWAP_V3_FACTORY;\n\n    /// @dev The PancakeSwapV3Pool initcodehash\n    bytes32 internal immutable PANCAKESWAP_V3_POOL_INIT_CODE_HASH;\n\n    /// @dev The address of PancakeSwap V3 Deployer\n    address internal immutable PANCAKESWAP_V3_DEPLOYER;\n\n    /// @dev The address of PancakeSwap NFT Market\n    address internal immutable PANCAKESWAP_NFT_MARKET;\n\n    enum Spenders {\n        OSConduit\n    }\n\n    constructor(RouterParameters memory params) {\n        PERMIT2 = IAllowanceTransfer(params.permit2);\n        WETH9 = IWETH9(params.weth9);\n        SEAPORT_V1_5 = params.seaportV1_5;\n        SEAPORT_V1_4 = params.seaportV1_4;\n        OPENSEA_CONDUIT = params.openseaConduit;\n        X2Y2 = params.x2y2;\n        LOOKS_RARE_V2 = params.looksRareV2;\n        LOOKS_RARE_TOKEN = ERC20(params.looksRareToken);\n        LOOKS_RARE_REWARDS_DISTRIBUTOR = params.looksRareRewardsDistributor;\n        ROUTER_REWARDS_DISTRIBUTOR = params.routerRewardsDistributor;\n        PANCAKESWAP_V2_FACTORY = params.v2Factory;\n        PANCAKESWAP_V2_PAIR_INIT_CODE_HASH = params.v2InitCodeHash;\n        PANCAKESWAP_V3_FACTORY = params.v3Factory;\n        PANCAKESWAP_V3_POOL_INIT_CODE_HASH = params.v3InitCodeHash;\n        PANCAKESWAP_V3_DEPLOYER = params.v3Deployer;\n        PANCAKESWAP_NFT_MARKET = params.pancakeNFTMarket;\n    }\n}\n"
      },
      "src/libraries/Commands.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.17;\n\n/// @title Commands\n/// @notice Command Flags used to decode commands\nlibrary Commands {\n    // Masks to extract certain bits of commands\n    bytes1 internal constant FLAG_ALLOW_REVERT = 0x80;\n    bytes1 internal constant COMMAND_TYPE_MASK = 0x3f;\n\n    // Command Types. Maximum supported command at this moment is 0x3f.\n\n    // Command Types where value<0x08, executed in the first nested-if block\n    uint256 constant V3_SWAP_EXACT_IN = 0x00;\n    uint256 constant V3_SWAP_EXACT_OUT = 0x01;\n    uint256 constant PERMIT2_TRANSFER_FROM = 0x02;\n    uint256 constant PERMIT2_PERMIT_BATCH = 0x03;\n    uint256 constant SWEEP = 0x04;\n    uint256 constant TRANSFER = 0x05;\n    uint256 constant PAY_PORTION = 0x06;\n    // COMMAND_PLACEHOLDER = 0x07;\n\n    // The commands are executed in nested if blocks to minimise gas consumption\n    // The following constant defines one of the boundaries where the if blocks split commands\n    uint256 constant FIRST_IF_BOUNDARY = 0x08;\n\n    // Command Types where 0x08<=value<0x10, executed in the second nested-if block\n    uint256 constant V2_SWAP_EXACT_IN = 0x08;\n    uint256 constant V2_SWAP_EXACT_OUT = 0x09;\n    uint256 constant PERMIT2_PERMIT = 0x0a;\n    uint256 constant WRAP_ETH = 0x0b;\n    uint256 constant UNWRAP_WETH = 0x0c;\n    uint256 constant PERMIT2_TRANSFER_FROM_BATCH = 0x0d;\n    uint256 constant BALANCE_CHECK_ERC20 = 0x0e;\n    // COMMAND_PLACEHOLDER = 0x0f;\n\n    // The commands are executed in nested if blocks to minimise gas consumption\n    // The following constant defines one of the boundaries where the if blocks split commands\n    uint256 constant SECOND_IF_BOUNDARY = 0x10;\n\n    // Command Types where 0x10<=value<0x18, executed in the third nested-if block\n    uint256 constant OWNER_CHECK_721 = 0x10;\n    uint256 constant OWNER_CHECK_1155 = 0x11;\n    uint256 constant SWEEP_ERC721 = 0x12;\n    uint256 constant SWEEP_ERC1155 = 0x13;\n    // COMMAND_PLACEHOLDER for 0x14-0x17 (all unused)\n\n    // The commands are executed in nested if blocks to minimise gas consumption\n    // The following constant defines one of the boundaries where the if blocks split commands\n    uint256 constant THIRD_IF_BOUNDARY = 0x18;\n\n    // Command Types where 0x18<=value<=0x1f, executed in the final nested-if block\n    uint256 constant SEAPORT_V1_5 = 0x18;\n    uint256 constant SEAPORT_V1_4 = 0x19;\n    uint256 constant LOOKS_RARE_V2 = 0x1a;\n    uint256 constant X2Y2_721 = 0x1b;\n    uint256 constant X2Y2_1155 = 0x1c;\n    // COMMAND_PLACEHOLDER for 0x1d-0x1f (all unused)\n\n    // The commands are executed in nested if blocks to minimise gas consumption\n    // The following constant defines one of the boundaries where the if blocks split commands\n    uint256 constant FOURTH_IF_BOUNDARY = 0x20;\n\n    // Command Types where 0x20<=value\n    uint256 constant EXECUTE_SUB_PLAN = 0x20;\n    uint256 constant APPROVE_ERC20 = 0x21;\n    uint256 constant STABLE_SWAP_EXACT_IN = 0x22;\n    uint256 constant STABLE_SWAP_EXACT_OUT = 0x23;\n    uint256 constant PANCAKE_NFT_BNB = 0x24;\n    uint256 constant PANCAKE_NFT_WBNB = 0x25;\n    // COMMAND_PLACEHOLDER for 0x26-0x3f (all unused)\n}\n"
      },
      "src/libraries/Constants.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.17;\n\nimport {IWETH9} from \"../interfaces/IWETH9.sol\";\n\n/// @title Constant state\n/// @notice Constant state used by the Universal Router\nlibrary Constants {\n    /// @dev Used for identifying cases when this contract's balance of a token is to be used as an input\n    /// This value is equivalent to 1<<255, i.e. a singular 1 in the most significant bit.\n    uint256 internal constant CONTRACT_BALANCE = 0x8000000000000000000000000000000000000000000000000000000000000000;\n\n    /// @dev Used for identifying cases when a v2 pair has already received input tokens\n    uint256 internal constant ALREADY_PAID = 0;\n\n    /// @dev Used as a flag for identifying the transfer of ETH instead of a token\n    address internal constant ETH = address(0);\n\n    /// @dev Used as a flag for identifying that msg.sender should be used, saves gas by sending more 0 bytes\n    address internal constant MSG_SENDER = address(1);\n\n    /// @dev Used as a flag for identifying address(this) should be used, saves gas by sending more 0 bytes\n    address internal constant ADDRESS_THIS = address(2);\n\n    /// @dev The length of the bytes encoded address\n    uint256 internal constant ADDR_SIZE = 20;\n\n    /// @dev The length of the bytes encoded fee\n    uint256 internal constant V3_FEE_SIZE = 3;\n\n    /// @dev The offset of a single token address (20) and pool fee (3)\n    uint256 internal constant NEXT_V3_POOL_OFFSET = ADDR_SIZE + V3_FEE_SIZE;\n\n    /// @dev The offset of an encoded pool key\n    /// Token (20) + Fee (3) + Token (20) = 43\n    uint256 internal constant V3_POP_OFFSET = NEXT_V3_POOL_OFFSET + ADDR_SIZE;\n\n    /// @dev The minimum length of an encoding that contains 2 or more pools\n    uint256 internal constant MULTIPLE_V3_POOLS_MIN_LENGTH = V3_POP_OFFSET + NEXT_V3_POOL_OFFSET;\n}\n"
      },
      "src/interfaces/IUniversalRouter.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.17;\n\nimport {IERC721Receiver} from \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport {IERC1155Receiver} from \"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol\";\nimport {IRewardsCollector} from \"./IRewardsCollector.sol\";\n\ninterface IUniversalRouter is IRewardsCollector, IERC721Receiver, IERC1155Receiver {\n    /// @notice Thrown when a required command has failed\n    error ExecutionFailed(uint256 commandIndex, bytes message);\n\n    /// @notice Thrown when attempting to send ETH directly to the contract\n    error ETHNotAccepted();\n\n    /// @notice Thrown when executing commands with an expired deadline\n    error TransactionDeadlinePassed();\n\n    /// @notice Thrown when attempting to execute commands and an incorrect number of inputs are provided\n    error LengthMismatch();\n\n    /// @notice Executes encoded commands along with provided inputs. Reverts if deadline has expired.\n    /// @param commands A set of concatenated commands, each 1 byte in length\n    /// @param inputs An array of byte strings containing abi encoded inputs for each command\n    /// @param deadline The deadline by which the transaction must be executed\n    function execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline) external payable;\n}\n"
      },
      "src/modules/pancakeswap/StableSwapRouter.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.17;\n\nimport {RouterImmutables} from \"../../base/RouterImmutables.sol\";\nimport {Payments} from \"../Payments.sol\";\nimport {Permit2Payments} from \"../Permit2Payments.sol\";\nimport {Constants} from \"../../libraries/Constants.sol\";\nimport {UniversalRouterHelper} from \"../../libraries/UniversalRouterHelper.sol\";\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\nimport {SafeTransferLib} from \"solmate/utils/SafeTransferLib.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {IStableSwap} from \"../../interfaces/IStableSwap.sol\";\n\n/// @title Router for PancakeSwap Stable Trades\nabstract contract StableSwapRouter is RouterImmutables, Permit2Payments, Ownable {\n    using SafeTransferLib for ERC20;\n    using UniversalRouterHelper for address;\n\n    error StableTooLittleReceived();\n    error StableTooMuchRequested();\n    error StableInvalidPath();\n\n    address public stableSwapFactory;\n    address public stableSwapInfo;\n\n    event SetStableSwap(address indexed factory, address indexed info);\n\n    constructor(address _stableSwapFactory, address _stableSwapInfo) {\n        stableSwapFactory = _stableSwapFactory;\n        stableSwapInfo = _stableSwapInfo;\n    }\n\n    /**\n     * @notice Set Pancake Stable Swap Factory and Info\n     * @dev Only callable by contract owner\n     */\n    function setStableSwap(address _factory, address _info) external onlyOwner {\n        require(_factory != address(0) && _info != address(0));\n\n        stableSwapFactory = _factory;\n        stableSwapInfo = _info;\n\n        emit SetStableSwap(stableSwapFactory, stableSwapInfo);\n    }\n\n    function _stableSwap(address[] calldata path, uint256[] calldata flag) private {\n        unchecked {\n            if (path.length - 1 != flag.length) revert StableInvalidPath();\n\n            for (uint256 i; i < flag.length; i++) {\n                (address input, address output) = (path[i], path[i + 1]);\n                (uint256 k, uint256 j, address swapContract) = stableSwapFactory.getStableInfo(input, output, flag[i]);\n                uint256 amountIn = ERC20(input).balanceOf(address(this));\n                ERC20(input).safeApprove(swapContract, amountIn);\n                IStableSwap(swapContract).exchange(k, j, amountIn, 0);\n            }\n        }\n    }\n\n    /// @notice Performs a PancakeSwap stable exact input swap\n    /// @param recipient The recipient of the output tokens\n    /// @param amountIn The amount of input tokens for the trade\n    /// @param amountOutMinimum The minimum desired amount of output tokens\n    /// @param path The path of the trade as an array of token addresses\n    /// @param flag token amount in a stable swap pool. 2 for 2pool, 3 for 3pool\n    /// @param payer The address that will be paying the input\n    function stableSwapExactInput(\n        address recipient,\n        uint256 amountIn,\n        uint256 amountOutMinimum,\n        address[] calldata path,\n        uint256[] calldata flag,\n        address payer\n    ) internal {\n        if (amountIn != Constants.ALREADY_PAID && amountIn != Constants.CONTRACT_BALANCE) {\n            payOrPermit2Transfer(path[0], payer, address(this), amountIn);\n        }\n\n        ERC20 tokenOut = ERC20(path[path.length - 1]);\n\n        _stableSwap(path, flag);\n\n        uint256 amountOut = tokenOut.balanceOf(address(this));\n        if (amountOut < amountOutMinimum) revert StableTooLittleReceived();\n\n        if (recipient != address(this)) pay(address(tokenOut), recipient, amountOut);\n    }\n\n    /// @notice Performs a PancakeSwap stable exact output swap\n    /// @param recipient The recipient of the output tokens\n    /// @param amountOut The amount of output tokens to receive for the trade\n    /// @param amountInMaximum The maximum desired amount of input tokens\n    /// @param path The path of the trade as an array of token addresses\n    /// @param flag token amount in a stable swap pool. 2 for 2pool, 3 for 3pool\n    /// @param payer The address that will be paying the input\n    function stableSwapExactOutput(\n        address recipient,\n        uint256 amountOut,\n        uint256 amountInMaximum,\n        address[] calldata path,\n        uint256[] calldata flag,\n        address payer\n    ) internal {\n        uint256 amountIn = stableSwapFactory.getStableAmountsIn(stableSwapInfo, path, flag, amountOut)[0];\n\n        if (amountIn > amountInMaximum) revert StableTooMuchRequested();\n\n        payOrPermit2Transfer(path[0], payer, address(this), amountIn);\n\n        _stableSwap(path, flag);\n\n        if (recipient != address(this)) pay(path[path.length - 1], recipient, amountOut);\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/security/Pausable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n    /**\n     * @dev Emitted when the pause is triggered by `account`.\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by `account`.\n     */\n    event Unpaused(address account);\n\n    bool private _paused;\n\n    /**\n     * @dev Initializes the contract in unpaused state.\n     */\n    constructor() {\n        _paused = false;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    modifier whenNotPaused() {\n        _requireNotPaused();\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    modifier whenPaused() {\n        _requirePaused();\n        _;\n    }\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view virtual returns (bool) {\n        return _paused;\n    }\n\n    /**\n     * @dev Throws if the contract is paused.\n     */\n    function _requireNotPaused() internal view virtual {\n        require(!paused(), \"Pausable: paused\");\n    }\n\n    /**\n     * @dev Throws if the contract is not paused.\n     */\n    function _requirePaused() internal view virtual {\n        require(paused(), \"Pausable: not paused\");\n    }\n\n    /**\n     * @dev Triggers stopped state.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    function _pause() internal virtual whenNotPaused {\n        _paused = true;\n        emit Paused(_msgSender());\n    }\n\n    /**\n     * @dev Returns to normal state.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    function _unpause() internal virtual whenPaused {\n        _paused = false;\n        emit Unpaused(_msgSender());\n    }\n}\n"
      },
      "src/modules/pancakeswap/v2/V2SwapRouter.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.17;\n\nimport {IUniswapV2Pair} from \"./interfaces/IUniswapV2Pair.sol\";\nimport {RouterImmutables} from \"../../../base/RouterImmutables.sol\";\nimport {Payments} from \"../../Payments.sol\";\nimport {Permit2Payments} from \"../../Permit2Payments.sol\";\nimport {Constants} from \"../../../libraries/Constants.sol\";\nimport {UniversalRouterHelper} from \"../../../libraries/UniversalRouterHelper.sol\";\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\n\n/// @title Router for PancakeSwap v2 Trades\nabstract contract V2SwapRouter is RouterImmutables, Permit2Payments {\n    error V2TooLittleReceived();\n    error V2TooMuchRequested();\n    error V2InvalidPath();\n\n    function _v2Swap(address[] calldata path, address recipient, address pair) private {\n        unchecked {\n            if (path.length < 2) revert V2InvalidPath();\n\n            // cached to save on duplicate operations\n            (address token0,) = UniversalRouterHelper.sortTokens(path[0], path[1]);\n            uint256 finalPairIndex = path.length - 1;\n            uint256 penultimatePairIndex = finalPairIndex - 1;\n            for (uint256 i; i < finalPairIndex; i++) {\n                (address input, address output) = (path[i], path[i + 1]);\n                (uint256 reserve0, uint256 reserve1,) = IUniswapV2Pair(pair).getReserves();\n                (uint256 reserveInput, uint256 reserveOutput) =\n                    input == token0 ? (reserve0, reserve1) : (reserve1, reserve0);\n                uint256 amountInput = ERC20(input).balanceOf(pair) - reserveInput;\n                uint256 amountOutput = UniversalRouterHelper.getAmountOut(amountInput, reserveInput, reserveOutput);\n                (uint256 amount0Out, uint256 amount1Out) =\n                    input == token0 ? (uint256(0), amountOutput) : (amountOutput, uint256(0));\n                address nextPair;\n                (nextPair, token0) = i < penultimatePairIndex\n                    ? UniversalRouterHelper.pairAndToken0For(\n                        PANCAKESWAP_V2_FACTORY, PANCAKESWAP_V2_PAIR_INIT_CODE_HASH, output, path[i + 2]\n                    )\n                    : (recipient, address(0));\n                IUniswapV2Pair(pair).swap(amount0Out, amount1Out, nextPair, new bytes(0));\n                pair = nextPair;\n            }\n        }\n    }\n\n    /// @notice Performs a PancakeSwap v2 exact input swap\n    /// @param recipient The recipient of the output tokens\n    /// @param amountIn The amount of input tokens for the trade\n    /// @param amountOutMinimum The minimum desired amount of output tokens\n    /// @param path The path of the trade as an array of token addresses\n    /// @param payer The address that will be paying the input\n    function v2SwapExactInput(\n        address recipient,\n        uint256 amountIn,\n        uint256 amountOutMinimum,\n        address[] calldata path,\n        address payer\n    ) internal {\n        address firstPair =\n            UniversalRouterHelper.pairFor(PANCAKESWAP_V2_FACTORY, PANCAKESWAP_V2_PAIR_INIT_CODE_HASH, path[0], path[1]);\n        if (\n            amountIn != Constants.ALREADY_PAID // amountIn of 0 to signal that the pair already has the tokens\n        ) {\n            payOrPermit2Transfer(path[0], payer, firstPair, amountIn);\n        }\n\n        ERC20 tokenOut = ERC20(path[path.length - 1]);\n        uint256 balanceBefore = tokenOut.balanceOf(recipient);\n\n        _v2Swap(path, recipient, firstPair);\n\n        uint256 amountOut = tokenOut.balanceOf(recipient) - balanceBefore;\n        if (amountOut < amountOutMinimum) revert V2TooLittleReceived();\n    }\n\n    /// @notice Performs a PancakeSwap v2 exact output swap\n    /// @param recipient The recipient of the output tokens\n    /// @param amountOut The amount of output tokens to receive for the trade\n    /// @param amountInMaximum The maximum desired amount of input tokens\n    /// @param path The path of the trade as an array of token addresses\n    /// @param payer The address that will be paying the input\n    function v2SwapExactOutput(\n        address recipient,\n        uint256 amountOut,\n        uint256 amountInMaximum,\n        address[] calldata path,\n        address payer\n    ) internal {\n        (uint256 amountIn, address firstPair) = UniversalRouterHelper.getAmountInMultihop(\n            PANCAKESWAP_V2_FACTORY, PANCAKESWAP_V2_PAIR_INIT_CODE_HASH, amountOut, path\n        );\n        if (amountIn > amountInMaximum) revert V2TooMuchRequested();\n\n        payOrPermit2Transfer(path[0], payer, firstPair, amountIn);\n        _v2Swap(path, recipient, firstPair);\n    }\n}\n"
      },
      "src/modules/pancakeswap/v3/V3SwapRouter.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.17;\n\nimport {SafeCast} from \"./SafeCast.sol\";\nimport {IPancakeV3Pool} from \"./interfaces/IPancakeV3Pool.sol\";\nimport {IPancakeV3SwapCallback} from \"./interfaces/IPancakeV3SwapCallback.sol\";\nimport {BytesLib} from \"../../../libraries/BytesLib.sol\";\nimport {Constants} from \"../../../libraries/Constants.sol\";\nimport {UniversalRouterHelper} from \"../../../libraries/UniversalRouterHelper.sol\";\nimport {RouterImmutables} from \"../../../base/RouterImmutables.sol\";\nimport {Permit2Payments} from \"../../Permit2Payments.sol\";\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\n\n/// @title Router for PancakeSwap v3 Trades\nabstract contract V3SwapRouter is RouterImmutables, Permit2Payments, IPancakeV3SwapCallback {\n    using UniversalRouterHelper for bytes;\n    using BytesLib for bytes;\n    using SafeCast for uint256;\n\n    error V3InvalidSwap();\n    error V3TooLittleReceived();\n    error V3TooMuchRequested();\n    error V3InvalidAmountOut();\n    error V3InvalidCaller();\n\n    /// @dev Used as the placeholder value for maxAmountIn, because the computed amount in for an exact output swap\n    /// can never actually be this value\n    uint256 private constant DEFAULT_MAX_AMOUNT_IN = type(uint256).max;\n\n    /// @dev Transient storage variable used for checking slippage\n    uint256 private maxAmountInCached = DEFAULT_MAX_AMOUNT_IN;\n\n    /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\n    uint160 internal constant MIN_SQRT_RATIO = 4295128739;\n\n    /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\n    uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\n\n    function pancakeV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external {\n        if (amount0Delta <= 0 && amount1Delta <= 0) revert V3InvalidSwap(); // swaps entirely within 0-liquidity regions are not supported\n        (, address payer) = abi.decode(data, (bytes, address));\n        bytes calldata path = data.toBytes(0);\n\n        // because exact output swaps are executed in reverse order, in this case tokenOut is actually tokenIn\n        (address tokenIn, uint24 fee, address tokenOut) = path.decodeFirstPool();\n\n        if (\n            UniversalRouterHelper.computePoolAddress(\n                PANCAKESWAP_V3_DEPLOYER, PANCAKESWAP_V3_POOL_INIT_CODE_HASH, tokenIn, tokenOut, fee\n            ) != msg.sender\n        ) revert V3InvalidCaller();\n\n        (bool isExactInput, uint256 amountToPay) =\n            amount0Delta > 0 ? (tokenIn < tokenOut, uint256(amount0Delta)) : (tokenOut < tokenIn, uint256(amount1Delta));\n\n        if (isExactInput) {\n            // Pay the pool (msg.sender)\n            payOrPermit2Transfer(tokenIn, payer, msg.sender, amountToPay);\n        } else {\n            // either initiate the next swap or pay\n            if (path.hasMultiplePools()) {\n                // this is an intermediate step so the payer is actually this contract\n                path = path.skipToken();\n                _swap(-amountToPay.toInt256(), msg.sender, path, payer, false);\n            } else {\n                if (amountToPay > maxAmountInCached) revert V3TooMuchRequested();\n                // note that because exact output swaps are executed in reverse order, tokenOut is actually tokenIn\n                payOrPermit2Transfer(tokenOut, payer, msg.sender, amountToPay);\n            }\n        }\n    }\n\n    /// @notice Performs a PancakeSwap v3 exact input swap\n    /// @param recipient The recipient of the output tokens\n    /// @param amountIn The amount of input tokens for the trade\n    /// @param amountOutMinimum The minimum desired amount of output tokens\n    /// @param path The path of the trade as a bytes string\n    /// @param payer The address that will be paying the input\n    function v3SwapExactInput(\n        address recipient,\n        uint256 amountIn,\n        uint256 amountOutMinimum,\n        bytes calldata path,\n        address payer\n    ) internal {\n        // use amountIn == Constants.CONTRACT_BALANCE as a flag to swap the entire balance of the contract\n        if (amountIn == Constants.CONTRACT_BALANCE) {\n            address tokenIn = path.decodeFirstToken();\n            amountIn = ERC20(tokenIn).balanceOf(address(this));\n        }\n\n        uint256 amountOut;\n        while (true) {\n            bool hasMultiplePools = path.hasMultiplePools();\n\n            // the outputs of prior swaps become the inputs to subsequent ones\n            (int256 amount0Delta, int256 amount1Delta, bool zeroForOne) = _swap(\n                amountIn.toInt256(),\n                hasMultiplePools ? address(this) : recipient, // for intermediate swaps, this contract custodies\n                path.getFirstPool(), // only the first pool is needed\n                payer, // for intermediate swaps, this contract custodies\n                true\n            );\n\n            amountIn = uint256(-(zeroForOne ? amount1Delta : amount0Delta));\n\n            // decide whether to continue or terminate\n            if (hasMultiplePools) {\n                payer = address(this);\n                path = path.skipToken();\n            } else {\n                amountOut = amountIn;\n                break;\n            }\n        }\n\n        if (amountOut < amountOutMinimum) revert V3TooLittleReceived();\n    }\n\n    /// @notice Performs a PancakeSwap v3 exact output swap\n    /// @param recipient The recipient of the output tokens\n    /// @param amountOut The amount of output tokens to receive for the trade\n    /// @param amountInMaximum The maximum desired amount of input tokens\n    /// @param path The path of the trade as a bytes string\n    /// @param payer The address that will be paying the input\n    function v3SwapExactOutput(\n        address recipient,\n        uint256 amountOut,\n        uint256 amountInMaximum,\n        bytes calldata path,\n        address payer\n    ) internal {\n        maxAmountInCached = amountInMaximum;\n        (int256 amount0Delta, int256 amount1Delta, bool zeroForOne) =\n            _swap(-amountOut.toInt256(), recipient, path, payer, false);\n\n        uint256 amountOutReceived = zeroForOne ? uint256(-amount1Delta) : uint256(-amount0Delta);\n\n        if (amountOutReceived != amountOut) revert V3InvalidAmountOut();\n\n        maxAmountInCached = DEFAULT_MAX_AMOUNT_IN;\n    }\n\n    /// @dev Performs a single swap for both exactIn and exactOut\n    /// For exactIn, `amount` is `amountIn`. For exactOut, `amount` is `-amountOut`\n    function _swap(int256 amount, address recipient, bytes calldata path, address payer, bool isExactIn)\n        private\n        returns (int256 amount0Delta, int256 amount1Delta, bool zeroForOne)\n    {\n        (address tokenIn, uint24 fee, address tokenOut) = path.decodeFirstPool();\n\n        zeroForOne = isExactIn ? tokenIn < tokenOut : tokenOut < tokenIn;\n\n        (amount0Delta, amount1Delta) = IPancakeV3Pool(\n            UniversalRouterHelper.computePoolAddress(\n                PANCAKESWAP_V3_DEPLOYER, PANCAKESWAP_V3_POOL_INIT_CODE_HASH, tokenIn, tokenOut, fee\n            )\n        ).swap(\n            recipient,\n            zeroForOne,\n            amount,\n            (zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1),\n            abi.encode(path, payer)\n        );\n    }\n}\n"
      },
      "src/modules/Payments.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.17;\n\nimport {Constants} from \"../libraries/Constants.sol\";\nimport {RouterImmutables} from \"../base/RouterImmutables.sol\";\nimport {SafeTransferLib} from \"solmate/utils/SafeTransferLib.sol\";\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\nimport {ERC721} from \"solmate/tokens/ERC721.sol\";\nimport {ERC1155} from \"solmate/tokens/ERC1155.sol\";\n\n/// @title Payments contract\n/// @notice Performs various operations around the payment of ETH and tokens\nabstract contract Payments is RouterImmutables {\n    using SafeTransferLib for ERC20;\n    using SafeTransferLib for address;\n\n    error InsufficientToken();\n    error InsufficientETH();\n    error InvalidBips();\n    error InvalidSpender();\n\n    uint256 internal constant FEE_BIPS_BASE = 10_000;\n\n    /// @notice Pays an amount of ETH or ERC20 to a recipient\n    /// @param token The token to pay (can be ETH using Constants.ETH)\n    /// @param recipient The address that will receive the payment\n    /// @param value The amount to pay\n    function pay(address token, address recipient, uint256 value) internal {\n        if (token == Constants.ETH) {\n            recipient.safeTransferETH(value);\n        } else {\n            if (value == Constants.CONTRACT_BALANCE) {\n                value = ERC20(token).balanceOf(address(this));\n            }\n\n            ERC20(token).safeTransfer(recipient, value);\n        }\n    }\n\n    /// @notice Approves a protocol to spend ERC20s in the router\n    /// @param token The token to approve\n    /// @param spender Which protocol to approve\n    function approveERC20(ERC20 token, Spenders spender) internal {\n        // check spender is one of our approved spenders\n        address spenderAddress;\n        /// @dev use 0 = Opensea Conduit for both Seaport v1.4 and v1.5\n        if (spender == Spenders.OSConduit) spenderAddress = OPENSEA_CONDUIT;\n        else revert InvalidSpender();\n\n        // set approval\n        token.safeApprove(spenderAddress, type(uint256).max);\n    }\n\n    /// @notice Pays a proportion of the contract's ETH or ERC20 to a recipient\n    /// @param token The token to pay (can be ETH using Constants.ETH)\n    /// @param recipient The address that will receive payment\n    /// @param bips Portion in bips of whole balance of the contract\n    function payPortion(address token, address recipient, uint256 bips) internal {\n        if (bips == 0 || bips > FEE_BIPS_BASE) revert InvalidBips();\n        if (token == Constants.ETH) {\n            uint256 balance = address(this).balance;\n            uint256 amount = (balance * bips) / FEE_BIPS_BASE;\n            recipient.safeTransferETH(amount);\n        } else {\n            uint256 balance = ERC20(token).balanceOf(address(this));\n            uint256 amount = (balance * bips) / FEE_BIPS_BASE;\n            ERC20(token).safeTransfer(recipient, amount);\n        }\n    }\n\n    /// @notice Sweeps all of the contract's ERC20 or ETH to an address\n    /// @param token The token to sweep (can be ETH using Constants.ETH)\n    /// @param recipient The address that will receive payment\n    /// @param amountMinimum The minimum desired amount\n    function sweep(address token, address recipient, uint256 amountMinimum) internal {\n        uint256 balance;\n        if (token == Constants.ETH) {\n            balance = address(this).balance;\n            if (balance < amountMinimum) revert InsufficientETH();\n            if (balance > 0) recipient.safeTransferETH(balance);\n        } else {\n            balance = ERC20(token).balanceOf(address(this));\n            if (balance < amountMinimum) revert InsufficientToken();\n            if (balance > 0) ERC20(token).safeTransfer(recipient, balance);\n        }\n    }\n\n    /// @notice Sweeps an ERC721 to a recipient from the contract\n    /// @param token The ERC721 token to sweep\n    /// @param recipient The address that will receive payment\n    /// @param id The ID of the ERC721 to sweep\n    function sweepERC721(address token, address recipient, uint256 id) internal {\n        ERC721(token).safeTransferFrom(address(this), recipient, id);\n    }\n\n    /// @notice Sweeps all of the contract's ERC1155 to an address\n    /// @param token The ERC1155 token to sweep\n    /// @param recipient The address that will receive payment\n    /// @param id The ID of the ERC1155 to sweep\n    /// @param amountMinimum The minimum desired amount\n    function sweepERC1155(address token, address recipient, uint256 id, uint256 amountMinimum) internal {\n        uint256 balance = ERC1155(token).balanceOf(address(this), id);\n        if (balance < amountMinimum) revert InsufficientToken();\n        ERC1155(token).safeTransferFrom(address(this), recipient, id, balance, bytes(\"\"));\n    }\n\n    /// @notice Wraps an amount of ETH into WETH\n    /// @param recipient The recipient of the WETH\n    /// @param amount The amount to wrap (can be CONTRACT_BALANCE)\n    function wrapETH(address recipient, uint256 amount) internal {\n        if (amount == Constants.CONTRACT_BALANCE) {\n            amount = address(this).balance;\n        } else if (amount > address(this).balance) {\n            revert InsufficientETH();\n        }\n        if (amount > 0) {\n            WETH9.deposit{value: amount}();\n            if (recipient != address(this)) {\n                WETH9.transfer(recipient, amount);\n            }\n        }\n    }\n\n    /// @notice Unwraps all of the contract's WETH into ETH\n    /// @param recipient The recipient of the ETH\n    /// @param amountMinimum The minimum amount of ETH desired\n    function unwrapWETH9(address recipient, uint256 amountMinimum) internal {\n        uint256 value = WETH9.balanceOf(address(this));\n        if (value < amountMinimum) {\n            revert InsufficientETH();\n        }\n        if (value > 0) {\n            WETH9.withdraw(value);\n            if (recipient != address(this)) {\n                recipient.safeTransferETH(value);\n            }\n        }\n    }\n}\n"
      },
      "src/base/Callbacks.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.17;\n\nimport {IERC721Receiver} from \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport {IERC1155Receiver} from \"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol\";\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\n/// @title ERC Callback Support\n/// @notice Implements various functions introduced by a variety of ERCs for security reasons.\n/// All are called by external contracts to ensure that this contract safely supports the ERC in question.\ncontract Callbacks is IERC721Receiver, IERC1155Receiver {\n    function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4) {\n        return this.onERC721Received.selector;\n    }\n\n    function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure returns (bytes4) {\n        return this.onERC1155Received.selector;\n    }\n\n    function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata)\n        external\n        pure\n        returns (bytes4)\n    {\n        return this.onERC1155BatchReceived.selector;\n    }\n\n    function supportsInterface(bytes4 interfaceId) external pure returns (bool) {\n        return interfaceId == type(IERC1155Receiver).interfaceId || interfaceId == type(IERC721Receiver).interfaceId\n            || interfaceId == type(IERC165).interfaceId;\n    }\n}\n"
      },
      "src/libraries/BytesLib.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n/// @title Library for Bytes Manipulation\npragma solidity ^0.8.0;\n\nimport {Constants} from \"./Constants.sol\";\n\nlibrary BytesLib {\n    error SliceOutOfBounds();\n\n    /// @notice Returns the address starting at byte 0\n    /// @dev length and overflow checks must be carried out before calling\n    /// @param _bytes The input bytes string to slice\n    /// @return _address The address starting at byte 0\n    function toAddress(bytes calldata _bytes) internal pure returns (address _address) {\n        if (_bytes.length < Constants.ADDR_SIZE) revert SliceOutOfBounds();\n        assembly {\n            _address := shr(96, calldataload(_bytes.offset))\n        }\n    }\n\n    /// @notice Returns the pool details starting at byte 0\n    /// @dev length and overflow checks must be carried out before calling\n    /// @param _bytes The input bytes string to slice\n    /// @return token0 The address at byte 0\n    /// @return fee The uint24 starting at byte 20\n    /// @return token1 The address at byte 23\n    function toPool(bytes calldata _bytes) internal pure returns (address token0, uint24 fee, address token1) {\n        if (_bytes.length < Constants.V3_POP_OFFSET) revert SliceOutOfBounds();\n        assembly {\n            let firstWord := calldataload(_bytes.offset)\n            token0 := shr(96, firstWord)\n            fee := and(shr(72, firstWord), 0xffffff)\n            token1 := shr(96, calldataload(add(_bytes.offset, 23)))\n        }\n    }\n\n    /// @notice Decode the `_arg`-th element in `_bytes` as a dynamic array\n    /// @dev The decoding of `length` and `offset` is universal,\n    /// whereas the type declaration of `res` instructs the compiler how to read it.\n    /// @param _bytes The input bytes string to slice\n    /// @param _arg The index of the argument to extract\n    /// @return length Length of the array\n    /// @return offset Pointer to the data part of the array\n    function toLengthOffset(bytes calldata _bytes, uint256 _arg)\n        internal\n        pure\n        returns (uint256 length, uint256 offset)\n    {\n        uint256 relativeOffset;\n        assembly {\n            // The offset of the `_arg`-th element is `32 * arg`, which stores the offset of the length pointer.\n            // shl(5, x) is equivalent to mul(32, x)\n            let lengthPtr := add(_bytes.offset, calldataload(add(_bytes.offset, shl(5, _arg))))\n            length := calldataload(lengthPtr)\n            offset := add(lengthPtr, 0x20)\n            relativeOffset := sub(offset, _bytes.offset)\n        }\n        if (_bytes.length < length + relativeOffset) revert SliceOutOfBounds();\n    }\n\n    /// @notice Decode the `_arg`-th element in `_bytes` as `bytes`\n    /// @param _bytes The input bytes string to extract a bytes string from\n    /// @param _arg The index of the argument to extract\n    function toBytes(bytes calldata _bytes, uint256 _arg) internal pure returns (bytes calldata res) {\n        (uint256 length, uint256 offset) = toLengthOffset(_bytes, _arg);\n        assembly {\n            res.length := length\n            res.offset := offset\n        }\n    }\n\n    /// @notice Decode the `_arg`-th element in `_bytes` as `address[]`\n    /// @param _bytes The input bytes string to extract an address array from\n    /// @param _arg The index of the argument to extract\n    function toAddressArray(bytes calldata _bytes, uint256 _arg) internal pure returns (address[] calldata res) {\n        (uint256 length, uint256 offset) = toLengthOffset(_bytes, _arg);\n        assembly {\n            res.length := length\n            res.offset := offset\n        }\n    }\n\n    /// @notice Decode the `_arg`-th element in `_bytes` as `bytes[]`\n    /// @param _bytes The input bytes string to extract a bytes array from\n    /// @param _arg The index of the argument to extract\n    function toBytesArray(bytes calldata _bytes, uint256 _arg) internal pure returns (bytes[] calldata res) {\n        (uint256 length, uint256 offset) = toLengthOffset(_bytes, _arg);\n        assembly {\n            res.length := length\n            res.offset := offset\n        }\n    }\n\n    /// @notice Decode the `_arg`-th element in `_bytes` as `uint[]`\n    /// @param _bytes The input bytes string to extract an uint array from\n    /// @param _arg The index of the argument to extract\n    function toUintArray(bytes calldata _bytes, uint256 _arg) internal pure returns (uint256[] calldata res) {\n        (uint256 length, uint256 offset) = toLengthOffset(_bytes, _arg);\n        assembly {\n            res.length := length\n            res.offset := offset\n        }\n    }\n}\n"
      },
      "src/base/LockAndMsgSender.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.17;\n\nimport {Constants} from \"../libraries/Constants.sol\";\n\ncontract LockAndMsgSender {\n    error ContractLocked();\n\n    address internal constant NOT_LOCKED_FLAG = address(1);\n    address internal lockedBy = NOT_LOCKED_FLAG;\n\n    modifier isNotLocked() {\n        if (msg.sender != address(this)) {\n            if (lockedBy != NOT_LOCKED_FLAG) revert ContractLocked();\n            lockedBy = msg.sender;\n            _;\n            lockedBy = NOT_LOCKED_FLAG;\n        } else {\n            _;\n        }\n    }\n\n    /// @notice Calculates the recipient address for a command\n    /// @param recipient The recipient or recipient-flag for the command\n    /// @return output The resultant recipient for the command\n    function map(address recipient) internal view returns (address) {\n        if (recipient == Constants.MSG_SENDER) {\n            return lockedBy;\n        } else if (recipient == Constants.ADDRESS_THIS) {\n            return address(this);\n        } else {\n            return recipient;\n        }\n    }\n}\n"
      },
      "lib/solmate/src/tokens/ERC721.sol": {
        "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Modern, minimalist, and gas efficient ERC-721 implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol)\nabstract contract ERC721 {\n    /*//////////////////////////////////////////////////////////////\n                                 EVENTS\n    //////////////////////////////////////////////////////////////*/\n\n    event Transfer(address indexed from, address indexed to, uint256 indexed id);\n\n    event Approval(address indexed owner, address indexed spender, uint256 indexed id);\n\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /*//////////////////////////////////////////////////////////////\n                         METADATA STORAGE/LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    string public name;\n\n    string public symbol;\n\n    function tokenURI(uint256 id) public view virtual returns (string memory);\n\n    /*//////////////////////////////////////////////////////////////\n                      ERC721 BALANCE/OWNER STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    mapping(uint256 => address) internal _ownerOf;\n\n    mapping(address => uint256) internal _balanceOf;\n\n    function ownerOf(uint256 id) public view virtual returns (address owner) {\n        require((owner = _ownerOf[id]) != address(0), \"NOT_MINTED\");\n    }\n\n    function balanceOf(address owner) public view virtual returns (uint256) {\n        require(owner != address(0), \"ZERO_ADDRESS\");\n\n        return _balanceOf[owner];\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                         ERC721 APPROVAL STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    mapping(uint256 => address) public getApproved;\n\n    mapping(address => mapping(address => bool)) public isApprovedForAll;\n\n    /*//////////////////////////////////////////////////////////////\n                               CONSTRUCTOR\n    //////////////////////////////////////////////////////////////*/\n\n    constructor(string memory _name, string memory _symbol) {\n        name = _name;\n        symbol = _symbol;\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                              ERC721 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function approve(address spender, uint256 id) public virtual {\n        address owner = _ownerOf[id];\n\n        require(msg.sender == owner || isApprovedForAll[owner][msg.sender], \"NOT_AUTHORIZED\");\n\n        getApproved[id] = spender;\n\n        emit Approval(owner, spender, id);\n    }\n\n    function setApprovalForAll(address operator, bool approved) public virtual {\n        isApprovedForAll[msg.sender][operator] = approved;\n\n        emit ApprovalForAll(msg.sender, operator, approved);\n    }\n\n    function transferFrom(\n        address from,\n        address to,\n        uint256 id\n    ) public virtual {\n        require(from == _ownerOf[id], \"WRONG_FROM\");\n\n        require(to != address(0), \"INVALID_RECIPIENT\");\n\n        require(\n            msg.sender == from || isApprovedForAll[from][msg.sender] || msg.sender == getApproved[id],\n            \"NOT_AUTHORIZED\"\n        );\n\n        // Underflow of the sender's balance is impossible because we check for\n        // ownership above and the recipient's balance can't realistically overflow.\n        unchecked {\n            _balanceOf[from]--;\n\n            _balanceOf[to]++;\n        }\n\n        _ownerOf[id] = to;\n\n        delete getApproved[id];\n\n        emit Transfer(from, to, id);\n    }\n\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 id\n    ) public virtual {\n        transferFrom(from, to, id);\n\n        require(\n            to.code.length == 0 ||\n                ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, \"\") ==\n                ERC721TokenReceiver.onERC721Received.selector,\n            \"UNSAFE_RECIPIENT\"\n        );\n    }\n\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 id,\n        bytes calldata data\n    ) public virtual {\n        transferFrom(from, to, id);\n\n        require(\n            to.code.length == 0 ||\n                ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) ==\n                ERC721TokenReceiver.onERC721Received.selector,\n            \"UNSAFE_RECIPIENT\"\n        );\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                              ERC165 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n        return\n            interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165\n            interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721\n            interfaceId == 0x5b5e139f; // ERC165 Interface ID for ERC721Metadata\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                        INTERNAL MINT/BURN LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function _mint(address to, uint256 id) internal virtual {\n        require(to != address(0), \"INVALID_RECIPIENT\");\n\n        require(_ownerOf[id] == address(0), \"ALREADY_MINTED\");\n\n        // Counter overflow is incredibly unrealistic.\n        unchecked {\n            _balanceOf[to]++;\n        }\n\n        _ownerOf[id] = to;\n\n        emit Transfer(address(0), to, id);\n    }\n\n    function _burn(uint256 id) internal virtual {\n        address owner = _ownerOf[id];\n\n        require(owner != address(0), \"NOT_MINTED\");\n\n        // Ownership check above ensures no underflow.\n        unchecked {\n            _balanceOf[owner]--;\n        }\n\n        delete _ownerOf[id];\n\n        delete getApproved[id];\n\n        emit Transfer(owner, address(0), id);\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                        INTERNAL SAFE MINT LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function _safeMint(address to, uint256 id) internal virtual {\n        _mint(to, id);\n\n        require(\n            to.code.length == 0 ||\n                ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, \"\") ==\n                ERC721TokenReceiver.onERC721Received.selector,\n            \"UNSAFE_RECIPIENT\"\n        );\n    }\n\n    function _safeMint(\n        address to,\n        uint256 id,\n        bytes memory data\n    ) internal virtual {\n        _mint(to, id);\n\n        require(\n            to.code.length == 0 ||\n                ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, data) ==\n                ERC721TokenReceiver.onERC721Received.selector,\n            \"UNSAFE_RECIPIENT\"\n        );\n    }\n}\n\n/// @notice A generic interface for a contract which properly accepts ERC721 tokens.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol)\nabstract contract ERC721TokenReceiver {\n    function onERC721Received(\n        address,\n        address,\n        uint256,\n        bytes calldata\n    ) external virtual returns (bytes4) {\n        return ERC721TokenReceiver.onERC721Received.selector;\n    }\n}\n"
      },
      "lib/solmate/src/tokens/ERC1155.sol": {
        "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Minimalist and gas efficient standard ERC1155 implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC1155.sol)\nabstract contract ERC1155 {\n    /*//////////////////////////////////////////////////////////////\n                                 EVENTS\n    //////////////////////////////////////////////////////////////*/\n\n    event TransferSingle(\n        address indexed operator,\n        address indexed from,\n        address indexed to,\n        uint256 id,\n        uint256 amount\n    );\n\n    event TransferBatch(\n        address indexed operator,\n        address indexed from,\n        address indexed to,\n        uint256[] ids,\n        uint256[] amounts\n    );\n\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    event URI(string value, uint256 indexed id);\n\n    /*//////////////////////////////////////////////////////////////\n                             ERC1155 STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    mapping(address => mapping(uint256 => uint256)) public balanceOf;\n\n    mapping(address => mapping(address => bool)) public isApprovedForAll;\n\n    /*//////////////////////////////////////////////////////////////\n                             METADATA LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function uri(uint256 id) public view virtual returns (string memory);\n\n    /*//////////////////////////////////////////////////////////////\n                              ERC1155 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function setApprovalForAll(address operator, bool approved) public virtual {\n        isApprovedForAll[msg.sender][operator] = approved;\n\n        emit ApprovalForAll(msg.sender, operator, approved);\n    }\n\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 id,\n        uint256 amount,\n        bytes calldata data\n    ) public virtual {\n        require(msg.sender == from || isApprovedForAll[from][msg.sender], \"NOT_AUTHORIZED\");\n\n        balanceOf[from][id] -= amount;\n        balanceOf[to][id] += amount;\n\n        emit TransferSingle(msg.sender, from, to, id, amount);\n\n        require(\n            to.code.length == 0\n                ? to != address(0)\n                : ERC1155TokenReceiver(to).onERC1155Received(msg.sender, from, id, amount, data) ==\n                    ERC1155TokenReceiver.onERC1155Received.selector,\n            \"UNSAFE_RECIPIENT\"\n        );\n    }\n\n    function safeBatchTransferFrom(\n        address from,\n        address to,\n        uint256[] calldata ids,\n        uint256[] calldata amounts,\n        bytes calldata data\n    ) public virtual {\n        require(ids.length == amounts.length, \"LENGTH_MISMATCH\");\n\n        require(msg.sender == from || isApprovedForAll[from][msg.sender], \"NOT_AUTHORIZED\");\n\n        // Storing these outside the loop saves ~15 gas per iteration.\n        uint256 id;\n        uint256 amount;\n\n        for (uint256 i = 0; i < ids.length; ) {\n            id = ids[i];\n            amount = amounts[i];\n\n            balanceOf[from][id] -= amount;\n            balanceOf[to][id] += amount;\n\n            // An array can't have a total length\n            // larger than the max uint256 value.\n            unchecked {\n                ++i;\n            }\n        }\n\n        emit TransferBatch(msg.sender, from, to, ids, amounts);\n\n        require(\n            to.code.length == 0\n                ? to != address(0)\n                : ERC1155TokenReceiver(to).onERC1155BatchReceived(msg.sender, from, ids, amounts, data) ==\n                    ERC1155TokenReceiver.onERC1155BatchReceived.selector,\n            \"UNSAFE_RECIPIENT\"\n        );\n    }\n\n    function balanceOfBatch(address[] calldata owners, uint256[] calldata ids)\n        public\n        view\n        virtual\n        returns (uint256[] memory balances)\n    {\n        require(owners.length == ids.length, \"LENGTH_MISMATCH\");\n\n        balances = new uint256[](owners.length);\n\n        // Unchecked because the only math done is incrementing\n        // the array index counter which cannot possibly overflow.\n        unchecked {\n            for (uint256 i = 0; i < owners.length; ++i) {\n                balances[i] = balanceOf[owners[i]][ids[i]];\n            }\n        }\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                              ERC165 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n        return\n            interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165\n            interfaceId == 0xd9b67a26 || // ERC165 Interface ID for ERC1155\n            interfaceId == 0x0e89341c; // ERC165 Interface ID for ERC1155MetadataURI\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                        INTERNAL MINT/BURN LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function _mint(\n        address to,\n        uint256 id,\n        uint256 amount,\n        bytes memory data\n    ) internal virtual {\n        balanceOf[to][id] += amount;\n\n        emit TransferSingle(msg.sender, address(0), to, id, amount);\n\n        require(\n            to.code.length == 0\n                ? to != address(0)\n                : ERC1155TokenReceiver(to).onERC1155Received(msg.sender, address(0), id, amount, data) ==\n                    ERC1155TokenReceiver.onERC1155Received.selector,\n            \"UNSAFE_RECIPIENT\"\n        );\n    }\n\n    function _batchMint(\n        address to,\n        uint256[] memory ids,\n        uint256[] memory amounts,\n        bytes memory data\n    ) internal virtual {\n        uint256 idsLength = ids.length; // Saves MLOADs.\n\n        require(idsLength == amounts.length, \"LENGTH_MISMATCH\");\n\n        for (uint256 i = 0; i < idsLength; ) {\n            balanceOf[to][ids[i]] += amounts[i];\n\n            // An array can't have a total length\n            // larger than the max uint256 value.\n            unchecked {\n                ++i;\n            }\n        }\n\n        emit TransferBatch(msg.sender, address(0), to, ids, amounts);\n\n        require(\n            to.code.length == 0\n                ? to != address(0)\n                : ERC1155TokenReceiver(to).onERC1155BatchReceived(msg.sender, address(0), ids, amounts, data) ==\n                    ERC1155TokenReceiver.onERC1155BatchReceived.selector,\n            \"UNSAFE_RECIPIENT\"\n        );\n    }\n\n    function _batchBurn(\n        address from,\n        uint256[] memory ids,\n        uint256[] memory amounts\n    ) internal virtual {\n        uint256 idsLength = ids.length; // Saves MLOADs.\n\n        require(idsLength == amounts.length, \"LENGTH_MISMATCH\");\n\n        for (uint256 i = 0; i < idsLength; ) {\n            balanceOf[from][ids[i]] -= amounts[i];\n\n            // An array can't have a total length\n            // larger than the max uint256 value.\n            unchecked {\n                ++i;\n            }\n        }\n\n        emit TransferBatch(msg.sender, from, address(0), ids, amounts);\n    }\n\n    function _burn(\n        address from,\n        uint256 id,\n        uint256 amount\n    ) internal virtual {\n        balanceOf[from][id] -= amount;\n\n        emit TransferSingle(msg.sender, from, address(0), id, amount);\n    }\n}\n\n/// @notice A generic interface for a contract which properly accepts ERC1155 tokens.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC1155.sol)\nabstract contract ERC1155TokenReceiver {\n    function onERC1155Received(\n        address,\n        address,\n        uint256,\n        uint256,\n        bytes calldata\n    ) external virtual returns (bytes4) {\n        return ERC1155TokenReceiver.onERC1155Received.selector;\n    }\n\n    function onERC1155BatchReceived(\n        address,\n        address,\n        uint256[] calldata,\n        uint256[] calldata,\n        bytes calldata\n    ) external virtual returns (bytes4) {\n        return ERC1155TokenReceiver.onERC1155BatchReceived.selector;\n    }\n}\n"
      },
      "lib/solmate/src/tokens/ERC20.sol": {
        "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\nabstract contract ERC20 {\n    /*//////////////////////////////////////////////////////////////\n                                 EVENTS\n    //////////////////////////////////////////////////////////////*/\n\n    event Transfer(address indexed from, address indexed to, uint256 amount);\n\n    event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n    /*//////////////////////////////////////////////////////////////\n                            METADATA STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    string public name;\n\n    string public symbol;\n\n    uint8 public immutable decimals;\n\n    /*//////////////////////////////////////////////////////////////\n                              ERC20 STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    uint256 public totalSupply;\n\n    mapping(address => uint256) public balanceOf;\n\n    mapping(address => mapping(address => uint256)) public allowance;\n\n    /*//////////////////////////////////////////////////////////////\n                            EIP-2612 STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    uint256 internal immutable INITIAL_CHAIN_ID;\n\n    bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\n\n    mapping(address => uint256) public nonces;\n\n    /*//////////////////////////////////////////////////////////////\n                               CONSTRUCTOR\n    //////////////////////////////////////////////////////////////*/\n\n    constructor(\n        string memory _name,\n        string memory _symbol,\n        uint8 _decimals\n    ) {\n        name = _name;\n        symbol = _symbol;\n        decimals = _decimals;\n\n        INITIAL_CHAIN_ID = block.chainid;\n        INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                               ERC20 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function approve(address spender, uint256 amount) public virtual returns (bool) {\n        allowance[msg.sender][spender] = amount;\n\n        emit Approval(msg.sender, spender, amount);\n\n        return true;\n    }\n\n    function transfer(address to, uint256 amount) public virtual returns (bool) {\n        balanceOf[msg.sender] -= amount;\n\n        // Cannot overflow because the sum of all user\n        // balances can't exceed the max uint256 value.\n        unchecked {\n            balanceOf[to] += amount;\n        }\n\n        emit Transfer(msg.sender, to, amount);\n\n        return true;\n    }\n\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) public virtual returns (bool) {\n        uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\n\n        if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\n\n        balanceOf[from] -= amount;\n\n        // Cannot overflow because the sum of all user\n        // balances can't exceed the max uint256 value.\n        unchecked {\n            balanceOf[to] += amount;\n        }\n\n        emit Transfer(from, to, amount);\n\n        return true;\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                             EIP-2612 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) public virtual {\n        require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n        // Unchecked because the only math done is incrementing\n        // the owner's nonce which cannot realistically overflow.\n        unchecked {\n            address recoveredAddress = ecrecover(\n                keccak256(\n                    abi.encodePacked(\n                        \"\\x19\\x01\",\n                        DOMAIN_SEPARATOR(),\n                        keccak256(\n                            abi.encode(\n                                keccak256(\n                                    \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n                                ),\n                                owner,\n                                spender,\n                                value,\n                                nonces[owner]++,\n                                deadline\n                            )\n                        )\n                    )\n                ),\n                v,\n                r,\n                s\n            );\n\n            require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNER\");\n\n            allowance[recoveredAddress][spender] = value;\n        }\n\n        emit Approval(owner, spender, value);\n    }\n\n    function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\n        return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\n    }\n\n    function computeDomainSeparator() internal view virtual returns (bytes32) {\n        return\n            keccak256(\n                abi.encode(\n                    keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n                    keccak256(bytes(name)),\n                    keccak256(\"1\"),\n                    block.chainid,\n                    address(this)\n                )\n            );\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                        INTERNAL MINT/BURN LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function _mint(address to, uint256 amount) internal virtual {\n        totalSupply += amount;\n\n        // Cannot overflow because the sum of all user\n        // balances can't exceed the max uint256 value.\n        unchecked {\n            balanceOf[to] += amount;\n        }\n\n        emit Transfer(address(0), to, amount);\n    }\n\n    function _burn(address from, uint256 amount) internal virtual {\n        balanceOf[from] -= amount;\n\n        // Cannot underflow because a user's balance\n        // will never be larger than the total supply.\n        unchecked {\n            totalSupply -= amount;\n        }\n\n        emit Transfer(from, address(0), amount);\n    }\n}\n"
      },
      "src/permit2/src/interfaces/IAllowanceTransfer.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\n/// @title AllowanceTransfer\n/// @notice Handles ERC20 token permissions through signature based allowance setting and ERC20 token transfers by checking allowed amounts\n/// @dev Requires user's token approval on the Permit2 contract\ninterface IAllowanceTransfer {\n    /// @notice Thrown when an allowance on a token has expired.\n    /// @param deadline The timestamp at which the allowed amount is no longer valid\n    error AllowanceExpired(uint256 deadline);\n\n    /// @notice Thrown when an allowance on a token has been depleted.\n    /// @param amount The maximum amount allowed\n    error InsufficientAllowance(uint256 amount);\n\n    /// @notice Thrown when too many nonces are invalidated.\n    error ExcessiveInvalidation();\n\n    /// @notice Emits an event when the owner successfully invalidates an ordered nonce.\n    event NonceInvalidation(\n        address indexed owner, address indexed token, address indexed spender, uint48 newNonce, uint48 oldNonce\n    );\n\n    /// @notice Emits an event when the owner successfully sets permissions on a token for the spender.\n    event Approval(\n        address indexed owner, address indexed token, address indexed spender, uint160 amount, uint48 expiration\n    );\n\n    /// @notice Emits an event when the owner successfully sets permissions using a permit signature on a token for the spender.\n    event Permit(\n        address indexed owner,\n        address indexed token,\n        address indexed spender,\n        uint160 amount,\n        uint48 expiration,\n        uint48 nonce\n    );\n\n    /// @notice Emits an event when the owner sets the allowance back to 0 with the lockdown function.\n    event Lockdown(address indexed owner, address token, address spender);\n\n    /// @notice The permit data for a token\n    struct PermitDetails {\n        // ERC20 token address\n        address token;\n        // the maximum amount allowed to spend\n        uint160 amount;\n        // timestamp at which a spender's token allowances become invalid\n        uint48 expiration;\n        // an incrementing value indexed per owner,token,and spender for each signature\n        uint48 nonce;\n    }\n\n    /// @notice The permit message signed for a single token allownce\n    struct PermitSingle {\n        // the permit data for a single token alownce\n        PermitDetails details;\n        // address permissioned on the allowed tokens\n        address spender;\n        // deadline on the permit signature\n        uint256 sigDeadline;\n    }\n\n    /// @notice The permit message signed for multiple token allowances\n    struct PermitBatch {\n        // the permit data for multiple token allowances\n        PermitDetails[] details;\n        // address permissioned on the allowed tokens\n        address spender;\n        // deadline on the permit signature\n        uint256 sigDeadline;\n    }\n\n    /// @notice The saved permissions\n    /// @dev This info is saved per owner, per token, per spender and all signed over in the permit message\n    /// @dev Setting amount to type(uint160).max sets an unlimited approval\n    struct PackedAllowance {\n        // amount allowed\n        uint160 amount;\n        // permission expiry\n        uint48 expiration;\n        // an incrementing value indexed per owner,token,and spender for each signature\n        uint48 nonce;\n    }\n\n    /// @notice A token spender pair.\n    struct TokenSpenderPair {\n        // the token the spender is approved\n        address token;\n        // the spender address\n        address spender;\n    }\n\n    /// @notice Details for a token transfer.\n    struct AllowanceTransferDetails {\n        // the owner of the token\n        address from;\n        // the recipient of the token\n        address to;\n        // the amount of the token\n        uint160 amount;\n        // the token to be transferred\n        address token;\n    }\n\n    /// @notice A mapping from owner address to token address to spender address to PackedAllowance struct, which contains details and conditions of the approval.\n    /// @notice The mapping is indexed in the above order see: allowance[ownerAddress][tokenAddress][spenderAddress]\n    /// @dev The packed slot holds the allowed amount, expiration at which the allowed amount is no longer valid, and current nonce thats updated on any signature based approvals.\n    function allowance(address, address, address) external view returns (uint160, uint48, uint48);\n\n    /// @notice Approves the spender to use up to amount of the specified token up until the expiration\n    /// @param token The token to approve\n    /// @param spender The spender address to approve\n    /// @param amount The approved amount of the token\n    /// @param expiration The timestamp at which the approval is no longer valid\n    /// @dev The packed allowance also holds a nonce, which will stay unchanged in approve\n    /// @dev Setting amount to type(uint160).max sets an unlimited approval\n    function approve(address token, address spender, uint160 amount, uint48 expiration) external;\n\n    /// @notice Permit a spender to a given amount of the owners token via the owner's EIP-712 signature\n    /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce\n    /// @param owner The owner of the tokens being approved\n    /// @param permitSingle Data signed over by the owner specifying the terms of approval\n    /// @param signature The owner's signature over the permit data\n    function permit(address owner, PermitSingle memory permitSingle, bytes calldata signature) external;\n\n    /// @notice Permit a spender to the signed amounts of the owners tokens via the owner's EIP-712 signature\n    /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce\n    /// @param owner The owner of the tokens being approved\n    /// @param permitBatch Data signed over by the owner specifying the terms of approval\n    /// @param signature The owner's signature over the permit data\n    function permit(address owner, PermitBatch memory permitBatch, bytes calldata signature) external;\n\n    /// @notice Transfer approved tokens from one address to another\n    /// @param from The address to transfer from\n    /// @param to The address of the recipient\n    /// @param amount The amount of the token to transfer\n    /// @param token The token address to transfer\n    /// @dev Requires the from address to have approved at least the desired amount\n    /// of tokens to msg.sender.\n    function transferFrom(address from, address to, uint160 amount, address token) external;\n\n    /// @notice Transfer approved tokens in a batch\n    /// @param transferDetails Array of owners, recipients, amounts, and tokens for the transfers\n    /// @dev Requires the from addresses to have approved at least the desired amount\n    /// of tokens to msg.sender.\n    function transferFrom(AllowanceTransferDetails[] calldata transferDetails) external;\n\n    /// @notice Enables performing a \"lockdown\" of the sender's Permit2 identity\n    /// by batch revoking approvals\n    /// @param approvals Array of approvals to revoke.\n    function lockdown(TokenSpenderPair[] calldata approvals) external;\n\n    /// @notice Invalidate nonces for a given (token, spender) pair\n    /// @param token The token to invalidate nonces for\n    /// @param spender The spender to invalidate nonces for\n    /// @param newNonce The new nonce to set. Invalidates all nonces less than it.\n    /// @dev Can't invalidate more than 2**16 nonces per transaction.\n    function invalidateNonces(address token, address spender, uint48 newNonce) external;\n}\n"
      },
      "src/interfaces/IPancakeNFTMarket.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.0;\n\n/// @title Interface for PancakeSwap NFT Market\ninterface IPancakeNFTMarket {\n    /**\n     * @notice Buy token with BNB by matching the price of an existing ask order\n     * @param _collection: contract address of the NFT\n     * @param _tokenId: tokenId of the NFT purchased\n     */\n    function buyTokenUsingBNB(address _collection, uint256 _tokenId) external payable;\n\n    /**\n     * @notice Buy token with WBNB by matching the price of an existing ask order\n     * @param _collection: contract address of the NFT\n     * @param _tokenId: tokenId of the NFT purchased\n     * @param _price: price (must be equal to the askPrice set by the seller)\n     */\n    function buyTokenUsingWBNB(address _collection, uint256 _tokenId, uint256 _price) external;\n}\n"
      },
      "lib/solmate/src/utils/SafeTransferLib.sol": {
        "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../tokens/ERC20.sol\";\n\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\n/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.\nlibrary SafeTransferLib {\n    /*//////////////////////////////////////////////////////////////\n                             ETH OPERATIONS\n    //////////////////////////////////////////////////////////////*/\n\n    function safeTransferETH(address to, uint256 amount) internal {\n        bool success;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            // Transfer the ETH and store if it succeeded or not.\n            success := call(gas(), to, amount, 0, 0, 0, 0)\n        }\n\n        require(success, \"ETH_TRANSFER_FAILED\");\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                            ERC20 OPERATIONS\n    //////////////////////////////////////////////////////////////*/\n\n    function safeTransferFrom(\n        ERC20 token,\n        address from,\n        address to,\n        uint256 amount\n    ) internal {\n        bool success;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            // Get a pointer to some free memory.\n            let freeMemoryPointer := mload(0x40)\n\n            // Write the abi-encoded calldata into memory, beginning with the function selector.\n            mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\n            mstore(add(freeMemoryPointer, 4), from) // Append the \"from\" argument.\n            mstore(add(freeMemoryPointer, 36), to) // Append the \"to\" argument.\n            mstore(add(freeMemoryPointer, 68), amount) // Append the \"amount\" argument.\n\n            success := and(\n                // Set success to whether the call reverted, if not we check it either\n                // returned exactly 1 (can't just be non-zero data), or had no return data.\n                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n                // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.\n                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n                // Counterintuitively, this call must be positioned second to the or() call in the\n                // surrounding and() call or else returndatasize() will be zero during the computation.\n                call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)\n            )\n        }\n\n        require(success, \"TRANSFER_FROM_FAILED\");\n    }\n\n    function safeTransfer(\n        ERC20 token,\n        address to,\n        uint256 amount\n    ) internal {\n        bool success;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            // Get a pointer to some free memory.\n            let freeMemoryPointer := mload(0x40)\n\n            // Write the abi-encoded calldata into memory, beginning with the function selector.\n            mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\n            mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n            mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n            success := and(\n                // Set success to whether the call reverted, if not we check it either\n                // returned exactly 1 (can't just be non-zero data), or had no return data.\n                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n                // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n                // Counterintuitively, this call must be positioned second to the or() call in the\n                // surrounding and() call or else returndatasize() will be zero during the computation.\n                call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n            )\n        }\n\n        require(success, \"TRANSFER_FAILED\");\n    }\n\n    function safeApprove(\n        ERC20 token,\n        address to,\n        uint256 amount\n    ) internal {\n        bool success;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            // Get a pointer to some free memory.\n            let freeMemoryPointer := mload(0x40)\n\n            // Write the abi-encoded calldata into memory, beginning with the function selector.\n            mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\n            mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n            mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n            success := and(\n                // Set success to whether the call reverted, if not we check it either\n                // returned exactly 1 (can't just be non-zero data), or had no return data.\n                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n                // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n                // Counterintuitively, this call must be positioned second to the or() call in the\n                // surrounding and() call or else returndatasize() will be zero during the computation.\n                call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n            )\n        }\n\n        require(success, \"APPROVE_FAILED\");\n    }\n}\n"
      },
      "src/interfaces/IRewardsCollector.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.15;\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\n\n/// @title LooksRare Rewards Collector\n/// @notice Implements a permissionless call to fetch LooksRare rewards earned by Universal Router users\n/// and transfers them to an external rewards distributor contract\ninterface IRewardsCollector {\n    /// @notice Fetches users' LooksRare rewards and sends them to the distributor contract\n    /// @param looksRareClaim The data required by LooksRare to claim reward tokens\n    function collectRewards(bytes calldata looksRareClaim) external;\n}\n"
      },
      "src/interfaces/IWETH9.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.4;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title Interface for WETH9\ninterface IWETH9 is IERC20 {\n    /// @notice Deposit ether to get wrapped ether\n    function deposit() external payable;\n\n    /// @notice Withdraw wrapped ether to get ether\n    function withdraw(uint256) external;\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Receiver.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n    /**\n     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n     * by `operator` from `from`, this function is called.\n     *\n     * It must return its Solidity selector to confirm the token transfer.\n     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n     *\n     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n     */\n    function onERC721Received(\n        address operator,\n        address from,\n        uint256 tokenId,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC1155/IERC1155Receiver.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ninterface IERC1155Receiver is IERC165 {\n    /**\n     * @dev Handles the receipt of a single ERC1155 token type. This function is\n     * called at the end of a `safeTransferFrom` after the balance has been updated.\n     *\n     * NOTE: To accept the transfer, this must return\n     * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n     * (i.e. 0xf23a6e61, or its own function selector).\n     *\n     * @param operator The address which initiated the transfer (i.e. msg.sender)\n     * @param from The address which previously owned the token\n     * @param id The ID of the token being transferred\n     * @param value The amount of tokens being transferred\n     * @param data Additional data with no specified format\n     * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n     */\n    function onERC1155Received(\n        address operator,\n        address from,\n        uint256 id,\n        uint256 value,\n        bytes calldata data\n    ) external returns (bytes4);\n\n    /**\n     * @dev Handles the receipt of a multiple ERC1155 token types. This function\n     * is called at the end of a `safeBatchTransferFrom` after the balances have\n     * been updated.\n     *\n     * NOTE: To accept the transfer(s), this must return\n     * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n     * (i.e. 0xbc197c81, or its own function selector).\n     *\n     * @param operator The address which initiated the batch transfer (i.e. msg.sender)\n     * @param from The address which previously owned the token\n     * @param ids An array containing ids of each token being transferred (order and length must match values array)\n     * @param values An array containing amounts of each token being transferred (order and length must match ids array)\n     * @param data Additional data with no specified format\n     * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n     */\n    function onERC1155BatchReceived(\n        address operator,\n        address from,\n        uint256[] calldata ids,\n        uint256[] calldata values,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
      },
      "src/modules/Permit2Payments.sol": {
        "content": "pragma solidity ^0.8.17;\n\nimport {IAllowanceTransfer} from \"../permit2/src/interfaces/IAllowanceTransfer.sol\";\nimport {SafeCast160} from \"../permit2/src/libraries/SafeCast160.sol\";\nimport {Payments} from \"./Payments.sol\";\nimport {Constants} from \"../libraries/Constants.sol\";\nimport {RouterImmutables} from \"../base/RouterImmutables.sol\";\n\n/// @title Payments through Permit2\n/// @notice Performs interactions with Permit2 to transfer tokens\nabstract contract Permit2Payments is Payments {\n    using SafeCast160 for uint256;\n\n    error FromAddressIsNotOwner();\n\n    /// @notice Performs a transferFrom on Permit2\n    /// @param token The token to transfer\n    /// @param from The address to transfer from\n    /// @param to The recipient of the transfer\n    /// @param amount The amount to transfer\n    function permit2TransferFrom(address token, address from, address to, uint160 amount) internal {\n        PERMIT2.transferFrom(from, to, amount, token);\n    }\n\n    /// @notice Performs a batch transferFrom on Permit2\n    /// @param batchDetails An array detailing each of the transfers that should occur\n    function permit2TransferFrom(IAllowanceTransfer.AllowanceTransferDetails[] memory batchDetails, address owner)\n        internal\n    {\n        uint256 batchLength = batchDetails.length;\n        for (uint256 i = 0; i < batchLength; ++i) {\n            if (batchDetails[i].from != owner) revert FromAddressIsNotOwner();\n        }\n        PERMIT2.transferFrom(batchDetails);\n    }\n\n    /// @notice Either performs a regular payment or transferFrom on Permit2, depending on the payer address\n    /// @param token The token to transfer\n    /// @param payer The address to pay for the transfer\n    /// @param recipient The recipient of the transfer\n    /// @param amount The amount to transfer\n    function payOrPermit2Transfer(address token, address payer, address recipient, uint256 amount) internal {\n        if (payer == address(this)) pay(token, recipient, amount);\n        else permit2TransferFrom(token, payer, recipient, amount.toUint160());\n    }\n}\n"
      },
      "src/libraries/UniversalRouterHelper.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.8.0;\n\nimport {IUniswapV2Pair} from \"../modules/pancakeswap/v2/interfaces/IUniswapV2Pair.sol\";\nimport {IPancakeV3Pool} from \"../modules/pancakeswap/v3/interfaces/IPancakeV3Pool.sol\";\nimport {IStableSwapFactory} from \"../interfaces/IStableSwapFactory.sol\";\nimport {IStableSwapInfo} from \"../interfaces/IStableSwapInfo.sol\";\nimport {BytesLib} from \"./BytesLib.sol\";\nimport {Constants} from \"./Constants.sol\";\n\nlibrary UniversalRouterHelper {\n    using BytesLib for bytes;\n\n    error InvalidPoolAddress();\n    error InvalidPoolLength();\n    error InvalidReserves();\n    error InvalidPath();\n\n    /**\n     * Stable *************************************************\n     */\n\n    // get the pool info in stable swap\n    function getStableInfo(address stableSwapFactory, address input, address output, uint256 flag)\n        internal\n        view\n        returns (uint256 i, uint256 j, address swapContract)\n    {\n        if (flag == 2) {\n            IStableSwapFactory.StableSwapPairInfo memory info =\n                IStableSwapFactory(stableSwapFactory).getPairInfo(input, output);\n            i = input == info.token0 ? 0 : 1;\n            j = (i == 0) ? 1 : 0;\n            swapContract = info.swapContract;\n        } else if (flag == 3) {\n            IStableSwapFactory.StableSwapThreePoolPairInfo memory info =\n                IStableSwapFactory(stableSwapFactory).getThreePoolPairInfo(input, output);\n\n            if (input == info.token0) i = 0;\n            else if (input == info.token1) i = 1;\n            else if (input == info.token2) i = 2;\n\n            if (output == info.token0) j = 0;\n            else if (output == info.token1) j = 1;\n            else if (output == info.token2) j = 2;\n\n            swapContract = info.swapContract;\n        }\n\n        if (swapContract == address(0)) revert InvalidPoolAddress();\n    }\n\n    function getStableAmountsIn(\n        address stableSwapFactory,\n        address stableSwapInfo,\n        address[] calldata path,\n        uint256[] calldata flag,\n        uint256 amountOut\n    ) internal view returns (uint256[] memory amounts) {\n        uint256 length = path.length;\n        if (length < 2) revert InvalidPoolLength();\n\n        amounts = new uint256[](length);\n        amounts[length - 1] = amountOut;\n\n        for (uint256 i = length - 1; i > 0; i--) {\n            uint256 last = i - 1;\n            (uint256 k, uint256 j, address swapContract) =\n                getStableInfo(stableSwapFactory, path[last], path[i], flag[last]);\n            amounts[last] = IStableSwapInfo(stableSwapInfo).get_dx(swapContract, k, j, amounts[i], type(uint256).max);\n        }\n    }\n\n    /**\n     * V2 *************************************************\n     */\n    /// @notice Sorts two tokens to return token0 and token1\n    /// @param tokenA The first token to sort\n    /// @param tokenB The other token to sort\n    /// @return token0 The smaller token by address value\n    /// @return token1 The larger token by address value\n    function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {\n        (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);\n    }\n\n    /// @notice Calculates the v2 address for a pair assuming the input tokens are pre-sorted\n    /// @param factory The address of the v2 factory\n    /// @param initCodeHash The hash of the pair initcode\n    /// @param token0 The pair's token0\n    /// @param token1 The pair's token1\n    /// @return pair The resultant v2 pair address\n    function pairForPreSorted(address factory, bytes32 initCodeHash, address token0, address token1)\n        private\n        pure\n        returns (address pair)\n    {\n        pair = address(\n            uint160(\n                uint256(\n                    keccak256(\n                        abi.encodePacked(hex\"ff\", factory, keccak256(abi.encodePacked(token0, token1)), initCodeHash)\n                    )\n                )\n            )\n        );\n    }\n\n    /// @notice Calculates the v2 address for a pair without making any external calls\n    /// @param factory The address of the v2 factory\n    /// @param initCodeHash The hash of the pair initcode\n    /// @param tokenA One of the tokens in the pair\n    /// @param tokenB The other token in the pair\n    /// @return pair The resultant v2 pair address\n    function pairFor(address factory, bytes32 initCodeHash, address tokenA, address tokenB)\n        internal\n        pure\n        returns (address pair)\n    {\n        (address token0, address token1) = sortTokens(tokenA, tokenB);\n        pair = pairForPreSorted(factory, initCodeHash, token0, token1);\n    }\n\n    /// @notice Calculates the v2 address for a pair and the pair's token0\n    /// @param factory The address of the v2 factory\n    /// @param initCodeHash The hash of the pair initcode\n    /// @param tokenA One of the tokens in the pair\n    /// @param tokenB The other token in the pair\n    /// @return pair The resultant v2 pair address\n    /// @return token0 The token considered token0 in this pair\n    function pairAndToken0For(address factory, bytes32 initCodeHash, address tokenA, address tokenB)\n        internal\n        pure\n        returns (address pair, address token0)\n    {\n        address token1;\n        (token0, token1) = sortTokens(tokenA, tokenB);\n        pair = pairForPreSorted(factory, initCodeHash, token0, token1);\n    }\n\n    /// @notice Calculates the v2 address for a pair and fetches the reserves for each token\n    /// @param factory The address of the v2 factory\n    /// @param initCodeHash The hash of the pair initcode\n    /// @param tokenA One of the tokens in the pair\n    /// @param tokenB The other token in the pair\n    /// @return pair The resultant v2 pair address\n    /// @return reserveA The reserves for tokenA\n    /// @return reserveB The reserves for tokenB\n    function pairAndReservesFor(address factory, bytes32 initCodeHash, address tokenA, address tokenB)\n        private\n        view\n        returns (address pair, uint256 reserveA, uint256 reserveB)\n    {\n        address token0;\n        (pair, token0) = pairAndToken0For(factory, initCodeHash, tokenA, tokenB);\n        (uint256 reserve0, uint256 reserve1,) = IUniswapV2Pair(pair).getReserves();\n        (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);\n    }\n\n    /// @notice Given an input asset amount returns the maximum output amount of the other asset\n    /// @param amountIn The token input amount\n    /// @param reserveIn The reserves available of the input token\n    /// @param reserveOut The reserves available of the output token\n    /// @return amountOut The output amount of the output token\n    function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut)\n        internal\n        pure\n        returns (uint256 amountOut)\n    {\n        if (reserveIn == 0 || reserveOut == 0) revert InvalidReserves();\n        uint256 amountInWithFee = amountIn * 9975;\n        uint256 numerator = amountInWithFee * reserveOut;\n        uint256 denominator = reserveIn * 10000 + amountInWithFee;\n        amountOut = numerator / denominator;\n    }\n\n    /// @notice Returns the input amount needed for a desired output amount in a single-hop trade\n    /// @param amountOut The desired output amount\n    /// @param reserveIn The reserves available of the input token\n    /// @param reserveOut The reserves available of the output token\n    /// @return amountIn The input amount of the input token\n    function getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut)\n        internal\n        pure\n        returns (uint256 amountIn)\n    {\n        if (reserveIn == 0 || reserveOut == 0) revert InvalidReserves();\n        uint256 numerator = reserveIn * amountOut * 10000;\n        uint256 denominator = (reserveOut - amountOut) * 9975;\n        amountIn = (numerator / denominator) + 1;\n    }\n\n    /// @notice Returns the input amount needed for a desired output amount in a multi-hop trade\n    /// @param factory The address of the v2 factory\n    /// @param initCodeHash The hash of the pair initcode\n    /// @param amountOut The desired output amount\n    /// @param path The path of the multi-hop trade\n    /// @return amount The input amount of the input token\n    /// @return pair The first pair in the trade\n    function getAmountInMultihop(address factory, bytes32 initCodeHash, uint256 amountOut, address[] calldata path)\n        internal\n        view\n        returns (uint256 amount, address pair)\n    {\n        if (path.length < 2) revert InvalidPath();\n        amount = amountOut;\n        for (uint256 i = path.length - 1; i > 0; i--) {\n            uint256 reserveIn;\n            uint256 reserveOut;\n\n            (pair, reserveIn, reserveOut) = pairAndReservesFor(factory, initCodeHash, path[i - 1], path[i]);\n            amount = getAmountIn(amount, reserveIn, reserveOut);\n        }\n    }\n\n    /**\n     * V3 *************************************************\n     */\n    /// @notice Returns true iff the path contains two or more pools\n    /// @param path The encoded swap path\n    /// @return True if path contains two or more pools, otherwise false\n    function hasMultiplePools(bytes calldata path) internal pure returns (bool) {\n        return path.length >= Constants.MULTIPLE_V3_POOLS_MIN_LENGTH;\n    }\n\n    /// @notice Decodes the first pool in path\n    /// @param path The bytes encoded swap path\n    /// @return tokenA The first token of the given pool\n    /// @return fee The fee level of the pool\n    /// @return tokenB The second token of the given pool\n    function decodeFirstPool(bytes calldata path) internal pure returns (address, uint24, address) {\n        return path.toPool();\n    }\n\n    /// @notice Gets the segment corresponding to the first pool in the path\n    /// @param path The bytes encoded swap path\n    /// @return The segment containing all data necessary to target the first pool in the path\n    function getFirstPool(bytes calldata path) internal pure returns (bytes calldata) {\n        return path[:Constants.V3_POP_OFFSET];\n    }\n\n    function decodeFirstToken(bytes calldata path) internal pure returns (address tokenA) {\n        tokenA = path.toAddress();\n    }\n\n    /// @notice Skips a token + fee element\n    /// @param path The swap path\n    function skipToken(bytes calldata path) internal pure returns (bytes calldata) {\n        return path[Constants.NEXT_V3_POOL_OFFSET:];\n    }\n\n    function computePoolAddress(address deployer, bytes32 initCodeHash, address tokenA, address tokenB, uint24 fee)\n        internal\n        pure\n        returns (address pool)\n    {\n        if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);\n        pool = address(\n            uint160(\n                uint256(\n                    keccak256(\n                        abi.encodePacked(hex\"ff\", deployer, keccak256(abi.encode(tokenA, tokenB, fee)), initCodeHash)\n                    )\n                )\n            )\n        );\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/access/Ownable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor() {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
      },
      "src/interfaces/IStableSwap.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IStableSwap {\n    // solium-disable-next-line mixedcase\n    function get_dy(uint256 i, uint256 j, uint256 dx) external view returns (uint256 dy);\n\n    // solium-disable-next-line mixedcase\n    function exchange(uint256 i, uint256 j, uint256 dx, uint256 minDy) external payable;\n\n    // solium-disable-next-line mixedcase\n    function coins(uint256 i) external view returns (address);\n\n    // solium-disable-next-line mixedcase\n    function balances(uint256 i) external view returns (uint256);\n\n    // solium-disable-next-line mixedcase\n    function A() external view returns (uint256);\n\n    // solium-disable-next-line mixedcase\n    function fee() external view returns (uint256);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n}\n"
      },
      "src/modules/pancakeswap/v2/interfaces/IUniswapV2Pair.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity >=0.5.0;\n\ninterface IUniswapV2Pair {\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    function name() external pure returns (string memory);\n    function symbol() external pure returns (string memory);\n    function decimals() external pure returns (uint8);\n    function totalSupply() external view returns (uint256);\n    function balanceOf(address owner) external view returns (uint256);\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    function approve(address spender, uint256 value) external returns (bool);\n    function transfer(address to, uint256 value) external returns (bool);\n    function transferFrom(address from, address to, uint256 value) external returns (bool);\n\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n    function PERMIT_TYPEHASH() external pure returns (bytes32);\n    function nonces(address owner) external view returns (uint256);\n\n    function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)\n        external;\n\n    event Mint(address indexed sender, uint256 amount0, uint256 amount1);\n    event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);\n    event Swap(\n        address indexed sender,\n        uint256 amount0In,\n        uint256 amount1In,\n        uint256 amount0Out,\n        uint256 amount1Out,\n        address indexed to\n    );\n    event Sync(uint112 reserve0, uint112 reserve1);\n\n    function MINIMUM_LIQUIDITY() external pure returns (uint256);\n    function factory() external view returns (address);\n    function token0() external view returns (address);\n    function token1() external view returns (address);\n    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\n    function price0CumulativeLast() external view returns (uint256);\n    function price1CumulativeLast() external view returns (uint256);\n    function kLast() external view returns (uint256);\n\n    function mint(address to) external returns (uint256 liquidity);\n    function burn(address to) external returns (uint256 amount0, uint256 amount1);\n    function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;\n    function skim(address to) external;\n    function sync() external;\n\n    function initialize(address, address) external;\n}\n"
      },
      "src/modules/pancakeswap/v3/SafeCast.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Safe casting methods\n/// @notice Contains methods for safely casting between types\nlibrary SafeCast {\n    /// @notice Cast a uint256 to a uint160, revert on overflow\n    /// @param y The uint256 to be downcasted\n    /// @return z The downcasted integer, now type uint160\n    function toUint160(uint256 y) internal pure returns (uint160 z) {\n        require((z = uint160(y)) == y);\n    }\n\n    /// @notice Cast a int256 to a int128, revert on overflow or underflow\n    /// @param y The int256 to be downcasted\n    /// @return z The downcasted integer, now type int128\n    function toInt128(int256 y) internal pure returns (int128 z) {\n        require((z = int128(y)) == y);\n    }\n\n    /// @notice Cast a uint256 to a int256, revert on overflow\n    /// @param y The uint256 to be casted\n    /// @return z The casted integer, now type int256\n    function toInt256(uint256 y) internal pure returns (int256 z) {\n        require(y < 2 ** 255);\n        z = int256(y);\n    }\n}\n"
      },
      "src/modules/pancakeswap/v3/interfaces/IPancakeV3Pool.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\nimport \"./pool/IPancakeV3PoolImmutables.sol\";\nimport \"./pool/IPancakeV3PoolState.sol\";\nimport \"./pool/IPancakeV3PoolDerivedState.sol\";\nimport \"./pool/IPancakeV3PoolActions.sol\";\nimport \"./pool/IPancakeV3PoolOwnerActions.sol\";\nimport \"./pool/IPancakeV3PoolEvents.sol\";\n\n/// @title The interface for a PancakeSwap V3 Pool\n/// @notice A PancakeSwap pool facilitates swapping and automated market making between any two assets that strictly conform\n/// to the ERC20 specification\n/// @dev The pool interface is broken up into many smaller pieces\ninterface IPancakeV3Pool is\n    IPancakeV3PoolImmutables,\n    IPancakeV3PoolState,\n    IPancakeV3PoolDerivedState,\n    IPancakeV3PoolActions,\n    IPancakeV3PoolOwnerActions,\n    IPancakeV3PoolEvents\n{}\n"
      },
      "src/modules/pancakeswap/v3/interfaces/IPancakeV3SwapCallback.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IPancakeV3PoolActions#swap\n/// @notice Any contract that calls IPancakeV3PoolActions#swap must implement this interface\ninterface IPancakeV3SwapCallback {\n    /// @notice Called to `msg.sender` after executing a swap via IPancakeV3Pool#swap.\n    /// @dev In the implementation you must pay the pool tokens owed for the swap.\n    /// The caller of this method must be checked to be a PancakeV3Pool deployed by the canonical PancakeV3Factory.\n    /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n    /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n    /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n    /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n    /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n    /// @param data Any data passed through by the caller via the IPancakeV3PoolActions#swap call\n    function pancakeV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external;\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) external returns (bool);\n}\n"
      },
      "src/permit2/src/libraries/SafeCast160.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\nlibrary SafeCast160 {\n    /// @notice Thrown when a valude greater than type(uint160).max is cast to uint160\n    error UnsafeCast();\n\n    /// @notice Safely casts uint256 to uint160\n    /// @param value The uint256 to be cast\n    function toUint160(uint256 value) internal pure returns (uint160) {\n        if (value > type(uint160).max) revert UnsafeCast();\n        return uint160(value);\n    }\n}\n"
      },
      "src/interfaces/IStableSwapFactory.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IStableSwapFactory {\n    struct StableSwapPairInfo {\n        address swapContract;\n        address token0;\n        address token1;\n        address LPContract;\n    }\n\n    struct StableSwapThreePoolPairInfo {\n        address swapContract;\n        address token0;\n        address token1;\n        address token2;\n        address LPContract;\n    }\n\n    // solium-disable-next-line mixedcase\n    function pairLength() external view returns (uint256);\n\n    function getPairInfo(address _tokenA, address _tokenB) external view returns (StableSwapPairInfo memory info);\n\n    function getThreePoolPairInfo(address _tokenA, address _tokenB)\n        external\n        view\n        returns (StableSwapThreePoolPairInfo memory info);\n}\n"
      },
      "src/interfaces/IStableSwapInfo.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IStableSwapInfo {\n    function get_dx(address _swap, uint256 i, uint256 j, uint256 dy, uint256 max_dx) external view returns (uint256);\n}\n"
      },
      "src/modules/pancakeswap/v3/interfaces/pool/IPancakeV3PoolImmutables.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that never changes\n/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values\ninterface IPancakeV3PoolImmutables {\n    /// @notice The contract that deployed the pool, which must adhere to the IPancakeV3Factory interface\n    /// @return The contract address\n    function factory() external view returns (address);\n\n    /// @notice The first of the two tokens of the pool, sorted by address\n    /// @return The token contract address\n    function token0() external view returns (address);\n\n    /// @notice The second of the two tokens of the pool, sorted by address\n    /// @return The token contract address\n    function token1() external view returns (address);\n\n    /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6\n    /// @return The fee\n    function fee() external view returns (uint24);\n\n    /// @notice The pool tick spacing\n    /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive\n    /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...\n    /// This value is an int24 to avoid casting even though it is always positive.\n    /// @return The tick spacing\n    function tickSpacing() external view returns (int24);\n\n    /// @notice The maximum amount of position liquidity that can use any tick in the range\n    /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and\n    /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool\n    /// @return The max amount of liquidity per tick\n    function maxLiquidityPerTick() external view returns (uint128);\n}\n"
      },
      "src/modules/pancakeswap/v3/interfaces/pool/IPancakeV3PoolState.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that can change\n/// @notice These methods compose the pool's state, and can change with any frequency including multiple times\n/// per transaction\ninterface IPancakeV3PoolState {\n    /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas\n    /// when accessed externally.\n    /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value\n    /// tick The current tick of the pool, i.e. according to the last tick transition that was run.\n    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick\n    /// boundary.\n    /// observationIndex The index of the last oracle observation that was written,\n    /// observationCardinality The current maximum number of observations stored in the pool,\n    /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.\n    /// feeProtocol The protocol fee for both tokens of the pool.\n    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0\n    /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.\n    /// unlocked Whether the pool is currently locked to reentrancy\n    function slot0()\n        external\n        view\n        returns (\n            uint160 sqrtPriceX96,\n            int24 tick,\n            uint16 observationIndex,\n            uint16 observationCardinality,\n            uint16 observationCardinalityNext,\n            uint32 feeProtocol,\n            bool unlocked\n        );\n\n    /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool\n    /// @dev This value can overflow the uint256\n    function feeGrowthGlobal0X128() external view returns (uint256);\n\n    /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool\n    /// @dev This value can overflow the uint256\n    function feeGrowthGlobal1X128() external view returns (uint256);\n\n    /// @notice The amounts of token0 and token1 that are owed to the protocol\n    /// @dev Protocol fees will never exceed uint128 max in either token\n    function protocolFees() external view returns (uint128 token0, uint128 token1);\n\n    /// @notice The currently in range liquidity available to the pool\n    /// @dev This value has no relationship to the total liquidity across all ticks\n    function liquidity() external view returns (uint128);\n\n    /// @notice Look up information about a specific tick in the pool\n    /// @param tick The tick to look up\n    /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or\n    /// tick upper,\n    /// liquidityNet how much liquidity changes when the pool price crosses the tick,\n    /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,\n    /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,\n    /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick\n    /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,\n    /// secondsOutside the seconds spent on the other side of the tick from the current tick,\n    /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.\n    /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.\n    /// In addition, these values are only relative and must be used only in comparison to previous snapshots for\n    /// a specific position.\n    function ticks(int24 tick)\n        external\n        view\n        returns (\n            uint128 liquidityGross,\n            int128 liquidityNet,\n            uint256 feeGrowthOutside0X128,\n            uint256 feeGrowthOutside1X128,\n            int56 tickCumulativeOutside,\n            uint160 secondsPerLiquidityOutsideX128,\n            uint32 secondsOutside,\n            bool initialized\n        );\n\n    /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information\n    function tickBitmap(int16 wordPosition) external view returns (uint256);\n\n    /// @notice Returns the information about a position by the position's key\n    /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper\n    /// @return _liquidity The amount of liquidity in the position,\n    /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,\n    /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,\n    /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,\n    /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke\n    function positions(bytes32 key)\n        external\n        view\n        returns (\n            uint128 _liquidity,\n            uint256 feeGrowthInside0LastX128,\n            uint256 feeGrowthInside1LastX128,\n            uint128 tokensOwed0,\n            uint128 tokensOwed1\n        );\n\n    /// @notice Returns data about a specific observation index\n    /// @param index The element of the observations array to fetch\n    /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time\n    /// ago, rather than at a specific index in the array.\n    /// @return blockTimestamp The timestamp of the observation,\n    /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,\n    /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,\n    /// Returns initialized whether the observation has been initialized and the values are safe to use\n    function observations(uint256 index)\n        external\n        view\n        returns (\n            uint32 blockTimestamp,\n            int56 tickCumulative,\n            uint160 secondsPerLiquidityCumulativeX128,\n            bool initialized\n        );\n}\n"
      },
      "src/modules/pancakeswap/v3/interfaces/pool/IPancakeV3PoolDerivedState.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that is not stored\n/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the\n/// blockchain. The functions here may have variable gas costs.\ninterface IPancakeV3PoolDerivedState {\n    /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp\n    /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing\n    /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,\n    /// you must call it with secondsAgos = [3600, 0].\n    /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in\n    /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.\n    /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned\n    /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp\n    /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block\n    /// timestamp\n    function observe(uint32[] calldata secondsAgos)\n        external\n        view\n        returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);\n\n    /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range\n    /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.\n    /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first\n    /// snapshot is taken and the second snapshot is taken.\n    /// @param tickLower The lower tick of the range\n    /// @param tickUpper The upper tick of the range\n    /// @return tickCumulativeInside The snapshot of the tick accumulator for the range\n    /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range\n    /// @return secondsInside The snapshot of seconds per liquidity for the range\n    function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)\n        external\n        view\n        returns (int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside);\n}\n"
      },
      "src/modules/pancakeswap/v3/interfaces/pool/IPancakeV3PoolActions.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Permissionless pool actions\n/// @notice Contains pool methods that can be called by anyone\ninterface IPancakeV3PoolActions {\n    /// @notice Sets the initial price for the pool\n    /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\n    /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96\n    function initialize(uint160 sqrtPriceX96) external;\n\n    /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position\n    /// @dev The caller of this method receives a callback in the form of IPancakeV3MintCallback#pancakeV3MintCallback\n    /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\n    /// on tickLower, tickUpper, the amount of liquidity, and the current price.\n    /// @param recipient The address for which the liquidity will be created\n    /// @param tickLower The lower tick of the position in which to add liquidity\n    /// @param tickUpper The upper tick of the position in which to add liquidity\n    /// @param amount The amount of liquidity to mint\n    /// @param data Any data that should be passed through to the callback\n    /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\n    /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\n    function mint(address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data)\n        external\n        returns (uint256 amount0, uint256 amount1);\n\n    /// @notice Collects tokens owed to a position\n    /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\n    /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\n    /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\n    /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\n    /// @param recipient The address which should receive the fees collected\n    /// @param tickLower The lower tick of the position for which to collect fees\n    /// @param tickUpper The upper tick of the position for which to collect fees\n    /// @param amount0Requested How much token0 should be withdrawn from the fees owed\n    /// @param amount1Requested How much token1 should be withdrawn from the fees owed\n    /// @return amount0 The amount of fees collected in token0\n    /// @return amount1 The amount of fees collected in token1\n    function collect(\n        address recipient,\n        int24 tickLower,\n        int24 tickUpper,\n        uint128 amount0Requested,\n        uint128 amount1Requested\n    ) external returns (uint128 amount0, uint128 amount1);\n\n    /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\n    /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\n    /// @dev Fees must be collected separately via a call to #collect\n    /// @param tickLower The lower tick of the position for which to burn liquidity\n    /// @param tickUpper The upper tick of the position for which to burn liquidity\n    /// @param amount How much liquidity to burn\n    /// @return amount0 The amount of token0 sent to the recipient\n    /// @return amount1 The amount of token1 sent to the recipient\n    function burn(int24 tickLower, int24 tickUpper, uint128 amount)\n        external\n        returns (uint256 amount0, uint256 amount1);\n\n    /// @notice Swap token0 for token1, or token1 for token0\n    /// @dev The caller of this method receives a callback in the form of IPancakeV3SwapCallback#pancakeV3SwapCallback\n    /// @param recipient The address to receive the output of the swap\n    /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0\n    /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\n    /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\n    /// value after the swap. If one for zero, the price cannot be greater than this value after the swap\n    /// @param data Any data to be passed through to the callback\n    /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\n    /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\n    function swap(\n        address recipient,\n        bool zeroForOne,\n        int256 amountSpecified,\n        uint160 sqrtPriceLimitX96,\n        bytes calldata data\n    ) external returns (int256 amount0, int256 amount1);\n\n    /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\n    /// @dev The caller of this method receives a callback in the form of IPancakeV3FlashCallback#pancakeV3FlashCallback\n    /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling\n    /// with 0 amount{0,1} and sending the donation amount(s) from the callback\n    /// @param recipient The address which will receive the token0 and token1 amounts\n    /// @param amount0 The amount of token0 to send\n    /// @param amount1 The amount of token1 to send\n    /// @param data Any data to be passed through to the callback\n    function flash(address recipient, uint256 amount0, uint256 amount1, bytes calldata data) external;\n\n    /// @notice Increase the maximum number of price and liquidity observations that this pool will store\n    /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\n    /// the input observationCardinalityNext.\n    /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\n    function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\n}\n"
      },
      "src/modules/pancakeswap/v3/interfaces/pool/IPancakeV3PoolOwnerActions.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Permissioned pool actions\n/// @notice Contains pool methods that may only be called by the factory owner\ninterface IPancakeV3PoolOwnerActions {\n    /// @notice Set the denominator of the protocol's % share of the fees\n    /// @param feeProtocol0 new protocol fee for token0 of the pool\n    /// @param feeProtocol1 new protocol fee for token1 of the pool\n    function setFeeProtocol(uint32 feeProtocol0, uint32 feeProtocol1) external;\n\n    /// @notice Collect the protocol fee accrued to the pool\n    /// @param recipient The address to which collected protocol fees should be sent\n    /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1\n    /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0\n    /// @return amount0 The protocol fee collected in token0\n    /// @return amount1 The protocol fee collected in token1\n    function collectProtocol(address recipient, uint128 amount0Requested, uint128 amount1Requested)\n        external\n        returns (uint128 amount0, uint128 amount1);\n\n    /// @notice Set the LM pool to enable liquidity mining\n    function setLmPool(address lmPool) external;\n}\n"
      },
      "src/modules/pancakeswap/v3/interfaces/pool/IPancakeV3PoolEvents.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Events emitted by a pool\n/// @notice Contains all events emitted by the pool\ninterface IPancakeV3PoolEvents {\n    /// @notice Emitted exactly once by a pool when #initialize is first called on the pool\n    /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize\n    /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96\n    /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool\n    event Initialize(uint160 sqrtPriceX96, int24 tick);\n\n    /// @notice Emitted when liquidity is minted for a given position\n    /// @param sender The address that minted the liquidity\n    /// @param owner The owner of the position and recipient of any minted liquidity\n    /// @param tickLower The lower tick of the position\n    /// @param tickUpper The upper tick of the position\n    /// @param amount The amount of liquidity minted to the position range\n    /// @param amount0 How much token0 was required for the minted liquidity\n    /// @param amount1 How much token1 was required for the minted liquidity\n    event Mint(\n        address sender,\n        address indexed owner,\n        int24 indexed tickLower,\n        int24 indexed tickUpper,\n        uint128 amount,\n        uint256 amount0,\n        uint256 amount1\n    );\n\n    /// @notice Emitted when fees are collected by the owner of a position\n    /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees\n    /// @param owner The owner of the position for which fees are collected\n    /// @param tickLower The lower tick of the position\n    /// @param tickUpper The upper tick of the position\n    /// @param amount0 The amount of token0 fees collected\n    /// @param amount1 The amount of token1 fees collected\n    event Collect(\n        address indexed owner,\n        address recipient,\n        int24 indexed tickLower,\n        int24 indexed tickUpper,\n        uint128 amount0,\n        uint128 amount1\n    );\n\n    /// @notice Emitted when a position's liquidity is removed\n    /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect\n    /// @param owner The owner of the position for which liquidity is removed\n    /// @param tickLower The lower tick of the position\n    /// @param tickUpper The upper tick of the position\n    /// @param amount The amount of liquidity to remove\n    /// @param amount0 The amount of token0 withdrawn\n    /// @param amount1 The amount of token1 withdrawn\n    event Burn(\n        address indexed owner,\n        int24 indexed tickLower,\n        int24 indexed tickUpper,\n        uint128 amount,\n        uint256 amount0,\n        uint256 amount1\n    );\n\n    /// @notice Emitted by the pool for any swaps between token0 and token1\n    /// @param sender The address that initiated the swap call, and that received the callback\n    /// @param recipient The address that received the output of the swap\n    /// @param amount0 The delta of the token0 balance of the pool\n    /// @param amount1 The delta of the token1 balance of the pool\n    /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96\n    /// @param liquidity The liquidity of the pool after the swap\n    /// @param tick The log base 1.0001 of price of the pool after the swap\n    /// @param protocolFeesToken0 The protocol fee of token0 in the swap\n    /// @param protocolFeesToken1 The protocol fee of token1 in the swap\n    event Swap(\n        address indexed sender,\n        address indexed recipient,\n        int256 amount0,\n        int256 amount1,\n        uint160 sqrtPriceX96,\n        uint128 liquidity,\n        int24 tick,\n        uint128 protocolFeesToken0,\n        uint128 protocolFeesToken1\n    );\n\n    /// @notice Emitted by the pool for any flashes of token0/token1\n    /// @param sender The address that initiated the swap call, and that received the callback\n    /// @param recipient The address that received the tokens from flash\n    /// @param amount0 The amount of token0 that was flashed\n    /// @param amount1 The amount of token1 that was flashed\n    /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee\n    /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee\n    event Flash(\n        address indexed sender,\n        address indexed recipient,\n        uint256 amount0,\n        uint256 amount1,\n        uint256 paid0,\n        uint256 paid1\n    );\n\n    /// @notice Emitted by the pool for increases to the number of observations that can be stored\n    /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index\n    /// just before a mint/swap/burn.\n    /// @param observationCardinalityNextOld The previous value of the next observation cardinality\n    /// @param observationCardinalityNextNew The updated value of the next observation cardinality\n    event IncreaseObservationCardinalityNext(\n        uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew\n    );\n\n    /// @notice Emitted when the protocol fee is changed by the pool\n    /// @param feeProtocol0Old The previous value of the token0 protocol fee\n    /// @param feeProtocol1Old The previous value of the token1 protocol fee\n    /// @param feeProtocol0New The updated value of the token0 protocol fee\n    /// @param feeProtocol1New The updated value of the token1 protocol fee\n    event SetFeeProtocol(\n        uint32 feeProtocol0Old, uint32 feeProtocol1Old, uint32 feeProtocol0New, uint32 feeProtocol1New\n    );\n\n    /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner\n    /// @param sender The address that collects the protocol fees\n    /// @param recipient The address that receives the collected protocol fees\n    /// @param amount0 The amount of token0 protocol fees that is withdrawn\n    /// @param amount0 The amount of token1 protocol fees that is withdrawn\n    event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "forge-std/=lib/forge-std/src/",
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "@openzeppelin/=lib/openzeppelin-contracts/",
        "solmate/=lib/solmate/src/",
        "openzeppelin-contracts/=lib/openzeppelin-contracts/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 10
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "ipfs"
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "london",
      "viaIR": true,
      "libraries": {}
    }
  }}