ETH Price: $3,648.38 (+1.92%)
Gas: 6.41 Gwei

Contract

0x9C72E35c360aa7024E7Ae143AEfEFd72d0d634d7
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Deploy With Type...200749422024-06-12 9:46:23170 days ago1718185583IN
0x9C72E35c...2d0d634d7
0 ETH0.0170041534.05775283
Deploy With Type...200749392024-06-12 9:45:47170 days ago1718185547IN
0x9C72E35c...2d0d634d7
0 ETH0.0171432334.33281879
Deploy With Type...200749362024-06-12 9:45:11170 days ago1718185511IN
0x9C72E35c...2d0d634d7
0 ETH0.0151916329.41487911
Deploy With Type...200154852024-06-04 2:30:59179 days ago1717468259IN
0x9C72E35c...2d0d634d7
0 ETH0.003347746.70538252
Deploy With Type...200154802024-06-04 2:29:59179 days ago1717468199IN
0x9C72E35c...2d0d634d7
0 ETH0.003127976.2647466
Deploy With Type...200154712024-06-04 2:28:11179 days ago1717468091IN
0x9C72E35c...2d0d634d7
0 ETH0.003197286.19165765
Deploy With Type...198097132024-05-06 8:00:59207 days ago1714982459IN
0x9C72E35c...2d0d634d7
0 ETH0.002445524.89696289
Deploy With Type...198096912024-05-06 7:56:35207 days ago1714982195IN
0x9C72E35c...2d0d634d7
0 ETH0.00239294.63327132
Deploy With Type...196668832024-04-16 8:34:23227 days ago1713256463IN
0x9C72E35c...2d0d634d7
0 ETH0.004296838.60486576
Deploy With Type...196661302024-04-16 6:02:11227 days ago1713247331IN
0x9C72E35c...2d0d634d7
0 ETH0.004079438.169109
Deploy With Type...196661172024-04-16 5:59:35227 days ago1713247175IN
0x9C72E35c...2d0d634d7
0 ETH0.004359468.4325033
Set Backoffice A...196099652024-04-08 9:09:11235 days ago1712567351IN
0x9C72E35c...2d0d634d7
0 ETH0.0011979124.78308085
Set Subscription...196099602024-04-08 9:08:11235 days ago1712567291IN
0x9C72E35c...2d0d634d7
0 ETH0.0013402225.93220412
Set Implementati...196099552024-04-08 9:07:11235 days ago1712567231IN
0x9C72E35c...2d0d634d7
0 ETH0.0012491324.23097293

Latest 11 internal transactions

Advanced mode:
Parent Transaction Hash Block From To
200749422024-06-12 9:46:23170 days ago1718185583
0x9C72E35c...2d0d634d7
 Contract Creation0 ETH
200749392024-06-12 9:45:47170 days ago1718185547
0x9C72E35c...2d0d634d7
 Contract Creation0 ETH
200749362024-06-12 9:45:11170 days ago1718185511
0x9C72E35c...2d0d634d7
 Contract Creation0 ETH
200154852024-06-04 2:30:59179 days ago1717468259
0x9C72E35c...2d0d634d7
 Contract Creation0 ETH
200154802024-06-04 2:29:59179 days ago1717468199
0x9C72E35c...2d0d634d7
 Contract Creation0 ETH
200154712024-06-04 2:28:11179 days ago1717468091
0x9C72E35c...2d0d634d7
 Contract Creation0 ETH
198097132024-05-06 8:00:59207 days ago1714982459
0x9C72E35c...2d0d634d7
 Contract Creation0 ETH
198096912024-05-06 7:56:35207 days ago1714982195
0x9C72E35c...2d0d634d7
 Contract Creation0 ETH
196668832024-04-16 8:34:23227 days ago1713256463
0x9C72E35c...2d0d634d7
 Contract Creation0 ETH
196661302024-04-16 6:02:11227 days ago1713247331
0x9C72E35c...2d0d634d7
 Contract Creation0 ETH
196661172024-04-16 5:59:35227 days ago1713247175
0x9C72E35c...2d0d634d7
 Contract Creation0 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
VestingCustomFactory

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 24 : VestingCustomFactory.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Enjinstarter
pragma solidity 0.8.19;

import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import {AdminPrivileges} from "./AdminPrivileges.sol";
import {ISubscriptionService} from "./interfaces/ISubscriptionService.sol";
import {IFactoryImplementation, IVestingCustomFactory} from "./interfaces/IVestingCustomFactory.sol";

/**
 * @title VestingCustomFactory
 * @author Tim Loh
 * @notice Provides an implementation of custom vesting factory interface for deploying custom vesting contracts based
 *         on reference implementation
 */
