Contract 0x0ebc7e6884f08f34b9c8180461bf7901f094fcc6

Contract Overview

Balance:
0 MATIC
Txn Hash
Method
Block
From
To
Value [Txn Fee]
0x1ca70fb6f97ace7852c2318aaa2738e1b09cb5d3894c721610f5347af8f880360x60a06040311018412023-01-18 10:42:41135 days 47 mins ago0x7a34b2f0da5ea35b5117cac735e99ba0e2aceecd IN  Create: BufferManager0 MATIC0.0058094160611.500000016
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
BufferManager

Compiler Version
v0.8.11+commit.d7f03943

Optimization Enabled:
Yes with 0 runs

Other Settings:
default evmVersion
File 1 of 31 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.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 AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
    function __AccessControl_init() internal onlyInitializing {
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    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(IAccessControlUpgradeable).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 ",
                        StringsUpgradeable.toHexString(uint160(account), 20),
                        " is missing role ",
                        StringsUpgradeable.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.
     */
    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.
     */
    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`.
     */
    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.
     *
     * [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.
     */
    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.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }

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

File 2 of 31 : IAccessControlUpgradeable.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 IAccessControlUpgradeable {
    /**
     * @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 3 of 31 : draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

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

File 4 of 31 : IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/extensions/IERC20MetadataUpgradeable.sol";

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

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.2;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
        require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");

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

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

File 7 of 31 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

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

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

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

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

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = _setInitializedVersion(1);
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        bool isTopLevelCall = _setInitializedVersion(version);
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(version);
        }
    }

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

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     */
    function _disableInitializers() internal virtual {
        _setInitializedVersion(type(uint8).max);
    }

    function _setInitializedVersion(uint8 version) private returns (bool) {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, and for the lowest level
        // of initializers, because in other contexts the contract may have been reentered.
        if (_initializing) {
            require(
                version == 1 && !AddressUpgradeable.isContract(address(this)),
                "Initializable: contract is already initialized"
            );
            return false;
        } else {
            require(_initialized < version, "Initializable: contract is already initialized");
            _initialized = version;
            return true;
        }
    }
}

File 8 of 31 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

File 9 of 31 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @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.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _paused = false;
    }

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

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

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        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());
    }

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

File 10 of 31 : IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 11 of 31 : IERC20Upgradeable.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 IERC20Upgradeable {
    /**
     * @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 12 of 31 : SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20Upgradeable {
    using AddressUpgradeable for address;

    function safeTransfer(
        IERC20Upgradeable token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20Upgradeable token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 13 of 31 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165Upgradeable {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 17 of 31 : StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

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

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

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

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

File 18 of 31 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @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] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 19 of 31 : EnumerableMapUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/structs/EnumerableMap.sol)

pragma solidity ^0.8.0;

import "./EnumerableSetUpgradeable.sol";

/**
 * @dev Library for managing an enumerable variant of Solidity's
 * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
 * type.
 *
 * Maps have the following properties:
 *
 * - Entries are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Entries are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableMap for EnumerableMap.UintToAddressMap;
 *
 *     // Declare a set state variable
 *     EnumerableMap.UintToAddressMap private myMap;
 * }
 * ```
 *
 * The following map types are supported:
 *
 * - `uint256 -> address` (`UintToAddressMap`) since v3.0.0
 * - `address -> uint256` (`AddressToUintMap`) since v4.6.0
 * - `bytes32 -> bytes32` (`Bytes32ToBytes32`) since v4.6.0
 */
library EnumerableMapUpgradeable {
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.Bytes32Set;

    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Map type with
    // bytes32 keys and values.
    // The Map implementation uses private functions, and user-facing
    // implementations (such as Uint256ToAddressMap) are just wrappers around
    // the underlying Map.
    // This means that we can only create new EnumerableMaps for types that fit
    // in bytes32.

    struct Bytes32ToBytes32Map {
        // Storage of keys
        EnumerableSetUpgradeable.Bytes32Set _keys;
        mapping(bytes32 => bytes32) _values;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(
        Bytes32ToBytes32Map storage map,
        bytes32 key,
        bytes32 value
    ) internal returns (bool) {
        map._values[key] = value;
        return map._keys.add(key);
    }

    /**
     * @dev Removes a key-value pair from a map. O(1).
     *
     * Returns true if the key was removed from the map, that is if it was present.
     */
    function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) {
        delete map._values[key];
        return map._keys.remove(key);
    }

    /**
     * @dev Returns true if the key is in the map. O(1).
     */
    function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) {
        return map._keys.contains(key);
    }

    /**
     * @dev Returns the number of key-value pairs in the map. O(1).
     */
    function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) {
        return map._keys.length();
    }

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

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) {
        bytes32 value = map._values[key];
        if (value == bytes32(0)) {
            return (contains(map, key), bytes32(0));
        } else {
            return (true, value);
        }
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) {
        bytes32 value = map._values[key];
        require(value != 0 || contains(map, key), "EnumerableMap: nonexistent key");
        return value;
    }

    /**
     * @dev Same as {_get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {_tryGet}.
     */
    function get(
        Bytes32ToBytes32Map storage map,
        bytes32 key,
        string memory errorMessage
    ) internal view returns (bytes32) {
        bytes32 value = map._values[key];
        require(value != 0 || contains(map, key), errorMessage);
        return value;
    }

    // UintToAddressMap

    struct UintToAddressMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(
        UintToAddressMap storage map,
        uint256 key,
        address value
    ) internal returns (bool) {
        return set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(UintToAddressMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

    /**
     * @dev Returns the element 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(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
        (bytes32 key, bytes32 value) = at(map._inner, index);
        return (uint256(key), address(uint160(uint256(value))));
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     *
     * _Available since v3.4._
     */
    function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
        (bool success, bytes32 value) = tryGet(map._inner, bytes32(key));
        return (success, address(uint160(uint256(value))));
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
        return address(uint160(uint256(get(map._inner, bytes32(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        UintToAddressMap storage map,
        uint256 key,
        string memory errorMessage
    ) internal view returns (address) {
        return address(uint160(uint256(get(map._inner, bytes32(key), errorMessage))));
    }

    // AddressToUintMap

    struct AddressToUintMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(
        AddressToUintMap storage map,
        address key,
        uint256 value
    ) internal returns (bool) {
        return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(AddressToUintMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

    /**
     * @dev Returns the element 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(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) {
        (bytes32 key, bytes32 value) = at(map._inner, index);
        return (address(uint160(uint256(key))), uint256(value));
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     *
     * _Available since v3.4._
     */
    function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) {
        (bool success, bytes32 value) = tryGet(map._inner, bytes32(uint256(uint160(key))));
        return (success, uint256(value));
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(AddressToUintMap storage map, address key) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(uint256(uint160(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        AddressToUintMap storage map,
        address key,
        string memory errorMessage
    ) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(uint256(uint160(key))), errorMessage));
    }
}

File 20 of 31 : EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/structs/EnumerableSet.sol)

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.
 */
library EnumerableSetUpgradeable {
    // 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) {
        return _values(set._inner);
    }

    // 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;

        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 on 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;

        assembly {
            result := store
        }

        return result;
    }
}

File 21 of 31 : 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 22 of 31 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/IERC20.sol";

File 23 of 31 : 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 24 of 31 : BufferManager.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/interfaces/IERC20MetadataUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableMapUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";

import "../../../interfaces/IPriceFeedRouter.sol";
import "../../../interfaces/ILiquidityHandler.sol";
import "../../../interfaces/IHandlerAdapter.sol";
import "../../../interfaces/IVoteExecutorSlave.sol";
import "../../../interfaces/IIbAlluo.sol";

import {ISpokePool} from "../../../interfaces/ISpokePool.sol";
import {ICallProxy} from "../../../interfaces/ICallProxy.sol";

contract BufferManager is
    Initializable,
    PausableUpgradeable,
    AccessControlUpgradeable,
    UUPSUpgradeable
{
    using AddressUpgradeable for address;
    using SafeERC20Upgradeable for IERC20Upgradeable;
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet;
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;

    event Bridge(
        address distributor,
        address originToken,
        address ethToken,
        uint256 amount,
        uint64 relayerFeePct,
        uint256[] directions,
        uint256[] percentage
    );

    bool public upgradeStatus;

    // address of the DepositDistributor on mainnet
    address public distributor;
    address public slave;
    // address of the anycall contract on polygon
    address public anycall;
    // adress of the Across bridge contract to initiate the swap
    address public spokepool;
    // address of the gnosis multisig
    address public gnosis;
    uint256 public epochDuration;
    
    // bridge settings
    uint256 public lastExecuted;
    uint256 public bridgeInterval;
    uint64 public relayerFeePct;

    bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
    bytes32 public constant GELATO = keccak256("GELATO");
    bytes32 public constant SWAPPER = keccak256("SWAPPER");

    // liquidity handler
    ILiquidityHandler public handler;

    mapping(address => Epoch[]) public ibAlluoToEpoch;
    mapping(address => address) public ibAlluoToAdapter;
    mapping(address => uint256) public ibAlluoToMaxRefillPerEpoch;
    mapping(address => address) public tokenToEth;
    mapping(address => uint256) public tokenToMinBridge;

    // EnumerableSet of currently supported IBAlluo
    EnumerableSetUpgradeable.AddressSet private activeIbAlluos;

    // Data used to prevent draining the gnosis by setting a relevant limit to be used
    struct Epoch {
        uint256 startTime;
        uint256 refilledPerEpoch;
    }

    uint256 public bridgeCap;
    uint256 public bridgeRefilled;
    // min pct of the deviation from expectedAdapterRefill to trigger the refill (with 2 decimals, e.g. 5% = 500)
    uint256 public refillThreshold; 

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() initializer {}

    /**
     * @dev
     * param _epochDuration Value for refill function to work properly
     * param _bridgeGenesis Unix timestamp declaring a starting point for counter
     * param _bridgeInterval Min time to pass between bridging (Unix timestamp)
     * param _gnosis Gnosis Multisig
     * param _spokepool Address of the SpokePool Polygon contract of Accross Protocol Bridge
     * param _anycall Address of the Multichain Anycall contract
     * param _distributor Address of the DepositDistritor contract on mainnet, which receives the bridged funds
     */
    function initialize(
        uint256 _epochDuration,
        uint256 _brigeGenesis,
        uint256 _bridgeInterval,
        address _gnosis,
        address _spokepool,
        address _anycall,
        address _distributor
    ) public initializer {
        __Pausable_init();
        __AccessControl_init();
        __UUPSUpgradeable_init();

        epochDuration = _epochDuration;
        distributor = _distributor;
        lastExecuted = _brigeGenesis;
        bridgeInterval = _bridgeInterval;

        spokepool = _spokepool;
        anycall = _anycall;
        gnosis = _gnosis;

        _grantRole(DEFAULT_ADMIN_ROLE, _gnosis);
        _grantRole(UPGRADER_ROLE, _gnosis);
        _grantRole(GELATO, _gnosis);
        _grantRole(SWAPPER, _gnosis);
    }

    /**
     * @notice Initiates transfer only if adapter is filled, there are no queued withdrawals and
     * balance of this contract exceeds the minimum required mark
     * @dev Function checker for gelato, after the balance crosses the threshold initates the swap function
     * @dev Checks minimumBridging amout, attempts to reffil the adapters
     * @return canExec Bool, if true - initiates the call by gelato
     * @return execPayload Data to be called by gelato
     */
    function checkerBridge()
        external
        view
        returns (bool canExec, bytes memory execPayload)
    {
        for (uint256 i; i < activeIbAlluos.length(); i++) {
            (address iballuo, address token, uint256 amount) = getValues(i);
            if (
                adapterRequiredRefill(iballuo) == 0 && canBridge(token, amount)
            ) {
                canExec = true;
                execPayload = abi.encodeWithSelector(
                    BufferManager.swap.selector,
                    amount,
                    token,
                    iballuo
                );

                break;
            }
        }

        return (canExec, execPayload);
    }

    /**
     * @dev Triggers GELATO to refill buffer
     * @dev Checks buffer balance, balance of the gnosis and compares if he can execute the refill
     * @return canExec bool, serves as a flag for gelato
     * @return execPayload encoded call to refillBuffer with correct values
     */
    function checkerRefill()
        external
        view
        returns (bool canExec, bytes memory execPayload)
    {
        for (uint256 i; i < activeIbAlluos.length(); i++) {
            (address iballuo, address token, ) = getValues(i);
            if (canRefill(iballuo, token)) {
                canExec = true;
                execPayload = abi.encodeWithSelector(
                    BufferManager.refillBuffer.selector,
                    iballuo
                );

                break;
            }
        }

        return (canExec, execPayload);
    }

    /**
     * @notice Function is called by gelato when checker flags it. Can only be called by
     * either Gelato or Multisig
     * @dev Bridges assets using Across Bridge by UMA Protocol (Source: https://across.to/)
     * @dev Bridges data for liquidity direction using Multichain AnyCallV6
     * @param amount Amount of the funds to be transferred
     * @param originToken Address of the token to be bridged
     */
    function swap(
        uint256 amount,
        address originToken
    ) external whenNotPaused onlyRole(SWAPPER) {
        require(
            canBridge(originToken, amount),
            "Buffer: <minAmount or <bridgeInterval"
        );

        if (block.timestamp > lastExecuted + bridgeInterval) {
            bridgeRefilled = 0;
        }
        lastExecuted = block.timestamp;
        IERC20Upgradeable(originToken).approve(spokepool, amount);
        ISpokePool(spokepool).deposit(
            distributor,
            originToken,
            amount,
            1,
            relayerFeePct,
            uint32(block.timestamp)
        );
        address tokenEth = tokenToEth[originToken];
        (
            uint256[] memory direction,
            uint256[] memory percentage
        ) = IVoteExecutorSlave(slave).getEntries();
        ICallProxy(anycall).anyCall(
            // address of the collector contract on mainnet
            distributor,
            abi.encode(direction, percentage, tokenEth, amount),
            address(0),
            1,
            // 0 flag to pay fee on destination chain
            0
        );

        emit Bridge(
            distributor,
            originToken,
            tokenEth,
            amount,
            relayerFeePct,
            direction,
            percentage
        );
    }

    /**
     * @dev Function checks if IBAlluos respective adapter has queued withdrawals
     * @param _ibAlluo Address of the IBAlluo pool
     * @return isAdapterPendingWithdrawal bool - true if there is a pending withdrawal on correspoding to an IBAlluo pool adapter
     */
    function isAdapterPendingWithdrawal(
        address _ibAlluo
    ) public view returns (bool) {
        (, , uint256 totalWithdrawalAmount, ) = handler
            .ibAlluoToWithdrawalSystems(_ibAlluo);
        if (totalWithdrawalAmount > 0) {
            return true;
        }
        return false;
    }

    /**
     * @notice Function checks the amount of asset that needs to be transferred for an adapter to be filled
     * @notice Liquidity Handler works differently for wbtc/weth and fiat-pegged assets, in first scenario getExpectedAdapteramount
     * and getAdapterAmount return token value in 18 decimals, while 2nd scenario (stablecoins) return their fiat value.
     * Function checks the adapter id and adapts the amount to the 18decimal token value format
     * @param _ibAlluo Address of an IBAlluo contract, which corresponding adapter is to be filled
     * @return requiredRefill Amount to be refilled in token with 18 decimals
     */
    function adapterRequiredRefill(
        address _ibAlluo
    ) public view returns (uint256) {
        uint256 expectedAmount = handler.getExpectedAdapterAmount(_ibAlluo, 0);
        uint256 actualAmount = handler.getAdapterAmount(_ibAlluo);
        if (actualAmount >= expectedAmount) {
            return 0;
        }
        uint256 difference = expectedAmount - actualAmount; 
        if ((difference * 10000) / expectedAmount <= refillThreshold) {
            return 0;
        } 
        uint id = ILiquidityHandler(handler).getAdapterId(_ibAlluo); // id 3 and 4 are weth and wbtc, which must not follow fiat logic
        address priceFeedRouter = IIbAlluo(_ibAlluo).priceFeedRouter();
        if (priceFeedRouter != address(0) && id!=3 && id!=4) {
            address adapter = ibAlluoToAdapter[_ibAlluo];
            address token = IHandlerAdapter(adapter).getCoreTokens();
            (uint256 price, uint8 priceDecimals) = IPriceFeedRouter(
                priceFeedRouter
            ).getPrice(token, IIbAlluo(_ibAlluo).fiatIndex());

            difference = (difference * price) / (10 ** priceDecimals);
        }
        return difference;
    }

    /**
     * @dev Function returns relevant refill settings by IBAlluo address
     * @param _ibAlluo address of the IBAlluo
     * @return Epoch struct with settings
     */

    function _confirmEpoch(address _ibAlluo) internal returns (Epoch storage) {
        Epoch[] storage relevantEpochs = ibAlluoToEpoch[_ibAlluo];
        Epoch storage lastEpoch = relevantEpochs[relevantEpochs.length - 1];
        uint256 deadline = lastEpoch.startTime + epochDuration;
        if (block.timestamp > deadline) {
            uint256 cycles = (block.timestamp - deadline) / epochDuration;
            if (cycles != 0) {
                uint256 newStartTime = lastEpoch.startTime +
                    (cycles * epochDuration);
                Epoch memory newEpoch = Epoch(newStartTime, 0);
                ibAlluoToEpoch[_ibAlluo].push(newEpoch);
            }
        }
        Epoch storage finalEpoch = relevantEpochs[relevantEpochs.length - 1];
        return finalEpoch;
    }

    /**
     * @notice adapterRequiredRefill() and deposit() operate with 18 decimals, so balances need to be adjusted
     * @dev Refills corresponding IBAlluo adapter with prior checks and triggers executing queued withdrawals on the adapter
     * @dev First checks if buffer has enough funds to refill adapter. If not - checks if funds on buffer and gnosis multisig
     * together are enough to satisfy adapters. Uses all the available funds in buffer, takes rest from gnosis.
     * @dev After successful refill calls deposit() on corresponding adapter, instructing to leave all the funds in pool.
     * If there are any queued withdrawals on adapter - satisfies them
     * @param _ibAlluo address of corresponding IBAlluo
     */
    function refillBuffer(
        address _ibAlluo
    ) external whenNotPaused onlyRole(GELATO) returns (bool) {
        uint256 totalAmount = adapterRequiredRefill(_ibAlluo);

        require(totalAmount > 0, "No refill required");

        address adapterAddress = ibAlluoToAdapter[_ibAlluo];
        address bufferToken = IHandlerAdapter(adapterAddress).getCoreTokens();
        uint256 decDif = 18 - IERC20MetadataUpgradeable(bufferToken).decimals();
        uint256 bufferBalance = IERC20Upgradeable(bufferToken).balanceOf(
            address(this)
        );
        uint256 gnosisBalance = IERC20Upgradeable(bufferToken).balanceOf(
            gnosis
        );

        bufferBalance = bufferBalance * 10 ** decDif;
        gnosisBalance = gnosisBalance * 10 ** decDif;
        // 2 percent on top to be safe against pricefeed and lp slippage
        totalAmount += (totalAmount * 200) / 10000;

        if (bufferBalance < totalAmount) {
            if (totalAmount < bufferBalance + gnosisBalance) {
                refillGnosis(
                    totalAmount,
                    bufferBalance,
                    bufferToken,
                    _ibAlluo,
                    adapterAddress,
                    decDif
                );
                return true;
            } else {
                return false;
            }
        } else {
        bridgeRefilled += totalAmount;
        IERC20Upgradeable(bufferToken).transfer(adapterAddress, totalAmount / 10 ** decDif);
        IHandlerAdapter(adapterAddress).deposit(bufferToken, totalAmount, totalAmount);
        if (isAdapterPendingWithdrawal(_ibAlluo)) {
            handler.satisfyAdapterWithdrawals(_ibAlluo);
        }
        return true;
        }
    }

    /**
     * @notice All the amounts are 18 decimals
     * @dev Internal function called by refillBuffer() in a scenario of using gnosis funds to execute the refill
     * @param totalAmount Required amount to fully refill the adapter
     * @param bufferBalance Amount of the asset on buffer
     * @param bufferToken Address of the token used to refill
     * @param ibAlluo Address of the ibAlluo binded to the adapter
     * @param adapterAddress Address of the adapter to be refilled
     * @param decDif Decimal difference, see notice in refillBuffer() for details
     */
    function refillGnosis(
        uint256 totalAmount,
        uint256 bufferBalance,
        address bufferToken,
        address ibAlluo,
        address adapterAddress,
        uint256 decDif
    ) internal {
        uint256 gnosisAmount = totalAmount - bufferBalance;

        Epoch storage currentEpoch = _confirmEpoch(ibAlluo);

        require(
            ibAlluoToMaxRefillPerEpoch[ibAlluo] >=
                currentEpoch.refilledPerEpoch + gnosisAmount,
            "Cumulative refills exceeds limit"
        );

        currentEpoch.refilledPerEpoch += gnosisAmount;
        bridgeRefilled += totalAmount;
        IERC20Upgradeable(bufferToken).transferFrom(
            gnosis,
            adapterAddress,
            gnosisAmount / 10 ** decDif
        );
        if (gnosisAmount != totalAmount) {
            IERC20Upgradeable(bufferToken).transfer(
                adapterAddress,
                bufferBalance / 10 ** decDif
            );
        }
        IHandlerAdapter(adapterAddress).deposit(
            bufferToken,
            totalAmount,
            totalAmount
        );
        if (isAdapterPendingWithdrawal(ibAlluo)) {
            handler.satisfyAdapterWithdrawals(ibAlluo);
        }
    }

    /**
     * @dev View function to trigger bridging
     * @param token Token to bridge
     * @param amount Amount to bridge
     */
    function canBridge(
        address token,
        uint256 amount
    ) public view returns (bool) {
        uint256 amount18 = amount *
            10 ** (18 - IERC20MetadataUpgradeable(token).decimals());
        if (
            amount >= tokenToMinBridge[token] &&
            block.timestamp >= lastExecuted + bridgeInterval &&
            bridgeRefilled + amount18 <= bridgeCap
        ) {
            return true;
        }
        return false;
    }

    /**
     * @dev View function to trigger refillBuffer
     * @param _iballuo Address of the IBAlluo
     * @param token Address of the correspondin primary token of the pool
     */
    function canRefill(
        address _iballuo,
        address token
    ) public view returns (bool) {
        uint256 balance = IERC20Upgradeable(token).balanceOf(address(this));
        uint256 decDif = 18 - IERC20MetadataUpgradeable(token).decimals();
        uint256 gnosisBalance = IERC20Upgradeable(token).balanceOf(gnosis);
        balance = balance * 10 ** decDif;
        gnosisBalance = gnosisBalance * 10 ** decDif;
        uint256 refill = adapterRequiredRefill(_iballuo);
        if (refill > 0 && refill < gnosisBalance + balance) {
            return true;
        }
        return false;
    }

    /**
     * @dev Internal function for readabilty of checker functions
     * @param i Index in a loop in checkerRefill and checkerBridge
     */
    function getValues(
        uint256 i
    ) internal view returns (address, address, uint256) {
        address iballuo = activeIbAlluos.at(i);
        address token = IHandlerAdapter(ibAlluoToAdapter[iballuo])
            .getCoreTokens();
        uint256 amount = IERC20Upgradeable(token).balanceOf(address(this));

        return (iballuo, token, amount);
    }

    /**
     * @notice Initialize function faces stack too deep error, due to too many arguments. Used to safely set-up/upgrage
     * iballuos and corresponding settings
     * @param _activeIbAlluos Array of IBAlluo contract supported for bridging
     * @param _ibAlluoAdapters Array of corresponding Adapters
     * @param _tokensEth Addresses of the same tokens on mainnet
     * @param _minBridgeAmount Min amount of asset to trigget bridging for each of the iballuo
     * @param _maxRefillPerEpoch Max value of asset for an adapter to be filled in span of a predefined interval
     */
    function initializeValues(
        address _handler,
        address[] memory _activeIbAlluos,
        address[] memory _ibAlluoAdapters,
        address[] memory _tokensEth,
        uint256[] memory _minBridgeAmount,
        uint256[] memory _maxRefillPerEpoch,
        uint256 _epochDuration
    ) public onlyRole(DEFAULT_ADMIN_ROLE) {
        handler = ILiquidityHandler(_handler);

        for (uint256 i; i < _activeIbAlluos.length; i++) {
            activeIbAlluos.add(_activeIbAlluos[i]);
            ibAlluoToAdapter[_activeIbAlluos[i]] = _ibAlluoAdapters[i];
            address token = IHandlerAdapter(_ibAlluoAdapters[i])
                .getCoreTokens();
            tokenToMinBridge[token] = _minBridgeAmount[i];
            tokenToEth[token] = _tokensEth[i];
            ibAlluoToMaxRefillPerEpoch[_activeIbAlluos[i]] = _maxRefillPerEpoch[
                i
            ];
            epochDuration = _epochDuration;

            Epoch memory newEpoch = Epoch(block.timestamp, 0);
            ibAlluoToEpoch[_activeIbAlluos[i]].push(newEpoch);
        }
    }

    /* ========== ADMIN CONFIGURATION ========== */

    /**
     * @dev Admin function to change bridge interval
     * @param _bridgeInterval interval in seconds, to put limitations for an amount to be bridged
     */
    function changeBridgeInterval(
        uint256 _bridgeInterval
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        bridgeInterval = _bridgeInterval;
    }

    /**
     * @dev Admin function to set minimum amount for each token that will serve as threshold to trigger bridging
     * @param _token Address of the token
     * @param _minAmount Minimum amount to allow bridging
     */
    function setMinBridgeAmount(
        address _token,
        uint256 _minAmount
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        tokenToMinBridge[_token] = _minAmount;
    }

    /**
    * @dev Admin function to set bridge cap
    * @param _cap Max amount that can be bridged per interval
    */
    function setBridgeCap(uint256 _cap) external onlyRole(DEFAULT_ADMIN_ROLE) {
        bridgeCap = _cap;
    }

    /**
     * @dev Admin function to manually set relayersFeePct for bridging
     * @param _relayerFeePct relayerFeePct in uint64
     */
    function setRelayerFeePct(
        uint64 _relayerFeePct
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        relayerFeePct = _relayerFeePct;
    }

    /**
     * @dev Admin function to change the address of VoteExecutorSlave contract
     * @param _slave Address of the VoteExecutorSlave contract
     */
    function setVoteExecutorSlave(
        address _slave
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        slave = _slave;
    }

    /**
     * @dev Admin function to set anycall contract address
     * @param _anycall Address of the anycall contract
     */
    function setAnycall(
        address _anycall
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        anycall = _anycall;
    }

    /**
     * @dev Admin function to set Distributor contract address
     * @param _distributor Address of the Distributor contract on ETH mainnet
     */
    function setDistributor(
        address _distributor
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        distributor = _distributor;
    }

    /**
     * @notice Needed for bridging
     * @dev Admin function to change the address of the respective token on Mainnet
     * @param _token address of the token on Polygon
     * @param _tokenEth address of the same token on Mainnet
     */
    function setEthToken(
        address _token,
        address _tokenEth
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        tokenToEth[_token] = _tokenEth;
    }

    /**
     * @dev Admin function for setting max amount an adapter can be refilled per interval
     * @param _ibAlluo address of the IBAlluo of the respective adapter
     * @param _maxRefillPerEpoch max amount to be refilled
     */
    function setMaxRefillPerEpoch(
        address _ibAlluo,
        uint256 _maxRefillPerEpoch
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        ibAlluoToMaxRefillPerEpoch[_ibAlluo] = _maxRefillPerEpoch;
    }

    /**
    * @notice Prevents buffer from refilling adapters with "dust" amount
    * @dev Admin function to set a minimum deviation from expectedAdapterAmount that would trigger a refill
    * @param _pct Minimum percentage of deviation to trigger the refill (format: 5% = 500)
    */
    function setRefillThresholdPct(uint _pct) external onlyRole(DEFAULT_ADMIN_ROLE) {
        refillThreshold = _pct;
    }

    /**
     * @dev Admin function for setting the aforementioned interval
     * @param _epochDuration time of the epoch in seconds
     */
    function setEpochDuration(
        uint256 _epochDuration
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        epochDuration = _epochDuration;
    }

    /**
     * @notice Function is called by gnosis
     * @dev Adds IBAlluo pool to the list of active pools
     * @param ibAlluo Address of the IBAlluo pool to be added
     */
    function addIBAlluoPool(
        address ibAlluo,
        address adapter
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(!activeIbAlluos.contains(ibAlluo), "Already active");

        activeIbAlluos.add(ibAlluo);
        ibAlluoToAdapter[ibAlluo] = adapter;
    }

    /**
     * @notice Funtion is called by gnosis
     * @dev Removes IBAlluo pool from the list of active pools
     * @param ibAlluo Address of the IBAlluo pool to be removed
     */
    function removeIBAlluoPool(
        address ibAlluo
    ) external onlyRole(DEFAULT_ADMIN_ROLE) returns (bool) {
        bool removed;
        for (uint256 i = 0; i < activeIbAlluos.length(); i++) {
            if (activeIbAlluos.at(i) == ibAlluo) {
                activeIbAlluos.remove(activeIbAlluos.at(i));
                ibAlluoToAdapter[ibAlluo] = address(0);
                removed = true;
            }
        }
        return removed;
    }

    // @notice if _amount == 0 withdraws all
    function emergencyWithdrawal(address _token, uint256 _amount) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if(_amount != 0){
        IERC20Upgradeable(_token).transfer(msg.sender, _amount);
        } else {
            IERC20Upgradeable(_token).transfer(msg.sender, IERC20Upgradeable(_token).balanceOf(address(this)));
        }
    }

    function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {
        _pause();
    }

    function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {
        _unpause();
    }

    function changeUpgradeStatus(
        bool _status
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        upgradeStatus = _status;
    }

    function _authorizeUpgrade(
        address newImplementation
    ) internal override onlyRole(UPGRADER_ROLE) {
        require(upgradeStatus, "Manager: Upgrade not allowed");
        upgradeStatus = false;
    }
}

File 25 of 31 : ICallProxy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

interface ICallProxy {
    function anyCall(
        address _to,
        bytes calldata _data,
        address _fallback,
        uint256 _toChainID,
        uint256 _flags
    ) external;
}

File 26 of 31 : IHandlerAdapter.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.11;

interface IHandlerAdapter {
    function deposit(
        address _token,
        uint256 fullAmount,
        uint256 leaveInPool
    ) external;

    function withdraw(address _user, address _token, uint256 _amount) external;

    function getAdapterAmount() external view returns (uint256);

    function getCoreTokens() external view returns (address primaryToken);

    function setSlippage(uint64 _newSlippage) external;

    function setWallet(address _newWallet) external;
}

File 27 of 31 : IIbAlluo.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

import "@openzeppelin/contracts/interfaces/IERC20.sol";
import "@openzeppelin/contracts/access/IAccessControl.sol";

interface IIbAlluo is IERC20, IAccessControl {
    function annualInterest() external view returns (uint256);

    function approveAssetValue(
        address spender,
        uint256 amount
    ) external returns (bool);

    function burn(address account, uint256 amount) external;

    function changeTokenStatus(address _token, bool _status) external;

    function changeUpgradeStatus(bool _status) external;

    function decreaseAllowance(
        address spender,
        uint256 subtractedValue
    ) external returns (bool);

    function deposit(address _token, uint256 _amount) external;

    function getBalance(address _address) external view returns (uint256);

    function getBalanceForTransfer(
        address _address
    ) external view returns (uint256);

    function getListSupportedTokens() external view returns (address[] memory);

    function growingRatio() external view returns (uint256);

    function interestPerSecond() external view returns (uint256);

    function lastInterestCompound() external view returns (uint256);

    function liquidityBuffer() external view returns (address);

    function mint(address account, uint256 amount) external;

    function pause() external;

    function unpause() external;

    function paused() external view returns (bool);

    function setInterest(
        uint256 _newAnnualInterest,
        uint256 _newInterestPerSecond
    ) external;

    function setLiquidityBuffer(address newBuffer) external;

    function setUpdateTimeLimit(uint256 _newLimit) external;

    function totalAssetSupply() external view returns (uint256);

    function transferAssetValue(
        address to,
        uint256 amount
    ) external returns (bool);

    function transferFromAssetValue(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);

    function updateRatio() external;

    function updateTimeLimit() external view returns (uint256);

    function upgradeStatus() external view returns (bool);

    function withdraw(address _targetToken, uint256 _amount) external;

    function withdrawTo(
        address _recipient,
        address _targetToken,
        uint256 _amount
    ) external;

    function stopFlowWhenCritical(address sender, address receiver) external;

    function forceWrap(address sender) external;

    function superToken() external view returns (address);

    function priceFeedRouter() external view returns (address);

    function fiatIndex() external view returns (uint256);

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

File 28 of 31 : ILiquidityHandler.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.11;

import "@openzeppelin/contracts/access/IAccessControl.sol";

interface ILiquidityHandler is IAccessControl {
    function adapterIdsToAdapterInfo(
        uint256
    )
        external
        view
        returns (
            string memory name,
            uint256 percentage,
            address adapterAddress,
            bool status
        );

    function changeAdapterStatus(uint256 _id, bool _status) external;

    function changeUpgradeStatus(bool _status) external;

    function deposit(address _token, uint256 _amount) external;

    function deposit(
        address _token,
        uint256 _amount,
        address _targetToken
    ) external;

    function getActiveAdapters()
        external
        view
        returns (
            ILiquidityHandlerStructs.AdapterInfo[] memory,
            address[] memory
        );

    function getAdapterAmount(address _ibAlluo) external view returns (uint256);

    function getAdapterId(address _ibAlluo) external view returns (uint256);

    function getAllAdapters()
        external
        view
        returns (
            ILiquidityHandlerStructs.AdapterInfo[] memory,
            address[] memory
        );

    function getExpectedAdapterAmount(
        address _ibAlluo,
        uint256 _newAmount
    ) external view returns (uint256);

    function getIbAlluoByAdapterId(
        uint256 _adapterId
    ) external view returns (address);

    function getLastAdapterIndex() external view returns (uint256);

    function getListOfIbAlluos() external view returns (address[] memory);

    function getWithdrawal(
        address _ibAlluo,
        uint256 _id
    ) external view returns (ILiquidityHandlerStructs.Withdrawal memory);

    function ibAlluoToWithdrawalSystems(
        address
    )
        external
        view
        returns (
            uint256 lastWithdrawalRequest,
            uint256 lastSatisfiedWithdrawal,
            uint256 totalWithdrawalAmount,
            bool resolverTrigger
        );

    function isUserWaiting(
        address _ibAlluo,
        address _user
    ) external view returns (bool);

    function pause() external;

    function paused() external view returns (bool);

    function removeTokenByAddress(
        address _address,
        address _to,
        uint256 _amount
    ) external;

    function satisfyAdapterWithdrawals(address _ibAlluo) external;

    function satisfyAllWithdrawals() external;

    function setAdapter(
        uint256 _id,
        string memory _name,
        uint256 _percentage,
        address _adapterAddress,
        bool _status
    ) external;

    function setIbAlluoToAdapterId(
        address _ibAlluo,
        uint256 _adapterId
    ) external;

    function supportsInterface(bytes4 interfaceId) external view returns (bool);

    function upgradeStatus() external view returns (bool);

    function withdraw(
        address _user,
        address _token,
        uint256 _amount
    ) external;

    function withdraw(
        address _user,
        address _token,
        uint256 _amount,
        address _outputToken
    ) external;

    function getAdapterCoreTokensFromIbAlluo(
        address _ibAlluo
    ) external view returns (address);
}

interface ILiquidityHandlerStructs {
    struct AdapterInfo {
        string name;
        uint256 percentage;
        address adapterAddress;
        bool status;
    }

    struct Withdrawal {
        address user;
        address token;
        uint256 amount;
        uint256 time;
    }
}

File 29 of 31 : IPriceFeedRouter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

interface IPriceFeedRouter {
    function getPrice(
        address token,
        string calldata fiatName
    ) external returns (uint256 value, uint8 decimals);

    function getPrice(
        address token,
        uint256 fiatId
    ) external view returns (uint256 value, uint8 decimals);

    function setCrytoStrategy(address strategy, address coin) external;

    function setFiatStrategy(
        string calldata fiatSymbol,
        uint256 fiatId,
        address fiatFeed
    ) external;

    function transferOwnership(address newOwner) external;
}

File 30 of 31 : ISpokePool.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;

interface ISpokePool {
    function deposit(
        address recipient,
        address originToken,
        uint256 amount,
        uint256 destinationChainId,
        uint64 relayerFeePct,
        uint32 quoteTimestamp
    ) external payable;

    function speedUpDeposit(
        address depositor,
        uint64 newRelayerFeePct,
        uint32 depositId,
        bytes memory depositorSignature
    ) external;
}

File 31 of 31 : IVoteExecutorSlave.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.11;

interface IVoteExecutorSlave {
    struct Entry {
        uint256 directionId;
        uint256 percent;
    }

    function getEntries() external returns (uint256[] memory, uint256[] memory);
}

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

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"distributor","type":"address"},{"indexed":false,"internalType":"address","name":"originToken","type":"address"},{"indexed":false,"internalType":"address","name":"ethToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"relayerFeePct","type":"uint64"},{"indexed":false,"internalType":"uint256[]","name":"directions","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"percentage","type":"uint256[]"}],"name":"Bridge","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GELATO","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SWAPPER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_ibAlluo","type":"address"}],"name":"adapterRequiredRefill","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"ibAlluo","type":"address"},{"internalType":"address","name":"adapter","type":"address"}],"name":"addIBAlluoPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"anycall","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridgeCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridgeInterval","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridgeRefilled","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"canBridge","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_iballuo","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"canRefill","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_bridgeInterval","type":"uint256"}],"name":"changeBridgeInterval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_status","type":"bool"}],"name":"changeUpgradeStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"checkerBridge","outputs":[{"internalType":"bool","name":"canExec","type":"bool"},{"internalType":"bytes","name":"execPayload","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"checkerRefill","outputs":[{"internalType":"bool","name":"canExec","type":"bool"},{"internalType":"bytes","name":"execPayload","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"distributor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"emergencyWithdrawal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"epochDuration","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":[],"name":"gnosis","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[],"name":"handler","outputs":[{"internalType":"contract ILiquidityHandler","name":"","type":"address"}],"stateMutability":"view","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":[{"internalType":"address","name":"","type":"address"}],"name":"ibAlluoToAdapter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"ibAlluoToEpoch","outputs":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"refilledPerEpoch","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"ibAlluoToMaxRefillPerEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_epochDuration","type":"uint256"},{"internalType":"uint256","name":"_brigeGenesis","type":"uint256"},{"internalType":"uint256","name":"_bridgeInterval","type":"uint256"},{"internalType":"address","name":"_gnosis","type":"address"},{"internalType":"address","name":"_spokepool","type":"address"},{"internalType":"address","name":"_anycall","type":"address"},{"internalType":"address","name":"_distributor","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_handler","type":"address"},{"internalType":"address[]","name":"_activeIbAlluos","type":"address[]"},{"internalType":"address[]","name":"_ibAlluoAdapters","type":"address[]"},{"internalType":"address[]","name":"_tokensEth","type":"address[]"},{"internalType":"uint256[]","name":"_minBridgeAmount","type":"uint256[]"},{"internalType":"uint256[]","name":"_maxRefillPerEpoch","type":"uint256[]"},{"internalType":"uint256","name":"_epochDuration","type":"uint256"}],"name":"initializeValues","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_ibAlluo","type":"address"}],"name":"isAdapterPendingWithdrawal","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastExecuted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_ibAlluo","type":"address"}],"name":"refillBuffer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"refillThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"relayerFeePct","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"ibAlluo","type":"address"}],"name":"removeIBAlluoPool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"_anycall","type":"address"}],"name":"setAnycall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_cap","type":"uint256"}],"name":"setBridgeCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_distributor","type":"address"}],"name":"setDistributor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_epochDuration","type":"uint256"}],"name":"setEpochDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_tokenEth","type":"address"}],"name":"setEthToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_ibAlluo","type":"address"},{"internalType":"uint256","name":"_maxRefillPerEpoch","type":"uint256"}],"name":"setMaxRefillPerEpoch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_minAmount","type":"uint256"}],"name":"setMinBridgeAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pct","type":"uint256"}],"name":"setRefillThresholdPct","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"_relayerFeePct","type":"uint64"}],"name":"setRelayerFeePct","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_slave","type":"address"}],"name":"setVoteExecutorSlave","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"slave","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"spokepool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"originToken","type":"address"}],"name":"swap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenToEth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenToMinBridge","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"upgradeStatus","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]

