Contract 0x5C071a3FCd0A8A22633c47aC662bb62A356ED9Dd 1

 

Contract Overview

Balance:
0 MATIC

MATIC Value:
$0.00

Token:
 
Txn Hash
Method
Block
From
To
Value [Txn Fee]
0x2d9fa9092d8ad2577ae7abfcacb436f69f2c004012a6b09848f97cca0ad50f47_trigger Pause408714792023-03-28 18:23:1160 days 15 hrs ago0xe820cc557279acc115d61b7c450f47ff000b4ef6 IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.004979243612 105.33623044
0x7a00049709224040202f6d385c6ebf5048ba134cfd1cfedb02cdfb08b0a72c74Submit Floors408714662023-03-28 18:22:4360 days 15 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.015385979919110.214755869
0x4298b48147c66541f0011e49f0e7b475eae3b04e34a21c00ca1b8d72bd681205Submit Floors408714182023-03-28 18:21:0160 days 15 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.01431284773102.536376557
0x0e481982055062141ec0213d989626ceb68308f47f0a828dbaa09c7802068160Submit Floors408713522023-03-28 18:18:0960 days 15 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.015708741864112.536477811
0x0e0afaa73f03f57f0ecb9fe9da0869496845578bfdde910801fe33aa4dd0f122Submit Floors408713252023-03-28 18:17:1160 days 15 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.015338966221109.887427443
0x2dacb36980857c8e7bbc064a3e5693a1fec403591756f01dd00695eac2cbf485Submit Floors408713052023-03-28 18:16:2960 days 15 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.014956220285107.145458673
0xdd87e95d9cbb3087cbe538efb5470787fd6fa41606ff85b5c8eafa61d5099027_set Update Thre...408712782023-03-28 18:15:3160 days 15 hrs ago0xe820cc557279acc115d61b7c450f47ff000b4ef6 IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.004038741837 130.38714567
0x9c7790708ae1e8b25e023b2dde100870e8ca47ee1edffb7094d3d4f1e854e4baSubmit Floors408712242023-03-28 18:13:0560 days 15 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.016272444017116.574805983
0xee391d18986ea754f4c3c05412bfc6e14627cdfc0d53d0dbdd48c47e95cc98c8_set Update Thre...408712222023-03-28 18:13:0160 days 15 hrs ago0xe820cc557279acc115d61b7c450f47ff000b4ef6 IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.003623387401 117.023137331
0x93b643b207035a3800034e31f838b0d3f22b1ac8d391f3831881afd224034882Submit Floors408712082023-03-28 18:12:3160 days 15 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.017355698336124.335174485
0x3984d5efbe883719b21ba104e050977efa7c122ce3527459789865a7adb1b425Submit Floors408711832023-03-28 18:11:0560 days 15 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.014279492743102.297423443
0x02cb94e4fcd832965c50c790ed882226b6113240f4466b3308eab1a3b78c5da5Submit Floors408711532023-03-28 18:10:0360 days 15 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.014428273626103.363280699
0x6fcf6160f1f7196f0f002841d8c429dbb7c82eae14893406731a85d69963398cSubmit Floors408711242023-03-28 18:09:0160 days 15 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.017087374559122.412919162
0x6787cba314087c36432392dd0aff4d3867e8e5f14745145bc2f10befc383b58fSubmit Floors408710962023-03-28 18:08:0160 days 15 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.021115073242151.267109227
0x07eaf1a33af57caf7d7a9dfcad379d12b09a78ec0a455cc4671b7fac772cd4fa_set Update Thre...408710602023-03-28 18:06:2360 days 15 hrs ago0xe820cc557279acc115d61b7c450f47ff000b4ef6 IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.004818332642 155.615820249
0x96d3782cf267bbe2a1ed1287e2b86530c3310e0b22cd1293580ac9aefc930b91Submit Floors408525042023-03-28 6:23:1761 days 3 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.023649532048169.423819017
0x63d23105cf9c6c832fa1ecd7cd53857d072dca75fed02a7ebdf0ec70167eba8fSubmit Floors408524762023-03-28 6:22:1761 days 3 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.024472418875175.318930534
0x225ba25436cba2642eb257be3005f9de2b1aa0cff1282e60c49ce28cde39443dSubmit Floors408517852023-03-28 5:56:0461 days 3 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.01589378123113.803388449
0xf08f7a84cc9ac032c62f74537ce12d4b1751c33670ff4438eaa4fd8b46ade0a5Submit Floors408514962023-03-28 5:45:1861 days 3 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.01791250891128.268997128
0xcfd55a549b1a68ce7c471dc258b2e67637460d7a5787a732db6cfa4314e86933Submit Floors408514682023-03-28 5:44:1861 days 3 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.015826791706144.895510411
0xa5f39d32b5222e089e8ba070b2215be40f655a6aeedede7669d77044354fcdc9Submit Floors408514432023-03-28 5:43:2661 days 3 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.017441091703159.674552581
0xfce9f4f102facf954c92f067765920f825f0132b615e7a493e6f9df146cdfdd0Submit Floors408513722023-03-28 5:40:1861 days 3 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.015046046073137.747723345
0x13699f95c63b5d3de4487e3518af9c84de14db5dc46da296f06ad8950f44905cSubmit Floors408513532023-03-28 5:39:3861 days 3 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.017371180336137.507463343
0x9df49947db9ea48e349385eb5e64478c22c2fbedc410fc44c439326e7796180eRegister Collect...408513002023-03-28 5:37:4661 days 3 hrs ago0xe820cc557279acc115d61b7c450f47ff000b4ef6 IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.014146614949 145.123255533
0xaea1dcb84173104ba762160d7e8b8cfd0ef6dbb9ccdc7d96424474f8d76a280dSubmit Floors408511512023-03-28 5:31:5661 days 3 hrs ago0xe4e56aa48e268975e62a1783cd9e25aada4ab4fe IN  0x5c071a3fcd0a8a22633c47ac662bb62a356ed9dd0 MATIC0.02146533533153.76314707
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PermissionlessOracle

Compiler Version
v0.8.15+commit.e14f2714

Optimization Enabled:
Yes with 300 runs

Other Settings:
default evmVersion
File 1 of 20 : AggregatorV3Interface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface AggregatorV3Interface {
  function decimals() external view returns (uint8);

  function description() external view returns (string memory);

  function version() external view returns (uint256);

  // getRoundData and latestRoundData should both raise "No data present"
  // if they do not have data to report, instead of returning unset values
  // which could be misinterpreted as actual reported values.
  function getRoundData(uint80 _roundId)
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
}