contract VestingCustomFactory is AdminPrivileges, EIP712, Pausable, ReentrancyGuard, IVestingCustomFactory {
    using Address for address;
    using Clones for address;
    using ECDSA for bytes32;

    struct DeployInfo {
        address implementation; // address of reference implementation
        address deployedContract; // address of deployed contract
        bool isInitialized; // `true` if initialized
    }

    uint256 public constant SIGNATURE_LENGTH = 65;
    uint256 public constant TOKEN_DECIMALS_MAX = 18;

    uint256 public immutable factoryImplementationType;

    address public backofficeAdminAddress;
    // https://github.com/crytic/slither/wiki/Detector-Documentation#state-variables-that-could-be-declared-immutable
    // slither-disable-next-line immutable-states
    string public factoryName;
    // slither-disable-next-line immutable-states
    string public factoryVersion;
    address public implementationAddress;
    address public subscriptionService;

    mapping(bytes32 => DeployInfo) private _deployments;

    /**
     * @notice The meaning of `name` and `version` is specified in
     *         https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator
     */
    constructor(string memory name, string memory version, uint256 implementationType) EIP712(name, version) {
        _setRoleAdmin(BACKOFFICE_ROLE_ADMIN_ROLE, BACKOFFICE_ROLE_ADMIN_ROLE);
        _setRoleAdmin(BACKOFFICE_GOVERNANCE_ROLE, BACKOFFICE_ROLE_ADMIN_ROLE);
        _setRoleAdmin(BACKOFFICE_CONTRACT_ADMIN_ROLE, BACKOFFICE_ROLE_ADMIN_ROLE);

        _grantRole(BACKOFFICE_ROLE_ADMIN_ROLE, msg.sender);
        _grantRole(BACKOFFICE_GOVERNANCE_ROLE, msg.sender);
        _grantRole(BACKOFFICE_CONTRACT_ADMIN_ROLE, msg.sender);

        factoryName = name;
        factoryVersion = version;
        factoryImplementationType = implementationType;
    }

    /**
     * @inheritdoc IVestingCustomFactory
     */
    function deployWithTypedSignature(
        bytes32 deployId,
        bytes32 subscriptionId,
        string memory name,
        address tokenAddress,
        uint256 tokenDecimals,
        bool allowAccumulate,
        bytes memory signature
    ) external virtual override whenNotPaused {
        _deployWithTypedSignature(
            deployId,
            subscriptionId,
            name,
            tokenAddress,
            tokenDecimals,
            allowAccumulate,
            backofficeAdminAddress,
            msg.sender,
            signature
        );
    }

    /**
     * @inheritdoc IVestingCustomFactory
     */
    function pauseContract() external virtual override onlyRole(BACKOFFICE_CONTRACT_ADMIN_ROLE) {
        _pause();
    }

    /**
     * @inheritdoc IVestingCustomFactory
     */
    function setBackofficeAdminAddress(
        address newBackofficeAdminAddress
    ) external virtual override onlyRole(BACKOFFICE_CONTRACT_ADMIN_ROLE) {
        require(newBackofficeAdminAddress != address(0), "VCF: backoffice admin");

        address oldBackofficeAdminAddress = backofficeAdminAddress;
        backofficeAdminAddress = newBackofficeAdminAddress;

        emit BackofficeAdminAddressChanged(oldBackofficeAdminAddress, newBackofficeAdminAddress, msg.sender);
    }

    /**
     * @inheritdoc IVestingCustomFactory
     */
    function setImplementationAddress(
        address newImplementation
    ) external virtual override onlyRole(BACKOFFICE_GOVERNANCE_ROLE) {
        require(newImplementation != address(0), "VCF: new implementation");

        address oldImplementation = implementationAddress;
        implementationAddress = newImplementation;

        emit ImplementationAddressChanged(oldImplementation, newImplementation, msg.sender);

        uint256 implementationType = IFactoryImplementation(newImplementation).factoryImplementationType();
        require(implementationType == factoryImplementationType, "VCF: implementation type");
    }

    /**
     * @inheritdoc IVestingCustomFactory
     */
    function setSubscriptionService(address newAddress) external virtual override onlyRole(BACKOFFICE_GOVERNANCE_ROLE) {
        require(newAddress != address(0), "VCF: address");

        address oldAddress = subscriptionService;
        subscriptionService = newAddress;

        emit SubscriptionServiceChanged(oldAddress, newAddress, msg.sender);

        bool supportsSubscriptionServiceInterface = ISubscriptionService(newAddress).supportsInterface(
            type(ISubscriptionService).interfaceId
        );
        require(supportsSubscriptionServiceInterface, "VCF: interface");
    }

    /**
     * @inheritdoc IVestingCustomFactory
     */
    function unpauseContract() external virtual override onlyRole(BACKOFFICE_CONTRACT_ADMIN_ROLE) {
        _unpause();
    }

    /**
     * @inheritdoc IVestingCustomFactory
     */
    function deployInfoFor(
        bytes32 deployId
    ) external view virtual override returns (address implementation, address deployedContract) {
        require(_deployments[deployId].isInitialized, "VCF: uninitialized");

        implementation = _deployments[deployId].implementation;
        deployedContract = _deployments[deployId].deployedContract;
    }

    /**
     * @inheritdoc IVestingCustomFactory
     */
    function recoverTypedSignature(
        address implementation,
        bytes32 deployId,
        string memory name,
        address tokenAddress,
        uint256 tokenDecimals,
        bool allowAccumulate,
        address tenantAdminAddress,
        bytes memory signature
    ) external view virtual override returns (address recovered) {
        recovered = _recoverTypedSignature(
            implementation,
            deployId,
            name,
            tokenAddress,
            tokenDecimals,
            allowAccumulate,
            tenantAdminAddress,
            signature
        );
    }

    /**
     * @dev Consume purchased subscription package by `account` to deploy a contract
     * @param subscriptionId The subscription identifier
     * @param account The account consuming the subscription package to deploy a contract
     * @return isConsumed Returns whether subscription package has been successfully consumed
     */
    function _consumeSubscriptionPackage(
        bytes32 subscriptionId,
        address account
    ) internal virtual returns (bool isConsumed) {
        require(subscriptionService != address(0), "VCF: subscription");

        isConsumed = ISubscriptionService(subscriptionService).consumeSubscriptionPackage(subscriptionId, account);
    }

    /**
     * @dev Deploy contract based on given typed signature
     * @param deployId The deploy identifier
     * @param subscriptionId The subscription identifier
     * @param name The deployment name
     * @param tokenAddress The vesting token address
     * @param tokenDecimals The number of decimals for vesting token
     * @param allowAccumulate `true` if multiple grant amounts is allowed to accumulate for the same user,
     *                        `false` if a user can only have one grant
     * @param backofficeAddress The backoffice admin address that will be set for deploy contract
     * @param tenantAdminAddress The tenant admin address that will be set for deploy contract
     * @param signature The typed signature must be from an authorized signer before contract is deployed
     */
    function _deployWithTypedSignature(
        bytes32 deployId,
        bytes32 subscriptionId,
        string memory name,
        address tokenAddress,
        uint256 tokenDecimals,
        bool allowAccumulate,
        address backofficeAddress,
        address tenantAdminAddress,
        bytes memory signature
    ) internal virtual nonReentrant {
        require(!_deployments[deployId].isInitialized, "VCF: exists");
        require(backofficeAddress != address(0), "VCF: backoffice address");

        address recovered = _recoverTypedSignature(
            implementationAddress,
            deployId,
            name,
            tokenAddress,
            tokenDecimals,
            allowAccumulate,
            tenantAdminAddress,
            signature
        );
        require(msg.sender == recovered, "VCF: sender");

        bytes memory saltdata = _encodeSaltData(deployId);
        bytes32 salt = keccak256(saltdata);
        address deployedAddress = implementationAddress.cloneDeterministic(salt);
        require(deployedAddress != address(0), "VCF: deployed address");

        _deployments[deployId] = DeployInfo({
            implementation: implementationAddress,
            deployedContract: deployedAddress,
            isInitialized: true
        });

        bytes memory initializeData = _encodeInitializeData(
            tokenAddress,
            tokenDecimals,
            allowAccumulate,
            backofficeAddress,
            tenantAdminAddress
        );

        emit ContractDeployed(
            deployedAddress,
            deployId,
            subscriptionId,
            name,
            tokenAddress,
            tokenDecimals,
            allowAccumulate,
            backofficeAddress,
            tenantAdminAddress,
            recovered,
            implementationAddress
        );

        require(_consumeSubscriptionPackage(subscriptionId, recovered), "VCF: consume");

        // https://github.com/crytic/slither/wiki/Detector-Documentation#unused-return
        // slither-disable-next-line unused-return
        deployedAddress.functionCall(initializeData);
    }

    /**
     * @dev Returns signer of given typed signature
     * @param implementation The reference contract implementation address
     * @param deployId The deploy identifier
     * @param name The deployment name
     * @param tokenAddress The vesting token address
     * @param tokenDecimals The number of decimals for vesting token
     * @param allowAccumulate `true` if multiple grant amounts is allowed to accumulate for the same user,
     *                        `false` if a user can only have one grant
     * @param tenantAdminAddress The tenant admin address that will be set for deploy contract
     * @param signature The typed signature is verified to be from an authorized signer before contract is deployed
     * @return recovered The signer address
     */
    function _recoverTypedSignature(
        address implementation,
        bytes32 deployId,
        string memory name,
        address tokenAddress,
        uint256 tokenDecimals,
        bool allowAccumulate,
        address tenantAdminAddress,
        bytes memory signature
    ) internal view virtual returns (address recovered) {
        require(implementation != address(0), "VCF: implementation");
        require(bytes(name).length > 0, "VCF: name");
        require(tokenAddress != address(0), "VCF: token address");
        require(tokenDecimals <= TOKEN_DECIMALS_MAX, "VCF: token decimals");
        require(tenantAdminAddress != address(0), "VCF: tenant address");
        require(signature.length == SIGNATURE_LENGTH, "VCF: signature");

        bytes32 digest = _hashTypedDataV4(
            keccak256(
                abi.encode(
                    keccak256(
                        "VestingCustom("
                        "address implementation,"
                        "bytes32 deployId,"
                        "string name,"
                        "address tokenAddress,"
                        "uint256 tokenDecimals,"
                        "bool allowAccumulate,"
                        "address tenantAdminAddress"
                        ")"
                    ),
                    implementation,
                    deployId,
                    keccak256(bytes(name)),
                    tokenAddress,
                    tokenDecimals,
                    allowAccumulate,
                    tenantAdminAddress
                )
            )
        );
        recovered = digest.recover(signature);
        require(recovered != address(0), "VCF: recovered");
    }

    /**
     * @dev Returns encoded initialization data for deploy contract
     * @param tokenAddress The vesting token address
     * @param tokenDecimals The number of decimals for vesting token
     * @param allowAccumulate `true` if multiple grant amounts is allowed to accumulate for the same user,
     *                        `false` if a user can only have one grant
     * @param backofficeAddress The backoffice admin address that will be set for deploy contract
     * @param tenantAdminAddress The tenant admin address that will be set for deploy contract
     * @return encodedData The encoded initialization data for deploy contract
     */
    function _encodeInitializeData(
        address tokenAddress,
        uint256 tokenDecimals,
        bool allowAccumulate,
        address backofficeAddress,
        address tenantAdminAddress
    ) internal pure virtual returns (bytes memory encodedData) {
        encodedData = abi.encodeWithSignature(
            "initialize(address,uint256,bool,address,address)",
            tokenAddress,
            tokenDecimals,
            allowAccumulate,
            backofficeAddress,
            tenantAdminAddress
        );
    }

    /**
     * @dev Returns encoded salt data for deploy contract
     * @param deployId The deploy identifier
     * @return encodedData The encoded salt data for deploy contract
     */
    function _encodeSaltData(bytes32 deployId) internal pure virtual returns (bytes memory encodedData) {
        encodedData = abi.encodeWithSignature("salt(bytes32)", deployId);
    }
}

File 2 of 24 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

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

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(account),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 3 of 24 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 4 of 24 : IERC5267.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol)

pragma solidity ^0.8.0;

interface IERC5267 {
    /**
     * @dev MAY be emitted to signal that the domain could have changed.
     */
    event EIP712DomainChanged();

    /**
     * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
     * signature.
     */
    function eip712Domain()
        external
        view
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        );
}

File 5 of 24 : Clones.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/Clones.sol)

pragma solidity ^0.8.0;

/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 *
 * _Available since v3.4._
 */
library Clones {
    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address implementation) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create(0, 0x09, 0x37)
        }
        require(instance != address(0), "ERC1167: create failed");
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `implementation` and `salt` multiple time will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create2(0, 0x09, 0x37, salt)
        }
        require(instance != address(0), "ERC1167: create2 failed");
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt,
        address deployer
    ) internal pure returns (address predicted) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(add(ptr, 0x38), deployer)
            mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)
            mstore(add(ptr, 0x14), implementation)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)
            mstore(add(ptr, 0x58), salt)
            mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))
            predicted := keccak256(add(ptr, 0x43), 0x55)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt
    ) internal view returns (address predicted) {
        return predictDeterministicAddress(implementation, salt, address(this));
    }
}

File 6 of 24 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

File 7 of 24 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}

File 8 of 24 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.0/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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(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 9 of 24 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

File 10 of 24 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, "\x19Ethereum Signed Message:\n32")
            mstore(0x1c, hash)
            message := keccak256(0x00, 0x3c)
        }
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, "\x19\x01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            data := keccak256(ptr, 0x42)
        }
    }

    /**
     * @dev Returns an Ethereum Signed Data with intended validator, created from a
     * `validator` and `data` according to the version 0 of EIP-191.
     *
     * See {recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x00", validator, data));
    }
}

File 11 of 24 : EIP712.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol)

pragma solidity ^0.8.8;

import "./ECDSA.sol";
import "../ShortStrings.sol";
import "../../interfaces/IERC5267.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
 * separator of the implementation contract. This will cause the `_domainSeparatorV4` function to always rebuild the
 * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
 *
 * _Available since v3.4._
 *
 * @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
 */
abstract contract EIP712 is IERC5267 {
    using ShortStrings for *;

    bytes32 private constant _TYPE_HASH =
        keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    bytes32 private immutable _cachedDomainSeparator;
    uint256 private immutable _cachedChainId;
    address private immutable _cachedThis;

    bytes32 private immutable _hashedName;
    bytes32 private immutable _hashedVersion;

    ShortString private immutable _name;
    ShortString private immutable _version;
    string private _nameFallback;
    string private _versionFallback;

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        _name = name.toShortStringWithFallback(_nameFallback);
        _version = version.toShortStringWithFallback(_versionFallback);
        _hashedName = keccak256(bytes(name));
        _hashedVersion = keccak256(bytes(version));

        _cachedChainId = block.chainid;
        _cachedDomainSeparator = _buildDomainSeparator();
        _cachedThis = address(this);
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (address(this) == _cachedThis && block.chainid == _cachedChainId) {
            return _cachedDomainSeparator;
        } else {
            return _buildDomainSeparator();
        }
    }

    function _buildDomainSeparator() private view returns (bytes32) {
        return keccak256(abi.encode(_TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
    }

    /**
     * @dev See {EIP-5267}.
     *
     * _Available since v4.9._
     */
    function eip712Domain()
        public
        view
        virtual
        override
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        )
    {
        return (
            hex"0f", // 01111
            _name.toStringWithFallback(_nameFallback),
            _version.toStringWithFallback(_versionFallback),
            block.chainid,
            address(this),
            bytes32(0),
            new uint256[](0)
        );
    }
}

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

pragma solidity ^0.8.0;

import "./IERC165.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 ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 13 of 24 : IERC165.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 IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 14 of 24 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    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) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 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 256, 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 << 3) < value ? 1 : 0);
        }
    }
}

File 15 of 24 : SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

File 16 of 24 : ShortStrings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/ShortStrings.sol)

pragma solidity ^0.8.8;

import "./StorageSlot.sol";

// | string  | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA   |
// | length  | 0x                                                              BB |
type ShortString is bytes32;

