Address Details
contract

0x57f130e4873ac340Cee867f64e4E203070984E9F

Contract Name
UBIController
Creator
0xc02b8b–fa8663 at 0x50bae1–05c288
Balance
0 CELO ( )
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
1 Transactions
Transfers
0 Transfers
Gas Used
68,077
Last Balance Update
5007988
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
UBIController




Optimization enabled
true
Compiler version
v0.8.4+commit.c7e474f2




Optimization runs
200
EVM Version
istanbul




Verified at
2022-06-04T05:15:29.919259Z

/home/boyd/git/keyko/celo-ubi-contract/contracts/UBIController.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol";
import "./interface/IUBIBeneficiary.sol";
import "./interface/IUBIReconciliationAccount.sol";
import "./interface/IUBIBeneficiaryFactory.sol";
import "./interface/IVersionedContract.sol";

/**
 * @title Celo UBI administrative contract
 *
 * @dev Administrative and orchestrator contract for the Celo UBI program
 *
 * @author Aaron Boyd <https://github.com/aaronmboyd>
 */
contract UBIController is IVersionedContract, Ownable, Pausable, ReentrancyGuard {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;
    using SafeERC20 for ERC20PresetMinterPauser;
    using EnumerableMap for EnumerableMap.UintToAddressMap;

    /**
     * @notice Triggered when a new user has been created
     *
     * @param _userId       Hashed bytes32 of the userId
     * @param _ubiAddress   Celo address of the UBI Beneficiary
     */
    event NewUser(bytes32 indexed _userId, address indexed _ubiAddress);

    /**
     * @notice Triggered when the disbursement amount is changed
     *
     * @param _disbursementWei   New value of wei to disburse to beneficiaries
     */
    event DisbursementUpdated(uint256 indexed _disbursementWei);

    /**
     * @notice Triggered when the UBI Beneficiary Factory is updated
     *
     * @param _oldFactoryAddress   Old factory address
     * @param _newFactoryAddress   New factory address
     */
    event FactoryUpdated(address indexed _oldFactoryAddress, address indexed _newFactoryAddress);

    IERC20 public cUSDToken;
    ERC20PresetMinterPauser public cUBIAuthToken;
    IUBIBeneficiaryFactory public ubiFactory;
    IUBIReconciliationAccount public reconciliationAccount;

    // Default disbursement amount
    uint256 public disbursementWei = 100 ether;

    // Mapping of UBI Beneficiary identifiers to their contract address
    EnumerableMap.UintToAddressMap private ubiBeneficiaries;

    /**
     * @notice Used to initialize a new UBIController contract
     *
     * @param _cUSDToken token used for cUSD
     */
    constructor(
        address _cUSDToken,
        address _cUBIAuthToken,
        address _factory,
        address _custodian
    ) {
        cUSDToken = IERC20(_cUSDToken);
        cUBIAuthToken = ERC20PresetMinterPauser(_cUBIAuthToken);
        ubiFactory = IUBIBeneficiaryFactory(_factory);
        address tmp = ubiFactory.createProxiedUBIReconciliationAccount(_custodian);
        reconciliationAccount = IUBIReconciliationAccount(tmp);
    }

    /**
     * @notice Returns the storage, major, minor, and patch version of the contract.
     * @return The storage, major, minor, and patch version of the contract.
     */
    function getVersionNumber()
        external
        pure
        override
        returns (
            uint256,
            uint256,
            uint256,
            uint256
        )
    {
        return (1, 2, 0, 1);
    }

    /**
     * @notice Enforces values > 0 only
     */
    modifier greaterThanZero(uint256 _value) {
        require(_value > 0, "ERR_ZERO_VALUE");
        _;
    }

    /**
     * @notice Enforces value to not be greater than a user's available balance
     */
    modifier balanceAvailable(bytes32 _userId, uint256 _value) {
        require(balanceOfUBIBeneficiary(_userId) >= _value, "ERR_NO_BALANCE");
        _;
    }

    /**
     * @notice Enforces a _userId should not be mapped to an existing user / contract address
     */
    modifier userNotExist(bytes32 _userId) {
        require(!ubiBeneficiaries.contains(uint256(_userId)), "ERR_USER_EXISTS");
        _;
    }

    /**
     * @notice Set amount of wei to disburse to new beneficiaries
     *
     * @param _newDisbursementWei   disbursement amount in wei
     */
    function setDisbursementWei(uint256 _newDisbursementWei) external onlyOwner {
        disbursementWei = _newDisbursementWei;
        emit DisbursementUpdated(disbursementWei);
    }

    /**
     * @notice Public update to a new UBI Beneficiary Factory
     *
     * @param _newFactoryAddress   new factory address
     */
    function setUBIBeneficiaryFactory(address _newFactoryAddress) external onlyOwner {
        _setUBIBeneficiaryFactory(_newFactoryAddress);
    }

    /**
     * @notice Internal implementation of update to a new UBI Beneficiary Factory
     *
     * @param _newFactoryAddress   new factory address
     */
    function _setUBIBeneficiaryFactory(address _newFactoryAddress) private {
        ubiFactory = IUBIBeneficiaryFactory(_newFactoryAddress);
        emit FactoryUpdated(address(ubiFactory), _newFactoryAddress);
    }

    /**
     * @notice Update the custodian address
     *
     * @param _custodian   new custodian address
     */
    function setCustodian(address _custodian) external onlyOwner {
        reconciliationAccount.setCustodian(_custodian);
    }

    /**
     * @notice Retrieves the available balance of a UBI beneficiary
     *
     * @param _userId user identifier
     * @return uint256 available balance
     */
    function balanceOfUBIBeneficiary(bytes32 _userId) public view returns (uint256) {
        address ubiBeneficiaryAddress = ubiBeneficiaries.get(uint256(_userId));
        IUBIBeneficiary user = IUBIBeneficiary(ubiBeneficiaryAddress);
        return user.availableBalance();
    }

    /**
     * @notice Retrieves the authorized balance of a UBI beneficiary
     *
     * @param _userId user identifier
     * @return uint256 authorized balance
     */
    function authBalanceOfUBIBeneficiary(bytes32 _userId) public view returns (uint256) {
        address ubiBeneficiaryAddress = ubiBeneficiaries.get(uint256(_userId));
        IUBIBeneficiary user = IUBIBeneficiary(ubiBeneficiaryAddress);
        return user.authorizationBalance();
    }

    /**
     * @notice Authorizes an amount for a UBI beneficiary
     *
     * @param _userId       User identifier
     * @param _txId         Raw transaction ID for this event
     * @param _value        Amount to authorize
     */
    function authorize(
        bytes32 _userId,
        string calldata _txId,
        uint256 _value
    )
        external
        greaterThanZero(_value)
        balanceAvailable(_userId, _value)
        onlyOwner
        nonReentrant
        whenNotPaused
    {
        address ubiBeneficiaryAddress = ubiBeneficiaries.get(uint256(_userId));
        cUBIAuthToken.mint(ubiBeneficiaryAddress, _value);

        IUBIBeneficiary user = IUBIBeneficiary(ubiBeneficiaryAddress);
        user.authorize(_txId, _value);
    }

    /**
     * @notice Deauthorizes an amount for a UBI beneficiary
     *
     * @param _userId       User identifier
     * @param _txId         Raw transaction ID for this event
     */
    function deauthorize(bytes32 _userId, string calldata _txId)
        external
        onlyOwner
        nonReentrant
        whenNotPaused
    {
        _deauthorize(uint256(_userId), _txId);
    }

    /**
     * @notice Deauthorizes an amount for a UBI beneficiary
     * @dev Implementation of external "deauthorize" function so that it may be called internally without reentrancy guard incrementing
     *
     * @param _userId       User identifier
     * @param _txId         Raw transaction ID for this event
     */
    function _deauthorize(uint256 _userId, string calldata _txId) private {
        address ubiBeneficiaryAddress = ubiBeneficiaries.get(_userId);
        IUBIBeneficiary user = IUBIBeneficiary(ubiBeneficiaryAddress);
        uint256 deauthorizedAmt = user.deauthorize(_txId);
        cUBIAuthToken.burn(deauthorizedAmt);
    }

    /**
     * @notice Settles an amount for a UBI Beneficiary and transfers to the Reconciliation account
     *
     * @param _userId       User identifier
     * @param _txId         Raw transaction ID for this event
     * @param _value        Amount to settle
     */
    function settle(
        bytes32 _userId,
        string calldata _txId,
        uint256 _value
    )
        external
        greaterThanZero(_value)
        balanceAvailable(_userId, _value)
        onlyOwner
        nonReentrant
        whenNotPaused
    {
        _settle(uint256(_userId), _txId, _value);
    }

    /**
     * @notice Settles an amount for a UBI Beneficiary and transfers to the Reconciliation account
     * @dev Implementation of external "settle" function so that it may be called internally without reentrancy guard incrementing
     *
     * @param _userId       User identifier
     * @param _txId         Raw transaction ID for this event
     * @param _value        Amount to settle
     */
    function _settle(
        uint256 _userId,
        string calldata _txId,
        uint256 _value
    ) private {
        address ubiBeneficiaryAddress = ubiBeneficiaries.get(_userId);
        IUBIBeneficiary user = IUBIBeneficiary(ubiBeneficiaryAddress);
        user.settle(_txId, _value, address(reconciliationAccount));
    }

    /**
     * @notice Reconciles cUSD built up in reconciliation account and sends to pre-configured custodian
     *
     */
    function reconcile() external onlyOwner nonReentrant whenNotPaused {
        reconciliationAccount.reconcile();
    }

    /**
     * @notice create a new user and assign them a wallet contract
     *
     * @param _userId user identifier
     */
    function newUbiBeneficiary(string calldata _userId)
        external
        onlyOwner
        nonReentrant
        whenNotPaused
        userNotExist(keccak256(bytes(_userId)))
    {
        address newUBIBeneficiaryAddress = ubiFactory.createProxiedUBIBeneficiary(_userId);
        bytes32 key = keccak256(bytes(_userId));
        ubiBeneficiaries.set(uint256(key), newUBIBeneficiaryAddress);
        cUSDToken.transfer(newUBIBeneficiaryAddress, disbursementWei);

        emit NewUser(key, newUBIBeneficiaryAddress);
    }

    /**
     * @notice retrieve contract address for a UBI Beneficiary
     *
     * @param _userId user identifier
     * @return address of user's contract
     */
    function beneficiaryAddress(bytes32 _userId) public view returns (address) {
        return ubiBeneficiaries.get(uint256(_userId), "ERR_USER_NOT_EXIST");
    }

    /**
     * @notice Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     *
     * @dev In this override, we iterate all the existing UBIBeneficiary contracts
     * and change their owner before changing the owner of the core contract
     *
     * @param newOwner new owner of this contract
     * @inheritdoc Ownable
     *
     */
    function transferOwnership(address newOwner) public override onlyOwner {
        // 1 Update owner on all UBIBeneficiary contracts
        uint256 i;
        for (i = 0; i < ubiBeneficiaries.length(); i = i.add(1)) {
            address ubiBeneficiaryAddress;

            // .at function returns a tuple of (uint256, address)
            (, ubiBeneficiaryAddress) = ubiBeneficiaries.at(i);

            IUBIBeneficiary user = IUBIBeneficiary(ubiBeneficiaryAddress);
            user.transferController(newOwner);
        }

        // 2 Update reconciliation account owner, cast it as a
        //      IUBIBeneficiary to use the transferController function
        IUBIBeneficiary(address(reconciliationAccount)).transferController(newOwner);

        // 3 Update owner of this contract
        super.transferOwnership(newOwner);
    }

    /**
     * @notice Update implementation address for beneficiaries
     *
     * @param _newLogic New implementation logic for beneficiary proxies
     *
     */
    function updateBeneficiaryImplementation(address _newLogic) external onlyOwner {
        uint256 i;
        for (i = 0; i < ubiBeneficiaries.length(); i = i.add(1)) {
            address ubiBeneficiaryAddress;
            // .at function returns a tuple of (uint256, address)
            (, ubiBeneficiaryAddress) = ubiBeneficiaries.at(i);
            ubiFactory.updateProxyImplementation(ubiBeneficiaryAddress, _newLogic);
        }
    }

    /**
     * @notice Update implementation address for reconciliationAccount
     *
     * @param _newLogic New implementation logic for reconciliationAccount
     *
     */
    function updateReconciliationImplementation(address _newLogic) external onlyOwner {
        ubiFactory.updateProxyImplementation(address(reconciliationAccount), _newLogic);
    }

    /**
     * @notice Update demurrage parameters. Can only be called by the current owner.
     *
     * @param _blocksInEpoch Number of blocks in an epoch for this network
     * @param _demurrageFreeEpochs Number of epochs which are free of demurrage
     * @param _demurrageNumerator Numerator for demurrage ratio
     * @param _demurrageDenominator Denominator for demurrage ratio
     *
     */
    function setDemurrageParameters(
        uint256 _blocksInEpoch,
        uint256 _demurrageFreeEpochs,
        uint256 _demurrageNumerator,
        uint256 _demurrageDenominator
    ) external onlyOwner {
        uint256 i;
        for (i = 0; i < ubiBeneficiaries.length(); i = i.add(1)) {
            address ubiBeneficiaryAddress;
            // .at function returns a tuple of (uint256, address)
            (, ubiBeneficiaryAddress) = ubiBeneficiaries.at(i);
            IUBIBeneficiary user = IUBIBeneficiary(ubiBeneficiaryAddress);
            user.setDemurrageParameters(
                _blocksInEpoch,
                _demurrageFreeEpochs,
                _demurrageNumerator,
                _demurrageDenominator
            );
        }
    }

    /**
     * @notice Triggers stopped state.
     *
     * @dev Requirements: The contract must not be paused.
     */
    function pause() external onlyOwner nonReentrant {
        _pause();
    }

    /**
     * @notice Returns to normal state.
     *
     * @dev Requirements: The contract must be paused.
     */
    function unpause() external onlyOwner nonReentrant {
        _unpause();
    }

    /**
     * @notice Emergency withdrawal of all remaining cUSD to the custodian account
     *
     * @dev The contract must be paused
     * @dev Sends cUSD to current custodian from the current reconciliation account
     */
    function withdrawToCustodian() external onlyOwner whenPaused nonReentrant {
        uint256 balanceOf = cUSDToken.balanceOf(address(this));
        address custodian = reconciliationAccount.getCustodian();
        cUSDToken.transfer(custodian, balanceOf);
    }

    /**
     * @notice Emergency withdrawal of all remaining cUSD to the owner account
     *
     * @dev The contract must be paused
     * @dev Sends cUSD to current owner
     */
    function withdrawToOwner() external onlyOwner whenPaused nonReentrant {
        uint256 balanceOf = cUSDToken.balanceOf(address(this));
        cUSDToken.transfer(owner(), balanceOf);
    }

    /**
     * @notice Get beneficiary address at index
     * @dev Used for iterating the complete list of beneficiaries
     *
     */
    function getBeneficiaryAddressAtIndex(uint256 _index) external view returns (address) {
        // .at function returns a tuple of (uint256, address)
        address ubiBeneficiaryAddress;
        (, ubiBeneficiaryAddress) = ubiBeneficiaries.at(_index);

        return ubiBeneficiaryAddress;
    }

    /**
     * @notice Get count of beneficiaries
     *
     */
    function getBeneficiaryCount() external view returns (uint256) {
        return ubiBeneficiaries.length();
    }
}
        

