Contract 0x6317E38384821E0E4BeeAf04fb437fD1148f27BE

Contract Overview

Balance:
0 MATIC
Txn Hash
Method
Block
From
To
Value [Txn Fee]
0xefe74a8c8b8e365f06765ea7b437dca3d5d19741148386bc71000746301ec91a0x60a08060336397702023-03-27 17:46:3763 days 13 hrs ago0x4e27128cdef7a3cffdf800be3be6ee74639cb639 IN  Create: RouterRider0 MATIC0.012179502577 2.500000016
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
RouterRider

Compiler Version
v0.8.18+commit.87f61d96

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 27 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

    /**
     * @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 {
        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 {
        _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 {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _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);
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 2 of 27 : draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

File 3 of 27 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

File 4 of 27 : ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {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 bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @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) private returns (bytes memory) {
        require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 5 of 27 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

File 6 of 27 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 7 of 27 : ERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.2) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import "./IERC721Upgradeable.sol";
import "./IERC721ReceiverUpgradeable.sol";
import "./extensions/IERC721MetadataUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../utils/StringsUpgradeable.sol";
import "../../utils/introspection/ERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {
    using AddressUpgradeable for address;
    using StringsUpgradeable for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {
        __ERC721_init_unchained(name_, symbol_);
    }

    function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {
        return
            interfaceId == type(IERC721Upgradeable).interfaceId ||
            interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: address zero is not a valid owner");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _ownerOf(tokenId);
        require(owner != address(0), "ERC721: invalid token ID");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        _requireMinted(tokenId);

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overridden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721Upgradeable.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not token owner or approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        _requireMinted(tokenId);

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
        _safeTransfer(from, to, tokenId, data);
    }

    /**
     * @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.
     *
     * `data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
     */
    function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
        return _owners[tokenId];
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _ownerOf(tokenId) != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        address owner = ERC721Upgradeable.ownerOf(tokenId);
        return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId, 1);

        // Check that tokenId was not minted by `_beforeTokenTransfer` hook
        require(!_exists(tokenId), "ERC721: token already minted");

        unchecked {
            // Will not overflow unless all 2**256 token ids are minted to the same owner.
            // Given that tokens are minted one by one, it is impossible in practice that
            // this ever happens. Might change if we allow batch minting.
            // The ERC fails to describe this case.
            _balances[to] += 1;
        }

        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);

        _afterTokenTransfer(address(0), to, tokenId, 1);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     * This is an internal function that does not check if the sender is authorized to operate on the token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721Upgradeable.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId, 1);

        // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook
        owner = ERC721Upgradeable.ownerOf(tokenId);

        // Clear approvals
        delete _tokenApprovals[tokenId];

        unchecked {
            // Cannot overflow, as that would require more tokens to be burned/transferred
            // out than the owner initially received through minting and transferring in.
            _balances[owner] -= 1;
        }
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);

        _afterTokenTransfer(owner, address(0), tokenId, 1);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId, 1);

        // Check that tokenId was not transferred by `_beforeTokenTransfer` hook
        require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");

        // Clear approvals from the previous owner
        delete _tokenApprovals[tokenId];

        unchecked {
            // `_balances[from]` cannot overflow for the same reason as described in `_burn`:
            // `from`'s balance is the number of token held, which is at least one before the current
            // transfer.
            // `_balances[to]` could overflow in the conditions described in `_mint`. That would require
            // all 2**256 token ids to be minted, which in practice is impossible.
            _balances[from] -= 1;
            _balances[to] += 1;
        }
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId, 1);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits an {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Reverts if the `tokenId` has not been minted yet.
     */
    function _requireMinted(uint256 tokenId) internal view virtual {
        require(_exists(tokenId), "ERC721: invalid token ID");
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
                return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is
     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.
     * - When `from` is zero, the tokens will be minted for `to`.
     * - When `to` is zero, ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     * - `batchSize` is non-zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 firstTokenId,
        uint256 batchSize
    ) internal virtual {}

    /**
     * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is
     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.
     * - When `from` is zero, the tokens were minted for `to`.
     * - When `to` is zero, ``from``'s tokens were burned.
     * - `from` and `to` are never both zero.
     * - `batchSize` is non-zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 firstTokenId,
        uint256 batchSize
    ) internal virtual {}

    /**
     * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
     *
     * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant
     * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such
     * that `ownerOf(tokenId)` is `a`.
     */
    // solhint-disable-next-line func-name-mixedcase
    function __unsafe_increaseBalance(address account, uint256 amount) internal {
        _balances[account] += amount;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[44] private __gap;
}

File 8 of 27 : ERC721URIStorageUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721URIStorage.sol)

pragma solidity ^0.8.0;

import "../ERC721Upgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev ERC721 token with storage based token URI management.
 */