/**
 * @dev This library provides functions to convert short memory strings
 * into a `ShortString` type that can be used as an immutable variable.
 *
 * Strings of arbitrary length can be optimized using this library if
 * they are short enough (up to 31 bytes) by packing them with their
 * length (1 byte) in a single EVM word (32 bytes). Additionally, a
 * fallback mechanism can be used for every other case.
 *
 * Usage example:
 *
 * ```solidity
 * contract Named {
 *     using ShortStrings for *;
 *
 *     ShortString private immutable _name;
 *     string private _nameFallback;
 *
 *     constructor(string memory contractName) {
 *         _name = contractName.toShortStringWithFallback(_nameFallback);
 *     }
 *
 *     function name() external view returns (string memory) {
 *         return _name.toStringWithFallback(_nameFallback);
 *     }
 * }
 * ```
 */
library ShortStrings {
    // Used as an identifier for strings longer than 31 bytes.
    bytes32 private constant _FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;

    error StringTooLong(string str);
    error InvalidShortString();

    /**
     * @dev Encode a string of at most 31 chars into a `ShortString`.
     *
     * This will trigger a `StringTooLong` error is the input string is too long.
     */
    function toShortString(string memory str) internal pure returns (ShortString) {
        bytes memory bstr = bytes(str);
        if (bstr.length > 31) {
            revert StringTooLong(str);
        }
        return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));
    }

    /**
     * @dev Decode a `ShortString` back to a "normal" string.
     */
    function toString(ShortString sstr) internal pure returns (string memory) {
        uint256 len = byteLength(sstr);
        // using `new string(len)` would work locally but is not memory safe.
        string memory str = new string(32);
        /// @solidity memory-safe-assembly
        assembly {
            mstore(str, len)
            mstore(add(str, 0x20), sstr)
        }
        return str;
    }

    /**
     * @dev Return the length of a `ShortString`.
     */
    function byteLength(ShortString sstr) internal pure returns (uint256) {
        uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;
        if (result > 31) {
            revert InvalidShortString();
        }
        return result;
    }

    /**
     * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.
     */
    function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {
        if (bytes(value).length < 32) {
            return toShortString(value);
        } else {
            StorageSlot.getStringSlot(store).value = value;
            return ShortString.wrap(_FALLBACK_SENTINEL);
        }
    }

    /**
     * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
     */
    function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {
        if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {
            return toString(value);
        } else {
            return store;
        }
    }

    /**
     * @dev Return the length of a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
     *
     * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
     * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
     */
    function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {
        if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {
            return byteLength(value);
        } else {
            return bytes(store).length;
        }
    }
}

File 17 of 24 : StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

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:
 * ```solidity
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
 * _Available since v4.9 for `string`, `bytes`._
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}

File 18 of 24 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    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 = Math.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 `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.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);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

File 19 of 24 : AdminPrivileges.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Enjinstarter
pragma solidity 0.8.19;

import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {IAdminPrivileges} from "./interfaces/IAdminPrivileges.sol";

/**
 * @title AdminPrivileges
 * @author Tim Loh
 * @notice Provides admin privileges role definitions that are inherited by other contracts
 */
contract AdminPrivileges is AccessControl, IAdminPrivileges {
    bytes32 public constant BACKOFFICE_ROLE_ADMIN_ROLE = keccak256("BACKOFFICE_ROLE_ADMIN_ROLE");
    bytes32 public constant BACKOFFICE_GOVERNANCE_ROLE = keccak256("BACKOFFICE_GOVERNANCE_ROLE");
    bytes32 public constant BACKOFFICE_CONTRACT_ADMIN_ROLE = keccak256("BACKOFFICE_CONTRACT_ADMIN_ROLE");

    bytes32 public constant TENANT_ROLE_ADMIN_ROLE = keccak256("TENANT_ROLE_ADMIN_ROLE");
    bytes32 public constant TENANT_GOVERNANCE_ROLE = keccak256("TENANT_GOVERNANCE_ROLE");
    bytes32 public constant TENANT_CONTRACT_ADMIN_ROLE = keccak256("TENANT_CONTRACT_ADMIN_ROLE");
}

File 20 of 24 : IAdminPrivileges.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Enjinstarter
pragma solidity 0.8.19;

/**
 * @title AdminPrivileges Interface
 * @author Tim Loh
 * @notice Interface for admin privileges role definitions that are inherited by other contracts
 */
interface IAdminPrivileges {
    // solhint-disable func-name-mixedcase

    // https://github.com/crytic/slither/wiki/Detector-Documentation#conformance-to-solidity-naming-conventions
    // slither-disable-next-line naming-convention
    function BACKOFFICE_ROLE_ADMIN_ROLE() external view returns (bytes32);

    // https://github.com/crytic/slither/wiki/Detector-Documentation#conformance-to-solidity-naming-conventions
    // slither-disable-next-line naming-convention
    function BACKOFFICE_GOVERNANCE_ROLE() external view returns (bytes32);

    // https://github.com/crytic/slither/wiki/Detector-Documentation#conformance-to-solidity-naming-conventions
    // slither-disable-next-line naming-convention
    function BACKOFFICE_CONTRACT_ADMIN_ROLE() external view returns (bytes32);

    // https://github.com/crytic/slither/wiki/Detector-Documentation#conformance-to-solidity-naming-conventions
    // slither-disable-next-line naming-convention
    function TENANT_ROLE_ADMIN_ROLE() external view returns (bytes32);

    // https://github.com/crytic/slither/wiki/Detector-Documentation#conformance-to-solidity-naming-conventions
    // slither-disable-next-line naming-convention
    function TENANT_GOVERNANCE_ROLE() external view returns (bytes32);

    // https://github.com/crytic/slither/wiki/Detector-Documentation#conformance-to-solidity-naming-conventions
    // slither-disable-next-line naming-convention
    function TENANT_CONTRACT_ADMIN_ROLE() external view returns (bytes32);

    // solhint-enable func-name-mixedcase
}

File 21 of 24 : IAdminWallet.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Enjinstarter
pragma solidity 0.8.19;

/**
 * @title AdminWallet Interface
 * @author Tim Loh
 * @notice Interface for admin wallet that will receive the funds
 */
interface IAdminWallet {
    /**
     * @notice Emitted when admin wallet has been changed from `oldWallet` to `newWallet`
     * @param oldWallet The wallet before the wallet was changed
     * @param newWallet The wallet after the wallet was changed
     * @param sender The address that changes the admin wallet
     */
    event AdminWalletChanged(address indexed oldWallet, address indexed newWallet, address indexed sender);

    /**
     * @notice Returns the admin wallet address that will receive the funds
     * @return Admin wallet address
     */
    function adminWallet() external view returns (address);
}

File 22 of 24 : IFactoryImplementation.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Enjinstarter
pragma solidity 0.8.19;

/**
 * @title IFactoryImplementation
 * @author Tim Loh
 * @notice Provides factory implementation type that is inherited by reference implementation contracts for matching
 *         with corresponding factory contracts
 */
interface IFactoryImplementation {
    function factoryImplementationType() external view returns (uint256);
}

File 23 of 24 : ISubscriptionService.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Enjinstarter
pragma solidity 0.8.19;

import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {IAdminPrivileges} from "./IAdminPrivileges.sol";
import {IAdminWallet} from "./IAdminWallet.sol";

/**
 * @title ISubscriptionService
 * @author Tim Loh
 */
interface ISubscriptionService is IAccessControl, IAdminPrivileges, IAdminWallet {
    /**
     * @notice Emitted when subscription package available for purchase has been setup
     * @param subscriptionId The subscription identifier
     * @param sender The address with backoffice contract admin role that setup the subscription package for purchase
     * @param paymentTokenAddress The address of the token that will be used for payment
     * @param paymentTokenDecimals The number of decimals for the payment token
     * @param priceInPaymentTokenWei The amount in wei of payment tokens to pay for subscription package
     * @param expiryDays The number of days after purchase when subscription package expires
     * @param numberOfContracts The additional number of contracts that can be deployed after purchase
     */
    event AvailableSubscriptionPackageSet(
        bytes32 indexed subscriptionId,
        address indexed sender,
        address indexed paymentTokenAddress,
        uint256 paymentTokenDecimals,
        uint256 priceInPaymentTokenWei,
        uint256 expiryDays,
        uint256 numberOfContracts
    );

    /**
     * @notice Emitted when `purchaserAddress` is added as purchaser of specified subscription
     * @param subscriptionId The subscription identifier
     * @param purchaserAddress The address to be added as purchaser of specified subscription
     * @param sender The address with backoffice contract admin role that added the address as purchaser
     */
    event PurchaserAddressAdded(
        bytes32 indexed subscriptionId,
        address indexed purchaserAddress,
        address indexed sender
    );

    /**
     * @notice Emitted when `purchaserAddress` is removed as purchaser of specified subscription.
     * @param subscriptionId The subscription identifier
     * @param purchaserAddress The address to be removed as purchaser of specified subscription
     * @param sender The address with backoffice contract admin role that removed the address as purchaser
     */
    event PurchaserAddressRemoved(
        bytes32 indexed subscriptionId,
        address indexed purchaserAddress,
        address indexed sender
    );

    /**
     * @notice Emitted when purchased subscription package has been consumed by `account` to deploy a contract
     * @param subscriptionId The subscription identifier
     * @param sender The address with contract usage role that initiated the subscription package consumption by
     *               `account`
     * @param account The address that consumed the subscription package to deploy a contract
     * @param numberOfContractsDeployed The number of contracts deployed after consuming subscription package
     * @param numberOfDeployableContracts The number of deployable contracts after consuming subscription package
     * @param expiryTimestamp The timestamp when purchased subscription package expires
     */
    event SubscriptionPackageConsumed(
        bytes32 indexed subscriptionId,
        address indexed sender,
        address indexed account,
        uint256 numberOfContractsDeployed,
        uint256 numberOfDeployableContracts,
        uint256 expiryTimestamp
    );

    /**
     * @notice Emitted when available subscription package has been purchased by `account`
     * @param subscriptionId The subscription identifier
     * @param sender The address that purchased the available subscription package
     * @param paymentTokenAddress The address of the token that is used for payment
     * @param paymentTokenDecimals The number of decimals for the payment token
     * @param priceInPaymentTokenWei The amount in wei of payment tokens paid for subscription package
     * @param availablePackageNumberOfContracts The additional number of contracts that can be deployed after purchase
     * @param availablePackageExpiryDays The number of days after purchase when subscription package expires
     * @param numberOfDeployableContracts The number of deployable contracts after purchase
     * @param purchaseExpiryTimestamp The timestamp when purchased subscription package expires
     * @param adminWallet The address receiving the payment tokens paid
     */
    event SubscriptionPackagePurchased(
        bytes32 indexed subscriptionId,
        address indexed sender,
        address indexed paymentTokenAddress,
        uint256 paymentTokenDecimals,
        uint256 priceInPaymentTokenWei,
        uint256 availablePackageNumberOfContracts,
        uint256 availablePackageExpiryDays,
        uint256 numberOfDeployableContracts,
        uint256 purchaseExpiryTimestamp,
        address adminWallet
    );