File 2 of 20 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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:
 *
 * ```
 * 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}:
 *
 * ```
 * 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.
 */
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 20 : AccessControlEnumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
    using EnumerableSet for EnumerableSet.AddressSet;

    mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;

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

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
        return _roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
        return _roleMembers[role].length();
    }

    /**
     * @dev Overload {_grantRole} to track enumerable memberships
     */
    function _grantRole(bytes32 role, address account) internal virtual override {
        super._grantRole(role, account);
        _roleMembers[role].add(account);
    }

    /**
     * @dev Overload {_revokeRole} to track enumerable memberships
     */
    function _revokeRole(bytes32 role, address account) internal virtual override {
        super._revokeRole(role, account);
        _roleMembers[role].remove(account);
    }
}

File 4 of 20 : 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 5 of 20 : IAccessControlEnumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerable is IAccessControl {
    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}

File 6 of 20 : 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 20 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

File 8 of 20 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

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

pragma solidity ^0.8.0;

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

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 10 of 20 : 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 11 of 20 : 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 12 of 20 : 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 13 of 20 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library 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) {
                return prod0 / denominator;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "./math/Math.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 `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);
    }
}

File 15 of 20 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

File 16 of 20 : HTokenI.sol
//SPDX-License-Identifier: BUSL-1.1

pragma solidity >=0.8.4;
import "./HTokenInternalI.sol";

/**
 * @title   Interface of HToken
 * @author  Honey Labs Inc.
 * @custom:coauthor BowTiedPickle
 * @custom:coauthor m4rio
 */
interface HTokenI is HTokenInternalI {
  /**
   * @notice  Deposit underlying ERC-20 asset and mint hTokens
   * @dev     Pull pattern, user must approve the contract before calling. If _to is address(0) then it becomes msg.sender
   * @param   _amount   Quantity of underlying ERC-20 to transfer in
   * @param   _to       Target address to mint hTokens to
   */
  function depositUnderlying(uint256 _amount, address _to) external;

  /**
   * @notice  Redeem a specified amount of hTokens for their underlying ERC-20 asset
   * @param   _amount   Quantity of hTokens to redeem for underlying ERC-20
   */
  function redeem(uint256 _amount) external;

  /**
   * @notice  Withdraws the specified amount of underlying ERC-20 asset, consuming the minimum amount of hTokens necessary
   * @param   _amount   Quantity of underlying ERC-20 tokens to withdraw
   */
  function withdraw(uint256 _amount) external;

  /**
   * @notice  Deposit multiple specified tokens of the underlying ERC-721 asset and mint ERC-1155 deposit coupon NFTs
   * @dev     Pull pattern, user must approve the contract before calling.
   * @param   _collateralIds  Token IDs of underlying ERC-721 to be transferred in
   */
  function depositCollateral(uint256[] calldata _collateralIds) external;

  /**
   * @notice  Sender borrows assets from the protocol against the specified collateral asset, without a referral code
   * @dev     Collateral must be deposited first.
   * @param   _borrowAmount   Amount of underlying ERC-20 to borrow
   * @param   _collateralId   Token ID of underlying ERC-721 to be borrowed against
   */
  function borrow(uint256 _borrowAmount, uint256 _collateralId) external;

  /**
   * @notice  Sender borrows assets from the protocol against the specified collateral asset, using a referral code
   * @param   _borrowAmount   Amount of underlying ERC-20 to borrow
   * @param   _collateralId   Token ID of underlying ERC-721 to be borrowed against
   * @param   _referral       Referral code as a plain string
   * @param   _signature      Signed message authorizing the referral, provided by Honey Labs
   */
  function borrowReferred(
    uint256 _borrowAmount,
    uint256 _collateralId,
    string calldata _referral,
    bytes calldata _signature
  ) external;

  /**
   * @notice  Sender repays a borrow taken against the specified collateral asset
   * @dev     Pull pattern, user must approve the contract before calling.
   * @param   _repayAmount    Amount of underlying ERC-20 to repay
   * @param   _collateralId   Token ID of underlying ERC-721 to be repaid against
   */
  function repayBorrow(
    uint256 _repayAmount,
    uint256 _collateralId,
    address _to
  ) external;

  /**
   * @notice  Burn deposit coupon NFTs and withdraw the associated underlying ERC-721 NFTs
   * @param   _collateralIds  Token IDs of underlying ERC-721 to be withdrawn
   */
  function withdrawCollateral(uint256[] calldata _collateralIds) external;

  /**
   * @notice  Trigger transfer of an NFT to the liquidation contract
   * @param   _collateralId   Token ID of underlying ERC-721 to be liquidated
   */
  function liquidateBorrow(uint256 _collateralId) external;

  /**
   * @notice  Pay off the entirety of a liquidated debt position and burn the coupon
   * @dev     May only be called by the liquidator
   * @param   _borrower       Owner of the debt position
   * @param   _collateralId   Token ID of underlying ERC-721 to be closed out
   */
  function closeoutLiquidation(address _borrower, uint256 _collateralId) external;

  /**
   * @notice  Accrues all interest due to the protocol
   * @dev     Call this before performing calculations using 'totalBorrows' or other contract-wide quantities
   */
  function accrueInterest() external;

  // ----- Utility functions -----

  /**
   * @notice  Sweep accidental ERC-20 transfers to this contract.
   * @dev     Tokens are sent to the DAO for later distribution
   * @param   _token  The address of the ERC-20 token to sweep
   */
  function sweepToken(IERC20 _token) external;
}

File 17 of 20 : HTokenInternalI.sol
//SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.4;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/access/IAccessControl.sol";

/**
 * @title   Interface of HToken Internal
 * @author  Honey Labs Inc.
 * @custom:coauthor m4rio
 * @custom:coauthor BowTiedPickle
 */
interface HTokenInternalI is IERC1155, IAccessControl {
  struct Coupon {
    uint32 id; //Coupon's id
    uint8 active; // Coupon activity status
    address owner; // Who is the current owner of this coupon
    uint256 collateralId; // tokenId of the collateral collection that is borrowed against
    uint256 borrowAmount; // Principal borrow balance, denominated in underlying ERC20 token.
    uint256 debtShares; // Debt shares, keeps the shares of total debt by the protocol
  }

  struct Collateral {
    uint256 collateralId; // TokenId of the collateral
    bool active; // Collateral activity status
  }

  // ----- Informational -----

  function decimals() external view returns (uint8);

  function name() external view returns (string memory);

  function symbol() external view returns (string memory);

  // ----- Addresses -----

  function collateralToken() external view returns (IERC721);

  function underlyingToken() external view returns (IERC20);

  // ----- Protocol Accounting -----

  function totalBorrows() external view returns (uint256);

  function totalReserves() external view returns (uint256);

  function totalSupply() external view returns (uint256);

  function totalFuseFees() external view returns (uint256);

  function totalAdminCommission() external view returns (uint256);

  function accrualBlockNumber() external view returns (uint256);

  function interestIndexStored() external view returns (uint256);

  function totalProtocolCommissions() external view returns (uint256);

  function userToCoupons(address _user) external view returns (uint256);

  function collateralPerBorrowCouponId(uint256 _couponId) external view returns (Collateral memory);