60a0604052306080523480156200001557600080fd5b5060006200002460016200008b565b905080156200003d576000805461ff0019166101001790555b801562000084576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5062000195565b60008054610100900460ff1615620000f4578160ff166001148015620000c45750620000c2306200013860201b620027511760201c565b155b620000ec5760405162461bcd60e51b8152600401620000e39062000147565b60405180910390fd5b506000919050565b60005460ff8084169116106200011e5760405162461bcd60e51b8152600401620000e39062000147565b506000805460ff191660ff92909216919091179055600190565b6001600160a01b03163b151590565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b608051614496620001cd600039600081816112ef0152818161132f015281816113fa0152818161143a01526114b201526144966000f3fe6080604052600436106102a75760003560e01c806301ffc9a7146102ac5780630810cf22146102e157806309077c09146103035780630a971d81146103285780630c31900c146103485780630e8ff1e7146103685780630fc654071461037f578063163e691c1461039f5780631c15ff77146103d85780631f8bd144146103ef57806320412d721461040f5780632143d0331461043d578063238c8aad14610454578063248a9ca3146104825780632f2ff15d146104a257806330024dfe146104c25780633095634a146104e257806331b36b3d14610502578063324e92931461052557806336568abe1461055a5780633659cfe61461057a578063365ba6ce1461059a5780633d5302ae146105d15780633f4ba83a146105f15780633fcdc0d714610606578063430a5df71461063d5780634f1ef2861461065e5780634ff0876a1461067157806352d1902d14610688578063547cde5e1461069d57806357d9989c146106bd5780635ac3a79f146106dd5780635c975abb146106fd578063700d85ae1461071557806375619ab5146107375780637895876f146107575780638456cb591461076c578063877721af146107815780638d18138c146107a157806391d14854146107c1578063a217fddf146107e1578063b8e637e3146107f6578063bc7a629114610817578063bfe1092814610837578063c80916d41461085d578063cb1a4da314610885578063cbcfeb0a146108a5578063cc5e8fe8146108c5578063d3986f08146108f3578063d4c7161f14610913578063d4d543c514610933578063d547741f1461094e578063d701f5231461096e578063d90430561461098e578063daa16525146109ae578063e1506695146109c5578063ec347594146109e5578063eff557a714610a06578063f101c98314610a28578063f72c0d8b14610a48575b600080fd5b3480156102b857600080fd5b506102cc6102c7366004613783565b610a6a565b60405190151581526020015b60405180910390f35b3480156102ed57600080fd5b506103016102fc3660046137cd565b610aa1565b005b34801561030f57600080fd5b5061031a61013d5481565b6040519081526020016102d8565b34801561033457600080fd5b506103016103433660046137f9565b610aca565b34801561035457600080fd5b50610301610363366004613822565b610af9565b34801561037457600080fd5b5061031a61013e5481565b34801561038b57600080fd5b5061030161039a36600461383b565b610b0b565b3480156103ab57600080fd5b50610135546103c0906001600160401b031681565b6040516001600160401b0390911681526020016102d8565b3480156103e457600080fd5b5061031a6101335481565b3480156103fb57600080fd5b5061031a61040a3660046138b6565b610c5b565b34801561041b57600080fd5b5061031a61042a3660046138b6565b61013a6020526000908152604090205481565b34801561044957600080fd5b5061031a6101345481565b34801561046057600080fd5b5061013154610475906001600160a01b031681565b6040516102d891906138d3565b34801561048e57600080fd5b5061031a61049d366004613822565b611037565b3480156104ae57600080fd5b506103016104bd3660046138e7565b61104c565b3480156104ce57600080fd5b506103016104dd366004613822565b61106d565b3480156104ee57600080fd5b506102cc6104fd3660046137cd565b61107f565b34801561050e57600080fd5b50610517611177565b6040516102d892919061396f565b34801561053157600080fd5b506105456105403660046137cd565b611224565b604080519283526020830191909152016102d8565b34801561056657600080fd5b506103016105753660046138e7565b611261565b34801561058657600080fd5b506103016105953660046138b6565b6112e4565b3480156105a657600080fd5b506104756105b53660046138b6565b610137602052600090815260409020546001600160a01b031681565b3480156105dd57600080fd5b506103016105ec3660046138b6565b6113ad565b3480156105fd57600080fd5b506103016113dc565b34801561061257600080fd5b506104756106213660046138b6565b610139602052600090815260409020546001600160a01b031681565b34801561064957600080fd5b5061013054610475906001600160a01b031681565b61030161066c3660046139d8565b6113ef565b34801561067d57600080fd5b5061031a6101325481565b34801561069457600080fd5b5061031a6114a5565b3480156106a957600080fd5b506103016106b8366004613a7f565b611553565b3480156106c957600080fd5b506103016106d83660046137cd565b61158e565b3480156106e957600080fd5b506103016106f8366004613b9f565b6116aa565b34801561070957600080fd5b5060335460ff166102cc565b34801561072157600080fd5b5061031a60008051602061444183398151915281565b34801561074357600080fd5b506103016107523660046138b6565b6119b6565b34801561076357600080fd5b506105176119eb565b34801561077857600080fd5b50610301611aae565b34801561078d57600080fd5b506102cc61079c3660046138b6565b611ac1565b3480156107ad57600080fd5b506103016107bc3660046138b6565b611f51565b3480156107cd57600080fd5b506102cc6107dc3660046138e7565b611f80565b3480156107ed57600080fd5b5061031a600081565b34801561080257600080fd5b5061012f54610475906001600160a01b031681565b34801561082357600080fd5b50610301610832366004613822565b611fab565b34801561084357600080fd5b5061012d546104759061010090046001600160a01b031681565b34801561086957600080fd5b506101355461047590600160401b90046001600160a01b031681565b34801561089157600080fd5b506103016108a0366004613822565b611fbd565b3480156108b157600080fd5b506103016108c0366004613a7f565b611fcf565b3480156108d157600080fd5b5061031a6108e03660046138b6565b6101386020526000908152604090205481565b3480156108ff57600080fd5b5061030161090e3660046138e7565b612061565b34801561091f57600080fd5b506102cc61092e3660046138b6565b6123d7565b34801561093f57600080fd5b5061012d546102cc9060ff1681565b34801561095a57600080fd5b506103016109693660046138e7565b61247d565b34801561097a57600080fd5b50610301610989366004613c98565b612499565b34801561099a57600080fd5b506102cc6109a93660046138b6565b6124b9565b3480156109ba57600080fd5b5061031a61013f5481565b3480156109d157600080fd5b506102cc6109e0366004613a7f565b612554565b3480156109f157600080fd5b5061012e54610475906001600160a01b031681565b348015610a1257600080fd5b5061031a6000805160206143da83398151915281565b348015610a3457600080fd5b50610301610a433660046137cd565b612728565b348015610a5457600080fd5b5061031a6000805160206143ba83398151915281565b60006001600160e01b03198216637965db0b60e01b1480610a9b57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6000610aac81612760565b506001600160a01b03909116600090815261013a6020526040902055565b6000610ad581612760565b5061013580546001600160401b0319166001600160401b0392909216919091179055565b6000610b0481612760565b5061013f55565b6000610b17600161276a565b90508015610b2f576000805461ff0019166101001790555b610b376127fe565b610b3f61282f565b610b4761282f565b61013288905561012d8054610100600160a81b0319166101006001600160a01b03858116919091029190911790915561013388905561013487905561013080546001600160a01b03199081168784161790915561012f805482168684161790556101318054909116918716919091179055610bc3600086612856565b610bdb6000805160206143ba83398151915286612856565b610bf36000805160206143da83398151915286612856565b610c0b60008051602061444183398151915286612856565b8015610c51576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b61013554604051637971bae560e11b81526000918291600160401b9091046001600160a01b03169063f2e375ca90610c999086908590600401613cb5565b602060405180830381865afa158015610cb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cda9190613cce565b610135546040516337491c4f60e11b8152919250600091600160401b9091046001600160a01b031690636e92389e90610d179087906004016138d3565b602060405180830381865afa158015610d34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d589190613cce565b9050818110610d6b575060009392505050565b6000610d778284613cfd565b61013f5490915083610d8b83612710613d14565b610d959190613d33565b11610da557506000949350505050565b61013554604051630d071a3760e11b8152600091600160401b90046001600160a01b031690631a0e346e90610dde9089906004016138d3565b602060405180830381865afa158015610dfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e1f9190613cce565b90506000866001600160a01b031663c04bea386040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e859190613d55565b90506001600160a01b03811615801590610ea0575081600314155b8015610ead575081600414155b1561102c576001600160a01b038088166000908152610137602090815260408083205481516330abf5cb60e11b815291519416938492636157eb9692600480820193918290030181865afa158015610f09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f2d9190613d55565b9050600080846001600160a01b031663449e815d848d6001600160a01b0316631e054de16040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fa49190613cce565b6040518363ffffffff1660e01b8152600401610fc1929190613cb5565b6040805180830381865afa158015610fdd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110019190613d83565b909250905061101181600a613e93565b61101b8389613d14565b6110259190613d33565b9650505050505b509095945050505050565b60009081526097602052604090206001015490565b61105582611037565b61105e81612760565b6110688383612856565b505050565b600061107881612760565b5061013255565b600080836001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110e49190613ea2565b6110ef906012613ebd565b6110fa90600a613e93565b6111049084613d14565b6001600160a01b038516600090815261013a602052604090205490915083108015906111415750610134546101335461113d9190613ee0565b4210155b801561115e575061013d548161013e5461115b9190613ee0565b11155b1561116d576001915050610a9b565b5060009392505050565b6000606060005b61118961013b6128dc565b81101561121f5760008061119c836128e6565b50915091506111ab8282612554565b1561120a576040516001955063877721af60e01b906111ce9084906024016138d3565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152935061121f915050565b5050808061121790613ef8565b91505061117e565b509091565b610136602052816000526040600020818154811061124157600080fd5b600091825260209091206002909102018054600190910154909250905082565b6001600160a01b03811633146112d65760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6112e082826129f6565b5050565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561132d5760405162461bcd60e51b81526004016112cd90613f13565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661135f612a5d565b6001600160a01b0316146113855760405162461bcd60e51b81526004016112cd90613f4d565b61138e81612a79565b604080516000808252602082019092526113aa91839190612af2565b50565b60006113b881612760565b5061012f80546001600160a01b0319166001600160a01b0392909216919091179055565b60006113e781612760565b6113aa612c5d565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156114385760405162461bcd60e51b81526004016112cd90613f13565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661146a612a5d565b6001600160a01b0316146114905760405162461bcd60e51b81526004016112cd90613f4d565b61149982612a79565b6112e082826001612af2565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146115405760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b60648201526084016112cd565b506000805160206143fa83398151915290565b600061155e81612760565b506001600160a01b0391821660009081526101396020526040902080546001600160a01b03191691909216179055565b600061159981612760565b81156116165760405163a9059cbb60e01b81526001600160a01b0384169063a9059cbb906115cd9033908690600401613cb5565b6020604051808303816000875af11580156115ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116109190613f87565b50505050565b6040516370a0823160e01b81526001600160a01b0384169063a9059cbb90339083906370a082319061164c9030906004016138d3565b602060405180830381865afa158015611669573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061168d9190613cce565b6040518363ffffffff1660e01b81526004016115cd929190613cb5565b60006116b581612760565b6101358054600160401b600160e01b031916600160401b6001600160a01b038b160217905560005b87518110156119ab576117148882815181106116fb576116fb613fa4565b602002602001015161013b612cea90919063ffffffff16565b5086818151811061172757611727613fa4565b602002602001015161013760008a848151811061174657611746613fa4565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060008782815181106117a6576117a6613fa4565b60200260200101516001600160a01b0316636157eb966040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061180f9190613d55565b905085828151811061182357611823613fa4565b602002602001015161013a6000836001600160a01b03166001600160a01b031681526020019081526020016000208190555086828151811061186757611867613fa4565b60200260200101516101396000836001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b031602179055508482815181106118cb576118cb613fa4565b602002602001015161013860008b85815181106118ea576118ea613fa4565b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020819055508361013281905550600060405180604001604052804281526020016000815250905061013660008b858151811061194f5761194f613fa4565b6020908102919091018101516001600160a01b03168252818101929092526040016000908120805460018181018355918352918390208451600290930201918255929091015191015550806119a381613ef8565b9150506116dd565b505050505050505050565b60006119c181612760565b5061012d80546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6000606060005b6119fd61013b6128dc565b81101561121f576000806000611a12846128e6565b925092509250611a2183610c5b565b158015611a335750611a33828261107f565b15611a98576040805160248101929092526001600160a01b039283166044830152929091166064808301919091528251808303909101815260849091019091526020810180516001600160e01b0316631a730de160e31b179052600193509150509091565b5050508080611aa690613ef8565b9150506119f2565b6000611ab981612760565b6113aa612d06565b6000611acf60335460ff1690565b15611aec5760405162461bcd60e51b81526004016112cd90613fba565b6000805160206143da833981519152611b0481612760565b6000611b0f84610c5b565b905060008111611b565760405162461bcd60e51b8152602060048201526012602482015271139bc81c99599a5b1b081c995c5d5a5c995960721b60448201526064016112cd565b6001600160a01b038085166000908152610137602090815260408083205481516330abf5cb60e11b815291519416938492636157eb9692600480820193918290030181865afa158015611bad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd19190613d55565b90506000816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c379190613ea2565b611c42906012613ebd565b60ff1690506000826001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611c7591906138d3565b602060405180830381865afa158015611c92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cb69190613cce565b610131546040516370a0823160e01b81529192506000916001600160a01b03868116926370a0823192611cef92909116906004016138d3565b602060405180830381865afa158015611d0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d309190613cce565b9050611d3d83600a613fe4565b611d479083613d14565b9150611d5483600a613fe4565b611d5e9082613d14565b9050612710611d6e8760c8613d14565b611d789190613d33565b611d829087613ee0565b955085821015611dc957611d968183613ee0565b861015611dba57611dab8683868c8988612d5e565b60019750505050505050611f4b565b60009750505050505050611f4b565b8561013e6000828254611ddc9190613ee0565b90915550506001600160a01b03841663a9059cbb86611dfc86600a613fe4565b611e06908a613d33565b6040518363ffffffff1660e01b8152600401611e23929190613cb5565b6020604051808303816000875af1158015611e42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e669190613f87565b50604051630efe6a8b60e01b81526001600160a01b03861690630efe6a8b90611e979087908a908190600401613ff0565b600060405180830381600087803b158015611eb157600080fd5b505af1158015611ec5573d6000803e3d6000fd5b50505050611ed2896124b9565b15611dab57610135546040516396f1382160e01b8152600160401b9091046001600160a01b0316906396f1382190611f0e908c906004016138d3565b600060405180830381600087803b158015611f2857600080fd5b505af1158015611f3c573d6000803e3d6000fd5b50505050600197505050505050505b50919050565b6000611f5c81612760565b5061012e80546001600160a01b0319166001600160a01b0392909216919091179055565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6000611fb681612760565b5061013d55565b6000611fc881612760565b5061013455565b6000611fda81612760565b611fe661013b8461303b565b156120245760405162461bcd60e51b815260206004820152600e60248201526d416c72656164792061637469766560901b60448201526064016112cd565b61203061013b84612cea565b50506001600160a01b0391821660009081526101376020526040902080546001600160a01b03191691909216179055565b60335460ff16156120845760405162461bcd60e51b81526004016112cd90613fba565b60008051602061444183398151915261209c81612760565b6120a6828461107f565b6121005760405162461bcd60e51b815260206004820152602560248201527f4275666665723a203c6d696e416d6f756e74206f72203c627269646765496e74604482015264195c9d985b60da1b60648201526084016112cd565b61013454610133546121129190613ee0565b42111561212057600061013e555b42610133556101305460405163095ea7b360e01b81526001600160a01b038481169263095ea7b39261215a92909116908790600401613cb5565b6020604051808303816000875af1158015612179573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219d9190613f87565b506101305461012d5461013554604051630924512f60e31b81526001600160a01b0361010090930483166004820152858316602482015260448101879052600160648201526001600160401b0390911660848201524263ffffffff1660a482015291169063492289789060c401600060405180830381600087803b15801561222457600080fd5b505af1158015612238573d6000803e3d6000fd5b5050506001600160a01b03808416600090815261013960205260408082205461012e5482516317be85c360e01b8152925191851695509293849316916317be85c39160048083019286929190829003018183875af115801561229e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526122c6919081019061406c565b61012f5461012d546040519395509193506001600160a01b039081169263bd45c4e792610100900490911690612306908690869089908d9060200161410a565b6040516020818303038152906040526000600160006040518663ffffffff1660e01b815260040161233b95949392919061414c565b600060405180830381600087803b15801561235557600080fd5b505af1158015612369573d6000803e3d6000fd5b505061012d54610135546040517f8cd19855172f79b649919cafcdeb37d17aa75198b4f4a4415796a64690e24f2994506123c793506101009092046001600160a01b031691899188918c916001600160401b0316908990899061418a565b60405180910390a1505050505050565b6000806123e381612760565b6000805b6123f261013b6128dc565b811015612475576001600160a01b03851661240f61013b83613050565b6001600160a01b031614156124635761243661242d61013b83613050565b61013b9061305c565b506001600160a01b03851660009081526101376020526040902080546001600160a01b0319169055600191505b8061246d81613ef8565b9150506123e7565b509392505050565b61248682611037565b61248f81612760565b61106883836129f6565b60006124a481612760565b5061012d805460ff1916911515919091179055565b610135546040516305ff325160e01b81526000918291600160401b9091046001600160a01b0316906305ff3251906124f59086906004016138d3565b608060405180830381865afa158015612512573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061253691906141f4565b509250508115905061254b5750600192915050565b50600092915050565b600080826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161258391906138d3565b602060405180830381865afa1580156125a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125c49190613cce565b90506000836001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612606573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061262a9190613ea2565b612635906012613ebd565b610131546040516370a0823160e01b815260ff9290921692506000916001600160a01b03878116926370a082319261267392909116906004016138d3565b602060405180830381865afa158015612690573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126b49190613cce565b90506126c182600a613fe4565b6126cb9084613d14565b92506126d882600a613fe4565b6126e29082613d14565b905060006126ef87610c5b565b905060008111801561270957506127068483613ee0565b81105b1561271b576001945050505050610a9b565b5060009695505050505050565b600061273381612760565b506001600160a01b0390911660009081526101386020526040902055565b6001600160a01b03163b151590565b6113aa8133613071565b60008054610100900460ff16156127b8578160ff166001148015612794575061279230612751565b155b6127b05760405162461bcd60e51b81526004016112cd90614235565b506000919050565b60005460ff8084169116106127df5760405162461bcd60e51b81526004016112cd90614235565b506000805460ff191660ff92909216919091179055600190565b919050565b600054610100900460ff166128255760405162461bcd60e51b81526004016112cd90614283565b61282d6130d5565b565b600054610100900460ff1661282d5760405162461bcd60e51b81526004016112cd90614283565b6128608282611f80565b6112e05760008281526097602090815260408083206001600160a01b03851684529091529020805460ff191660011790556128983390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000610a9b825490565b60008080806128f761013b86613050565b6001600160a01b038082166000908152610137602090815260408083205481516330abf5cb60e11b8152915195965092949290931692636157eb9692600480830193928290030181865afa158015612953573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129779190613d55565b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016129a791906138d3565b602060405180830381865afa1580156129c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e89190613cce565b929791965091945092505050565b612a008282611f80565b156112e05760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000805160206143fa833981519152546001600160a01b031690565b6000805160206143ba833981519152612a9181612760565b61012d5460ff16612ae35760405162461bcd60e51b815260206004820152601c60248201527b13585b9859d95c8e88155c19dc985919481b9bdd08185b1b1bddd95960221b60448201526064016112cd565b505061012d805460ff19169055565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615612b255761106883613108565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612b7f575060408051601f3d908101601f19168201909252612b7c91810190613cce565b60015b612be25760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b60648201526084016112cd565b6000805160206143fa8339815191528114612c515760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b60648201526084016112cd565b506110688383836131a2565b60335460ff16612ca65760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016112cd565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051612ce091906138d3565b60405180910390a1565b6000612cff836001600160a01b0384166131c7565b9392505050565b60335460ff1615612d295760405162461bcd60e51b81526004016112cd90613fba565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612cd33390565b6000612d6a8688613cfd565b90506000612d7785613211565b9050818160010154612d899190613ee0565b6001600160a01b038616600090815261013860205260409020541015612df15760405162461bcd60e51b815260206004820181905260248201527f43756d756c617469766520726566696c6c732065786365656473206c696d697460448201526064016112cd565b81816001016000828254612e059190613ee0565b925050819055508761013e6000828254612e1f9190613ee0565b9091555050610131546001600160a01b03808816916323b872dd911686612e4787600a613fe4565b612e519087613d33565b6040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015612ea5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ec99190613f87565b50878214612f58576001600160a01b03861663a9059cbb85612eec86600a613fe4565b612ef6908b613d33565b6040518363ffffffff1660e01b8152600401612f13929190613cb5565b6020604051808303816000875af1158015612f32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f569190613f87565b505b604051630efe6a8b60e01b81526001600160a01b03851690630efe6a8b90612f889089908c908190600401613ff0565b600060405180830381600087803b158015612fa257600080fd5b505af1158015612fb6573d6000803e3d6000fd5b50505050612fc3856124b9565b15610c5157610135546040516396f1382160e01b8152600160401b9091046001600160a01b0316906396f1382190612fff9088906004016138d3565b600060405180830381600087803b15801561301957600080fd5b505af115801561302d573d6000803e3d6000fd5b505050505050505050505050565b6000612cff836001600160a01b038416613348565b6000612cff8383613360565b6000612cff836001600160a01b03841661338a565b61307b8282611f80565b6112e057613093816001600160a01b0316601461347d565b61309e83602061347d565b6040516020016130af9291906142ce565b60408051601f198184030181529082905262461bcd60e51b82526112cd9160040161433d565b600054610100900460ff166130fc5760405162461bcd60e51b81526004016112cd90614283565b6033805460ff19169055565b61311181612751565b6131735760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016112cd565b6000805160206143fa83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6131ab83613618565b6000825111806131b85750805b15611068576116108383613658565b60006131d38383613348565b61320957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a9b565b506000610a9b565b6001600160a01b03811660009081526101366020526040812080548290829061323c90600190613cfd565b8154811061324c5761324c613fa4565b9060005260206000209060020201905060006101325482600001546132719190613ee0565b90508042111561330b576101325460009061328c8342613cfd565b6132969190613d33565b9050801561330957600061013254826132af9190613d14565b84546132bb9190613ee0565b604080518082018252918252600060208084018281526001600160a01b038c168352610136825292822080546001818101835591845291909220935160029091029093019283559051910155505b505b8254600090849061331e90600190613cfd565b8154811061332e5761332e613fa4565b600091825260209091206002909102019695505050505050565b60009081526001919091016020526040902054151590565b600082600001828154811061337757613377613fa4565b9060005260206000200154905092915050565b600081815260018301602052604081205480156134735760006133ae600183613cfd565b85549091506000906133c290600190613cfd565b90508181146134275760008660000182815481106133e2576133e2613fa4565b906000526020600020015490508087600001848154811061340557613405613fa4565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061343857613438614350565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610a9b565b6000915050610a9b565b6060600061348c836002613d14565b613497906002613ee0565b6001600160401b038111156134ae576134ae613992565b6040519080825280601f01601f1916602001820160405280156134d8576020820181803683370190505b509050600360fc1b816000815181106134f3576134f3613fa4565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061352257613522613fa4565b60200101906001600160f81b031916908160001a9053506000613546846002613d14565b613551906001613ee0565b90505b60018111156135c9576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061358557613585613fa4565b1a60f81b82828151811061359b5761359b613fa4565b60200101906001600160f81b031916908160001a90535060049490941c936135c281614366565b9050613554565b508315612cff5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016112cd565b61362181613108565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606061366383612751565b6136be5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016112cd565b600080846001600160a01b0316846040516136d9919061437d565b600060405180830381855af49150503d8060008114613714576040519150601f19603f3d011682016040523d82523d6000602084013e613719565b606091505b5091509150613741828260405180606001604052806027815260200161441a6027913961374a565b95945050505050565b60608315613759575081612cff565b8251156137695782518084602001fd5b8160405162461bcd60e51b81526004016112cd919061433d565b60006020828403121561379557600080fd5b81356001600160e01b031981168114612cff57600080fd5b6001600160a01b03811681146113aa57600080fd5b80356127f9816137ad565b600080604083850312156137e057600080fd5b82356137eb816137ad565b946020939093013593505050565b60006020828403121561380b57600080fd5b81356001600160401b0381168114612cff57600080fd5b60006020828403121561383457600080fd5b5035919050565b600080600080600080600060e0888a03121561385657600080fd5b8735965060208801359550604088013594506060880135613876816137ad565b93506080880135613886816137ad565b925060a0880135613896816137ad565b915060c08801356138a6816137ad565b8091505092959891949750929550565b6000602082840312156138c857600080fd5b8135612cff816137ad565b6001600160a01b0391909116815260200190565b600080604083850312156138fa57600080fd5b82359150602083013561390c816137ad565b809150509250929050565b60005b8381101561393257818101518382015260200161391a565b838111156116105750506000910152565b6000815180845261395b816020860160208601613917565b601f01601f19169290920160200192915050565b821515815260406020820152600061398a6040830184613943565b949350505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156139d0576139d0613992565b604052919050565b600080604083850312156139eb57600080fd5b82356139f6816137ad565b91506020838101356001600160401b0380821115613a1357600080fd5b818601915086601f830112613a2757600080fd5b813581811115613a3957613a39613992565b613a4b601f8201601f191685016139a8565b91508082528784828501011115613a6157600080fd5b80848401858401376000848284010152508093505050509250929050565b60008060408385031215613a9257600080fd5b8235613a9d816137ad565b9150602083013561390c816137ad565b60006001600160401b03821115613ac657613ac6613992565b5060051b60200190565b600082601f830112613ae157600080fd5b81356020613af6613af183613aad565b6139a8565b82815260059290921b84018101918181019086841115613b1557600080fd5b8286015b84811015613b39578035613b2c816137ad565b8352918301918301613b19565b509695505050505050565b600082601f830112613b5557600080fd5b81356020613b65613af183613aad565b82815260059290921b84018101918181019086841115613b8457600080fd5b8286015b84811015613b395780358352918301918301613b88565b600080600080600080600060e0888a031215613bba57600080fd5b613bc3886137c2565b965060208801356001600160401b0380821115613bdf57600080fd5b613beb8b838c01613ad0565b975060408a0135915080821115613c0157600080fd5b613c0d8b838c01613ad0565b965060608a0135915080821115613c2357600080fd5b613c2f8b838c01613ad0565b955060808a0135915080821115613c4557600080fd5b613c518b838c01613b44565b945060a08a0135915080821115613c6757600080fd5b50613c748a828b01613b44565b92505060c0880135905092959891949750929550565b80151581146113aa57600080fd5b600060208284031215613caa57600080fd5b8135612cff81613c8a565b6001600160a01b03929092168252602082015260400190565b600060208284031215613ce057600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082821015613d0f57613d0f613ce7565b500390565b6000816000190483118215151615613d2e57613d2e613ce7565b500290565b600082613d5057634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215613d6757600080fd5b8151612cff816137ad565b805160ff811681146127f957600080fd5b60008060408385031215613d9657600080fd5b82519150613da660208401613d72565b90509250929050565b600181815b80851115613dea578160001904821115613dd057613dd0613ce7565b80851615613ddd57918102915b93841c9390800290613db4565b509250929050565b600082613e0157506001610a9b565b81613e0e57506000610a9b565b8160018114613e245760028114613e2e57613e4a565b6001915050610a9b565b60ff841115613e3f57613e3f613ce7565b50506001821b610a9b565b5060208310610133831016604e8410600b8410161715613e6d575081810a610a9b565b613e778383613daf565b8060001904821115613e8b57613e8b613ce7565b029392505050565b6000612cff60ff841683613df2565b600060208284031215613eb457600080fd5b612cff82613d72565b600060ff821660ff841680821015613ed757613ed7613ce7565b90039392505050565b60008219821115613ef357613ef3613ce7565b500190565b6000600019821415613f0c57613f0c613ce7565b5060010190565b6020808252602c9082015260008051602061439a83398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c9082015260008051602061439a83398151915260408201526b6163746976652070726f787960a01b606082015260800190565b600060208284031215613f9957600080fd5b8151612cff81613c8a565b634e487b7160e01b600052603260045260246000fd5b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6000612cff8383613df2565b6001600160a01b039390931683526020830191909152604082015260600190565b600082601f83011261402257600080fd5b81516020614032613af183613aad565b82815260059290921b8401810191818101908684111561405157600080fd5b8286015b84811015613b395780518352918301918301614055565b6000806040838503121561407f57600080fd5b82516001600160401b038082111561409657600080fd5b6140a286838701614011565b935060208501519150808211156140b857600080fd5b506140c585828601614011565b9150509250929050565b600081518084526020808501945080840160005b838110156140ff578151875295820195908201906001016140e3565b509495945050505050565b60808152600061411d60808301876140cf565b828103602084015261412f81876140cf565b6001600160a01b0395909516604084015250506060015292915050565b600060018060a01b03808816835260a0602084015261416e60a0840188613943565b9516604083015250606081019290925260809091015292915050565b6001600160a01b038881168252878116602083015286166040820152606081018590526001600160401b038416608082015260e060a082018190526000906141d4908301856140cf565b82810360c08401526141e681856140cf565b9a9950505050505050505050565b6000806000806080858703121561420a57600080fd5b845193506020850151925060408501519150606085015161422a81613c8a565b939692955090935050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351614300816017850160208801613917565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351614331816028840160208801613917565b01602801949350505050565b602081526000612cff6020830184613943565b634e487b7160e01b600052603160045260246000fd5b60008161437557614375613ce7565b506000190190565b6000825161438f818460208701613917565b919091019291505056fe46756e6374696f6e206d7573742062652063616c6c6564207468726f75676820189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e38e81cee32eed7d8f4f15cd1d324edf5fe36cbe57fae18180879d4bdc265ceb30360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564d2761b102bda9831f4af400cc824b8cecb9cc5c1c85c51acb1479db9735fbfc6a264697066735822122025cd37234c32ed9b88a36b86f53ce071d07a4da8768fc70038e0bf25afcbcc2764736f6c634300080b0033

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