    /**
     * @notice Add `purchaserAddress` as purchaser of subscription package so that can purchase or consume subscription
     * @dev Must be called by backoffice contract admin role
     * @param subscriptionId The subscription identifier
     * @param purchaserAddress The address to be added as purchaser of specified subscription
     */
    function addPurchaserAddress(bytes32 subscriptionId, address purchaserAddress) external;

    /**
     * @notice Consume subscription package to deploy a contract
     * @dev Must be called by contract usage role
     * @dev Can only be consumed if `account` is purchaser of subscription package
     * @param subscriptionId The subscription identifier
     * @param account The address that will consume the subscription package to deploy a contract
     * @return isConsumed `true` if subscription package has been consumed successfully
     */
    function consumeSubscriptionPackage(bytes32 subscriptionId, address account) external returns (bool isConsumed);

    /**
     * @notice Purchase subscription package by sender using ERC20 token for payment
     * @dev Can only be purchased if sender is purchaser of subscription package
     * @param subscriptionId The subscription identifier
     */
    function erc20PurchaseSubscriptionPackage(bytes32 subscriptionId) external;

    /**
     * @notice Purchase subscription package by sender using native token for payment
     * @dev Can only be purchased if sender is purchaser of subscription package
     * @param subscriptionId The subscription identifier
     */
    function nativePurchaseSubscriptionPackage(bytes32 subscriptionId) external payable;

    /**
     * @notice Pause user functions
     * @dev Must be called by backoffice contract admin role
     */
    function pauseContract() external;

    /**
     * @notice Remove `purchaserAddress` as purchaser of subscription package
     * @dev Must be called by backoffice contract admin role
     * @param subscriptionId The subscription identifier
     * @param purchaserAddress The address to be removed as purchaser of specified subscription
     */
    function removePurchaserAddress(bytes32 subscriptionId, address purchaserAddress) external;

    /**
     * @notice Change admin wallet that will receive funds to a new wallet address
     * @dev Must be called by backoffice governance role
     * @param newWallet The new admin wallet
     */
    function setAdminWallet(address newWallet) external;

    /**
     * @notice Setup subscription package that will be available for purchase
     * @dev Must be called by backoffice contract admin role
     * @dev Will auto purchase for zero cost subscription package
     * @param subscriptionId The subscription identifier
     * @param expiryDays The number of days after purchase when subscription package expires
     * @param numberOfContracts The additional number of contracts that can be deployed after purchase
     * @param paymentTokenAddress The address of the token that will be used for payment
     * @param paymentTokenDecimals The number of decimals for the payment token
     * @param priceInPaymentTokenWei The amount in wei of payment tokens to pay for subscription package
     */
    function setAvailableSubscriptionPackage(
        bytes32 subscriptionId,
        uint256 expiryDays,
        uint256 numberOfContracts,
        address paymentTokenAddress,
        uint256 paymentTokenDecimals,
        uint256 priceInPaymentTokenWei
    ) external;

    /**
     * @notice Unpause user functions
     * @dev Must be called by backoffice contract admin role
     */
    function unpauseContract() external;

    /**
     * @notice Get info of subscription package available for purchase
     * @param subscriptionId The subscription identifier
     * @return expiryDays The number of days after purchase when subscription package expires
     * @return numberOfContracts The additional number of contracts that can be deployed after purchase
     * @return paymentTokenAddress The address of the token that will be used for payment
     * @return paymentTokenDecimals The number of decimals for the payment token
     * @return priceInPaymentTokenWei The amount in wei of payment tokens to pay for subscription package
     * @return isInitialized `true` if package is available for purchase
     */
    function getAvailableSubscriptionPackageFor(
        bytes32 subscriptionId
    )
        external
        view
        returns (
            uint256 expiryDays,
            uint256 numberOfContracts,
            address paymentTokenAddress,
            uint256 paymentTokenDecimals,
            uint256 priceInPaymentTokenWei,
            bool isInitialized
        );

    /**
     * @notice Get info of purchased subscription package
     * @param subscriptionId The subscription identifier
     * @return expiryTimestamp The timestamp when purchased subscription package expires
     * @return numberOfContractsDeployed The number of contracts that have been deployed
     * @return numberOfDeployableContracts The number of contracts that can be deployed
     */
    function getPurchasedSubscriptionPackageFor(
        bytes32 subscriptionId
    )
        external
        view
        returns (uint256 expiryTimestamp, uint256 numberOfContractsDeployed, uint256 numberOfDeployableContracts);

    /**
     * @notice Checks whether `purchaserAddress` is allowed to purchase specified subscription package
     * @param subscriptionId The subscription identifier
     * @param purchaserAddress The address to check
     * @return Returns `true` if `purchaserAddress` is allowed to purchase specified subscription package
     */
    function isAllowedToPurchase(bytes32 subscriptionId, address purchaserAddress) external view returns (bool);

    /**
     * @notice Checks whether this contract implements the interface defined by `interfaceId`
     * @dev ERC165
     * @return `true` if this contract implements the interface defined by `interfaceId`
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);

    // solhint-disable func-name-mixedcase

    /**
     * @notice Get contract usage role definition
     * @return Returns contract usage role definition
     */
    // https://github.com/crytic/slither/wiki/Detector-Documentation#conformance-to-solidity-naming-conventions
    // slither-disable-next-line naming-convention
    function CONTRACT_USAGE_ROLE() external view returns (bytes32);

    /**
     * @notice Get interface ID for ISubscriptionService interface
     * @return Returns interface ID for ISubscriptionService interface
     */
    // https://github.com/crytic/slither/wiki/Detector-Documentation#conformance-to-solidity-naming-conventions
    // slither-disable-next-line naming-convention
    function INTERFACE_ID() external view returns (bytes4);

    // solhint-enable func-name-mixedcase
}

File 24 of 24 : IVestingCustomFactory.sol
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023 Enjinstarter
pragma solidity 0.8.19;

import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {IAdminPrivileges} from "./IAdminPrivileges.sol";
import {IFactoryImplementation} from "./IFactoryImplementation.sol";

/**
 * @title IVestingCustomFactory
 * @author Tim Loh
 * @notice Custom vesting factory interface for deploying custom vesting contracts based on implementation
 */
interface IVestingCustomFactory is IAccessControl, IAdminPrivileges {
    /**
     * @notice Emitted when backoffice admin address has been changed from `oldBackofficeAdminAddress` to
     *         `newBackofficeAdminAddress`
     * @param oldBackofficeAdminAddress The backoffice admin address before the change
     * @param newBackofficeAdminAddress The backoffice admin address after the change
     * @param sender The address that changes the backoffice admin address
     */
    event BackofficeAdminAddressChanged(
        address indexed oldBackofficeAdminAddress,
        address indexed newBackofficeAdminAddress,
        address indexed sender
    );

    /**
     * @notice Emitted when contract has been successfully deployed
     * @param deployedContract The address of the deployed contract
     * @param deployId The deployment identifier
     * @param subscriptionId The subscription identifier
     * @param deployName The deployment name
     * @param tokenAddress The vesting token address
     * @param tokenDecimals The number of decimals for vesting token
     * @param allowAccumulate `true` if multiple grant amounts is allowed to accumulate for the same user,
     *                        `false` if a user can only have one grant
     * @param backofficeAddress The backoffice admin address that is set for deploy contract
     * @param tenantAdminAddress The tenant admin address that is set for deploy contract
     * @param signer The signer address corresponding to the given signature
     * @param implementation The reference contract implementation address
     */
    event ContractDeployed(
        address indexed deployedContract,
        bytes32 indexed deployId,
        bytes32 indexed subscriptionId,
        string deployName,
        address tokenAddress,
        uint256 tokenDecimals,
        bool allowAccumulate,
        address backofficeAddress,
        address tenantAdminAddress,
        address signer,
        address implementation
    );

    /**
     * @notice Emitted when implementation address has been changed from `oldImplementation` to `newImplementation`
     * @param oldImplementation The implementation address before the change
     * @param newImplementation The implementation address after the change
     * @param sender The address that changes the implementation address
     */
    event ImplementationAddressChanged(
        address indexed oldImplementation,
        address indexed newImplementation,
        address indexed sender
    );

    /**
     * @notice Emitted when subscription service contract address has been changed from `oldAddress` to `newAddress`
     * @param oldAddress The subscription service contract address before the change
     * @param newAddress The subscription service contract address after the change
     * @param sender The address that changes the subscription service contract address
     */
    event SubscriptionServiceChanged(address indexed oldAddress, address indexed newAddress, address indexed sender);

    /**
     * @notice Deploy contract based on given typed signature
     * @param deployId The deploy identifier
     * @param subscriptionId The subscription identifier
     * @param name The deployment name
     * @param tokenAddress The vesting token address
     * @param tokenDecimals The number of decimals for vesting token
     * @param allowAccumulate `true` if multiple grant amounts is allowed to accumulate for the same user,
     *                        `false` if a user can only have one grant
     * @param signature The typed signature must be from an authorized signer before contract is deployed
     */
    function deployWithTypedSignature(
        bytes32 deployId,
        bytes32 subscriptionId,
        string memory name,
        address tokenAddress,
        uint256 tokenDecimals,
        bool allowAccumulate,
        bytes memory signature
    ) external;

    /**
     * @notice Pause user functions (deploy)
     * @dev Must be called by backoffice contract admin role
     */
    function pauseContract() external;

    /**
     * @notice Change backoffice admin address that will be set for deploy contract to a new address
     * @dev Must be called by backoffice contract admin role
     * @param newBackofficeAdminAddress The new backoffice admin address
     */
    function setBackofficeAdminAddress(address newBackofficeAdminAddress) external;

    /**
     * @notice Change implementation to a new address
     * @dev Must be called by backoffice governance role
     * @param newImplementation The new implementation address
     */
    function setImplementationAddress(address newImplementation) external;

    /**
     * @notice Change subscription service contract address
     * @dev Must be called by backoffice governance role
     * @param newAddress The new contract address
     */
    function setSubscriptionService(address newAddress) external;

    /**
     * @notice Unpause user functions (deploy)
     * @dev Must be called by backoffice contract admin role
     */
    function unpauseContract() external;