abstract contract ERC721URIStorageUpgradeable is Initializable, ERC721Upgradeable {
    function __ERC721URIStorage_init() internal onlyInitializing {
    }

    function __ERC721URIStorage_init_unchained() internal onlyInitializing {
    }
    using StringsUpgradeable for uint256;

    // Optional mapping for token URIs
    mapping(uint256 => string) private _tokenURIs;

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        _requireMinted(tokenId);

        string memory _tokenURI = _tokenURIs[tokenId];
        string memory base = _baseURI();

        // If there is no base URI, return the token URI.
        if (bytes(base).length == 0) {
            return _tokenURI;
        }
        // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
        if (bytes(_tokenURI).length > 0) {
            return string(abi.encodePacked(base, _tokenURI));
        }

        return super.tokenURI(tokenId);
    }

    /**
     * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
        require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token");
        _tokenURIs[tokenId] = _tokenURI;
    }

    /**
     * @dev See {ERC721-_burn}. This override additionally checks to see if a
     * token-specific URI was set for the token, and if so, it deletes the token URI from
     * the storage mapping.
     */
    function _burn(uint256 tokenId) internal virtual override {
        super._burn(tokenId);

        if (bytes(_tokenURIs[tokenId]).length != 0) {
            delete _tokenURIs[tokenId];
        }
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 9 of 27 : IERC721MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721Upgradeable.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721MetadataUpgradeable is IERC721Upgradeable {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 10 of 27 : IERC721ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721ReceiverUpgradeable {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 11 of 27 : IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165Upgradeable.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721Upgradeable is IERC165Upgradeable {
    /**
     * @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`.
     *
     * 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;

    /**
     * @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 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * 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 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 the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @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);
}

File 12 of 27 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @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
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage);
        }
    }
}

File 13 of 27 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @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 ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 14 of 27 : CountersUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library CountersUpgradeable {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

File 15 of 27 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 16 of 27 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

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 IERC165Upgradeable {
    /**
     * @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 17 of 27 : MathUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library MathUpgradeable {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

File 18 of 27 : StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

/**
 * @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:
 * ```
 * 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(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 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
        }
    }
}

File 19 of 27 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/MathUpgradeable.sol";

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = MathUpgradeable.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, MathUpgradeable.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

File 20 of 27 : ICrossTalkApplication.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;

/**
 * @dev CrossTalk flow Interface.
 */
interface ICrossTalkApplication {
    function handleRequestFromSource(
        bytes memory srcContractAddress,
        bytes memory payload,
        string memory srcChainId,
        uint64 srcChainType
    ) external returns (bytes memory);

    function handleCrossTalkAck(uint64 eventIdentifier, bool[] memory execFlags, bytes[] memory execData) external;
}

interface AddOnShieldModule {
    function verifyRequestFromSource(
        bytes memory srcContractAddress,
        string memory srcChainId,
        uint64 srcChainType,
        uint64 eventNonce,
        bool isAtomic,
        uint64 requestTimestamp,
        bytes[] memory payloads,
        bytes[] memory handlers
    ) external returns (bool);

    function verifyRequestFromRouter(
        string memory routerBridgeAddress,
        uint64 outboundTxNonce,
        bool isAtomic,
        uint64 requestTimestamp,
        bytes[] memory payloads,
        bytes[] memory handlers
    ) external returns (bool);
}

File 21 of 27 : IGateway.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;

import "./Utils.sol";

/**
 * @dev Interface of the Gateway Self External Calls.
 */
interface IGateway {
    function requestToRouter(
        uint256 routeAmount,
        string memory routeRecipient,
        bytes memory payload,
        string memory routerBridgeContract,
        uint256 gasLimit,
        bytes memory asmAddress
    ) external payable returns (uint64);

    function setDappMetadata(string memory feePayerAddress) external payable returns (uint64);

    function executeHandlerCalls(
        string memory sender,
        bytes[] memory handlers,
        bytes[] memory payloads,
        bool isAtomic
    ) external returns (bool[] memory, bytes[] memory);

    function requestToDest(
        Utils.RequestArgs memory requestArgs,
        Utils.AckType ackType,
        Utils.AckGasParams memory ackGasParams,
        Utils.DestinationChainParams memory destChainParams,
        Utils.ContractCalls memory contractCalls
    ) external payable returns (uint64);

    function readQueryToDest(
        Utils.RequestArgs memory requestArgs,
        Utils.AckGasParams memory ackGasParams,
        Utils.DestinationChainParams memory destChainParams,
        Utils.ContractCalls memory contractCalls
    ) external payable returns (uint64);

    function requestToRouterDefaultFee() external view returns (uint256 fees);

    function requestToDestDefaultFee() external view returns (uint256 fees);
}

File 22 of 27 : Utils.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;

library Utils {
    // This is used purely to avoid stack too deep errors
    // represents everything about a given validator set
    struct ValsetArgs {
        // the validators in this set, represented by an Ethereum address
        address[] validators;
        // the powers of the given validators in the same order as above
        uint64[] powers;
        // the nonce of this validator set
        uint64 valsetNonce;
    }

    // This is being used purely to avoid stack too deep errors
    struct RouterRequestPayload {
        //route
        uint256 routeAmount;
        bytes routeRecipient;
        // the sender address
        string routerBridgeAddress;
        string relayerRouterAddress;
        bool isAtomic;
        uint64 chainTimestamp;
        uint64 expTimestamp;
        // The user contract address
        bytes asmAddress;
        bytes[] handlers;
        bytes[] payloads;
        uint64 outboundTxNonce;
    }

    struct AckGasParams {
        uint64 gasLimit;
        uint64 gasPrice;
    }

    struct InboundSourceInfo {
        uint256 routeAmount;
        string routeRecipient;
        uint64 eventNonce;
        uint64 srcChainType;
        string srcChainId;
    }

    struct SourceChainParams {
        uint64 crossTalkNonce;
        uint64 expTimestamp;
        bool isAtomicCalls;
        uint64 chainType;
        string chainId;
    }
    struct SourceParams {
        bytes caller;
        uint64 chainType;
        string chainId;
    }

    struct DestinationChainParams {
        uint64 gasLimit;
        uint64 gasPrice;
        uint64 destChainType;
        string destChainId;
        bytes asmAddress;
    }

    struct RequestArgs {
        uint64 expTimestamp;
        bool isAtomicCalls;
    }

    struct ContractCalls {
        bytes[] payloads;
        bytes[] destContractAddresses;
    }

    struct CrossTalkPayload {
        string relayerRouterAddress;
        bool isAtomic;
        uint64 eventIdentifier;
        uint64 chainTimestamp;
        uint64 expTimestamp;
        uint64 crossTalkNonce;
        bytes asmAddress;
        SourceParams sourceParams;
        ContractCalls contractCalls;
        bool isReadCall;
    }

    struct CrossTalkAckPayload {
        string relayerRouterAddress;
        uint64 crossTalkNonce;
        uint64 eventIdentifier;
        uint64 destChainType;
        string destChainId;
        bytes srcContractAddress;
        bool[] execFlags;
        bytes[] execData;
    }

    // This represents a validator signature
    struct Signature {
        uint8 v;
        bytes32 r;
        bytes32 s;
    }

    enum AckType {
        NO_ACK,
        ACK_ON_SUCCESS,
        ACK_ON_ERROR,
        ACK_ON_BOTH
    }

    error IncorrectCheckpoint();
    error InvalidValsetNonce(uint64 newNonce, uint64 currentNonce);
    error MalformedNewValidatorSet();
    error MalformedCurrentValidatorSet();
    error InsufficientPower(uint64 cumulativePower, uint64 powerThreshold);
    error InvalidSignature();
    // constants
    string constant MSG_PREFIX = "\x19Ethereum Signed Message:\n32";
    // The number of 'votes' required to execute a valset
    // update or batch execution, set to 2/3 of 2^32
    uint64 constant constantPowerThreshold = 2791728742;
}

File 23 of 27 : CrossTalkUtils.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@routerprotocol/evm-gateway-contracts/contracts/IGateway.sol";
import "@routerprotocol/evm-gateway-contracts/contracts/Utils.sol";

/// @title CrossTalkUtils
/// @author Router Protocol
/// @notice This contract can be used to abstract the complexities while using the
/// Router CrossTalk framework.
library CrossTalkUtils {
    /// @notice Fuction to get whether the calls were executed on the destination chain.
    /// @param execFlags Array of boolean flags which indicate the execution status of calls on dest chain.
    /// @return boolean value indicating whether the calls were successfully executed on destination chain.
    function getTxStatusForAtomicCall(
        bool[] calldata execFlags
    ) internal pure returns (bool) {
        return execFlags[execFlags.length - 1] == true;
    }

    /// @notice Fuction to get the index of call out of an array of calls that failed on the destination chain.
    /// @param execFlags Array of boolean flags which indicate the execution status of calls on dest chain.
    /// @return index of call that failed
    function getTheIndexOfCallFailure(
        bool[] calldata execFlags
    ) internal pure returns (uint8) {
        require(getTxStatusForAtomicCall(execFlags), "No calls failed");

        for (uint8 i = 0; i < execFlags.length; i++) {
            if (execFlags[i] == false) {
                return i;
            }
        }

        return 0;
    }

    /// @notice Function to convert address to bytes
    /// @param addr address to be converted
    /// @return b bytes pertaining to address addr
    function toBytes(address addr) internal pure returns (bytes memory b) {
        assembly {
            let m := mload(0x40)
            addr := and(addr, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
            mstore(
                add(m, 20),
                xor(0x140000000000000000000000000000000000000000, addr)
            )
            mstore(0x40, add(m, 52))
            b := m
        }
    }

    /// @notice Function to convert bytes to address
    /// @param _bytes bytes to be converted
    /// @return addr address pertaining to the bytes
    function toAddress(
        bytes memory _bytes
    ) internal pure returns (address addr) {
        bytes20 srcTokenAddress;
        assembly {
            srcTokenAddress := mload(add(_bytes, 0x20))
        }
        addr = address(srcTokenAddress);
    }

    /// @notice Function to get the crosstalk fees in native tokens of the source chain.
    /// @param  gatewayContract address of the gateway contract.
    /// @return fees required for the transaction in native tokens of source chain.
    function getCrossTalkFees(
        address gatewayContract
    ) internal view returns (uint256) {
        return IGateway(gatewayContract).requestToDestDefaultFee();
    }

    /// @notice Function to send a single request without acknowledgement to the destination chain.
    /// @dev You will be able to send a single request to a single contract on the destination chain and
    /// you don't need the acknowledgement back on the source chain.
    /// @param gatewayContract address of the gateway contract.
    /// @param requestArgs requestArgs consists of expiryTimestamp, isAtomicCalls boolean and feePayerEnum.
    /// expiryTimestamp: timestamp when the call expires. If this time passes by, the call will fail
    /// on the destination chain. If you don't want to add an expiry timestamp, set it to zero.
    /// isAtomicCalls: boolean value suggesting whether the calls are atomic. If true, either all the
    /// calls will be executed or none will be executed on the destination chain. If false, even if some calls
    /// fail, others will not be affected. In this case, true or false doesn't matter.
    /// feePayerEnum: fee payer enum can be either Utils.FeePayer.{APP, USER, NONE}. NONE can be used
    /// in case of meta tx. In case you use APP or USER, fee is deducted on router chain from the router address
    /// of the app or the user respectively.
    /// @param destChainParams dest chain params include the destChainType, destChainId, the gas limit
    /// required to execute handler function on the destination chain and the gas price of destination chain.
    /// @param destinationContractAddress Contract address (in bytes format) of the contract which will be
    /// called on the destination chain which will handle the payload.
    /// @param payload abi encoded data that you want to send to the destination chain.
    /// @return Returns the nonce from the gateway contract.
    function singleRequestWithoutAcknowledgement(
        address gatewayContract,
        Utils.RequestArgs memory requestArgs,
        Utils.DestinationChainParams memory destChainParams,
        bytes memory destinationContractAddress,
        bytes memory payload
    ) internal returns (uint64) {
        require(msg.value != 0, "fees not sent");

        if (requestArgs.expTimestamp == 0) {
            requestArgs.expTimestamp = type(uint64).max;
        }

        bytes[] memory addresses = new bytes[](1);
        addresses[0] = destinationContractAddress;
        bytes[] memory payloads = new bytes[](1);
        payloads[0] = payload;

        return
            IGateway(gatewayContract).requestToDest{value: msg.value}(
                requestArgs,
                Utils.AckType.NO_ACK,
                Utils.AckGasParams(0, 0),
                destChainParams,
                Utils.ContractCalls(payloads, addresses)
            );
    }

    /// @notice Function to send a single request with acknowledgement to the destination chain.
    /// @dev You will be able to send a single request to a single contract on the destination chain and
    /// you need the acknowledgement back on the source chain.
    /// @param gatewayContract address of the gateway contract.
    /// @param requestArgs requestArgs consists of expiryTimestamp, isAtomicCalls boolean and feePayerEnum.
    /// expiryTimestamp: timestamp when the call expires. If this time passes by, the call will fail
    /// on the destination chain. If you don't want to add an expiry timestamp, set it to zero.
    /// isAtomicCalls: boolean value suggesting whether the calls are atomic. If true, either all the
    /// calls will be executed or none will be executed on the destination chain. If false, even if some calls
    /// fail, others will not be affected. In this case, true or false doesn't matter.
    /// feePayerEnum: fee payer enum can be either Utils.FeePayer.{APP, USER, NONE}. NONE can be used
    /// in case of meta tx. In case you use APP or USER, fee is deducted on router chain from the router address
    /// of the app or the user respectively.
    /// @param ackType type of acknowledgement you want: ACK_ON_SUCCESS, ACK_ON_ERR, ACK_ON_BOTH.
    /// @param ackGasParams This includes the gas limit required for the execution of handler function for
    /// crosstalk acknowledgement on the source chain and the gas price of the source chain.
    /// @param destChainParams dest chain params include the destChainType, destChainId, the gas limit
    /// required to execute handler function on the destination chain and the gas price of destination chain.
    /// @param destinationContractAddress Contract address (in bytes format) of the contract which will be
    /// called on the destination chain which will handle the payload.
    /// @param payload abi encoded data that you want to send to the destination chain.
    /// @return Returns the nonce from the gateway contract.
    function singleRequestWithAcknowledgement(
        address gatewayContract,
        Utils.RequestArgs memory requestArgs,
        Utils.AckType ackType,
        Utils.AckGasParams memory ackGasParams,
        Utils.DestinationChainParams memory destChainParams,
        bytes memory destinationContractAddress,
        bytes memory payload
    ) internal returns (uint64) {
        require(msg.value != 0, "fees not sent");

        if (requestArgs.expTimestamp == 0) {
            requestArgs.expTimestamp = type(uint64).max;
        }

        bytes[] memory addresses = new bytes[](1);
        addresses[0] = destinationContractAddress;
        bytes[] memory payloads = new bytes[](1);
        payloads[0] = payload;

        return
            IGateway(gatewayContract).requestToDest{value: msg.value}(
                requestArgs,
                ackType,
                ackGasParams,
                destChainParams,
                Utils.ContractCalls(payloads, addresses)
            );
    }

    /// @notice Function to send multiple requests without acknowledgement to multiple contracts on the
    /// destination chain.
    /// @dev You will be able to send multiple requests to multiple contracts on the destination chain and
    /// you don't need the acknowledgement back on the source chain.
    /// @param gatewayContract address of the gateway contract.
    /// @param requestArgs requestArgs consists of expiryTimestamp, isAtomicCalls boolean and feePayerEnum.
    /// expiryTimestamp: timestamp when the call expires. If this time passes by, the call will fail
    /// on the destination chain. If you don't want to add an expiry timestamp, set it to zero.
    /// isAtomicCalls: boolean value suggesting whether the calls are atomic. If true, either all the
    /// calls will be executed or none will be executed on the destination chain. If false, even if some calls
    /// fail, others will not be affected.
    /// feePayerEnum: fee payer enum can be either Utils.FeePayer.{APP, USER, NONE}. NONE can be used
    /// in case of meta tx. In case you use APP or USER, fee is deducted on router chain from the router address
    /// of the app or the user respectively.
    /// @param destChainParams dest chain params include the destChainType, destChainId, the gas limit
    /// required to execute handler function on the destination chain and the gas price of destination chain.
    /// @param destinationContractAddresses Array of contract addresses (in bytes format) of the contracts
    /// which will be called on the destination chain which will handle the respective payloads.
    /// @param payloads Array of abi encoded data that you want to send to the destination chain.
    /// @return Returns the nonce from the gateway contract.
    function multipleRequestsWithoutAcknowledgement(
        address gatewayContract,
        Utils.RequestArgs memory requestArgs,
        Utils.DestinationChainParams memory destChainParams,
        bytes[] memory destinationContractAddresses,
        bytes[] memory payloads
    ) internal returns (uint64) {
        require(msg.value != 0, "fees not sent");

        if (requestArgs.expTimestamp == 0) {
            requestArgs.expTimestamp = type(uint64).max;
        }

        return
            IGateway(gatewayContract).requestToDest{value: msg.value}(
                requestArgs,
                Utils.AckType.NO_ACK,
                Utils.AckGasParams(0, 0),
                destChainParams,
                Utils.ContractCalls(payloads, destinationContractAddresses)
            );
    }

    /// @notice Function to send multiple requests with acknowledgement to multiple contracts on the
    /// destination chain.
    /// @dev You will be able to send multiple requests to multiple contracts on the destination chain and
    /// you need the acknowledgement back on the source chain.
    /// @param gatewayContract address of the gateway contract.
    /// @param requestArgs requestArgs consists of expiryTimestamp, isAtomicCalls boolean and feePayerEnum.
    /// expiryTimestamp: timestamp when the call expires. If this time passes by, the call will fail
    /// on the destination chain. If you don't want to add an expiry timestamp, set it to zero.
    /// isAtomicCalls: boolean value suggesting whether the calls are atomic. If true, either all the
    /// calls will be executed or none will be executed on the destination chain. If false, even if some calls
    /// fail, others will not be affected.
    /// feePayerEnum: fee payer enum can be either Utils.FeePayer.{APP, USER, NONE}. NONE can be used
    /// in case of meta tx. In case you use APP or USER, fee is deducted on router chain from the router address
    /// of the app or the user respectively.
    /// @param ackType type of acknowledgement you want: ACK_ON_SUCCESS, ACK_ON_ERR, ACK_ON_BOTH.
    /// @param ackGasParams This includes the gas limit required for the execution of handler function for
    /// crosstalk acknowledgement on the source chain and the gas price of the source chain.
    /// @param destChainParams dest chain params include the destChainType, destChainId, the gas limit
    /// required to execute handler function on the destination chain and the gas price of destination chain.
    /// @param destinationContractAddresses Array of contract addresses (in bytes format) of the contracts
    /// which will be called on the destination chain which will handle the respective payloads.
    /// @param payloads Array of abi encoded data that you want to send to the destination chain.
    /// @return Returns the nonce from the gateway contract.
    function multipleRequestsWithAcknowledgement(
        address gatewayContract,
        Utils.RequestArgs memory requestArgs,
        Utils.AckType ackType,
        Utils.AckGasParams memory ackGasParams,
        Utils.DestinationChainParams memory destChainParams,
        bytes[] memory destinationContractAddresses,
        bytes[] memory payloads
    ) internal returns (uint64) {
        require(msg.value != 0, "fees not sent");
        if (requestArgs.expTimestamp == 0) {
            requestArgs.expTimestamp = type(uint64).max;
        }

        return
            IGateway(gatewayContract).requestToDest{value: msg.value}(
                requestArgs,
                ackType,
                ackGasParams,
                destChainParams,
                Utils.ContractCalls(payloads, destinationContractAddresses)
            );
    }
}

File 24 of 27 : IEvmBinding.sol
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;

abstract contract IEvmBinding {
    // event to create an outbound request on the router chain to the destination chain
    event OutboundBatchRequest(
        uint64 destinationChainType,
        string destinationChainId,
        bytes[] handlers,
        bytes[] payloads,
        uint256 relayerFee,
        uint256 gasLimit,
        uint256 gasPrice,
        uint64 outbound_ack_gas_limit,
        bool isAtomic,
        uint256 expTimestamp,
        uint256 routeAmount,
        bytes routeRecipient,
        bytes asmAddress
    );

    // function to receive an inbound request on the router chain from any source chain
    function inboundSudo(
        bytes memory sender,
        string memory srcChainId,
        uint64 srcChainType,
        uint64 eventNonce,
        bytes memory payload,
        bytes memory asmAddress
    ) external virtual;

    // function to receive an outbound request on the router chain from any source chain
    function outboundAckSudo(
        bytes memory outboundTxRequestedBy,
        string memory destChainId,
        uint64 destChainType,
        uint64 outboundBatchNonce,
        uint64 execCode,
        bool execStatus,
        bool[] memory execFlags,
        bytes[] memory execData,
        uint256 refund_amount
    ) external virtual;

    function toAddress(bytes memory _bytes) public pure returns (address contractAddress) {
        bytes20 srcTokenAddress;
        assembly {
            srcTokenAddress := mload(add(_bytes, 0x20))
        }
        contractAddress = address(srcTokenAddress);
    }

    function toBytes(address a) public pure returns (bytes memory b) {
        assembly {
            let m := mload(0x40)
            a := and(a, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
            mstore(add(m, 20), xor(0x140000000000000000000000000000000000000000, a))
            mstore(0x40, add(m, 52))
            b := m
        }
    }
}

File 25 of 27 : RouterRider.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma abicoder v2;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

import "@routerprotocol/evm-gateway-contracts/contracts/IGateway.sol";
import "@routerprotocol/evm-gateway-contracts/contracts/ICrossTalkApplication.sol";
import "@routerprotocol/router-crosstalk-utils/contracts/CrossTalkUtils.sol";

import "./RouterRiderERC721.sol";

/**
 * @title Router Rider ctoss chain NFT
 * @author Router Protocol
 * @notice this is ERC721 NFT, users can leverage advantage by participating in lottery and can able to win award as well
 */

contract RouterRider is
    Initializable,
    RouterRiderERC721,
    ICrossTalkApplication,
    UUPSUpgradeable
{
    IGateway gateway;
    string riderHomeRouterAddress;
    string riderHomeEVMAddress;
    string rChainId;
    uint64 rChainType;
    mapping(uint64 => mapping(string => bytes)) public ourContractOnChains;

    /**
     * initializer for this contract for this chain
     * @param gatewayAddress gatway contract address
     * @param _destGasLimit gas limit for handleRequestFromSource on dst chain
     * @param _ackGasLimit gas limit for handleCrossTalkAck on this chain
     * @param _chainId  chain id of this chain
     * @param _chainType chain type of this chain
     * @param _coolDownTime cool down time
     * @param _expiryTimestamp upper time limit for which handleCrossTalkAck on dst chain should be executed
     */
    function initialize(
        address payable gatewayAddress,
        uint64 _destGasLimit,
        uint64 _ackGasLimit,
        string memory _chainId,
        uint64 _chainType,
        uint256 _coolDownTime,
        uint64 _expiryTimestamp,
        string memory _rChainId,
        uint64 _rChainType,
        string memory _riderHomeRouterAddress,
        string memory _riderHomeEVMAddress
    ) public initializer {
        __UUPSUpgradeable_init();
        _RouterRiderERC721_init(
            gatewayAddress,
            _destGasLimit,
            _ackGasLimit,
            _chainId,
            _chainType,
            _coolDownTime,
            _expiryTimestamp
        );

        rChainId = _rChainId;
        rChainType = _rChainType;
        riderHomeRouterAddress = _riderHomeRouterAddress;
        riderHomeEVMAddress = _riderHomeEVMAddress;
        gateway = IGateway(gatewayContract);
    }

    function setFeePayer(string memory feePayer) public payable onlyOwner {
        gateway.setDappMetadata{value: msg.value}(feePayer);
    }

    /**
     * it enroll other rider nft contract which it deployed on other supported chain, can only be executed by owner of this contract
     * @param _chainType chain type of chain X
     * @param _chainId  chain id of chain X
     * @param _contractAddress  contract address of rider nft deployed on chain X
     */
    function enrollRemoteContract(
        uint64 _chainType,
        string memory _chainId,
        address _contractAddress
    ) external onlyOwner {
        ourContractOnChains[_chainType][_chainId] = toBytes(_contractAddress);
    }

    /**
     * modifer to check if caller is trusted gateway or not
     */
    modifier isGateway() {
        require(msg.sender == gatewayContract, "Caller: not gateway");
        _;
    }

    function _authorizeUpgrade(
        address newImplementation
    ) internal override onlyOwner {}

    /**
     * This function transfers rider NFTs across different blockchain networks, and increases the NFTs' score on successful rides.
     * @param _dstChainType chain type of dst chain
     * @param _dstChainId chain id of dst chain
     * @param destGasPrice The gas price for executing handleRequestFromSource on the destination chain.
     * @param ackGasPrice ack gast price to execute handleCrossTalkAck on this chain
     * @param _riderId  token Id of rider NFT that need to be transferred.
     * @param receiver receiver of nft on dst chain
     */
    function RideCrossChain(
        uint64 _dstChainType,
        string memory _dstChainId,
        uint64 destGasPrice,
        uint64 ackGasPrice,
        uint256 _riderId,
        address receiver
    ) public payable {
        require(msg.value > 0, "fee not sent");
        bytes memory dstContractAdress = ourContractOnChains[_dstChainType][
            _dstChainId
        ];
        require(
            keccak256(dstContractAdress) != keccak256(abi.encodePacked("")),
            "Invalid dst chain"
        );

        bytes memory payload = handleCrossChainTransfer(
            _riderId,
            receiver,
            false
        );

        // means riding to router chain
        if (
            keccak256(abi.encodePacked(_dstChainId)) ==
            keccak256(abi.encodePacked(rChainId)) &&
            _dstChainType == rChainType
        ) {
            gateway.requestToRouter{value: msg.value}(
                0, // routeAmount
                "", //routeRecipient
                payload,
                riderHomeEVMAddress,
                destGasLimit,
                "0x"
            );
        } else {
            CrossTalkUtils.singleRequestWithAcknowledgement(
                gatewayContract,
                Utils.RequestArgs(expiryTimestamp, false),
                Utils.AckType.ACK_ON_BOTH,
                Utils.AckGasParams(ackGasLimit, ackGasPrice),
                Utils.DestinationChainParams(
                    destGasLimit,
                    destGasPrice,
                    _dstChainType,
                    _dstChainId,
                    "0x"
                ),
                dstContractAdress, // destination contract address
                payload
            );
        }

        // token will be burned on ack
        emit CrossChainTransfer(
            riderMetadatas[_riderId].noOfRides,
            msg.sender,
            receiver,
            chainId,
            chainType,
            _dstChainId,
            _dstChainType,
            _riderId
        );
    }

    function handleRequestFromRouter(
        string memory sender,
        bytes memory payload
    ) external isGateway returns (bytes memory) {
        // TODO: get riderHomeRouterAddress in string format not address
        require(
            keccak256(abi.encodePacked(sender)) ==
                keccak256(abi.encodePacked(riderHomeRouterAddress)),
            "not called from router home contract"
        );
        bool isAck = abi.decode(payload, (bool));
        // on ack, outbound event to router will be created have to handle it
        if (isAck) {
            // hanlde ack from router chain here
            //TODO: for now assuming on router chain, execution went successful
            handleCrossTalkAckRequest(payload, true); // true indicates, tx went successful on router chain
            return ""; // ack of ack
        }
        // handle nft transfer from router chain
        return handleCrossTalkRequest(payload, false);
    }

    /**
     * When a cross-chain transfer is made from a source chain to this chain, the gateway contract on the destination chain executes this function. It re-evaluates the score of the NFT and mints a new NFT on this chain
     * @param srcContractAddress contract address of rider nft on src chain
     * @param payload abi encode data that being sent from crossChain tranfer
     * @param srcChainId chain id of src chain
     * @param srcChainType chain type of src chain
     */

    function handleRequestFromSource(
        bytes memory srcContractAddress,
        bytes memory payload,
        string memory srcChainId,
        uint64 srcChainType
    ) external isGateway returns (bytes memory) {
        require(
            keccak256(srcContractAddress) ==
                keccak256(ourContractOnChains[srcChainType][srcChainId]),
            "Not called from trusted contract"
        );
        return handleCrossTalkRequest(payload, false);
    }

    /**
     * The gateway contract on this chain executes this function only when the cross-chain transfer has been successful on the destination chain
     * @param execData it is array of abi.encoded data that's returned from handleRequestFromSource function on dst chain
     */
    function handleCrossTalkAck(
        uint64 /*eventIdentifier*/,
        bool[] memory execFlags,
        bytes[] memory execData
    ) external isGateway {
        bytes memory _payload = abi.decode(execData[0], (bytes));
        handleCrossTalkAckRequest(_payload, execFlags[0]);
    }

    function toBytes(address a) internal pure returns (bytes memory b) {
        assembly {
            let m := mload(0x40)
            a := and(a, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
            mstore(
                add(m, 20),
                xor(0x140000000000000000000000000000000000000000, a)
            )
            mstore(0x40, add(m, 52))
            b := m
        }
    }
}

File 26 of 27 : RouterRiderERC721.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma abicoder v2;

import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

/**
 * @title RouterRiderERC721
 * @author Router Protocol
 */

contract RouterRiderERC721 is
    Initializable,
    ERC721Upgradeable,
    ERC721URIStorageUpgradeable,
    OwnableUpgradeable
{
    address public gatewayContract;
    /**
     * @notice cool down time b/w each cross chain transfer in sec
     */
    uint256 public coolDownTime;
    uint64 public destGasLimit;
    uint64 public ackGasLimit;
    uint64 public chainType;
    uint64 public expiryTimestamp;
    uint64 lastChainIdx;
    string public chainId; // current chain id

    /**
     * @dev number of chain supported by this nft
     */
    uint256 numberOfChainSupported;

    /**
     * @notice this is threshold on number of visited to any chain
     */
    uint64[5] public chainTravelThresholds;
    /**
     * @notice this is scoring array based on chain travel threshold
     */
    uint64[6] public ccTravelRangeScore;

    /**
     * this event will be emitted when rider rides cross chain
     * @param rideNo ride no
     * @param sender address of sender who is executing cross chain tranfer
     * @param receiver receiver to whom ownership of rider will be transferred on dst chain
     * @param srcChainId chain id of src chain
     * @param srcChainType chain type of src chain
     * @param dstChainId chain id of dst chain
     * @param dstChainType chain type of dst chain
     * @param riderId token id of rider nft
     */
    event CrossChainTransfer(
        uint64 rideNo,
        address sender,
        address receiver,
        string srcChainId,
        uint64 srcChainType,
        string dstChainId,
        uint64 dstChainType,
        uint256 riderId
    );

    /**
     * this event will be emitted on handleRequestFromSource, when rider is received on dst chain from src chain
     * @param sender address of sender who had sent rider to receiver
     * @param receiver recipent address on dst chain
     * @param riderId token Id of rider nft which is transferred
     * @param scoreFrom score before ride
     * @param scoreTo score increased to after ride
     */
    event CrossChainReceive(
        uint64 rideNo,
        address sender,
        address receiver,
        uint256 riderId,
        uint256 scoreFrom,
        uint256 scoreTo
    );

    /**
     * This event will be emitted when the rider is successfully transferred from the source chain to the destination chain, received by the recipient, and acknowledged.
     * @param riderId token id of nft that is received on dst chain
     */
    event CrossChainReceived(uint64 rideNo, uint256 riderId);

    /**
     * struct of rider nft metadata
     * @notice owner owner of rider
     * @notice score score of this rider
     * @notice last_five_chains keeps track of last five cross chain visit by rider
     * @notice numberOfTimes it keeps track of number of visit on each supported chain
     * @notice lastRideTime it is the time when rider rides crosschain last in sec
     * @notice trackLast this keeps track of 5th index last_five_chains
     * @notice lastRideStartTime last start time of rider [if last request failed then user can able to try again after expiry timestamp]
     */
    struct RiderMetadata {
        address owner;
        bool riding;
        uint256 score;
        uint256 lastRideTime;
        uint256 lastRideStartTime;
        bytes32[5] last_five_chains;
        uint64[20] numberOfTimes;
        uint64 trackLast;
        uint64 noOfRides;
    }

    /**
     * @dev maps token id to it's metadata
     */
    mapping(uint256 => RiderMetadata) riderMetadatas;

    /**
     * @notice mapping b/w src and dst chain with index for RiderMetadata.chains_travelling_count
     */
    mapping(uint64 => mapping(string => uint64)) public chainIndexMapping;

    /**
     * initializer for this contract for this chain
     * @param gatewayAddress gatway contract address
     * @param _destGasLimit gas limit for handleRequestFromSource on dst chain
     * @param _ackGasLimit gas limit for handleCrossTalkAck on this chain
     * @param _chainId  chain id of this chain
     * @param _chainType chain type of this chain
     * @param _coolDownTime cool down time
     * @param _expiryTimestamp upper time limit for which handleCrossTalkAck on dst chain should be executed
     */
    function _RouterRiderERC721_init(
        address payable gatewayAddress,
        uint64 _destGasLimit,
        uint64 _ackGasLimit,
        string memory _chainId,
        uint64 _chainType,
        uint256 _coolDownTime,
        uint64 _expiryTimestamp
    ) internal onlyInitializing {
        _RouterRiderERC721WithoutGateway_init(
            _destGasLimit,
            _ackGasLimit,
            _chainId,
            _chainType,
            _coolDownTime,
            _expiryTimestamp
        );
        gatewayContract = gatewayAddress;
    }

    function _RouterRiderERC721WithoutGateway_init(
        uint64 _destGasLimit,
        uint64 _ackGasLimit,
        string memory _chainId,
        uint64 _chainType,
        uint256 _coolDownTime,
        uint64 _expiryTimestamp
    ) internal onlyInitializing {
        __ERC721_init("RouterRider", "RTR");
        __ERC721URIStorage_init();
        __Ownable_init();

        coolDownTime = _coolDownTime;
        destGasLimit = _destGasLimit;
        ackGasLimit = _ackGasLimit;
        chainId = _chainId;
        chainType = _chainType;
        numberOfChainSupported = 20;
        lastChainIdx = 0;
        if (_expiryTimestamp == 0) expiryTimestamp = type(uint64).max;
        else expiryTimestamp = _expiryTimestamp;
    }

    /**
     * returns rider metadata of rider nft token
     * @param riderId token id
     */
    function getRiderMetadata(
        uint256 riderId
    ) public view returns (RiderMetadata memory) {
        return riderMetadatas[riderId];
    }

    function updateTravelThresholds(
        uint64[5] memory _chainTravelThresholds,
        uint64[6] memory _ccTravelRangeScore
    ) public onlyOwner {
        chainTravelThresholds = _chainTravelThresholds;
        ccTravelRangeScore = _ccTravelRangeScore;
    }

    function updateExpiryTimeStamp(uint64 _expiryTimestamp) public onlyOwner {
        expiryTimestamp = _expiryTimestamp;
    }

    function updateCooldown(uint256 _coolDownTime) public onlyOwner {
        coolDownTime = _coolDownTime;
    }

    /**
     * this helps us indexing in numberOfTimes of Ridermetadata, this array should be same across all contracts on each chain
     * @param _chainTypes array of chaintypes and this should we in respective of chainIds array
     * @param _chainIds array of chainId and this should we in respective of chainTypes array
     */
    function mapChainContract(
        uint64[] memory _chainTypes,
        string[] memory _chainIds
    ) external onlyOwner {
        require(_chainTypes.length == _chainIds.length, "mismatch length");
        require(
            _chainTypes.length + lastChainIdx <= numberOfChainSupported,
            "only numberOfChainSupported!!"
        );

        for (uint64 crrIndex = 0; crrIndex < _chainIds.length; crrIndex++) {
            chainIndexMapping[_chainTypes[crrIndex]][
                _chainIds[crrIndex]
            ] = lastChainIdx;
            lastChainIdx++;
        }
    }

    function mapAChainContract(
        uint64 _chainType,
        string memory _chainId
    ) public onlyOwner {
        require(
            lastChainIdx + 1 <= numberOfChainSupported,
            "only numberOfChainSupported!!"
        );
        chainIndexMapping[_chainType][_chainId] = lastChainIdx;
        lastChainIdx++;
    }

    /**
     * this is internal function, will mint rider nft
     * @param to receipent of rider nft
     * @param riderId token id
     * @param uri uri of rider nft
     */
    function _safeMint(
        address to,
        uint256 riderId,
        string memory uri
    ) internal {
        _safeMint(to, riderId);
        _setTokenURI(riderId, uri);
    }

    // The following functions are overrides required by Solidity.
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        require(!riderMetadatas[tokenId].riding, "riding");
        //solhint-disable-next-line max-line-length
        require(
            _isApprovedOrOwner(_msgSender(), tokenId),
            "ERC721: caller is not token owner or approved"
        );
        _transfer(from, to, tokenId);
        riderMetadatas[tokenId].owner = to;
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) public virtual override {
        require(!riderMetadatas[tokenId].riding, "riding");
        require(
            _isApprovedOrOwner(_msgSender(), tokenId),
            "ERC721: caller is not token owner or approved"
        );
        _safeTransfer(from, to, tokenId, data);
        riderMetadatas[tokenId].owner = to;
    }

    function _burn(
        uint256 tokenId
    ) internal override(ERC721Upgradeable, ERC721URIStorageUpgradeable) {
        super._burn(tokenId);
    }

    function tokenURI(
        uint256 tokenId
    )
        public
        view
        override(ERC721Upgradeable, ERC721URIStorageUpgradeable)
        returns (string memory)
    {
        return super.tokenURI(tokenId);
    }

    /**
     * this function will check if rider with this _riderMetadata have visited this chain in last five cross chain transfer or not
     * @return _ true or false
     */
    function _isLastVisited(
        RiderMetadata memory _riderMetadata
    ) internal view returns (bool) {
        for (uint256 i = 0; i < 5; i++) {
            if (
                keccak256(abi.encode(chainId, chainType)) ==
                _riderMetadata.last_five_chains[i]
            ) return true;
        }
        return false;
    }

    /**
     * This function calculates the score of the rider NFT based on the number of times it has visited this chain. If this chain is among the last five chains visited, then the score is halved.
     */
    function _scoreOnChain(
        RiderMetadata memory _riderMetadata,
        uint256 chainMpIndex
    ) internal view returns (uint256) {
        uint256 numTravels = _riderMetadata.numberOfTimes[chainMpIndex];
        uint256 left = 0;
        uint256 right = chainTravelThresholds.length;
        while (left < right) {
            uint256 mid = (left + right) / 2;
            if (chainTravelThresholds[mid] < numTravels) {
                left = mid + 1;
            } else {
                right = mid;
            }
        }
        // Determine the score based on whether the rider is the last visited or not
        uint256 score = ccTravelRangeScore[left];
        if (_isLastVisited(_riderMetadata)) {
            score /= 2;
        }
        return score;
    }

    /**
     *  this is internal function and will be called internally when cross chain transfer goes successful
     * @param _riderMetadata rider metadata for which score should be recalculated based on scoring system
     */
    function _updateScore(RiderMetadata storage _riderMetadata) internal {
        uint256 chainMpIndex = chainIndexMapping[chainType][chainId];
        // taken this travel also for score calculation
        _riderMetadata.numberOfTimes[chainMpIndex] += 1;
        _riderMetadata.noOfRides += 1;

        uint256 score = 0; // base score on each transfer
        score += _scoreOnChain(_riderMetadata, chainMpIndex);
        _riderMetadata.score += score;
        // setting current block time as last transfer timestamp
        _riderMetadata.lastRideTime = block.timestamp;
    }

    /**
     * This function transfers rider NFTs across different blockchain networks, and increases the NFTs' score on successful rides.
     * @param _riderId  token Id of rider NFT that need to be transferred.
     * @param receiver receiver of nft on dst chain
     */
    function handleCrossChainTransfer(
        uint256 _riderId,
        address receiver,
        bool isRouterAck
    ) internal returns (bytes memory) {
        require(
            !riderMetadatas[_riderId].riding ||
                riderMetadatas[_riderId].lastRideStartTime + expiryTimestamp <
                block.timestamp,
            "already riding"
        );
        require(_ownerOf(_riderId) == msg.sender, "RP: Caller not owner");
        require(
            riderMetadatas[_riderId].lastRideTime + coolDownTime <
                block.timestamp,
            "try again after cooldown"
        );
        require(receiver != address(0), "RP: transfer to the address 0");
        bytes memory payload = abi.encode(
            isRouterAck,
            _riderId,
            tokenURI(_riderId),
            msg.sender,
            riderMetadatas[_riderId],
            receiver
        );
        riderMetadatas[_riderId].lastRideStartTime = block.timestamp;
        riderMetadatas[_riderId].riding = true;
        // token will be burned on ack
        return payload;
    }

    /**
     * @param payload payload sent from requestFromRouter or handleRequestFromSource
     * @param isRouterAck[keeping bool for our usecase] to check is ack request or cross talk request from router chain to other chain
     */
    function handleCrossTalkRequest(
        bytes memory payload,
        bool isRouterAck
    ) internal returns (bytes memory) {
        (
            ,
            //bool isRouterAck
            uint256 riderId,
            string memory tokenUri,
            address sender,
            RiderMetadata memory _riderMetadata,
            address receiver
        ) = abi.decode(
                payload,
                (bool, uint256, string, address, RiderMetadata, address)
            );
        uint64 rideNo = _riderMetadata.noOfRides;
        riderMetadatas[riderId] = _riderMetadata;
        riderMetadatas[riderId].owner = receiver;

        _updateScore(riderMetadatas[riderId]);

        // add this chain to last_five_chains

        riderMetadatas[riderId].last_five_chains[
            riderMetadatas[riderId].trackLast
        ] = keccak256(abi.encode(chainId, chainType));
        riderMetadatas[riderId].trackLast += 1;
        riderMetadatas[riderId].trackLast %= 5;

        // minting on dst chain to receiver
        _safeMint(receiver, riderId, tokenUri);

        emit CrossChainReceive(
            rideNo,
            sender,
            receiver,
            riderId,
            _riderMetadata.score,
            riderMetadatas[riderId].score
        );
        return abi.encode(isRouterAck, rideNo, riderId);
    }

    /**
     * The gateway contract on this chain executes this function only when the cross-chain transfer has been successful on the destination chain
     */
    function handleCrossTalkAckRequest(
        bytes memory _payload,
        bool isSuccess
    ) internal {
        (, uint64 rideNo, uint256 riderId) = abi.decode(
            _payload,
            (bool, uint64, uint256)
        );

        // unstacking on failure[no use]
        if (!isSuccess) {
            riderMetadatas[riderId].riding = false;
            return;
        }

        delete riderMetadatas[riderId];
        _burn(riderId);
        emit CrossChainReceived(rideNo, riderId);
    }

    receive() external payable {}
}

File 27 of 27 : RouterRiderHome.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma abicoder v2;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol";

import "@routerprotocol/router-evm-bindings/contracts/IEvmBinding.sol";
import "./RouterRiderERC721.sol";

/**
 * @title Router Rider Home, Rider Born Here
 * @author Router Protocol
 * @notice this is ERC721 NFT, users can leverage advantage by participating in lottery and can able to win award as well
 */

contract RouterRiderHome is
    Initializable,
    RouterRiderERC721,
    IEvmBinding,
    UUPSUpgradeable
{
    event RiderRedeemed(
        uint256 riderId,
        address by,
        string riderURI,
        uint256 score
    );

    using CountersUpgradeable for CountersUpgradeable.Counter;
    CountersUpgradeable.Counter private _tokenIdCounter;

    /**
     * @notice This mapping associates a user's address with a boolean value that indicates whether the user has redeemed their rider NFT or not.
     */
    mapping(address => bool) public isReedemed;
    mapping(uint64 => mapping(string => bytes)) public ourContractOnChains;
    mapping(uint64 => mapping(string => uint256)) public gasPriceMp;

    /**
     * initializer for this contract for this chain
     * @param _destGasLimit gas limit for handleRequestFromSource on dst chain
     * @param _ackGasLimit gas limit for handleCrossTalkAck on this chain
     * @param _chainId  chain id of this chain
     * @param _chainType chain type of this chain
     * @param _coolDownTime cool down time
     * @param _expiryTimestamp upper time limit for which handleCrossTalkAck on dst chain should be executed
     */
    function initialize(
        uint64 _destGasLimit,
        uint64 _ackGasLimit,
        string memory _chainId,
        uint64 _chainType,
        uint256 _coolDownTime,
        uint64 _expiryTimestamp
    ) public initializer {
        __UUPSUpgradeable_init();
        _RouterRiderERC721WithoutGateway_init(
            _destGasLimit,
            _ackGasLimit,
            _chainId,
            _chainType,
            _coolDownTime,
            _expiryTimestamp
        );
    }

    modifier isRouterChain() {
        require(
            msg.sender == address(0x0000000000000000000000000000000000000001),
            "Invalid Caller"
        );
        _;
    }

    function enrollRemoteContractGasPrice(
        uint64 _chainType,
        string memory _chainId,
        uint256 _gasPrice
    ) external onlyOwner {
        gasPriceMp[_chainType][_chainId] = _gasPrice;
    }

    /**
     * user can redeem on free rider nft by executing this public function
     */
    function RedeemRider() public {
        require(!isReedemed[msg.sender], "already redeemed");

        // TODO: Need to update the URI logic
        string memory uri = "URI";
        uint256 tokenId = _tokenIdCounter.current();
        _tokenIdCounter.increment();

        isReedemed[msg.sender] = true;
        RiderMetadata storage riderMetadata = riderMetadatas[tokenId];
        riderMetadata.owner = msg.sender;

        riderMetadata.numberOfTimes[chainIndexMapping[chainType][chainId]] = 1;
        riderMetadata.last_five_chains[0] = keccak256(
            abi.encode(chainId, chainType)
        );
        riderMetadata.score = ccTravelRangeScore[0];
        riderMetadata.lastRideTime = block.timestamp;
        riderMetadata.noOfRides = 1;
        riderMetadata.trackLast = 1;

        _safeMint(msg.sender, tokenId, uri);
        emit RiderRedeemed(tokenId, msg.sender, uri, riderMetadata.score);
    }

    /**
     * it enroll other rider nft contract which it deployed on other supported chain, can only be executed by owner of this contract
     * @param _chainType chain type of chain X
     * @param _chainId  chain id of chain X
     * @param _contractAddress  contract address of rider nft deployed on chain X
     */
    function enrollRemoteContract(
        uint64 _chainType,
        string memory _chainId,
        address _contractAddress
    ) external onlyOwner {
        ourContractOnChains[_chainType][_chainId] = toBytes(_contractAddress);
    }

    function _authorizeUpgrade(
        address newImplementation
    ) internal override onlyOwner {}

    /**
     * This function transfers rider NFTs across different blockchain networks, and increases the NFTs' score on successful rides.
     * @param _dstChainType chain type of dst chain
     * @param _dstChainId chain id of dst chain
     * @param destGasPrice The gas price for executing handleRequestFromSource on the destination chain.
     * @param _riderId  token Id of rider NFT that need to be transferred.
     * @param receiver receiver of nft on dst chain
     */
    function RideCrossChain(
        uint64 _dstChainType,
        string memory _dstChainId,
        uint64 destGasPrice,
        uint256 _riderId,
        address receiver
    ) public payable {
        require(msg.value > 0, "fee not sent");
        bytes memory dstContractAdress = ourContractOnChains[_dstChainType][
            _dstChainId
        ];
        require(
            keccak256(dstContractAdress) != keccak256(abi.encodePacked("")),
            "Invalid dst chain"
        );

        // token will be burned on ack
        uint256 relayerFee = 100; //  ? should be static or what
        bytes[] memory payloads = new bytes[](1);
        payloads[0] = handleCrossChainTransfer(_riderId, receiver, false);
        bytes[] memory handlers = new bytes[](1);
        handlers[0] = dstContractAdress;

        emit IEvmBinding.OutboundBatchRequest(
            _dstChainType,
            _dstChainId,
            handlers,
            payloads,
            relayerFee,
            destGasLimit,
            destGasPrice,
            ackGasLimit, // ackGasPrice?
            false,
            expiryTimestamp,
            0,
            "",
            ""
        );

        emit CrossChainTransfer(
            riderMetadatas[_riderId].noOfRides,
            msg.sender,
            receiver,
            chainId,
            chainType,
            _dstChainId,
            _dstChainType,
            _riderId
        );
    }

    /**
     * When a cross-chain transfer is made from a source chain to this chain, the gateway contract on the destination chain executes this function. It re-evaluates the score of the NFT and mints a new NFT on this chain
     * @param _sender contract address of rider nft on src chain
     * @param _payload abi encode data that being sent from crossChain tranfer
     * @param _srcChainId chain id of src chain
     * @param _srcChainType chain type of src chain
     */
    function inboundSudo(
        bytes memory _sender,
        string memory _srcChainId,
        uint64 _srcChainType,
        uint64 /*_eventNonce*/,
        bytes memory _payload,
        bytes memory /*_asmAddress*/
    ) external override isRouterChain {
        //TODO: open function
        require(
            keccak256(_sender) ==
                keccak256(ourContractOnChains[_srcChainType][_srcChainId]),
            "Not called from enrolled contract"
        );

        uint256 relayerFee = 100; //TODO:  ? should be static or what
        bytes[] memory handlers = new bytes[](1);
        handlers[0] = ourContractOnChains[_srcChainType][_srcChainId];

        bytes[] memory payloads = new bytes[](1);
        payloads[0] = handleCrossTalkRequest(_payload, true);
        uint256 expTimestamp = type(uint64).max;

        // send ack here, if it failed on dst chain, no ack will be sent
        emit IEvmBinding.OutboundBatchRequest(
            _srcChainType,
            _srcChainId,
            handlers,
            payloads,
            relayerFee,
            destGasLimit,
            gasPriceMp[_srcChainType][_srcChainId],
            ackGasLimit, // ackGasPrice?
            false,
            expTimestamp,
            0,
            "0x",
            "0x"
        );
    }

    /**
     * The gateway contract on this chain executes this function only when the cross-chain transfer has been successful on the destination chain
     * @param execData it is array of abi.encoded data that's returned from handleRequestFromSource function on dst chain
     */
    function outboundAckSudo(
        bytes memory outboundTxRequestedBy,
        string memory destChainId,
        uint64 destChainType,
        uint64 /*outboundBatchNonce*/,
        uint64 /*execCode*/,
        bool /*execStatus*/,
        bool[] memory execFlags,
        bytes[] memory execData,
        uint256 /*refund_amount*/
    ) external override isRouterChain {
        // TODO: have to verify this
        require(
            keccak256(outboundTxRequestedBy) ==
                keccak256(toBytes(address(this))),
            "Not called from trusted contract"
        );
        bytes memory _payload = abi.decode(execData[0], (bytes));
        if (keccak256(_payload) == keccak256(abi.encodePacked(""))) return;
        handleCrossTalkAckRequest(_payload, execFlags[0]);
    }
}

Settings
{
  "viaIR": true,
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"rideNo","type":"uint64"},{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"riderId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"scoreFrom","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"scoreTo","type":"uint256"}],"name":"CrossChainReceive","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"rideNo","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"riderId","type":"uint256"}],"name":"CrossChainReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"rideNo","type":"uint64"},{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"string","name":"srcChainId","type":"string"},{"indexed":false,"internalType":"uint64","name":"srcChainType","type":"uint64"},{"indexed":false,"internalType":"string","name":"dstChainId","type":"string"},{"indexed":false,"internalType":"uint64","name":"dstChainType","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"riderId","type":"uint256"}],"name":"CrossChainTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[{"internalType":"uint64","name":"_dstChainType","type":"uint64"},{"internalType":"string","name":"_dstChainId","type":"string"},{"internalType":"uint64","name":"destGasPrice","type":"uint64"},{"internalType":"uint64","name":"ackGasPrice","type":"uint64"},{"internalType":"uint256","name":"_riderId","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"RideCrossChain","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"ackGasLimit","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"ccTravelRangeScore","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"chainId","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"","type":"uint64"},{"internalType":"string","name":"","type":"string"}],"name":"chainIndexMapping","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"chainTravelThresholds","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"chainType","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"coolDownTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"destGasLimit","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_chainType","type":"uint64"},{"internalType":"string","name":"_chainId","type":"string"},{"internalType":"address","name":"_contractAddress","type":"address"}],"name":"enrollRemoteContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"expiryTimestamp","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gatewayContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"riderId","type":"uint256"}],"name":"getRiderMetadata","outputs":[{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"bool","name":"riding","type":"bool"},{"internalType":"uint256","name":"score","type":"uint256"},{"internalType":"uint256","name":"lastRideTime","type":"uint256"},{"internalType":"uint256","name":"lastRideStartTime","type":"uint256"},{"internalType":"bytes32[5]","name":"last_five_chains","type":"bytes32[5]"},{"internalType":"uint64[20]","name":"numberOfTimes","type":"uint64[20]"},{"internalType":"uint64","name":"trackLast","type":"uint64"},{"internalType":"uint64","name":"noOfRides","type":"uint64"}],"internalType":"struct RouterRiderERC721.RiderMetadata","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"","type":"uint64"},{"internalType":"bool[]","name":"execFlags","type":"bool[]"},{"internalType":"bytes[]","name":"execData","type":"bytes[]"}],"name":"handleCrossTalkAck","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"sender","type":"string"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"handleRequestFromRouter","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"srcContractAddress","type":"bytes"},{"internalType":"bytes","name":"payload","type":"bytes"},{"internalType":"string","name":"srcChainId","type":"string"},{"internalType":"uint64","name":"srcChainType","type":"uint64"}],"name":"handleRequestFromSource","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"gatewayAddress","type":"address"},{"internalType":"uint64","name":"_destGasLimit","type":"uint64"},{"internalType":"uint64","name":"_ackGasLimit","type":"uint64"},{"internalType":"string","name":"_chainId","type":"string"},{"internalType":"uint64","name":"_chainType","type":"uint64"},{"internalType":"uint256","name":"_coolDownTime","type":"uint256"},{"internalType":"uint64","name":"_expiryTimestamp","type":"uint64"},{"internalType":"string","name":"_rChainId","type":"string"},{"internalType":"uint64","name":"_rChainType","type":"uint64"},{"internalType":"string","name":"_riderHomeRouterAddress","type":"string"},{"internalType":"string","name":"_riderHomeEVMAddress","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_chainType","type":"uint64"},{"internalType":"string","name":"_chainId","type":"string"}],"name":"mapAChainContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"_chainTypes","type":"uint64[]"},{"internalType":"string[]","name":"_chainIds","type":"string[]"}],"name":"mapChainContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"","type":"uint64"},{"internalType":"string","name":"","type":"string"}],"name":"ourContractOnChains","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"feePayer","type":"string"}],"name":"setFeePayer","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_coolDownTime","type":"uint256"}],"name":"updateCooldown","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"_expiryTimestamp","type":"uint64"}],"name":"updateExpiryTimeStamp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64[5]","name":"_chainTravelThresholds","type":"uint64[5]"},{"internalType":"uint64[6]","name":"_ccTravelRangeScore","type":"uint64[6]"}],"name":"updateTravelThresholds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a080604052346100325730608052615722908162000038823960805181818161093001528181610cf80152610ecd0152f35b600080fdfe6080604052600436101561001b575b361561001957600080fd5b005b60003560e01c806301ffc9a7146102cb57806306fdde03146102c6578063081812fc146102c1578063095ea7b3146102bc5780631d3ea11e146102b757806323b872dd146102b25780633553a0bd146102ad5780633659cfe6146102a857806337a4daab146102a357806339d2d6091461029e5780633a027491146102995780633b397af51461029457806342842e0e1461028f5780634f1ef2861461028a578063504307d91461028557806352d1902d1461028057806355119df91461027b5780636352211e1461027657806370313a801461027157806370a082311461026c578063715018a614610267578063802e731c146102625780638da5cb5b1461025d57806395d89b411461025857806399ce2e8f146102535780639a8a05921461024e5780639bd2954914610249578063a22cb46514610244578063ade6e2aa1461023f578063b2901fec1461023a578063b5a910be14610235578063b88d4fde14610230578063bac5541e1461022b578063c87b56dd14610226578063c8e1eaca14610221578063d2ce0db21461021c578063d8a9646514610217578063e448ab8114610212578063e73389261461020d578063e985e9c514610208578063eb0cde1d14610203578063f2fde38b146101fe5763ffe8d4be0361000e576121d2565b612126565b6120fd565b612095565b612065565b611fc1565b611eaf565b611dfc565b611d7f565b611d60565b611d20565b611c93565b611940565b6118eb565b61188d565b61179d565b6116fc565b61157a565b6112ad565b611206565b6111dd565b6111b3565b611155565b6110b0565b610ff6565b610fa0565b610f7f565b610eba565b610e04565b610cb7565b610c8f565b610c65565b610c18565b610b6d565b610a56565b610909565b610849565b610602565b6105af565b6104d7565b610496565b6103b1565b6102e7565b6001600160e01b03198116036102e257565b600080fd5b346102e25760203660031901126102e2576020600435610306816102d0565b63ffffffff60e01b166380ac58cd60e01b8114908115610344575b8115610333575b506040519015158152f35b6301ffc9a760e01b14905038610328565b635b5e139f60e01b81149150610321565b60005b8381106103685750506000910152565b8181015183820152602001610358565b9060209161039181518092818552858086019101610355565b601f01601f1916010190565b9060206103ae928181520190610378565b90565b346102e2576000806003193601126104935760405190806065546103d481611418565b80855291600191808316908115610469575060011461040e575b61040a856103fe8187038261079f565b6040519182918261039d565b0390f35b9250606583527f8ff97419363ffd7000167f130ef7168fbea05faf9251824ca5043f113cc6a7c75b8284106104515750505081016020016103fe8261040a6103ee565b80546020858701810191909152909301928101610436565b86955061040a969350602092506103fe94915060ff191682840152151560051b82010192936103ee565b80fd5b346102e25760203660031901126102e25760206104b4600435612781565b6040516001600160a01b039091168152f35b6001600160a01b038116036102e257565b346102e25760403660031901126102e2576004356104f4816104c6565b602435610500816126ec565b916001600160a01b038084169082168114610560576100199361052d913314908115610532575b5061270f565b6127bf565b6001600160a01b03166000908152606a6020908152604080832033845290915290205460ff16905038610527565b60405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608490fd5b346102e25760003660031901126102e25760206001600160401b0360fd5416604051908152f35b60609060031901126102e2576004356105ee816104c6565b906024356105fb816104c6565b9060443590565b346102e25761067b610613366105d6565b92916000938085526106538184610105948560205261063c60ff60408b205460a01c1615614042565b61064e61064984336140d9565b614077565b6141aa565b84526020526040832080546001600160a01b0319166001600160a01b03909216919091179055565b80f35b6004359061068b826104c6565b565b6001600160401b038116036102e257565b6024359061068b8261068d565b6044359061068b8261068d565b6084359061068b8261068d565b60c4359061068b8261068d565b610104359061068b8261068d565b634e487b7160e01b600052604160045260246000fd5b61012081019081106001600160401b0382111761071257604052565b6106e0565b604081019081106001600160401b0382111761071257604052565b60a081019081106001600160401b0382111761071257604052565b602081019081106001600160401b0382111761071257604052565b61028081019081106001600160401b0382111761071257604052565b606081019081106001600160401b0382111761071257604052565b90601f801991011681019081106001600160401b0382111761071257604052565b6040519061068b82610717565b6040519061068b82610732565b6040519061068b826106f6565b6001600160401b03811161071257601f01601f191660200190565b81601f820112156102e257803590610819826107e7565b92610827604051948561079f565b828452602083830101116102e257816000926020809301838601378301015290565b346102e2576101603660031901126102e25761086361067e565b61086b61069e565b6108736106ab565b6001600160401b03926064358481116102e257610894903690600401610802565b9061089d6106b8565b906108a66106c5565b9060e4358781116102e2576108bf903690600401610802565b926108c86106d2565b94610124358981116102e2576108e2903690600401610802565b9661014435998a116102e2576108ff6100199a3690600401610802565b9860a43594612863565b346102e25760203660031901126102e257600435610926816104c6565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116919061095f308414156122d5565b61097c6000805160206156ad833981519152938285541614612336565b610984612234565b604051906109918261074d565b600082527f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156109cb5750506100199150612472565b6020600491604094939451928380926352d1902d60e01b825286165afa60009181610a26575b50610a135760405162461bcd60e51b815280610a0f60048201612423565b0390fd5b61001993610a2191146123c5565b612502565b610a4891925060203d8111610a4f575b610a40818361079f565b8101906123aa565b90386109f1565b503d610a36565b346102e25760403660031901126102e2576001600160401b036004358181116102e257610a87903690600401610802565b906024359081116102e25761040a91610aa7610ac2923690600401610802565b90610abd60018060a01b0360fb541633146138bb565b61391d565b604051918291602083526020830190610378565b6001600160401b0381116107125760051b60200190565b9080601f830112156102e257813590610b0582610ad6565b92610b13604051948561079f565b828452602092838086019160051b830101928084116102e257848301915b848310610b415750505050505090565b82356001600160401b0381116102e2578691610b6284848094890101610802565b815201920191610b31565b346102e25760403660031901126102e2576001600160401b036004358181116102e257366023820112156102e2578060040135610ba981610ad6565b91610bb7604051938461079f565b81835260209160248385019160051b830101913683116102e257602401905b828210610bff57602435858782116102e257610bf9610019923690600401610aed565b90613e6b565b8380918335610c0d8161068d565b815201910190610bd6565b346102e25760203660031901126102e257610019600435610c388161068d565b610c40612234565b60fd80546001600160c01b031660c09290921b6001600160c01b031916919091179055565b346102e25760003660031901126102e25760206001600160401b0360fd5460801c16604051908152f35b346102e257610019610ca0366105d6565b9060405192610cae8461074d565b60008452614307565b60403660031901126102e257600435610ccf816104c6565b6024356001600160401b0381116102e257610cee903690600401610802565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116929190610d28308514156122d5565b610d456000805160206156ad833981519152948286541614612336565b610d4d612234565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615610d835750506100199150612472565b6020600491604094939451928380926352d1902d60e01b825286165afa60009181610dda575b50610dc75760405162461bcd60e51b815280610a0f60048201612423565b61001993610dd591146123c5565b61261a565b610df391925060203d8111610a4f57610a40818361079f565b9038610da9565b801515036102e257565b346102e25760603660031901126102e257610e2060043561068d565b6001600160401b036024358181116102e257366023820112156102e2578060040135610e4b81610ad6565b91610e59604051938461079f565b81835260209160248385019160051b830101913683116102e257602401905b828210610ea157604435858782116102e257610e9b610019923690600401610aed565b90613aa6565b8380918335610eaf81610dfa565b815201910190610e78565b346102e25760003660031901126102e2577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163003610f14576040516000805160206156ad8339815191528152602090f35b60405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608490fd5b346102e25760203660031901126102e257610f98612234565b60043560fc55005b346102e25760203660031901126102e25760206104b46004356126ec565b9060406003198301126102e257600435610fd78161068d565b91602435906001600160401b0382116102e2576103ae91600401610802565b346102e25761001961109461108b61100d36610fbe565b9190611017612234565b61106760206001600160401b0394858060fe5416946110466110388761402a565b836101005491161115613fc6565b16600052610106825260406000208260405194838680955193849201610355565b820190815203019020906001600160401b03166001600160401b0319825416179055565b60fe5416614012565b6001600160401b03166001600160401b031960fe54161760fe55565b346102e25760203660031901126102e2576004356110cd816104c6565b6001600160a01b031680156110fe57600052606860205261040a604060002054604051918291829190602083019252565b60405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608490fd5b346102e2576000806003193601126104935761116f612234565b60c980546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b346102e25760003660031901126102e257602060fd546001600160401b036040519160401c168152f35b346102e25760003660031901126102e25760c9546040516001600160a01b039091168152602090f35b346102e25760008060031936011261049357604051908060665461122981611418565b8085529160019180831690811561046957506001146112525761040a856103fe8187038261079f565b9250606683527f46501879b8ca8525e8c2fd519e2fbfcfa2ebea26501294aa02cbfcfb12e943545b8284106112955750505081016020016103fe8261040a6103ee565b8054602085870181019190915290930192810161127a565b346102e25760603660031901126102e2576004356112ca8161068d565b6001600160401b03906024358281116102e2576112eb903690600401610802565b91604435906112f9826104c6565b611301612234565b60405193849260018060a01b0316600560a21b186014840152603483019081604052826000951685526020938491610170835282611349604089209286815193849201610355565b820190603482015203019020918451918211610712576113738261136d8554611418565b85612bb3565b80601f83116001146113ad57508394829394926113a2575b50508160011b916000199060031b1c191617905580f35b01519050388061138b565b90601f198316956113c385600052602060002090565b9286905b888210611400575050836001959697106113e7575b505050811b01905580f35b015160001960f88460031b161c191690553880806113dc565b806001859682949686015181550195019301906113c7565b90600182811c92168015611448575b602083101461143257565b634e487b7160e01b600052602260045260246000fd5b91607f1691611427565b60ff546000929161146282611418565b808252916001908181169081156114c7575060011461148057505050565b9192935060ff6000526000805160206156cd833981519152916000925b8484106114af57505060209250010190565b8054602085850181019190915290930192810161149d565b915050602093945060ff929192191683830152151560051b010190565b90600092918054916114f583611418565b9182825260019384811690816000146115575750600114611517575b50505050565b90919394506000526020928360002092846000945b838610611543575050505001019038808080611511565b80548587018301529401938590820161152c565b9294505050602093945060ff191683830152151560051b01019038808080611511565b346102e25760008060031936011261049357604051908060ff5461159d81611418565b8085529160019180831690811561046957506001146115c65761040a856103fe8187038261079f565b925060ff83526000805160206156cd8339815191525b8284106115f75750505081016020016103fe8261040a6103ee565b805460208587018101919091529093019281016115dc565b6000915b6005831061162057505050565b600190825181526020809101920192019190611613565b6000915b6014831061164857505050565b6001906001600160401b038351168152602080910192019201919061163b565b81516001600160a01b031681526020808301511515908201526104008101929161068b91906103e090610100906040810151604085015260608101516060850152608081015160808501526116c560a082015160a086019061160f565b6116d860c0820151610140860190611637565b60e08101516001600160401b03166103c085015201516001600160401b0316910152565b346102e25760203660031901126102e257604051611719816106f6565b61010060009182815282602082015282604082015282606082015282608082015260405161174681610732565b60a036823760a082015260405161175c81610768565b61028036823760c08201528260e0820152015261040a61179161178c600435600052610105602052604060002090565b613d36565b60405191829182611668565b346102e25760403660031901126102e2576004356117ba816104c6565b6024356117c681610dfa565b6001600160a01b0382169133831461184857816118056118169233600052606a60205260406000209060018060a01b0316600052602052604060002090565b9060ff801983541691151516179055565b604051901515815233907f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3190602090a3005b60405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606490fd5b346102e25760003660031901126102e257602060fd5460c01c604051908152f35b906118c160209282815194859201610355565b0190565b6020906118df928260405194838680955193849201610355565b82019081520301902090565b346102e25760208061192d6118ff36610fbe565b6001600160401b03939193809416600052610106825260406000208260405194838680955193849201610355565b8201908152030190205416604051908152f35b60c03660031901126102e2576004356119588161068d565b6001600160401b03906024358281116102e257611979903690600401610802565b90604435926119878461068d565b606435916119948361068d565b6084359060a435946119a5866104c6565b6119b03415156132d5565b6119df6119da6119d4846001600160401b0316600052610170602052604060002090565b836118c5565b6121b7565b8051946020958683012096611a0c6040988951600081526119ff8161074d565b8981519101201415613310565b611a1689876147a3565b99885188810181611a2782896118ae565b0391611a3b601f199384810183528261079f565b519020908a51611a5e8b82019282611a5285613350565b0390810183528261079f565b5190201480611c67575b15611b8157505061016b54611abf998793509150611a96906001600160a01b03165b6001600160a01b031690565b60fd546001600160401b03168851636418cb8960e01b81529a8b93849283929160048401613495565b039134905af1938415611b7c577fec8ed408af8ecf0a4379a01f192738964d9705fe4d42810be74916da93e2afa797611b4995611b4e575b50505b611b25600e611b1485600052610105602052604060002090565b015460401c6001600160401b031690565b94611b3c60fd546001600160401b039060801c1690565b90519687963390886135b7565b0390a1005b81611b6d92903d10611b75575b611b65818361079f565b8101906132c0565b503880611af7565b503d611b5b565b6123b9565b9188611c619492611b4999611c3b7fec8ed408af8ecf0a4379a01f192738964d9705fe4d42810be74916da93e2afa79e96611bc360fb5460018060a01b031690565b92611c2b60fd5497611c12611bd66107c0565b60c08b901c8152976000858a0152611c03838c611bf16107c0565b9c1c168b906001600160401b03169052565b6001600160401b031689850152565b611c1a6107cd565b981688906001600160401b03169052565b8601906001600160401b03169052565b6001600160401b038916848d0152876060850152611c57613477565b60808501526137da565b50611afa565b50611c8a611c7e61016f546001600160401b031690565b6001600160401b031690565b83871614611a68565b346102e25760803660031901126102e257600435611cb0816104c6565b602435611cbc816104c6565b606435916001600160401b0383116102e257611cdf610019933690600401610802565b9160443591614307565b634e487b7160e01b600052603260045260246000fd5b906006821015611d1b5760188260021c610103019260031b1690565b611ce9565b346102e25760203660031901126102e25760043560068110156102e2576001600160401b03611d50602092611cff565b9190546040519260031b1c168152f35b346102e25760203660031901126102e25761040a610ac2600435614565565b346102e25760803660031901126102e2576001600160401b036004358181116102e257611db0903690600401610802565b906024358181116102e257611dc9903690600401610802565b916044359182116102e25761040a92611de96103fe933690600401610802565b9060643592611df78461068d565b6139f7565b346102e25760003660031901126102e257602060fc54604051908152f35b9060405191611e2883610732565b8260a49182116102e2576004905b828210611e4257505050565b602080918335611e518161068d565b815201910190611e36565b906040519160c083018381106001600160401b0382111761071257604052826101649182116102e25760a4905b828210611e9557505050565b602080918335611ea48161068d565b815201910190611e89565b346102e2576101603660031901126102e25736602312156102e257611ed336611e1a565b3660c312156102e257611ee536611e5c565b90611eee612234565b906000915b60019283811015611f635760009384905b60048210611f215750506001919293816101010155019190611ef3565b6020611f598597611f3b849597516001600160401b031690565b908760031b60031b916001600160401b03809116831b921b19161790565b9601930190611f04565b50906000805b60018110611f7f57610019838361010255613dd7565b906020611fb7600192611f9987516001600160401b031690565b908560031b60031b916001600160401b03809116831b921b19161790565b9401939101611f69565b60203660031901126102e2576004356001600160401b0381116102e2576020611ff1612020923690600401610802565b611ff9612234565b60018060a01b0361016b5416604051808095819463778ae5ed60e11b83526004830161039d565b039134905af18015611b7c5761203257005b6100199060203d8111611b7557611b65818361079f565b906005821015611d1b5760188260021c610101019260031b1690565b346102e25760203660031901126102e25760043560058110156102e2576001600160401b03611d50602092612049565b346102e25760403660031901126102e257602060ff6120f16004356120b9816104c6565b602435906120c6826104c6565b60018060a01b0316600052606a845260406000209060018060a01b0316600052602052604060002090565b54166040519015158152f35b346102e25760003660031901126102e25760fb546040516001600160a01b039091168152602090f35b346102e25760203660031901126102e257600435612143816104c6565b61214b612234565b6001600160a01b03811615612163576100199061228c565b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b9061068b6121cb92604051938480926114e4565b038361079f565b346102e25761040a61222d610ac261221860206001600160401b036121f636610fbe565b9116600052610170825260406000208260405194838680955193849201610355565b820190815203019020604051928380926114e4565b038261079f565b60c9546001600160a01b0316330361224857565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b60c980546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b156122dc57565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608490fd5b1561233d57565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608490fd5b604051906123a48261074d565b60008252565b908160209103126102e2575190565b6040513d6000823e3d90fd5b156123cc57565b60405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b60809060208152602e60208201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960408201526d6f6e206973206e6f74205555505360901b60608201520190565b803b156124a7576000805160206156ad83398151915280546001600160a01b0319166001600160a01b03909216919091179055565b60405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b61250b81612472565b6040516001600160a01b0382167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a2825115801590612612575b61255157505050565b813b156125c15750600082819260206125be95519201905af4612572612670565b6040519161257f83610784565b602783527f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c6020840152660819985a5b195960ca1b6040840152612823565b50565b62461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608490fd5b506000612548565b61262381612472565b6040516001600160a01b0382167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a28251158015906126685761255157505050565b506001612548565b3d1561269b573d90612681826107e7565b9161268f604051938461079f565b82523d6000602084013e565b606090565b156126a757565b60405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606490fd5b6000908152606760205260409020546001600160a01b03166103ae8115156126a0565b1561271657565b60405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608490fd5b6000818152606760205260409020546127a4906001600160a01b031615156126a0565b6000908152606960205260409020546001600160a01b031690565b600082815260696020526040902080546001600160a01b0319166001600160a01b0383161790556001600160a01b03806127f8846126ec565b169116907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600080a4565b9091901561282f575090565b81511561283f5750805190602001fd5b60405162461bcd60e51b815260206004820152908190610a0f906024830190610378565b989694929099979593916000549a60ff8c60081c1615809c819d61298e575b811561296e575b5015612912576128af9a8c6128a6600160ff196000541617600055565b6128f957613028565b6128b557565b6128c561ff001960005416600055565b604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989080602081015b0390a1565b61290d61010061ff00196000541617600055565b613028565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b303b15915081612980575b5038612889565b6001915060ff161438612979565b600160ff8216109150612882565b8181106129a7575050565b6000815560010161299c565b90601f82116129c0575050565b61068b9160656000527f8ff97419363ffd7000167f130ef7168fbea05faf9251824ca5043f113cc6a7c7906020601f840160051c83019310612a0a575b601f0160051c019061299c565b90915081906129fd565b90601f8211612a21575050565b61068b9160ff6000526000805160206156cd833981519152906020601f840160051c83019310612a0a57601f0160051c019061299c565b90601f8211612a65575050565b61068b9161016e6000527ff82fbbf6ecba5c6bca8ffdb165c351ca78f1011f756f9b1202212482fd7d8313906020601f840160051c83019310612a0a57601f0160051c019061299c565b90601f8211612abc575050565b61068b9161016c6000527fe5af487827b121aa2456a019311df153887da6c98285803eea72252e4f09489b906020601f840160051c83019310612a0a57601f0160051c019061299c565b90601f8211612b13575050565b61068b9161016d6000527f535f6990c27693b80d059530c371f53ea19bfc595ef3bd58348694aac9095300906020601f840160051c83019310612a0a57601f0160051c019061299c565b90601f8211612b6a575050565b61068b9160666000527f46501879b8ca8525e8c2fd519e2fbfcfa2ebea26501294aa02cbfcfb12e94354906020601f840160051c83019310612a0a57601f0160051c019061299c565b9190601f8111612bc257505050565b61068b926000526020600020906020601f840160051c83019310612a0a57601f0160051c019061299c565b9081516001600160401b03811161071257612c1281612c0d60ff54611418565b612a14565b602080601f8311600114612c4e5750819293600092612c43575b50508160011b916000199060031b1c19161760ff55565b015190503880612c2c565b90601f19831694612c6f60ff6000526000805160206156cd83398151915290565b926000905b878210612cac575050836001959610612c93575b505050811b0160ff55565b015160001960f88460031b161c19169055388080612c88565b80600185968294968601518155019501930190612c74565b9081516001600160401b0381116107125761016e90612cec81612ce78454611418565b612a58565b602080601f8311600114612d28575081929394600092612d1d575b50508160011b916000199060031b1c1916179055565b015190503880612d07565b90601f19831695612d5c61016e6000527ff82fbbf6ecba5c6bca8ffdb165c351ca78f1011f756f9b1202212482fd7d831390565b926000905b888210612d9957505083600195969710612d80575b505050811b019055565b015160001960f88460031b161c19169055388080612d76565b80600185968294968601518155019501930190612d61565b9081516001600160401b0381116107125761016c90612dd981612dd48454611418565b612aaf565b602080601f8311600114612e09575081929394600092612d1d5750508160011b916000199060031b1c1916179055565b90601f19831695612e3d61016c6000527fe5af487827b121aa2456a019311df153887da6c98285803eea72252e4f09489b90565b926000905b888210612e6057505083600195969710612d8057505050811b019055565b80600185968294968601518155019501930190612e42565b9081516001600160401b0381116107125761016d90612ea081612e9b8454611418565b612b06565b602080601f8311600114612ed0575081929394600092612d1d5750508160011b916000199060031b1c1916179055565b90601f19831695612f0461016d6000527f535f6990c27693b80d059530c371f53ea19bfc595ef3bd58348694aac909530090565b926000905b888210612f2757505083600195969710612d8057505050811b019055565b80600185968294968601518155019501930190612f09565b9081516001600160401b03811161071257612f6481612f5f606654611418565b612b5d565b602080601f8311600114612fa05750819293600092612f95575b50508160011b916000199060031b1c191617606655565b015190503880612f7e565b90601f19831694612fd360666000527f46501879b8ca8525e8c2fd519e2fbfcfa2ebea26501294aa02cbfcfb12e9435490565b926000905b878210613010575050836001959610612ff7575b505050811b01606655565b015160001960f88460031b161c19169055388080612fec565b80600185968294968601518155019501930190612fd8565b90956131496131b99561311c6131e19d9c9a966131176131b4976130ee6131dc9f9c9d6130d26131d79f61305a6132a4565b61307460ff60005460081c1661306f81613244565b613244565b6130bd60405161308381610717565b600b81526a2937baba32b92934b232b960a91b6020820152604051906130a882610717565b6003825262292a2960e91b6020830152613b7b565b6130c56132a4565b6130cd613b5d565b60fc55565b6001600160401b03166001600160401b031960fd54161760fd55565b67ffffffffffffffff60401b60fd549160401b169067ffffffffffffffff60401b19161760fd55565b612bed565b60fd805467ffffffffffffffff60801b191660809290921b67ffffffffffffffff60801b16919091179055565b613154601461010055565b6131696001600160401b031960fe541660fe55565b6001600160401b03811661321c575060fd80546001600160c01b03166001600160c01b03191790555b60fb80546001600160a01b0319166001600160a01b0392909216919091179055565b612cc4565b6001600160401b0361016f91166001600160401b0319825416179055565b612db1565b612e78565b60fb5461068b906131fa906001600160a01b0316611a8a565b61016b80546001600160a01b0319166001600160a01b03909216919091179055565b60fd80546001600160c01b031660c09290921b6001600160c01b031916919091179055613192565b1561324b57565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b61068b60ff60005460081c16613244565b519061068b8261068d565b908160209103126102e257516103ae8161068d565b156132dc57565b60405162461bcd60e51b815260206004820152600c60248201526b199959481b9bdd081cd95b9d60a21b6044820152606490fd5b1561331757565b60405162461bcd60e51b815260206004820152601160248201527024b73b30b634b2103239ba1031b430b4b760791b6044820152606490fd5b9060009161016e90815461336381611418565b926001918083169081156133d6575060011461337f5750505050565b9091929394506000527ff82fbbf6ecba5c6bca8ffdb165c351ca78f1011f756f9b1202212482fd7d8313906000915b8483106133c357505050019038808080611511565b81816020925485870152019201916133ae565b60ff1916845250505081151590910201915038808080611511565b9060009161016c90815461340481611418565b926001918083169081156133d657506001146134205750505050565b9091929394506000527fe5af487827b121aa2456a019311df153887da6c98285803eea72252e4f09489b906000915b84831061346457505050019038808080611511565b818160209254858701520192019161344f565b6040519061348482610717565b6002825261060f60f31b6020830152565b92919092600081526134c160209460c086840152600060c084015260e0604084015260e0830190610378565b91818303606083015260009261016d9081546134dc81611418565b8083529260019180831690811561358b5750600114613527575b505050509361060f60f31b916001600160401b036040959616608082015260a0818503910152600283528201520190565b60009081529395509091907f535f6990c27693b80d059530c371f53ea19bfc595ef3bd58348694aac90953005b8285106135785750505001840191816001600160401b03604061060f60f31b6134f6565b80548486018a0152938801938101613554565b60ff1916848b015250505090151560051b0185019250816001600160401b03604061060f60f31b6134f6565b939092946136109260e096999897996001600160401b03809616875260018060a01b038092166020880152166040860152836135fc6101008060608901528701611452565b9216608086015284820360a0860152610378565b951660c08201520152565b1561362257565b60405162461bcd60e51b815260206004820152600d60248201526c1999595cc81b9bdd081cd95b9d609a1b6044820152606490fd5b60405161366381610717565b600181528060005b6020808210156136865790606060209282850101520161366b565b50505090565b805115611d1b5760200190565b8051821015611d1b5760209160051b010190565b908082519081815260208091019281808460051b8301019501936000915b8483106136db5750505050505090565b90919293949584806136f9600193601f198682030187528a51610378565b98019301930191949392906136cb565b6103ae91602061372283516040845260408401906136ad565b9201519060208184039101526136ad565b9260206137cc92816103ae97956001600160401b03938385809551168a52015115158289015260036040890152828151166060890152015116608086015260e060a08601528082511660e08601528060208301511661010086015260408201511661012085015260806137b7606083015160a0610140880152610180870190610378565b91015184820360df1901610160860152610378565b9160c0818403910152613709565b91906020946137ea34151561361b565b6001600160401b0361380383516001600160401b031690565b16156138ac575b613812613657565b9061381c8261368c565b526138268161368c565b5061382f613657565b966138398861368c565b526138438761368c565b5061384c6107c0565b968752858701526138736040519687958694859463b3e64a7960e01b865260048601613733565b039134906001600160a01b03165af1908115611b7c57600091613894575090565b6103ae915060203d8111611b7557611b65818361079f565b6001600160401b03825261380a565b156138c257565b60405162461bcd60e51b815260206004820152601360248201527243616c6c65723a206e6f74206761746577617960681b6044820152606490fd5b519061068b82610dfa565b908160209103126102e257516103ae81610dfa565b6040519060209161394a83828161393d8183019687815193849201610355565b810103808452018261079f565b5190206040518281019061396f81613961846133f1565b03601f19810183528261079f565b519020036139a75780613989918351840101908301613908565b613996576103ae90614c6f565b61399f90615470565b6103ae612397565b6084906040519062461bcd60e51b825260048201526024808201527f6e6f742063616c6c65642066726f6d20726f7574657220686f6d6520636f6e746044820152631c9858dd60e21b6064820152fd5b613a4e61221861222d92959395613a1960018060a01b0360fb541633146138bb565b8051956001600160401b0360209788809401209616600052610170825260406000208260405194838680955193849201610355565b82815191012003613a6357506103ae90614c6f565b6064906040519062461bcd60e51b825280600483015260248201527f4e6f742063616c6c65642066726f6d207472757374656420636f6e74726163746044820152fd5b90613abc60018060a01b0360fb541633146138bb565b805115611d1b57602001519081518201916020818185019403126102e2576020810151906001600160401b0382116102e2570182603f820112156102e257613b1c613b1661068b948360406020613b229601519101613b28565b9261368c565b51151590565b90615509565b90929192613b35816107e7565b91613b43604051938461079f565b8294828452828201116102e257602061068b930190610355565b613b7260ff60005460081c1661306f81613244565b61068b3361228c565b90613b9160ff60005460081c1661306f81613244565b81516001600160401b03811161071257613bb581613bb0606554611418565b6129b3565b602080601f8311600114613bf75750819061068b94600092613bec575b50508160011b916000199060031b1c191617606555612f3f565b015190503880613bd2565b919293601f198416613c2b60656000527f8ff97419363ffd7000167f130ef7168fbea05faf9251824ca5043f113cc6a7c790565b936000905b828210613c7257505091600193918561068b97969410613c59575b505050811b01606555612f3f565b015160001960f88460031b161c19169055388080613c4b565b80600186978294978701518155019601940190613c30565b906000905b60058210613c9c57505050565b6001602081928554815201930191019091613c8f565b90613cc06040518093613c8a565b61068b82610732565b906000905b60146003830110613cde57505050565b60016004918454906001600160401b0391828116825260408382821c16602084015260809382851c169083015260c01c606082015201930191019091613cce565b90613d2d6040518093613cc9565b61068b82610768565b9061068b600e613d446107da565b84546001600160a01b038116825260a01c60ff161515602082015293600181015460408601526002810154606086015260038101546080860152613d8a60048201613cb2565b60a0860152613d9b60098201613d1f565b60c086015201546001600160401b0380821660e086015260409190911c16610100840152565b634e487b7160e01b600052601160045260246000fd5b906000915b60019283811015613e2e5760009384905b60048210613e0a5750506001919293816101030155019190613ddc565b6020613e248597611f3b849597516001600160401b031690565b9601930190613ded565b50909150600090815b60028110613e4757505061010455565b90916020613e62600192611f9986516001600160401b031690565b93019101613e37565b919091613e76612234565b8051835103613f6f57805192613eb0613ea560fe95613e9f611c7e88546001600160401b031690565b90613fb9565b610100541015613fc6565b60005b81516001600160401b03821690811015613f675790613f46613f6292613f2b613ee389546001600160401b031690565b91613f25613f1e613f04613ef7848c613699565b516001600160401b031690565b6001600160401b0316600052610106602052604060002090565b9188613699565b516118c5565b906001600160401b03166001600160401b0319825416179055565b613f5d611094613f5d88546001600160401b031690565b614012565b613eb3565b505050509050565b60405162461bcd60e51b815260206004820152600f60248201526e0dad2e6dac2e8c6d040d8cadccee8d608b1b6044820152606490fd5b9060018201809211613fb457565b613dc1565b91908201809211613fb457565b15613fcd57565b60405162461bcd60e51b815260206004820152601d60248201527f6f6e6c79206e756d6265724f66436861696e537570706f7274656421210000006044820152606490fd5b6001600160401b03809116908114613fb45760010190565b9060016001600160401b0380931601918211613fb457565b1561404957565b60405162461bcd60e51b8152602060048201526006602482015265726964696e6760d01b6044820152606490fd5b1561407e57565b60405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201526c1c881bdc88185c1c1c9bdd9959609a1b6064820152608490fd5b6001600160a01b03806140eb846126ec565b169281831692848414948515614120575b5050831561410a5750505090565b61411691929350612781565b1614388080613686565b6000908152606a602090815260408083206001600160a01b03949094168352929052205460ff16935038806140fc565b1561415757565b60405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608490fd5b6141ce906141b7846126ec565b6001600160a01b0382811693909182168414614150565b83169283156142b65761423561428f926141f4856141ee611a8a8a6126ec565b14614150565b61421b61420b886000526069602052604060002090565b80546001600160a01b0319169055565b6001600160a01b0316600090815260686020526040902090565b80546000190190556001600160a01b038116600090815260686020526040902060018154019055614270856000526067602052604060002090565b80546001600160a01b0319166001600160a01b03909216919091179055565b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4565b60405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608490fd5b909161435861435361068b95836000528386610105968760205261433660ff60406000205460a01c1615614042565b61434361064984336140d9565b61434e8383836141aa565b614529565b6143d7565b60005260205260406000209060018060a01b03166bffffffffffffffffffffffff60a01b825416179055565b60809060208152603260208201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b60608201520190565b156143de57565b60405162461bcd60e51b815280610a0f60048201614384565b908160209103126102e257516103ae816102d0565b6103ae939260809260018060a01b031682526000602083015260408201528160608201520190610378565b6001600160a01b0391821681529116602082015260408101919091526080606082018190526103ae92910190610378565b909190803b156145215761449a602091600093604051948580948193630a85bd0160e11b998a8452336004850161440c565b03926001600160a01b03165af1600091816144f1575b506144e3576144bd612670565b805190816144de5760405162461bcd60e51b815280610a0f60048201614384565b602001fd5b6001600160e01b0319161490565b61451391925060203d811161451a575b61450b818361079f565b8101906143f7565b90386144b0565b503d614501565b505050600190565b92909190823b1561455c5761449a926020926000604051809681958294630a85bd0160e11b9a8b85523360048601614437565b50505050600190565b600081815260676020526040902054614588906001600160a01b031615156126a0565b600052609760205261222d6145a76040600020604051928380926114e4565b60006040516145b58161074d565b5290565b156145c057565b60405162461bcd60e51b815260206004820152600e60248201526d616c726561647920726964696e6760901b6044820152606490fd5b156145fd57565b60405162461bcd60e51b815260206004820152601460248201527329281d1021b0b63632b9103737ba1037bbb732b960611b6044820152606490fd5b1561464057565b60405162461bcd60e51b815260206004820152601860248201527f74727920616761696e20616674657220636f6f6c646f776e00000000000000006044820152606490fd5b1561468c57565b60405162461bcd60e51b815260206004820152601d60248201527f52503a207472616e7366657220746f20746865206164647265737320300000006044820152606490fd5b90600e61068b9561473061470461048096614793959b9a989b6000885260208801526104a0806040890152870190610378565b6001600160a01b039a8b16606087015282549a8b1660808701529960ff60a087019160a01c1615159052565b600181015460c0850152600281015460e08501526003810154610100850152614760610120850160048301613c8a565b6147716101c0850160098301613cc9565b01546001600160401b0380821661044085015260409190911c16610460830152565b6001600160a01b03909216910152565b6148c86103ae916147d36147cf6147c583600052610105602052604060002090565b5460a01c60ff1690565b1590565b80156148db575b6147e3906145b9565b61485861480a6147fd836000526067602052604060002090565b546001600160a01b031690565b6001600160a01b039061482090821633146145f6565b61484f614848600261483d86600052610105602052604060002090565b015460fc5490613fb9565b4211614639565b85161515614685565b61489d61486482614565565b61488f61487c84600052610105602052604060002090565b96604051978893339087602087016146d1565b03601f19810186528561079f565b4260036148b583600052610105602052604060002090565b0155600052610105602052604060002090565b805460ff60a01b1916600160a01b179055565b506147e361490a60036148f984600052610105602052604060002090565b0154613e9f611c7e60fd5460c01c90565b421190506147da565b519061068b826104c6565b9080601f830112156102e2576040519161493783610732565b829060a081019283116102e257905b8282106149535750505090565b8151815260209182019101614946565b9080601f830112156102e2576040519161497c83610768565b829061028081019283116102e257905b8282106149995750505090565b6020809183516149a88161068d565b81520191019061498c565b91908281036104a081126102e25783516149cc81610dfa565b9360208101519360408201516001600160401b0381116102e257820184601f820112156102e25784816020614a0393519101613b28565b936104006060840151614a15816104c6565b94607f1901126102e2576104806103ae91614a2e6107da565b90614a3b60808701614913565b8252614a4960a087016138fd565b602083015260c0860151604083015260e08601516060830152614a8f61010091828801516080850152614a80816101208a0161491e565b60a08501526101c08801614963565b60c0830152614aa161044087016132b5565b60e0830152614ab361046087016132b5565b908201529301614913565b9060005b60058110614acf57505050565b600190602083519301928185015501614ac2565b9060005b60058110614af457505050565b6000805b60048110614b0d575083820155600101614ae7565b83519093916001916020916001600160401b03600688901b81811b199092169216901b1792019301614af8565b815181546001600160a01b0319166001600160a01b0390911617815561068b9190614c149061010090600e90614b90614b766020870151151590565b825460ff60a01b191690151560a01b60ff60a01b16178255565b604085015160018201556060850151600282015560808501516003820155614bbf60a086015160048301614abe565b614bd060c086015160098301614ae3565b0192614c06614be960e08301516001600160401b031690565b855467ffffffffffffffff19166001600160401b03909116178555565b01516001600160401b031690565b67ffffffffffffffff60401b82549160401b169067ffffffffffffffff60401b1916179055565b9190916040815260206001600160401b03614c5860408401611452565b9416910152565b6005821015611d1b570190600090565b805181016020019060200190614c84916149b3565b6101008201519195509293926001600160a01b039291908316906001600160401b03169580614cbe86600052610105602052604060002090565b90614cc891614b3a565b81614cde86600052610105602052604060002090565b80546001600160a01b0319166001600160a01b03909216919091179055614d1085600052610105602052604060002090565b614d19906151b2565b60fd5460801c6001600160401b03169560405196876020810191614d3d9083614c3b565b0397601f19988981018252614d52908261079f565b519020614d6a87600052610105602052604060002090565b600401614d8288600052610105602052604060002090565b600e01546001600160401b0316614d9891614c5f565b614db3929082549060031b91821b91600019901b1916179055565b614dc886600052610105602052604060002090565b600e0180546001600160401b0316614ddf9061402a565b815467ffffffffffffffff19166001600160401b03909116179055614e0f86600052610105602052604060002090565b600e01805467ffffffffffffffff19811660056001600160401b0392831606909116179055614e3f908684614ef2565b60400151614e5885600052610105602052604060002090565b60010154604080516001600160401b038a1681526001600160a01b039590961685166020870152929093169184019190915260608301849052608083015260a08201527f0bbd5284c2b978ebdeca289d0dec079626c8db49dfeacf2a94895e7bb909822c9060c090a160408051600060208201526001600160401b0394909416908401526060830152608090810182526103ae908261079f565b909160405192614f018461074d565b6000808552936001600160a01b03841693841561510657614fd2918361435392614f49614f4383600052606760205260018060a01b0360406000205416151590565b1561514a565b600082815260676020526040902054614f6c906001600160a01b03161515614f43565b6001600160a01b03811660009081526068602052604090208290986001998a8154019055614fa883614270846000526067602052604060002090565b8a7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4614468565b6000818152606760205260409020546001600160a01b0316156150aa5783526020916097835260408420938251926001600160401b038411610712576150228461501c8854611418565b88612bb3565b8491601f851160011461505a57939450849291908361504f575b50501b916000199060031b1c1916179055565b01519250388061503c565b92948490601f1982169061507389600052602060002090565b95905b888383106150905750505010612d8057505050811b019055565b858701518855909601959485019487935090810190615076565b60405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b6064820152608490fd5b606460405162461bcd60e51b815260206004820152602060248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152fd5b1561515157565b60405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606490fd5b9190916014831015611d1b576018908360021c019260031b1690565b6001600160401b0360fd5460801c166000526020610106815260406000209060405190600060ff54936151e485611418565b6001958087169081156152f357506001146152b2575b508152829003019020546152a89061529d9061521e906001600160401b0316611c7e565b61527061522e8260098801615196565b61524d6152488284546001600160401b039160031b1c1690565b61402a565b91805490926001600160401b0360039390931b83811b199092169216901b179055565b61528f600e8601614c1461524882546001600160401b039060401c1690565b61529885613d36565b615308565b918301918254613fb9565b9055600242910155565b90915060ff6000526000805160206156cd833981519152856000915b8383106152e157505050830190836151fa565b805487840152918501918791016152ce565b60ff19168652508015150284019150836151fa565b9060c0820151906014811015611d1b5760051b01516001600160401b03166000906005905b81831061536e57505061535b611c7e61534861536193611cff565b90546001600160401b039160031b1c1690565b916153be565b6153685790565b60011c90565b909161537d6153688483613fb9565b908261538e611c7e61534885612049565b10156153a6575061539e90613fa6565b915b9061532d565b92506153a0565b906005811015611d1b5760051b0190565b60fd5460801c6001600160401b0316919060005b600581106153e257506000925050565b60405160208101906153f8816139618885614c3b565b5190206154098260a08501516153ad565b5114615420576000198114613fb4576001016153d2565b506001925050565b60009081815560019082828201558260028201558260038201556009810191600482015b838110615466575050600e6154639101809261299c565b55565b848155810161544c565b6060818051810103126102e257806154ac60207f0c745eeff686a2036009a8923579a79d8b462926976ccc918c1932d5c8ba0a98930151610dfa565b60606040820151916154bd8361068d565b0151906154dd6154d883600052610105602052604060002090565b615428565b6154e682615594565b604080516001600160401b039092168252602082019290925290819081016128f4565b6060818051810103126102e2576155236020820151610dfa565b60606040820151916155348361068d565b0151911561557757907f0c745eeff686a2036009a8923579a79d8b462926976ccc918c1932d5c8ba0a98916154dd6154d883600052610105602052604060002090565b50600090815261010560205260409020805460ff60a01b19169055565b61559d816126ec565b506155a7816126ec565b908060008093828252606960205260408220906bffffffffffffffffffffffff60a01b9182815416905560018060a01b0316908183526068602052604083206000198154019055615602846000526067602052604060002090565b9081541690557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a4615649615643826000526097602052604060002090565b54611418565b615651575050565b615665906000526097602052604060002090565b61566f8154611418565b8061567957505050565b82601f821160011461568a57505055565b90918082526156a8601f60208420940160051c84016001850161299c565b555556fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbce08ec2af2cfc251225e1968fd6ca21e4044f129bffa95bac3503be8bdb30a367a2646970667358221220e02184281783af2fcd3442c8acd5dd42b6d7d931234323cc0ba67c41bf2409e564736f6c63430008120033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading