ETH Price: $1,867.32 (-4.24%)

Transaction Decoder

Block:
24289529 at Jan-22-2026 09:47:59 AM +UTC
Transaction Fee:
0.000006382822506648 ETH $0.01
Gas Used:
135,219 Gas / 0.047203592 Gwei

Emitted Events:

446 TransparentUpgradeableProxy.0x67427a9ff7b7a8bc19eeb98172dd4c920e53f548a3854807bafd7de9c0814bb7( 0x67427a9ff7b7a8bc19eeb98172dd4c920e53f548a3854807bafd7de9c0814bb7, 0x000000000000000000000000d7fb1de0a4c2ffe5474e003656302a3f3a388a8a, 0x0000000000000000000000000000000000000000000000000000000000000985, 0000000000000000000000000000000000000000000000000000000000000080, 00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a88, 00000000000000000000000000000000000000000000000000013d18f478b831, 0000000000000000000000000000000000000000000000000000000000000000, 0000000000000000000000000000000000000000000000000000000000000014, f9c809766cd31ec0531c7b72b19c2eb11eaa0770000000000000000000000000 )
447 TransparentUpgradeableProxy.0xf3c1d15f8136332d14fce7c55a0179e59c44cb75d928d363b05cb22a1c36e9fd( 0xf3c1d15f8136332d14fce7c55a0179e59c44cb75d928d363b05cb22a1c36e9fd, 0x0000000000000000000000000000000000000000000000000000000000000985, 0xebe32522e6d5f0bb2ee0b270d5e0232d4b3b39f08433d7dee594c6341b1affe5, 0x00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a88, 00000000000000000000000000000000000000000000000000013d18f478b831, 0000000000000000000000000000000000000000000000000000000000000000 )
448 TransparentUpgradeableProxy.0x3a24d3c2a6b177a835cbf8f854944d6bd20ad08538f9d962cc63c5f59da69e73( 0x3a24d3c2a6b177a835cbf8f854944d6bd20ad08538f9d962cc63c5f59da69e73, 0x0000000000000000000000000000000000000000000000000000000000000985, 0000000000000000000000000000000000000000000000000000000000000020, 0000000000000000000000000000000000000000000000000000000000000014, f9c809766cd31ec0531c7b72b19c2eb11eaa0770000000000000000000000000 )
449 TransparentUpgradeableProxy.0xe55980a387d8b6f11ede459bd7e71fe1e0dd649c3b4caa62db722cdcf386805a( 0xe55980a387d8b6f11ede459bd7e71fe1e0dd649c3b4caa62db722cdcf386805a, 0x00000000000000000000000018084fba666a33d37592fa2633fd49a74dd93a88, 0x00000000000000000000000023d625f4f1825bc68d8dd38ad958fb8da370d337, 0000000000000000000000000000000000000000000000000000188e6d68b000 )
450 TBTC.Transfer( from=[Receiver] TransparentUpgradeableProxy, to=0x23D625F4f1825BC68d8dD38ad958fB8dA370d337, value=27000000000000 )
451 TBTC.Transfer( from=[Receiver] TransparentUpgradeableProxy, to=0xf9c809766Cd31EC0531C7b72B19C2eb11EaA0770, value=321652366772273 )

Account State Difference:

  Address   Before After State Difference Code
0x18084fbA...74DD93a88
(Titan Builder)
21.008753388136893301 Eth21.008753388138921586 Eth0.000000000002028285
0x700C8840...76f9C92A7 1.433634022450080497 Eth1.433627361881638521 Eth0.000006660568441976
0xD7fb1De0...f3A388A8a
0.001934391726025604 Eth
Nonce: 2252
0.001934669471960932 Eth
Nonce: 2253
0.000000277745935328
0xF6680EA3...Fd8e6908c

Execution Trace