/_openzeppelin/contracts/access/AccessControl.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    function hasRole(bytes32 role, address account) external view returns (bool);
    function getRoleAdmin(bytes32 role) external view returns (bytes32);
    function grantRole(bytes32 role, address account) external;
    function revokeRole(bytes32 role, address account) external;
    function renounceRole(bytes32 role, address account) external;
}

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

    mapping (bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev 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 {_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 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]{20}) is missing role (0x[0-9a-f]{32})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

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

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

    /**
     * @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]{20}) is missing role (0x[0-9a-f]{32})$/
     */
    function _checkRole(bytes32 role, address account) internal view {
        if(!hasRole(role, account)) {
            revert(string(abi.encodePacked(
                "AccessControl: account ",
                Strings.toHexString(uint160(account), 20),
                " is missing role ",
                Strings.toHexString(uint256(role), 32)
            )));
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view 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 granted `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}.
     * ====
     */
    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 {
        emit RoleAdminChanged(role, getRoleAdmin(role), adminRole);
        _roles[role].adminRole = adminRole;
    }

    function _grantRole(bytes32 role, address account) private {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}
          

/_openzeppelin/contracts/access/AccessControlEnumerable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerable {
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}

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

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

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

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

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

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

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

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

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

/_openzeppelin/contracts/access/Ownable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";
/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}
          

/_openzeppelin/contracts/security/Pausable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

    bool private _paused;

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

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

/_openzeppelin/contracts/security/ReentrancyGuard.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor () {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

/_openzeppelin/contracts/token/ERC20/ERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping (address => uint256) private _balances;

    mapping (address => mapping (address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The defaut value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        _approve(sender, _msgSender(), currentAllowance - amount);

        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        _approve(_msgSender(), spender, currentAllowance - subtractedValue);

        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        _balances[sender] = senderBalance - amount;
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        _balances[account] = accountBalance - amount;
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
          

/_openzeppelin/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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 `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool);

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

/_openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20Burnable is Context, ERC20 {
    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        uint256 currentAllowance = allowance(account, _msgSender());
        require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance");
        _approve(account, _msgSender(), currentAllowance - amount);
        _burn(account, amount);
    }
}
          