    /**
     * @notice Get backoffice admin address that will be set for deploy contract
     * @return Returns backoffice admin address
     */
    function backofficeAdminAddress() external view returns (address);

    /**
     * @notice Returns deployment info for given deploy identifier
     * @param deployId The deploy identifier
     * @return implementation The reference contract implementation address
     * @return deployedContract The deployed contract address
     */
    function deployInfoFor(bytes32 deployId) external view returns (address implementation, address deployedContract);

    /**
     * @notice Get factory name
     * @return Returns factory name
     */
    function factoryName() external view returns (string memory);

    /**
     * @notice Get factory version
     * @return Returns factory version
     */
    function factoryVersion() external view returns (string memory);

    /**
     * @notice Get reference implementation contract address
     * @return Returns reference implementation contract address
     */
    function implementationAddress() external view returns (address);

    /**
     * @notice Returns signer of given typed signature
     * @param implementation The reference contract implementation address
     * @param deployId The deploy identifier
     * @param name The deployment name
     * @param tokenAddress The vesting token address
     * @param tokenDecimals The number of decimals for vesting token
     * @param allowAccumulate `true` if multiple grant amounts is allowed to accumulate for the same user,
     *                        `false` if a user can only have one grant
     * @param tenantAdminAddress The tenant admin address that will be set for deploy contract
     * @param signature The typed signature is verified to be from an authorized signer before contract is deployed
     * @return recovered The signer address
     */
    function recoverTypedSignature(
        address implementation,
        bytes32 deployId,
        string memory name,
        address tokenAddress,
        uint256 tokenDecimals,
        bool allowAccumulate,
        address tenantAdminAddress,
        bytes memory signature
    ) external view returns (address recovered);

    /**
     * @notice Get subscription serbice contract address
     * @return Returns subscription service contract address
     */
    function subscriptionService() external view returns (address);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"implementationType","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldBackofficeAdminAddress","type":"address"},{"indexed":true,"internalType":"address","name":"newBackofficeAdminAddress","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"BackofficeAdminAddressChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"deployedContract","type":"address"},{"indexed":true,"internalType":"bytes32","name":"deployId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"subscriptionId","type":"bytes32"},{"indexed":false,"internalType":"string","name":"deployName","type":"string"},{"indexed":false,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenDecimals","type":"uint256"},{"indexed":false,"internalType":"bool","name":"allowAccumulate","type":"bool"},{"indexed":false,"internalType":"address","name":"backofficeAddress","type":"address"},{"indexed":false,"internalType":"address","name":"tenantAdminAddress","type":"address"},{"indexed":false,"internalType":"address","name":"signer","type":"address"},{"indexed":false,"internalType":"address","name":"implementation","type":"address"}],"name":"ContractDeployed","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldImplementation","type":"address"},{"indexed":true,"internalType":"address","name":"newImplementation","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"ImplementationAddressChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldAddress","type":"address"},{"indexed":true,"internalType":"address","name":"newAddress","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"SubscriptionServiceChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"BACKOFFICE_CONTRACT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BACKOFFICE_GOVERNANCE_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BACKOFFICE_ROLE_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SIGNATURE_LENGTH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TENANT_CONTRACT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TENANT_GOVERNANCE_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TENANT_ROLE_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKEN_DECIMALS_MAX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"backofficeAdminAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"deployId","type":"bytes32"}],"name":"deployInfoFor","outputs":[{"internalType":"address","name":"implementation","type":"address"},{"internalType":"address","name":"deployedContract","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"deployId","type":"bytes32"},{"internalType":"bytes32","name":"subscriptionId","type":"bytes32"},{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenDecimals","type":"uint256"},{"internalType":"bool","name":"allowAccumulate","type":"bool"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"deployWithTypedSignature","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factoryImplementationType","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factoryName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factoryVersion","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"implementationAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pauseContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"},{"internalType":"bytes32","name":"deployId","type":"bytes32"},{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenDecimals","type":"uint256"},{"internalType":"bool","name":"allowAccumulate","type":"bool"},{"internalType":"address","name":"tenantAdminAddress","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"recoverTypedSignature","outputs":[{"internalType":"address","name":"recovered","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newBackofficeAdminAddress","type":"address"}],"name":"setBackofficeAdminAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"setImplementationAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAddress","type":"address"}],"name":"setSubscriptionService","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"subscriptionService","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpauseContract","outputs":[],"stateMutability":"nonpayable","type":"function"}]