  function borrowCoupons(uint256 _collateralId) external view returns (Coupon memory);

  // ----- Views -----

  /**
   * @notice  Get the outstanding debt of a collateral
   * @dev     Simulates accrual of interest
   * @param   _collateralId   Token ID of underlying ERC-721
   * @return  Outstanding debt in units of underlying ERC-20
   */
  function getDebtForCollateral(uint256 _collateralId) external view returns (uint256);

  /**
   * @notice  Returns the current per-block borrow interest rate for this hToken
   * @return  The borrow interest rate per block, scaled by 1e18
   */
  function borrowRatePerBlock() external view returns (uint256);

  /**
   * @notice  Get the outstanding debt of a coupon
   * @dev     Simulates accrual of interest
   * @param   _couponId   ID of the coupon
   * @return  Outstanding debt in units of underlying ERC-20
   */
  function getDebtForCoupon(uint256 _couponId) external view returns (uint256);

  /**
   * @notice  Gets balance of this contract in terms of the underlying excluding the fees
   * @dev     This excludes the value of the current message, if any
   * @return  The quantity of underlying ERC-20 tokens owned by this contract
   */
  function getCashPrior() external view returns (uint256);

  /**
   * @notice  Get a snapshot of the account's balances, and the cached exchange rate
   * @dev     This is used by controller to more efficiently perform liquidity checks.
   * @param   _account  Address of the account to snapshot
   * @return  (token balance, borrow balance, exchange rate mantissa)
   */
  function getAccountSnapshot(address _account)
    external
    view
    returns (
      uint256,
      uint256,
      uint256
    );

  /**
   * @notice  Get the outstanding debt of the protocol
   * @return  Protocol debt
   */
  function getDebt() external view returns (uint256);

  /**
   * @notice  Returns protocol fees
   * @return  Reserve factor mantissa
   * @return  Admin fee mantissa
   * @return  Hive fee mantissa
   * @return  Initial exchange rate mantissa
   * @return  Maximum borrow rate mantissa
   */
  function getProtocolFees()
    external
    view
    returns (
      uint256,
      uint256,
      uint256,
      uint256,
      uint256
    );

  /**
   * @notice  Returns different addresses of the protocol
   * @return  Liquidator address
   * @return  HTokenHelper address
   * @return  Controller address
   * @return  Admin Fee Receiver address
   * @return  Hive Fee Receiver address
   * @return  Interest Model address
   * @return  Referral Pool address
   * @return  DAO address
   */
  function getAddresses()
    external
    view
    returns (
      address,
      address,
      address,
      address,
      address,
      address,
      address,
      address
    );

  /**
   * @notice  Get the last minted coupon ID
   * @return  The last minted coupon ID
   */
  function idCounter() external view returns (uint256);

  /**
   * @notice  Get the coupon for a specific collateral NFT
   * @param   _collateralId   Token ID of underlying ERC-721
   * @return  Coupon
   */
  function getSpecificCouponByCollateralId(uint256 _collateralId) external view returns (Coupon memory);

  /**
   * @notice  Calculate the prevailing interest due per token of debt principal
   * @return  Mantissa formatted interest rate per token of debt
   */
  function interestIndex() external view returns (uint256);

  /**
   * @notice  Accrue interest then return the up-to-date exchange rate from the ERC-20 underlying to the HToken
   * @return  Calculated exchange rate scaled by 1e18
   */
  function exchangeRateCurrent() external returns (uint256);

  /**
   * @notice  Calculates the exchange rate from the ERC-20 underlying to the HToken
   * @dev     This function does not accrue interest before calculating the exchange rate
   * @return  Calculated exchange rate scaled by 1e18
   */
  function exchangeRateStored() external view returns (uint256);

  /**
   * @notice  Add to or take away from reserves
   * @dev     Accrues interest
   * @param   _amount  Quantity of underlying ERC-20 token to change the reserves by
   */
  function _modifyReserves(uint256 _amount, bool _add) external;

  /**
   * @notice  Set new admin fee mantissas
   * @dev     Accrues interest
   * @param   _newAdminCommissionMantissa        New admin fee mantissa
   */
  function _setAdminCommission(uint256 _newAdminCommissionMantissa) external;

  /**
   * @notice  Set new protocol commission and reserve factor mantissas
   * @dev     Accrues interest
   * @param   _newProtocolCommissionMantissa         New protocol commission mantissa
   * @param   _newReserveFactorMantissa   New reserve factor mantissa
   */
  function _setProtocolFees(uint256 _newProtocolCommissionMantissa, uint256 _newReserveFactorMantissa) external;

  /**
   * @notice  Sets a new admin fee receiver
   * @param   _newAddress   Address of the new admin fee receiver
   * @param   _target       Target ID of the address to be set
   */
  function _setAddressMarketAdmin(address _newAddress, uint256 _target) external;
}

File 18 of 20 : PermissionlessOracleI.sol
//SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.4;

import "./HTokenI.sol";

import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

/**
 * @title   PermissionlessOracleI interface for the Permissionless oracle
 * @author  Honey Labs Inc.
 * @custom:coauthor BowTiedPickle
 * @custom:coauthor m4rio
 */
interface PermissionlessOracleI {
  /**
   * @notice returns the price (in eth) for the floor of a collection
   * @param _collection address of the collection
   * @param _decimals adjust decimals of the returned price
   */
  function getFloorPrice(address _collection, uint256 _decimals) external view returns (uint128, uint128);

  /**
   * @notice returns the latest price for a given pair
   * @param _erc20 the erc20 we want to get the price for in USD
   * @param _decimals decimals to denote the result in
   */
  function getUnderlyingPriceInUSD(IERC20 _erc20, uint256 _decimals) external view returns (uint256);

  /**
   * @notice get price of eth
   * @param _decimals adjust decimals of the returned price
   */
  function getEthPrice(uint256 _decimals) external view returns (uint256);

  /**
   * @notice get price feeds for a token
   * @return returns the Chainlink Aggregator interface
   */
  function priceFeeds(IERC20 _token) external view returns (AggregatorV3Interface);

  /**
   * @notice returns the update threshold for a specific _collection
   */
  function updateThreshold(address _collection) external view returns (uint256);

  /**
   * @notice returns the number of floors for a specific _collection
   * @param _address address of the collection
   *
   */
  function getNoOfFloors(address _address) external view returns (uint256);

  /**
   * @notice returns the last updated timestamp for a specific _collection
   * @param _collection address of the collection
   *
   */
  function getLastUpdated(address _collection) external view returns (uint256);
}

File 19 of 20 : PermissionlessOracle.sol
//SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.15;

import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

import ".././interfaces/HTokenI.sol";
import ".././interfaces/PermissionlessOracleI.sol";
import ".././utils/ErrorReporter.sol";