/_openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC20.sol";
import "../../../security/Pausable.sol";

/**
 * @dev ERC20 token with pausable token transfers, minting and burning.
 *
 * Useful for scenarios such as preventing trades until the end of an evaluation
 * period, or having an emergency switch for freezing all token transfers in the
 * event of a large bug.
 */
abstract contract ERC20Pausable is ERC20, Pausable {
    /**
     * @dev See {ERC20-_beforeTokenTransfer}.
     *
     * Requirements:
     *
     * - the contract must not be paused.
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
        super._beforeTokenTransfer(from, to, amount);

        require(!paused(), "ERC20Pausable: token transfer while paused");
    }
}
          

/_openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @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);
}
          

/_openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC20.sol";
import "../extensions/ERC20Burnable.sol";
import "../extensions/ERC20Pausable.sol";
import "../../../access/AccessControlEnumerable.sol";
import "../../../utils/Context.sol";

/**
 * @dev {ERC20} token, including:
 *
 *  - ability for holders to burn (destroy) their tokens
 *  - a minter role that allows for token minting (creation)
 *  - a pauser role that allows to stop all token transfers
 *
 * This contract uses {AccessControl} to lock permissioned functions using the
 * different roles - head to its documentation for details.
 *
 * The account that deploys the contract will be granted the minter and pauser
 * roles, as well as the default admin role, which will let it grant both minter
 * and pauser roles to other accounts.
 */
contract ERC20PresetMinterPauser is Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable {
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

    /**
     * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the
     * account that deploys the contract.
     *
     * See {ERC20-constructor}.
     */
    constructor(string memory name, string memory symbol) ERC20(name, symbol) {
        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());

        _setupRole(MINTER_ROLE, _msgSender());
        _setupRole(PAUSER_ROLE, _msgSender());
    }

    /**
     * @dev Creates `amount` new tokens for `to`.
     *
     * See {ERC20-_mint}.
     *
     * Requirements:
     *
     * - the caller must have the `MINTER_ROLE`.
     */
    function mint(address to, uint256 amount) public virtual {
        require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to mint");
        _mint(to, amount);
    }

    /**
     * @dev Pauses all token transfers.
     *
     * See {ERC20Pausable} and {Pausable-_pause}.
     *
     * Requirements:
     *
     * - the caller must have the `PAUSER_ROLE`.
     */
    function pause() public virtual {
        require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to pause");
        _pause();
    }

    /**
     * @dev Unpauses all token transfers.
     *
     * See {ERC20Pausable} and {Pausable-_unpause}.
     *
     * Requirements:
     *
     * - the caller must have the `PAUSER_ROLE`.
     */
    function unpause() public virtual {
        require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to unpause");
        _unpause();
    }

    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) {
        super._beforeTokenTransfer(from, to, amount);
    }
}
          

