creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts/interfaces/IERC1271.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC1271 standard signature validation method for\n * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].\n *\n * _Available since v4.1._\n */\ninterface IERC1271 {\n    /**\n     * @dev Should return whether the signature provided is valid for the provided data\n     * @param hash      Hash of the data to be signed\n     * @param signature Signature byte array associated with _data\n     */\n    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);\n}\n"
      },
      "@openzeppelin/contracts/proxy/utils/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts.\n     *\n     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n     * constructor.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\n            \"Initializable: contract is already initialized\"\n        );\n        _initialized = 1;\n        if (isTopLevelCall) {\n            _initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            _initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n     * are added through upgrades and that require initialization.\n     *\n     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n     * cannot be nested. If one is invoked in the context of another, execution will revert.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     *\n     * WARNING: setting the version to 255 will prevent any future reinitialization.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n        _initialized = version;\n        _initializing = true;\n        _;\n        _initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     *\n     * Emits an {Initialized} event the first time it is successfully executed.\n     */\n    function _disableInitializers() internal virtual {\n        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized != type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n\n    /**\n     * @dev Returns the highest version that has been initialized. See {reinitializer}.\n     */\n    function _getInitializedVersion() internal view returns (uint8) {\n        return _initialized;\n    }\n\n    /**\n     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n     */\n    function _isInitializing() internal view returns (bool) {\n        return _initializing;\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (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 */\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    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.0) (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. Compatible with tokens that require the approval to be set to\n     * 0 before setting it to a non-zero value.\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 v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n    enum RecoverError {\n        NoError,\n        InvalidSignature,\n        InvalidSignatureLength,\n        InvalidSignatureS,\n        InvalidSignatureV // Deprecated in v4.8\n    }\n\n    function _throwError(RecoverError error) private pure {\n        if (error == RecoverError.NoError) {\n            return; // no error: do nothing\n        } else if (error == RecoverError.InvalidSignature) {\n            revert(\"ECDSA: invalid signature\");\n        } else if (error == RecoverError.InvalidSignatureLength) {\n            revert(\"ECDSA: invalid signature length\");\n        } else if (error == RecoverError.InvalidSignatureS) {\n            revert(\"ECDSA: invalid signature 's' value\");\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature` or error string. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {toEthSignedMessageHash} on it.\n     *\n     * Documentation for signature generation:\n     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n        if (signature.length == 65) {\n            bytes32 r;\n            bytes32 s;\n            uint8 v;\n            // ecrecover takes the signature parameters, and the only way to get them\n            // currently is to use assembly.\n            /// @solidity memory-safe-assembly\n            assembly {\n                r := mload(add(signature, 0x20))\n                s := mload(add(signature, 0x40))\n                v := byte(0, mload(add(signature, 0x60)))\n            }\n            return tryRecover(hash, v, r, s);\n        } else {\n            return (address(0), RecoverError.InvalidSignatureLength);\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature`. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {toEthSignedMessageHash} on it.\n     */\n    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, signature);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n     *\n     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {\n        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n        uint8 v = uint8((uint256(vs) >> 255) + 27);\n        return tryRecover(hash, v, r, s);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n     *\n     * _Available since v4.2._\n     */\n    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n            return (address(0), RecoverError.InvalidSignatureS);\n        }\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        if (signer == address(0)) {\n            return (address(0), RecoverError.InvalidSignature);\n        }\n\n        return (signer, RecoverError.NoError);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {\n        // 32 is the length in bytes of hash,\n        // enforced by the type signature above\n        /// @solidity memory-safe-assembly\n        assembly {\n            mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\")\n            mstore(0x1c, hash)\n            message := keccak256(0x00, 0x3c)\n        }\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from `s`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Typed Data, created from a\n     * `domainSeparator` and a `structHash`. This produces hash corresponding\n     * to the one signed with the\n     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n     * JSON-RPC method as part of EIP-712.\n     *\n     * See {recover}.\n     */\n    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let ptr := mload(0x40)\n            mstore(ptr, \"\\x19\\x01\")\n            mstore(add(ptr, 0x02), domainSeparator)\n            mstore(add(ptr, 0x22), structHash)\n            data := keccak256(ptr, 0x42)\n        }\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Data with intended validator, created from a\n     * `validator` and `data` according to the version 0 of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19\\x00\", validator, data));\n    }\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"
      },
      "contracts/interfaces/external/IWETH.sol": {
        "content": "/**\n * SPDX-License-Identifier: UNLICENSED\n */\npragma solidity >=0.8.0;\n\ninterface IWETH {\n    function deposit() external payable;\n\n    function transfer(address to, uint256 value) external returns (bool);\n\n    function withdraw(uint256) external;\n}\n"
      },
      "contracts/interfaces/IHashflowPool.sol": {
        "content": "/**\n * SPDX-License-Identifier: UNLICENSED\n */\npragma solidity >=0.8.0;\n\nimport '@openzeppelin/contracts/interfaces/IERC1271.sol';\n\nimport './IQuote.sol';\n\n/// @title IHashflowPool\n/// @author Victor Ionescu\n/**\n * Pool contract used for trading. The Pool can either hold funds or\n * rely on external accounts. External accounts are used in order to preserve\n * Capital Efficiency on the Market Maker side. This way, a Market Maker can\n * make markets using funds that are also used on other venues.\n */\ninterface IHashflowPool is IQuote, IERC1271 {\n    /// @notice Specifies a HashflowPool on a foreign chain.\n    struct AuthorizedXChainPool {\n        uint16 chainId;\n        bytes32 pool;\n    }\n\n    /// @notice Contains a signer verification address, and whether trading is enabled.\n    struct SignerConfiguration {\n        address signer;\n        bool enabled;\n    }\n\n    /// @notice Emitted when the authorization status of a withdrawal account changes.\n    /// @param account The account for which the status changes.\n    /// @param authorized The new authorization status.\n    event UpdateWithdrawalAccount(address account, bool authorized);\n\n    /// @notice Emitted when the signer key used for the pool has changed.\n    /// @param signer The new signer key.\n    /// @param prevSigner The old signer key.\n    event UpdateSigner(address signer, address prevSigner);\n\n    /// @notice Emitted when liquidity is withdrawn from the pool.\n    /// @param token Token being withdrawn.\n    /// @param recipient Address receiving the token.\n    /// @param withdrawAmount Amount being withdrawn.\n    event RemoveLiquidity(\n        address token,\n        address recipient,\n        uint256 withdrawAmount\n    );\n\n    /// @notice Emitted when an intra-chain trade happens.\n    /// @param trader The trader.\n    /// @param effectiveTrader The effective Trader.\n    /// @param txid The txid of the quote.\n    /// @param baseToken The token the trader sold.\n    /// @param quoteToken The token the trader bought.\n    /// @param baseTokenAmount The amount of baseToken sold.\n    /// @param quoteTokenAmount The amount of quoteToken bought.\n    event Trade(\n        address trader,\n        address effectiveTrader,\n        bytes32 txid,\n        address baseToken,\n        address quoteToken,\n        uint256 baseTokenAmount,\n        uint256 quoteTokenAmount\n    );\n\n    /// @notice Emitted when a cross-chain trade happens.\n    /// @param dstChainId The Hashflow Chain ID for the destination chain.\n    /// @param dstPool The pool address on the destination chain.\n    /// @param trader The trader address.\n    /// @param txid The txid of the quote.\n    /// @param baseToken The token the trader sold.\n    /// @param quoteToken The token the trader bought.\n    /// @param baseTokenAmount The amount of baseToken sold.\n    /// @param quoteTokenAmount The amount of quoteToken bought.\n    event XChainTrade(\n        uint16 dstChainId,\n        bytes32 dstPool,\n        address trader,\n        bytes32 dstTrader,\n        bytes32 txid,\n        address baseToken,\n        bytes32 quoteToken,\n        uint256 baseTokenAmount,\n        uint256 quoteTokenAmount\n    );\n\n    /// @notice Emitted when a cross-chain trade is filled.\n    /// @param txid The txid identified the quote that was filled.\n    event XChainTradeFill(bytes32 txid);\n\n    /// @notice Main initializer.\n    /// @param name Name of the pool.\n    /// @param signer Signer key used for quote / deposit verification.\n    /// @param operations Operations key that governs the pool.\n    /// @param router Address of the HashflowRouter contract.\n    function initialize(\n        string calldata name,\n        address signer,\n        address operations,\n        address router\n    ) external;\n\n    /// @notice Returns the pool name.\n    function name() external view returns (string memory);\n\n    /// @notice Returns the signer address and whether the pool is enabled.\n    function signerConfiguration() external view returns (address, bool);\n\n    /// @notice Returns the Operations address of this pool.\n    function operations() external view returns (address);\n\n    /// @notice Returns the Router contract address.\n    function router() external view returns (address);\n\n    /// @notice Returns the current nonce for a trader.\n    function nonces(address trader) external view returns (uint256);\n\n    /// @notice Removes liquidity from the pool.\n    /// @param token Token to withdraw.\n    /// @param recipient Address to send token to.\n    /// @param amount Amount to withdraw.\n    function removeLiquidity(\n        address token,\n        address recipient,\n        uint256 amount\n    ) external;\n\n    /// @notice Execute an RFQ-T trade.\n    /// @param quote The quote to be executed.\n    function tradeRFQT(RFQTQuote memory quote) external payable;\n\n    /// @notice Execute an RFQ-M trade.\n    /// @param quote The quote to be executed.\n    function tradeRFQM(RFQMQuote memory quote) external;\n\n    /// @notice Execute a cross-chain RFQ-T trade.\n    /// @param quote The quote to be executed.\n    /// @param trader The account that sends baseToken on this chain.\n    function tradeXChainRFQT(XChainRFQTQuote memory quote, address trader)\n        external\n        payable;\n\n    /// @notice Execute a cross-chain RFQ-M trade.\n    /// @param quote The quote to be executed.\n    function tradeXChainRFQM(XChainRFQMQuote memory quote) external;\n\n    /// @notice Changes authorization for a set of pools to send X-Chain messages.\n    /// @param pools The pools to change authorization status for.\n    /// @param authorized The new authorization status.\n    function updateXChainPoolAuthorization(\n        AuthorizedXChainPool[] calldata pools,\n        bool authorized\n    ) external;\n\n    /// @notice Changes authorization for an X-Chain Messenger app.\n    /// @param xChainMessenger The address of the Messenger app.\n    /// @param authorized The new authorization status.\n    function updateXChainMessengerAuthorization(\n        address xChainMessenger,\n        bool authorized\n    ) external;\n\n    /// @notice Fills an x-chain order that completed on the source chain.\n    /// @param externalAccount The external account to fill from, if any.\n    /// @param txid The txid of the quote.\n    /// @param trader The trader to receive the funds.\n    /// @param quoteToken The token to be sent.\n    /// @param quoteTokenAmount The amount of quoteToken to be sent.\n    function fillXChain(\n        address externalAccount,\n        bytes32 txid,\n        address trader,\n        address quoteToken,\n        uint256 quoteTokenAmount\n    ) external;\n\n    /// @notice Updates withdrawal account authorization.\n    /// @param withdrawalAccounts the accounts for which to update authorization status.\n    /// @param authorized The new authorization status.\n    function updateWithdrawalAccount(\n        address[] memory withdrawalAccounts,\n        bool authorized\n    ) external;\n\n    /// @notice Updates the signer key.\n    /// @param signer The new signer key.\n    function updateSigner(address signer) external;\n\n    /// @notice Used by the router to disable pool actions (Trade, Withdraw, Deposit)\n    function killswitchOperations(bool enabled) external;\n\n    /// @notice Returns the token reserves for this pool.\n    /// @param token The token to check reserves for.\n    function getReserves(address token) external view returns (uint256);\n\n    /// @notice Approves a token for spend. Used for 1inch RFQ protocol.\n    /// @param token The address of the ERC-20 token.\n    /// @param spender The spender address (typically the 1inch RFQ order router)\n    /// @param amount The approval amount.\n    function approveToken(\n        address token,\n        address spender,\n        uint256 amount\n    ) external;\n\n    /// @notice Increases allowance for a token. Used for 1inch RFQ protocol.\n    /// @param token The address of the ERC-20 token.\n    /// @param spender The spender address (typically the 1inch RFQ order router).\n    /// @param amount The approval amount.\n    function increaseTokenAllowance(\n        address token,\n        address spender,\n        uint256 amount\n    ) external;\n\n    /// @notice Decreases allowance for a token. Used for 1inch RFQ protocol.\n    /// @param token The address of the ERC-20 token.\n    /// @param spender The spender address (typically the 1inch RFQ order router)\n    /// @param amount The approval amount.\n    function decreaseTokenAllowance(\n        address token,\n        address spender,\n        uint256 amount\n    ) external;\n}\n"
      },
      "contracts/interfaces/IHashflowRouter.sol": {
        "content": "/**\n * SPDX-License-Identifier: UNLICENSED\n */\npragma solidity >=0.8.0;\n\nimport './IQuote.sol';\n\n/// @title IHashflowRouter\n/// @author Victor Ionescu\n/**\n * @notice In terms of user-facing functionality, the Router is responsible for:\n * - orchestrating trades\n * - managing cross-chain permissions\n *\n * Every trade requires consent from two parties: the Trader and the Market Maker.\n * However, there are two models to establish consent:\n * - RFQ-T: in this model, the Market Maker provides an EIP-191 signature for the quote,\n *   while the Trader signs the transaction and submits it on-chain\n * - RFQ-M: in this model, the Trader provides an EIP-712 signature for the quote,\n *   the Market Maker provides an EIP-191 signature, and a 3rd party relays the trade.\n *   The 3rd party can be the Market Maker itself.\n *\n * In terms of Hashflow internals, the Router maintains a set of authorized pool\n * contracts that are allowed to be used for trading. This allowlist creates\n * guarantees against malicious behavior, as documented in specific places.\n *\n * The Router contract is not upgradeable. In order to change functionality, a new\n * Router has to be deployed, and new HashflowPool contracts have to be deployed\n * by the Market Makers.\n */\n/// @dev Trade / liquidity events are emitted at the HashflowPool level, rather than the router.\ninterface IHashflowRouter is IQuote {\n    /**\n     * @notice X-Chain message received from an X-Chain Messenger. This is used by the\n     * Router to communicate a fill to a HashflowPool.\n     */\n    struct XChainFillMessage {\n        /// @notice The Hashflow Chain ID of the source chain.\n        uint16 srcHashflowChainId;\n        /// @notice The address of the HashflowPool on the source chain.\n        bytes32 srcPool;\n        /// @notice The HashflowPool to disburse funds on the destination chain.\n        address dstPool;\n        /**\n         * @notice The external account linked to the HashflowPool on the destination chain.\n         * If the HashflowPool holds funds, this should be bytes32(0).\n         */\n        address dstExternalAccount;\n        /// @notice The recipient of the quoteToken on the destination chain.\n        address dstTrader;\n        /// @notice The token that the trader buys on the destination chain.\n        address quoteToken;\n        /// @notice The amount of quoteToken bought.\n        uint256 quoteTokenAmount;\n        /// @notice Unique identifier for the quote.\n        /// @dev Generated off-chain via a distributed UUID generator.\n        bytes32 txid;\n        /// @notice The caller of the trade function on the source chain.\n        bytes32 srcCaller;\n        /// @notice The contract to call, if any.\n        address dstContract;\n        /// @notice The calldata for the contract.\n        bytes dstContractCalldata;\n    }\n\n    /// @notice Emitted when the authorization status of a pool changes.\n    /// @param pool The pool whose status changed.\n    /// @param authorized The new auth status.\n    event UpdatePoolAuthorizaton(address pool, bool authorized);\n\n    /// @notice Emitted when a sender pool authorization changes.\n    /// @param pool Pool address on this chain.\n    /// @param otherHashflowChainId Hashflow Chain ID of the other chain.\n    /// @param otherChainPool Pool address on the other chain.\n    /// @param authorized Whether the pool is authorized.\n    event UpdateXChainPoolAuthorization(\n        address indexed pool,\n        uint16 otherHashflowChainId,\n        bytes32 otherChainPool,\n        bool authorized\n    );\n\n    /// @notice Emitted when the authorization of an x-caller changes.\n    /// @param pool Pool address on this chain.\n    /// @param otherHashflowChainId Hashflow Chain ID of the other chain.\n    /// @param caller Caller address on the other chain.\n    /// @param authorized Whether the caller is authorized.\n    event UpdateXChainCallerAuthorization(\n        address indexed pool,\n        uint16 otherHashflowChainId,\n        bytes32 caller,\n        bool authorized\n    );\n\n    /// @notice Emitted when the authorization status of an X-Chain Messenger changes for a pool.\n    /// @param pool Pool address for which the Messenger authorization changes.\n    /// @param xChainMessenger Address of the Messenger.\n    /// @param authorized Whether the X-Chain Messenger is authorized.\n    event UpdateXChainMessengerAuthorization(\n        address indexed pool,\n        address xChainMessenger,\n        bool authorized\n    );\n\n    /// @notice Emitted when the authorized status of an X-Chain Messenger changes for a callee.\n    /// @param callee Address of the callee.\n    /// @param xChainMessenger Address of the Messenger.\n    /// @param authorized Whether the X-Chain Messenger is authorized.\n    event UpdateXChainMessengerCallerAuthorization(\n        address indexed callee,\n        address xChainMessenger,\n        bool authorized\n    );\n\n    /// @notice Emitted when the Limit Order Guardian address is updated.\n    /// @param guardian The new Guardian address.\n    event UpdateLimitOrderGuardian(address guardian);\n\n    /// @notice Initializes the Router. Called one time.\n    /// @param factory The address of the HashflowFactory contract.\n    function initialize(address factory) external;\n\n    /// @notice Returns the address of the associated HashflowFactor contract.\n    function factory() external view returns (address);\n\n    function authorizedXChainPools(\n        bytes32 dstPool,\n        uint16 srcHChainId,\n        bytes32 srcPool\n    ) external view returns (bool);\n\n    function authorizedXChainCallers(\n        address dstContract,\n        uint16 srcHashflowChainId,\n        bytes32 caller\n    ) external view returns (bool);\n\n    function authorizedXChainMessengersByPool(address pool, address messenger)\n        external\n        view\n        returns (bool);\n\n    function authorizedXChainMessengersByCallee(\n        address callee,\n        address messenger\n    ) external view returns (bool);\n\n    /// @notice Executes an intra-chain RFQ-T trade.\n    /// @param quote The quote data to be executed.\n    function tradeRFQT(RFQTQuote memory quote) external payable;\n\n    /// @notice Executes an intra-chain RFQ-T trade, leveraging an ERC-20 permit.\n    /// @param quote The quote data to be executed.\n    /// @dev Does not support native tokens for the baseToken.\n    function tradeRFQTWithPermit(\n        RFQTQuote memory quote,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s,\n        uint256 amountToApprove\n    ) external;\n\n    /// @notice Executes an intra-chain RFQ-T trade.\n    /// @param quote The quote to be executed.\n    function tradeRFQM(RFQMQuote memory quote) external;\n\n    /// @notice Executes an intra-chain RFQ-T trade, leveraging an ERC-20 permit.\n    /// @param quote The quote to be executed.\n    /// @param deadline The deadline of the ERC-20 permit.\n    /// @param v v-part of the signature.\n    /// @param r r-part of the signature.\n    /// @param s s-part of the signature.\n    /// @param amountToApprove The amount being approved.\n    function tradeRFQMWithPermit(\n        RFQMQuote memory quote,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s,\n        uint256 amountToApprove\n    ) external;\n\n    /// @notice Executes an intra-chain RFQ-T trade.\n    /// @param quote The quote to be executed.\n    /// @param guardianSignature A signature issued by the Limit Order Guardian.\n    function tradeRFQMLimitOrder(\n        RFQMQuote memory quote,\n        bytes memory guardianSignature\n    ) external;\n\n    /// @notice Executes an intra-chain RFQ-T trade, leveraging an ERC-20 permit.\n    /// @param quote The quote to be executed.\n    /// @param guardianSignature A signature issued by the Limit Order Guardian.\n    /// @param deadline The deadline of the ERC-20 permit.\n    /// @param v v-part of the signature.\n    /// @param r r-part of the signature.\n    /// @param s s-part of the signature.\n    /// @param amountToApprove The amount being approved.\n    function tradeRFQMLimitOrderWithPermit(\n        RFQMQuote memory quote,\n        bytes memory guardianSignature,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s,\n        uint256 amountToApprove\n    ) external;\n\n    /// @notice Executes an RFQ-T cross-chain trade.\n    /// @param quote The quote to be executed.\n    /// @param dstContract The address of the contract to be called on the destination chain.\n    /// @param dstCalldata The calldata for the smart contract call.\n    function tradeXChainRFQT(\n        XChainRFQTQuote memory quote,\n        bytes32 dstContract,\n        bytes memory dstCalldata\n    ) external payable;\n\n    /// @notice Executes an RFQ-T cross-chain trade, leveraging an ERC-20 permit.\n    /// @param quote The quote to be executed.\n    /// @param dstContract The address of the contract to be called on the destination chain.\n    /// @param dstCalldata The calldata for the smart contract call.\n    /// @param deadline The deadline of the ERC-20 permit.\n    /// @param v v-part of the signature.\n    /// @param r r-part of the signature.\n    /// @param s s-part of the signature.\n    /// @param amountToApprove The amount being approved.\n    function tradeXChainRFQTWithPermit(\n        XChainRFQTQuote memory quote,\n        bytes32 dstContract,\n        bytes memory dstCalldata,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s,\n        uint256 amountToApprove\n    ) external payable;\n\n    /// @notice Executes an RFQ-M cross-chain trade.\n    /// @param quote The quote to be executed.\n    /// @param dstContract The address of the contract to be called on the destination chain.\n    /// @param dstCalldata The calldata for the smart contract call.\n    function tradeXChainRFQM(\n        XChainRFQMQuote memory quote,\n        bytes32 dstContract,\n        bytes memory dstCalldata\n    ) external payable;\n\n    /// @notice Similar to tradeXChainRFQm, but includes a spend permit for the baseToken.\n    /// @param quote The quote to be executed.\n    /// @param dstContract The address of the contract to be called on the destination chain.\n    /// @param dstCalldata The calldata for the smart contract call.\n    /// @param deadline The deadline of the ERC-20 permit.\n    /// @param v v-part of the signature.\n    /// @param r r-part of the signature.\n    /// @param s s-part of the signature.\n    /// @param amountToApprove The amount to approve.\n    function tradeXChainRFQMWithPermit(\n        XChainRFQMQuote memory quote,\n        bytes32 dstContract,\n        bytes memory dstCalldata,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s,\n        uint256 amountToApprove\n    ) external payable;\n\n    /// @notice Completes the second leg of a cross-chain trade.\n    /// @param fillMessage Payload containing information necessary to complete the trade.\n    function fillXChain(XChainFillMessage memory fillMessage) external;\n\n    /// @notice Returns whether the pool is authorized for trading.\n    /// @param pool The address of the HashflowPool.\n    function authorizedPools(address pool) external view returns (bool);\n\n    /// @notice Allows the owner to unauthorize a potentially compromised pool. Cannot be reverted.\n    /// @param pool The address of the HashflowPool.\n    function forceUnauthorizePool(address pool) external;\n\n    /// @notice Authorizes a HashflowPool for trading.\n    /// @dev Can only be called by the HashflowFactory or the admin.\n    function updatePoolAuthorization(address pool, bool authorized) external;\n\n    /// @notice Updates the authorization status of an X-Chain pool pair.\n    /// @param otherHashflowChainId The Hashflow Chain ID of the peer chain.\n    /// @param otherPool The 32-byte representation of the Pool address on the peer chain.\n    /// @param authorized Whether the pool is authorized to communicate with the sender pool.\n    function updateXChainPoolAuthorization(\n        uint16 otherHashflowChainId,\n        bytes32 otherPool,\n        bool authorized\n    ) external;\n\n    /// @notice Updates the authorization status of an X-Chain caller.\n    /// @param otherHashflowChainId The Hashflow Chain ID of the peer chain.\n    /// @param caller The caller address.\n    /// @param authorized Whether the caller is authorized to send an x-call to the sender pool.\n    function updateXChainCallerAuthorization(\n        uint16 otherHashflowChainId,\n        bytes32 caller,\n        bool authorized\n    ) external;\n\n    /// @notice Updates the authorization status of an X-Chain Messenger app.\n    /// @param xChainMessenger The address of the Messenger App.\n    /// @param authorized The new authorization status.\n    function updateXChainMessengerAuthorization(\n        address xChainMessenger,\n        bool authorized\n    ) external;\n\n    /// @notice Updates the authorization status of an X-Chain Messenger app.\n    /// @param xChainMessenger The address of the Messenger App.\n    /// @param authorized The new authorization status.\n    function updateXChainMessengerCallerAuthorization(\n        address xChainMessenger,\n        bool authorized\n    ) external;\n\n    /// @notice Used to stop all operations on a pool, in case of an emergency.\n    /// @param pool The address of the HashflowPool.\n    /// @param enabled Whether the pool is enabled.\n    function killswitchPool(address pool, bool enabled) external;\n\n    /// @notice Used to update the Limit Order Guardian.\n    /// @param guardian The address of the new Guardian.\n    function updateLimitOrderGuardian(address guardian) external;\n\n    /// @notice Allows the owner to withdraw excess funds from the Router.\n    /// @dev Under normal operations, the Router should not have excess funds.\n    function withdrawFunds(address token) external;\n}\n"
      },
      "contracts/interfaces/IQuote.sol": {
        "content": "/**\n * SPDX-License-Identifier: UNLICENSED\n */\npragma solidity >=0.8.0;\n\n/// @title IQuote\n/// @author Victor Ionescu\n/**\n * @notice Interface for quote structs used for trading. There are two major types of trades:\n * - intra-chain: atomic transactions within one chain\n * - cross-chain: multi-leg transactions between two chains, which utilize interoperability protocols\n *                such as Wormhole.\n *\n * Separately, there are two trading modes:\n * - RFQ-T: the trader signs the transaction, the market maker signs the quote\n * - RFQ-M: both the trader and Market Maker sign the quote, any relayer can sign the transaction\n */\ninterface IQuote {\n    /// @notice Used for intra-chain RFQ-T trades.\n    struct RFQTQuote {\n        /// @notice The address of the HashflowPool to trade against.\n        address pool;\n        /**\n         * @notice The external account linked to the HashflowPool.\n         * If the HashflowPool holds funds, this should be address(0).\n         */\n        address externalAccount;\n        /// @notice The recipient of the quoteToken at the end of the trade.\n        address trader;\n        /**\n         * @notice The account \"effectively\" making the trade (ultimately receiving the funds).\n         * This is commonly used by aggregators, where a proxy contract (the 'trader')\n         * receives the quoteToken, and the effective trader is the user initiating the call.\n         *\n         * This field DOES NOT influence movement of funds. However, it is used to check against\n         * quote replay.\n         */\n        address effectiveTrader;\n        /// @notice The token that the trader sells.\n        address baseToken;\n        /// @notice The token that the trader buys.\n        address quoteToken;\n        /**\n         * @notice The amount of baseToken sold in this trade. The exchange rate\n         * is going to be preserved as the quoteTokenAmount / baseTokenAmount ratio.\n         *\n         * Most commonly, effectiveBaseTokenAmount will == baseTokenAmount.\n         */\n        uint256 effectiveBaseTokenAmount;\n        /// @notice The max amount of baseToken sold.\n        uint256 baseTokenAmount;\n        /// @notice The amount of quoteToken bought when baseTokenAmount is sold.\n        uint256 quoteTokenAmount;\n        /// @notice The Unix timestamp (in seconds) when the quote expires.\n        /// @dev This gets checked against block.timestamp.\n        uint256 quoteExpiry;\n        /// @notice The nonce used by this effectiveTrader. Nonces are used to protect against replay.\n        uint256 nonce;\n        /// @notice Unique identifier for the quote.\n        /// @dev Generated off-chain via a distributed UUID generator.\n        bytes32 txid;\n        /// @notice Signature provided by the market maker (EIP-191).\n        bytes signature;\n    }\n\n    /// @notice Used for intra-chain RFQ-M trades.\n    struct RFQMQuote {\n        /// @notice The address of the HashflowPool to trade against.\n        address pool;\n        /**\n         * @notice The external account linked to the HashflowPool.\n         * If the HashflowPool holds funds, this should be address(0).\n         */\n        address externalAccount;\n        /// @notice The account that will be debited baseToken / credited quoteToken.\n        address trader;\n        /// @notice The token that the trader sells.\n        address baseToken;\n        /// @notice The token that the trader buys.\n        address quoteToken;\n        /// @notice The amount of baseToken sold.\n        uint256 baseTokenAmount;\n        /// @notice The amount of quoteToken bought.\n        uint256 quoteTokenAmount;\n        /// @notice The Unix timestamp (in seconds) when the quote expires.\n        /// @dev This gets checked against block.timestamp.\n        uint256 quoteExpiry;\n        /// @notice Unique identifier for the quote.\n        /// @dev Generated off-chain via a distributed UUID generator.\n        bytes32 txid;\n        /// @notice Signature provided by the trader (EIP-712).\n        bytes takerSignature;\n        /// @notice Signature provided by the market maker (EIP-191).\n        bytes makerSignature;\n    }\n\n    /// @notice Used for cross-chain RFQ-T trades.\n    struct XChainRFQTQuote {\n        /// @notice The Hashflow Chain ID of the source chain.\n        uint16 srcChainId;\n        /// @notice The Hashflow Chain ID of the destination chain.\n        uint16 dstChainId;\n        /// @notice The address of the HashflowPool to trade against on the source chain.\n        address srcPool;\n        /// @notice The HashflowPool to disburse funds on the destination chain.\n        /// @dev This is bytes32 in order to anticipate non-EVM chains.\n        bytes32 dstPool;\n        /**\n         * @notice The external account linked to the HashflowPool on the source chain.\n         * If the HashflowPool holds funds, this should be address(0).\n         */\n        address srcExternalAccount;\n        /**\n         * @notice The external account linked to the HashflowPool on the destination chain.\n         * If the HashflowPool holds funds, this should be bytes32(0).\n         */\n        bytes32 dstExternalAccount;\n        /// @notice The recipient of the quoteToken on the destination chain.\n        bytes32 dstTrader;\n        /// @notice The token that the trader sells on the source chain.\n        address baseToken;\n        /// @notice The token that the trader buys on the destination chain.\n        bytes32 quoteToken;\n        /**\n         * @notice The amount of baseToken sold in this trade. The exchange rate\n         * is going to be preserved as the quoteTokenAmount / baseTokenAmount ratio.\n         *\n         * Most commonly, effectiveBaseTokenAmount will == baseTokenAmount.\n         */\n        uint256 effectiveBaseTokenAmount;\n        /// @notice The amount of baseToken sold.\n        uint256 baseTokenAmount;\n        /// @notice The amount of quoteToken bought.\n        uint256 quoteTokenAmount;\n        /**\n         * @notice The Unix timestamp (in seconds) when the quote expire. Only enforced\n         * on the source chain.\n         */\n        /// @dev This gets checked against block.timestamp.\n        uint256 quoteExpiry;\n        /// @notice The nonce used by this trader.\n        uint256 nonce;\n        /// @notice Unique identifier for the quote.\n        /// @dev Generated off-chain via a distributed UUID generator.\n        bytes32 txid;\n        /**\n         * @notice The address of the IHashflowXChainMessenger contract used for\n         * cross-chain communication.\n         */\n        address xChainMessenger;\n        /// @notice Signature provided by the market maker (EIP-191).\n        bytes signature;\n    }\n\n    /// @notice Used for Cross-Chain RFQ-M trades.\n    struct XChainRFQMQuote {\n        /// @notice The Hashflow Chain ID of the source chain.\n        uint16 srcChainId;\n        /// @notice The Hashflow Chain ID of the destination chain.\n        uint16 dstChainId;\n        /// @notice The address of the HashflowPool to trade against on the source chain.\n        address srcPool;\n        /// @notice The HashflowPool to disburse funds on the destination chain.\n        /// @dev This is bytes32 in order to anticipate non-EVM chains.\n        bytes32 dstPool;\n        /**\n         * @notice The external account linked to the HashflowPool on the source chain.\n         * If the HashflowPool holds funds, this should be address(0).\n         */\n        address srcExternalAccount;\n        /**\n         * @notice The external account linked to the HashflowPool on the destination chain.\n         * If the HashflowPool holds funds, this should be bytes32(0).\n         */\n        bytes32 dstExternalAccount;\n        /// @notice The account that will be debited baseToken on the source chain.\n        address trader;\n        /// @notice The recipient of the quoteToken on the destination chain.\n        bytes32 dstTrader;\n        /// @notice The token that the trader sells on the source chain.\n        address baseToken;\n        /// @notice The token that the trader buys on the destination chain.\n        bytes32 quoteToken;\n        /// @notice The amount of baseToken sold.\n        uint256 baseTokenAmount;\n        /// @notice The amount of quoteToken bought.\n        uint256 quoteTokenAmount;\n        /**\n         * @notice The Unix timestamp (in seconds) when the quote expire. Only enforced\n         * on the source chain.\n         */\n        /// @dev This gets checked against block.timestamp.\n        uint256 quoteExpiry;\n        /// @notice Unique identifier for the quote.\n        /// @dev Generated off-chain via a distributed UUID generator.\n        bytes32 txid;\n        /**\n         * @notice The address of the IHashflowXChainMessenger contract used for\n         * cross-chain communication.\n         */\n        address xChainMessenger;\n        /// @notice Signature provided by the trader (EIP-712).\n        bytes takerSignature;\n        /// @notice Signature provided by the market maker (EIP-191).\n        bytes makerSignature;\n    }\n}\n"
      },
      "contracts/pools/HashflowPool.sol": {
        "content": "/**\n * SPDX-License-Identifier: UNLICENSED\n */\npragma solidity 0.8.18;\n\nimport '@openzeppelin/contracts/proxy/utils/Initializable.sol';\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\nimport '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';\nimport '@openzeppelin/contracts/utils/Context.sol';\n\nimport '../interfaces/external/IWETH.sol';\nimport '../interfaces/IHashflowPool.sol';\nimport '../interfaces/IHashflowRouter.sol';\n\ninterface IERC20AllowanceExtension {\n    function increaseAllowance(address spender, uint256 addedValue)\n        external\n        returns (bool);\n\n    function decreaseAllowance(address spender, uint256 subtractedValue)\n        external\n        returns (bool);\n}\n\ncontract HashflowPool is IHashflowPool, Initializable, Context {\n    using Address for address payable;\n    using SafeERC20 for IERC20;\n    using ECDSA for bytes32;\n\n    string public name;\n\n    SignerConfiguration public signerConfiguration;\n    address public operations;\n\n    address public router;\n\n    mapping(address => uint256) public nonces;\n    mapping(bytes32 => uint256) public xChainNonces;\n\n    mapping(address => bool) internal _withrawalAccountAuth;\n    mapping(bytes32 => bool) internal _filledXChainTxids;\n\n    address public immutable _WETH;\n\n    constructor(address weth) {\n        require(\n            weth != address(0),\n            'HashflowPool::constructor WETH cannot be 0 address.'\n        );\n        _WETH = weth;\n    }\n\n    /// @dev Fallback function to receive native token.\n    receive() external payable {}\n\n    /// @inheritdoc IHashflowPool\n    function initialize(\n        string memory _name,\n        address _signer,\n        address _operations,\n        address _router\n    ) public override initializer {\n        require(\n            _signer != address(0),\n            'HashflowPool::initialize Signer cannot be 0 address.'\n        );\n        require(\n            _operations != address(0),\n            'HashflowPool::initialize Operations cannot be 0 address.'\n        );\n        require(\n            _router != address(0),\n            'HashflowPool::initialize Router cannot be 0 address.'\n        );\n        require(\n            bytes(_name).length > 0,\n            'HashflowPool::initialize Name cannot be empty'\n        );\n\n        name = _name;\n\n        SignerConfiguration memory signerConfig;\n        signerConfig.enabled = true;\n        signerConfig.signer = _signer;\n\n        emit UpdateSigner(_signer, address(0));\n\n        signerConfiguration = signerConfig;\n\n        operations = _operations;\n        router = _router;\n    }\n\n    modifier authorizedOperations() {\n        require(\n            _msgSender() == operations,\n            'HashflowPool:authorizedOperations Sender must be operator.'\n        );\n        _;\n    }\n\n    modifier authorizedRouter() {\n        require(\n            _msgSender() == router,\n            'HashflowPool::authorizedRouter Sender must be Router.'\n        );\n        _;\n    }\n\n    /// @inheritdoc IHashflowPool\n    function tradeRFQT(RFQTQuote memory quote)\n        external\n        payable\n        override\n        authorizedRouter\n    {\n        /// Trust assumption: the Router has transferred baseToken.\n        require(\n            quote.baseToken != address(0) ||\n                quote.externalAccount != address(0) ||\n                msg.value == quote.effectiveBaseTokenAmount,\n            'HashflowPool::tradeRFQT msg.value must equal effectiveBaseTokenAmount'\n        );\n        bytes32 quoteHash = _hashQuoteRFQT(quote);\n\n        SignerConfiguration memory signerConfig = signerConfiguration;\n        require(signerConfig.enabled, 'HashflowPool::tradeRFQT Disabled.');\n\n        require(\n            quoteHash.recover(quote.signature) == signerConfig.signer,\n            'HashflowPool::tradeRFQT Invalid signer.'\n        );\n        _updateNonce(quote.effectiveTrader, quote.nonce);\n\n        uint256 quoteTokenAmount = quote.quoteTokenAmount;\n        if (quote.effectiveBaseTokenAmount < quote.baseTokenAmount) {\n            quoteTokenAmount =\n                (quote.effectiveBaseTokenAmount * quote.quoteTokenAmount) /\n                quote.baseTokenAmount;\n        }\n\n        emit Trade(\n            quote.trader,\n            quote.effectiveTrader,\n            quote.txid,\n            quote.baseToken,\n            quote.quoteToken,\n            quote.effectiveBaseTokenAmount,\n            quoteTokenAmount\n        );\n\n        if (quote.externalAccount == address(0)) {\n            _transferFromPool(quote.quoteToken, quote.trader, quoteTokenAmount);\n        } else {\n            _transferFromExternalAccount(\n                quote.externalAccount,\n                quote.quoteToken,\n                quote.trader,\n                quoteTokenAmount\n            );\n        }\n    }\n\n    /// @inheritdoc IHashflowPool\n    function tradeRFQM(RFQMQuote memory quote)\n        external\n        override\n        authorizedRouter\n    {\n        SignerConfiguration memory signerConfig = signerConfiguration;\n        require(signerConfig.enabled, 'HashflowPool::tradeRFQM Disabled.');\n\n        bytes32 quoteHash = _hashQuoteRFQM(quote);\n        require(\n            quoteHash.recover(quote.makerSignature) == signerConfig.signer,\n            'HashflowPool::tradeRFQM Invalid signer.'\n        );\n\n        emit Trade(\n            quote.trader,\n            quote.trader,\n            quote.txid,\n            quote.baseToken,\n            quote.quoteToken,\n            quote.baseTokenAmount,\n            quote.quoteTokenAmount\n        );\n\n        if (quote.externalAccount == address(0)) {\n            _transferFromPool(\n                quote.quoteToken,\n                quote.trader,\n                quote.quoteTokenAmount\n            );\n        } else {\n            _transferFromExternalAccount(\n                quote.externalAccount,\n                quote.quoteToken,\n                quote.trader,\n                quote.quoteTokenAmount\n            );\n        }\n    }\n\n    /// @inheritdoc IHashflowPool\n    function tradeXChainRFQT(XChainRFQTQuote memory quote, address trader)\n        external\n        payable\n        override\n        authorizedRouter\n    {\n        require(\n            quote.srcExternalAccount != address(0) ||\n                quote.baseToken != address(0) ||\n                msg.value == quote.effectiveBaseTokenAmount,\n            'HashflowPool::tradeXChainRFQT msg.value must = amount'\n        );\n\n        SignerConfiguration memory signerConfig = signerConfiguration;\n        require(\n            signerConfig.enabled,\n            'HashflowPool::tradeXChainRFQT Disabled.'\n        );\n\n        _updateNonceXChain(quote.dstTrader, quote.nonce);\n        bytes32 quoteHash = _hashXChainQuoteRFQT(quote);\n        require(\n            quoteHash.recover(quote.signature) == signerConfig.signer,\n            'HashflowPool::tradeXChainRFQT Invalid signer'\n        );\n\n        uint256 effectiveQuoteTokenAmount = quote.quoteTokenAmount;\n        if (quote.effectiveBaseTokenAmount < quote.baseTokenAmount) {\n            effectiveQuoteTokenAmount =\n                (quote.quoteTokenAmount * quote.effectiveBaseTokenAmount) /\n                quote.baseTokenAmount;\n        }\n\n        emit XChainTrade(\n            quote.dstChainId,\n            quote.dstPool,\n            trader,\n            quote.dstTrader,\n            quote.txid,\n            quote.baseToken,\n            quote.quoteToken,\n            quote.effectiveBaseTokenAmount,\n            effectiveQuoteTokenAmount\n        );\n    }\n\n    /// @inheritdoc IHashflowPool\n    function fillXChain(\n        address externalAccount,\n        bytes32 txid,\n        address trader,\n        address quoteToken,\n        uint256 quoteTokenAmount\n    ) external override authorizedRouter {\n        require(\n            !_filledXChainTxids[txid],\n            'HashflowPool::fillXChain Quote has been executed previously.'\n        );\n        _filledXChainTxids[txid] = true;\n\n        emit XChainTradeFill(txid);\n\n        if (externalAccount == address(0)) {\n            _transferFromPool(quoteToken, trader, quoteTokenAmount);\n        } else {\n            _transferFromExternalAccount(\n                externalAccount,\n                quoteToken,\n                trader,\n                quoteTokenAmount\n            );\n        }\n    }\n\n    /// @inheritdoc IHashflowPool\n    function tradeXChainRFQM(XChainRFQMQuote memory quote)\n        external\n        override\n        authorizedRouter\n    {\n        SignerConfiguration memory signerConfig = signerConfiguration;\n        require(\n            signerConfig.enabled,\n            'HashflowPool::tradeXChainRFQM Disabled.'\n        );\n\n        bytes32 quoteHash = _hashXChainQuoteRFQM(quote);\n        require(\n            quoteHash.recover(quote.makerSignature) == signerConfig.signer,\n            'HashflowPool::tradeXChainRFQM Invalid signer'\n        );\n        emit XChainTrade(\n            quote.dstChainId,\n            quote.dstPool,\n            quote.trader,\n            quote.dstTrader,\n            quote.txid,\n            quote.baseToken,\n            quote.quoteToken,\n            quote.baseTokenAmount,\n            quote.quoteTokenAmount\n        );\n    }\n\n    /// @inheritdoc IHashflowPool\n    function updateXChainPoolAuthorization(\n        AuthorizedXChainPool[] calldata pools,\n        bool status\n    ) external override authorizedOperations {\n        for (uint256 i = 0; i < pools.length; i++) {\n            require(pools[i].pool != bytes32(0));\n            IHashflowRouter(router).updateXChainPoolAuthorization(\n                pools[i].chainId,\n                pools[i].pool,\n                status\n            );\n        }\n    }\n\n    /// @inheritdoc IHashflowPool\n    function updateXChainMessengerAuthorization(\n        address xChainMessenger,\n        bool authorized\n    ) external override authorizedOperations {\n        require(\n            xChainMessenger != address(0),\n            'HashflowPool::updateXChainMessengerAuthorization Invalid messenger address.'\n        );\n        IHashflowRouter(router).updateXChainMessengerAuthorization(\n            xChainMessenger,\n            authorized\n        );\n    }\n\n    /// @dev ERC1271 implementation.\n    function isValidSignature(bytes32 hash, bytes memory signature)\n        external\n        view\n        override\n        returns (bytes4 magicValue)\n    {\n        if (hash.recover(signature) == signerConfiguration.signer) {\n            magicValue = 0x1626ba7e;\n        }\n    }\n\n    /// @inheritdoc IHashflowPool\n    function approveToken(\n        address token,\n        address spender,\n        uint256 amount\n    ) external override authorizedOperations {\n        IERC20(token).forceApprove(spender, amount);\n    }\n\n    /// @inheritdoc IHashflowPool\n    function increaseTokenAllowance(\n        address token,\n        address spender,\n        uint256 amount\n    ) external override authorizedOperations {\n        IERC20(token).safeIncreaseAllowance(spender, amount);\n    }\n\n    /// @inheritdoc IHashflowPool\n    function decreaseTokenAllowance(\n        address token,\n        address spender,\n        uint256 amount\n    ) external override authorizedOperations {\n        IERC20(token).safeDecreaseAllowance(spender, amount);\n    }\n\n    /// @inheritdoc IHashflowPool\n    function removeLiquidity(\n        address token,\n        address recipient,\n        uint256 amount\n    ) external override authorizedOperations {\n        SignerConfiguration memory signerConfig = signerConfiguration;\n        require(\n            signerConfig.enabled,\n            'HashflowPool::removeLiquidity Disabled.'\n        );\n\n        require(amount > 0, 'HashflowPool::removeLiquidity Invalid amount');\n        address _recipient;\n        if (recipient != address(0)) {\n            require(\n                _withrawalAccountAuth[recipient],\n                'HashflowPool::removeLiquidity Recipient must be hedging account'\n            );\n\n            _recipient = recipient;\n        } else {\n            _recipient = _msgSender();\n        }\n\n        emit RemoveLiquidity(token, _recipient, amount);\n\n        _transferFromPool(token, _recipient, amount);\n    }\n\n    /// @inheritdoc IHashflowPool\n    function updateWithdrawalAccount(\n        address[] memory withdrawalAccounts,\n        bool authorized\n    ) external override authorizedOperations {\n        for (uint256 i = 0; i < withdrawalAccounts.length; i++) {\n            require(withdrawalAccounts[i] != address(0));\n            _withrawalAccountAuth[withdrawalAccounts[i]] = authorized;\n            emit UpdateWithdrawalAccount(withdrawalAccounts[i], authorized);\n        }\n    }\n\n    /// @inheritdoc IHashflowPool\n    function updateSigner(address newSigner)\n        external\n        override\n        authorizedOperations\n    {\n        require(newSigner != address(0));\n\n        SignerConfiguration memory signerConfig = signerConfiguration;\n\n        emit UpdateSigner(newSigner, signerConfig.signer);\n\n        signerConfig.signer = newSigner;\n        signerConfiguration = signerConfig;\n    }\n\n    /// @inheritdoc IHashflowPool\n    function killswitchOperations(bool enabled)\n        external\n        override\n        authorizedRouter\n    {\n        SignerConfiguration memory signerConfig = signerConfiguration;\n\n        signerConfig.enabled = enabled;\n\n        signerConfiguration = signerConfig;\n    }\n\n    function getReserves(address token)\n        external\n        view\n        override\n        returns (uint256)\n    {\n        return _getReserves(token);\n    }\n\n    /**\n     * @dev Prevents against replay for RFQ-T. Checks that nonces are strictly increasing.\n     */\n    function _updateNonce(address trader, uint256 nonce) internal {\n        require(\n            nonce > nonces[trader],\n            'HashflowPool::_updateNonce Invalid nonce.'\n        );\n        nonces[trader] = nonce;\n    }\n\n    /**\n     * @dev Prevents against replay for X-Chain RFQ-T. Checks that nonces are strictly increasing.\n     */\n    function _updateNonceXChain(bytes32 trader, uint256 nonce) internal {\n        require(\n            nonce > xChainNonces[trader],\n            'HashflowPool::_updateNonceXChain Invalid nonce.'\n        );\n        xChainNonces[trader] = nonce;\n    }\n\n    function _transferFromPool(\n        address token,\n        address recipient,\n        uint256 value\n    ) internal {\n        if (token == address(0)) {\n            payable(recipient).sendValue(value);\n        } else {\n            IERC20(token).safeTransfer(recipient, value);\n        }\n    }\n\n    /// @dev Helper function to transfer quoteToken from external account.\n    function _transferFromExternalAccount(\n        address externalAccount,\n        address token,\n        address receiver,\n        uint256 value\n    ) private {\n        if (token == address(0)) {\n            IERC20(_WETH).safeTransferFrom(\n                externalAccount,\n                address(this),\n                value\n            );\n\n            IWETH(_WETH).withdraw(value);\n            payable(receiver).sendValue(value);\n        } else {\n            IERC20(token).safeTransferFrom(externalAccount, receiver, value);\n        }\n    }\n\n    function _getReserves(address token) internal view returns (uint256) {\n        return\n            token == address(0)\n                ? address(this).balance\n                : IERC20(token).balanceOf(address(this));\n    }\n\n    /**\n     * @dev Generates a quote hash for RFQ-t.\n     */\n    function _hashQuoteRFQT(RFQTQuote memory quote)\n        private\n        view\n        returns (bytes32)\n    {\n        return\n            keccak256(\n                abi.encodePacked(\n                    '\\x19Ethereum Signed Message:\\n32',\n                    keccak256(\n                        abi.encodePacked(\n                            address(this),\n                            quote.trader,\n                            quote.effectiveTrader,\n                            quote.externalAccount,\n                            quote.baseToken,\n                            quote.quoteToken,\n                            quote.baseTokenAmount,\n                            quote.quoteTokenAmount,\n                            quote.nonce,\n                            quote.quoteExpiry,\n                            quote.txid,\n                            block.chainid\n                        )\n                    )\n                )\n            );\n    }\n\n    function _hashQuoteRFQM(RFQMQuote memory quote)\n        private\n        view\n        returns (bytes32)\n    {\n        return\n            keccak256(\n                abi.encodePacked(\n                    '\\x19Ethereum Signed Message:\\n32',\n                    keccak256(\n                        abi.encodePacked(\n                            quote.pool,\n                            quote.externalAccount,\n                            quote.trader,\n                            quote.baseToken,\n                            quote.quoteToken,\n                            quote.baseTokenAmount,\n                            quote.quoteTokenAmount,\n                            quote.quoteExpiry,\n                            quote.txid,\n                            block.chainid\n                        )\n                    )\n                )\n            );\n    }\n\n    function _hashXChainQuoteRFQT(XChainRFQTQuote memory quote)\n        private\n        pure\n        returns (bytes32)\n    {\n        bytes32 digest = keccak256(\n            abi.encodePacked(\n                keccak256(\n                    abi.encodePacked(\n                        quote.srcChainId,\n                        quote.dstChainId,\n                        quote.srcPool,\n                        quote.dstPool,\n                        quote.srcExternalAccount,\n                        quote.dstExternalAccount\n                    )\n                ),\n                quote.dstTrader,\n                quote.baseToken,\n                quote.quoteToken,\n                quote.baseTokenAmount,\n                quote.quoteTokenAmount,\n                quote.quoteExpiry,\n                quote.nonce,\n                quote.txid,\n                quote.xChainMessenger\n            )\n        );\n        return\n            keccak256(\n                abi.encodePacked('\\x19Ethereum Signed Message:\\n32', digest)\n            );\n    }\n\n    function _hashXChainQuoteRFQM(XChainRFQMQuote memory quote)\n        private\n        pure\n        returns (bytes32)\n    {\n        return\n            keccak256(\n                abi.encodePacked(\n                    '\\x19Ethereum Signed Message:\\n32',\n                    keccak256(\n                        abi.encodePacked(\n                            keccak256(\n                                abi.encodePacked(\n                                    quote.srcChainId,\n                                    quote.dstChainId,\n                                    quote.srcPool,\n                                    quote.dstPool,\n                                    quote.srcExternalAccount,\n                                    quote.dstExternalAccount\n                                )\n                            ),\n                            quote.trader,\n                            quote.baseToken,\n                            quote.quoteToken,\n                            quote.baseTokenAmount,\n                            quote.quoteTokenAmount,\n                            quote.quoteExpiry,\n                            quote.txid,\n                            quote.xChainMessenger\n                        )\n                    )\n                )\n            );\n    }\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}