creation_sourcecode: {{
    "language": "Solidity",
    "settings": {
      "evmVersion": "paris",
      "libraries": {},
      "metadata": {
        "bytecodeHash": "ipfs",
        "useLiteralContent": true
      },
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "remappings": [],
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      }
    },
    "sources": {
      "contracts/MagpieRouterV2.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.22;\n\nimport {Ownable2Step} from \"openzeppelin-solidity/contracts/access/Ownable2Step.sol\";\nimport {Multicall} from \"openzeppelin-solidity/contracts/utils/Multicall.sol\";\nimport {IMagpieRouterV2} from \"./interfaces/IMagpieRouterV2.sol\";\nimport {LibAsset} from \"./libraries/LibAsset.sol\";\nimport {AppStorage, LibMagpieRouterV2} from \"./libraries/LibMagpieRouterV2.sol\";\nimport {LibSwap, SwapData} from \"./libraries/LibSwap.sol\";\nimport {LibCommand, CommandAction, CommandData} from \"./router/LibCommand.sol\";\nimport {LibUniswapV3} from \"./router/LibUniswapV3.sol\";\n\nerror ExpiredTransaction();\nerror InsufficientAmountOut();\nerror InvalidCall();\nerror InvalidCommand();\n\ncontract MagpieRouterV2 is IMagpieRouterV2, Ownable2Step, Multicall {\n    using LibAsset for address;\n\n    /// @dev See {IMagpieRouterV2-updateSelector}\n    function updateSelector(uint16 commandType, bytes4 selector) external onlyOwner {\n        AppStorage storage s = LibMagpieRouterV2.getStorage();\n\n        s.selectors[commandType] = selector;\n    }\n\n    /// @dev Enforces time constraints on certain operations within a smart contract.\n    /// @param deadline The timestamp in epochs beyond which the transaction will get expired.\n    function enforceDeadline(uint256 deadline) private view {\n        if (deadline < block.timestamp) {\n            revert ExpiredTransaction();\n        }\n    }\n\n    /// @dev Handle uniswapV3SwapCallback requests from any protocol that is based on UniswapV3. We dont check for factory since this contract is not supposed to store tokens. We protect the user by handling amountOutMin check at the end of execution by comparing starting and final balance at the destination address.\n    fallback() external {\n        int256 amount0Delta;\n        int256 amount1Delta;\n        address assetIn;\n        uint256 callDataSize;\n        assembly {\n            amount0Delta := calldataload(4)\n            amount1Delta := calldataload(36)\n            assetIn := shr(96, calldataload(132))\n            callDataSize := calldatasize()\n        }\n\n        if (callDataSize != 164) {\n            revert InvalidCall();\n        }\n\n        LibUniswapV3.uniswapV3SwapCallback(amount0Delta, amount1Delta, assetIn);\n    }\n\n    /// @dev Determinines whether a specific command action within a swap sequence involves moving tokens.\n    function isTokenMovement(CommandAction commandAction) private pure returns (bool) {\n        return\n            commandAction == CommandAction.Approval ||\n            commandAction == CommandAction.TransferFrom ||\n            commandAction == CommandAction.Transfer ||\n            commandAction == CommandAction.Wrap ||\n            commandAction == CommandAction.Unwrap;\n    }\n\n    /// @dev See {IMagpieRouterV2-estimateSwapGas}\n    function estimateSwapGas(bytes calldata) external payable returns (uint256 amountOut, uint256 gasUsed) {\n        (amountOut, gasUsed) = execute(true);\n    }\n\n    /// @dev See {IMagpieRouterV2-swap}\n    function swap(bytes calldata) external payable returns (uint256 amountOut) {\n        (amountOut, ) = execute(true);\n    }\n\n    /// @dev See {IMagpieRouterV2-silentSwap}\n    function silentSwap(bytes calldata) external payable returns (uint256 amountOut) {\n        (amountOut, ) = execute(false);\n    }\n\n    /// @dev Handles the execution of a sequence of commands for the swap operation.\n    /// @param triggerEvent An indicator if the function needs to trigger the swap event.\n    /// @return amountOut The amount received after swapping.\n    /// @return gasUsed The gas utilised during swapping.\n    function execute(bool triggerEvent) private returns (uint256 amountOut, uint256 gasUsed) {\n        SwapData memory swapData = LibSwap.getData(LibSwap.SWAP_ARGS_OFFSET);\n\n        enforceDeadline(swapData.deadline);\n\n        amountOut = swapData.toAssetAddress.getBalanceOf(swapData.toAddress);\n\n        bytes memory commandOutput = new bytes(swapData.outputsLength);\n        uint16 i;\n        CommandData memory commandData;\n        uint256 nativeAmount;\n        uint256 tmpAmount;\n        bytes memory input;\n\n        uint256 commandOutputOffset;\n        assembly {\n            commandOutputOffset := add(commandOutput, 32)\n        }\n\n        for (i = swapData.commandsOffset; i < swapData.commandsOffsetEnd; ) {\n            commandData = LibCommand.getData(i);\n\n            (nativeAmount, input) = LibCommand.getInput(commandOutput, commandData);\n\n            if (commandData.commandAction == CommandAction.Call) {\n                assembly {\n                    let outputLength := mload(add(commandData, 64))\n                    if iszero(\n                        call(\n                            gas(),\n                            mload(add(commandData, 160)),\n                            nativeAmount,\n                            add(input, 32),\n                            mload(input),\n                            commandOutputOffset,\n                            outputLength\n                        )\n                    ) {\n                        returndatacopy(0, 0, returndatasize())\n                        revert(0, returndatasize())\n                    }\n                    commandOutputOffset := add(commandOutputOffset, outputLength)\n                }\n            } else if (commandData.commandAction == CommandAction.Approval) {\n                LibCommand.approve(input);\n            } else if (commandData.commandAction == CommandAction.TransferFrom) {\n                LibCommand.transferFrom(input);\n            } else if (commandData.commandAction == CommandAction.Transfer) {\n                LibCommand.transfer(input);\n            } else if (commandData.commandAction == CommandAction.Wrap) {\n                LibCommand.wrap(input);\n            } else if (commandData.commandAction == CommandAction.Unwrap) {\n                LibCommand.unwrap(input);\n            } else if (commandData.commandAction == CommandAction.Balance) {\n                tmpAmount = LibCommand.balance(input);\n                assembly {\n                    mstore(commandOutputOffset, tmpAmount)\n                    commandOutputOffset := add(commandOutputOffset, 32)\n                }\n            } else if (commandData.commandAction == CommandAction.Math) {\n                tmpAmount = LibCommand.math(input);\n                assembly {\n                    mstore(commandOutputOffset, tmpAmount)\n                    commandOutputOffset := add(commandOutputOffset, 32)\n                }\n            } else if (commandData.commandAction == CommandAction.EstimateGasStart) {\n                gasUsed = gasleft();\n            } else if (commandData.commandAction == CommandAction.EstimateGasEnd) {\n                gasUsed -= gasleft();\n            } else {\n                revert InvalidCommand();\n            }\n\n            assembly {\n                if gt(commandOutputOffset, add(add(commandOutput, 32), mload(commandOutput))) {\n                    revert(0, 0)\n                }\n            }\n\n            unchecked {\n                i += 11;\n            }\n        }\n\n        amountOut = swapData.toAssetAddress.getBalanceOf(swapData.toAddress) - amountOut;\n\n        if (amountOut < swapData.amountOutMin) {\n            revert InsufficientAmountOut();\n        }\n\n        if (triggerEvent) {\n            emit Swap(\n                msg.sender,\n                swapData.toAddress,\n                swapData.fromAssetAddress,\n                swapData.toAssetAddress,\n                swapData.amountIn,\n                amountOut\n            );\n        }\n    }\n\n    /// @dev Used to receive ethers\n    receive() external payable {}\n}\n"
      },
      "contracts/interfaces/IMagpieRouterV2.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.22;\n\ninterface IMagpieRouterV2 {\n    /// @dev Allows the owner to update the mapping of command types to function selectors.\n    /// @param commandId Identifier for each command. We have one selector / command.\n    /// @param selector The function selector for each of these commands.\n    function updateSelector(uint16 commandId, bytes4 selector) external;\n\n    event Swap(\n        address indexed fromAddress,\n        address indexed toAddress,\n        address fromAssetAddress,\n        address toAssetAddress,\n        uint256 amountIn,\n        uint256 amountOut\n    );\n\n    /// @dev Provides an external interface to estimate the gas cost of the last hop in a route.\n    /// @return amountOut The amount received after swapping.\n    /// @return gasUsed The cost of gas while performing the swap.\n    function estimateSwapGas(bytes calldata swapArgs) external payable returns (uint256 amountOut, uint256 gasUsed);\n\n    /// @dev Performs token swap.\n    /// @return amountOut The amount received after swapping.\n    function swap(bytes calldata swapArgs) external payable returns (uint256 amountOut);\n\n    /// @dev Performs token swap without triggering event.\n    /// @return amountOut The amount received after swapping.\n    function silentSwap(bytes calldata swapArgs) external payable returns (uint256 amountOut);\n}\n"
      },
      "contracts/interfaces/IWETH.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.22;\n\ninterface IWETH {\n    function deposit() external payable;\n\n    function transfer(address to, uint256 value) external returns (bool);\n\n    function withdraw(uint256) external;\n}\n"
      },
      "contracts/libraries/LibAsset.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.22;\n\nimport \"openzeppelin-solidity/contracts/token/ERC20/IERC20.sol\";\nimport \"../interfaces/IWETH.sol\";\n\nerror AssetNotReceived();\nerror ApprovalFailed();\nerror TransferFromFailed();\nerror TransferFailed();\n\nlibrary LibAsset {\n    using LibAsset for address;\n\n    address constant NATIVE_ASSETID = address(0);\n\n    /// @dev Checks if the given address (self) represents a native asset (Ether).\n    /// @param self The asset that will be checked for a native token.\n    /// @return Flag to identify if the asset is native or not.\n    function isNative(address self) internal pure returns (bool) {\n        return self == NATIVE_ASSETID;\n    }\n\n    /// @dev Retrieves the balance of the current contract for a given asset (self).\n    /// @param self Asset whose balance needs to be found.\n    /// @return Balance of the specific asset.\n    function getBalance(address self) internal view returns (uint256) {\n        return self.isNative() ? address(this).balance : IERC20(self).balanceOf(address(this));\n    }\n\n    /// @dev Retrieves the balance of the target address for a given asset (self).\n    /// @param self Asset whose balance needs to be found.\n    /// @param targetAddress The address where the balance is checked from.\n    /// @return Balance of the specific asset.\n    function getBalanceOf(address self, address targetAddress) internal view returns (uint256) {\n        return self.isNative() ? targetAddress.balance : IERC20(self).balanceOf(targetAddress);\n    }\n\n    /// @dev Performs a safe transferFrom operation for a given asset (self) from one address (from) to another address (to).\n    /// @param self Asset that will be transferred.\n    /// @param from Address that will send the asset.\n    /// @param to Address that will receive the asset.\n    /// @param amount Transferred amount.\n    function transferFrom(address self, address from, address to, uint256 amount) internal {\n        IERC20 token = IERC20(self);\n\n        bool success = execute(self, abi.encodeWithSelector(token.transferFrom.selector, from, to, amount));\n\n        if (!success) revert TransferFromFailed();\n    }\n\n    /// @dev Transfers a given amount of an asset (self) to a recipient address (recipient).\n    /// @param self Asset that will be transferred.\n    /// @param recipient Address that will receive the transferred asset.\n    /// @param amount Transferred amount.\n    function transfer(address self, address recipient, uint256 amount) internal {\n        IERC20 token = IERC20(self);\n        bool success;\n\n        if (self.isNative()) {\n            (success, ) = payable(recipient).call{value: amount}(\"\");\n        } else {\n            success = execute(self, abi.encodeWithSelector(token.transfer.selector, recipient, amount));\n        }\n\n        if (!success) {\n            revert TransferFailed();\n        }\n    }\n\n    /// @dev Approves a spender address (spender) to spend a specified amount of an asset (self).\n    /// @param self The asset that will be approved.\n    /// @param spender Address of a contract that will spend the owners asset.\n    /// @param amount Asset amount that can be spent.\n    function approve(address self, address spender, uint256 amount) internal {\n        IERC20 token = IERC20(self);\n\n        if (!execute(self, abi.encodeWithSelector(token.approve.selector, spender, amount))) {\n            if (\n                !execute(self, abi.encodeWithSelector(token.approve.selector, spender, 0)) ||\n                !(execute(self, abi.encodeWithSelector(token.approve.selector, spender, amount)))\n            ) {\n                revert ApprovalFailed();\n            }\n        }\n    }\n\n    /// @dev Determines if a call was successful.\n    /// @param target Address of the target contract.\n    /// @param success To check if the call to the contract was successful or not.\n    /// @param data The data was sent while calling the target contract.\n    /// @return result The success of the call.\n    function isSuccessful(address target, bool success, bytes memory data) private view returns (bool result) {\n        if (success) {\n            if (data.length == 0) {\n                // isContract\n                if (target.code.length > 0) {\n                    result = true;\n                }\n            } else {\n                assembly {\n                    result := mload(add(data, 32))\n                }\n            }\n        }\n    }\n\n    /// @dev Executes a low level call.\n    /// @param self The address of the contract to which the call is being made.\n    /// @param params The parameters or data to be sent in the call.\n    /// @return result The success of the call.\n    function execute(address self, bytes memory params) private returns (bool) {\n        (bool success, bytes memory data) = self.call(params);\n\n        return isSuccessful(self, success, data);\n    }\n\n    /// @dev Deposit of a specified amount of an asset (self).\n    /// @param self Address of the asset that will be deposited.\n    /// @param weth Address of the Wrapped Ether (WETH) contract.\n    /// @param amount Amount that needs to be deposited.\n    function deposit(address self, address weth, uint256 amount) internal {\n        if (self.isNative()) {\n            if (msg.value < amount) {\n                revert AssetNotReceived();\n            }\n            IWETH(weth).deposit{value: amount}();\n        } else {\n            self.transferFrom(msg.sender, address(this), amount);\n        }\n    }\n\n    /// @dev Withdrawal of a specified amount of an asset (self) to a designated address (to).\n    /// @param self The asset that will be withdrawn.\n    /// @param weth Address of the Wrapped Ether (WETH) contract.\n    /// @param to Address that will receive withdrawn token.\n    /// @param amount Amount that needs to be withdrawn\n    function withdraw(address self, address weth, address to, uint256 amount) internal {\n        if (self.isNative()) {\n            IWETH(weth).withdraw(amount);\n        }\n        self.transfer(payable(to), amount);\n    }\n\n    /// @dev Retrieves the decimal precision of an ERC20 token.\n    /// @param self The asset address whose decimals we are retrieving.\n    /// @return tokenDecimals The decimals of the asset.\n    function getDecimals(address self) internal view returns (uint8 tokenDecimals) {\n        tokenDecimals = 18;\n\n        if (!self.isNative()) {\n            (, bytes memory queriedDecimals) = self.staticcall(abi.encodeWithSignature(\"decimals()\"));\n            tokenDecimals = abi.decode(queriedDecimals, (uint8));\n        }\n    }\n}\n"
      },
      "contracts/libraries/LibMagpieRouterV2.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.22;\n\nstruct AppStorage {\n    mapping(uint16 => bytes4) selectors; // Mapping of command to its corresponding function selector.\n}\n\nlibrary LibMagpieRouterV2 {\n    function getStorage() internal pure returns (AppStorage storage s) {\n        assembly {\n            s.slot := 0\n        }\n    }\n}\n"
      },
      "contracts/libraries/LibSwap.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.22;\n\nimport {LibAsset} from \"../libraries/LibAsset.sol\";\n\nstruct SwapData {\n    uint16 amountsOffset; // Represents the offset for the amounts section in the transaction calldata\n    uint16 dataOffset; // Represents the offset for reusable data section in the calldata.\n    uint16 commandsOffset; // Represents the starting point of the commands section in the calldata.\n    uint16 commandsOffsetEnd; // Represents the end of the commands section in the calldata.\n    uint16 outputsLength; // Represents the length of all of the commands\n    uint256 amountIn; // Representing the amount of the asset being provided in the swap.\n    address toAddress; // This is the address to which the output of the swap (the swapped asset) will be sent.\n    address fromAssetAddress; // The address of the source asset being swapped from.\n    address toAssetAddress; // The address of the final asset being swapped to.\n    uint256 deadline; // Represents the deadline by which the swap must be completed.\n    uint256 amountOutMin; // The minimum amount of the output asset that must be received for the swap to be considered successful.\n}\n\nlibrary LibSwap {\n    using LibAsset for address;\n\n    uint16 constant SWAP_ARGS_OFFSET = 68;\n\n    /// @dev Extracts and sums up the amounts of the source asset.\n    /// @param startOffset Relative starting position.\n    /// @param endOffset Ending position.\n    /// @param positionOffset Absolute starting position.\n    /// @return amountIn Sum of amounts.\n    function getAmountIn(\n        uint16 startOffset,\n        uint16 endOffset,\n        uint16 positionOffset\n    ) internal pure returns (uint256 amountIn) {\n        for (uint16 i = startOffset; i < endOffset; ) {\n            uint256 currentAmountIn;\n            assembly {\n                let p := shr(240, calldataload(i))\n                currentAmountIn := calldataload(add(p, positionOffset))\n            }\n            amountIn += currentAmountIn;\n\n            unchecked {\n                i += 2;\n            }\n        }\n    }\n\n    /// @dev Extract the first amount.\n    /// @param swapArgsOffset Starting position of swapArgs in calldata.\n    /// @return amountIn First amount in.\n    function getFirstAmountIn(uint16 swapArgsOffset) internal pure returns (uint256 amountIn) {\n        uint16 position = swapArgsOffset + 4;\n        assembly {\n            amountIn := calldataload(position)\n        }\n    }\n\n    /// @dev Extracts SwapData from calldata.\n    /// @param swapArgsOffset Starting position of swapArgs in calldata.\n    /// @return swapData Essential data for the swap.\n    function getData(uint16 swapArgsOffset) internal pure returns (SwapData memory swapData) {\n        uint16 dataLength;\n        uint16 amountsLength;\n        uint16 dataOffset;\n        uint16 swapArgsLength;\n        assembly {\n            dataLength := shr(240, calldataload(swapArgsOffset))\n            amountsLength := shr(240, calldataload(add(swapArgsOffset, 2)))\n            swapArgsLength := calldataload(sub(swapArgsOffset, 32))\n        }\n        dataOffset = swapArgsOffset + 4;\n        swapData.dataOffset = dataOffset;\n        swapData.amountsOffset = swapData.dataOffset + dataLength;\n        swapData.commandsOffset = swapData.amountsOffset + amountsLength;\n        swapData.commandsOffsetEnd = swapArgsLength + swapArgsOffset;\n        // Depends on the context we have shift the position addSelector\n        // By default the position is adjusted to the router's offset\n        uint256 amountIn = getAmountIn(\n            swapData.amountsOffset,\n            swapData.commandsOffset,\n            swapArgsOffset - SWAP_ARGS_OFFSET\n        );\n\n        assembly {\n            mstore(add(swapData, 128), shr(240, calldataload(add(dataOffset, 32))))\n            mstore(add(swapData, 160), amountIn)\n            mstore(add(swapData, 192), shr(96, calldataload(add(dataOffset, 34))))\n            mstore(add(swapData, 224), shr(96, calldataload(add(dataOffset, 54))))\n            mstore(add(swapData, 256), shr(96, calldataload(add(dataOffset, 74))))\n            mstore(add(swapData, 288), calldataload(add(dataOffset, 94)))\n            mstore(add(swapData, 320), calldataload(add(dataOffset, 126)))\n        }\n    }\n}\n"
      },
      "contracts/router/LibCommand.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.22;\n\nimport \"../interfaces/IWETH.sol\";\nimport {LibAsset} from \"../libraries/LibAsset.sol\";\nimport {AppStorage, LibMagpieRouterV2} from \"../libraries/LibMagpieRouterV2.sol\";\nimport {LibSwap, SwapData} from \"../libraries/LibSwap.sol\";\n\nenum MathOperation {\n    None,\n    Add,\n    Sub,\n    Mul,\n    Div,\n    Pow,\n    Abs128,\n    Abs256,\n    Shr,\n    Shl\n}\n\nenum CommandAction {\n    Call, // Represents a generic call to a function within a contract.\n    Approval, // Represents an approval operation.\n    TransferFrom, // Indicates a transfer-from operation.\n    Transfer, // Represents a direct transfer operation.\n    Wrap, // This action is used for wrapping native tokens.\n    Unwrap, // This action is used for unwrapping native tokens.\n    Balance, // Checks the balance of an account or contract for a specific asset.\n    Math,\n    EstimateGasStart,\n    EstimateGasEnd\n}\n\nenum SequenceType {\n    NativeAmount,\n    Selector,\n    Address,\n    Amount,\n    Data, // Parameter represented in bytes.\n    CommandOutput, // Parameter using the output of an other command.\n    RouterAddress, // The address of this contract.\n    SenderAddress // The address of the caller.\n}\n\nstruct CommandData {\n    CommandAction commandAction;\n    uint16 inputLength; // Specifies the length of the input data for this command.\n    uint16 outputLength; // Specifies the length of the output data for this command.\n    uint16 sequencesPosition; // Specifies the starting position of a sequence of data related to this command.\n    uint16 sequencesPositionEnd; // Marks the end position of the sequence of data.\n    address targetAddress; // The address of the contract that is the target of this command.\n}\n\nerror CommandFailed(bytes data);\nerror InvalidAmountOut();\nerror InvalidSequenceType();\nerror InvalidSelector();\nerror InvalidSequencesLength();\nerror InvalidTransferFrom();\n\nlibrary LibCommand {\n    using LibAsset for address;\n\n    /// @dev Extracts and assembles a CommandData structure from transaction calldata.\n    /// @param i The starting position in the calldata from where data extraction should begin.\n    /// @return commandData Describes the specific command.\n    function getData(uint16 i) internal pure returns (CommandData memory commandData) {\n        assembly {\n            mstore(commandData, shr(248, calldataload(i)))\n            mstore(add(commandData, 32), shr(240, calldataload(add(i, 1))))\n            mstore(add(commandData, 64), shr(240, calldataload(add(i, 3))))\n            mstore(add(commandData, 96), shr(240, calldataload(add(i, 5))))\n            mstore(add(commandData, 128), shr(240, calldataload(add(i, 7))))\n            let targetPosition := shr(240, calldataload(add(i, 9)))\n            mstore(add(commandData, 160), shr(96, calldataload(targetPosition)))\n        }\n    }\n\n    /// @dev Extracts data that is required for the next command's execution.\n    /// @param commandOutput Summarized byte code received / calculated after each command execution.\n    /// @param commandData Describes the specific command.\n    /// @return nativeAmount Amount in native tokens.\n    /// @return input The calldata that has to be executed by the next command.\n    function getInput(\n        bytes memory commandOutput,\n        CommandData memory commandData\n    ) internal view returns (uint256 nativeAmount, bytes memory input) {\n        AppStorage storage s = LibMagpieRouterV2.getStorage();\n        input = new bytes(commandData.inputLength);\n\n        SequenceType sequenceType;\n        uint16 p;\n        uint16 l;\n        uint16 inputOffset = 32;\n        bytes4 selector;\n        for (uint16 i = commandData.sequencesPosition; i < commandData.sequencesPositionEnd; ) {\n            assembly {\n                sequenceType := shr(248, calldataload(i))\n            }\n\n            if (sequenceType == SequenceType.NativeAmount) {\n                assembly {\n                    p := shr(240, calldataload(add(i, 1)))\n                    l := shr(240, calldataload(add(i, 3)))\n                    switch l\n                    case 1 {\n                        nativeAmount := mload(add(add(commandOutput, 32), p))\n                    }\n                    default {\n                        nativeAmount := calldataload(p)\n                    }\n                }\n                unchecked {\n                    i += 5;\n                }\n            } else if (sequenceType == SequenceType.Selector) {\n                assembly {\n                    p := shr(240, calldataload(add(i, 1)))\n                }\n                selector = s.selectors[p];\n                assembly {\n                    mstore(add(input, inputOffset), selector)\n                }\n                inputOffset += 4;\n                unchecked {\n                    i += 3;\n                }\n            } else if (sequenceType == SequenceType.Address) {\n                assembly {\n                    p := shr(240, calldataload(add(i, 1)))\n                    mstore(add(input, inputOffset), shr(96, calldataload(p)))\n                }\n                inputOffset += 32;\n                unchecked {\n                    i += 3;\n                }\n            } else if (sequenceType == SequenceType.Amount) {\n                assembly {\n                    p := shr(240, calldataload(add(i, 1)))\n                    mstore(add(input, inputOffset), calldataload(p))\n                }\n                inputOffset += 32;\n                unchecked {\n                    i += 3;\n                }\n            } else if (sequenceType == SequenceType.Data) {\n                assembly {\n                    p := shr(240, calldataload(add(i, 1)))\n                    l := shr(240, calldataload(add(i, 3)))\n                    calldatacopy(add(input, inputOffset), p, l)\n                }\n                inputOffset += l;\n                unchecked {\n                    i += 5;\n                }\n            } else if (sequenceType == SequenceType.CommandOutput) {\n                assembly {\n                    p := shr(240, calldataload(add(i, 1)))\n                    mstore(add(input, inputOffset), mload(add(add(commandOutput, 32), p)))\n                }\n                inputOffset += 32;\n                unchecked {\n                    i += 3;\n                }\n            } else if (sequenceType == SequenceType.RouterAddress) {\n                assembly {\n                    mstore(add(input, inputOffset), address())\n                }\n                inputOffset += 32;\n                unchecked {\n                    i += 1;\n                }\n            } else if (sequenceType == SequenceType.SenderAddress) {\n                assembly {\n                    mstore(add(input, inputOffset), caller())\n                }\n                inputOffset += 32;\n                unchecked {\n                    i += 1;\n                }\n            } else {\n                revert InvalidSequenceType();\n            }\n        }\n\n        if (inputOffset - 32 != commandData.inputLength) {\n            revert InvalidSequencesLength();\n        }\n\n        if (commandData.commandAction == CommandAction.Call) {\n            if (selector == 0) {\n                revert InvalidSelector();\n            } else if (selector == 0x23b872dd) {\n                // Blacklist transferFrom in custom calls\n                revert InvalidTransferFrom();\n            }\n        }\n    }\n\n    /// @dev Math operations.\n    function math(bytes memory input) internal pure returns (uint256) {\n        uint256[] memory localOutputs = new uint256[](10);\n        bytes32 amount0;\n        bytes32 amount1;\n        MathOperation operation;\n\n        for (uint8 i = 0; i <= 10; ) {\n            assembly {\n                let pos := add(add(input, 32), mul(i, 3))\n                let amount0Index := shr(248, mload(add(pos, 1)))\n                if lt(amount0Index, 10) {\n                    amount0 := mload(add(add(localOutputs, 32), mul(amount0Index, 32)))\n                }\n                if gt(amount0Index, 9) {\n                    amount0Index := sub(amount0Index, 10)\n                    amount0 := mload(add(add(input, 64), mul(amount0Index, 32)))\n                }\n                let amount1Index := shr(248, mload(add(pos, 2)))\n                if lt(amount1Index, 10) {\n                    amount1 := mload(add(add(localOutputs, 32), mul(amount1Index, 32)))\n                }\n                if gt(amount1Index, 9) {\n                    amount1Index := sub(amount1Index, 10)\n                    amount1 := mload(add(add(input, 64), mul(amount1Index, 32)))\n                }\n                operation := shr(248, mload(pos))\n            }\n\n            if (operation == MathOperation.None) {\n                return localOutputs[i - 1];\n            } else if (operation == MathOperation.Add) {\n                localOutputs[i] = uint256(amount0) + uint256(amount1);\n            } else if (operation == MathOperation.Sub) {\n                localOutputs[i] = uint256(amount0) - uint256(amount1);\n            } else if (operation == MathOperation.Mul) {\n                localOutputs[i] = uint256(amount0) * uint256(amount1);\n            } else if (operation == MathOperation.Div) {\n                localOutputs[i] = uint256(amount0) / uint256(amount1);\n            } else if (operation == MathOperation.Pow) {\n                localOutputs[i] = uint256(amount0) ** uint256(amount1);\n            } else if (operation == MathOperation.Abs128) {\n                int128 amount;\n                assembly {\n                    amount := amount0\n                }\n\n                if (amount < 0) {\n                    localOutputs[i] = uint256(uint128(-(amount)));\n                } else {\n                    localOutputs[i] = uint256(uint128(amount));\n                }\n            } else if (operation == MathOperation.Abs256) {\n                int256 amount;\n                assembly {\n                    amount := amount0\n                }\n\n                if (amount < 0) {\n                    localOutputs[i] = uint256(-(amount));\n                } else {\n                    localOutputs[i] = uint256(amount);\n                }\n            } else if (operation == MathOperation.Shr) {\n                assembly {\n                    mstore(add(add(localOutputs, 32), mul(i, 32)), shr(amount0, amount1))\n                }\n            } else if (operation == MathOperation.Shl) {\n                assembly {\n                    mstore(add(add(localOutputs, 32), mul(i, 32)), shl(amount0, amount1))\n                }\n            }\n\n            unchecked {\n                i++;\n            }\n        }\n\n        return localOutputs[9];\n    }\n\n    /// @dev Perform an ERC-20 token approval operation.\n    /// @param input Parameters required by approve.\n    function approve(bytes memory input) internal {\n        address assetAddress;\n        address spenderAddress;\n        uint256 amount;\n        assembly {\n            assetAddress := mload(add(input, 32))\n            spenderAddress := mload(add(input, 64))\n            amount := mload(add(input, 96))\n        }\n\n        if (amount == 0) {\n            return;\n        }\n\n        assetAddress.approve(spenderAddress, amount);\n    }\n\n    /// @dev Perform an ERC-20 token transfer from one address to another.\n    /// @param input Parameters required by transferFrom.\n    function transferFrom(bytes memory input) internal {\n        address assetAddress;\n        address fromAddress;\n        address toAddress;\n        uint256 amount;\n        assembly {\n            assetAddress := mload(add(input, 32))\n            fromAddress := mload(add(input, 64))\n            toAddress := mload(add(input, 96))\n            amount := mload(add(input, 128))\n        }\n\n        if (fromAddress != msg.sender) {\n            revert InvalidTransferFrom();\n        }\n\n        if (amount == 0) {\n            return;\n        }\n\n        assetAddress.transferFrom(fromAddress, toAddress, amount);\n    }\n\n    /// @dev Perform an ERC-20 token transfer to a specified address.\n    /// @param input Parameters required by transfer.\n    function transfer(bytes memory input) internal {\n        address assetAddress;\n        address toAddress;\n        uint256 amount;\n        assembly {\n            assetAddress := mload(add(input, 32))\n            toAddress := mload(add(input, 64))\n            amount := mload(add(input, 96))\n        }\n\n        if (amount == 0) {\n            return;\n        }\n\n        assetAddress.transfer(toAddress, amount);\n    }\n\n    /// @dev Convert native token into wrapped native token.\n    /// @param input Parameters required by wrap.\n    function wrap(bytes memory input) internal {\n        address assetAddress;\n        uint256 amount;\n        assembly {\n            assetAddress := mload(add(input, 32))\n            amount := mload(add(input, 64))\n        }\n\n        IWETH(assetAddress).deposit{value: amount}();\n    }\n\n    /// @dev Convert wrapped native token into native token.\n    /// @param input Parameters required by unwrap.\n    function unwrap(bytes memory input) internal {\n        address assetAddress;\n        uint256 amount;\n        assembly {\n            assetAddress := mload(add(input, 32))\n            amount := mload(add(input, 64))\n        }\n\n        IWETH(assetAddress).withdraw(amount);\n    }\n\n    /// @dev Query the balance of a specific asset.\n    /// @param input Parameters required by balance.\n    /// @return Balance of the specific asset\n    function balance(bytes memory input) internal view returns (uint256) {\n        address assetAddress;\n        assembly {\n            assetAddress := mload(add(input, 32))\n        }\n\n        return assetAddress.getBalanceOf(address(this));\n    }\n}\n"
      },
      "contracts/router/LibUniswapV3.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.22;\n\nimport {LibAsset} from \"../libraries/LibAsset.sol\";\n\nerror UniswapV3InvalidAmount();\n\nlibrary LibUniswapV3 {\n    using LibAsset for address;\n\n    /// @dev Callback function used in Uniswap V3 swaps, typically called by the Uniswap V3 pool contract during a swap operation.\n    /// @param amount0Delta Changes in the amount of the first token involved in the swap.\n    /// @param amount1Delta Changes in the amount of the second token involved in the swap.\n    /// @param assetIn Asset that has to be transfered to the UniswapV3 pool.\n    function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, address assetIn) internal {\n        if (amount0Delta <= 0 && amount1Delta <= 0) {\n            revert UniswapV3InvalidAmount();\n        }\n\n        assetIn.transfer(msg.sender, amount0Delta > 0 ? uint256(amount0Delta) : uint256(amount1Delta));\n    }\n}\n"
      },
      "openzeppelin-solidity/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. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling 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"
      },
      "openzeppelin-solidity/contracts/access/Ownable2Step.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./Ownable.sol\";\n\n/**\n * @dev Contract module which provides 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} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2Step is Ownable {\n    address private _pendingOwner;\n\n    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Returns the address of the pending owner.\n     */\n    function pendingOwner() public view virtual returns (address) {\n        return _pendingOwner;\n    }\n\n    /**\n     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual override onlyOwner {\n        _pendingOwner = newOwner;\n        emit OwnershipTransferStarted(owner(), newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual override {\n        delete _pendingOwner;\n        super._transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev The new owner accepts the ownership transfer.\n     */\n    function acceptOwnership() public virtual {\n        address sender = _msgSender();\n        require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\n        _transferOwnership(sender);\n    }\n}\n"
      },
      "openzeppelin-solidity/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(address from, address to, uint256 amount) external returns (bool);\n}\n"
      },
      "openzeppelin-solidity/contracts/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     *\n     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert(errorMessage);\n        }\n    }\n}\n"
      },
      "openzeppelin-solidity/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"
      },
      "openzeppelin-solidity/contracts/utils/Multicall.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Multicall.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./Address.sol\";\n\n/**\n * @dev Provides a function to batch together multiple calls in a single external call.\n *\n * _Available since v4.1._\n */\nabstract contract Multicall {\n    /**\n     * @dev Receives and executes a batch of function calls on this contract.\n     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall\n     */\n    function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {\n        results = new bytes[](data.length);\n        for (uint256 i = 0; i < data.length; i++) {\n            results[i] = Address.functionDelegateCall(address(this), data[i]);\n        }\n        return results;\n    }\n}\n"
      }
    }
  }}