/**
 * @title   Custom oracle for Honey Labs
 * @author  Honey Labs Inc.
 * @custom:coauthor     m4rio
 * @custom:contributor  BowTiedPickle
 */
contract PermissionlessOracle is PermissionlessOracleI, AccessControlEnumerable, Pausable {
  bytes32 public constant SUBMITTER_ROLE = keccak256("SUBMITTER_ROLE");
  bytes32 public constant CREATOR_ROLE = keccak256("CREATOR_ROLE");

  /// @notice Version of the contract. 1_000_000 corresponds to 1.0.0
  uint256 public constant version = 1_000_000;

  struct Collection {
    bool paused;
    uint16 twapRange;
    address collectionAddress;
    uint256 updateThreshold; // this will make the oracle revert in case the last update is > than this threshold
    string collectionSlug;
  }

  struct FloorPrice {
    uint96 insertedAt;
    address collectionAddress;
    uint256 price;
    uint256 lastMean;
    address submitter;
  }

  /// @notice weth address
  IERC20 public immutable weth;

  /// @notice collections that are supported on the oracle
  mapping(address => Collection) public collections;

  /// @notice floor prices for different collections
  mapping(address => FloorPrice[]) public floorPrices;

  /// @notice price feeds for different ERC20s we support in the markets
  mapping(IERC20 => AggregatorV3Interface) public priceFeeds;

  constructor(IERC20 _weth) {
    _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
    _setupRole(SUBMITTER_ROLE, msg.sender);
    _setupRole(CREATOR_ROLE, msg.sender);
    weth = _weth;
  }

  /**
   * @notice  register collections to get the floors for
   * @param   _addresses        Addresses of the collections
   * @param   _collectionSlugs  Collection slugs
   * @param   _twapRanges       TWAP ranges for each collection
   * @param   _updateThresholds Update thresholds for each collection (in seconds)
   */
  function registerCollections(
    address[] calldata _addresses,
    string[] calldata _collectionSlugs,
    uint16[] calldata _twapRanges,
    uint256[] calldata _updateThresholds
  ) external whenNotPaused onlyRole(CREATOR_ROLE) {
    if (
      _addresses.length != _collectionSlugs.length &&
      _addresses.length != _twapRanges.length &&
      _addresses.length != _updateThresholds.length
    ) {
      revert WrongParams();
    }

    for (uint256 i; i < _addresses.length; ) {
      collections[_addresses[i]] = Collection(
        false,
        _twapRanges[i],
        _addresses[i],
        _updateThresholds[i],
        _collectionSlugs[i]
      );
      unchecked {
        ++i;
      }
    }
  }

  /**
   * @notice  submit floors for multiple collections
   * @param   _addresses  Collections we want to submit floors for
   * @param   _floors     Floors for each collection
   */
  function submitFloors(address[] calldata _addresses, uint256[] calldata _floors)
    external
    whenNotPaused
    onlyRole(SUBMITTER_ROLE)
  {
    if (_addresses.length != _floors.length) {
      revert WrongParams();
    }
    for (uint256 i; i < _addresses.length; ) {
      address col = _addresses[i];

      if (collections[col].collectionAddress == address(0)) {
        revert CollectionNotRegistered();
      }

      Collection storage collection = collections[col];

      uint256 lastMean;
      uint256 length = floorPrices[col].length;
      uint256 cachedTwapRange = collection.twapRange;

      // if we don't have enough twap, we just submit data, we don't have mean
      if (length < cachedTwapRange) {
        floorPrices[col].push(FloorPrice(uint96(block.timestamp), col, _floors[i], 0, msg.sender));
        emit FloorSubmitted(collection.collectionSlug, _floors[i], msg.sender);
        unchecked {
          ++i;
        }
        continue;
      }

      for (uint256 j = 1; j <= cachedTwapRange; ) {
        lastMean += floorPrices[col][length - j].price;
        unchecked {
          ++j;
        }
      }

      lastMean += _floors[i];
      floorPrices[col].push(
        FloorPrice(uint96(block.timestamp), col, _floors[i], lastMean / cachedTwapRange, msg.sender)
      );
      emit FloorSubmitted(collection.collectionSlug, _floors[i], msg.sender);

      unchecked {
        ++i;
      }
    }
  }

  /**
   * @notice  returns the price (in eth) for the floor of a collection
   * @param   _address  address of the collection
   * @param   _decimals adjust decimals of the returned price
   */
  function getFloorPrice(address _address, uint256 _decimals) external view override returns (uint128, uint128) {
    uint256 lengthOfFloor = floorPrices[_address].length;
    if (lengthOfFloor == 0) return (0, 0);
    FloorPrice storage lastFloor = floorPrices[_address][lengthOfFloor - 1];
    uint256 lastMean = lastFloor.lastMean;
    uint256 oracleDecimals = 18;

    if (oracleDecimals < _decimals) {
      unchecked {
        _decimals -= oracleDecimals;
      }

      return (uint128(lastMean * 10**_decimals), lastFloor.insertedAt);
    } else {
      unchecked {
        _decimals = oracleDecimals - _decimals;
      }
    }

    return (uint128(lastMean / 10**_decimals), lastFloor.insertedAt);
  }

  /**
   * @notice  returns the latest price for a given pair
   * @param   _erc20    the erc20 we want to get the price for in USD
   * @param   _decimals decimals to denote the result in
   */
  function getUnderlyingPriceInUSD(IERC20 _erc20, uint256 _decimals) public view returns (uint256) {
    uint256 oracleDecimals = priceFeeds[_erc20].decimals();
    (uint80 roundID, int256 price, , uint256 updatedAt, uint80 answeredInRound) = priceFeeds[_erc20].latestRoundData();

    if (updatedAt == 0 || price <= 0 || answeredInRound < roundID) {
      revert Unexpected("Price data is stale");
    }

    if (oracleDecimals < _decimals) {
      unchecked {
        _decimals -= oracleDecimals;
      }
      return uint256(price) * 10**_decimals;
    } else {
      unchecked {
        _decimals = oracleDecimals - _decimals;
      }
      return uint256(price) / 10**_decimals;
    }
  }

  /**
   * @notice  get price of eth
   * @param   _decimals adjust decimals of the returned price
   */
  function getEthPrice(uint256 _decimals) external view returns (uint256) {
    return getUnderlyingPriceInUSD(weth, _decimals);
  }

  /**
   * @notice  Returns the floor prices for a collection (paginated)
   * @param   _address  Address of the collection
   * @param   _start    Start index
   * @param   _length   Length of the results
   */
  function getFloorPricesForCollection(
    address _address,
    uint256 _start,
    uint256 _length
  ) external view returns (FloorPrice[] memory) {
    uint256 floorLength = floorPrices[_address].length;

    if (_start > floorLength) revert WrongParams();

    if (_start + _length > floorLength) {
      _length = floorLength - _start;
    }
    unchecked {
      FloorPrice[] memory collectionFloorPrices = new FloorPrice[](_length);

      for (uint256 i = _start; i < _start + _length; ++i) {
        collectionFloorPrices[i] = floorPrices[_address][i];
      }
      return collectionFloorPrices;
    }
  }

  /**
   * @notice  Returns the number of submitted floors for a collection
   * @param   _address address of the collection
   */
  function getNoOfFloors(address _address) external view override returns (uint256) {
    return floorPrices[_address].length;
  }

  /**
   * @notice Returns the update threshold for a specific _collection
   */
  function updateThreshold(address _collection) external view override returns (uint256) {
    return collections[_collection].updateThreshold;
  }

  /**
   * @notice returns the last updated timestamp for a specific _collection
   * @param _collection address of the collection
   *
   */
  function getLastUpdated(address _collection) external view override returns (uint256) {
    return floorPrices[_collection][floorPrices[_collection].length - 1].insertedAt;
  }

  /**
   * @notice  Pauses or unpauses the contract
   * @param   _shouldUnpause true if we should unpause, false if we should pause
   */
  function _triggerPause(bool _shouldUnpause) external onlyRole(DEFAULT_ADMIN_ROLE) {
    if (_shouldUnpause) _unpause();
    else _pause();
  }

  /**
   * @notice Adds a new price feed for a specific ERC20 token
   * @param _erc20 ERC20 token we want to add pricefeed for
   * @param _oracle Price feed oracle
   */
  function _addPriceFeed(IERC20 _erc20, address _oracle) external onlyRole(DEFAULT_ADMIN_ROLE) {
    priceFeeds[_erc20] = AggregatorV3Interface(_oracle);
    emit PriceFeedAdded(_erc20, _oracle);
  }

  /**
   * @notice  Sets the threshold of checking last update on the oracle side
   * @dev     Admin function to set updateThreshold
   * @param   _newThreshold   New threshold
   * @param   _collection     The collection we update the threshold for
   */
  function _setUpdateThreshold(uint256 _newThreshold, address _collection) external {
    if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender) && !hasRole(CREATOR_ROLE, msg.sender)) revert Unauthorized();

    emit ThresholdUpdated(collections[_collection].updateThreshold, _newThreshold, _collection);
    collections[_collection].updateThreshold = _newThreshold;
  }

  error CollectionNotRegistered();

  event PriceFeedAdded(IERC20 indexed _erc20, address indexed _oracle);
  event FloorSubmitted(string _collectionSlug, uint256 _floor, address _submitter);
  /// @notice Emitted when threshold is changed by the admin
  event ThresholdUpdated(uint256 _oldThreshold, uint256 _newThreshold, address _collection);
}

