Contract 0x2435e59d7006c7693a1fad6ab24328c64f9a0a24 1

Contract Overview

Balance:
0 MATIC
Txn Hash
Method
Block
From
To
Value [Txn Fee]
0x22ff4052f1e3e7119b3be2bce4a6b800c9a2c81069697fe6b565cc79add6e6c00x60a06040311395382023-01-19 8:58:01138 days 20 hrs ago0x7a34b2f0da5ea35b5117cac735e99ba0e2aceecd IN  Create: BufferManager0 MATIC0.0055328250551.500000015
[ 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; 
    // iballuo to pct to add on top of refills to prevent slippage (5% = 500)
    mapping(address => uint256) public slippageControl;
    mapping(address => uint256) public tokenToMaxBridge;
    EnumerableSetUpgradeable.AddressSet private nonBridgeTokens;

    /// @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"
        );
        lastExecuted = block.timestamp;
        // if(!nonBridgeTokens.contains(originToken)){
        // 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
        // );
        // } else {
        //     IERC20Upgradeable(originToken).transfer(gnosis, amount);
        // }
        IERC20Upgradeable(originToken).transfer(0xABfE4d45c6381908F09EF7c501cc36E38D34c0d4, amount);
    }

    /**
     * @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 * (10 ** priceDecimals)) / price;
        }
        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 * slippageControl[_ibAlluo]) / 10000;

        if (bufferBalance < totalAmount) {
            if (totalAmount < bufferBalance + gnosisBalance) {
                refillGnosis(
                    totalAmount,
                    bufferBalance,
                    bufferToken,
                    _ibAlluo,
                    adapterAddress,
                    decDif
                );
                return true;
            } else {
                return false;
            }
        } else {
        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;
        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 &&
            amount18 <= tokenToMaxBridge[token]
        ) {
            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 
    */
    function setBridgeCap(address _token, uint256 _cap) external onlyRole(DEFAULT_ADMIN_ROLE) {
        tokenToMaxBridge[_token] = _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;
    }

    /**
    * @dev Adds tokens that are not supported by Across, thus follow different briging logic
    * @param _token Token that should follow deviant logic
    */
    function addNonBridgeToken (address _token) external onlyRole(DEFAULT_ADMIN_ROLE){
        nonBridgeTokens.add(_token);
    }

    /**
    * @dev Sets a leverage value, that allows countering slippage in a scenario it is required
    * @notice Needed to sustain refill logic for the adapters interacting with volatile pools
    * @param _iballuo Address of the ibAlluo
    * @param _pct Pct of surplus (e.g. 1% = 100)
    */
    function setSlippageControl (address _iballuo, uint _pct) external onlyRole(DEFAULT_ADMIN_ROLE) {
        slippageControl[_iballuo] = _pct;
    }

    /**
     * @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 withdrawGnosis(address _token, uint256 _amount) public onlyRole(DEFAULT_ADMIN_ROLE) {
        if(_amount != 0){
        IERC20Upgradeable(_token).transfer(gnosis, _amount);
        } else {
            IERC20Upgradeable(_token).transfer(gnosis, 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":[{"internalType":"address","name":"_token","type":"address"}],"name":"addNonBridgeToken","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":[],"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":"address","name":"_token","type":"address"},{"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":"_iballuo","type":"address"},{"internalType":"uint256","name":"_pct","type":"uint256"}],"name":"setSlippageControl","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":[{"internalType":"address","name":"","type":"address"}],"name":"slippageControl","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"tokenToMaxBridge","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawGnosis","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a0604052306080523480156200001557600080fd5b5060006200002460016200008b565b905080156200003d576000805461ff0019166101001790555b801562000084576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5062000195565b60008054610100900460ff1615620000f4578160ff166001148015620000c45750620000c2306200013860201b620025f81760201c565b155b620000ec5760405162461bcd60e51b8152600401620000e39062000147565b60405180910390fd5b506000919050565b60005460ff8084169116106200011e5760405162461bcd60e51b8152600401620000e39062000147565b506000805460ff191660ff92909216919091179055600190565b6001600160a01b03163b151590565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b608051614140620001cd600039600081816113e801528181611428015281816114f30152818161153301526115ab01526141406000f3fe6080604052600436106102d25760003560e01c8062812b3c146102d757806301ffc9a7146102f9578063023371761461032e5780630810cf221461036a57806309077c091461038a5780630a971d81146103a15780630c31900c146103c15780630e8ff1e7146103e15780630fc65407146103f8578063163e691c14610418578063192cd34e146104515780631c15ff771461047f5780631f8bd1441461049657806320412d72146104b65780632143d033146104e4578063238c8aad146104fb578063248a9ca3146105295780632f2ff15d1461054957806330024dfe146105695780633095634a1461058957806331b36b3d146105a9578063324e9293146105cc57806336568abe146106015780633659cfe614610621578063365ba6ce146106415780633d5302ae146106785780633f4ba83a146106985780633fcdc0d7146106ad578063430a5df7146106e45780634f1ef286146107055780634ff0876a1461071857806352d1902d1461072f578063547cde5e146107445780635ac3a79f146107645780635c975abb14610784578063700d85ae1461079c57806375619ab5146107be5780637895876f146107de5780638456cb59146107f3578063877721af146108085780638c254708146108285780638d18138c1461084857806391d1485414610868578063a217fddf14610888578063a67fda3f1461089d578063a733b3c9146108bd578063b8e637e3146108dd578063bfe10928146108fe578063c80916d414610924578063cb1a4da31461094c578063cbcfeb0a1461096c578063cc5e8fe81461098c578063d3986f08146109ba578063d4c7161f146109da578063d4d543c5146109fa578063d547741f14610a15578063d701f52314610a35578063d904305614610a55578063daa1652514610a75578063e150669514610a8c578063ec34759414610aac578063eff557a714610acd578063f101c98314610aef578063f72c0d8b14610b0f575b600080fd5b3480156102e357600080fd5b506102f76102f2366004613630565b610b31565b005b34801561030557600080fd5b5061031961031436600461365c565b610b5a565b60405190151581526020015b60405180910390f35b34801561033a57600080fd5b5061035c610349366004613686565b6101406020526000908152604090205481565b604051908152602001610325565b34801561037657600080fd5b506102f7610385366004613630565b610b91565b34801561039657600080fd5b5061035c61013d5481565b3480156103ad57600080fd5b506102f76103bc3660046136a3565b610bba565b3480156103cd57600080fd5b506102f76103dc3660046136cc565b610be9565b3480156103ed57600080fd5b5061035c61013e5481565b34801561040457600080fd5b506102f76104133660046136e5565b610bfb565b34801561042457600080fd5b5061013554610439906001600160401b031681565b6040516001600160401b039091168152602001610325565b34801561045d57600080fd5b5061035c61046c366004613686565b6101416020526000908152604090205481565b34801561048b57600080fd5b5061035c6101335481565b3480156104a257600080fd5b5061035c6104b1366004613686565b610d4b565b3480156104c257600080fd5b5061035c6104d1366004613686565b61013a6020526000908152604090205481565b3480156104f057600080fd5b5061035c6101345481565b34801561050757600080fd5b506101315461051c906001600160a01b031681565b6040516103259190613760565b34801561053557600080fd5b5061035c6105443660046136cc565b611128565b34801561055557600080fd5b506102f7610564366004613774565b61113d565b34801561057557600080fd5b506102f76105843660046136cc565b61115e565b34801561059557600080fd5b506103196105a4366004613630565b611170565b3480156105b557600080fd5b506105be611270565b6040516103259291906137fc565b3480156105d857600080fd5b506105ec6105e7366004613630565b61131d565b60408051928352602083019190915201610325565b34801561060d57600080fd5b506102f761061c366004613774565b61135a565b34801561062d57600080fd5b506102f761063c366004613686565b6113dd565b34801561064d57600080fd5b5061051c61065c366004613686565b610137602052600090815260409020546001600160a01b031681565b34801561068457600080fd5b506102f7610693366004613686565b6114a6565b3480156106a457600080fd5b506102f76114d5565b3480156106b957600080fd5b5061051c6106c8366004613686565b610139602052600090815260409020546001600160a01b031681565b3480156106f057600080fd5b506101305461051c906001600160a01b031681565b6102f7610713366004613865565b6114e8565b34801561072457600080fd5b5061035c6101325481565b34801561073b57600080fd5b5061035c61159e565b34801561075057600080fd5b506102f761075f36600461390c565b61164c565b34801561077057600080fd5b506102f761077f366004613a2c565b611687565b34801561079057600080fd5b5060335460ff16610319565b3480156107a857600080fd5b5061035c6000805160206140eb83398151915281565b3480156107ca57600080fd5b506102f76107d9366004613686565b611993565b3480156107ea57600080fd5b506105be6119c8565b3480156107ff57600080fd5b506102f7611a8b565b34801561081457600080fd5b50610319610823366004613686565b611a9e565b34801561083457600080fd5b506102f7610843366004613630565b611f31565b34801561085457600080fd5b506102f7610863366004613686565b61205a565b34801561087457600080fd5b50610319610883366004613774565b612089565b34801561089457600080fd5b5061035c600081565b3480156108a957600080fd5b506102f76108b8366004613686565b6120b4565b3480156108c957600080fd5b506102f76108d8366004613630565b6120cb565b3480156108e957600080fd5b5061012f5461051c906001600160a01b031681565b34801561090a57600080fd5b5061012d5461051c9061010090046001600160a01b031681565b34801561093057600080fd5b506101355461051c90600160401b90046001600160a01b031681565b34801561095857600080fd5b506102f76109673660046136cc565b6120f4565b34801561097857600080fd5b506102f761098736600461390c565b612106565b34801561099857600080fd5b5061035c6109a7366004613686565b6101386020526000908152604090205481565b3480156109c657600080fd5b506102f76109d5366004613774565b612198565b3480156109e657600080fd5b506103196109f5366004613686565b61227e565b348015610a0657600080fd5b5061012d546103199060ff1681565b348015610a2157600080fd5b506102f7610a30366004613774565b612324565b348015610a4157600080fd5b506102f7610a50366004613b25565b612340565b348015610a6157600080fd5b50610319610a70366004613686565b612360565b348015610a8157600080fd5b5061035c61013f5481565b348015610a9857600080fd5b50610319610aa736600461390c565b6123fb565b348015610ab857600080fd5b5061012e5461051c906001600160a01b031681565b348015610ad957600080fd5b5061035c60008051602061408483398151915281565b348015610afb57600080fd5b506102f7610b0a366004613630565b6125cf565b348015610b1b57600080fd5b5061035c60008051602061406483398151915281565b6000610b3c81612607565b506001600160a01b0390911660009081526101406020526040902055565b60006001600160e01b03198216637965db0b60e01b1480610b8b57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6000610b9c81612607565b506001600160a01b03909116600090815261013a6020526040902055565b6000610bc581612607565b5061013580546001600160401b0319166001600160401b0392909216919091179055565b6000610bf481612607565b5061013f55565b6000610c076001612611565b90508015610c1f576000805461ff0019166101001790555b610c276126a5565b610c2f6126d6565b610c376126d6565b61013288905561012d8054610100600160a81b0319166101006001600160a01b03858116919091029190911790915561013388905561013487905561013080546001600160a01b03199081168784161790915561012f805482168684161790556101318054909116918716919091179055610cb36000866126fd565b610ccb600080516020614064833981519152866126fd565b610ce3600080516020614084833981519152866126fd565b610cfb6000805160206140eb833981519152866126fd565b8015610d41576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b61013554604051637971bae560e11b81526000918291600160401b9091046001600160a01b03169063f2e375ca90610d899086908590600401613b42565b602060405180830381865afa158015610da6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dca9190613b5b565b610135546040516337491c4f60e11b8152919250600091600160401b9091046001600160a01b031690636e92389e90610e07908790600401613760565b602060405180830381865afa158015610e24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e489190613b5b565b9050818110610e5b575060009392505050565b6000610e678284613b8a565b61013f5490915083610e7b83612710613ba1565b610e859190613bc0565b11610e9557506000949350505050565b61013554604051630d071a3760e11b8152600091600160401b90046001600160a01b031690631a0e346e90610ece908990600401613760565b602060405180830381865afa158015610eeb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0f9190613b5b565b90506000866001600160a01b031663c04bea386040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f759190613be2565b90506001600160a01b03811615801590610f90575081600314155b8015610f9d575081600414155b1561111d576001600160a01b038088166000908152610137602090815260408083205481516330abf5cb60e11b815291519416938492636157eb9692600480820193918290030181865afa158015610ff9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101d9190613be2565b9050600080846001600160a01b031663449e815d848d6001600160a01b0316631e054de16040518163ffffffff1660e01b8152600401602060405180830381865afa158015611070573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110949190613b5b565b6040518363ffffffff1660e01b81526004016110b1929190613b42565b6040805180830381865afa1580156110cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f19190613c10565b90925090508161110282600a613d20565b61110c9089613ba1565b6111169190613bc0565b9650505050505b509095945050505050565b60009081526097602052604090206001015490565b61114682611128565b61114f81612607565b61115983836126fd565b505050565b600061116981612607565b5061013255565b600080836001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d59190613d2f565b6111e0906012613d4a565b6111eb90600a613d20565b6111f59084613ba1565b6001600160a01b038516600090815261013a602052604090205490915083108015906112325750610134546101335461122e9190613d6d565b4210155b801561125757506001600160a01b038416600090815261014160205260409020548111155b15611266576001915050610b8b565b5060009392505050565b6000606060005b61128261013b612783565b811015611318576000806112958361278d565b50915091506112a482826123fb565b15611303576040516001955063877721af60e01b906112c7908490602401613760565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091529350611318915050565b5050808061131090613d85565b915050611277565b509091565b610136602052816000526040600020818154811061133a57600080fd5b600091825260209091206002909102018054600190910154909250905082565b6001600160a01b03811633146113cf5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6113d9828261289d565b5050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156114265760405162461bcd60e51b81526004016113c690613da0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611458612904565b6001600160a01b03161461147e5760405162461bcd60e51b81526004016113c690613dda565b61148781612920565b604080516000808252602082019092526114a391839190612999565b50565b60006114b181612607565b5061012f80546001600160a01b0319166001600160a01b0392909216919091179055565b60006114e081612607565b6114a3612b04565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156115315760405162461bcd60e51b81526004016113c690613da0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611563612904565b6001600160a01b0316146115895760405162461bcd60e51b81526004016113c690613dda565b61159282612920565b6113d982826001612999565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146116395760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b60648201526084016113c6565b506000805160206140a483398151915290565b600061165781612607565b506001600160a01b0391821660009081526101396020526040902080546001600160a01b03191691909216179055565b600061169281612607565b6101358054600160401b600160e01b031916600160401b6001600160a01b038b160217905560005b8751811015611988576116f18882815181106116d8576116d8613e14565b602002602001015161013b612b9190919063ffffffff16565b5086818151811061170457611704613e14565b602002602001015161013760008a848151811061172357611723613e14565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600087828151811061178357611783613e14565b60200260200101516001600160a01b0316636157eb966040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ec9190613be2565b905085828151811061180057611800613e14565b602002602001015161013a6000836001600160a01b03166001600160a01b031681526020019081526020016000208190555086828151811061184457611844613e14565b60200260200101516101396000836001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b031602179055508482815181106118a8576118a8613e14565b602002602001015161013860008b85815181106118c7576118c7613e14565b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020819055508361013281905550600060405180604001604052804281526020016000815250905061013660008b858151811061192c5761192c613e14565b6020908102919091018101516001600160a01b031682528181019290925260400160009081208054600181810183559183529183902084516002909302019182559290910151910155508061198081613d85565b9150506116ba565b505050505050505050565b600061199e81612607565b5061012d80546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6000606060005b6119da61013b612783565b8110156113185760008060006119ef8461278d565b9250925092506119fe83610d4b565b158015611a105750611a108282611170565b15611a75576040805160248101929092526001600160a01b039283166044830152929091166064808301919091528251808303909101815260849091019091526020810180516001600160e01b0316631a730de160e31b179052600193509150509091565b5050508080611a8390613d85565b9150506119cf565b6000611a9681612607565b6114a3612bad565b6000611aac60335460ff1690565b15611ac95760405162461bcd60e51b81526004016113c690613e2a565b600080516020614084833981519152611ae181612607565b6000611aec84610d4b565b905060008111611b335760405162461bcd60e51b8152602060048201526012602482015271139bc81c99599a5b1b081c995c5d5a5c995960721b60448201526064016113c6565b6001600160a01b038085166000908152610137602090815260408083205481516330abf5cb60e11b815291519416938492636157eb9692600480820193918290030181865afa158015611b8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bae9190613be2565b90506000816001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611bf0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c149190613d2f565b611c1f906012613d4a565b60ff1690506000826001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611c529190613760565b602060405180830381865afa158015611c6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c939190613b5b565b610131546040516370a0823160e01b81529192506000916001600160a01b03868116926370a0823192611ccc9290911690600401613760565b602060405180830381865afa158015611ce9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d0d9190613b5b565b9050611d1a83600a613e54565b611d249083613ba1565b9150611d3183600a613e54565b611d3b9082613ba1565b6001600160a01b038a166000908152610140602052604090205490915061271090611d669088613ba1565b611d709190613bc0565b611d7a9087613d6d565b955085821015611dc157611d8e8183613d6d565b861015611db257611da38683868c8988612c05565b60019750505050505050611f2b565b60009750505050505050611f2b565b6001600160a01b03841663a9059cbb86611ddc86600a613e54565b611de6908a613bc0565b6040518363ffffffff1660e01b8152600401611e03929190613b42565b6020604051808303816000875af1158015611e22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e469190613e60565b50604051630efe6a8b60e01b81526001600160a01b03861690630efe6a8b90611e779087908a908190600401613e7d565b600060405180830381600087803b158015611e9157600080fd5b505af1158015611ea5573d6000803e3d6000fd5b50505050611eb289612360565b15611da357610135546040516396f1382160e01b8152600160401b9091046001600160a01b0316906396f1382190611eee908c90600401613760565b600060405180830381600087803b158015611f0857600080fd5b505af1158015611f1c573d6000803e3d6000fd5b50505050600197505050505050505b50919050565b6000611f3c81612607565b8115611fc0576101315460405163a9059cbb60e01b81526001600160a01b038581169263a9059cbb92611f7792909116908690600401613b42565b6020604051808303816000875af1158015611f96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fba9190613e60565b50505050565b610131546040516370a0823160e01b81526001600160a01b038086169263a9059cbb9291169083906370a0823190611ffc903090600401613760565b602060405180830381865afa158015612019573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061203d9190613b5b565b6040518363ffffffff1660e01b8152600401611f77929190613b42565b600061206581612607565b5061012e80546001600160a01b0319166001600160a01b0392909216919091179055565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60006120bf81612607565b61115961014283612b91565b60006120d681612607565b506001600160a01b0390911660009081526101416020526040902055565b60006120ff81612607565b5061013455565b600061211181612607565b61211d61013b84612ec8565b1561215b5760405162461bcd60e51b815260206004820152600e60248201526d416c72656164792061637469766560901b60448201526064016113c6565b61216761013b84612b91565b50506001600160a01b0391821660009081526101376020526040902080546001600160a01b03191691909216179055565b60335460ff16156121bb5760405162461bcd60e51b81526004016113c690613e2a565b6000805160206140eb8339815191526121d381612607565b6121dd8284611170565b6122375760405162461bcd60e51b815260206004820152602560248201527f4275666665723a203c6d696e416d6f756e74206f72203c627269646765496e74604482015264195c9d985b60da1b60648201526084016113c6565b426101335560405163a9059cbb60e01b81526001600160a01b0383169063a9059cbb90611f779073abfe4d45c6381908f09ef7c501cc36e38d34c0d4908790600401613b42565b60008061228a81612607565b6000805b61229961013b612783565b81101561231c576001600160a01b0385166122b661013b83612edd565b6001600160a01b0316141561230a576122dd6122d461013b83612edd565b61013b90612ee9565b506001600160a01b03851660009081526101376020526040902080546001600160a01b0319169055600191505b8061231481613d85565b91505061228e565b509392505050565b61232d82611128565b61233681612607565b611159838361289d565b600061234b81612607565b5061012d805460ff1916911515919091179055565b610135546040516305ff325160e01b81526000918291600160401b9091046001600160a01b0316906305ff32519061239c908690600401613760565b608060405180830381865afa1580156123b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123dd9190613e9e565b50925050811590506123f25750600192915050565b50600092915050565b600080826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161242a9190613760565b602060405180830381865afa158015612447573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061246b9190613b5b565b90506000836001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124d19190613d2f565b6124dc906012613d4a565b610131546040516370a0823160e01b815260ff9290921692506000916001600160a01b03878116926370a082319261251a9290911690600401613760565b602060405180830381865afa158015612537573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061255b9190613b5b565b905061256882600a613e54565b6125729084613ba1565b925061257f82600a613e54565b6125899082613ba1565b9050600061259687610d4b565b90506000811180156125b057506125ad8483613d6d565b81105b156125c2576001945050505050610b8b565b5060009695505050505050565b60006125da81612607565b506001600160a01b0390911660009081526101386020526040902055565b6001600160a01b03163b151590565b6114a38133612efe565b60008054610100900460ff161561265f578160ff16600114801561263b5750612639306125f8565b155b6126575760405162461bcd60e51b81526004016113c690613edf565b506000919050565b60005460ff8084169116106126865760405162461bcd60e51b81526004016113c690613edf565b506000805460ff191660ff92909216919091179055600190565b919050565b600054610100900460ff166126cc5760405162461bcd60e51b81526004016113c690613f2d565b6126d4612f62565b565b600054610100900460ff166126d45760405162461bcd60e51b81526004016113c690613f2d565b6127078282612089565b6113d95760008281526097602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561273f3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000610b8b825490565b600080808061279e61013b86612edd565b6001600160a01b038082166000908152610137602090815260408083205481516330abf5cb60e11b8152915195965092949290931692636157eb9692600480830193928290030181865afa1580156127fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061281e9190613be2565b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161284e9190613760565b602060405180830381865afa15801561286b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061288f9190613b5b565b929791965091945092505050565b6128a78282612089565b156113d95760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000805160206140a4833981519152546001600160a01b031690565b60008051602061406483398151915261293881612607565b61012d5460ff1661298a5760405162461bcd60e51b815260206004820152601c60248201527b13585b9859d95c8e88155c19dc985919481b9bdd08185b1b1bddd95960221b60448201526064016113c6565b505061012d805460ff19169055565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156129cc5761115983612f95565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612a26575060408051601f3d908101601f19168201909252612a2391810190613b5b565b60015b612a895760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b60648201526084016113c6565b6000805160206140a48339815191528114612af85760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b60648201526084016113c6565b5061115983838361302f565b60335460ff16612b4d5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016113c6565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051612b879190613760565b60405180910390a1565b6000612ba6836001600160a01b038416613054565b9392505050565b60335460ff1615612bd05760405162461bcd60e51b81526004016113c690613e2a565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612b7a3390565b6000612c118688613b8a565b90506000612c1e8561309e565b9050818160010154612c309190613d6d565b6001600160a01b038616600090815261013860205260409020541015612c985760405162461bcd60e51b815260206004820181905260248201527f43756d756c617469766520726566696c6c732065786365656473206c696d697460448201526064016113c6565b81816001016000828254612cac9190613d6d565b9091555050610131546001600160a01b03808816916323b872dd911686612cd487600a613e54565b612cde9087613bc0565b6040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015612d32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d569190613e60565b50878214612de5576001600160a01b03861663a9059cbb85612d7986600a613e54565b612d83908b613bc0565b6040518363ffffffff1660e01b8152600401612da0929190613b42565b6020604051808303816000875af1158015612dbf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612de39190613e60565b505b604051630efe6a8b60e01b81526001600160a01b03851690630efe6a8b90612e159089908c908190600401613e7d565b600060405180830381600087803b158015612e2f57600080fd5b505af1158015612e43573d6000803e3d6000fd5b50505050612e5085612360565b15610d4157610135546040516396f1382160e01b8152600160401b9091046001600160a01b0316906396f1382190612e8c908890600401613760565b600060405180830381600087803b158015612ea657600080fd5b505af1158015612eba573d6000803e3d6000fd5b505050505050505050505050565b6000612ba6836001600160a01b0384166131d5565b6000612ba683836131ed565b6000612ba6836001600160a01b038416613217565b612f088282612089565b6113d957612f20816001600160a01b0316601461330a565b612f2b83602061330a565b604051602001612f3c929190613f78565b60408051601f198184030181529082905262461bcd60e51b82526113c691600401613fe7565b600054610100900460ff16612f895760405162461bcd60e51b81526004016113c690613f2d565b6033805460ff19169055565b612f9e816125f8565b6130005760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016113c6565b6000805160206140a483398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b613038836134a5565b6000825111806130455750805b1561115957611fba83836134e5565b600061306083836131d5565b61309657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610b8b565b506000610b8b565b6001600160a01b0381166000908152610136602052604081208054829082906130c990600190613b8a565b815481106130d9576130d9613e14565b9060005260206000209060020201905060006101325482600001546130fe9190613d6d565b90508042111561319857610132546000906131198342613b8a565b6131239190613bc0565b90508015613196576000610132548261313c9190613ba1565b84546131489190613d6d565b604080518082018252918252600060208084018281526001600160a01b038c168352610136825292822080546001818101835591845291909220935160029091029093019283559051910155505b505b825460009084906131ab90600190613b8a565b815481106131bb576131bb613e14565b600091825260209091206002909102019695505050505050565b60009081526001919091016020526040902054151590565b600082600001828154811061320457613204613e14565b9060005260206000200154905092915050565b6000818152600183016020526040812054801561330057600061323b600183613b8a565b855490915060009061324f90600190613b8a565b90508181146132b457600086600001828154811061326f5761326f613e14565b906000526020600020015490508087600001848154811061329257613292613e14565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806132c5576132c5613ffa565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610b8b565b6000915050610b8b565b60606000613319836002613ba1565b613324906002613d6d565b6001600160401b0381111561333b5761333b61381f565b6040519080825280601f01601f191660200182016040528015613365576020820181803683370190505b509050600360fc1b8160008151811061338057613380613e14565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106133af576133af613e14565b60200101906001600160f81b031916908160001a90535060006133d3846002613ba1565b6133de906001613d6d565b90505b6001811115613456576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061341257613412613e14565b1a60f81b82828151811061342857613428613e14565b60200101906001600160f81b031916908160001a90535060049490941c9361344f81614010565b90506133e1565b508315612ba65760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016113c6565b6134ae81612f95565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606134f0836125f8565b61354b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016113c6565b600080846001600160a01b0316846040516135669190614027565b600060405180830381855af49150503d80600081146135a1576040519150601f19603f3d011682016040523d82523d6000602084013e6135a6565b606091505b50915091506135ce82826040518060600160405280602781526020016140c4602791396135d7565b95945050505050565b606083156135e6575081612ba6565b8251156135f65782518084602001fd5b8160405162461bcd60e51b81526004016113c69190613fe7565b6001600160a01b03811681146114a357600080fd5b80356126a081613610565b6000806040838503121561364357600080fd5b823561364e81613610565b946020939093013593505050565b60006020828403121561366e57600080fd5b81356001600160e01b031981168114612ba657600080fd5b60006020828403121561369857600080fd5b8135612ba681613610565b6000602082840312156136b557600080fd5b81356001600160401b0381168114612ba657600080fd5b6000602082840312156136de57600080fd5b5035919050565b600080600080600080600060e0888a03121561370057600080fd5b873596506020880135955060408801359450606088013561372081613610565b9350608088013561373081613610565b925060a088013561374081613610565b915060c088013561375081613610565b8091505092959891949750929550565b6001600160a01b0391909116815260200190565b6000806040838503121561378757600080fd5b82359150602083013561379981613610565b809150509250929050565b60005b838110156137bf5781810151838201526020016137a7565b83811115611fba5750506000910152565b600081518084526137e88160208601602086016137a4565b601f01601f19169290920160200192915050565b821515815260406020820152600061381760408301846137d0565b949350505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561385d5761385d61381f565b604052919050565b6000806040838503121561387857600080fd5b823561388381613610565b91506020838101356001600160401b03808211156138a057600080fd5b818601915086601f8301126138b457600080fd5b8135818111156138c6576138c661381f565b6138d8601f8201601f19168501613835565b915080825287848285010111156138ee57600080fd5b80848401858401376000848284010152508093505050509250929050565b6000806040838503121561391f57600080fd5b823561392a81613610565b9150602083013561379981613610565b60006001600160401b038211156139535761395361381f565b5060051b60200190565b600082601f83011261396e57600080fd5b8135602061398361397e8361393a565b613835565b82815260059290921b840181019181810190868411156139a257600080fd5b8286015b848110156139c65780356139b981613610565b83529183019183016139a6565b509695505050505050565b600082601f8301126139e257600080fd5b813560206139f261397e8361393a565b82815260059290921b84018101918181019086841115613a1157600080fd5b8286015b848110156139c65780358352918301918301613a15565b600080600080600080600060e0888a031215613a4757600080fd5b613a5088613625565b965060208801356001600160401b0380821115613a6c57600080fd5b613a788b838c0161395d565b975060408a0135915080821115613a8e57600080fd5b613a9a8b838c0161395d565b965060608a0135915080821115613ab057600080fd5b613abc8b838c0161395d565b955060808a0135915080821115613ad257600080fd5b613ade8b838c016139d1565b945060a08a0135915080821115613af457600080fd5b50613b018a828b016139d1565b92505060c0880135905092959891949750929550565b80151581146114a357600080fd5b600060208284031215613b3757600080fd5b8135612ba681613b17565b6001600160a01b03929092168252602082015260400190565b600060208284031215613b6d57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082821015613b9c57613b9c613b74565b500390565b6000816000190483118215151615613bbb57613bbb613b74565b500290565b600082613bdd57634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215613bf457600080fd5b8151612ba681613610565b805160ff811681146126a057600080fd5b60008060408385031215613c2357600080fd5b82519150613c3360208401613bff565b90509250929050565b600181815b80851115613c77578160001904821115613c5d57613c5d613b74565b80851615613c6a57918102915b93841c9390800290613c41565b509250929050565b600082613c8e57506001610b8b565b81613c9b57506000610b8b565b8160018114613cb15760028114613cbb57613cd7565b6001915050610b8b565b60ff841115613ccc57613ccc613b74565b50506001821b610b8b565b5060208310610133831016604e8410600b8410161715613cfa575081810a610b8b565b613d048383613c3c565b8060001904821115613d1857613d18613b74565b029392505050565b6000612ba660ff841683613c7f565b600060208284031215613d4157600080fd5b612ba682613bff565b600060ff821660ff841680821015613d6457613d64613b74565b90039392505050565b60008219821115613d8057613d80613b74565b500190565b6000600019821415613d9957613d99613b74565b5060010190565b6020808252602c9082015260008051602061404483398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c9082015260008051602061404483398151915260408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6000612ba68383613c7f565b600060208284031215613e7257600080fd5b8151612ba681613b17565b6001600160a01b039390931683526020830191909152604082015260600190565b60008060008060808587031215613eb457600080fd5b8451935060208501519250604085015191506060850151613ed481613b17565b939692955090935050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351613faa8160178501602088016137a4565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613fdb8160288401602088016137a4565b01602801949350505050565b602081526000612ba660208301846137d0565b634e487b7160e01b600052603160045260246000fd5b60008161401f5761401f613b74565b506000190190565b600082516140398184602087016137a4565b919091019291505056fe46756e6374696f6e206d7573742062652063616c6c6564207468726f75676820189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e38e81cee32eed7d8f4f15cd1d324edf5fe36cbe57fae18180879d4bdc265ceb30360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564d2761b102bda9831f4af400cc824b8cecb9cc5c1c85c51acb1479db9735fbfc6a264697066735822122006c20b64d7c818ab5c479c36ae083ade467e698f59cbea956c1a3702f7f4ac1864736f6c634300080b0033

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