/_openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.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 SafeERC20 {
    using Address for address;

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

    function safeTransferFrom(IERC20 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(IERC20 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'
        // solhint-disable-next-line max-line-length
        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(IERC20 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(IERC20 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(IERC20 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
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}
          

/_openzeppelin/contracts/utils/Address.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 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");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        require(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 _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
          

/_openzeppelin/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

    function _msgData() internal view virtual returns (bytes calldata) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}
          

/_openzeppelin/contracts/utils/Strings.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant alphabet = "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] = alphabet[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

}
          

/_openzeppelin/contracts/utils/introspection/ERC165.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

/_openzeppelin/contracts/utils/introspection/IERC165.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/_openzeppelin/contracts/utils/math/SafeMath.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}
          

/_openzeppelin/contracts/utils/structs/EnumerableMap.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./EnumerableSet.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;
 * }
 * ```
 *
 * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are
 * supported.
 */
library EnumerableMap {
    using EnumerableSet for EnumerableSet.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 Map {
        // Storage of keys
        EnumerableSet.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(Map storage map, bytes32 key, bytes32 value) private 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(Map storage map, bytes32 key) private 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(Map storage map, bytes32 key) private view returns (bool) {
        return map._keys.contains(key);
    }

    /**
     * @dev Returns the number of key-value pairs in the map. O(1).
     */
    function _length(Map storage map) private 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(Map storage map, uint256 index) private 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(Map storage map, bytes32 key) private 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(Map storage map, bytes32 key) private 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(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {
        bytes32 value = map._values[key];
        require(value != 0 || _contains(map, key), errorMessage);
        return value;
    }

    // UintToAddressMap

    struct UintToAddressMap {
        Map _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))));
    }
}
          

/_openzeppelin/contracts/utils/structs/EnumerableSet.sol

// SPDX-License-Identifier: MIT

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 EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;

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

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

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

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

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

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            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) {
        require(set._values.length > index, "EnumerableSet: index out of bounds");
        return set._values[index];
    }

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

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


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

/home/boyd/git/keyko/celo-ubi-contract/contracts/interface/IUBIBeneficiary.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @title Celo UBI beneficiary contract interface
 *
 * @dev A simple wallet contract to hold specific ERC20 tokens that is controlled by an owner
 *
 * @author Aaron Boyd <https://github.com/aaronmboyd>
 */
interface IUBIBeneficiary {
    /**
     * @notice Triggered when an amount has been pre-authorized for a user
     *
     * @param _userId       Hashed bytes32 of the userId converted to uint256
     * @param _ubiAddress   Celo address of the UBI Beneficiary
     * @param _txId         Raw transaction ID for this event
     * @param _amt          Amount of the transaction
     */
    event AuthorizationEvent(
        bytes32 indexed _userId,
        address indexed _ubiAddress,
        string _txId,
        uint256 _amt
    );

    /**
     * @notice Triggered when an amount has been de-authorized for a user
     *
     * @param _userId       Hashed bytes32 of the userId converted to uint256
     * @param _ubiAddress   Celo address of the UBI Beneficiary
     * @param _txId         Raw transaction ID for this event
     */
    event DeauthorizationEvent(
        bytes32 indexed _userId,
        address indexed _ubiAddress,
        string _txId,
        uint256 _amt
    );

    /**
     * @notice Triggered when an amount has been settled for a user
     *
     * @param _userId       Hashed bytes32 of the userId converted to uint256
     * @param _ubiAddress   Celo address of the UBI Beneficiary
     * @param _txId         Raw transaction ID for this event
     * @param _amt          Amount of the transaction
     */
    event SettlementEvent(
        bytes32 indexed _userId,
        address indexed _ubiAddress,
        string _txId,
        uint256 _amt
    );

    /**
     * @notice Triggered when a demurrage charge has been paid back to the owner
     *
     * @param _userId       Hashed bytes32 of the userId converted to uint256
     * @param _ubiAddress   Celo address of the UBI Beneficiary
     * @param _txId         Raw transaction ID for this event
     * @param _amt          Demurrage amount paid
     */
    event DemurragePaidEvent(
        bytes32 indexed _userId,
        address indexed _ubiAddress,
        string _txId,
        uint256 _amt
    );

    /**
     * @notice Used to initialize a new UBIBeneficiary contract
     *
     * @param _cUSDToken token used for cUSD
     * @param _cUBIAuthToken token used for cUSD authorizations
     * @param _userId userId for the UBI beneficiary
     *
     * @dev Demurrage parameters defaulted to Celo: 17280 blocks/epoch, 28 epochs demurrage free, and 1% (1/100) per epoch after
     */
    function initialize(
        address _cUSDToken,
        address _cUBIAuthToken,
        address _controller,
        string memory _userId
    ) external;

    /**
     * @notice External entry point function for updating of updating demurrage parameters
     *
     * @param _blocksInEpoch Number of blocks in an epoch for this network
     * @param _demurrageFreeEpochs Number of epochs which are free of demurrage
     * @param _demurrageNumerator Numerator for demurrage ratio
     * @param _demurrageDenominator Denominator for demurrage ratio
     *
     */
    function setDemurrageParameters(
        uint256 _blocksInEpoch,
        uint256 _demurrageFreeEpochs,
        uint256 _demurrageNumerator,
        uint256 _demurrageDenominator
    ) external;

    /**
     * @notice Return array of settlementKeys
     *
     * @dev Note this is marked external, you cannot return dynamically sized data target is a Web3 caller for iterating Settlements
     *
     */
    function getSettlementKeys() external view returns (bytes32[] memory);

    /**
     * @notice Return array of authorizationsKeys
     *
     * @dev Note this is marked external, you cannot return dynamically sized data target is a Web3 caller for iterating Authorizations
     *
     */
    function getAuthorizationKeys() external view returns (bytes32[] memory);

    /**
     * @notice Return the primitive attributes of an Authorization struct
     *
     * @param _key Map key of the Authorization to return
     *
     */
    function getAuthorizationAtKey(bytes32 _key)
        external
        view
        returns (
            uint256,
            bool,
            string memory
        );

    /**
     * @notice Return the primitive attributes of an Settlement struct
     *
     * @param _key Map key of the Settlement to return
     *
     */
    function getSettlementAtKey(bytes32 _key) external view returns (uint256, string memory);

    /**
     * @notice retrieve available balance for this contract
     *
     * @return uint256 usable balance for this contract
     */
    function availableBalance() external view returns (uint256);

    /**
     * @notice retrieve authorization balance for this contract
     *
     * @return uint256 authorization balance for this contract
     */
    function authorizationBalance() external view returns (uint256);

    /**
     * @notice External method deauthorization
     *
     * @param _txId Dynamic string txId of the transaction to de-authorize
     *
     * @dev We don't need to specify the transaction size here because it is stored in the Authorization struct
     *
     */
    function deauthorize(string calldata _txId) external returns (uint256);

    /**
     * @notice Store a new authorization 

     * @param _txId Dynamic string txId of the transaction to authorize
     * @param _value uint256 transaction amount
     *
     *
    */
    function authorize(string calldata _txId, uint256 _value) external;

    /**
     * @notice Perform a settlement by returning cUSD token to the reconciliation contract
     *
     * @param _txId Dynamic string txId of the transaction to authorize
     * @param _value uint256 transaction amount
     * @param _reconciliationAccount Reconciliation account to send the cUSD to during settlement
     *
     * @dev If there was an existing authorization for this txId, de-authorize it, for the original authorization amount, regardless of the current settlement amount
     *
     */
    function settle(
        string calldata _txId,
        uint256 _value,
        address _reconciliationAccount
    ) external;

    /**
     * @notice Transfer control of the UBIBeneficiary
     *
     * @param _newController New owner address
     *
     */
    function transferController(address _newController) external;
}
          

/home/boyd/git/keyko/celo-ubi-contract/contracts/interface/IUBIBeneficiaryFactory.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IUBIBeneficiaryFactory {
    /**
     * @notice Triggered when a new UBIBeneficiary has been created
     *
     * @param _newUBIBeneficiaryAddress   Celo address of the UBI Beneficiary
     */
    event UBIBeneficiaryCreated(address _newUBIBeneficiaryAddress);

    /**
     * @notice Triggered when a new UBIReconciliationAccount has been created
     *
     * @param _newUBIReconciliationAccountAddress   Celo address of the UBI Reconciliation Account
     */
    event UBIReconciliationAccountCreated(address _newUBIReconciliationAccountAddress);

    /**
     * @notice Create a new UBI Beneficiary proxy contract
     *
     * @param _userId UserId of the new beneficiary
     *
     */
    function createProxiedUBIBeneficiary(string memory _userId) external returns (address);

    /**
     * @notice Create a new UBI Reconciliation proxy contract
     *
     * @param _custodian Address of the custodian target address
     *
     */
    function createProxiedUBIReconciliationAccount(address _custodian) external returns (address);

    /**
     * @notice Update proxy implementation address
     *
     * @param _proxy Address of either a UBIBeneficiary or ReconciliationAccount proxy
     * @param _newLogic Address of new implementation contract
     *
     */
    function updateProxyImplementation(address _proxy, address _newLogic) external;
}
          

/home/boyd/git/keyko/celo-ubi-contract/contracts/interface/IUBIReconciliationAccount.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IUBIBeneficiary.sol";

/**
 * @title Celo UBI reconciliation contract interface
 *
 * @dev This contract is a special version of a
 *      UBIBeneficiary that additionally sweeps
 *      cUSD to a known custodian address
 *
 * @author Aaron Boyd <https://github.com/aaronmboyd>
 */
interface IUBIReconciliationAccount is IUBIBeneficiary {
    /**
     * @notice triggered when an amount has been reconciled
     *
     * @param _custodian   reconciliation target
     * @param _amt   reconciliation amount
     */
    event Reconciled(address _custodian, uint256 _amt);

    /**
     * @notice triggered when the custodian has been updated
     *
     * @param _custodianPrevious   previous custodian
     * @param _custodianCurrent    current custodian
     */
    event CustodianUpdated(address _custodianPrevious, address _custodianCurrent);

    /**
     * @notice Used to initialize a new UBIReconciliationAccount contract
     *
     * @param _cUSDToken token used for cUSD
     * @param _cUBIAuthToken token used for cUSD authorizations
     * @param _custodian Address of the custodian
     *
     */
    function initialize(
        address _cUSDToken,
        address _cUBIAuthToken,
        address _custodian,
        address _controller
    ) external;

    /**
     * @notice reconcile the cUSD balance of this account and send to the custodian
     *
     */
    function reconcile() external;

    /**
     * @notice update the custodian address
     *
     * @param _custodian   new custodian address
     */
    function setCustodian(address _custodian) external;

    /**
     * @notice Get the custodian address
     */
    function getCustodian() external view returns (address);
}
          

/home/boyd/git/keyko/celo-ubi-contract/contracts/interface/IVersionedContract.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IVersionedContract {
    /**
     * @notice Returns the storage, major, minor, and patch version of the contract.
     * @return The storage, major, minor, and patch version of the contract.
     */
    function getVersionNumber()
        external
        pure
        returns (
            uint256,
            uint256,
            uint256,
            uint256
        );
}
          

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_cUSDToken","internalType":"address"},{"type":"address","name":"_cUBIAuthToken","internalType":"address"},{"type":"address","name":"_factory","internalType":"address"},{"type":"address","name":"_custodian","internalType":"address"}]},{"type":"event","name":"DisbursementUpdated","inputs":[{"type":"uint256","name":"_disbursementWei","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"FactoryUpdated","inputs":[{"type":"address","name":"_oldFactoryAddress","internalType":"address","indexed":true},{"type":"address","name":"_newFactoryAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"NewUser","inputs":[{"type":"bytes32","name":"_userId","internalType":"bytes32","indexed":true},{"type":"address","name":"_ubiAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"authBalanceOfUBIBeneficiary","inputs":[{"type":"bytes32","name":"_userId","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"authorize","inputs":[{"type":"bytes32","name":"_userId","internalType":"bytes32"},{"type":"string","name":"_txId","internalType":"string"},{"type":"uint256","name":"_value","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOfUBIBeneficiary","inputs":[{"type":"bytes32","name":"_userId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"beneficiaryAddress","inputs":[{"type":"bytes32","name":"_userId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ERC20PresetMinterPauser"}],"name":"cUBIAuthToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"cUSDToken","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"deauthorize","inputs":[{"type":"bytes32","name":"_userId","internalType":"bytes32"},{"type":"string","name":"_txId","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"disbursementWei","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getBeneficiaryAddressAtIndex","inputs":[{"type":"uint256","name":"_index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getBeneficiaryCount","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getVersionNumber","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"newUbiBeneficiary","inputs":[{"type":"string","name":"_userId","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"reconcile","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IUBIReconciliationAccount"}],"name":"reconciliationAccount","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setCustodian","inputs":[{"type":"address","name":"_custodian","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDemurrageParameters","inputs":[{"type":"uint256","name":"_blocksInEpoch","internalType":"uint256"},{"type":"uint256","name":"_demurrageFreeEpochs","internalType":"uint256"},{"type":"uint256","name":"_demurrageNumerator","internalType":"uint256"},{"type":"uint256","name":"_demurrageDenominator","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDisbursementWei","inputs":[{"type":"uint256","name":"_newDisbursementWei","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setUBIBeneficiaryFactory","inputs":[{"type":"address","name":"_newFactoryAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"settle","inputs":[{"type":"bytes32","name":"_userId","internalType":"bytes32"},{"type":"string","name":"_txId","internalType":"string"},{"type":"uint256","name":"_value","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IUBIBeneficiaryFactory"}],"name":"ubiFactory","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateBeneficiaryImplementation","inputs":[{"type":"address","name":"_newLogic","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateReconciliationImplementation","inputs":[{"type":"address","name":"_newLogic","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawToCustodian","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawToOwner","inputs":[]}]
              

Contract Creation Code

0x608060405268056bc75e2d631000006006553480156200001e57600080fd5b50604051620021b1380380620021b18339810160408190526200004191620001c0565b600080546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506000805460ff60a01b1916815560018055600280546001600160a01b038088166001600160a01b03199283161790925560038054878416908316179055600480549286169290911682178155604051635a72982560e11b815263b4e5304a91620000fd918691016001600160a01b0391909116815260200190565b602060405180830381600087803b1580156200011857600080fd5b505af11580156200012d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200015391906200019c565b600580546001600160a01b0319166001600160a01b0392909216919091179055506200021c9350505050565b80516001600160a01b03811681146200019757600080fd5b919050565b600060208284031215620001ae578081fd5b620001b9826200017f565b9392505050565b60008060008060808587031215620001d6578283fd5b620001e1856200017f565b9350620001f1602086016200017f565b925062000201604086016200017f565b915062000211606086016200017f565b905092959194509250565b611f85806200022c6000396000f3fe608060405234801561001057600080fd5b50600436106101da5760003560e01c80636bb3130e116101045780639a6e7fd1116100a2578063c6fb17a111610071578063c6fb17a1146103bf578063cf8bbcde146103d2578063f2fde38b146103e5578063f8713c95146103f857600080fd5b80639a6e7fd11461037e578063b8e2705914610386578063ba325b3d14610399578063bb0e1280146103ac57600080fd5b80638456cb59116100de5780638456cb591461034a5780638da5cb5b146103525780638f0d7e3514610363578063953bdf3d1461036b57600080fd5b80636bb3130e146103265780637062add11461032f578063715018a61461034257600080fd5b806340dc08591161017c5780635ba9bd721161014b5780635ba9bd72146102db5780635c975abb146102ee578063685b41571461030b5780636b0243301461031357600080fd5b806340dc08591461027b5780634d89a08a1461028e57806354255be0146102a15780635a59f630146102c857600080fd5b80633addc4e0116101b85780633addc4e0146102375780633cb40e16146102585780633f4ba83a14610260578063403f37311461026857600080fd5b80630a3f3fa6146101df5780630ea86ad81461020f5780631b633c5314610222575b600080fd5b6005546101f2906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6002546101f2906001600160a01b031681565b610235610230366004611c7f565b61040b565b005b61024a610245366004611c1d565b610601565b604051908152602001610206565b61023561068f565b610235610834565b610235610276366004611bc5565b610894565b610235610289366004611bc5565b610921565b61024a61029c366004611c1d565b6109f8565b60016002600082604080519485526020850193909352918301526060820152608001610206565b6101f26102d6366004611c1d565b610a46565b6102356102e9366004611c35565b610a54565b600054600160a01b900460ff166040519015158152602001610206565b610235610ae4565b6003546101f2906001600160a01b031681565b61024a60065481565b61023561033d366004611bc5565b610ced565b610235610d55565b610235610dc9565b6000546001600160a01b03166101f2565b610235610e23565b6101f2610379366004611c1d565b610f0d565b61024a610f4d565b610235610394366004611bc5565b610f5e565b6102356103a7366004611cd0565b610f94565b6102356103ba366004611d28565b6111f0565b6102356103cd366004611c1d565b6112cd565b6004546101f2906001600160a01b031681565b6102356103f3366004611bc5565b61132a565b610235610406366004611c7f565b61145c565b80600081116104525760405162461bcd60e51b815260206004820152600e60248201526d4552525f5a45524f5f56414c554560901b60448201526064015b60405180910390fd5b84828061045e83610601565b101561049d5760405162461bcd60e51b815260206004820152600e60248201526d4552525f4e4f5f42414c414e434560901b6044820152606401610449565b6000546001600160a01b031633146104c75760405162461bcd60e51b815260040161044990611eaa565b600260015414156104ea5760405162461bcd60e51b815260040161044990611edf565b6002600155600054600160a01b900460ff16156105195760405162461bcd60e51b815260040161044990611e80565b600061052660078961157e565b6003546040516340c10f1960e01b81526001600160a01b038084166004830152602482018990529293509116906340c10f1990604401600060405180830381600087803b15801561057657600080fd5b505af115801561058a573d6000803e3d6000fd5b50506040516367fac01360e01b81528392506001600160a01b03831691506367fac013906105c0908b908b908b90600401611da6565b600060405180830381600087803b1580156105da57600080fd5b505af11580156105ee573d6000803e3d6000fd5b5050600180555050505050505050505050565b60008061060f60078461157e565b90506000819050806001600160a01b031663ab2f0e516040518163ffffffff1660e01b815260040160206040518083038186803b15801561064f57600080fd5b505afa158015610663573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106879190611d10565b949350505050565b6000546001600160a01b031633146106b95760405162461bcd60e51b815260040161044990611eaa565b600054600160a01b900460ff166106e25760405162461bcd60e51b815260040161044990611e52565b600260015414156107055760405162461bcd60e51b815260040161044990611edf565b60026001819055546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b15801561074e57600080fd5b505afa158015610762573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107869190611d10565b6002549091506001600160a01b031663a9059cbb6107ac6000546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401602060405180830381600087803b1580156107f457600080fd5b505af1158015610808573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082c9190611bfd565b505060018055565b6000546001600160a01b0316331461085e5760405162461bcd60e51b815260040161044990611eaa565b600260015414156108815760405162461bcd60e51b815260040161044990611edf565b600260015561088e611591565b60018055565b6000546001600160a01b031633146108be5760405162461bcd60e51b815260040161044990611eaa565b60055460405163403f373160e01b81526001600160a01b0383811660048301529091169063403f3731906024015b600060405180830381600087803b15801561090657600080fd5b505af115801561091a573d6000803e3d6000fd5b5050505050565b6000546001600160a01b0316331461094b5760405162461bcd60e51b815260040161044990611eaa565b60005b6109586007611607565b8110156109f457600061096c600783611612565b60048054604051631cfa9cd160e11b81526001600160a01b038085169382019390935287831660248201529294501691506339f539a290604401600060405180830381600087803b1580156109c057600080fd5b505af11580156109d4573d6000803e3d6000fd5b50505050506109ed60018261163090919063ffffffff16565b905061094e565b5050565b600080610a0660078461157e565b90506000819050806001600160a01b031663f1e462696040518163ffffffff1660e01b815260040160206040518083038186803b15801561064f57600080fd5b600080610687600784611612565b6000546001600160a01b03163314610a7e5760405162461bcd60e51b815260040161044990611eaa565b60026001541415610aa15760405162461bcd60e51b815260040161044990611edf565b6002600155600054600160a01b900460ff1615610ad05760405162461bcd60e51b815260040161044990611e80565b610adb83838361163c565b50506001805550565b6000546001600160a01b03163314610b0e5760405162461bcd60e51b815260040161044990611eaa565b600054600160a01b900460ff16610b375760405162461bcd60e51b815260040161044990611e52565b60026001541415610b5a5760405162461bcd60e51b815260040161044990611edf565b60026001819055546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b158015610ba357600080fd5b505afa158015610bb7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bdb9190611d10565b90506000600560009054906101000a90046001600160a01b03166001600160a01b031663c561d4b76040518163ffffffff1660e01b815260040160206040518083038186803b158015610c2d57600080fd5b505afa158015610c41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c659190611be1565b60025460405163a9059cbb60e01b81526001600160a01b0380841660048301526024820186905292935091169063a9059cbb90604401602060405180830381600087803b158015610cb557600080fd5b505af1158015610cc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610adb9190611bfd565b6000546001600160a01b03163314610d175760405162461bcd60e51b815260040161044990611eaa565b60048054600554604051631cfa9cd160e11b81526001600160a01b0391821693810193909352838116602484015216906339f539a2906044016108ec565b6000546001600160a01b03163314610d7f5760405162461bcd60e51b815260040161044990611eaa565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b03163314610df35760405162461bcd60e51b815260040161044990611eaa565b60026001541415610e165760405162461bcd60e51b815260040161044990611edf565b600260015561088e611739565b6000546001600160a01b03163314610e4d5760405162461bcd60e51b815260040161044990611eaa565b60026001541415610e705760405162461bcd60e51b815260040161044990611edf565b6002600155600054600160a01b900460ff1615610e9f5760405162461bcd60e51b815260040161044990611e80565b600560009054906101000a90046001600160a01b03166001600160a01b0316638f0d7e356040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610eef57600080fd5b505af1158015610f03573d6000803e3d6000fd5b5050600180555050565b60408051808201909152601281527111549497d554d15497d393d517d1561254d560721b6020820152600090610f4790600790849061179e565b92915050565b6000610f596007611607565b905090565b6000546001600160a01b03163314610f885760405162461bcd60e51b815260040161044990611eaa565b610f91816117ab565b50565b6000546001600160a01b03163314610fbe5760405162461bcd60e51b815260040161044990611eaa565b60026001541415610fe15760405162461bcd60e51b815260040161044990611edf565b6002600155600054600160a01b900460ff16156110105760405162461bcd60e51b815260040161044990611e80565b8181604051611020929190611d82565b6040519081900390206110346007826117f7565b156110735760405162461bcd60e51b815260206004820152600f60248201526e4552525f555345525f45584953545360881b6044820152606401610449565b60048054604051634f9bf3f360e01b81526000926001600160a01b0390921691634f9bf3f3916110a7918891889101611d92565b602060405180830381600087803b1580156110c157600080fd5b505af11580156110d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f99190611be1565b90506000848460405161110d929190611d82565b604051908190039020905061112460078284611803565b5060025460065460405163a9059cbb60e01b81526001600160a01b038581166004830152602482019290925291169063a9059cbb90604401602060405180830381600087803b15801561117657600080fd5b505af115801561118a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ae9190611bfd565b506040516001600160a01b0383169082907f5fde7be6fd256edbbe1d991a982527a20d550875499314500d2e12fd1be2e83690600090a3505060018055505050565b6000546001600160a01b0316331461121a5760405162461bcd60e51b815260040161044990611eaa565b60005b6112276007611607565b81101561091a57600061123b600783611612565b6040516301761c2560e71b8152600481018990526024810188905260448101879052606481018690529092508291506001600160a01b0382169063bb0e128090608401600060405180830381600087803b15801561129857600080fd5b505af11580156112ac573d6000803e3d6000fd5b5050505050506112c660018261163090919063ffffffff16565b905061121d565b6000546001600160a01b031633146112f75760405162461bcd60e51b815260040161044990611eaa565b600681905560405181907ffcd679f840f581cf9cd88a11ed3203bbf677d301b56dbdca72a855ac9674671d90600090a250565b6000546001600160a01b031633146113545760405162461bcd60e51b815260040161044990611eaa565b60005b6113616007611607565b8110156113f4576000611375600783611612565b60405163e8ea054b60e01b81526001600160a01b0386811660048301529193508392509082169063e8ea054b90602401600060405180830381600087803b1580156113bf57600080fd5b505af11580156113d3573d6000803e3d6000fd5b5050505050506113ed60018261163090919063ffffffff16565b9050611357565b60055460405163e8ea054b60e01b81526001600160a01b0384811660048301529091169063e8ea054b90602401600060405180830381600087803b15801561143b57600080fd5b505af115801561144f573d6000803e3d6000fd5b505050506109f482611819565b806000811161149e5760405162461bcd60e51b815260206004820152600e60248201526d4552525f5a45524f5f56414c554560901b6044820152606401610449565b8482806114aa83610601565b10156114e95760405162461bcd60e51b815260206004820152600e60248201526d4552525f4e4f5f42414c414e434560901b6044820152606401610449565b6000546001600160a01b031633146115135760405162461bcd60e51b815260040161044990611eaa565b600260015414156115365760405162461bcd60e51b815260040161044990611edf565b6002600155600054600160a01b900460ff16156115655760405162461bcd60e51b815260040161044990611e80565b61157187878787611903565b5050600180555050505050565b600061158a838361194d565b9392505050565b600054600160a01b900460ff166115ba5760405162461bcd60e51b815260040161044990611e52565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000610f47826119bd565b600080808061162186866119c8565b909450925050505b9250929050565b600061158a8284611f16565b600061164960078561157e565b6040516308214b4f60e41b815290915081906000906001600160a01b03831690638214b4f09061167f9088908890600401611d92565b602060405180830381600087803b15801561169957600080fd5b505af11580156116ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d19190611d10565b600354604051630852cd8d60e31b8152600481018390529192506001600160a01b0316906342966c68906024015b600060405180830381600087803b15801561171957600080fd5b505af115801561172d573d6000803e3d6000fd5b50505050505050505050565b600054600160a01b900460ff16156117635760405162461bcd60e51b815260040161044990611e80565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586115ea3390565b60006106878484846119f3565b600480546001600160a01b0319166001600160a01b03831690811790915560405181907f333c7678baf16017cf31e1d2f90143a62aab01a67a0807f6836a4304ceabb55590600090a350565b600061158a8383611a3f565b600061068784846001600160a01b038516611a4b565b6000546001600160a01b031633146118435760405162461bcd60e51b815260040161044990611eaa565b6001600160a01b0381166118a85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610449565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600061191060078661157e565b600554604051637f20e06d60e11b815291925082916001600160a01b038084169263fe41c0da926116ff928a928a928a9290911690600401611dca565b60008181526002830160205260408120548015158061197157506119718484611a3f565b61158a5760405162461bcd60e51b815260206004820152601e60248201527f456e756d657261626c654d61703a206e6f6e6578697374656e74206b657900006044820152606401610449565b6000610f4782611a68565b600080806119d68585611a72565b600081815260029690960160205260409095205494959350505050565b600082815260028401602052604081205480151580611a175750611a178585611a3f565b8390611a365760405162461bcd60e51b81526004016104499190611dff565b50949350505050565b600061158a8383611a7e565b600082815260028401602052604081208290556106878484611a96565b6000610f47825490565b600061158a8383611aa2565b6000818152600183016020526040812054151561158a565b600061158a8383611b36565b81546000908210611b005760405162461bcd60e51b815260206004820152602260248201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604482015261647360f01b6064820152608401610449565b826000018281548110611b2357634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b6000818152600183016020526040812054611b7d57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610f47565b506000610f47565b60008083601f840112611b96578182fd5b50813567ffffffffffffffff811115611bad578182fd5b60208301915083602082850101111561162957600080fd5b600060208284031215611bd6578081fd5b813561158a81611f3a565b600060208284031215611bf2578081fd5b815161158a81611f3a565b600060208284031215611c0e578081fd5b8151801515811461158a578182fd5b600060208284031215611c2e578081fd5b5035919050565b600080600060408486031215611c49578182fd5b83359250602084013567ffffffffffffffff811115611c66578283fd5b611c7286828701611b85565b9497909650939450505050565b60008060008060608587031215611c94578081fd5b84359350602085013567ffffffffffffffff811115611cb1578182fd5b611cbd87828801611b85565b9598909750949560400135949350505050565b60008060208385031215611ce2578182fd5b823567ffffffffffffffff811115611cf8578283fd5b611d0485828601611b85565b90969095509350505050565b600060208284031215611d21578081fd5b5051919050565b60008060008060808587031215611d3d578384fd5b5050823594602084013594506040840135936060013592509050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8183823760009101908152919050565b602081526000610687602083018486611d59565b604081526000611dba604083018587611d59565b9050826020830152949350505050565b606081526000611dde606083018688611d59565b6020830194909452506001600160a01b039190911660409091015292915050565b6000602080835283518082850152825b81811015611e2b57858101830151858201604001528201611e0f565b81811115611e3c5783604083870101525b50601f01601f1916929092016040019392505050565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115611f3557634e487b7160e01b81526011600452602481fd5b500190565b6001600160a01b0381168114610f9157600080fdfea2646970667358221220bbd357a2c5e3af562000b1b3cd5495088cd4fb432165506092ba6043feba8b4b64736f6c63430008040033000000000000000000000000874069fa1eb16d44d622f2e0ca25eea172369bc1000000000000000000000000657b81b00f3ebc6952dbdb6cabe7255b46eea4ec0000000000000000000000002a37e81a9544670a1a6ba5d6ec22309d681725560000000000000000000000000000000000000000000000000000000000000001

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106101da5760003560e01c80636bb3130e116101045780639a6e7fd1116100a2578063c6fb17a111610071578063c6fb17a1146103bf578063cf8bbcde146103d2578063f2fde38b146103e5578063f8713c95146103f857600080fd5b80639a6e7fd11461037e578063b8e2705914610386578063ba325b3d14610399578063bb0e1280146103ac57600080fd5b80638456cb59116100de5780638456cb591461034a5780638da5cb5b146103525780638f0d7e3514610363578063953bdf3d1461036b57600080fd5b80636bb3130e146103265780637062add11461032f578063715018a61461034257600080fd5b806340dc08591161017c5780635ba9bd721161014b5780635ba9bd72146102db5780635c975abb146102ee578063685b41571461030b5780636b0243301461031357600080fd5b806340dc08591461027b5780634d89a08a1461028e57806354255be0146102a15780635a59f630146102c857600080fd5b80633addc4e0116101b85780633addc4e0146102375780633cb40e16146102585780633f4ba83a14610260578063403f37311461026857600080fd5b80630a3f3fa6146101df5780630ea86ad81461020f5780631b633c5314610222575b600080fd5b6005546101f2906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6002546101f2906001600160a01b031681565b610235610230366004611c7f565b61040b565b005b61024a610245366004611c1d565b610601565b604051908152602001610206565b61023561068f565b610235610834565b610235610276366004611bc5565b610894565b610235610289366004611bc5565b610921565b61024a61029c366004611c1d565b6109f8565b60016002600082604080519485526020850193909352918301526060820152608001610206565b6101f26102d6366004611c1d565b610a46565b6102356102e9366004611c35565b610a54565b600054600160a01b900460ff166040519015158152602001610206565b610235610ae4565b6003546101f2906001600160a01b031681565b61024a60065481565b61023561033d366004611bc5565b610ced565b610235610d55565b610235610dc9565b6000546001600160a01b03166101f2565b610235610e23565b6101f2610379366004611c1d565b610f0d565b61024a610f4d565b610235610394366004611bc5565b610f5e565b6102356103a7366004611cd0565b610f94565b6102356103ba366004611d28565b6111f0565b6102356103cd366004611c1d565b6112cd565b6004546101f2906001600160a01b031681565b6102356103f3366004611bc5565b61132a565b610235610406366004611c7f565b61145c565b80600081116104525760405162461bcd60e51b815260206004820152600e60248201526d4552525f5a45524f5f56414c554560901b60448201526064015b60405180910390fd5b84828061045e83610601565b101561049d5760405162461bcd60e51b815260206004820152600e60248201526d4552525f4e4f5f42414c414e434560901b6044820152606401610449565b6000546001600160a01b031633146104c75760405162461bcd60e51b815260040161044990611eaa565b600260015414156104ea5760405162461bcd60e51b815260040161044990611edf565b6002600155600054600160a01b900460ff16156105195760405162461bcd60e51b815260040161044990611e80565b600061052660078961157e565b6003546040516340c10f1960e01b81526001600160a01b038084166004830152602482018990529293509116906340c10f1990604401600060405180830381600087803b15801561057657600080fd5b505af115801561058a573d6000803e3d6000fd5b50506040516367fac01360e01b81528392506001600160a01b03831691506367fac013906105c0908b908b908b90600401611da6565b600060405180830381600087803b1580156105da57600080fd5b505af11580156105ee573d6000803e3d6000fd5b5050600180555050505050505050505050565b60008061060f60078461157e565b90506000819050806001600160a01b031663ab2f0e516040518163ffffffff1660e01b815260040160206040518083038186803b15801561064f57600080fd5b505afa158015610663573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106879190611d10565b949350505050565b6000546001600160a01b031633146106b95760405162461bcd60e51b815260040161044990611eaa565b600054600160a01b900460ff166106e25760405162461bcd60e51b815260040161044990611e52565b600260015414156107055760405162461bcd60e51b815260040161044990611edf565b60026001819055546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b15801561074e57600080fd5b505afa158015610762573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107869190611d10565b6002549091506001600160a01b031663a9059cbb6107ac6000546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401602060405180830381600087803b1580156107f457600080fd5b505af1158015610808573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082c9190611bfd565b505060018055565b6000546001600160a01b0316331461085e5760405162461bcd60e51b815260040161044990611eaa565b600260015414156108815760405162461bcd60e51b815260040161044990611edf565b600260015561088e611591565b60018055565b6000546001600160a01b031633146108be5760405162461bcd60e51b815260040161044990611eaa565b60055460405163403f373160e01b81526001600160a01b0383811660048301529091169063403f3731906024015b600060405180830381600087803b15801561090657600080fd5b505af115801561091a573d6000803e3d6000fd5b5050505050565b6000546001600160a01b0316331461094b5760405162461bcd60e51b815260040161044990611eaa565b60005b6109586007611607565b8110156109f457600061096c600783611612565b60048054604051631cfa9cd160e11b81526001600160a01b038085169382019390935287831660248201529294501691506339f539a290604401600060405180830381600087803b1580156109c057600080fd5b505af11580156109d4573d6000803e3d6000fd5b50505050506109ed60018261163090919063ffffffff16565b905061094e565b5050565b600080610a0660078461157e565b90506000819050806001600160a01b031663f1e462696040518163ffffffff1660e01b815260040160206040518083038186803b15801561064f57600080fd5b600080610687600784611612565b6000546001600160a01b03163314610a7e5760405162461bcd60e51b815260040161044990611eaa565b60026001541415610aa15760405162461bcd60e51b815260040161044990611edf565b6002600155600054600160a01b900460ff1615610ad05760405162461bcd60e51b815260040161044990611e80565b610adb83838361163c565b50506001805550565b6000546001600160a01b03163314610b0e5760405162461bcd60e51b815260040161044990611eaa565b600054600160a01b900460ff16610b375760405162461bcd60e51b815260040161044990611e52565b60026001541415610b5a5760405162461bcd60e51b815260040161044990611edf565b60026001819055546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b158015610ba357600080fd5b505afa158015610bb7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bdb9190611d10565b90506000600560009054906101000a90046001600160a01b03166001600160a01b031663c561d4b76040518163ffffffff1660e01b815260040160206040518083038186803b158015610c2d57600080fd5b505afa158015610c41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c659190611be1565b60025460405163a9059cbb60e01b81526001600160a01b0380841660048301526024820186905292935091169063a9059cbb90604401602060405180830381600087803b158015610cb557600080fd5b505af1158015610cc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610adb9190611bfd565b6000546001600160a01b03163314610d175760405162461bcd60e51b815260040161044990611eaa565b60048054600554604051631cfa9cd160e11b81526001600160a01b0391821693810193909352838116602484015216906339f539a2906044016108ec565b6000546001600160a01b03163314610d7f5760405162461bcd60e51b815260040161044990611eaa565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b03163314610df35760405162461bcd60e51b815260040161044990611eaa565b60026001541415610e165760405162461bcd60e51b815260040161044990611edf565b600260015561088e611739565b6000546001600160a01b03163314610e4d5760405162461bcd60e51b815260040161044990611eaa565b60026001541415610e705760405162461bcd60e51b815260040161044990611edf565b6002600155600054600160a01b900460ff1615610e9f5760405162461bcd60e51b815260040161044990611e80565b600560009054906101000a90046001600160a01b03166001600160a01b0316638f0d7e356040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610eef57600080fd5b505af1158015610f03573d6000803e3d6000fd5b5050600180555050565b60408051808201909152601281527111549497d554d15497d393d517d1561254d560721b6020820152600090610f4790600790849061179e565b92915050565b6000610f596007611607565b905090565b6000546001600160a01b03163314610f885760405162461bcd60e51b815260040161044990611eaa565b610f91816117ab565b50565b6000546001600160a01b03163314610fbe5760405162461bcd60e51b815260040161044990611eaa565b60026001541415610fe15760405162461bcd60e51b815260040161044990611edf565b6002600155600054600160a01b900460ff16156110105760405162461bcd60e51b815260040161044990611e80565b8181604051611020929190611d82565b6040519081900390206110346007826117f7565b156110735760405162461bcd60e51b815260206004820152600f60248201526e4552525f555345525f45584953545360881b6044820152606401610449565b60048054604051634f9bf3f360e01b81526000926001600160a01b0390921691634f9bf3f3916110a7918891889101611d92565b602060405180830381600087803b1580156110c157600080fd5b505af11580156110d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f99190611be1565b90506000848460405161110d929190611d82565b604051908190039020905061112460078284611803565b5060025460065460405163a9059cbb60e01b81526001600160a01b038581166004830152602482019290925291169063a9059cbb90604401602060405180830381600087803b15801561117657600080fd5b505af115801561118a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ae9190611bfd565b506040516001600160a01b0383169082907f5fde7be6fd256edbbe1d991a982527a20d550875499314500d2e12fd1be2e83690600090a3505060018055505050565b6000546001600160a01b0316331461121a5760405162461bcd60e51b815260040161044990611eaa565b60005b6112276007611607565b81101561091a57600061123b600783611612565b6040516301761c2560e71b8152600481018990526024810188905260448101879052606481018690529092508291506001600160a01b0382169063bb0e128090608401600060405180830381600087803b15801561129857600080fd5b505af11580156112ac573d6000803e3d6000fd5b5050505050506112c660018261163090919063ffffffff16565b905061121d565b6000546001600160a01b031633146112f75760405162461bcd60e51b815260040161044990611eaa565b600681905560405181907ffcd679f840f581cf9cd88a11ed3203bbf677d301b56dbdca72a855ac9674671d90600090a250565b6000546001600160a01b031633146113545760405162461bcd60e51b815260040161044990611eaa565b60005b6113616007611607565b8110156113f4576000611375600783611612565b60405163e8ea054b60e01b81526001600160a01b0386811660048301529193508392509082169063e8ea054b90602401600060405180830381600087803b1580156113bf57600080fd5b505af11580156113d3573d6000803e3d6000fd5b5050505050506113ed60018261163090919063ffffffff16565b9050611357565b60055460405163e8ea054b60e01b81526001600160a01b0384811660048301529091169063e8ea054b90602401600060405180830381600087803b15801561143b57600080fd5b505af115801561144f573d6000803e3d6000fd5b505050506109f482611819565b806000811161149e5760405162461bcd60e51b815260206004820152600e60248201526d4552525f5a45524f5f56414c554560901b6044820152606401610449565b8482806114aa83610601565b10156114e95760405162461bcd60e51b815260206004820152600e60248201526d4552525f4e4f5f42414c414e434560901b6044820152606401610449565b6000546001600160a01b031633146115135760405162461bcd60e51b815260040161044990611eaa565b600260015414156115365760405162461bcd60e51b815260040161044990611edf565b6002600155600054600160a01b900460ff16156115655760405162461bcd60e51b815260040161044990611e80565b61157187878787611903565b5050600180555050505050565b600061158a838361194d565b9392505050565b600054600160a01b900460ff166115ba5760405162461bcd60e51b815260040161044990611e52565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000610f47826119bd565b600080808061162186866119c8565b909450925050505b9250929050565b600061158a8284611f16565b600061164960078561157e565b6040516308214b4f60e41b815290915081906000906001600160a01b03831690638214b4f09061167f9088908890600401611d92565b602060405180830381600087803b15801561169957600080fd5b505af11580156116ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d19190611d10565b600354604051630852cd8d60e31b8152600481018390529192506001600160a01b0316906342966c68906024015b600060405180830381600087803b15801561171957600080fd5b505af115801561172d573d6000803e3d6000fd5b50505050505050505050565b600054600160a01b900460ff16156117635760405162461bcd60e51b815260040161044990611e80565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586115ea3390565b60006106878484846119f3565b600480546001600160a01b0319166001600160a01b03831690811790915560405181907f333c7678baf16017cf31e1d2f90143a62aab01a67a0807f6836a4304ceabb55590600090a350565b600061158a8383611a3f565b600061068784846001600160a01b038516611a4b565b6000546001600160a01b031633146118435760405162461bcd60e51b815260040161044990611eaa565b6001600160a01b0381166118a85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610449565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600061191060078661157e565b600554604051637f20e06d60e11b815291925082916001600160a01b038084169263fe41c0da926116ff928a928a928a9290911690600401611dca565b60008181526002830160205260408120548015158061197157506119718484611a3f565b61158a5760405162461bcd60e51b815260206004820152601e60248201527f456e756d657261626c654d61703a206e6f6e6578697374656e74206b657900006044820152606401610449565b6000610f4782611a68565b600080806119d68585611a72565b600081815260029690960160205260409095205494959350505050565b600082815260028401602052604081205480151580611a175750611a178585611a3f565b8390611a365760405162461bcd60e51b81526004016104499190611dff565b50949350505050565b600061158a8383611a7e565b600082815260028401602052604081208290556106878484611a96565b6000610f47825490565b600061158a8383611aa2565b6000818152600183016020526040812054151561158a565b600061158a8383611b36565b81546000908210611b005760405162461bcd60e51b815260206004820152602260248201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604482015261647360f01b6064820152608401610449565b826000018281548110611b2357634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b6000818152600183016020526040812054611b7d57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610f47565b506000610f47565b60008083601f840112611b96578182fd5b50813567ffffffffffffffff811115611bad578182fd5b60208301915083602082850101111561162957600080fd5b600060208284031215611bd6578081fd5b813561158a81611f3a565b600060208284031215611bf2578081fd5b815161158a81611f3a565b600060208284031215611c0e578081fd5b8151801515811461158a578182fd5b600060208284031215611c2e578081fd5b5035919050565b600080600060408486031215611c49578182fd5b83359250602084013567ffffffffffffffff811115611c66578283fd5b611c7286828701611b85565b9497909650939450505050565b60008060008060608587031215611c94578081fd5b84359350602085013567ffffffffffffffff811115611cb1578182fd5b611cbd87828801611b85565b9598909750949560400135949350505050565b60008060208385031215611ce2578182fd5b823567ffffffffffffffff811115611cf8578283fd5b611d0485828601611b85565b90969095509350505050565b600060208284031215611d21578081fd5b5051919050565b60008060008060808587031215611d3d578384fd5b5050823594602084013594506040840135936060013592509050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8183823760009101908152919050565b602081526000610687602083018486611d59565b604081526000611dba604083018587611d59565b9050826020830152949350505050565b606081526000611dde606083018688611d59565b6020830194909452506001600160a01b039190911660409091015292915050565b6000602080835283518082850152825b81811015611e2b57858101830151858201604001528201611e0f565b81811115611e3c5783604083870101525b50601f01601f1916929092016040019392505050565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115611f3557634e487b7160e01b81526011600452602481fd5b500190565b6001600160a01b0381168114610f9157600080fdfea2646970667358221220bbd357a2c5e3af562000b1b3cd5495088cd4fb432165506092ba6043feba8b4b64736f6c63430008040033