File 20 of 20 : ErrorReporter.sol
//SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.15;

error Unauthorized();
error AccrueInterestError(Error error);
error WrongParams();
error Unexpected(string error);
error InvalidCoupon();
error ControllerError(Error error);
error AdminError(Error error);
error MarketError(Error error);
error HTokenError(Error error);
error LiquidatorError(Error error);
error ControlPanelError(Error error);
error HTokenFactoryError(Error error);
error PausedAction();
error NotOwner();
error ExternalFailure(string error);
error Initialized();
error Uninitialized();
error OracleNotUpdated();
error TransferError();
error StalePrice();

/**
 * @title   Errors reported across Honey Labs Inc. contracts
 * @author  Honey Labs Inc.
 * @custom:coauthor BowTiedPickle
 * @custom:coauthor m4rio
 */
enum Error {
  UNAUTHORIZED, //0
  INSUFFICIENT_LIQUIDITY,
  INVALID_COLLATERAL_FACTOR,
  MAX_MARKETS_IN,
  MARKET_NOT_LISTED,
  MARKET_ALREADY_LISTED, //5
  MARKET_CAP_BORROW_REACHED,
  MARKET_NOT_FRESH,
  PRICE_ERROR,
  BAD_INPUT,
  AMOUNT_ZERO, //10
  NO_DEBT,
  LIQUIDATION_NOT_ALLOWED,
  WITHDRAW_NOT_ALLOWED,
  INITIAL_EXCHANGE_MANTISSA,
  TRANSFER_ERROR, //15
  COUPON_LOOKUP,
  TOKEN_INSUFFICIENT_CASH,
  BORROW_RATE_TOO_BIG,
  NONZERO_BORROW_BALANCE,
  AMOUNT_TOO_BIG, //20
  AUCTION_NOT_ACTIVE,
  AUCTION_FINISHED,
  AUCTION_NOT_FINISHED,
  AUCTION_BID_TOO_LOW,
  AUCTION_NO_BIDS, //25
  CLAWBACK_WINDOW_EXPIRED,
  CLAWBACK_WINDOW_NOT_EXPIRED,
  REFUND_NOT_OWED,
  TOKEN_LOOKUP_ERROR,
  INSUFFICIENT_WINNING_BID, //30
  TOKEN_DEBT_NONEXISTENT,
  AUCTION_SETTLE_FORBIDDEN,
  NFT20_PAIR_NOT_FOUND,
  NFTX_PAIR_NOT_FOUND,
  TOKEN_NOT_PRESENT, //35
  CANCEL_TOO_SOON,
  AUCTION_USER_NOT_FOUND,
  NOT_FOUND,
  INVALID_MAX_LTV_FACTOR,
  BALANCE_INSUFFICIENT, //40
  ORACLE_NOT_SET,
  MARKET_INVALID,
  FACTORY_INVALID_COLLATERAL,
  FACTORY_INVALID_UNDERLYING,
  FACTORY_INVALID_ORACLE, //45
  FACTORY_DEPLOYMENT_FAILED,
  REPAY_NOT_ALLOWED,
  NONZERO_UNDERLYING_BALANCE,
  INVALID_ACTION,
  ORACLE_IS_PRESENT, //50
  FACTORY_INVALID_UNDERLYING_DECIMALS,
  FACTORY_INVALID_INTEREST_RATE_MODEL
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IERC20","name":"_weth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CollectionNotRegistered","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[{"internalType":"string","name":"error","type":"string"}],"name":"Unexpected","type":"error"},{"inputs":[],"name":"WrongParams","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"_collectionSlug","type":"string"},{"indexed":false,"internalType":"uint256","name":"_floor","type":"uint256"},{"indexed":false,"internalType":"address","name":"_submitter","type":"address"}],"name":"FloorSubmitted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"_erc20","type":"address"},{"indexed":true,"internalType":"address","name":"_oracle","type":"address"}],"name":"PriceFeedAdded","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":false,"internalType":"uint256","name":"_oldThreshold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_newThreshold","type":"uint256"},{"indexed":false,"internalType":"address","name":"_collection","type":"address"}],"name":"ThresholdUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"CREATOR_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":"SUBMITTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_erc20","type":"address"},{"internalType":"address","name":"_oracle","type":"address"}],"name":"_addPriceFeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newThreshold","type":"uint256"},{"internalType":"address","name":"_collection","type":"address"}],"name":"_setUpdateThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_shouldUnpause","type":"bool"}],"name":"_triggerPause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"collections","outputs":[{"internalType":"bool","name":"paused","type":"bool"},{"internalType":"uint16","name":"twapRange","type":"uint16"},{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"uint256","name":"updateThreshold","type":"uint256"},{"internalType":"string","name":"collectionSlug","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"floorPrices","outputs":[{"internalType":"uint96","name":"insertedAt","type":"uint96"},{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"lastMean","type":"uint256"},{"internalType":"address","name":"submitter","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_decimals","type":"uint256"}],"name":"getEthPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"_decimals","type":"uint256"}],"name":"getFloorPrice","outputs":[{"internalType":"uint128","name":"","type":"uint128"},{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"_start","type":"uint256"},{"internalType":"uint256","name":"_length","type":"uint256"}],"name":"getFloorPricesForCollection","outputs":[{"components":[{"internalType":"uint96","name":"insertedAt","type":"uint96"},{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"lastMean","type":"uint256"},{"internalType":"address","name":"submitter","type":"address"}],"internalType":"struct PermissionlessOracle.FloorPrice[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collection","type":"address"}],"name":"getLastUpdated","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"getNoOfFloors","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_erc20","type":"address"},{"internalType":"uint256","name":"_decimals","type":"uint256"}],"name":"getUnderlyingPriceInUSD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"name":"priceFeeds","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_addresses","type":"address[]"},{"internalType":"string[]","name":"_collectionSlugs","type":"string[]"},{"internalType":"uint16[]","name":"_twapRanges","type":"uint16[]"},{"internalType":"uint256[]","name":"_updateThresholds","type":"uint256[]"}],"name":"registerCollections","outputs":[],"stateMutability":"nonpayable","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":"_addresses","type":"address[]"},{"internalType":"uint256[]","name":"_floors","type":"uint256[]"}],"name":"submitFloors","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collection","type":"address"}],"name":"updateThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