6101806040523480156200001257600080fd5b5060405162002c6938038062002c69833981016040819052620000359162000424565b828262000044826001620001e6565b6101205262000055816002620001e6565b61014052815160208084019190912060e052815190820120610100524660a052620000e360e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c0526003805460ff1916905560016004556200011660008051602062002c49833981519152806200021f565b6200014060008051602062002c2983398151915260008051602062002c498339815191526200021f565b6200016a60008051602062002c0983398151915260008051602062002c498339815191526200021f565b6200018560008051602062002c49833981519152336200026a565b620001a060008051602062002c29833981519152336200026a565b620001bb60008051602062002c09833981519152336200026a565b6006620001c9848262000526565b506007620001d8838262000526565b5061016052506200064c9050565b60006020835110156200020657620001fe836200030b565b905062000219565b8162000213848262000526565b5060ff90505b92915050565b600082815260208190526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1662000307576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620002c63390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b600080829050601f8151111562000342578260405163305a27a960e01b8152600401620003399190620005f2565b60405180910390fd5b80516200034f8262000627565b179392505050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156200038a57818101518382015260200162000370565b50506000910152565b600082601f830112620003a557600080fd5b81516001600160401b0380821115620003c257620003c262000357565b604051601f8301601f19908116603f01168101908282118183101715620003ed57620003ed62000357565b816040528381528660208588010111156200040757600080fd5b6200041a8460208301602089016200036d565b9695505050505050565b6000806000606084860312156200043a57600080fd5b83516001600160401b03808211156200045257600080fd5b620004608783880162000393565b945060208601519150808211156200047757600080fd5b50620004868682870162000393565b925050604084015190509250925092565b600181811c90821680620004ac57607f821691505b602082108103620004cd57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200052157600081815260208120601f850160051c81016020861015620004fc5750805b601f850160051c820191505b818110156200051d5782815560010162000508565b5050505b505050565b81516001600160401b0381111562000542576200054262000357565b6200055a8162000553845462000497565b84620004d3565b602080601f831160018114620005925760008415620005795750858301515b600019600386901b1c1916600185901b1785556200051d565b600085815260208120601f198616915b82811015620005c357888601518255948401946001909101908401620005a2565b5085821015620005e25787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6020815260008251806020840152620006138160408501602087016200036d565b601f01601f19169190910160400192915050565b80516020808301519190811015620004cd5760001960209190910360031b1b16919050565b60805160a05160c05160e05161010051610120516101405161016051612550620006b9600039600081816104bc0152610bbc0152600061099b0152600061097001526000611c1701526000611bef01526000611b4a01526000611b7401526000611b9e01526125506000f3fe608060405234801561001057600080fd5b50600436106101e55760003560e01c806384b0196e1161010f578063b97a2319116100a2578063d547741f11610071578063d547741f1461046a578063eba94ba01461047d578063ecade2f0146104a4578063fb872e19146104b757600080fd5b8063b97a231914610415578063bedecd4a14610428578063d1a8e5a91461044f578063d41304861461046257600080fd5b8063a217fddf116100de578063a217fddf146103c7578063b33712c5146103cf578063b3e72640146103d7578063b3f74cac1461040257600080fd5b806384b0196e1461037c57806391d148541461039757806398a389b4146103aa578063991224fc146103bf57600080fd5b80634260b374116101875780634ef7086b116101565780634ef7086b1461032f578063540bc5ea146103565780635c975abb1461035e57806382c509611461036957600080fd5b80634260b374146102d8578063439766ce146102eb578063462ebf44146102f35780634ef4e3871461031a57600080fd5b8063248a9ca3116101c3578063248a9ca31461025a57806326a1f5cc1461028b5780632f2ff15d146102b257806336568abe146102c557600080fd5b806301ffc9a7146101ea578063064bb7bf146102125780630d8ccb5514610227575b600080fd5b6101fd6101f8366004611f63565b6104de565b60405190151581526020015b60405180910390f35b610225610220366004611fa9565b610515565b005b61023a610235366004611fc4565b6105d4565b604080516001600160a01b03938416815292909116602083015201610209565b61027d610268366004611fc4565b60009081526020819052604090206001015490565b604051908152602001610209565b61027d7f85485e0579110e3a8651ecc622c4a4de1af035fb88034e30905cf67a60881bfd81565b6102256102c0366004611fdd565b61065c565b6102256102d3366004611fdd565b610686565b6102256102e6366004611fa9565b610704565b61022561087a565b61027d7f96569a1fadb2d4dcc763ecf02934e5ddc4e41d9d5f44b6b99af57748b38b505881565b61032261089d565b6040516102099190612059565b61027d7fb58f543c34fc3c79e1c358174f46808f77878cdc5ca730c4617cdbe574382eb681565b61027d604181565b60035460ff166101fd565b61022561037736600461211d565b61092b565b610384610962565b60405161020997969594939291906121c3565b6101fd6103a5366004611fdd565b6109eb565b61027d6000805160206124fb83398151915281565b61027d601281565b61027d600081565b610225610a14565b6103ea6103e5366004612259565b610a34565b6040516001600160a01b039091168152602001610209565b6009546103ea906001600160a01b031681565b6008546103ea906001600160a01b031681565b61027d7f52bbfa6e876ba7eadc80dc9b099c193c6daea0056635c463ce4d9723fa6d773381565b6005546103ea906001600160a01b031681565b610322610a53565b610225610478366004611fdd565b610a60565b61027d7f07258f049a6ded7f9eee4348cd5f072dca4852fa78e9604f2468ddeaa723e58881565b6102256104b2366004611fa9565b610a85565b61027d7f000000000000000000000000000000000000000000000000000000000000000081565b60006001600160e01b03198216637965db0b60e01b148061050f57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6000805160206124fb83398151915261052d81610c29565b6001600160a01b0382166105805760405162461bcd60e51b81526020600482015260156024820152742b21a31d103130b1b5b7b33334b1b29030b236b4b760591b60448201526064015b60405180910390fd5b600580546001600160a01b038481166001600160a01b031983168117909355604051911691339183907fe5cd7744b867d8c0cfc343b7881600bcc07fecd5bb276b7bad38d1d0467f877590600090a4505050565b6000818152600a60205260408120600101548190600160a01b900460ff166106335760405162461bcd60e51b81526020600482015260126024820152711590d18e881d5b9a5b9a5d1a585b1a5e995960721b6044820152606401610577565b50506000908152600a6020526040902080546001909101546001600160a01b0391821692911690565b60008281526020819052604090206001015461067781610c29565b6106818383610c33565b505050565b6001600160a01b03811633146106f65760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610577565b6107008282610cb7565b5050565b7f85485e0579110e3a8651ecc622c4a4de1af035fb88034e30905cf67a60881bfd61072e81610c29565b6001600160a01b0382166107735760405162461bcd60e51b815260206004820152600c60248201526b5643463a206164647265737360a01b6044820152606401610577565b600980546001600160a01b038481166001600160a01b031983168117909355604051911691339183907fd7cfb586eaba8edcbde8e3ed1b089d7cc4d345e3a0142b5df0116b6b13d10e3790600090a46040516301ffc9a760e01b8152637924698960e11b60048201526000906001600160a01b038516906301ffc9a790602401602060405180830381865afa158015610810573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108349190612318565b9050806108745760405162461bcd60e51b815260206004820152600e60248201526d5643463a20696e7465726661636560901b6044820152606401610577565b50505050565b6000805160206124fb83398151915261089281610c29565b61089a610d1c565b50565b600680546108aa90612335565b80601f01602080910402602001604051908101604052809291908181526020018280546108d690612335565b80156109235780601f106108f857610100808354040283529160200191610923565b820191906000526020600020905b81548152906001019060200180831161090657829003601f168201915b505050505081565b610933610d76565b610959878787878787600560009054906101000a90046001600160a01b03163389610dbe565b50505050505050565b6000606080828080836109967f0000000000000000000000000000000000000000000000000000000000000000600161117e565b6109c17f0000000000000000000000000000000000000000000000000000000000000000600261117e565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6000805160206124fb833981519152610a2c81610c29565b61089a611229565b6000610a468989898989898989611262565b9998505050505050505050565b600780546108aa90612335565b600082815260208190526040902060010154610a7b81610c29565b6106818383610cb7565b7f85485e0579110e3a8651ecc622c4a4de1af035fb88034e30905cf67a60881bfd610aaf81610c29565b6001600160a01b038216610b055760405162461bcd60e51b815260206004820152601760248201527f5643463a206e657720696d706c656d656e746174696f6e0000000000000000006044820152606401610577565b600880546001600160a01b038481166001600160a01b031983168117909355604051911691339183907f5deda12a73eb2acd7628ea75f435c8cd1d523724c7c0a3cfdfd0174b62924f6090600090a46000836001600160a01b031663fb872e196040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb8919061236f565b90507f000000000000000000000000000000000000000000000000000000000000000081146108745760405162461bcd60e51b815260206004820152601860248201527f5643463a20696d706c656d656e746174696f6e207479706500000000000000006044820152606401610577565b61089a813361150c565b610c3d82826109eb565b610700576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610c733390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610cc182826109eb565b15610700576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b610d24610d76565b6003805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610d593390565b6040516001600160a01b03909116815260200160405180910390a1565b60035460ff1615610dbc5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610577565b565b610dc6611565565b6000898152600a6020526040902060010154600160a01b900460ff1615610e1d5760405162461bcd60e51b815260206004820152600b60248201526a5643463a2065786973747360a81b6044820152606401610577565b6001600160a01b038316610e735760405162461bcd60e51b815260206004820152601760248201527f5643463a206261636b6f666669636520616464726573730000000000000000006044820152606401610577565b600854600090610e92906001600160a01b03168b8a8a8a8a8989611262565b9050336001600160a01b03821614610eda5760405162461bcd60e51b815260206004820152600b60248201526a2b21a31d1039b2b73232b960a91b6044820152606401610577565b6000610ee58b6115be565b8051602082012060085491925090600090610f09906001600160a01b031683611603565b90506001600160a01b038116610f595760405162461bcd60e51b81526020600482015260156024820152745643463a206465706c6f796564206164647265737360581b6044820152606401610577565b6040518060600160405280600860009054906101000a90046001600160a01b03166001600160a01b03168152602001826001600160a01b0316815260200160011515815250600a60008f815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160010160146101000a81548160ff02191690831515021790555090505060006110a38b8b8b8b8b6040516001600160a01b0380871660248301526044820186905284151560648301528084166084830152821660a482015260609060c40160408051601f198184030181529190526020810180516001600160e01b031663ea93e51d60e01b1790529695505050505050565b90508c8e836001600160a01b03167fd01a59e827ae2d668eaac037956beabfe7eee6f0209a535ba915beab74a738da8f8f8f8f8f8f8e600860009054906101000a90046001600160a01b0316604051611103989796959493929190612388565b60405180910390a46111158d866116a0565b6111505760405162461bcd60e51b815260206004820152600c60248201526b5643463a20636f6e73756d6560a01b6044820152606401610577565b6111636001600160a01b0383168261176d565b5050505050506111736001600455565b505050505050505050565b606060ff831461119857611191836117b1565b905061050f565b8180546111a490612335565b80601f01602080910402602001604051908101604052809291908181526020018280546111d090612335565b801561121d5780601f106111f25761010080835404028352916020019161121d565b820191906000526020600020905b81548152906001019060200180831161120057829003601f168201915b5050505050905061050f565b6112316117f0565b6003805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33610d59565b60006001600160a01b0389166112b05760405162461bcd60e51b81526020600482015260136024820152722b21a31d1034b6b83632b6b2b73a30ba34b7b760691b6044820152606401610577565b60008751116112ed5760405162461bcd60e51b81526020600482015260096024820152685643463a206e616d6560b81b6044820152606401610577565b6001600160a01b0386166113385760405162461bcd60e51b81526020600482015260126024820152715643463a20746f6b656e206164647265737360701b6044820152606401610577565b601285111561137f5760405162461bcd60e51b81526020600482015260136024820152725643463a20746f6b656e20646563696d616c7360681b6044820152606401610577565b6001600160a01b0383166113cb5760405162461bcd60e51b81526020600482015260136024820152725643463a2074656e616e74206164647265737360681b6044820152606401610577565b604182511461140d5760405162461bcd60e51b815260206004820152600e60248201526d5643463a207369676e617475726560901b6044820152606401610577565b8651602080890191909120604080517f79879e034d8fddd08e9216b25d8de4a956b3eb8e68d10f3438444cb2447ca77e938101939093526001600160a01b03808d1691840191909152606083018b9052608083019190915280881660a083015260c0820187905285151560e083015284166101008201526000906114aa906101200160405160208183030381529060405280519060200120611839565b90506114b68184611866565b91506001600160a01b0382166114ff5760405162461bcd60e51b815260206004820152600e60248201526d1590d18e881c9958dbdd995c995960921b6044820152606401610577565b5098975050505050505050565b61151682826109eb565b610700576115238161188a565b61152e83602061189c565b60405160200161153f9291906123e6565b60408051601f198184030181529082905262461bcd60e51b825261057791600401612059565b6002600454036115b75760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610577565b6002600455565b6060816040516024016115d391815260200190565b60408051601f198184030181529190526020810180516001600160e01b0316638f9caa8960e01b17905292915050565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008360601b60e81c176000526e5af43d82803e903d91602b57fd5bf38360781b1760205281603760096000f590506001600160a01b03811661050f5760405162461bcd60e51b815260206004820152601760248201527f455243313136373a2063726561746532206661696c65640000000000000000006044820152606401610577565b6009546000906001600160a01b03166116ef5760405162461bcd60e51b81526020600482015260116024820152702b21a31d1039bab139b1b934b83a34b7b760791b6044820152606401610577565b60095460405163044bda5760e11b8152600481018590526001600160a01b03848116602483015290911690630897b4ae906044016020604051808303816000875af1158015611742573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117669190612318565b9392505050565b6060611766838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250611a38565b606060006117be83611b15565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b60035460ff16610dbc5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610577565b600061050f611846611b3d565b8360405161190160f01b8152600281019290925260228201526042902090565b60008060006118758585611c6d565b9150915061188281611cb2565b509392505050565b606061050f6001600160a01b03831660145b606060006118ab836002612471565b6118b6906002612488565b67ffffffffffffffff8111156118ce576118ce61206c565b6040519080825280601f01601f1916602001820160405280156118f8576020820181803683370190505b509050600360fc1b816000815181106119135761191361249b565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106119425761194261249b565b60200101906001600160f81b031916908160001a9053506000611966846002612471565b611971906001612488565b90505b60018111156119e9576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106119a5576119a561249b565b1a60f81b8282815181106119bb576119bb61249b565b60200101906001600160f81b031916908160001a90535060049490941c936119e2816124b1565b9050611974565b5083156117665760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610577565b606082471015611a995760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610577565b600080866001600160a01b03168587604051611ab591906124c8565b60006040518083038185875af1925050503d8060008114611af2576040519150601f19603f3d011682016040523d82523d6000602084013e611af7565b606091505b5091509150611b0887838387611dfc565b925050505b949350505050565b600060ff8216601f81111561050f57604051632cd44ac360e21b815260040160405180910390fd5b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015611b9657507f000000000000000000000000000000000000000000000000000000000000000046145b15611bc057507f000000000000000000000000000000000000000000000000000000000000000090565b611c68604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b905090565b6000808251604103611ca35760208301516040840151606085015160001a611c9787828585611e75565b94509450505050611cab565b506000905060025b9250929050565b6000816004811115611cc657611cc66124e4565b03611cce5750565b6001816004811115611ce257611ce26124e4565b03611d2f5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610577565b6002816004811115611d4357611d436124e4565b03611d905760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610577565b6003816004811115611da457611da46124e4565b0361089a5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610577565b60608315611e6b578251600003611e64576001600160a01b0385163b611e645760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610577565b5081611b0d565b611b0d8383611f39565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611eac5750600090506003611f30565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611f00573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611f2957600060019250925050611f30565b9150600090505b94509492505050565b815115611f495781518083602001fd5b8060405162461bcd60e51b81526004016105779190612059565b600060208284031215611f7557600080fd5b81356001600160e01b03198116811461176657600080fd5b80356001600160a01b0381168114611fa457600080fd5b919050565b600060208284031215611fbb57600080fd5b61176682611f8d565b600060208284031215611fd657600080fd5b5035919050565b60008060408385031215611ff057600080fd5b8235915061200060208401611f8d565b90509250929050565b60005b8381101561202457818101518382015260200161200c565b50506000910152565b60008151808452612045816020860160208601612009565b601f01601f19169290920160200192915050565b602081526000611766602083018461202d565b634e487b7160e01b600052604160045260246000fd5b600082601f83011261209357600080fd5b813567ffffffffffffffff808211156120ae576120ae61206c565b604051601f8301601f19908116603f011681019082821181831017156120d6576120d661206c565b816040528381528660208588010111156120ef57600080fd5b836020870160208301376000602085830101528094505050505092915050565b801515811461089a57600080fd5b600080600080600080600060e0888a03121561213857600080fd5b8735965060208801359550604088013567ffffffffffffffff8082111561215e57600080fd5b61216a8b838c01612082565b965061217860608b01611f8d565b955060808a0135945060a08a013591506121918261210f565b90925060c089013590808211156121a757600080fd5b506121b48a828b01612082565b91505092959891949750929550565b60ff60f81b881681526000602060e0818401526121e360e084018a61202d565b83810360408501526121f5818a61202d565b606085018990526001600160a01b038816608086015260a0850187905284810360c0860152855180825283870192509083019060005b818110156122475783518352928401929184019160010161222b565b50909c9b505050505050505050505050565b600080600080600080600080610100898b03121561227657600080fd5b61227f89611f8d565b975060208901359650604089013567ffffffffffffffff808211156122a357600080fd5b6122af8c838d01612082565b97506122bd60608c01611f8d565b965060808b0135955060a08b013591506122d68261210f565b8194506122e560c08c01611f8d565b935060e08b01359150808211156122fb57600080fd5b506123088b828c01612082565b9150509295985092959890939650565b60006020828403121561232a57600080fd5b81516117668161210f565b600181811c9082168061234957607f821691505b60208210810361236957634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561238157600080fd5b5051919050565b600061010080835261239c8184018c61202d565b6001600160a01b039a8b166020850152604084019990995250509415156060860152928616608085015290851660a0840152841660c083015290921660e090920191909152919050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161241e816017850160208801612009565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161244f816028840160208801612009565b01602801949350505050565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761050f5761050f61245b565b8082018082111561050f5761050f61245b565b634e487b7160e01b600052603260045260246000fd5b6000816124c0576124c061245b565b506000190190565b600082516124da818460208701612009565b9190910192915050565b634e487b7160e01b600052602160045260246000fdfe1cc585a35ee40bc8e30be46c66514537f1953ad0977428ef905e8e0df71a6ee7a2646970667358221220d48efd5791bd03ea4bc2911f9a1848839ae0234c7b8c05cc7723abb33d8c56e664736f6c634300081300331cc585a35ee40bc8e30be46c66514537f1953ad0977428ef905e8e0df71a6ee785485e0579110e3a8651ecc622c4a4de1af035fb88034e30905cf67a60881bfdb58f543c34fc3c79e1c358174f46808f77878cdc5ca730c4617cdbe574382eb6000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a059eb2902326a23c3fb6e66c499c661a6165df892fc643c67c712570ad48e50d3000000000000000000000000000000000000000000000000000000000000001a56455354494e475f435553544f4d5f524546554e445f55534552000000000000000000000000000000000000000000000000000000000000000000000000000676312e302e300000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101e55760003560e01c806384b0196e1161010f578063b97a2319116100a2578063d547741f11610071578063d547741f1461046a578063eba94ba01461047d578063ecade2f0146104a4578063fb872e19146104b757600080fd5b8063b97a231914610415578063bedecd4a14610428578063d1a8e5a91461044f578063d41304861461046257600080fd5b8063a217fddf116100de578063a217fddf146103c7578063b33712c5146103cf578063b3e72640146103d7578063b3f74cac1461040257600080fd5b806384b0196e1461037c57806391d148541461039757806398a389b4146103aa578063991224fc146103bf57600080fd5b80634260b374116101875780634ef7086b116101565780634ef7086b1461032f578063540bc5ea146103565780635c975abb1461035e57806382c509611461036957600080fd5b80634260b374146102d8578063439766ce146102eb578063462ebf44146102f35780634ef4e3871461031a57600080fd5b8063248a9ca3116101c3578063248a9ca31461025a57806326a1f5cc1461028b5780632f2ff15d146102b257806336568abe146102c557600080fd5b806301ffc9a7146101ea578063064bb7bf146102125780630d8ccb5514610227575b600080fd5b6101fd6101f8366004611f63565b6104de565b60405190151581526020015b60405180910390f35b610225610220366004611fa9565b610515565b005b61023a610235366004611fc4565b6105d4565b604080516001600160a01b03938416815292909116602083015201610209565b61027d610268366004611fc4565b60009081526020819052604090206001015490565b604051908152602001610209565b61027d7f85485e0579110e3a8651ecc622c4a4de1af035fb88034e30905cf67a60881bfd81565b6102256102c0366004611fdd565b61065c565b6102256102d3366004611fdd565b610686565b6102256102e6366004611fa9565b610704565b61022561087a565b61027d7f96569a1fadb2d4dcc763ecf02934e5ddc4e41d9d5f44b6b99af57748b38b505881565b61032261089d565b6040516102099190612059565b61027d7fb58f543c34fc3c79e1c358174f46808f77878cdc5ca730c4617cdbe574382eb681565b61027d604181565b60035460ff166101fd565b61022561037736600461211d565b61092b565b610384610962565b60405161020997969594939291906121c3565b6101fd6103a5366004611fdd565b6109eb565b61027d6000805160206124fb83398151915281565b61027d601281565b61027d600081565b610225610a14565b6103ea6103e5366004612259565b610a34565b6040516001600160a01b039091168152602001610209565b6009546103ea906001600160a01b031681565b6008546103ea906001600160a01b031681565b61027d7f52bbfa6e876ba7eadc80dc9b099c193c6daea0056635c463ce4d9723fa6d773381565b6005546103ea906001600160a01b031681565b610322610a53565b610225610478366004611fdd565b610a60565b61027d7f07258f049a6ded7f9eee4348cd5f072dca4852fa78e9604f2468ddeaa723e58881565b6102256104b2366004611fa9565b610a85565b61027d7f59eb2902326a23c3fb6e66c499c661a6165df892fc643c67c712570ad48e50d381565b60006001600160e01b03198216637965db0b60e01b148061050f57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6000805160206124fb83398151915261052d81610c29565b6001600160a01b0382166105805760405162461bcd60e51b81526020600482015260156024820152742b21a31d103130b1b5b7b33334b1b29030b236b4b760591b60448201526064015b60405180910390fd5b600580546001600160a01b038481166001600160a01b031983168117909355604051911691339183907fe5cd7744b867d8c0cfc343b7881600bcc07fecd5bb276b7bad38d1d0467f877590600090a4505050565b6000818152600a60205260408120600101548190600160a01b900460ff166106335760405162461bcd60e51b81526020600482015260126024820152711590d18e881d5b9a5b9a5d1a585b1a5e995960721b6044820152606401610577565b50506000908152600a6020526040902080546001909101546001600160a01b0391821692911690565b60008281526020819052604090206001015461067781610c29565b6106818383610c33565b505050565b6001600160a01b03811633146106f65760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610577565b6107008282610cb7565b5050565b7f85485e0579110e3a8651ecc622c4a4de1af035fb88034e30905cf67a60881bfd61072e81610c29565b6001600160a01b0382166107735760405162461bcd60e51b815260206004820152600c60248201526b5643463a206164647265737360a01b6044820152606401610577565b600980546001600160a01b038481166001600160a01b031983168117909355604051911691339183907fd7cfb586eaba8edcbde8e3ed1b089d7cc4d345e3a0142b5df0116b6b13d10e3790600090a46040516301ffc9a760e01b8152637924698960e11b60048201526000906001600160a01b038516906301ffc9a790602401602060405180830381865afa158015610810573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108349190612318565b9050806108745760405162461bcd60e51b815260206004820152600e60248201526d5643463a20696e7465726661636560901b6044820152606401610577565b50505050565b6000805160206124fb83398151915261089281610c29565b61089a610d1c565b50565b600680546108aa90612335565b80601f01602080910402602001604051908101604052809291908181526020018280546108d690612335565b80156109235780601f106108f857610100808354040283529160200191610923565b820191906000526020600020905b81548152906001019060200180831161090657829003601f168201915b505050505081565b610933610d76565b610959878787878787600560009054906101000a90046001600160a01b03163389610dbe565b50505050505050565b6000606080828080836109967f56455354494e475f435553544f4d5f524546554e445f5553455200000000001a600161117e565b6109c17f76312e302e300000000000000000000000000000000000000000000000000006600261117e565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6000805160206124fb833981519152610a2c81610c29565b61089a611229565b6000610a468989898989898989611262565b9998505050505050505050565b600780546108aa90612335565b600082815260208190526040902060010154610a7b81610c29565b6106818383610cb7565b7f85485e0579110e3a8651ecc622c4a4de1af035fb88034e30905cf67a60881bfd610aaf81610c29565b6001600160a01b038216610b055760405162461bcd60e51b815260206004820152601760248201527f5643463a206e657720696d706c656d656e746174696f6e0000000000000000006044820152606401610577565b600880546001600160a01b038481166001600160a01b031983168117909355604051911691339183907f5deda12a73eb2acd7628ea75f435c8cd1d523724c7c0a3cfdfd0174b62924f6090600090a46000836001600160a01b031663fb872e196040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb8919061236f565b90507f59eb2902326a23c3fb6e66c499c661a6165df892fc643c67c712570ad48e50d381146108745760405162461bcd60e51b815260206004820152601860248201527f5643463a20696d706c656d656e746174696f6e207479706500000000000000006044820152606401610577565b61089a813361150c565b610c3d82826109eb565b610700576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610c733390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610cc182826109eb565b15610700576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b610d24610d76565b6003805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610d593390565b6040516001600160a01b03909116815260200160405180910390a1565b60035460ff1615610dbc5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610577565b565b610dc6611565565b6000898152600a6020526040902060010154600160a01b900460ff1615610e1d5760405162461bcd60e51b815260206004820152600b60248201526a5643463a2065786973747360a81b6044820152606401610577565b6001600160a01b038316610e735760405162461bcd60e51b815260206004820152601760248201527f5643463a206261636b6f666669636520616464726573730000000000000000006044820152606401610577565b600854600090610e92906001600160a01b03168b8a8a8a8a8989611262565b9050336001600160a01b03821614610eda5760405162461bcd60e51b815260206004820152600b60248201526a2b21a31d1039b2b73232b960a91b6044820152606401610577565b6000610ee58b6115be565b8051602082012060085491925090600090610f09906001600160a01b031683611603565b90506001600160a01b038116610f595760405162461bcd60e51b81526020600482015260156024820152745643463a206465706c6f796564206164647265737360581b6044820152606401610577565b6040518060600160405280600860009054906101000a90046001600160a01b03166001600160a01b03168152602001826001600160a01b0316815260200160011515815250600a60008f815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160010160146101000a81548160ff02191690831515021790555090505060006110a38b8b8b8b8b6040516001600160a01b0380871660248301526044820186905284151560648301528084166084830152821660a482015260609060c40160408051601f198184030181529190526020810180516001600160e01b031663ea93e51d60e01b1790529695505050505050565b90508c8e836001600160a01b03167fd01a59e827ae2d668eaac037956beabfe7eee6f0209a535ba915beab74a738da8f8f8f8f8f8f8e600860009054906101000a90046001600160a01b0316604051611103989796959493929190612388565b60405180910390a46111158d866116a0565b6111505760405162461bcd60e51b815260206004820152600c60248201526b5643463a20636f6e73756d6560a01b6044820152606401610577565b6111636001600160a01b0383168261176d565b5050505050506111736001600455565b505050505050505050565b606060ff831461119857611191836117b1565b905061050f565b8180546111a490612335565b80601f01602080910402602001604051908101604052809291908181526020018280546111d090612335565b801561121d5780601f106111f25761010080835404028352916020019161121d565b820191906000526020600020905b81548152906001019060200180831161120057829003601f168201915b5050505050905061050f565b6112316117f0565b6003805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33610d59565b60006001600160a01b0389166112b05760405162461bcd60e51b81526020600482015260136024820152722b21a31d1034b6b83632b6b2b73a30ba34b7b760691b6044820152606401610577565b60008751116112ed5760405162461bcd60e51b81526020600482015260096024820152685643463a206e616d6560b81b6044820152606401610577565b6001600160a01b0386166113385760405162461bcd60e51b81526020600482015260126024820152715643463a20746f6b656e206164647265737360701b6044820152606401610577565b601285111561137f5760405162461bcd60e51b81526020600482015260136024820152725643463a20746f6b656e20646563696d616c7360681b6044820152606401610577565b6001600160a01b0383166113cb5760405162461bcd60e51b81526020600482015260136024820152725643463a2074656e616e74206164647265737360681b6044820152606401610577565b604182511461140d5760405162461bcd60e51b815260206004820152600e60248201526d5643463a207369676e617475726560901b6044820152606401610577565b8651602080890191909120604080517f79879e034d8fddd08e9216b25d8de4a956b3eb8e68d10f3438444cb2447ca77e938101939093526001600160a01b03808d1691840191909152606083018b9052608083019190915280881660a083015260c0820187905285151560e083015284166101008201526000906114aa906101200160405160208183030381529060405280519060200120611839565b90506114b68184611866565b91506001600160a01b0382166114ff5760405162461bcd60e51b815260206004820152600e60248201526d1590d18e881c9958dbdd995c995960921b6044820152606401610577565b5098975050505050505050565b61151682826109eb565b610700576115238161188a565b61152e83602061189c565b60405160200161153f9291906123e6565b60408051601f198184030181529082905262461bcd60e51b825261057791600401612059565b6002600454036115b75760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610577565b6002600455565b6060816040516024016115d391815260200190565b60408051601f198184030181529190526020810180516001600160e01b0316638f9caa8960e01b17905292915050565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008360601b60e81c176000526e5af43d82803e903d91602b57fd5bf38360781b1760205281603760096000f590506001600160a01b03811661050f5760405162461bcd60e51b815260206004820152601760248201527f455243313136373a2063726561746532206661696c65640000000000000000006044820152606401610577565b6009546000906001600160a01b03166116ef5760405162461bcd60e51b81526020600482015260116024820152702b21a31d1039bab139b1b934b83a34b7b760791b6044820152606401610577565b60095460405163044bda5760e11b8152600481018590526001600160a01b03848116602483015290911690630897b4ae906044016020604051808303816000875af1158015611742573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117669190612318565b9392505050565b6060611766838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250611a38565b606060006117be83611b15565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b60035460ff16610dbc5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610577565b600061050f611846611b3d565b8360405161190160f01b8152600281019290925260228201526042902090565b60008060006118758585611c6d565b9150915061188281611cb2565b509392505050565b606061050f6001600160a01b03831660145b606060006118ab836002612471565b6118b6906002612488565b67ffffffffffffffff8111156118ce576118ce61206c565b6040519080825280601f01601f1916602001820160405280156118f8576020820181803683370190505b509050600360fc1b816000815181106119135761191361249b565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106119425761194261249b565b60200101906001600160f81b031916908160001a9053506000611966846002612471565b611971906001612488565b90505b60018111156119e9576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106119a5576119a561249b565b1a60f81b8282815181106119bb576119bb61249b565b60200101906001600160f81b031916908160001a90535060049490941c936119e2816124b1565b9050611974565b5083156117665760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610577565b606082471015611a995760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610577565b600080866001600160a01b03168587604051611ab591906124c8565b60006040518083038185875af1925050503d8060008114611af2576040519150601f19603f3d011682016040523d82523d6000602084013e611af7565b606091505b5091509150611b0887838387611dfc565b925050505b949350505050565b600060ff8216601f81111561050f57604051632cd44ac360e21b815260040160405180910390fd5b6000306001600160a01b037f0000000000000000000000009c72e35c360aa7024e7ae143aefefd72d0d634d716148015611b9657507f000000000000000000000000000000000000000000000000000000000000000146145b15611bc057507f7d990991e583d18eff764d272ce94036374c646b6e2417d7b455e00c05d2e6a090565b611c68604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f9ac25a6adbcab82770ae9b972f12da27e4697bad69f7d5b9a118eac42dded547918101919091527f15124d26d1272f8d4d5266a24ca397811f414b8cd05a53b26b745f63af5ae2fc60608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b905090565b6000808251604103611ca35760208301516040840151606085015160001a611c9787828585611e75565b94509450505050611cab565b506000905060025b9250929050565b6000816004811115611cc657611cc66124e4565b03611cce5750565b6001816004811115611ce257611ce26124e4565b03611d2f5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610577565b6002816004811115611d4357611d436124e4565b03611d905760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610577565b6003816004811115611da457611da46124e4565b0361089a5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610577565b60608315611e6b578251600003611e64576001600160a01b0385163b611e645760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610577565b5081611b0d565b611b0d8383611f39565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611eac5750600090506003611f30565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611f00573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611f2957600060019250925050611f30565b9150600090505b94509492505050565b815115611f495781518083602001fd5b8060405162461bcd60e51b81526004016105779190612059565b600060208284031215611f7557600080fd5b81356001600160e01b03198116811461176657600080fd5b80356001600160a01b0381168114611fa457600080fd5b919050565b600060208284031215611fbb57600080fd5b61176682611f8d565b600060208284031215611fd657600080fd5b5035919050565b60008060408385031215611ff057600080fd5b8235915061200060208401611f8d565b90509250929050565b60005b8381101561202457818101518382015260200161200c565b50506000910152565b60008151808452612045816020860160208601612009565b601f01601f19169290920160200192915050565b602081526000611766602083018461202d565b634e487b7160e01b600052604160045260246000fd5b600082601f83011261209357600080fd5b813567ffffffffffffffff808211156120ae576120ae61206c565b604051601f8301601f19908116603f011681019082821181831017156120d6576120d661206c565b816040528381528660208588010111156120ef57600080fd5b836020870160208301376000602085830101528094505050505092915050565b801515811461089a57600080fd5b600080600080600080600060e0888a03121561213857600080fd5b8735965060208801359550604088013567ffffffffffffffff8082111561215e57600080fd5b61216a8b838c01612082565b965061217860608b01611f8d565b955060808a0135945060a08a013591506121918261210f565b90925060c089013590808211156121a757600080fd5b506121b48a828b01612082565b91505092959891949750929550565b60ff60f81b881681526000602060e0818401526121e360e084018a61202d565b83810360408501526121f5818a61202d565b606085018990526001600160a01b038816608086015260a0850187905284810360c0860152855180825283870192509083019060005b818110156122475783518352928401929184019160010161222b565b50909c9b505050505050505050505050565b600080600080600080600080610100898b03121561227657600080fd5b61227f89611f8d565b975060208901359650604089013567ffffffffffffffff808211156122a357600080fd5b6122af8c838d01612082565b97506122bd60608c01611f8d565b965060808b0135955060a08b013591506122d68261210f565b8194506122e560c08c01611f8d565b935060e08b01359150808211156122fb57600080fd5b506123088b828c01612082565b9150509295985092959890939650565b60006020828403121561232a57600080fd5b81516117668161210f565b600181811c9082168061234957607f821691505b60208210810361236957634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561238157600080fd5b5051919050565b600061010080835261239c8184018c61202d565b6001600160a01b039a8b166020850152604084019990995250509415156060860152928616608085015290851660a0840152841660c083015290921660e090920191909152919050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161241e816017850160208801612009565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161244f816028840160208801612009565b01602801949350505050565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761050f5761050f61245b565b8082018082111561050f5761050f61245b565b634e487b7160e01b600052603260045260246000fd5b6000816124c0576124c061245b565b506000190190565b600082516124da818460208701612009565b9190910192915050565b634e487b7160e01b600052602160045260246000fdfe1cc585a35ee40bc8e30be46c66514537f1953ad0977428ef905e8e0df71a6ee7a2646970667358221220d48efd5791bd03ea4bc2911f9a1848839ae0234c7b8c05cc7723abb33d8c56e664736f6c63430008130033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a059eb2902326a23c3fb6e66c499c661a6165df892fc643c67c712570ad48e50d3000000000000000000000000000000000000000000000000000000000000001a56455354494e475f435553544f4d5f524546554e445f55534552000000000000000000000000000000000000000000000000000000000000000000000000000676312e302e300000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : name (string): VESTING_CUSTOM_REFUND_USER
Arg [1] : version (string): v1.0.0
Arg [2] : implementationType (uint256): 40671335614963018557322824793024863016445127676230257936628911677933926371539

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [1] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [2] : 59eb2902326a23c3fb6e66c499c661a6165df892fc643c67c712570ad48e50d3
Arg [3] : 000000000000000000000000000000000000000000000000000000000000001a
Arg [4] : 56455354494e475f435553544f4d5f524546554e445f55534552000000000000
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000006
Arg [6] : 76312e302e300000000000000000000000000000000000000000000000000000


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.