creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts/access/AccessControl.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n *     require(hasRole(MY_ROLE, msg.sender));\n *     ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n    struct RoleData {\n        mapping(address => bool) members;\n        bytes32 adminRole;\n    }\n\n    mapping(bytes32 => RoleData) private _roles;\n\n    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n    /**\n     * @dev Modifier that checks that an account has a specific role. Reverts\n     * with a standardized message including the required role.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n     *\n     * _Available since v4.1._\n     */\n    modifier onlyRole(bytes32 role) {\n        _checkRole(role);\n        _;\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n        return _roles[role].members[account];\n    }\n\n    /**\n     * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n     * Overriding this function changes the behavior of the {onlyRole} modifier.\n     *\n     * Format of the revert message is described in {_checkRole}.\n     *\n     * _Available since v4.6._\n     */\n    function _checkRole(bytes32 role) internal view virtual {\n        _checkRole(role, _msgSender());\n    }\n\n    /**\n     * @dev Revert with a standard message if `account` is missing `role`.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n     */\n    function _checkRole(bytes32 role, address account) internal view virtual {\n        if (!hasRole(role, account)) {\n            revert(\n                string(\n                    abi.encodePacked(\n                        \"AccessControl: account \",\n                        Strings.toHexString(account),\n                        \" is missing role \",\n                        Strings.toHexString(uint256(role), 32)\n                    )\n                )\n            );\n        }\n    }\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n        return _roles[role].adminRole;\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     *\n     * May emit a {RoleGranted} event.\n     */\n    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been revoked `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function renounceRole(bytes32 role, address account) public virtual override {\n        require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event. Note that unlike {grantRole}, this function doesn't perform any\n     * checks on the calling account.\n     *\n     * May emit a {RoleGranted} event.\n     *\n     * [WARNING]\n     * ====\n     * This function should only be called from the constructor when setting\n     * up the initial roles for the system.\n     *\n     * Using this function in any other way is effectively circumventing the admin\n     * system imposed by {AccessControl}.\n     * ====\n     *\n     * NOTE: This function is deprecated in favor of {_grantRole}.\n     */\n    function _setupRole(bytes32 role, address account) internal virtual {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Sets `adminRole` as ``role``'s admin role.\n     *\n     * Emits a {RoleAdminChanged} event.\n     */\n    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n        bytes32 previousAdminRole = getRoleAdmin(role);\n        _roles[role].adminRole = adminRole;\n        emit RoleAdminChanged(role, previousAdminRole, adminRole);\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleGranted} event.\n     */\n    function _grantRole(bytes32 role, address account) internal virtual {\n        if (!hasRole(role, account)) {\n            _roles[role].members[account] = true;\n            emit RoleGranted(role, account, _msgSender());\n        }\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function _revokeRole(bytes32 role, address account) internal virtual {\n        if (hasRole(role, account)) {\n            _roles[role].members[account] = false;\n            emit RoleRevoked(role, account, _msgSender());\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/access/IAccessControl.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n    /**\n     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n     *\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n     * {RoleAdminChanged} not being emitted signaling this.\n     *\n     * _Available since v3.1._\n     */\n    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n    /**\n     * @dev Emitted when `account` is granted `role`.\n     *\n     * `sender` is the account that originated the contract call, an admin role\n     * bearer except when using {AccessControl-_setupRole}.\n     */\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) external view returns (bool);\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been granted `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     */\n    function renounceRole(bytes32 role, address account) external;\n}\n"
      },
      "@openzeppelin/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/contracts/utils/introspection/ERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC165).interfaceId;\n    }\n}\n"
      },
      "@openzeppelin/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"
      },
      "@openzeppelin/contracts/utils/math/Math.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    enum Rounding {\n        Down, // Toward negative infinity\n        Up, // Toward infinity\n        Zero // Toward zero\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds up instead\n     * of rounding down.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n     * with further edits by Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2^256 + prod0.\n            uint256 prod0; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod0 := mul(x, y)\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            require(denominator > prod1, \"Math: mulDiv overflow\");\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n            // See https://cs.stackexchange.com/q/138556/92363.\n\n            // Does not overflow because the denominator cannot be zero at this stage in the function.\n            uint256 twos = denominator & (~denominator + 1);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n            // in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n        uint256 result = mulDiv(x, y, denominator);\n        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        //\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/math/SignedMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n    /**\n     * @dev Returns the largest of two signed numbers.\n     */\n    function max(int256 a, int256 b) internal pure returns (int256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two signed numbers.\n     */\n    function min(int256 a, int256 b) internal pure returns (int256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two signed numbers without overflow.\n     * The result is rounded towards zero.\n     */\n    function average(int256 a, int256 b) internal pure returns (int256) {\n        // Formula from the book \"Hacker's Delight\"\n        int256 x = (a & b) + ((a ^ b) >> 1);\n        return x + (int256(uint256(x) >> 255) & (a ^ b));\n    }\n\n    /**\n     * @dev Returns the absolute unsigned value of a signed value.\n     */\n    function abs(int256 n) internal pure returns (uint256) {\n        unchecked {\n            // must be unchecked in order to support `n = type(int256).min`\n            return uint256(n >= 0 ? n : -n);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Strings.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\nimport \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n    uint8 private constant _ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            uint256 length = Math.log10(value) + 1;\n            string memory buffer = new string(length);\n            uint256 ptr;\n            /// @solidity memory-safe-assembly\n            assembly {\n                ptr := add(buffer, add(32, length))\n            }\n            while (true) {\n                ptr--;\n                /// @solidity memory-safe-assembly\n                assembly {\n                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n                }\n                value /= 10;\n                if (value == 0) break;\n            }\n            return buffer;\n        }\n    }\n\n    /**\n     * @dev Converts a `int256` to its ASCII `string` decimal representation.\n     */\n    function toString(int256 value) internal pure returns (string memory) {\n        return string(abi.encodePacked(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value))));\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            return toHexString(value, Math.log256(value) + 1);\n        }\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n    }\n\n    /**\n     * @dev Returns true if the two strings are equal.\n     */\n    function equal(string memory a, string memory b) internal pure returns (bool) {\n        return keccak256(bytes(a)) == keccak256(bytes(b));\n    }\n}\n"
      },
      "@routerprotocol/intents-core/contracts/AdapterDataProvider.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport {IAdapterDataProvider} from \"./interfaces/IAdapterDataProvider.sol\";\n\n/**\n * @title AdapterDataProvider\n * @author Router Protocol\n * @notice This contract serves as the data provider for an intent adapter based on Router\n * Cross-Chain Intent Framework.\n */\ncontract AdapterDataProvider is IAdapterDataProvider {\n    address private _owner;\n    mapping(address => bool) private _headRegistry;\n    mapping(address => bool) private _tailRegistry;\n    mapping(address => bool) private _inboundAssetRegistry;\n    mapping(address => bool) private _outboundAssetRegistry;\n\n    constructor(address __owner) {\n        _owner = __owner;\n    }\n\n    /**\n     * @inheritdoc IAdapterDataProvider\n     */\n    function owner() external view returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @inheritdoc IAdapterDataProvider\n     */\n    function setOwner(address __owner) external onlyOwner {\n        _owner = __owner;\n    }\n\n    /**\n     * @inheritdoc IAdapterDataProvider\n     */\n    function isAuthorizedPrecedingContract(\n        address precedingContract\n    ) external view returns (bool) {\n        if (precedingContract == address(0)) return true;\n        return _headRegistry[precedingContract];\n    }\n\n    /**\n     * @inheritdoc IAdapterDataProvider\n     */\n    function isAuthorizedSucceedingContract(\n        address succeedingContract\n    ) external view returns (bool) {\n        if (succeedingContract == address(0)) return true;\n        return _tailRegistry[succeedingContract];\n    }\n\n    /**\n     * @inheritdoc IAdapterDataProvider\n     */\n    function isValidInboundAsset(address asset) external view returns (bool) {\n        return _inboundAssetRegistry[asset];\n    }\n\n    /**\n     * @inheritdoc IAdapterDataProvider\n     */\n    function isValidOutboundAsset(address asset) external view returns (bool) {\n        return _outboundAssetRegistry[asset];\n    }\n\n    /**\n     * @inheritdoc IAdapterDataProvider\n     */\n    function setPrecedingContract(\n        address precedingContract,\n        bool isValid\n    ) external onlyOwner {\n        _headRegistry[precedingContract] = isValid;\n    }\n\n    /**\n     * @inheritdoc IAdapterDataProvider\n     */\n    function setSucceedingContract(\n        address succeedingContract,\n        bool isValid\n    ) external onlyOwner {\n        _tailRegistry[succeedingContract] = isValid;\n    }\n\n    /**\n     * @inheritdoc IAdapterDataProvider\n     */\n    function setInboundAsset(address asset, bool isValid) external onlyOwner {\n        _inboundAssetRegistry[asset] = isValid;\n    }\n\n    /**\n     * @inheritdoc IAdapterDataProvider\n     */\n    function setOutboundAsset(address asset, bool isValid) external onlyOwner {\n        _outboundAssetRegistry[asset] = isValid;\n    }\n\n    /**\n     * @notice modifier to ensure that only owner can call this function\n     */\n    modifier onlyOwner() {\n        _onlyOwner();\n        _;\n    }\n\n    function _onlyOwner() private view {\n        require(msg.sender == _owner, \"Only owner\");\n    }\n}\n"
      },
      "@routerprotocol/intents-core/contracts/BaseAdapter.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport {Basic} from \"./common/Basic.sol\";\nimport {Errors} from \"./utils/Errors.sol\";\nimport {ReentrancyGuard} from \"./utils/ReentrancyGuard.sol\";\nimport {AdapterDataProvider} from \"./AdapterDataProvider.sol\";\n\n/**\n * @title BaseAdapter\n * @author Router Protocol\n * @notice This contract is the base implementation of an intent adapter based on Router\n * Cross-Chain Intent Framework.\n */\nabstract contract BaseAdapter is Basic, ReentrancyGuard {\n    address private immutable _self;\n    address private immutable _native;\n    address private immutable _wnative;\n    AdapterDataProvider private immutable _adapterDataProvider;\n\n    event ExecutionEvent(string indexed adapterName, bytes data);\n    event OperationFailedRefundEvent(\n        address token,\n        address recipient,\n        uint256 amount\n    );\n    event UnsupportedOperation(\n        address token,\n        address refundAddress,\n        uint256 amount\n    );\n\n    constructor(\n        address __native,\n        address __wnative,\n        bool __deployDataProvider,\n        address __owner\n    ) {\n        _self = address(this);\n        _native = __native;\n        _wnative = __wnative;\n\n        AdapterDataProvider dataProvider;\n\n        if (__deployDataProvider)\n            dataProvider = new AdapterDataProvider(__owner);\n        else dataProvider = AdapterDataProvider(address(0));\n\n        _adapterDataProvider = dataProvider;\n    }\n\n    /**\n     * @dev function to get the address of weth\n     */\n    function wnative() public view override returns (address) {\n        return _wnative;\n    }\n\n    /**\n     * @dev function to get the address of native token\n     */\n    function native() public view override returns (address) {\n        return _native;\n    }\n\n    /**\n     * @dev function to get the AdapterDataProvider instance for this contract\n     */\n    function adapterDataProvider() public view returns (AdapterDataProvider) {\n        return _adapterDataProvider;\n    }\n\n    /**\n     * @dev Function to check whether the contract is a valid preceding contract registered in\n     * the head registry.\n     * @dev This registry governs the initiation of the adapter, exclusively listing authorized\n     * preceding adapters.\n     * @notice Only the adapters documented in this registry can invoke the current adapter,\n     * thereby guaranteeing regulated and secure execution sequences.\n     * @param precedingContract Address of preceding contract.\n     * @return true if valid, false if invalid.\n     */\n    function isAuthorizedPrecedingContract(\n        address precedingContract\n    ) public view returns (bool) {\n        return\n            _adapterDataProvider.isAuthorizedPrecedingContract(\n                precedingContract\n            );\n    }\n\n    /**\n     * @dev Function to check whether the contract is a valid succeeding contract registered in\n     * the tail registry.\n     * @dev This registry dictates the potential succeeding actions by listing adapters that\n     * may be invoked following the current one.\n     * @notice Only the adapters documented in this registry can be invoked by the current adapter,\n     * thereby guaranteeing regulated and secure execution sequences.\n     * @param succeedingContract Address of succeeding contract.\n     * @return true if valid, false if invalid.\n     */\n    function isAuthorizedSucceedingContract(\n        address succeedingContract\n    ) public view returns (bool) {\n        return\n            _adapterDataProvider.isAuthorizedSucceedingContract(\n                succeedingContract\n            );\n    }\n\n    /**\n     * @dev Function to check whether the asset is a valid inbound asset registered in the inbound\n     * asset registry.\n     * @dev This registry keeps track of all the acceptable incoming assets, ensuring that the\n     * adapter only processes predefined asset types.\n     * @param asset Address of the asset.\n     * @return true if valid, false if invalid.\n     */\n    function isValidInboundAsset(address asset) public view returns (bool) {\n        return _adapterDataProvider.isValidInboundAsset(asset);\n    }\n\n    /**\n     * @dev Function to check whether the asset is a valid outbound asset registered in the outbound\n     * asset registry.\n     * @dev It manages the types of assets that the adapter is allowed to output, thus controlling\n     * the flow’s output and maintaining consistency.\n     * @param asset Address of the asset.\n     * @return true if valid, false if invalid.\n     */\n    function isValidOutboundAsset(address asset) public view returns (bool) {\n        return _adapterDataProvider.isValidOutboundAsset(asset);\n    }\n\n    /**\n     * @dev function to get the name of the adapter\n     */\n    function name() public view virtual returns (string memory);\n\n    /**\n     * @dev function to get the address of the contract\n     */\n    function self() public view returns (address) {\n        return _self;\n    }\n}\n"
      },
      "@routerprotocol/intents-core/contracts/common/Basic.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport {TokenInterface} from \"./Interfaces.sol\";\nimport {TokenUtilsBase} from \"./TokenUtilsBase.sol\";\n\nabstract contract Basic is TokenUtilsBase {\n    function getTokenBal(address token) internal view returns (uint _amt) {\n        _amt = address(token) == native()\n            ? address(this).balance\n            : TokenInterface(token).balanceOf(address(this));\n    }\n\n    function approve(address token, address spender, uint256 amount) internal {\n        // solhint-disable-next-line no-empty-blocks\n        try TokenInterface(token).approve(spender, amount) {} catch {\n            TokenInterface(token).approve(spender, 0);\n            TokenInterface(token).approve(spender, amount);\n        }\n    }\n\n    function convertNativeToWnative(uint amount) internal {\n        TokenInterface(wnative()).deposit{value: amount}();\n    }\n\n    function convertWnativeToNative(uint amount) internal {\n        TokenInterface(wnative()).withdraw(amount);\n    }\n}\n"
      },
      "@routerprotocol/intents-core/contracts/common/Interfaces.sol": {
        "content": "//SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\ninterface TokenInterface {\n    function approve(address, uint256) external;\n\n    function transfer(address, uint) external;\n\n    function transferFrom(address, address, uint) external;\n\n    function deposit() external payable;\n\n    function withdraw(uint) external;\n\n    function balanceOf(address) external view returns (uint);\n\n    function decimals() external view returns (uint);\n}\n"
      },
      "@routerprotocol/intents-core/contracts/common/TokenUtilsBase.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport {IWETH} from \"../interfaces/IWETH.sol\";\nimport {SafeERC20, IERC20} from \"../utils/SafeERC20.sol\";\n\nabstract contract TokenUtilsBase {\n    using SafeERC20 for IERC20;\n\n    function wnative() public view virtual returns (address);\n\n    function native() public view virtual returns (address);\n\n    function approveToken(\n        address _tokenAddr,\n        address _to,\n        uint256 _amount\n    ) internal {\n        if (_tokenAddr == native()) return;\n\n        if (IERC20(_tokenAddr).allowance(address(this), _to) < _amount) {\n            IERC20(_tokenAddr).safeApprove(_to, _amount);\n        }\n    }\n\n    function pullTokensIfNeeded(\n        address _token,\n        address _from,\n        uint256 _amount\n    ) internal returns (uint256) {\n        // handle max uint amount\n        if (_amount == type(uint256).max) {\n            _amount = getBalance(_token, _from);\n        }\n\n        if (\n            _from != address(0) &&\n            _from != address(this) &&\n            _token != native() &&\n            _amount != 0\n        ) {\n            IERC20(_token).safeTransferFrom(_from, address(this), _amount);\n        }\n\n        return _amount;\n    }\n\n    function withdrawTokens(\n        address _token,\n        address _to,\n        uint256 _amount\n    ) internal returns (uint256) {\n        if (_amount == type(uint256).max) {\n            _amount = getBalance(_token, address(this));\n        }\n\n        if (_to != address(0) && _to != address(this) && _amount != 0) {\n            if (_token != native()) {\n                IERC20(_token).safeTransfer(_to, _amount);\n            } else {\n                (bool success, ) = _to.call{value: _amount}(\"\");\n                require(success, \"native send fail\");\n            }\n        }\n\n        return _amount;\n    }\n\n    function depositWnative(uint256 _amount) internal {\n        IWETH(wnative()).deposit{value: _amount}();\n    }\n\n    function withdrawWnative(uint256 _amount) internal {\n        IWETH(wnative()).withdraw(_amount);\n    }\n\n    function getBalance(\n        address _tokenAddr,\n        address _acc\n    ) internal view returns (uint256) {\n        if (_tokenAddr == native()) {\n            return _acc.balance;\n        } else {\n            return IERC20(_tokenAddr).balanceOf(_acc);\n        }\n    }\n\n    function getTokenDecimals(address _token) internal view returns (uint256) {\n        if (_token == native()) return 18;\n\n        return IERC20(_token).decimals();\n    }\n}\n"
      },
      "@routerprotocol/intents-core/contracts/interfaces/IAdapterDataProvider.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\n/**\n * @title Interface for Adapter Data Provider contract for intent adapter.\n * @author Router Protocol.\n */\n\ninterface IAdapterDataProvider {\n    /**\n     * @dev Function to get the address of owner.\n     */\n    function owner() external view returns (address);\n\n    /**\n     * @dev Function to set the address of owner.\n     * @dev This function can only be called by the owner of this contract.\n     * @param __owner Address of the new owner\n     */\n    function setOwner(address __owner) external;\n\n    /**\n     * @dev Function to check whether the contract is a valid preceding contract registered in\n     * the head registry.\n     * @dev This registry governs the initiation of the adapter, exclusively listing authorized\n     * preceding adapters.\n     * @notice Only the adapters documented in this registry can invoke the current adapter,\n     * thereby guaranteeing regulated and secure execution sequences.\n     * @param precedingContract Address of preceding contract.\n     * @return true if valid, false if invalid.\n     */\n    function isAuthorizedPrecedingContract(\n        address precedingContract\n    ) external view returns (bool);\n\n    /**\n     * @dev Function to check whether the contract is a valid succeeding contract registered in\n     * the tail registry.\n     * @dev This registry dictates the potential succeeding actions by listing adapters that\n     * may be invoked following the current one.\n     * @notice Only the adapters documented in this registry can be invoked by the current adapter,\n     * thereby guaranteeing regulated and secure execution sequences.\n     * @param succeedingContract Address of succeeding contract.\n     * @return true if valid, false if invalid.\n     */\n    function isAuthorizedSucceedingContract(\n        address succeedingContract\n    ) external view returns (bool);\n\n    /**\n     * @dev Function to check whether the asset is a valid inbound asset registered in the inbound\n     * asset registry.\n     * @dev This registry keeps track of all the acceptable incoming assets, ensuring that the\n     * adapter only processes predefined asset types.\n     * @param asset Address of the asset.\n     * @return true if valid, false if invalid.\n     */\n    function isValidInboundAsset(address asset) external view returns (bool);\n\n    /**\n     * @dev Function to check whether the asset is a valid outbound asset registered in the outbound\n     * asset registry.\n     * @dev It manages the types of assets that the adapter is allowed to output, thus controlling\n     * the flow’s output and maintaining consistency.\n     * @param asset Address of the asset.\n     * @return true if valid, false if invalid.\n     */\n    function isValidOutboundAsset(address asset) external view returns (bool);\n\n    /**\n     * @dev Function to set preceding contract (head registry) for the adapter.\n     * @dev This registry governs the initiation of the adapter, exclusively listing authorized\n     * preceding adapters.\n     * @notice Only the adapters documented in this registry can invoke the current adapter,\n     * thereby guaranteeing regulated and secure execution sequences.\n     * @param precedingContract Address of preceding contract.\n     * @param isValid Boolean value suggesting if this is a valid preceding contract.\n     */\n    function setPrecedingContract(\n        address precedingContract,\n        bool isValid\n    ) external;\n\n    /**\n     * @dev Function to set succeeding contract (tail registry) for the adapter.\n     * @dev This registry dictates the potential succeeding actions by listing adapters that\n     * may be invoked following the current one.\n     * @notice Only the adapters documented in this registry can be invoked by the current adapter,\n     * thereby guaranteeing regulated and secure execution sequences.\n     * @param succeedingContract Address of succeeding contract.\n     * @param isValid Boolean value suggesting if this is a valid succeeding contract.\n     */\n    function setSucceedingContract(\n        address succeedingContract,\n        bool isValid\n    ) external;\n\n    /**\n     * @dev Function to set inbound asset registry for the adapter.\n     * @dev This registry keeps track of all the acceptable incoming assets, ensuring that the\n     * adapter only processes predefined asset types.\n     * @param asset Address of the asset.\n     * @param isValid Boolean value suggesting if this is a valid inbound asset.\n     */\n    function setInboundAsset(address asset, bool isValid) external;\n\n    /**\n     * @dev Function to set outbound asset registry for the adapter.\n     * @dev It manages the types of assets that the adapter is allowed to output, thus controlling\n     * the flow’s output and maintaining consistency.\n     * @param asset Address of the asset.\n     * @param isValid Boolean value suggesting if this is a valid inbound asset.\n     */\n    function setOutboundAsset(address asset, bool isValid) external;\n}\n"
      },
      "@routerprotocol/intents-core/contracts/interfaces/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\ninterface IERC20 {\n    function name() external view returns (string memory);\n\n    function symbol() external view returns (string memory);\n\n    function decimals() external view returns (uint8);\n\n    function totalSupply() external view returns (uint256 supply);\n\n    function balanceOf(address _owner) external view returns (uint256 balance);\n\n    function transfer(\n        address _to,\n        uint256 _value\n    ) external returns (bool success);\n\n    function transferFrom(\n        address _from,\n        address _to,\n        uint256 _value\n    ) external returns (bool success);\n\n    function approve(\n        address _spender,\n        uint256 _value\n    ) external returns (bool success);\n\n    function allowance(\n        address _owner,\n        address _spender\n    ) external view returns (uint256 remaining);\n\n    event Approval(\n        address indexed _owner,\n        address indexed _spender,\n        uint256 _value\n    );\n}\n"
      },
      "@routerprotocol/intents-core/contracts/interfaces/IWETH.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport {IERC20} from \"../utils/SafeERC20.sol\";\n\nabstract contract IWETH {\n    function allowance(address, address) public view virtual returns (uint256);\n\n    function balanceOf(address) public view virtual returns (uint256);\n\n    function approve(address, uint256) public virtual;\n\n    function transfer(address, uint256) public virtual returns (bool);\n\n    function transferFrom(\n        address,\n        address,\n        uint256\n    ) public virtual returns (bool);\n\n    function deposit() public payable virtual;\n\n    function withdraw(uint256) public virtual;\n}\n"
      },
      "@routerprotocol/intents-core/contracts/RouterIntentEoaAdapter.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport {BaseAdapter} from \"./BaseAdapter.sol\";\nimport {EoaExecutorWithDataProvider, EoaExecutorWithoutDataProvider} from \"./utils/EoaExecutor.sol\";\n\nabstract contract RouterIntentEoaAdapterWithDataProvider is\n    BaseAdapter,\n    EoaExecutorWithDataProvider\n{\n    constructor(\n        address __native,\n        address __wnative,\n        address __owner\n    )\n        BaseAdapter(__native, __wnative, true, __owner)\n    // solhint-disable-next-line no-empty-blocks\n    {\n\n    }\n}\n\nabstract contract RouterIntentEoaAdapterWithoutDataProvider is\n    BaseAdapter,\n    EoaExecutorWithoutDataProvider\n{\n    constructor(\n        address __native,\n        address __wnative\n    )\n        BaseAdapter(__native, __wnative, false, address(0))\n    // solhint-disable-next-line no-empty-blocks\n    {\n\n    }\n}\n"
      },
      "@routerprotocol/intents-core/contracts/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nlibrary Address {\n    //insufficient balance\n    error InsufficientBalance(uint256 available, uint256 required);\n    //unable to send value, recipient may have reverted\n    error SendingValueFail();\n    //insufficient balance for call\n    error InsufficientBalanceForCall(uint256 available, uint256 required);\n    //call to non-contract\n    error NonContractCall();\n\n    function isContract(address account) internal view returns (bool) {\n        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts\n        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\n        // for accounts without code, i.e. `keccak256('')`\n        bytes32 codehash;\n        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            codehash := extcodehash(account)\n        }\n        return (codehash != accountHash && codehash != 0x0);\n    }\n\n    function sendValue(address payable recipient, uint256 amount) internal {\n        uint256 balance = address(this).balance;\n        if (balance < amount) {\n            revert InsufficientBalance(balance, amount);\n        }\n\n        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        if (!(success)) {\n            revert SendingValueFail();\n        }\n    }\n\n    function functionCall(\n        address target,\n        bytes memory data\n    ) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\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    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return\n            functionCallWithValue(\n                target,\n                data,\n                value,\n                \"Address: low-level call with value failed\"\n            );\n    }\n\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        uint256 balance = address(this).balance;\n        if (balance < value) {\n            revert InsufficientBalanceForCall(balance, value);\n        }\n        return _functionCallWithValue(target, data, value, errorMessage);\n    }\n\n    function _functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 weiValue,\n        string memory errorMessage\n    ) private returns (bytes memory) {\n        if (!(isContract(target))) {\n            revert NonContractCall();\n        }\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.call{value: weiValue}(\n            data\n        );\n        if (success) {\n            return returndata;\n        } else {\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\n                // solhint-disable-next-line no-inline-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}\n"
      },
      "@routerprotocol/intents-core/contracts/utils/CallLib.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nlibrary CallLib {\n    /**\n     * @dev internal method that fecilitates the extenral calls from SmartAccount\n     * @dev similar to execute() of Executor.sol\n     * @param target destination address contract/non-contract\n     * @param value amount of native tokens\n     * @param data function singature of destination\n     */\n    function _call(\n        address target,\n        uint256 value,\n        bytes memory data\n    ) internal returns (bytes memory result) {\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            let success := call(\n                gas(),\n                target,\n                value,\n                add(data, 0x20),\n                mload(data),\n                0,\n                0\n            )\n\n            // Get the size of the returned data\n            let size := returndatasize()\n\n            // Allocate memory for the return data\n            result := mload(0x40)\n\n            // Set the length of the return data\n            mstore(result, size)\n\n            // Copy the return data to the allocated memory\n            returndatacopy(add(result, 0x20), 0, size)\n\n            // Update the free memory pointer\n            mstore(0x40, add(result, add(0x20, size)))\n\n            if iszero(success) {\n                revert(result, returndatasize())\n            }\n        }\n    }\n\n    /**\n     * @dev internal method that fecilitates the extenral calls from SmartAccount\n     * @dev similar to execute() of Executor.sol\n     * @param target destination address contract/non-contract\n     * @param data function singature of destination\n     */\n    function _delegateCall(\n        address target,\n        bytes memory data\n    ) internal returns (bytes memory result) {\n        require(target != address(this), \"delegatecall to self\");\n\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            // Perform delegatecall to the target contract\n            let success := delegatecall(\n                gas(),\n                target,\n                add(data, 0x20),\n                mload(data),\n                0,\n                0\n            )\n\n            // Get the size of the returned data\n            let size := returndatasize()\n\n            // Allocate memory for the return data\n            result := mload(0x40)\n\n            // Set the length of the return data\n            mstore(result, size)\n\n            // Copy the return data to the allocated memory\n            returndatacopy(add(result, 0x20), 0, size)\n\n            // Update the free memory pointer\n            mstore(0x40, add(result, add(0x20, size)))\n\n            if iszero(success) {\n                revert(result, returndatasize())\n            }\n        }\n    }\n}\n"
      },
      "@routerprotocol/intents-core/contracts/utils/EoaExecutor.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nabstract contract EoaExecutorWithDataProvider {\n    /**\n     * @dev function to execute an action on an adapter used in an EOA.\n     * @param precedingAdapter Address of the preceding adapter.\n     * @param succeedingAdapter Address of the succeeding adapter.\n     * @param data inputs data.\n     * @return tokens to be refunded to user at the end of tx.\n     */\n    function execute(\n        address precedingAdapter,\n        address succeedingAdapter,\n        bytes calldata data\n    ) external payable virtual returns (address[] memory tokens);\n}\n\nabstract contract EoaExecutorWithoutDataProvider {\n    /**\n     * @dev function to execute an action on an adapter used in an EOA.\n     * @param data inputs data.\n     * @return tokens to be refunded to user at the end of tx.\n     */\n    function execute(\n        bytes calldata data\n    ) external payable virtual returns (address[] memory tokens);\n}\n"
      },
      "@routerprotocol/intents-core/contracts/utils/Errors.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.18;\n\n/**\n * @title Errors library\n * @author Router Intents Error\n * @notice Defines the error messages emitted by the contracts on Router Intents\n */\nlibrary Errors {\n    string public constant ARRAY_LENGTH_MISMATCH = \"1\"; // 'Array lengths mismatch'\n    string public constant INSUFFICIENT_NATIVE_FUNDS_PASSED = \"2\"; // 'Insufficient native tokens passed'\n    string public constant WRONG_BATCH_PROVIDED = \"3\"; // 'The targetLength, valueLength, callTypeLength, funcLength do not match in executeBatch transaction functions in batch transaction contract'\n    string public constant INVALID_CALL_TYPE = \"4\"; // 'The callType value can only be 1 (call)' and 2(delegatecall)'\n    string public constant ONLY_NITRO = \"5\"; // 'Only nitro can call this function'\n    string public constant ONLY_SELF = \"6\"; // 'Only the current contract can call this function'\n    string public constant ADAPTER_NOT_WHITELISTED = \"7\"; // 'Adapter not whitelisted'\n}\n"
      },
      "@routerprotocol/intents-core/contracts/utils/ReentrancyGuard.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.18;\n\nabstract contract ReentrancyGuard {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant _NOT_ENTERED = 1;\n    uint256 private constant _ENTERED = 2;\n\n    uint256 private _status;\n\n    error ReentrantCall();\n\n    constructor() {\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and make it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        // On the first call to nonReentrant, _notEntered will be true\n        if (_status == _ENTERED) {\n            revert ReentrantCall();\n        }\n\n        // Any calls to nonReentrant after this point will fail\n        _status = _ENTERED;\n\n        _;\n\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = _NOT_ENTERED;\n    }\n}\n"
      },
      "@routerprotocol/intents-core/contracts/utils/SafeERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport {IERC20} from \"../interfaces/IERC20.sol\";\nimport {Address} from \"./Address.sol\";\nimport {SafeMath} from \"./SafeMath.sol\";\n\nlibrary SafeERC20 {\n    using SafeMath for uint256;\n    using Address for address;\n\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\n        _callOptionalReturn(\n            token,\n            abi.encodeWithSelector(token.transfer.selector, to, value)\n        );\n    }\n\n    function safeTransferFrom(\n        IERC20 token,\n        address from,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(\n            token,\n            abi.encodeWithSelector(token.transferFrom.selector, from, to, value)\n        );\n    }\n\n    /// @dev Edited so it always first approves 0 and then the value, because of non standard tokens\n    function safeApprove(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(\n            token,\n            abi.encodeWithSelector(token.approve.selector, spender, 0)\n        );\n        _callOptionalReturn(\n            token,\n            abi.encodeWithSelector(token.approve.selector, spender, value)\n        );\n    }\n\n    function safeIncreaseAllowance(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        uint256 newAllowance = token.allowance(address(this), spender).add(\n            value\n        );\n        _callOptionalReturn(\n            token,\n            abi.encodeWithSelector(\n                token.approve.selector,\n                spender,\n                newAllowance\n            )\n        );\n    }\n\n    function safeDecreaseAllowance(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        uint256 newAllowance = token.allowance(address(this), spender).sub(\n            value,\n            \"SafeERC20: decreased allowance below zero\"\n        );\n        _callOptionalReturn(\n            token,\n            abi.encodeWithSelector(\n                token.approve.selector,\n                spender,\n                newAllowance\n            )\n        );\n    }\n\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        bytes memory returndata = address(token).functionCall(\n            data,\n            \"SafeERC20: low-level call failed\"\n        );\n        if (returndata.length > 0) {\n            // Return data is optional\n            // solhint-disable-next-line max-line-length\n            require(\n                abi.decode(returndata, (bool)),\n                \"SafeERC20: operation failed\"\n            );\n        }\n    }\n}\n"
      },
      "@routerprotocol/intents-core/contracts/utils/SafeMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nlibrary SafeMath {\n    function add(uint256 a, uint256 b) internal pure returns (uint256) {\n        uint256 c = a + b;\n        require(c >= a, \"SafeMath: addition overflow\");\n\n        return c;\n    }\n\n    function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n        return sub(a, b, \"SafeMath: subtraction overflow\");\n    }\n\n    function sub(\n        uint256 a,\n        uint256 b,\n        string memory errorMessage\n    ) internal pure returns (uint256) {\n        require(b <= a, errorMessage);\n        uint256 c = a - b;\n\n        return c;\n    }\n\n    function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n        // benefit is lost if 'b' is also tested.\n        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n        if (a == 0) {\n            return 0;\n        }\n\n        uint256 c = a * b;\n        require(c / a == b, \"SafeMath: mul overflow\");\n\n        return c;\n    }\n\n    function div(uint256 a, uint256 b) internal pure returns (uint256) {\n        return div(a, b, \"SafeMath: division by zero\");\n    }\n\n    function div(\n        uint256 a,\n        uint256 b,\n        string memory errorMessage\n    ) internal pure returns (uint256) {\n        require(b > 0, errorMessage);\n        uint256 c = a / b;\n        // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n        return c;\n    }\n\n    function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n        return mod(a, b, \"SafeMath: modulo by zero\");\n    }\n\n    function mod(\n        uint256 a,\n        uint256 b,\n        string memory errorMessage\n    ) internal pure returns (uint256) {\n        require(b != 0, errorMessage);\n        return a % b;\n    }\n}\n"
      },
      "contracts/BatchTransaction.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport {ReentrancyGuard} from \"@routerprotocol/intents-core/contracts/utils/ReentrancyGuard.sol\";\nimport {Basic} from \"@routerprotocol/intents-core/contracts/common/Basic.sol\";\nimport {CallLib} from \"@routerprotocol/intents-core/contracts/utils/CallLib.sol\";\nimport {IERC20, SafeERC20} from \"@routerprotocol/intents-core/contracts/utils/SafeERC20.sol\";\nimport {Errors} from \"@routerprotocol/intents-core/contracts/utils/Errors.sol\";\nimport {AccessControl} from \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport {EoaExecutorWithDataProvider, EoaExecutorWithoutDataProvider} from \"@routerprotocol/intents-core/contracts/RouterIntentEoaAdapter.sol\";\nimport {BaseAdapter} from \"@routerprotocol/intents-core/contracts/BaseAdapter.sol\";\n\n/**\n * @title BatchTransaction\n * @author Shivam Agrawal\n * @notice Batch Transaction Contract for EOAs.\n */\ncontract BatchTransaction is Basic, AccessControl, ReentrancyGuard {\n    using SafeERC20 for IERC20;\n\n    struct RefundData {\n        address[] tokens;\n    }\n\n    bytes32 public constant SETTER_ROLE = keccak256(\"SETTER_ROLE\");\n\n    address private immutable _native;\n    address private immutable _wnative;\n    address private _assetForwarder;\n    address private _dexspan;\n\n    // user -> token array\n    mapping(address => RefundData) private tokensToRefund;\n    mapping(address => bool) private adapterWhitelist;\n\n    event OperationFailedRefundEvent(\n        address token,\n        address recipient,\n        uint256 amount\n    );\n    event OperationSuccessful();\n\n    constructor(\n        address __native,\n        address __wnative,\n        address __assetForwarder,\n        address __dexspan\n    ) {\n        _native = __native;\n        _wnative = __wnative;\n        _assetForwarder = __assetForwarder;\n        _dexspan = __dexspan;\n\n        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n        _grantRole(SETTER_ROLE, msg.sender);\n    }\n\n    /**\n     * @notice function to return the address of WNative token.\n     */\n    function wnative() public view virtual override returns (address) {\n        return _wnative;\n    }\n\n    /**\n     * @notice function to return the address of Native token.\n     */\n    function native() public view virtual override returns (address) {\n        return _native;\n    }\n\n    /**\n     * @notice function to return the address of Dexspan.\n     */\n    function dexspan() public view virtual returns (address) {\n        return _dexspan;\n    }\n\n    /**\n     * @notice function to return the address of AssetForwarder.\n     */\n    function assetForwarder() public view virtual returns (address) {\n        return _assetForwarder;\n    }\n\n    /**\n     * @notice function to check whether an adapter is whitelisted.\n     * @param adapter Address of the adapter.\n     */\n    function isAdapterWhitelisted(address adapter) public view returns (bool) {\n        return adapterWhitelist[adapter];\n    }\n\n    /**\n     * @notice function to set dexspan address.\n     * @param __dexspan Address of the dexspan.\n     */\n    function setDexspan(address __dexspan) external onlyRole(SETTER_ROLE) {\n        _dexspan = __dexspan;\n    }\n\n    /**\n     * @notice function to set assetForwarder address.\n     * @param __assetForwarder Address of the assetForwarder.\n     */\n    function setAssetForwarder(\n        address __assetForwarder\n    ) external onlyRole(SETTER_ROLE) {\n        _assetForwarder = __assetForwarder;\n    }\n\n    /**\n     * @notice function to set adapter whitelist.\n     * @param adapters Addresses of the adapters.\n     * @param shouldWhitelist Boolean array suggesting whether to whitelist the adapters.\n     */\n    function setAdapterWhitelist(\n        address[] memory adapters,\n        bool[] memory shouldWhitelist\n    ) external onlyRole(SETTER_ROLE) {\n        uint256 len = adapters.length;\n\n        require(\n            len != 0 && len == shouldWhitelist.length,\n            Errors.ARRAY_LENGTH_MISMATCH\n        );\n\n        for (uint i = 0; i < len; ) {\n            adapterWhitelist[adapters[i]] = shouldWhitelist[i];\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    /**\n     * @dev function to execute batch calls on the same chain\n     * @param tokens Addresses of the tokens to fetch from the user\n     * @param amounts amounts of the tokens to fetch from the user\n     * @param target Addresses of the contracts to call\n     * @param value Amounts of native tokens to send along with the transactions\n     * @param callType Type of call. 1: call, 2: delegatecall\n     * @param data Data of the transactions\n     */\n    function executeBatchCallsSameChain(\n        address[] calldata tokens,\n        uint256[] calldata amounts,\n        address[] calldata target,\n        uint256[] calldata value,\n        uint256[] calldata callType,\n        bytes[] calldata data\n    ) external payable {\n        uint256 tokensLength = tokens.length;\n        require(tokensLength == amounts.length, Errors.ARRAY_LENGTH_MISMATCH);\n        uint256 totalValue = 0;\n\n        for (uint256 i = 0; i < tokensLength; ) {\n            totalValue += _pullTokens(tokens[i], amounts[i]);\n            tokensToRefund[msg.sender].tokens.push(tokens[i]);\n\n            unchecked {\n                ++i;\n            }\n        }\n\n        require(\n            msg.value >= totalValue,\n            Errors.INSUFFICIENT_NATIVE_FUNDS_PASSED\n        );\n\n        for (uint256 i = 0; i < callType.length; ) {\n            // callType can be either 1 or 2\n            require(callType[i] < 3, Errors.INVALID_CALL_TYPE);\n            unchecked {\n                ++i;\n            }\n        }\n\n        _executeBatchCalls(msg.sender, target, value, callType, data);\n    }\n\n    /**\n     * @dev function to execute batch calls\n     * @param refundRecipient Address of recipient of refunds of dust at the end\n     * @param target Addresses of the contracts to call\n     * @param value Amounts of native tokens to send along with the transactions\n     * @param data Data of the transactions\n     * @param callType Type of call. 1: call, 2: delegatecall\n     */\n    function executeBatchCallsDestChain(\n        address refundRecipient,\n        address[] calldata target,\n        uint256[] calldata value,\n        uint256[] calldata callType,\n        bytes[] calldata data\n    ) external payable {\n        require(msg.sender == address(this), Errors.ONLY_SELF);\n\n        _executeBatchCalls(refundRecipient, target, value, callType, data);\n    }\n\n    /**\n     * @dev function to execute batch calls\n     * @param target Addresses of the contracts to call\n     * @param value Amounts of native tokens to send along with the transactions\n     * @param data Data of the transactions\n     * @param callType Type of call. 1: call, 2: delegatecall\n     */\n    function _executeBatchCalls(\n        address refundRecipient,\n        address[] calldata target,\n        uint256[] calldata value,\n        uint256[] calldata callType,\n        bytes[] calldata data\n    ) internal {\n        uint256 targetLength = target.length;\n\n        require(\n            targetLength != 0 &&\n                targetLength == value.length &&\n                value.length == data.length &&\n                data.length == callType.length,\n            Errors.WRONG_BATCH_PROVIDED\n        );\n\n        if (target.length == 1) {\n            _execute(\n                refundRecipient,\n                target[0],\n                address(0),\n                address(0),\n                value[0],\n                callType[0],\n                data[0]\n            );\n        } else {\n            _execute(\n                refundRecipient,\n                target[0],\n                address(0),\n                target[1],\n                value[0],\n                callType[0],\n                data[0]\n            );\n\n            for (uint256 i = 1; i < targetLength; ) {\n                if (i != targetLength - 1) {\n                    _execute(\n                        refundRecipient,\n                        target[i],\n                        target[i - 1],\n                        target[i + 1],\n                        value[i],\n                        callType[i],\n                        data[i]\n                    );\n                } else {\n                    _execute(\n                        refundRecipient,\n                        target[i],\n                        target[i - 1],\n                        address(0),\n                        value[i],\n                        callType[i],\n                        data[i]\n                    );\n                }\n\n                unchecked {\n                    ++i;\n                }\n            }\n        }\n\n        processRefunds(refundRecipient);\n    }\n\n    function _pullTokens(\n        address token,\n        uint256 amount\n    ) internal returns (uint256) {\n        uint256 totalValue = 0;\n        if (token == native()) {\n            totalValue += amount;\n        } else {\n            IERC20(token).safeTransferFrom(msg.sender, address(this), amount);\n        }\n\n        return totalValue;\n    }\n\n    function _execute(\n        address refundRecipient,\n        address target,\n        address precedingAdapter,\n        address succeedingAdapter,\n        uint256 value,\n        uint256 callType,\n        bytes memory data\n    ) internal {\n        require(adapterWhitelist[target], Errors.ADAPTER_NOT_WHITELISTED);\n\n        bytes memory _calldata;\n        if (address(BaseAdapter(target).adapterDataProvider()) == address(0)) {\n            _calldata = abi.encodeWithSelector(\n                EoaExecutorWithoutDataProvider.execute.selector,\n                data\n            );\n        } else {\n            _calldata = abi.encodeWithSelector(\n                EoaExecutorWithDataProvider.execute.selector,\n                precedingAdapter,\n                succeedingAdapter,\n                data\n            );\n        }\n\n        bytes memory result;\n        if (callType == 1) result = CallLib._call(target, value, _calldata);\n        else if (callType == 2)\n            result = CallLib._delegateCall(target, _calldata);\n\n        if (result.length != 0) processResult(refundRecipient, result);\n    }\n\n    function processResult(address user, bytes memory data) internal {\n        address[] memory tokens = abi.decode(data, (address[]));\n\n        for (uint256 i = 0; i < tokens.length; ) {\n            tokensToRefund[user].tokens.push(tokens[i]);\n\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    function processRefunds(address user) internal {\n        uint256 len = tokensToRefund[user].tokens.length;\n\n        for (uint256 i = 0; i < len; ) {\n            withdrawTokens(\n                tokensToRefund[user].tokens[i],\n                user,\n                type(uint256).max\n            );\n\n            unchecked {\n                ++i;\n            }\n        }\n\n        delete tokensToRefund[user];\n    }\n\n    function handleMessage(\n        address tokenSent,\n        uint256 amount,\n        bytes memory instruction\n    ) external onlyNitro nonReentrant {\n        (\n            address refundAddress,\n            address[] memory target,\n            uint256[] memory value,\n            uint256[] memory callType,\n            bytes[] memory data\n        ) = abi.decode(\n                instruction,\n                (address, address[], uint256[], uint256[], bytes[])\n            );\n\n        for (uint256 i = 0; i < callType.length; ) {\n            if (callType[i] > 2) {\n                withdrawTokens(tokenSent, refundAddress, amount);\n                emit OperationFailedRefundEvent(\n                    tokenSent,\n                    refundAddress,\n                    amount\n                );\n\n                return;\n            }\n            unchecked {\n                ++i;\n            }\n        }\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, ) = address(this).call(\n            abi.encodeWithSelector(\n                this.executeBatchCallsDestChain.selector,\n                refundAddress,\n                target,\n                value,\n                callType,\n                data\n            )\n        );\n\n        if (success) {\n            emit OperationSuccessful();\n        } else {\n            withdrawTokens(tokenSent, refundAddress, amount);\n            emit OperationFailedRefundEvent(tokenSent, refundAddress, amount);\n        }\n    }\n\n    // solhint-disable-next-line no-empty-blocks\n    receive() external payable {}\n\n    /**\n     * @notice modifier to ensure that only Nitro bridge can call handleMessage function\n     */\n    modifier onlyNitro() {\n        _onlyNitro();\n        _;\n    }\n\n    function _onlyNitro() private view {\n        require(\n            msg.sender == _assetForwarder || msg.sender == _dexspan,\n            Errors.ONLY_NITRO\n        );\n    }\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 1000000
      },
      "viaIR": true,
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "metadata": {
        "useLiteralContent": true
      },
      "libraries": {}
    }
  }}