60a06040523480156200001157600080fd5b50604051620027033803806200270383398101604081905262000034916200021a565b6002805460ff191690556200004b600033620000b5565b620000777fe1a65d1a914580ff6931bc952f0fb26573e9282358a4458bceb9ccc6d923d04133620000b5565b620000a37f828634d95e775031b9ff576b159a8509d3053581a8c9c4d7d86899e0afcd882f33620000b5565b6001600160a01b03166080526200024c565b620000c18282620000c5565b5050565b620000dc82826200010860201b6200147c1760201c565b6000828152600160209081526040909120620001039183906200151a620001a8821b17901c565b505050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16620000c1576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620001643390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000620001bf836001600160a01b038416620001c8565b90505b92915050565b60008181526001830160205260408120546200021157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620001c2565b506000620001c2565b6000602082840312156200022d57600080fd5b81516001600160a01b03811681146200024557600080fd5b9392505050565b6080516124946200026f600039600081816102a501526111a201526124946000f3fe608060405234801561001057600080fd5b50600436106101ce5760003560e01c80637996eef0116101045780639dcb511a116100a2578063c2803a9c11610071578063c2803a9c146104cb578063ca15c87314610518578063d547741f1461052b578063ef12969b1461053e57600080fd5b80639dcb511a1461044e578063a1718c3d14610477578063a217fddf146104a3578063b8286204146104ab57600080fd5b80638aeda25a116100de5780638aeda25a146103b65780639010d07c146103dd57806391712a0b146103f057806391d148541461041757600080fd5b80637996eef0146103545780637ef9a34414610390578063870d365d146103a357600080fd5b806336568abe1161017157806354fd4d501161014b57806354fd4d50146103035780635847e2c11461030d5780635c975abb146103365780635edd4cde1461034157600080fd5b806336568abe1461028d5780633fc8cef3146102a057806343add2e6146102df57600080fd5b8063248a9ca3116101ad578063248a9ca314610223578063297b5180146102545780632aa71cda146102675780632f2ff15d1461027a57600080fd5b80627a3e13146101d357806301ffc9a7146101e8578063067b6b8514610210575b600080fd5b6101e66101e1366004611b2a565b610551565b005b6101fb6101f6366004611b5a565b610656565b60405190151581526020015b60405180910390f35b6101e661021e366004611bc9565b610681565b610246610231366004611c35565b60009081526020819052604090206001015490565b604051908152602001610207565b610246610262366004611c4e565b610a87565b6101e6610275366004611c7a565b610c73565b6101e6610288366004611b2a565b610cd6565b6101e661029b366004611b2a565b610d00565b6102c77f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610207565b6102f26102ed366004611ca8565b610d7e565b604051610207959493929190611d21565b610246620f424081565b61024661031b366004611ca8565b6001600160a01b031660009081526004602052604090205490565b60025460ff166101fb565b6101e661034f366004611d66565b610e48565b610367610362366004611c4e565b61108b565b604080516fffffffffffffffffffffffffffffffff938416815292909116602083015201610207565b6101e661039e366004611e2a565b61117a565b6102466103b1366004611c35565b61119b565b6102467f828634d95e775031b9ff576b159a8509d3053581a8c9c4d7d86899e0afcd882f81565b6102c76103eb366004611e4c565b6111c7565b6102467fe1a65d1a914580ff6931bc952f0fb26573e9282358a4458bceb9ccc6d923d04181565b6101fb610425366004611b2a565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6102c761045c366004611ca8565b6005602052600090815260409020546001600160a01b031681565b610246610485366004611ca8565b6001600160a01b031660009081526003602052604090206001015490565b610246600081565b6104be6104b9366004611e6e565b6111e6565b6040516102079190611ea3565b6104de6104d9366004611c4e565b611385565b604080516001600160601b0390961686526001600160a01b039485166020870152850192909252606084015216608082015260a001610207565b610246610526366004611c35565b6113ea565b6101e6610539366004611b2a565b611401565b61024661054c366004611ca8565b611426565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff161580156105bf57503360009081527ffb6cfbf0a6e77dfd309859bf4bad2c7342bd2b734e42c01cbc85d3e6dd74f95e602052604090205460ff16155b156105dc576040516282b42960e81b815260040160405180910390fd5b6001600160a01b03811660008181526003602090815260409182902060010154825190815290810185905280820192909252517fe53e8c6a30ef6e59f159bf5957bdaed1516424159dfab93fc60eb745805d654b9181900360600190a16001600160a01b0316600090815260036020526040902060010155565b60006001600160e01b03198216635a05180f60e01b148061067b575061067b8261152f565b92915050565b610689611564565b7fe1a65d1a914580ff6931bc952f0fb26573e9282358a4458bceb9ccc6d923d0416106b3816115ac565b8382146106d357604051635863f78960e01b815260040160405180910390fd5b60005b84811015610a7f5760008686838181106106f2576106f2611f26565b90506020020160208101906107079190611ca8565b6001600160a01b0380821660009081526003602052604090205491925063010000009091041661074a57604051632a5cc95960e21b815260040160405180910390fd5b6001600160a01b038116600090815260036020908152604080832060049092528220548154919291610100900461ffff16808210156108c4576001600160a01b038516600081815260046020908152604091829020825160a0810184526001600160601b0342168152918201939093529081018b8b8a8181106107cf576107cf611f26565b60209081029290920135835250600082820181905233604093840152845460018082018755958252908290208451928501516001600160601b03909316600160601b6001600160a01b03948516021760049092020190815591830151938201939093556060820151600280830191909155608090920151600390910180546001600160a01b03191691909316179091557f7a8308bb6ef77c3689a00b87a3a4850dc81293de85069b789a1223205f5425599085018a8a8981811061089557610895611f26565b90506020020135336040516108ac93929190611f76565b60405180910390a185600101955050505050506106d6565b60015b818111610927576001600160a01b03861660009081526004602052604090206108f08285612030565b8154811061090057610900611f26565b9060005260206000209060040201600101548461091d9190612047565b93506001016108c7565b5088888781811061093a5761093a611f26565b905060200201358361094c9190612047565b925060046000866001600160a01b03166001600160a01b031681526020019081526020016000206040518060a00160405280426001600160601b03168152602001876001600160a01b031681526020018b8b8a8181106109ae576109ae611f26565b90506020020135815260200183866109c6919061205f565b8152336020918201528254600180820185556000948552938290208351928401516001600160601b03909316600160601b6001600160a01b0394851602176004909202019081556040830151938101939093556060820151600280850191909155608090920151600390930180546001600160a01b03191693909116929092179091557f7a8308bb6ef77c3689a00b87a3a4850dc81293de85069b789a1223205f5425599085018a8a8981811061089557610895611f26565b505050505050565b6001600160a01b03808316600090815260056020908152604080832054815163313ce56760e01b815291519394859491169263313ce56792600480820193918290030181865afa158015610adf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b039190612081565b60ff16905060008060008060056000896001600160a01b03166001600160a01b0316815260200190815260200160002060009054906101000a90046001600160a01b03166001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610b84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba891906120c3565b9450945050935093508160001480610bc1575060008313155b80610be357508369ffffffffffffffffffff168169ffffffffffffffffffff16105b15610c2c5760405163c83ad1cd60e01b815260206004820152601360248201527250726963652064617461206973207374616c6560681b60448201526064015b60405180910390fd5b86851015610c5a579584900395610c4487600a6121f7565b610c4e9084612203565b9550505050505061067b565b95840395610c6987600a6121f7565b610c4e908461205f565b6000610c7e816115ac565b6001600160a01b0383811660008181526005602052604080822080546001600160a01b0319169487169485179055517f2940c4bfb544a4b0a5b4262767947b0acc0b8f144197528463c4d476658cff799190a3505050565b600082815260208190526040902060010154610cf1816115ac565b610cfb83836115b9565b505050565b6001600160a01b0381163314610d705760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610c23565b610d7a82826115db565b5050565b60036020526000908152604090208054600182015460028301805460ff841694610100850461ffff1694630100000090046001600160a01b031693929091610dc590611f3c565b80601f0160208091040260200160405190810160405280929190818152602001828054610df190611f3c565b8015610e3e5780601f10610e1357610100808354040283529160200191610e3e565b820191906000526020600020905b815481529060010190602001808311610e2157829003601f168201915b5050505050905085565b610e50611564565b7f828634d95e775031b9ff576b159a8509d3053581a8c9c4d7d86899e0afcd882f610e7a816115ac565b878614801590610e8a5750878414155b8015610e965750878214155b15610eb457604051635863f78960e01b815260040160405180910390fd5b60005b8881101561107f576040518060a00160405280600015158152602001878784818110610ee557610ee5611f26565b9050602002016020810190610efa9190612222565b61ffff1681526020018b8b84818110610f1557610f15611f26565b9050602002016020810190610f2a9190611ca8565b6001600160a01b03168152602001858584818110610f4a57610f4a611f26565b905060200201358152602001898984818110610f6857610f68611f26565b9050602002810190610f7a9190612246565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509390945250600392508d90508c85818110610fc757610fc7611f26565b9050602002016020810190610fdc9190611ca8565b6001600160a01b039081168252602080830193909352604091820160002084518154948601519386015162ffffff1990951690151562ffff0019161761010061ffff909416939093029290921776ffffffffffffffffffffffffffffffffffffffff000000191663010000009390911692909202919091178155606082015160018201556080820151600282019061107490826122e9565b505050600101610eb7565b50505050505050505050565b6001600160a01b03821660009081526004602052604081205481908082036110ba576000809250925050611173565b6001600160a01b03851660009081526004602052604081206110dd600184612030565b815481106110ed576110ed611f26565b60009182526020909120600490910201600281015490915060128681101561114457958690039561111f87600a6121f7565b6111299083612203565b9254929550506001600160601b039091169250611173915050565b9586039561115387600a6121f7565b61115d908361205f565b9254929550506001600160601b03909116925050505b9250929050565b6000611185816115ac565b811561119357610d7a6115fd565b610d7a61164f565b600061067b7f000000000000000000000000000000000000000000000000000000000000000083610a87565b60008281526001602052604081206111df908361168c565b9392505050565b6001600160a01b0383166000908152600460205260409020546060908084111561122357604051635863f78960e01b815260040160405180910390fd5b8061122e8486612047565b11156112415761123e8482612030565b92505b60008367ffffffffffffffff81111561125c5761125c61228d565b6040519080825280602002602001820160405280156112b557816020015b6040805160a08101825260008082526020808301829052928201819052606082018190526080820152825260001990920191018161127a5790505b509050845b84860181101561137b576001600160a01b03871660009081526004602052604090208054829081106112ee576112ee611f26565b60009182526020918290206040805160a081018252600490930290910180546001600160601b03811684526001600160a01b03600160601b90910481169484019490945260018101549183019190915260028101546060830152600301549091166080820152825183908390811061136857611368611f26565b60209081029190910101526001016112ba565b5095945050505050565b600460205281600052604060002081815481106113a157600080fd5b600091825260209091206004909102018054600182015460028301546003909301546001600160601b03831695506001600160a01b03600160601b909304831694509092911685565b600081815260016020526040812061067b90611698565b60008281526020819052604090206001015461141c816115ac565b610cfb83836115db565b6001600160a01b0381166000908152600460205260408120805461144c90600190612030565b8154811061145c5761145c611f26565b60009182526020909120600490910201546001600160601b031692915050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610d7a576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556114d63390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006111df836001600160a01b0384166116a2565b60006001600160e01b03198216637965db0b60e01b148061067b57506301ffc9a760e01b6001600160e01b031983161461067b565b60025460ff16156115aa5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610c23565b565b6115b681336116f1565b50565b6115c3828261147c565b6000828152600160205260409020610cfb908261151a565b6115e58282611764565b6000828152600160205260409020610cfb90826117e3565b6116056117f8565b6002805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b611657611564565b6002805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586116323390565b60006111df838361184a565b600061067b825490565b60008181526001830160205260408120546116e95750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561067b565b50600061067b565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610d7a5761172281611874565b61172d836020611886565b60405160200161173e9291906123a9565b60408051601f198184030181529082905262461bcd60e51b8252610c239160040161241e565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1615610d7a576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006111df836001600160a01b038416611a22565b60025460ff166115aa5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610c23565b600082600001828154811061186157611861611f26565b9060005260206000200154905092915050565b606061067b6001600160a01b03831660145b60606000611895836002612203565b6118a0906002612047565b67ffffffffffffffff8111156118b8576118b861228d565b6040519080825280601f01601f1916602001820160405280156118e2576020820181803683370190505b509050600360fc1b816000815181106118fd576118fd611f26565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061192c5761192c611f26565b60200101906001600160f81b031916908160001a9053506000611950846002612203565b61195b906001612047565b90505b60018111156119d3576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061198f5761198f611f26565b1a60f81b8282815181106119a5576119a5611f26565b60200101906001600160f81b031916908160001a90535060049490941c936119cc81612431565b905061195e565b5083156111df5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610c23565b60008181526001830160205260408120548015611b0b576000611a46600183612030565b8554909150600090611a5a90600190612030565b9050818114611abf576000866000018281548110611a7a57611a7a611f26565b9060005260206000200154905080876000018481548110611a9d57611a9d611f26565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611ad057611ad0612448565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061067b565b600091505061067b565b6001600160a01b03811681146115b657600080fd5b60008060408385031215611b3d57600080fd5b823591506020830135611b4f81611b15565b809150509250929050565b600060208284031215611b6c57600080fd5b81356001600160e01b0319811681146111df57600080fd5b60008083601f840112611b9657600080fd5b50813567ffffffffffffffff811115611bae57600080fd5b6020830191508360208260051b850101111561117357600080fd5b60008060008060408587031215611bdf57600080fd5b843567ffffffffffffffff80821115611bf757600080fd5b611c0388838901611b84565b90965094506020870135915080821115611c1c57600080fd5b50611c2987828801611b84565b95989497509550505050565b600060208284031215611c4757600080fd5b5035919050565b60008060408385031215611c6157600080fd5b8235611c6c81611b15565b946020939093013593505050565b60008060408385031215611c8d57600080fd5b8235611c9881611b15565b91506020830135611b4f81611b15565b600060208284031215611cba57600080fd5b81356111df81611b15565b60005b83811015611ce0578181015183820152602001611cc8565b83811115611cef576000848401525b50505050565b60008151808452611d0d816020860160208601611cc5565b601f01601f19169290920160200192915050565b851515815261ffff851660208201526001600160a01b038416604082015282606082015260a060808201526000611d5b60a0830184611cf5565b979650505050505050565b6000806000806000806000806080898b031215611d8257600080fd5b883567ffffffffffffffff80821115611d9a57600080fd5b611da68c838d01611b84565b909a50985060208b0135915080821115611dbf57600080fd5b611dcb8c838d01611b84565b909850965060408b0135915080821115611de457600080fd5b611df08c838d01611b84565b909650945060608b0135915080821115611e0957600080fd5b50611e168b828c01611b84565b999c989b5096995094979396929594505050565b600060208284031215611e3c57600080fd5b813580151581146111df57600080fd5b60008060408385031215611e5f57600080fd5b50508035926020909101359150565b600080600060608486031215611e8357600080fd5b8335611e8e81611b15565b95602085013595506040909401359392505050565b602080825282518282018190526000919060409081850190868401855b82811015611f1957815180516001600160601b03168552868101516001600160a01b0390811688870152868201518787015260608083015190870152608091820151169085015260a09093019290850190600101611ec0565b5091979650505050505050565b634e487b7160e01b600052603260045260246000fd5b600181811c90821680611f5057607f821691505b602082108103611f7057634e487b7160e01b600052602260045260246000fd5b50919050565b606081526000808554611f8881611f3c565b8060608601526080600180841660008114611faa5760018114611fc457611ff5565b60ff1985168884015283151560051b880183019550611ff5565b8a60005260208060002060005b86811015611fec5781548b8201870152908401908201611fd1565b8a018501975050505b5050505050602083018590526001600160a01b03841660408401529050949350505050565b634e487b7160e01b600052601160045260246000fd5b6000828210156120425761204261201a565b500390565b6000821982111561205a5761205a61201a565b500190565b60008261207c57634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561209357600080fd5b815160ff811681146111df57600080fd5b805169ffffffffffffffffffff811681146120be57600080fd5b919050565b600080600080600060a086880312156120db57600080fd5b6120e4866120a4565b9450602086015193506040860151925060608601519150612107608087016120a4565b90509295509295909350565b600181815b8085111561214e5781600019048211156121345761213461201a565b8085161561214157918102915b93841c9390800290612118565b509250929050565b6000826121655750600161067b565b816121725750600061067b565b81600181146121885760028114612192576121ae565b600191505061067b565b60ff8411156121a3576121a361201a565b50506001821b61067b565b5060208310610133831016604e8410600b84101617156121d1575081810a61067b565b6121db8383612113565b80600019048211156121ef576121ef61201a565b029392505050565b60006111df8383612156565b600081600019048311821515161561221d5761221d61201a565b500290565b60006020828403121561223457600080fd5b813561ffff811681146111df57600080fd5b6000808335601e1984360301811261225d57600080fd5b83018035915067ffffffffffffffff82111561227857600080fd5b60200191503681900382131561117357600080fd5b634e487b7160e01b600052604160045260246000fd5b601f821115610cfb57600081815260208120601f850160051c810160208610156122ca5750805b601f850160051c820191505b81811015610a7f578281556001016122d6565b815167ffffffffffffffff8111156123035761230361228d565b612317816123118454611f3c565b846122a3565b602080601f83116001811461234c57600084156123345750858301515b600019600386901b1c1916600185901b178555610a7f565b600085815260208120601f198616915b8281101561237b5788860151825594840194600190910190840161235c565b50858210156123995787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516123e1816017850160208801611cc5565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612412816028840160208801611cc5565b01602801949350505050565b6020815260006111df6020830184611cf5565b6000816124405761244061201a565b506000190190565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220281d898955f1e318dae36d5a62fc11c73f86e134c65cacd55b7fe39969e8c13364736f6c634300080f00330000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619

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

0000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619

-----Decoded View---------------
Arg [0] : _weth (address): 0x7ceb23fd6bc0add59e62ac25578270cff1b9f619

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.