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/security/ReentrancyGuard.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\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    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 making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        _nonReentrantBefore();\n        _;\n        _nonReentrantAfter();\n    }\n\n    function _nonReentrantBefore() private {\n        // On the first call to nonReentrant, _status will be _NOT_ENTERED\n        require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _status = _ENTERED;\n    }\n\n    function _nonReentrantAfter() private {\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    /**\n     * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n     * `nonReentrant` function in the call stack.\n     */\n    function _reentrancyGuardEntered() internal view returns (bool) {\n        return _status == _ENTERED;\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n *     doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n *     token.safeTransferFrom(msg.sender, address(this), value);\n *     ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     *\n     * CAUTION: See Security Considerations above.\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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/contracts/token/ERC20/utils/SafeERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    using Address for address;\n\n    /**\n     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    /**\n     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n     */\n    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(IERC20 token, address spender, uint256 value) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    /**\n     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        uint256 oldAllowance = token.allowance(address(this), spender);\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n    }\n\n    /**\n     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n        }\n    }\n\n    /**\n     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n     * to be set to zero before setting it to a non-zero value, such as USDT.\n     */\n    function forceApprove(IERC20 token, address spender, uint256 value) internal {\n        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n        if (!_callOptionalReturnBool(token, approvalCall)) {\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n            _callOptionalReturn(token, approvalCall);\n        }\n    }\n\n    /**\n     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n     * Revert on invalid signature.\n     */\n    function safePermit(\n        IERC20Permit token,\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal {\n        uint256 nonceBefore = token.nonces(owner);\n        token.permit(owner, spender, value, deadline, v, r, s);\n        uint256 nonceAfter = token.nonces(owner);\n        require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     *\n     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n     */\n    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n        // and not revert is the subcall reverts.\n\n        (bool success, bytes memory returndata) = address(token).call(data);\n        return\n            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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/contracts/utils/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (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    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\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/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/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"
      },
      "contracts/Errors.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nlibrary Errors {\n    string public constant AMOUNT_CANNOT_BE_ZERO = \"1\";\n    string public constant RECIPIENT_CANNOT_BE_ZERO = \"2\";\n    string public constant AMOUNT_RECEIVED_CANNOT_BE_ZERO = \"3\";\n    string public constant RESTAKED_ETH_RECEIVED_AMOUNT_LESS_THAN_MIN_RETURN =\n        \"4\";\n    string public constant ONLY_EMERGENCY_OWNER = \"5\";\n    string public constant EMERGENCY_OWNER_CANNOT_BE_ZERO = \"6\";\n    string public constant WRONG_BATCH_PROVIDED = \"7\";\n    string public constant INSUFFICIENT_NATIVE_FUNDS_PASSED = \"8\";\n    string public constant ONLY_SELF = \"9\";\n    string public constant ARRAY_LENGTH_MISMATCH = \"10\";\n    string public constant INSUFFICIENT_FEE_PASSED = \"11\";\n    string public constant VOLUME_CANNOT_BE_ZERO = \"12\";\n    string public constant ONLY_NATIVE_TOKENS = \"13\";\n    string public constant ONLY_NITRO_BRIDGE = \"14\";\n    string public constant ONLY_WHITELISTED_BRIDGES = \"15\";\n    string public constant BRIDGE_ADAPTER_ADDRESS_CANNOT_BE_ZERO = \"16\";\n    string public constant MULTICALLER_ADDRESS_CANNOT_BE_ZERO = \"17\";\n    string public constant FEE_MANAGER_ADDRESS_CANNOT_BE_ZERO = \"18\";\n    string public constant SWAP_FAILED = \"19\";\n    string public constant ADAPTER_NOT_WHITELISTED = \"20\";\n    string public constant BRIDGE_TX_FAILED_ON_MULTICALL = \"21\";\n    string public constant TOKEN_PASSED_CANNOT_BE_NULL_ADDRESS = \"22\";\n    string public constant ADAPTER_ADDRESS_CANNOT_BE_ZERO = \"23\";\n    string public constant ADAPTER_TYPE_CAN_BE_EITHER_1_OR_2 = \"24\";\n    string public constant FEE_TRANSFER_FAILED = \"25\";\n    string public constant AMOUNT_LESSER_THAN_MIN_DEPOSIT = \"26\";\n    string public constant ARRAY_LENGTH_ZERO = \"27\";\n    string public constant REFUND_AMOUNT_ZERO = \"28\";\n    string public constant INVALID_RESTAKING_PROTOCOL_TYPE = \"29\";\n    string public constant INVALID_PROTOCOL_DATA = \"30\";\n    string public constant BASE_GAS_NOT_IN_RANGE = \"31\";\n    string public constant MARGINAL_GAS_PER_USER_NOT_IN_RANGE = \"32\";\n    string public constant FEE_TOO_LARGE = \"33\";\n    string public constant ZERO_DEPOSIT_FUNDS_FOR_THIS_PROTOCOL_ID = \"34\";\n    string public constant NOT_EXECUTABLE = \"35\";\n    string public constant PROTOCOL_DATA_NOT_SET = \"36\";\n    string public constant CANNOT_EXECUTE_LESSER_THAN_MIN_EXECUTABLE_BATCH =\n        \"37\";\n    string public constant MAX_FEE_PERCENTAGE_GREATER_THAN_CEILING = \"38\";\n    string public constant FUSION_TX_BUILDER_CANNOT_BE_ADDRESS_ZERO = \"39\";\n    string public constant PROTOCOL_IS_PAUSED = \"40\";\n    string public constant OPEN_OCEAN_ADDRESS_CANNOT_BE_ZERO = \"41\";\n    string public constant BRIDGE_ADDRESS_CANNOT_BE_ZERO = \"42\";\n    string public constant WNATIVE_ADDRESS_CANNOT_BE_ZERO = \"43\";\n    string public constant CHAIN_LINK_GAS_PRICE_ORACLE_ADDRESS_CANNOT_BE_ZERO =\n        \"44\";\n    string public constant STAKE_EASE_FEE_MANAGER_ADDRESS_CANNOT_BE_ZERO = \"45\";\n    string public constant PROTOCOL_GAS_PER_USER_OUT_OF_RANGE = \"46\";\n    string public constant GAS_PRICE_EXCEEDS_FAST_GAS_RANGE = \"47\";\n    string public constant AMOUNT_TO_RESTAKE_CANNOT_BE_ZERO = \"48\";\n    string public constant UNSUPPORTED_OPERATION = \"49\";\n    string public constant CANNOT_SET_ALL_DATA_FOR_PROTOCOL_AGAIN = \"50\";\n    string public constant INVALID_ASSET = \"51\";\n    string public constant CANNOT_SET_NEW_PROTOCOL_DATA_WITH_UPDATE_FUNCTION =\n        \"52\";\n    string public constant OFT_ADAPTER_NOT_FOUND = \"53\";\n}\n"
      },
      "contracts/interfaces/INitroMessageHandler.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\n/// @title Handles ERC20 deposits and deposit executions.\n/// @author Router Protocol.\n/// @notice This contract is intended to be used with the Bridge contract.\ninterface INitroMessageHandler {\n    function handleMessage(\n        address tokenSent,\n        uint256 amount,\n        bytes memory message\n    ) external;\n}\n\ninterface INitroAssetForwarder {\n    struct RelayDataMessage {\n        uint256 amount;\n        bytes32 srcChainId;\n        uint256 depositId;\n        address destToken;\n        address recipient;\n        bytes message;\n    }\n\n    function iRelayMessage(RelayDataMessage memory relayData) external payable;\n}\n"
      },
      "contracts/interfaces/IWETH.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\ninterface IWETH {\n    function deposit() external payable;\n\n    function withdraw(uint256 amount) external;\n\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(\n        address indexed owner,\n        address indexed spender,\n        uint256 value\n    );\n\n    /**\n     * @dev Returns the value of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the value of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves a `value` amount of 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 value) 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(\n        address owner,\n        address spender\n    ) external view returns (uint256);\n\n    /**\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n     * 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 value) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the\n     * allowance mechanism. `value` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 value\n    ) external returns (bool);\n}\n"
      },
      "contracts/Multicall.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport {IERC20, SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {AccessControl} from \"@openzeppelin/contracts/access/AccessControl.sol\";\nimport {EoaExecutorWithoutDataProvider} from \"@routerprotocol/intents-core/contracts/RouterIntentEoaAdapter.sol\";\nimport {Errors} from \"./Errors.sol\";\nimport {CallLib} from \"./CallLib.sol\";\nimport {TokenUtils} from \"./utils/TokenUtils.sol\";\nimport {INitroMessageHandler} from \"./interfaces/INitroMessageHandler.sol\";\nimport {IWETH} from \"./interfaces/IWETH.sol\";\n\n/**\n * @title Multicall\n * @author StakeEase\n * @notice Multicaller contract.\n */\ncontract Multicall is TokenUtils, AccessControl, INitroMessageHandler {\n    using SafeERC20 for IERC20;\n\n    struct RefundData {\n        address[] tokens;\n    }\n\n    bytes32 public constant SETTER_ROLE = keccak256(\"SETTER_ROLE\");\n    uint256 public constant TEMP_TOKENS_LENGTH = 6;\n\n    mapping(address => bool) private whitelistedAdapters;\n\n    address public assetForwarder;\n    address public dexspan;\n    IWETH public immutable wnative;\n\n    constructor(\n        address _assetForwarder,\n        address _dexspan,\n        address _wnative,\n        address[] memory _whitelistedAdapters\n    ) payable {\n        assetForwarder = _assetForwarder;\n        dexspan = _dexspan;\n        wnative = IWETH(_wnative);\n\n        uint256 length = _whitelistedAdapters.length;\n        for (uint256 i = 0; i < length; ) {\n            require(\n                _whitelistedAdapters[i] != address(0),\n                Errors.ADAPTER_ADDRESS_CANNOT_BE_ZERO\n            );\n\n            whitelistedAdapters[_whitelistedAdapters[i]] = true;\n\n            unchecked {\n                ++i;\n            }\n        }\n\n        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n        _grantRole(SETTER_ROLE, msg.sender);\n    }\n\n    /**\n     * @notice Function to check if a bridge adapter is whitelisted.\n     * @param adapter Address of the bridge adapter.\n     */\n    function isAdapterWhitelisted(address adapter) public view returns (bool) {\n        return whitelistedAdapters[adapter];\n    }\n\n    /**\n     * @notice Function to whitelist an adapter.\n     * @notice Can only be called by an address with the SETTER_ROLE.\n     * @param adapterAddress Array of addresses ofs adapters.\n     * @param shouldWhitelist Array of booleans suggesting whether the adapter should be whitelisted.\n     */\n    function setAdapterWhitelist(\n        address[] memory adapterAddress,\n        bool[] memory shouldWhitelist\n    ) external onlyRole(SETTER_ROLE) {\n        uint256 length = adapterAddress.length;\n        require(\n            length != 0 && length == shouldWhitelist.length,\n            Errors.ARRAY_LENGTH_MISMATCH\n        );\n\n        for (uint256 i = 0; i < length; ) {\n            require(\n                adapterAddress[i] != address(0),\n                Errors.ADAPTER_ADDRESS_CANNOT_BE_ZERO\n            );\n            whitelistedAdapters[adapterAddress[i]] = shouldWhitelist[i];\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    /**\n     * @notice Function to set dexspan contract.\n     * @notice Can only be called by an address with the SETTER_ROLE.\n     * @param _dexspan Dexspan address.\n     */\n    function setDexspan(address _dexspan) external onlyRole(SETTER_ROLE) {\n        dexspan = _dexspan;\n    }\n\n    /**\n     * @notice Function to set asset forwarder contract.\n     * @notice Can only be called by an address with the SETTER_ROLE.\n     * @param _assetForwarder AssetForwarder address.\n     */\n    function setAssetForwarder(\n        address _assetForwarder\n    ) external onlyRole(SETTER_ROLE) {\n        assetForwarder = _assetForwarder;\n    }\n\n    /**\n     * @dev function to execute batch calls on the same chain.\n     * @param token Addresses of the tokens to fetch from the user.\n     * @param amount Amounts of the tokens to fetch from the user.\n     * @param target Addresses of the contracts to call.\n     * @param data Data of the transactions.\n     */\n    function execute(\n        address token,\n        uint256 amount,\n        address[] calldata target,\n        bytes[] calldata data\n    ) external payable {\n        require(amount != 0, Errors.AMOUNT_CANNOT_BE_ZERO);\n\n        if (token != NATIVE_ADDRESS) {\n            IERC20(token).safeTransferFrom(msg.sender, address(this), amount);\n        } else\n            require(\n                msg.value >= amount,\n                Errors.INSUFFICIENT_NATIVE_FUNDS_PASSED\n            );\n\n        address[] memory tempTokens = new address[](TEMP_TOKENS_LENGTH);\n        tempTokens[0] = token;\n\n        _executeBatch(msg.sender, target, data, tempTokens);\n    }\n\n    /**\n     * @dev Function to execute batch calls on the destination chain.\n     * @param refundRecipient Address of recipient of refunds of dust at the end.\n     * @param target Addresses of the contracts to call.\n     * @param data Data of the transactions.\n     */\n    function executeDest(\n        address refundRecipient,\n        address[] calldata target,\n        bytes[] calldata data\n    ) external payable {\n        require(msg.sender == address(this), Errors.ONLY_SELF);\n\n        address[] memory tempTokens = new address[](TEMP_TOKENS_LENGTH);\n        tempTokens[0] = NATIVE_ADDRESS;\n\n        _executeBatch(refundRecipient, target, data, tempTokens);\n    }\n\n    /**\n     * @inheritdoc INitroMessageHandler\n     */\n    function handleMessage(\n        address tokenSent,\n        uint256 amount,\n        bytes memory message\n    ) external {\n        if (msg.sender != assetForwarder && msg.sender != dexspan)\n            revert(Errors.ONLY_NITRO_BRIDGE);\n        require(amount != 0, Errors.AMOUNT_CANNOT_BE_ZERO);\n\n        (\n            address refundAddress,\n            address[] memory target,\n            bytes[] memory data\n        ) = abi.decode(message, (address, address[], bytes[]));\n\n        if (tokenSent != NATIVE_ADDRESS && tokenSent != address(wnative)) {\n            IERC20(tokenSent).safeTransfer(refundAddress, amount);\n            return;\n        }\n\n        if (tokenSent == address(wnative)) wnative.withdraw(amount);\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, ) = address(this).call(\n            abi.encodeWithSelector(\n                this.executeDest.selector,\n                refundAddress,\n                target,\n                data\n            )\n        );\n\n        if (!success) payable(refundAddress).transfer(amount);\n    }\n\n    /**\n     * @notice Function to withdraw funds from this contract which may be sent due to mistake.\n     * @notice Can only be called by the DEFAULT_ADMIN.\n     * @param token Address of the token to withdraw.\n     * @param recipient Address of the recipient.\n     * @param amount Amount of funds to withdraw.\n     */\n    function emergencyWithdrawFunds(\n        address token,\n        address recipient,\n        uint256 amount\n    ) external onlyRole(DEFAULT_ADMIN_ROLE) {\n        require(recipient != address(0), Errors.RECIPIENT_CANNOT_BE_ZERO);\n\n        if (token == address(0) || token == NATIVE_ADDRESS) {\n            if (amount == 0) amount = address(this).balance;\n            if (amount == 0) revert(Errors.AMOUNT_CANNOT_BE_ZERO);\n            payable(recipient).transfer(amount);\n        } else {\n            if (amount == 0) amount = IERC20(token).balanceOf(address(this));\n            if (amount == 0) revert(Errors.AMOUNT_CANNOT_BE_ZERO);\n            IERC20(token).safeTransfer(recipient, amount);\n        }\n    }\n\n    /**\n     * @dev Function to execute batch calls.\n     * @param refundRecipient Address of the refund recipient.\n     * @param target Addresses of the contracts to call.\n     * @param data Data of the transactions.\n     */\n    function _executeBatch(\n        address refundRecipient,\n        address[] calldata target,\n        bytes[] calldata data,\n        address[] memory tempTokens\n    ) internal {\n        uint256 targetLength = target.length;\n\n        require(\n            targetLength != 0 && targetLength == data.length,\n            Errors.WRONG_BATCH_PROVIDED\n        );\n\n        for (uint256 i = 0; i < targetLength; ) {\n            _onlyWhitelistedAdapters(target[i]);\n\n            tempTokens = _execute(i, target[i], data[i], tempTokens);\n\n            unchecked {\n                ++i;\n            }\n        }\n\n        _processRefunds(refundRecipient, tempTokens);\n    }\n\n    function _execute(\n        uint256 index,\n        address target,\n        bytes memory data,\n        address[] memory tempTokens\n    ) internal returns (address[] memory) {\n        bytes memory _calldata = abi.encodeWithSelector(\n            EoaExecutorWithoutDataProvider.execute.selector,\n            data\n        );\n\n        bytes memory result = CallLib._delegateCall(target, _calldata);\n\n        address[] memory token = abi.decode(result, (address[]));\n        tempTokens[index + 1] = token[0];\n\n        return tempTokens;\n    }\n\n    function _processRefunds(\n        address user,\n        address[] memory tempTokens\n    ) internal {\n        for (uint256 i = 0; i < TEMP_TOKENS_LENGTH; ) {\n            if (tempTokens[i] == address(0)) {\n                break;\n            }\n\n            withdrawTokens(tempTokens[i], user, type(uint256).max);\n\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    function _onlyWhitelistedAdapters(address adapter) internal view {\n        require(whitelistedAdapters[adapter], Errors.ADAPTER_NOT_WHITELISTED);\n    }\n\n    // solhint-disable-next-line no-empty-blocks\n    receive() external payable {}\n}\n"
      },
      "contracts/utils/TokenUtils.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.18;\n\nimport {ReentrancyGuard} from \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport {SafeERC20, IERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ncontract TokenUtils {\n    using SafeERC20 for IERC20;\n\n    address public constant NATIVE_ADDRESS =\n        0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\n\n    function withdrawTokens(\n        address token,\n        address recipient,\n        uint256 amount\n    ) internal {\n        if (token == NATIVE_ADDRESS) {\n            if (amount == type(uint256).max) amount = address(this).balance;\n            if (amount == 0) return;\n            payable(recipient).transfer(amount);\n        } else {\n            if (amount == type(uint256).max)\n                amount = IERC20(token).balanceOf(address(this));\n            if (amount == 0) return;\n\n            IERC20(token).safeTransfer(recipient, amount);\n        }\n    }\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 1000
      },
      "evmVersion": "paris",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "metadata": {
        "useLiteralContent": true
      },
      "libraries": {}
    }
  }}