TransparentUpgradeableProxy.8993b5f8( )
  • 0x7e994d7fc7a2c3cad2331dadb07902f3a46b6cd9.8993b5f8( )
    • TBTC.transfer( recipient=0x23D625F4f1825BC68d8dD38ad958fB8dA370d337, amount=27000000000000 ) => ( True )
    • TBTC.transfer( recipient=0xf9c809766Cd31EC0531C7b72B19C2eb11EaA0770, amount=321652366772273 ) => ( True )
    • ReimbursementPool.refund( gasSpent=91103, receiver=0xD7fb1De0a4C2ffE5474E003656302A3f3A388A8a )
      • ETH 0.000006660568441976 0xd7fb1de0a4c2ffe5474e003656302a3f3a388a8a.CALL( )
        File 1 of 3: TransparentUpgradeableProxy
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
        pragma solidity ^0.8.20;
        import {Context} from "../utils/Context.sol";
        /**
         * @dev Contract module which provides a basic access control mechanism, where
         * there is an account (an owner) that can be granted exclusive access to
         * specific functions.
         *
         * The initial owner is set to the address provided by the deployer. This can
         * later be changed with {transferOwnership}.
         *
         * This module is used through inheritance. It will make available the modifier
         * `onlyOwner`, which can be applied to your functions to restrict their use to
         * the owner.
         */
        abstract contract Ownable is Context {
            address private _owner;
            /**
             * @dev The caller account is not authorized to perform an operation.
             */
            error OwnableUnauthorizedAccount(address account);
            /**
             * @dev The owner is not a valid owner account. (eg. `address(0)`)
             */
            error OwnableInvalidOwner(address owner);
            event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
            /**
             * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
             */
            constructor(address initialOwner) {
                if (initialOwner == address(0)) {
                    revert OwnableInvalidOwner(address(0));
                }
                _transferOwnership(initialOwner);
            }
            /**
             * @dev Throws if called by any account other than the owner.
             */
            modifier onlyOwner() {
                _checkOwner();
                _;
            }
            /**
             * @dev Returns the address of the current owner.
             */
            function owner() public view virtual returns (address) {
                return _owner;
            }
            /**
             * @dev Throws if the sender is not the owner.
             */
            function _checkOwner() internal view virtual {
                if (owner() != _msgSender()) {
                    revert OwnableUnauthorizedAccount(_msgSender());
                }
            }
            /**
             * @dev Leaves the contract without owner. It will not be possible to call
             * `onlyOwner` functions. Can only be called by the current owner.
             *
             * NOTE: Renouncing ownership will leave the contract without an owner,
             * thereby disabling any functionality that is only available to the owner.
             */
            function renounceOwnership() public virtual onlyOwner {
                _transferOwnership(address(0));
            }
            /**
             * @dev Transfers ownership of the contract to a new account (`newOwner`).
             * Can only be called by the current owner.
             */
            function transferOwnership(address newOwner) public virtual onlyOwner {
                if (newOwner == address(0)) {
                    revert OwnableInvalidOwner(address(0));
                }
                _transferOwnership(newOwner);
            }
            /**
             * @dev Transfers ownership of the contract to a new account (`newOwner`).
             * Internal function without access restriction.
             */
            function _transferOwnership(address newOwner) internal virtual {
                address oldOwner = _owner;
                _owner = newOwner;
                emit OwnershipTransferred(oldOwner, newOwner);
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol)
        pragma solidity ^0.8.20;
        /**
         * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
         */
        interface IERC1967 {
            /**
             * @dev Emitted when the implementation is upgraded.
             */
            event Upgraded(address indexed implementation);
            /**
             * @dev Emitted when the admin account has changed.
             */
            event AdminChanged(address previousAdmin, address newAdmin);
            /**
             * @dev Emitted when the beacon is changed.
             */
            event BeaconUpgraded(address indexed beacon);
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/BeaconProxy.sol)
        pragma solidity ^0.8.20;
        import {IBeacon} from "./IBeacon.sol";
        import {Proxy} from "../Proxy.sol";
        import {ERC1967Utils} from "../ERC1967/ERC1967Utils.sol";
        /**
         * @dev This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.
         *
         * The beacon address can only be set once during construction, and cannot be changed afterwards. It is stored in an
         * immutable variable to avoid unnecessary storage reads, and also in the beacon storage slot specified by
         * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] so that it can be accessed externally.
         *
         * CAUTION: Since the beacon address can never be changed, you must ensure that you either control the beacon, or trust
         * the beacon to not upgrade the implementation maliciously.
         *
         * IMPORTANT: Do not use the implementation logic to modify the beacon storage slot. Doing so would leave the proxy in
         * an inconsistent state where the beacon storage slot does not match the beacon address.
         */
        contract BeaconProxy is Proxy {
            // An immutable address for the beacon to avoid unnecessary SLOADs before each delegate call.
            address private immutable _beacon;
            /**
             * @dev Initializes the proxy with `beacon`.
             *
             * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This
             * will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity
             * constructor.
             *
             * Requirements:
             *
             * - `beacon` must be a contract with the interface {IBeacon}.
             * - If `data` is empty, `msg.value` must be zero.
             */
            constructor(address beacon, bytes memory data) payable {
                ERC1967Utils.upgradeBeaconToAndCall(beacon, data);
                _beacon = beacon;
            }
            /**
             * @dev Returns the current implementation address of the associated beacon.
             */
            function _implementation() internal view virtual override returns (address) {
                return IBeacon(_getBeacon()).implementation();
            }
            /**
             * @dev Returns the beacon.
             */
            function _getBeacon() internal view virtual returns (address) {
                return _beacon;
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)
        pragma solidity ^0.8.20;
        /**
         * @dev This is the interface that {BeaconProxy} expects of its beacon.
         */
        interface IBeacon {
            /**
             * @dev Must return an address that can be used as a delegate call target.
             *
             * {UpgradeableBeacon} will check that this address is a contract.
             */
            function implementation() external view returns (address);
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/UpgradeableBeacon.sol)
        pragma solidity ^0.8.20;
        import {IBeacon} from "./IBeacon.sol";
        import {Ownable} from "../../access/Ownable.sol";
        /**
         * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their
         * implementation contract, which is where they will delegate all function calls.
         *
         * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.
         */
        contract UpgradeableBeacon is IBeacon, Ownable {
            address private _implementation;
            /**
             * @dev The `implementation` of the beacon is invalid.
             */
            error BeaconInvalidImplementation(address implementation);
            /**
             * @dev Emitted when the implementation returned by the beacon is changed.
             */
            event Upgraded(address indexed implementation);
            /**
             * @dev Sets the address of the initial implementation, and the initial owner who can upgrade the beacon.
             */
            constructor(address implementation_, address initialOwner) Ownable(initialOwner) {
                _setImplementation(implementation_);
            }
            /**
             * @dev Returns the current implementation address.
             */
            function implementation() public view virtual returns (address) {
                return _implementation;
            }
            /**
             * @dev Upgrades the beacon to a new implementation.
             *
             * Emits an {Upgraded} event.
             *
             * Requirements:
             *
             * - msg.sender must be the owner of the contract.
             * - `newImplementation` must be a contract.
             */
            function upgradeTo(address newImplementation) public virtual onlyOwner {
                _setImplementation(newImplementation);
            }
            /**
             * @dev Sets the implementation contract address for this beacon
             *
             * Requirements:
             *
             * - `newImplementation` must be a contract.
             */
            function _setImplementation(address newImplementation) private {
                if (newImplementation.code.length == 0) {
                    revert BeaconInvalidImplementation(newImplementation);
                }
                _implementation = newImplementation;
                emit Upgraded(newImplementation);
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Proxy.sol)
        pragma solidity ^0.8.20;
        import {Proxy} from "../Proxy.sol";
        import {ERC1967Utils} from "./ERC1967Utils.sol";
        /**
         * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
         * implementation address that can be changed. This address is stored in storage in the location specified by
         * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
         * implementation behind the proxy.
         */
        contract ERC1967Proxy is Proxy {
            /**
             * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation`.
             *
             * If `_data` is nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
             * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
             *
             * Requirements:
             *
             * - If `data` is empty, `msg.value` must be zero.
             */
            constructor(address implementation, bytes memory _data) payable {
                ERC1967Utils.upgradeToAndCall(implementation, _data);
            }
            /**
             * @dev Returns the current implementation address.
             *
             * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using
             * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
             * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
             */
            function _implementation() internal view virtual override returns (address) {
                return ERC1967Utils.getImplementation();
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol)
        pragma solidity ^0.8.20;
        import {IBeacon} from "../beacon/IBeacon.sol";
        import {Address} from "../../utils/Address.sol";
        import {StorageSlot} from "../../utils/StorageSlot.sol";
        /**
         * @dev This abstract contract provides getters and event emitting update functions for
         * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
         */
        library ERC1967Utils {
            // We re-declare ERC-1967 events here because they can't be used directly from IERC1967.
            // This will be fixed in Solidity 0.8.21. At that point we should remove these events.
            /**
             * @dev Emitted when the implementation is upgraded.
             */
            event Upgraded(address indexed implementation);
            /**
             * @dev Emitted when the admin account has changed.
             */
            event AdminChanged(address previousAdmin, address newAdmin);
            /**
             * @dev Emitted when the beacon is changed.
             */
            event BeaconUpgraded(address indexed beacon);
            /**
             * @dev Storage slot with the address of the current implementation.
             * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
             */
            // solhint-disable-next-line private-vars-leading-underscore
            bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
            /**
             * @dev The `implementation` of the proxy is invalid.
             */
            error ERC1967InvalidImplementation(address implementation);
            /**
             * @dev The `admin` of the proxy is invalid.
             */
            error ERC1967InvalidAdmin(address admin);
            /**
             * @dev The `beacon` of the proxy is invalid.
             */
            error ERC1967InvalidBeacon(address beacon);
            /**
             * @dev An upgrade function sees `msg.value > 0` that may be lost.
             */
            error ERC1967NonPayable();
            /**
             * @dev Returns the current implementation address.
             */
            function getImplementation() internal view returns (address) {
                return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
            }
            /**
             * @dev Stores a new address in the EIP1967 implementation slot.
             */
            function _setImplementation(address newImplementation) private {
                if (newImplementation.code.length == 0) {
                    revert ERC1967InvalidImplementation(newImplementation);
                }
                StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
            }
            /**
             * @dev Performs implementation upgrade with additional setup call if data is nonempty.
             * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
             * to avoid stuck value in the contract.
             *
             * Emits an {IERC1967-Upgraded} event.
             */
            function upgradeToAndCall(address newImplementation, bytes memory data) internal {
                _setImplementation(newImplementation);
                emit Upgraded(newImplementation);
                if (data.length > 0) {
                    Address.functionDelegateCall(newImplementation, data);
                } else {
                    _checkNonPayable();
                }
            }
            /**
             * @dev Storage slot with the admin of the contract.
             * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
             */
            // solhint-disable-next-line private-vars-leading-underscore
            bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
            /**
             * @dev Returns the current admin.
             *
             * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using
             * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
             * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
             */
            function getAdmin() internal view returns (address) {
                return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
            }
            /**
             * @dev Stores a new address in the EIP1967 admin slot.
             */
            function _setAdmin(address newAdmin) private {
                if (newAdmin == address(0)) {
                    revert ERC1967InvalidAdmin(address(0));
                }
                StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
            }
            /**
             * @dev Changes the admin of the proxy.
             *
             * Emits an {IERC1967-AdminChanged} event.
             */
            function changeAdmin(address newAdmin) internal {
                emit AdminChanged(getAdmin(), newAdmin);
                _setAdmin(newAdmin);
            }
            /**
             * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
             * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
             */
            // solhint-disable-next-line private-vars-leading-underscore
            bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
            /**
             * @dev Returns the current beacon.
             */
            function getBeacon() internal view returns (address) {
                return StorageSlot.getAddressSlot(BEACON_SLOT).value;
            }
            /**
             * @dev Stores a new beacon in the EIP1967 beacon slot.
             */
            function _setBeacon(address newBeacon) private {
                if (newBeacon.code.length == 0) {
                    revert ERC1967InvalidBeacon(newBeacon);
                }
                StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
                address beaconImplementation = IBeacon(newBeacon).implementation();
                if (beaconImplementation.code.length == 0) {
                    revert ERC1967InvalidImplementation(beaconImplementation);
                }
            }
            /**
             * @dev Change the beacon and trigger a setup call if data is nonempty.
             * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
             * to avoid stuck value in the contract.
             *
             * Emits an {IERC1967-BeaconUpgraded} event.
             *
             * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
             * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
             * efficiency.
             */
            function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
                _setBeacon(newBeacon);
                emit BeaconUpgraded(newBeacon);
                if (data.length > 0) {
                    Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
                } else {
                    _checkNonPayable();
                }
            }
            /**
             * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
             * if an upgrade doesn't perform an initialization call.
             */
            function _checkNonPayable() private {
                if (msg.value > 0) {
                    revert ERC1967NonPayable();
                }
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.0) (proxy/Proxy.sol)
        pragma solidity ^0.8.20;
        /**
         * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
         * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
         * be specified by overriding the virtual {_implementation} function.
         *
         * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
         * different contract through the {_delegate} function.
         *
         * The success and return data of the delegated call will be returned back to the caller of the proxy.
         */
        abstract contract Proxy {
            /**
             * @dev Delegates the current call to `implementation`.
             *
             * This function does not return to its internal call site, it will return directly to the external caller.
             */
            function _delegate(address implementation) internal virtual {
                assembly {
                    // Copy msg.data. We take full control of memory in this inline assembly
                    // block because it will not return to Solidity code. We overwrite the
                    // Solidity scratch pad at memory position 0.
                    calldatacopy(0, 0, calldatasize())
                    // Call the implementation.
                    // out and outsize are 0 because we don't know the size yet.
                    let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
                    // Copy the returned data.
                    returndatacopy(0, 0, returndatasize())
                    switch result
                    // delegatecall returns 0 on error.
                    case 0 {
                        revert(0, returndatasize())
                    }
                    default {
                        return(0, returndatasize())
                    }
                }
            }
            /**
             * @dev This is a virtual function that should be overridden so it returns the address to which the fallback
             * function and {_fallback} should delegate.
             */
            function _implementation() internal view virtual returns (address);
            /**
             * @dev Delegates the current call to the address returned by `_implementation()`.
             *
             * This function does not return to its internal call site, it will return directly to the external caller.
             */
            function _fallback() internal virtual {
                _delegate(_implementation());
            }
            /**
             * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
             * function in the contract matches the call data.
             */
            fallback() external payable virtual {
                _fallback();
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.0) (proxy/transparent/ProxyAdmin.sol)
        pragma solidity ^0.8.20;
        import {ITransparentUpgradeableProxy} from "./TransparentUpgradeableProxy.sol";
        import {Ownable} from "../../access/Ownable.sol";
        /**
         * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
         * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
         */
        contract ProxyAdmin is Ownable {
            /**
             * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgrade(address)`
             * and `upgradeAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
             * while `upgradeAndCall` will invoke the `receive` function if the second argument is the empty byte string.
             * If the getter returns `"5.0.0"`, only `upgradeAndCall(address,bytes)` is present, and the second argument must
             * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
             * during an upgrade.
             */
            string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
            /**
             * @dev Sets the initial owner who can perform upgrades.
             */
            constructor(address initialOwner) Ownable(initialOwner) {}
            /**
             * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation.
             * See {TransparentUpgradeableProxy-_dispatchUpgradeToAndCall}.
             *
             * Requirements:
             *
             * - This contract must be the admin of `proxy`.
             * - If `data` is empty, `msg.value` must be zero.
             */
            function upgradeAndCall(
                ITransparentUpgradeableProxy proxy,
                address implementation,
                bytes memory data
            ) public payable virtual onlyOwner {
                proxy.upgradeToAndCall{value: msg.value}(implementation, data);
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.0) (proxy/transparent/TransparentUpgradeableProxy.sol)
        pragma solidity ^0.8.20;
        import {ERC1967Utils} from "../ERC1967/ERC1967Utils.sol";
        import {ERC1967Proxy} from "../ERC1967/ERC1967Proxy.sol";
        import {IERC1967} from "../../interfaces/IERC1967.sol";
        import {ProxyAdmin} from "./ProxyAdmin.sol";
        /**
         * @dev Interface for {TransparentUpgradeableProxy}. In order to implement transparency, {TransparentUpgradeableProxy}
         * does not implement this interface directly, and its upgradeability mechanism is implemented by an internal dispatch
         * mechanism. The compiler is unaware that these functions are implemented by {TransparentUpgradeableProxy} and will not
         * include them in the ABI so this interface must be used to interact with it.
         */
        interface ITransparentUpgradeableProxy is IERC1967 {
            function upgradeToAndCall(address, bytes calldata) external payable;
        }
        /**
         * @dev This contract implements a proxy that is upgradeable through an associated {ProxyAdmin} instance.
         *
         * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
         * clashing], which can potentially be used in an attack, this contract uses the
         * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
         * things that go hand in hand:
         *
         * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
         * that call matches the {ITransparentUpgradeableProxy-upgradeToAndCall} function exposed by the proxy itself.
         * 2. If the admin calls the proxy, it can call the `upgradeToAndCall` function but any other call won't be forwarded to
         * the implementation. If the admin tries to call a function on the implementation it will fail with an error indicating
         * the proxy admin cannot fallback to the target implementation.
         *
         * These properties mean that the admin account can only be used for upgrading the proxy, so it's best if it's a
         * dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to
         * call a function from the proxy implementation. For this reason, the proxy deploys an instance of {ProxyAdmin} and
         * allows upgrades only if they come through it. You should think of the `ProxyAdmin` instance as the administrative
         * interface of the proxy, including the ability to change who can trigger upgrades by transferring ownership.
         *
         * NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not
         * inherit from that interface, and instead `upgradeToAndCall` is implicitly implemented using a custom dispatch
         * mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to
         * fully implement transparency without decoding reverts caused by selector clashes between the proxy and the
         * implementation.
         *
         * NOTE: This proxy does not inherit from {Context} deliberately. The {ProxyAdmin} of this contract won't send a
         * meta-transaction in any way, and any other meta-transaction setup should be made in the implementation contract.
         *
         * IMPORTANT: This contract avoids unnecessary storage reads by setting the admin only during construction as an
         * immutable variable, preventing any changes thereafter. However, the admin slot defined in ERC-1967 can still be
         * overwritten by the implementation logic pointed to by this proxy. In such cases, the contract may end up in an
         * undesirable state where the admin slot is different from the actual admin.
         *
         * WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the
         * compiler will not check that there are no selector conflicts, due to the note above. A selector clash between any new
         * function and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This
         * could render the `upgradeToAndCall` function inaccessible, preventing upgradeability and compromising transparency.
         */
        contract TransparentUpgradeableProxy is ERC1967Proxy {
            // An immutable address for the admin to avoid unnecessary SLOADs before each call
            // at the expense of removing the ability to change the admin once it's set.
            // This is acceptable if the admin is always a ProxyAdmin instance or similar contract
            // with its own ability to transfer the permissions to another account.
            address private immutable _admin;
            /**
             * @dev The proxy caller is the current admin, and can't fallback to the proxy target.
             */
            error ProxyDeniedAdminAccess();
            /**
             * @dev Initializes an upgradeable proxy managed by an instance of a {ProxyAdmin} with an `initialOwner`,
             * backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in
             * {ERC1967Proxy-constructor}.
             */
            constructor(address _logic, address initialOwner, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
                _admin = address(new ProxyAdmin(initialOwner));
                // Set the storage value and emit an event for ERC-1967 compatibility
                ERC1967Utils.changeAdmin(_proxyAdmin());
            }
            /**
             * @dev Returns the admin of this proxy.
             */
            function _proxyAdmin() internal virtual returns (address) {
                return _admin;
            }
            /**
             * @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior.
             */
            function _fallback() internal virtual override {
                if (msg.sender == _proxyAdmin()) {
                    if (msg.sig != ITransparentUpgradeableProxy.upgradeToAndCall.selector) {
                        revert ProxyDeniedAdminAccess();
                    } else {
                        _dispatchUpgradeToAndCall();
                    }
                } else {
                    super._fallback();
                }
            }
            /**
             * @dev Upgrade the implementation of the proxy. See {ERC1967Utils-upgradeToAndCall}.
             *
             * Requirements:
             *
             * - If `data` is empty, `msg.value` must be zero.
             */
            function _dispatchUpgradeToAndCall() private {
                (address newImplementation, bytes memory data) = abi.decode(msg.data[4:], (address, bytes));
                ERC1967Utils.upgradeToAndCall(newImplementation, data);
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
        pragma solidity ^0.8.20;
        /**
         * @dev Collection of functions related to the address type
         */
        library Address {
            /**
             * @dev The ETH balance of the account is not enough to perform the operation.
             */
            error AddressInsufficientBalance(address account);
            /**
             * @dev There's no code at `target` (it is not a contract).
             */
            error AddressEmptyCode(address target);
            /**
             * @dev A call to an address target failed. The target may have reverted.
             */
            error FailedInnerCall();
            /**
             * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
             * `recipient`, forwarding all available gas and reverting on errors.
             *
             * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
             * of certain opcodes, possibly making contracts go over the 2300 gas limit
             * imposed by `transfer`, making them unable to receive funds via
             * `transfer`. {sendValue} removes this limitation.
             *
             * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
             *
             * IMPORTANT: because control is transferred to `recipient`, care must be
             * taken to not create reentrancy vulnerabilities. Consider using
             * {ReentrancyGuard} or the
             * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
             */
            function sendValue(address payable recipient, uint256 amount) internal {
                if (address(this).balance < amount) {
                    revert AddressInsufficientBalance(address(this));
                }
                (bool success, ) = recipient.call{value: amount}("");
                if (!success) {
                    revert FailedInnerCall();
                }
            }
            /**
             * @dev Performs a Solidity function call using a low level `call`. A
             * plain `call` is an unsafe replacement for a function call: use this
             * function instead.
             *
             * If `target` reverts with a revert reason or custom error, it is bubbled
             * up by this function (like regular Solidity function calls). However, if
             * the call reverted with no returned reason, this function reverts with a
             * {FailedInnerCall} error.
             *
             * Returns the raw returned data. To convert to the expected return value,
             * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
             *
             * Requirements:
             *
             * - `target` must be a contract.
             * - calling `target` with `data` must not revert.
             */
            function functionCall(address target, bytes memory data) internal returns (bytes memory) {
                return functionCallWithValue(target, data, 0);
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
             * but also transferring `value` wei to `target`.
             *
             * Requirements:
             *
             * - the calling contract must have an ETH balance of at least `value`.
             * - the called Solidity function must be `payable`.
             */
            function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
                if (address(this).balance < value) {
                    revert AddressInsufficientBalance(address(this));
                }
                (bool success, bytes memory returndata) = target.call{value: value}(data);
                return verifyCallResultFromTarget(target, success, returndata);
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
             * but performing a static call.
             */
            function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
                (bool success, bytes memory returndata) = target.staticcall(data);
                return verifyCallResultFromTarget(target, success, returndata);
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
             * but performing a delegate call.
             */
            function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
                (bool success, bytes memory returndata) = target.delegatecall(data);
                return verifyCallResultFromTarget(target, success, returndata);
            }
            /**
             * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
             * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
             * unsuccessful call.
             */
            function verifyCallResultFromTarget(
                address target,
                bool success,
                bytes memory returndata
            ) internal view returns (bytes memory) {
                if (!success) {
                    _revert(returndata);
                } else {
                    // only check if target is a contract if the call was successful and the return data is empty
                    // otherwise we already know that it was a contract
                    if (returndata.length == 0 && target.code.length == 0) {
                        revert AddressEmptyCode(target);
                    }
                    return returndata;
                }
            }
            /**
             * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
             * revert reason or with a default {FailedInnerCall} error.
             */
            function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
                if (!success) {
                    _revert(returndata);
                } else {
                    return returndata;
                }
            }
            /**
             * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
             */
            function _revert(bytes memory returndata) private pure {
                // Look for revert reason and bubble it up if present
                if (returndata.length > 0) {
                    // The easiest way to bubble the revert reason is using memory via assembly
                    /// @solidity memory-safe-assembly
                    assembly {
                        let returndata_size := mload(returndata)
                        revert(add(32, returndata), returndata_size)
                    }
                } else {
                    revert FailedInnerCall();
                }
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
        pragma solidity ^0.8.20;
        /**
         * @dev Provides information about the current execution context, including the
         * sender of the transaction and its data. While these are generally available
         * via msg.sender and msg.data, they should not be accessed in such a direct
         * manner, since when dealing with meta-transactions the account sending and
         * paying for execution may not be the actual sender (as far as an application
         * is concerned).
         *
         * This contract is only required for intermediate, library-like contracts.
         */
        abstract contract Context {
            function _msgSender() internal view virtual returns (address) {
                return msg.sender;
            }
            function _msgData() internal view virtual returns (bytes calldata) {
                return msg.data;
            }
            function _contextSuffixLength() internal view virtual returns (uint256) {
                return 0;
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
        // This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
        pragma solidity ^0.8.20;
        /**
         * @dev Library for reading and writing primitive types to specific storage slots.
         *
         * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
         * This library helps with reading and writing to such slots without the need for inline assembly.
         *
         * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
         *
         * Example usage to set ERC1967 implementation slot:
         * ```solidity
         * contract ERC1967 {
         *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
         *
         *     function _getImplementation() internal view returns (address) {
         *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
         *     }
         *
         *     function _setImplementation(address newImplementation) internal {
         *         require(newImplementation.code.length > 0);
         *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
         *     }
         * }
         * ```
         */
        library StorageSlot {
            struct AddressSlot {
                address value;
            }
            struct BooleanSlot {
                bool value;
            }
            struct Bytes32Slot {
                bytes32 value;
            }
            struct Uint256Slot {
                uint256 value;
            }
            struct StringSlot {
                string value;
            }
            struct BytesSlot {
                bytes value;
            }
            /**
             * @dev Returns an `AddressSlot` with member `value` located at `slot`.
             */
            function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
                /// @solidity memory-safe-assembly
                assembly {
                    r.slot := slot
                }
            }
            /**
             * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
             */
            function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
                /// @solidity memory-safe-assembly
                assembly {
                    r.slot := slot
                }
            }
            /**
             * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
             */
            function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
                /// @solidity memory-safe-assembly
                assembly {
                    r.slot := slot
                }
            }
            /**
             * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
             */
            function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
                /// @solidity memory-safe-assembly
                assembly {
                    r.slot := slot
                }
            }
            /**
             * @dev Returns an `StringSlot` with member `value` located at `slot`.
             */
            function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
                /// @solidity memory-safe-assembly
                assembly {
                    r.slot := slot
                }
            }
            /**
             * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
             */
            function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
                /// @solidity memory-safe-assembly
                assembly {
                    r.slot := store.slot
                }
            }
            /**
             * @dev Returns an `BytesSlot` with member `value` located at `slot`.
             */
            function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
                /// @solidity memory-safe-assembly
                assembly {
                    r.slot := slot
                }
            }
            /**
             * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
             */
            function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
                /// @solidity memory-safe-assembly
                assembly {
                    r.slot := store.slot
                }
            }
        }
        

        File 2 of 3: TBTC
        // SPDX-License-Identifier: MIT
        pragma solidity 0.8.4;
        import "@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol";
        import "@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol";
        contract TBTC is ERC20WithPermit, MisfundRecovery {
            constructor() ERC20WithPermit("tBTC v2", "tBTC") {}
        }
        // SPDX-License-Identifier: MIT
        pragma solidity ^0.8.4;
        import "@openzeppelin/contracts/access/Ownable.sol";
        import "./IERC20WithPermit.sol";
        import "./IReceiveApproval.sol";
        /// @title  ERC20WithPermit
        /// @notice Burnable ERC20 token with EIP2612 permit functionality. User can
        ///         authorize a transfer of their token with a signature conforming
        ///         EIP712 standard instead of an on-chain transaction from their
        ///         address. Anyone can submit this signature on the user's behalf by
        ///         calling the permit function, as specified in EIP2612 standard,
        ///         paying gas fees, and possibly performing other actions in the same
        ///         transaction.
        contract ERC20WithPermit is IERC20WithPermit, Ownable {
            /// @notice The amount of tokens owned by the given account.
            mapping(address => uint256) public override balanceOf;
            /// @notice The remaining number of tokens that spender will be
            ///         allowed to spend on behalf of owner through `transferFrom` and
            ///         `burnFrom`. This is zero by default.
            mapping(address => mapping(address => uint256)) public override allowance;
            /// @notice Returns the current nonce for EIP2612 permission for the
            ///         provided token owner for a replay protection. Used to construct
            ///         EIP2612 signature provided to `permit` function.
            mapping(address => uint256) public override nonces;
            uint256 public immutable cachedChainId;
            bytes32 public immutable cachedDomainSeparator;
            /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612
            ///         signature provided to `permit` function.
            bytes32 public constant override PERMIT_TYPEHASH =
                keccak256(
                    "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
                );
            /// @notice The amount of tokens in existence.
            uint256 public override totalSupply;
            /// @notice The name of the token.
            string public override name;
            /// @notice The symbol of the token.
            string public override symbol;
            /// @notice The decimals places of the token.
            uint8 public constant override decimals = 18;
            constructor(string memory _name, string memory _symbol) {
                name = _name;
                symbol = _symbol;
                cachedChainId = block.chainid;
                cachedDomainSeparator = buildDomainSeparator();
            }
            /// @notice Moves `amount` tokens from the caller's account to `recipient`.
            /// @return True if the operation succeeded, reverts otherwise.
            /// @dev Requirements:
            ///       - `recipient` cannot be the zero address,
            ///       - the caller must have a balance of at least `amount`.
            function transfer(address recipient, uint256 amount)
                external
                override
                returns (bool)
            {
                _transfer(msg.sender, recipient, amount);
                return true;
            }
            /// @notice Moves `amount` tokens from `sender` to `recipient` using the
            ///         allowance mechanism. `amount` is then deducted from the caller's
            ///         allowance unless the allowance was made for `type(uint256).max`.
            /// @return True if the operation succeeded, reverts otherwise.
            /// @dev Requirements:
            ///      - `sender` and `recipient` cannot be the zero address,
            ///      - `sender` must have a balance of at least `amount`,
            ///      - the caller must have allowance for `sender`'s tokens of at least
            ///        `amount`.
            function transferFrom(
                address sender,
                address recipient,
                uint256 amount
            ) external override returns (bool) {
                uint256 currentAllowance = allowance[sender][msg.sender];
                if (currentAllowance != type(uint256).max) {
                    require(
                        currentAllowance >= amount,
                        "Transfer amount exceeds allowance"
                    );
                    _approve(sender, msg.sender, currentAllowance - amount);
                }
                _transfer(sender, recipient, amount);
                return true;
            }
            /// @notice EIP2612 approval made with secp256k1 signature.
            ///         Users can authorize a transfer of their tokens with a signature
            ///         conforming EIP712 standard, rather than an on-chain transaction
            ///         from their address. Anyone can submit this signature on the
            ///         user's behalf by calling the permit function, paying gas fees,
            ///         and possibly performing other actions in the same transaction.
            /// @dev    The deadline argument can be set to `type(uint256).max to create
            ///         permits that effectively never expire.  If the `amount` is set
            ///         to `type(uint256).max` then `transferFrom` and `burnFrom` will
            ///         not reduce an allowance.
            function permit(
                address owner,
                address spender,
                uint256 amount,
                uint256 deadline,
                uint8 v,
                bytes32 r,
                bytes32 s
            ) external override {
                /* solhint-disable-next-line not-rely-on-time */
                require(deadline >= block.timestamp, "Permission expired");
                // Validate `s` and `v` values for a malleability concern described in EIP2.
                // Only signatures with `s` value in the lower half of the secp256k1
                // curve's order and `v` value of 27 or 28 are considered valid.
                require(
                    uint256(s) <=
                        0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,
                    "Invalid signature 's' value"
                );
                require(v == 27 || v == 28, "Invalid signature 'v' value");
                bytes32 digest = keccak256(
                    abi.encodePacked(
                        "\\x19\\x01",
                        DOMAIN_SEPARATOR(),
                        keccak256(
                            abi.encode(
                                PERMIT_TYPEHASH,
                                owner,
                                spender,
                                amount,
                                nonces[owner]++,
                                deadline
                            )
                        )
                    )
                );
                address recoveredAddress = ecrecover(digest, v, r, s);
                require(
                    recoveredAddress != address(0) && recoveredAddress == owner,
                    "Invalid signature"
                );
                _approve(owner, spender, amount);
            }
            /// @notice Creates `amount` tokens and assigns them to `account`,
            ///         increasing the total supply.
            /// @dev Requirements:
            ///      - `recipient` cannot be the zero address.
            function mint(address recipient, uint256 amount) external onlyOwner {
                require(recipient != address(0), "Mint to the zero address");
                beforeTokenTransfer(address(0), recipient, amount);
                totalSupply += amount;
                balanceOf[recipient] += amount;
                emit Transfer(address(0), recipient, amount);
            }
            /// @notice Destroys `amount` tokens from the caller.
            /// @dev Requirements:
            ///       - the caller must have a balance of at least `amount`.
            function burn(uint256 amount) external override {
                _burn(msg.sender, amount);
            }
            /// @notice Destroys `amount` of tokens from `account` using the allowance
            ///         mechanism. `amount` is then deducted from the caller's allowance
            ///         unless the allowance was made for `type(uint256).max`.
            /// @dev Requirements:
            ///      - `account` must have a balance of at least `amount`,
            ///      - the caller must have allowance for `account`'s tokens of at least
            ///        `amount`.
            function burnFrom(address account, uint256 amount) external override {
                uint256 currentAllowance = allowance[account][msg.sender];
                if (currentAllowance != type(uint256).max) {
                    require(
                        currentAllowance >= amount,
                        "Burn amount exceeds allowance"
                    );
                    _approve(account, msg.sender, currentAllowance - amount);
                }
                _burn(account, amount);
            }
            /// @notice Calls `receiveApproval` function on spender previously approving
            ///         the spender to withdraw from the caller multiple times, up to
            ///         the `amount` amount. If this function is called again, it
            ///         overwrites the current allowance with `amount`. Reverts if the
            ///         approval reverted or if `receiveApproval` call on the spender
            ///         reverted.
            /// @return True if both approval and `receiveApproval` calls succeeded.
            /// @dev If the `amount` is set to `type(uint256).max` then
            ///      `transferFrom` and `burnFrom` will not reduce an allowance.
            function approveAndCall(
                address spender,
                uint256 amount,
                bytes memory extraData
            ) external override returns (bool) {
                if (approve(spender, amount)) {
                    IReceiveApproval(spender).receiveApproval(
                        msg.sender,
                        amount,
                        address(this),
                        extraData
                    );
                    return true;
                }
                return false;
            }
            /// @notice Sets `amount` as the allowance of `spender` over the caller's
            ///         tokens.
            /// @return True if the operation succeeded.
            /// @dev If the `amount` is set to `type(uint256).max` then
            ///      `transferFrom` and `burnFrom` will not reduce an allowance.
            ///      Beware that changing an allowance with this method brings the risk
            ///      that someone may use both the old and the new allowance by
            ///      unfortunate transaction ordering. One possible solution to mitigate
            ///      this race condition is to first reduce the spender's allowance to 0
            ///      and set the desired value afterwards:
            ///      https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
            function approve(address spender, uint256 amount)
                public
                override
                returns (bool)
            {
                _approve(msg.sender, spender, amount);
                return true;
            }
            /// @notice Returns hash of EIP712 Domain struct with the token name as
            ///         a signing domain and token contract as a verifying contract.
            ///         Used to construct EIP2612 signature provided to `permit`
            ///         function.
            /* solhint-disable-next-line func-name-mixedcase */
            function DOMAIN_SEPARATOR() public view override returns (bytes32) {
                // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the
                // chainId and is defined at contract deployment instead of
                // reconstructed for every signature, there is a risk of possible replay
                // attacks between chains in the event of a future chain split.
                // To address this issue, we check the cached chain ID against the
                // current one and in case they are different, we build domain separator
                // from scratch.
                if (block.chainid == cachedChainId) {
                    return cachedDomainSeparator;
                } else {
                    return buildDomainSeparator();
                }
            }
            /// @dev Hook that is called before any transfer of tokens. This includes
            ///      minting and burning.
            ///
            /// Calling conditions:
            /// - when `from` and `to` are both non-zero, `amount` of `from`'s tokens
            ///   will be to transferred to `to`.
            /// - when `from` is zero, `amount` tokens will be minted for `to`.
            /// - when `to` is zero, `amount` of ``from``'s tokens will be burned.
            /// - `from` and `to` are never both zero.
            // slither-disable-next-line dead-code
            function beforeTokenTransfer(
                address from,
                address to,
                uint256 amount
            ) internal virtual {}
            function _burn(address account, uint256 amount) internal {
                uint256 currentBalance = balanceOf[account];
                require(currentBalance >= amount, "Burn amount exceeds balance");
                beforeTokenTransfer(account, address(0), amount);
                balanceOf[account] = currentBalance - amount;
                totalSupply -= amount;
                emit Transfer(account, address(0), amount);
            }
            function _transfer(
                address sender,
                address recipient,
                uint256 amount
            ) private {
                require(sender != address(0), "Transfer from the zero address");
                require(recipient != address(0), "Transfer to the zero address");
                require(recipient != address(this), "Transfer to the token address");
                beforeTokenTransfer(sender, recipient, amount);
                uint256 senderBalance = balanceOf[sender];
                require(senderBalance >= amount, "Transfer amount exceeds balance");
                balanceOf[sender] = senderBalance - amount;
                balanceOf[recipient] += amount;
                emit Transfer(sender, recipient, amount);
            }
            function _approve(
                address owner,
                address spender,
                uint256 amount
            ) private {
                require(owner != address(0), "Approve from the zero address");
                require(spender != address(0), "Approve to the zero address");
                allowance[owner][spender] = amount;
                emit Approval(owner, spender, amount);
            }
            function buildDomainSeparator() private view returns (bytes32) {
                return
                    keccak256(
                        abi.encode(
                            keccak256(
                                "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
                            ),
                            keccak256(bytes(name)),
                            keccak256(bytes("1")),
                            block.chainid,
                            address(this)
                        )
                    );
            }
        }
        // SPDX-License-Identifier: MIT
        pragma solidity ^0.8.4;
        import "@openzeppelin/contracts/access/Ownable.sol";
        import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
        import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
        import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
        /// @title  MisfundRecovery
        /// @notice Allows the owner of the token contract extending MisfundRecovery
        ///         to recover any ERC20 and ERC721 sent mistakenly to the token
        ///         contract address.
        contract MisfundRecovery is Ownable {
            using SafeERC20 for IERC20;
            function recoverERC20(
                IERC20 token,
                address recipient,
                uint256 amount
            ) external onlyOwner {
                token.safeTransfer(recipient, amount);
            }
            function recoverERC721(
                IERC721 token,
                address recipient,
                uint256 tokenId,
                bytes calldata data
            ) external onlyOwner {
                token.safeTransferFrom(address(this), recipient, tokenId, data);
            }
        }
        // SPDX-License-Identifier: MIT
        pragma solidity ^0.8.0;
        import "../utils/Context.sol";
        /**
         * @dev Contract module which provides a basic access control mechanism, where
         * there is an account (an owner) that can be granted exclusive access to
         * specific functions.
         *
         * By default, the owner account will be the one that deploys the contract. This
         * can later be changed with {transferOwnership}.
         *
         * This module is used through inheritance. It will make available the modifier
         * `onlyOwner`, which can be applied to your functions to restrict their use to
         * the owner.
         */
        abstract contract Ownable is Context {
            address private _owner;
            event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
            /**
             * @dev Initializes the contract setting the deployer as the initial owner.
             */
            constructor() {
                _setOwner(_msgSender());
            }
            /**
             * @dev Returns the address of the current owner.
             */
            function owner() public view virtual returns (address) {
                return _owner;
            }
            /**
             * @dev Throws if called by any account other than the owner.
             */
            modifier onlyOwner() {
                require(owner() == _msgSender(), "Ownable: caller is not the owner");
                _;
            }
            /**
             * @dev Leaves the contract without owner. It will not be possible to call
             * `onlyOwner` functions anymore. Can only be called by the current owner.
             *
             * NOTE: Renouncing ownership will leave the contract without an owner,
             * thereby removing any functionality that is only available to the owner.
             */
            function renounceOwnership() public virtual onlyOwner {
                _setOwner(address(0));
            }
            /**
             * @dev Transfers ownership of the contract to a new account (`newOwner`).
             * Can only be called by the current owner.
             */
            function transferOwnership(address newOwner) public virtual onlyOwner {
                require(newOwner != address(0), "Ownable: new owner is the zero address");
                _setOwner(newOwner);
            }
            function _setOwner(address newOwner) private {
                address oldOwner = _owner;
                _owner = newOwner;
                emit OwnershipTransferred(oldOwner, newOwner);
            }
        }
        // SPDX-License-Identifier: MIT
        pragma solidity ^0.8.4;
        import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
        import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
        import "./IApproveAndCall.sol";
        /// @title  IERC20WithPermit
        /// @notice Burnable ERC20 token with EIP2612 permit functionality. User can
        ///         authorize a transfer of their token with a signature conforming
        ///         EIP712 standard instead of an on-chain transaction from their
        ///         address. Anyone can submit this signature on the user's behalf by
        ///         calling the permit function, as specified in EIP2612 standard,
        ///         paying gas fees, and possibly performing other actions in the same
        ///         transaction.
        interface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {
            /// @notice EIP2612 approval made with secp256k1 signature.
            ///         Users can authorize a transfer of their tokens with a signature
            ///         conforming EIP712 standard, rather than an on-chain transaction
            ///         from their address. Anyone can submit this signature on the
            ///         user's behalf by calling the permit function, paying gas fees,
            ///         and possibly performing other actions in the same transaction.
            /// @dev    The deadline argument can be set to `type(uint256).max to create
            ///         permits that effectively never expire.
            function permit(
                address owner,
                address spender,
                uint256 amount,
                uint256 deadline,
                uint8 v,
                bytes32 r,
                bytes32 s
            ) external;
            /// @notice Destroys `amount` tokens from the caller.
            function burn(uint256 amount) external;
            /// @notice Destroys `amount` of tokens from `account`, deducting the amount
            ///         from caller's allowance.
            function burnFrom(address account, uint256 amount) external;
            /// @notice Returns hash of EIP712 Domain struct with the token name as
            ///         a signing domain and token contract as a verifying contract.
            ///         Used to construct EIP2612 signature provided to `permit`
            ///         function.
            /* solhint-disable-next-line func-name-mixedcase */
            function DOMAIN_SEPARATOR() external view returns (bytes32);
            /// @notice Returns the current nonce for EIP2612 permission for the
            ///         provided token owner for a replay protection. Used to construct
            ///         EIP2612 signature provided to `permit` function.
            function nonces(address owner) external view returns (uint256);
            /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612
            ///         signature provided to `permit` function.
            /* solhint-disable-next-line func-name-mixedcase */
            function PERMIT_TYPEHASH() external pure returns (bytes32);
        }
        // SPDX-License-Identifier: MIT
        pragma solidity ^0.8.4;
        /// @notice An interface that should be implemented by contracts supporting
        ///         `approveAndCall`/`receiveApproval` pattern.
        interface IReceiveApproval {
            /// @notice Receives approval to spend tokens. Called as a result of
            ///         `approveAndCall` call on the token.
            function receiveApproval(
                address from,
                uint256 amount,
                address token,
                bytes calldata extraData
            ) external;
        }
        // SPDX-License-Identifier: MIT
        pragma solidity ^0.8.0;
        /*
         * @dev Provides information about the current execution context, including the
         * sender of the transaction and its data. While these are generally available
         * via msg.sender and msg.data, they should not be accessed in such a direct
         * manner, since when dealing with meta-transactions the account sending and
         * paying for execution may not be the actual sender (as far as an application
         * is concerned).
         *
         * This contract is only required for intermediate, library-like contracts.
         */
        abstract contract Context {
            function _msgSender() internal view virtual returns (address) {
                return msg.sender;
            }
            function _msgData() internal view virtual returns (bytes calldata) {
                return msg.data;
            }
        }
        // SPDX-License-Identifier: MIT
        pragma solidity ^0.8.0;
        /**
         * @dev Interface of the ERC20 standard as defined in the EIP.
         */
        interface IERC20 {
            /**
             * @dev Returns the amount of tokens in existence.
             */
            function totalSupply() external view returns (uint256);
            /**
             * @dev Returns the amount of tokens owned by `account`.
             */
            function balanceOf(address account) external view returns (uint256);
            /**
             * @dev Moves `amount` tokens from the caller's account to `recipient`.
             *
             * Returns a boolean value indicating whether the operation succeeded.
             *
             * Emits a {Transfer} event.
             */
            function transfer(address recipient, uint256 amount) external returns (bool);
            /**
             * @dev Returns the remaining number of tokens that `spender` will be
             * allowed to spend on behalf of `owner` through {transferFrom}. This is
             * zero by default.
             *
             * This value changes when {approve} or {transferFrom} are called.
             */
            function allowance(address owner, address spender) external view returns (uint256);
            /**
             * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
             *
             * Returns a boolean value indicating whether the operation succeeded.
             *
             * IMPORTANT: Beware that changing an allowance with this method brings the risk
             * that someone may use both the old and the new allowance by unfortunate
             * transaction ordering. One possible solution to mitigate this race
             * condition is to first reduce the spender's allowance to 0 and set the
             * desired value afterwards:
             * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
             *
             * Emits an {Approval} event.
             */
            function approve(address spender, uint256 amount) external returns (bool);
            /**
             * @dev Moves `amount` tokens from `sender` to `recipient` using the
             * allowance mechanism. `amount` is then deducted from the caller's
             * allowance.
             *
             * Returns a boolean value indicating whether the operation succeeded.
             *
             * Emits a {Transfer} event.
             */
            function transferFrom(
                address sender,
                address recipient,
                uint256 amount
            ) external returns (bool);
            /**
             * @dev Emitted when `value` tokens are moved from one account (`from`) to
             * another (`to`).
             *
             * Note that `value` may be zero.
             */
            event Transfer(address indexed from, address indexed to, uint256 value);
            /**
             * @dev Emitted when the allowance of a `spender` for an `owner` is set by
             * a call to {approve}. `value` is the new allowance.
             */
            event Approval(address indexed owner, address indexed spender, uint256 value);
        }
        // SPDX-License-Identifier: MIT
        pragma solidity ^0.8.0;
        import "../IERC20.sol";
        /**
         * @dev Interface for the optional metadata functions from the ERC20 standard.
         *
         * _Available since v4.1._
         */
        interface IERC20Metadata is IERC20 {
            /**
             * @dev Returns the name of the token.
             */
            function name() external view returns (string memory);
            /**
             * @dev Returns the symbol of the token.
             */
            function symbol() external view returns (string memory);
            /**
             * @dev Returns the decimals places of the token.
             */
            function decimals() external view returns (uint8);
        }
        // SPDX-License-Identifier: MIT
        pragma solidity ^0.8.4;
        /// @notice An interface that should be implemented by tokens supporting
        ///         `approveAndCall`/`receiveApproval` pattern.
        interface IApproveAndCall {
            /// @notice Executes `receiveApproval` function on spender as specified in
            ///         `IReceiveApproval` interface. Approves spender to withdraw from
            ///         the caller multiple times, up to the `amount`. If this
            ///         function is called again, it overwrites the current allowance
            ///         with `amount`. Reverts if the approval reverted or if
            ///         `receiveApproval` call on the spender reverted.
            function approveAndCall(
                address spender,
                uint256 amount,
                bytes memory extraData
            ) external returns (bool);
        }
        // SPDX-License-Identifier: MIT
        pragma solidity ^0.8.0;
        import "../IERC20.sol";
        import "../../../utils/Address.sol";
        /**
         * @title SafeERC20
         * @dev Wrappers around ERC20 operations that throw on failure (when the token
         * contract returns false). Tokens that return no value (and instead revert or
         * throw on failure) are also supported, non-reverting calls are assumed to be
         * successful.
         * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
         * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
         */
        library SafeERC20 {
            using Address for address;
            function safeTransfer(
                IERC20 token,
                address to,
                uint256 value
            ) internal {
                _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
            }
            function safeTransferFrom(
                IERC20 token,
                address from,
                address to,
                uint256 value
            ) internal {
                _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
            }
            /**
             * @dev Deprecated. This function has issues similar to the ones found in
             * {IERC20-approve}, and its usage is discouraged.
             *
             * Whenever possible, use {safeIncreaseAllowance} and
             * {safeDecreaseAllowance} instead.
             */
            function safeApprove(
                IERC20 token,
                address spender,
                uint256 value
            ) internal {
                // safeApprove should only be called when setting an initial allowance,
                // or when resetting it to zero. To increase and decrease it, use
                // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
                require(
                    (value == 0) || (token.allowance(address(this), spender) == 0),
                    "SafeERC20: approve from non-zero to non-zero allowance"
                );
                _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
            }
            function safeIncreaseAllowance(
                IERC20 token,
                address spender,
                uint256 value
            ) internal {
                uint256 newAllowance = token.allowance(address(this), spender) + value;
                _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
            }
            function safeDecreaseAllowance(
                IERC20 token,
                address spender,
                uint256 value
            ) internal {
                unchecked {
                    uint256 oldAllowance = token.allowance(address(this), spender);
                    require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
                    uint256 newAllowance = oldAllowance - value;
                    _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
                }
            }
            /**
             * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
             * on the return value: the return value is optional (but if data is returned, it must not be false).
             * @param token The token targeted by the call.
             * @param data The call data (encoded using abi.encode or one of its variants).
             */
            function _callOptionalReturn(IERC20 token, bytes memory data) private {
                // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
                // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
                // the target address contains contract code and also asserts for success in the low-level call.
                bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
                if (returndata.length > 0) {
                    // Return data is optional
                    require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
                }
            }
        }
        // SPDX-License-Identifier: MIT
        pragma solidity ^0.8.0;
        import "../../utils/introspection/IERC165.sol";
        /**
         * @dev Required interface of an ERC721 compliant contract.
         */
        interface IERC721 is IERC165 {
            /**
             * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
             */
            event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
            /**
             * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
             */
            event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
            /**
             * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
             */
            event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
            /**
             * @dev Returns the number of tokens in ``owner``'s account.
             */
            function balanceOf(address owner) external view returns (uint256 balance);
            /**
             * @dev Returns the owner of the `tokenId` token.
             *
             * Requirements:
             *
             * - `tokenId` must exist.
             */
            function ownerOf(uint256 tokenId) external view returns (address owner);
            /**
             * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
             * are aware of the ERC721 protocol to prevent tokens from being forever locked.
             *
             * Requirements:
             *
             * - `from` cannot be the zero address.
             * - `to` cannot be the zero address.
             * - `tokenId` token must exist and be owned by `from`.
             * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
             * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
             *
             * Emits a {Transfer} event.
             */
            function safeTransferFrom(
                address from,
                address to,
                uint256 tokenId
            ) external;
            /**
             * @dev Transfers `tokenId` token from `from` to `to`.
             *
             * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
             *
             * Requirements:
             *
             * - `from` cannot be the zero address.
             * - `to` cannot be the zero address.
             * - `tokenId` token must be owned by `from`.
             * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
             *
             * Emits a {Transfer} event.
             */
            function transferFrom(
                address from,
                address to,
                uint256 tokenId
            ) external;
            /**
             * @dev Gives permission to `to` to transfer `tokenId` token to another account.
             * The approval is cleared when the token is transferred.
             *
             * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
             *
             * Requirements:
             *
             * - The caller must own the token or be an approved operator.
             * - `tokenId` must exist.
             *
             * Emits an {Approval} event.
             */
            function approve(address to, uint256 tokenId) external;
            /**
             * @dev Returns the account approved for `tokenId` token.
             *
             * Requirements:
             *
             * - `tokenId` must exist.
             */
            function getApproved(uint256 tokenId) external view returns (address operator);
            /**
             * @dev Approve or remove `operator` as an operator for the caller.
             * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
             *
             * Requirements:
             *
             * - The `operator` cannot be the caller.
             *
             * Emits an {ApprovalForAll} event.
             */
            function setApprovalForAll(address operator, bool _approved) external;
            /**
             * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
             *
             * See {setApprovalForAll}
             */
            function isApprovedForAll(address owner, address operator) external view returns (bool);
            /**
             * @dev Safely transfers `tokenId` token from `from` to `to`.
             *
             * Requirements:
             *
             * - `from` cannot be the zero address.
             * - `to` cannot be the zero address.
             * - `tokenId` token must exist and be owned by `from`.
             * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
             * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
             *
             * Emits a {Transfer} event.
             */
            function safeTransferFrom(
                address from,
                address to,
                uint256 tokenId,
                bytes calldata data
            ) external;
        }
        // SPDX-License-Identifier: MIT
        pragma solidity ^0.8.0;
        /**
         * @dev Collection of functions related to the address type
         */
        library Address {
            /**
             * @dev Returns true if `account` is a contract.
             *
             * [IMPORTANT]
             * ====
             * It is unsafe to assume that an address for which this function returns
             * false is an externally-owned account (EOA) and not a contract.
             *
             * Among others, `isContract` will return false for the following
             * types of addresses:
             *
             *  - an externally-owned account
             *  - a contract in construction
             *  - an address where a contract will be created
             *  - an address where a contract lived, but was destroyed
             * ====
             */
            function isContract(address account) internal view returns (bool) {
                // This method relies on extcodesize, which returns 0 for contracts in
                // construction, since the code is only stored at the end of the
                // constructor execution.
                uint256 size;
                assembly {
                    size := extcodesize(account)
                }
                return size > 0;
            }
            /**
             * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
             * `recipient`, forwarding all available gas and reverting on errors.
             *
             * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
             * of certain opcodes, possibly making contracts go over the 2300 gas limit
             * imposed by `transfer`, making them unable to receive funds via
             * `transfer`. {sendValue} removes this limitation.
             *
             * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
             *
             * IMPORTANT: because control is transferred to `recipient`, care must be
             * taken to not create reentrancy vulnerabilities. Consider using
             * {ReentrancyGuard} or the
             * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
             */
            function sendValue(address payable recipient, uint256 amount) internal {
                require(address(this).balance >= amount, "Address: insufficient balance");
                (bool success, ) = recipient.call{value: amount}("");
                require(success, "Address: unable to send value, recipient may have reverted");
            }
            /**
             * @dev Performs a Solidity function call using a low level `call`. A
             * plain `call` is an unsafe replacement for a function call: use this
             * function instead.
             *
             * If `target` reverts with a revert reason, it is bubbled up by this
             * function (like regular Solidity function calls).
             *
             * Returns the raw returned data. To convert to the expected return value,
             * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
             *
             * Requirements:
             *
             * - `target` must be a contract.
             * - calling `target` with `data` must not revert.
             *
             * _Available since v3.1._
             */
            function functionCall(address target, bytes memory data) internal returns (bytes memory) {
                return functionCall(target, data, "Address: low-level call failed");
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
             * `errorMessage` as a fallback revert reason when `target` reverts.
             *
             * _Available since v3.1._
             */
            function functionCall(
                address target,
                bytes memory data,
                string memory errorMessage
            ) internal returns (bytes memory) {
                return functionCallWithValue(target, data, 0, errorMessage);
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
             * but also transferring `value` wei to `target`.
             *
             * Requirements:
             *
             * - the calling contract must have an ETH balance of at least `value`.
             * - the called Solidity function must be `payable`.
             *
             * _Available since v3.1._
             */
            function functionCallWithValue(
                address target,
                bytes memory data,
                uint256 value
            ) internal returns (bytes memory) {
                return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
            }
            /**
             * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
             * with `errorMessage` as a fallback revert reason when `target` reverts.
             *
             * _Available since v3.1._
             */
            function functionCallWithValue(
                address target,
                bytes memory data,
                uint256 value,
                string memory errorMessage
            ) internal returns (bytes memory) {
                require(address(this).balance >= value, "Address: insufficient balance for call");
                require(isContract(target), "Address: call to non-contract");
                (bool success, bytes memory returndata) = target.call{value: value}(data);
                return _verifyCallResult(success, returndata, errorMessage);
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
             * but performing a static call.
             *
             * _Available since v3.3._
             */
            function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
                return functionStaticCall(target, data, "Address: low-level static call failed");
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
             * but performing a static call.
             *
             * _Available since v3.3._
             */
            function functionStaticCall(
                address target,
                bytes memory data,
                string memory errorMessage
            ) internal view returns (bytes memory) {
                require(isContract(target), "Address: static call to non-contract");
                (bool success, bytes memory returndata) = target.staticcall(data);
                return _verifyCallResult(success, returndata, errorMessage);
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
             * but performing a delegate call.
             *
             * _Available since v3.4._
             */
            function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
                return functionDelegateCall(target, data, "Address: low-level delegate call failed");
            }
            /**
             * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
             * but performing a delegate call.
             *
             * _Available since v3.4._
             */
            function functionDelegateCall(
                address target,
                bytes memory data,
                string memory errorMessage
            ) internal returns (bytes memory) {
                require(isContract(target), "Address: delegate call to non-contract");
                (bool success, bytes memory returndata) = target.delegatecall(data);
                return _verifyCallResult(success, returndata, errorMessage);
            }
            function _verifyCallResult(
                bool success,
                bytes memory returndata,
                string memory errorMessage
            ) private pure returns (bytes memory) {
                if (success) {
                    return returndata;
                } else {
                    // Look for revert reason and bubble it up if present
                    if (returndata.length > 0) {
                        // The easiest way to bubble the revert reason is using memory via assembly
                        assembly {
                            let returndata_size := mload(returndata)
                            revert(add(32, returndata), returndata_size)
                        }
                    } else {
                        revert(errorMessage);
                    }
                }
            }
        }
        // SPDX-License-Identifier: MIT
        pragma solidity ^0.8.0;
        /**
         * @dev Interface of the ERC165 standard, as defined in the
         * https://eips.ethereum.org/EIPS/eip-165[EIP].
         *
         * Implementers can declare support of contract interfaces, which can then be
         * queried by others ({ERC165Checker}).
         *
         * For an implementation, see {ERC165}.
         */
        interface IERC165 {
            /**
             * @dev Returns true if this contract implements the interface defined by
             * `interfaceId`. See the corresponding
             * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
             * to learn more about how these ids are created.
             *
             * This function call must use less than 30 000 gas.
             */
            function supportsInterface(bytes4 interfaceId) external view returns (bool);
        }
        

        File 3 of 3: ReimbursementPool
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
        pragma solidity ^0.8.20;
        import {Context} from "../utils/Context.sol";
        /**
         * @dev Contract module which provides a basic access control mechanism, where
         * there is an account (an owner) that can be granted exclusive access to
         * specific functions.
         *
         * The initial owner is set to the address provided by the deployer. This can
         * later be changed with {transferOwnership}.
         *
         * This module is used through inheritance. It will make available the modifier
         * `onlyOwner`, which can be applied to your functions to restrict their use to
         * the owner.
         */
        abstract contract Ownable is Context {
            address private _owner;
            /**
             * @dev The caller account is not authorized to perform an operation.
             */
            error OwnableUnauthorizedAccount(address account);
            /**
             * @dev The owner is not a valid owner account. (eg. `address(0)`)
             */
            error OwnableInvalidOwner(address owner);
            event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
            /**
             * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
             */
            constructor(address initialOwner) {
                if (initialOwner == address(0)) {
                    revert OwnableInvalidOwner(address(0));
                }
                _transferOwnership(initialOwner);
            }
            /**
             * @dev Throws if called by any account other than the owner.
             */
            modifier onlyOwner() {
                _checkOwner();
                _;
            }
            /**
             * @dev Returns the address of the current owner.
             */
            function owner() public view virtual returns (address) {
                return _owner;
            }
            /**
             * @dev Throws if the sender is not the owner.
             */
            function _checkOwner() internal view virtual {
                if (owner() != _msgSender()) {
                    revert OwnableUnauthorizedAccount(_msgSender());
                }
            }
            /**
             * @dev Leaves the contract without owner. It will not be possible to call
             * `onlyOwner` functions. Can only be called by the current owner.
             *
             * NOTE: Renouncing ownership will leave the contract without an owner,
             * thereby disabling any functionality that is only available to the owner.
             */
            function renounceOwnership() public virtual onlyOwner {
                _transferOwnership(address(0));
            }
            /**
             * @dev Transfers ownership of the contract to a new account (`newOwner`).
             * Can only be called by the current owner.
             */
            function transferOwnership(address newOwner) public virtual onlyOwner {
                if (newOwner == address(0)) {
                    revert OwnableInvalidOwner(address(0));
                }
                _transferOwnership(newOwner);
            }
            /**
             * @dev Transfers ownership of the contract to a new account (`newOwner`).
             * Internal function without access restriction.
             */
            function _transferOwnership(address newOwner) internal virtual {
                address oldOwner = _owner;
                _owner = newOwner;
                emit OwnershipTransferred(oldOwner, newOwner);
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
        pragma solidity ^0.8.20;
        /**
         * @dev Provides information about the current execution context, including the
         * sender of the transaction and its data. While these are generally available
         * via msg.sender and msg.data, they should not be accessed in such a direct
         * manner, since when dealing with meta-transactions the account sending and
         * paying for execution may not be the actual sender (as far as an application
         * is concerned).
         *
         * This contract is only required for intermediate, library-like contracts.
         */
        abstract contract Context {
            function _msgSender() internal view virtual returns (address) {
                return msg.sender;
            }
            function _msgData() internal view virtual returns (bytes calldata) {
                return msg.data;
            }
            function _contextSuffixLength() internal view virtual returns (uint256) {
                return 0;
            }
        }
        // SPDX-License-Identifier: MIT
        // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
        pragma solidity ^0.8.20;
        /**
         * @dev Contract module that helps prevent reentrant calls to a function.
         *
         * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
         * available, which can be applied to functions to make sure there are no nested
         * (reentrant) calls to them.
         *
         * Note that because there is a single `nonReentrant` guard, functions marked as
         * `nonReentrant` may not call one another. This can be worked around by making
         * those functions `private`, and then adding `external` `nonReentrant` entry
         * points to them.
         *
         * TIP: If you would like to learn more about reentrancy and alternative ways
         * to protect against it, check out our blog post
         * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
         */
        abstract contract ReentrancyGuard {
            // Booleans are more expensive than uint256 or any type that takes up a full
            // word because each write operation emits an extra SLOAD to first read the
            // slot's contents, replace the bits taken up by the boolean, and then write
            // back. This is the compiler's defense against contract upgrades and
            // pointer aliasing, and it cannot be disabled.
            // The values being non-zero value makes deployment a bit more expensive,
            // but in exchange the refund on every call to nonReentrant will be lower in
            // amount. Since refunds are capped to a percentage of the total
            // transaction's gas, it is best to keep them low in cases like this one, to
            // increase the likelihood of the full refund coming into effect.
            uint256 private constant NOT_ENTERED = 1;
            uint256 private constant ENTERED = 2;
            uint256 private _status;
            /**
             * @dev Unauthorized reentrant call.
             */
            error ReentrancyGuardReentrantCall();
            constructor() {
                _status = NOT_ENTERED;
            }
            /**
             * @dev Prevents a contract from calling itself, directly or indirectly.
             * Calling a `nonReentrant` function from another `nonReentrant`
             * function is not supported. It is possible to prevent this from happening
             * by making the `nonReentrant` function external, and making it call a
             * `private` function that does the actual work.
             */
            modifier nonReentrant() {
                _nonReentrantBefore();
                _;
                _nonReentrantAfter();
            }
            function _nonReentrantBefore() private {
                // On the first call to nonReentrant, _status will be NOT_ENTERED
                if (_status == ENTERED) {
                    revert ReentrancyGuardReentrantCall();
                }
                // Any calls to nonReentrant after this point will fail
                _status = ENTERED;
            }
            function _nonReentrantAfter() private {
                // By storing the original value once again, a refund is triggered (see
                // https://eips.ethereum.org/EIPS/eip-2200)
                _status = NOT_ENTERED;
            }
            /**
             * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
             * `nonReentrant` function in the call stack.
             */
            function _reentrancyGuardEntered() internal view returns (bool) {
                return _status == ENTERED;
            }
        }
        // SPDX-License-Identifier: GPL-3.0-only
        pragma solidity 0.8.24;
        import "@openzeppelin/contracts/access/Ownable.sol";
        import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
        /// @dev Copy of ReimbursementPool.sol from threshold-network/keep-core
        contract ReimbursementPool is Ownable, ReentrancyGuard {
            /// @notice Authorized contracts that can interact with the reimbursement pool.
            ///         Authorization can be granted and removed by the owner.
            mapping(address => bool) public isAuthorized;
            /// @notice Static gas includes:
            ///         - cost of the refund function
            ///         - base transaction cost
            uint256 public staticGas;
            /// @notice Max gas price used to reimburse a transaction submitter. Protects
            ///         against malicious operator-miners.
            uint256 public maxGasPrice;
            event StaticGasUpdated(uint256 newStaticGas);
            event MaxGasPriceUpdated(uint256 newMaxGasPrice);
            event SendingEtherFailed(uint256 refundAmount, address receiver);
            event AuthorizedContract(address thirdPartyContract);
            event UnauthorizedContract(address thirdPartyContract);
            event FundsWithdrawn(uint256 withdrawnAmount, address receiver);
            constructor(uint256 _staticGas, uint256 _maxGasPrice) Ownable(msg.sender) {
                staticGas = _staticGas;
                maxGasPrice = _maxGasPrice;
            }
            /// @notice Receive ETH
            receive() external payable {}
            /// @notice Refunds ETH to a spender for executing specific transactions.
            /// @dev Ignoring the result of sending ETH to a receiver is made on purpose.
            ///      For EOA receiving ETH should always work. If a receiver is a smart
            ///      contract, then we do not want to fail a transaction, because in some
            ///      cases the refund is done at the very end of multiple calls where all
            ///      the previous calls were already paid off. It is a receiver's smart
            ///      contract responsibility to make sure it can receive ETH.
            /// @dev Only authorized contracts are allowed calling this function.
            /// @param gasSpent Gas spent on a transaction that needs to be reimbursed.
            /// @param receiver Address where the reimbursement is sent.
            function refund(uint256 gasSpent, address receiver) external nonReentrant {
                require(
                    isAuthorized[msg.sender],
                    "Contract is not authorized for a refund"
                );
                require(receiver != address(0), "Receiver's address cannot be zero");
                uint256 gasPrice = tx.gasprice < maxGasPrice
                    ? tx.gasprice
                    : maxGasPrice;
                uint256 refundAmount = (gasSpent + staticGas) * gasPrice;
                /* solhint-disable avoid-low-level-calls */
                // slither-disable-next-line low-level-calls,unchecked-lowlevel
                (bool sent, ) = receiver.call{value: refundAmount}("");
                /* solhint-enable avoid-low-level-calls */
                if (!sent) {
                    // slither-disable-next-line reentrancy-events
                    emit SendingEtherFailed(refundAmount, receiver);
                }
            }
            /// @notice Authorize a contract that can interact with this reimbursement pool.
            ///         Can be authorized by the owner only.
            /// @param _contract Authorized contract.
            function authorize(address _contract) external onlyOwner {
                isAuthorized[_contract] = true;
                emit AuthorizedContract(_contract);
            }
            /// @notice Unauthorize a contract that was previously authorized to interact
            ///         with this reimbursement pool. Can be unauthorized by the
            ///         owner only.
            /// @param _contract Authorized contract.
            function unauthorize(address _contract) external onlyOwner {
                delete isAuthorized[_contract];
                emit UnauthorizedContract(_contract);
            }
            /// @notice Setting a static gas cost for executing a transaction. Can be set
            ///         by the owner only.
            /// @param _staticGas Static gas cost.
            function setStaticGas(uint256 _staticGas) external onlyOwner {
                staticGas = _staticGas;
                emit StaticGasUpdated(_staticGas);
            }
            /// @notice Setting a max gas price for transactions. Can be set by the
            ///         owner only.
            /// @param _maxGasPrice Max gas price used to reimburse tx submitters.
            function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwner {
                maxGasPrice = _maxGasPrice;
                emit MaxGasPriceUpdated(_maxGasPrice);
            }
            /// @notice Withdraws all ETH from this pool which are sent to a given
            ///         address. Can be set by the owner only.
            /// @param receiver An address where ETH is sent.
            function withdrawAll(address receiver) external onlyOwner {
                withdraw(address(this).balance, receiver);
            }
            /// @notice Withdraws ETH amount from this pool which are sent to a given
            ///         address. Can be set by the owner only.
            /// @param amount Amount to withdraw from the pool.
            /// @param receiver An address where ETH is sent.
            function withdraw(uint256 amount, address receiver) public onlyOwner {
                require(
                    address(this).balance >= amount,
                    "Insufficient contract balance"
                );
                require(receiver != address(0), "Receiver's address cannot be zero");
                emit FundsWithdrawn(amount, receiver);
                /* solhint-disable avoid-low-level-calls */
                // slither-disable-next-line low-level-calls,arbitrary-send
                (bool sent, ) = receiver.call{value: amount}("");
                /* solhint-enable avoid-low-level-calls */
                require(sent, "Failed to send Ether");
            }
        }