Address Details
contract

0x4eeE11Eb190c9F278aa05CafdED322dd3FAD49c3

Contract Name
Controller
Creator
0x9e7e40–1be6c5 at 0x420547–49cfd7
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
Fetching transactions...
Transfers
Fetching transfers...
Gas Used
Fetching gas used...
Last Balance Update
6508554
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
Controller




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




Optimization runs
200
EVM Version
istanbul




Verified at
2022-07-08T19:26:21.688164Z

/home/boyd/git/keyko/humanity-cash/local-currency-contracts/contracts/Controller.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/IWallet.sol";
import "./interface/IWalletFactory.sol";
import "./interface/IVersionedContract.sol";

/**
 * @title Controller contract
 *
 * @dev Administrative and orchestrator contract for local currencies
 *
 * @author Aaron Boyd <https://github.com/aaronmboyd>
 * @author Sebastian Gerske <https://github.com/h34d>
 */
contract Controller is
    IVersionedContract,
    AccessControlEnumerable,
    Ownable,
    Pausable,
    ReentrancyGuard
{
    using SafeMath for uint256;
    using SafeERC20 for ERC20PresetMinterPauser;
    using EnumerableMap for EnumerableMap.UintToAddressMap;

    bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
    bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");

    /**
     * @notice Triggered when a new user has been created
     *
     * @param _userId           Hashed bytes32 of the userId
     * @param _walletAddress    Address of the wallet
     */
    event NewUser(bytes32 indexed _userId, address indexed _walletAddress);

    /**
     * @notice Triggered when a user has deposited
     *
     * @param _userId           Hashed bytes32 of the userId
     * @param _operator         Address of the bank operator that fulfilled the deposit
     * @param _value            Value of the deposit
     */
    event UserDeposit(bytes32 indexed _userId, address indexed _operator, uint256 _value);

    /**
     * @notice Triggered when a user has withdrawn
     *
     * @param _userId           Hashed bytes32 of the userId
     * @param _operator         Address of the bank operator that will fulfill the withdrawal
     * @param _value            Value of the withdrawal
     */
    event UserWithdrawal(bytes32 indexed _userId, address indexed _operator, uint256 _value);    

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

    ERC20PresetMinterPauser public erc20Token;
    IWalletFactory public walletFactory;

    // Mapping of Wallet identifiers to their contract address
    EnumerableMap.UintToAddressMap private wallets;

    /**
     * @notice Used to initialize a new Controller contract
     *
     * @param _erc20Token token used
     */
    constructor(address _erc20Token, address _walletFactory) Ownable() {
        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
        _setupRole(ADMIN_ROLE, _msgSender());
        _setupRole(OPERATOR_ROLE, _msgSender());

        erc20Token = ERC20PresetMinterPauser(_erc20Token);
        walletFactory = IWalletFactory(_walletFactory);
    }

    /**********************************************************************
     *
     * View Methods
     *
     **********************************************************************/

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

    /**
     * @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(balanceOfWallet(_userId) >= _value, "ERR_NO_BALANCE");
        _;
    }

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

    /**
     * @notice Enforces a _userId exists
     */
    modifier userExist(bytes32 _userId) {
        require(wallets.contains(uint256(_userId)), "ERR_USER_NOT_EXISTS");
        _;
    }

    /**
     * @notice Retrieves the available balance of a wallet
     *
     * @param _userId user identifier
     * @return uint256 available balance
     */
    function balanceOfWallet(bytes32 _userId) public view returns (uint256) {
        address walletAddress = wallets.get(uint256(_userId));
        return balanceOfWallet(walletAddress);
    }

    /**
     * @notice Retrieves the available balance of a wallet
     *
     * @param _walletAddress wallet address
     * @return uint256 available balance
     */
    function balanceOfWallet(address _walletAddress) public view returns (uint256) {
        IWallet wallet = IWallet(_walletAddress);
        return wallet.availableBalance();
    }

    /**
     * @notice retrieve contract address for a Wallet
     *
     * @param _userId user identifier
     * @return address of user's contract
     */
    function getWalletAddress(bytes32 _userId) public view userExist(_userId) returns (address) {
        return wallets.get(uint256(_userId));
    }

    /**
     * @notice Get wallet address at index
     * @dev Used for iterating the complete list of wallets
     *
     */
    function getWalletAddressAtIndex(uint256 _index) external view returns (address) {
        // .at function returns a tuple of (uint256, address)
        address walletAddress;
        (, walletAddress) = wallets.at(_index);

        return walletAddress;
    }

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

    /**********************************************************************
     *
     * Operator Methods
     *
     **********************************************************************/

    /**
     * @notice Transfers a local currency token between two existing wallets
     *
     * @param _fromUserId   User identifier
     * @param _toUserId     Receiver identifier
     * @param _value        Amount to transfer
     */
    function transfer(
        bytes32 _fromUserId,
        bytes32 _toUserId,
        uint256 _value
    )
        external
        greaterThanZero(_value)
        userExist(_fromUserId)
        balanceAvailable(_fromUserId, _value)
        userExist(_toUserId)
        onlyRole(OPERATOR_ROLE)
        nonReentrant
        whenNotPaused
        returns (bool)
    {
        return _transfer(getWalletAddress(_fromUserId), getWalletAddress(_toUserId), _value);
    }

    function transfer(
        bytes32 _fromUserId,
        address _toAddress,
        uint256 _value
    )
        external
        greaterThanZero(_value)
        userExist(_fromUserId)
        balanceAvailable(_fromUserId, _value)
        onlyRole(OPERATOR_ROLE)
        nonReentrant
        whenNotPaused
        returns (bool)
    {
        return _transfer(getWalletAddress(_fromUserId), _toAddress, _value);
    }

    /**
     * @notice Internal implementation of transferring a local currency token between two existing wallets
     * @dev Implementation of external "transferTo" function so that it may be called internally without reentrancy guard incrementing
     *
     * @param _fromWallet   Sender wallet
     * @param _toWallet     Receiver wallet
     * @param _value        Amount to transfer
     */
    function _transfer(
        address _fromWallet,
        address _toWallet,
        uint256 _value
    ) private returns (bool) {
        return IWallet(_fromWallet).transferTo(IWallet(_toWallet), _value);
    }

    /**
     * @notice Deposits tokens in the wallet identified by the given user id
     *
     * @param _userId   User identifier
     * @param _value    Amount to deposit
     */
    function deposit(bytes32 _userId, uint256 _value)
        external
        greaterThanZero(_value)
        userExist(_userId)
        onlyRole(OPERATOR_ROLE)
        nonReentrant
        whenNotPaused
        returns (bool)
    {
        return _deposit(_userId, _value);
    }

    /**
     * @notice Internal implementation of deposits tokens in the wallet identified by the given user id
     *
     * @param _userId   User identifier
     * @param _value    Amount to deposit
     */
    function _deposit(bytes32 _userId, uint256 _value) private returns (bool) {
        address walletAddress = getWalletAddress(_userId);
        erc20Token.mint(walletAddress, _value);
        emit UserDeposit(_userId, msg.sender, _value);
        return true;
    }

    /**
     * @notice Withdraws tokens from the wallet identified by the given user id
     *
     * @param _userId   User identifier
     * @param _value    Amount to withdraw
     */
    function withdraw(bytes32 _userId, uint256 _value)
        external
        greaterThanZero(_value)
        userExist(_userId)
        onlyRole(OPERATOR_ROLE)
        nonReentrant
        whenNotPaused
        returns (bool)
    {
        return _withdraw(_userId, _value);
    }

    /**
     * @notice Internal implementation of withdraw tokens in the wallet identified by the given user id
     *
     * @param _userId   User identifier
     * @param _value    Amount to withdraw
     */
    function _withdraw(bytes32 _userId, uint256 _value) private returns (bool) {
        address walletAddress = getWalletAddress(_userId);
        IWallet(walletAddress).withdraw(_value);
        erc20Token.burn(_value);
        emit UserWithdrawal(_userId, msg.sender, _value);
        return true;
    }

    /**
     * @notice create a new user and assign them a wallet contract
     *
     * @param _userId user identifier
     */
    function newWallet(bytes32 _userId)
        external
        onlyRole(OPERATOR_ROLE)
        nonReentrant
        whenNotPaused
        userNotExist(_userId)
    {
        address newWalletAddress = walletFactory.createProxiedWallet(_userId);
        require(newWalletAddress != address(0x0), "ERR_WALLET_FAILED");

        wallets.set(uint256(_userId), newWalletAddress);

        emit NewUser(_userId, newWalletAddress);
    }

    /**********************************************************************
     *
     * Owner Methods
     *
     **********************************************************************/

    /**
     * @notice Public update to a new Wallet Factory
     *
     * @param _newFactoryAddress   new factory address
     */
    function setWalletFactory(address _newFactoryAddress) external onlyOwner {
        _setWalletFactory(_newFactoryAddress);
    }

    /**
     * @notice Internal implementation of update to a new Wallet Factory
     *
     * @param _newFactoryAddress   new factory address
     */
    function _setWalletFactory(address _newFactoryAddress) private {
        walletFactory = IWalletFactory(_newFactoryAddress);
        emit FactoryUpdated(address(walletFactory), _newFactoryAddress);
    }

    /**
     * @notice Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     *
     *
     * @param newOwner new owner of this contract
     *
     */
    function transferContractOwnership(address newOwner) public onlyOwner {
        super.transferOwnership(newOwner);
    }

    /**
     * @notice Transfers ownership of the wallet to a new account (`newOwner`).
     * Can only be called by the current owner.
     *
     *
     * @param newOwner new owner of wallet
     * @param userId current owner of the wallet
     *
     */
    function transferWalletOwnership(address newOwner, bytes32 userId) public onlyOwner {
        address walletAddress = getWalletAddress(userId);
        IWallet user = IWallet(walletAddress);
        user.transferController(newOwner);
    }

    /**
     * @notice Update implementation address for wallets
     *
     * @param _newLogic New implementation logic for wallet proxies
     *
     */
    function updateWalletImplementation(address _newLogic) external onlyOwner {
        uint256 i;
        for (i = 0; i < wallets.length(); i = i.add(1)) {
            address walletAddress;
            // .at function returns a tuple of (uint256, address)
            (, walletAddress) = wallets.at(i);
            walletFactory.updateProxyImplementation(walletAddress, _newLogic);
        }
    }

    /**
     * @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 token to the owner account
     *
     * @dev The contract must be paused
     * @dev Sends erc20 to current owner
     */
    function withdrawToOwner() external onlyOwner whenPaused nonReentrant {
        uint256 balanceOf = erc20Token.balanceOf(address(this));
        erc20Token.transfer(owner(), balanceOf);
    }
}
        

/_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/humanity-cash/local-currency-contracts/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
        );
}
          

/home/boyd/git/keyko/humanity-cash/local-currency-contracts/contracts/interface/IWallet.sol

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

/**
 * @title Wallet 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>
 * @author Sebastian Gerske <https://github.com/h34d>
 */
interface IWallet {
    /**
     * @notice Triggered when an amount has been transferred from one wallet to another
     *
     * @param _fromUserId       Hashed bytes32 of the sender
     * @param _toUserId         Hashed bytes32 of the receiver
     * @param _amt              Amount of the transaction
     */
    event TransferToEvent(bytes32 indexed _fromUserId, bytes32 indexed _toUserId, uint256 _amt);

    /**
     * @notice Triggered when an amount has been transferred from one wallet to another
     *
     * @param _fromUserId       Hashed bytes32 of the sender
     * @param _toAddress        Address of the receiver
     * @param _amt              Amount of the transaction
     */
    event TransferToEvent(bytes32 indexed _fromUserId, address indexed _toAddress, uint256 _amt);

    /**
     * @notice Used to initialize a new Wallet contract
     *
     * @param _erc20token token used
     * @param _userId userId for the wallet
     *
     */
    function initialize(
        address _erc20token,
        address _controller,
        bytes32 _userId
    ) external;

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

    /**
     * @notice Performs a transfer from one wallet to another
     *
     * @param _toWallet     IWallet wallet to transfer to
     * @param _value        uint256 transaction amount
     *
     */
    function transferTo(IWallet _toWallet, uint256 _value) external returns (bool);

    /**
     * @notice Performs a withdrawal to the controller
     *
     * @param _value        uint256 transaction amount
     *
     */
    function withdraw(uint256 _value) external returns (bool);    

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

/home/boyd/git/keyko/humanity-cash/local-currency-contracts/contracts/interface/IWalletFactory.sol

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

interface IWalletFactory {
    /**
     * @notice Triggered when a new Wallet has been created
     *
     * @param _newWalletAddress   Address of the Wallet
     */
    event WalletCreated(address _newWalletAddress);

    /**
     * @notice Create a new Wallet proxy contract
     *
     * @param _userId UserId of the new wallet
     *
     */
    function createProxiedWallet(bytes32 _userId) external returns (address);

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

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_erc20Token","internalType":"address"},{"type":"address","name":"_walletFactory","internalType":"address"}]},{"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":"_walletAddress","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":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"UserDeposit","inputs":[{"type":"bytes32","name":"_userId","internalType":"bytes32","indexed":true},{"type":"address","name":"_operator","internalType":"address","indexed":true},{"type":"uint256","name":"_value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"UserWithdrawal","inputs":[{"type":"bytes32","name":"_userId","internalType":"bytes32","indexed":true},{"type":"address","name":"_operator","internalType":"address","indexed":true},{"type":"uint256","name":"_value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"OPERATOR_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOfWallet","inputs":[{"type":"address","name":"_walletAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOfWallet","inputs":[{"type":"bytes32","name":"_userId","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"deposit","inputs":[{"type":"bytes32","name":"_userId","internalType":"bytes32"},{"type":"uint256","name":"_value","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ERC20PresetMinterPauser"}],"name":"erc20Token","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getRoleMember","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getRoleMemberCount","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"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":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getWalletAddress","inputs":[{"type":"bytes32","name":"_userId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getWalletAddressAtIndex","inputs":[{"type":"uint256","name":"_index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getWalletCount","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"newWallet","inputs":[{"type":"bytes32","name":"_userId","internalType":"bytes32"}]},{"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":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setWalletFactory","inputs":[{"type":"address","name":"_newFactoryAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transfer","inputs":[{"type":"bytes32","name":"_fromUserId","internalType":"bytes32"},{"type":"address","name":"_toAddress","internalType":"address"},{"type":"uint256","name":"_value","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transfer","inputs":[{"type":"bytes32","name":"_fromUserId","internalType":"bytes32"},{"type":"bytes32","name":"_toUserId","internalType":"bytes32"},{"type":"uint256","name":"_value","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferContractOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferWalletOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"},{"type":"bytes32","name":"userId","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateWalletImplementation","inputs":[{"type":"address","name":"_newLogic","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IWalletFactory"}],"name":"walletFactory","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"withdraw","inputs":[{"type":"bytes32","name":"_userId","internalType":"bytes32"},{"type":"uint256","name":"_value","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawToOwner","inputs":[]}]
              

Contract Creation Code

0x60806040523480156200001157600080fd5b50604051620024da380380620024da8339810160408190526200003491620002a2565b600280546001600160a01b0319163390811790915560405181906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506002805460ff60a01b1916905560016003556200009660003362000120565b620000c27fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217753362000120565b620000ee7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9293362000120565b600480546001600160a01b039384166001600160a01b03199182161790915560058054929093169116179055620002d9565b6200013782826200016360201b620012531760201c565b60008281526001602090815260409091206200015e9183906200125d62000173821b17901c565b505050565b6200016f828262000193565b5050565b60006200018a836001600160a01b03841662000233565b90505b92915050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff166200016f576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620001ef3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008181526001830160205260408120546200027c575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556200018d565b5060006200018d565b80516001600160a01b03811681146200029d57600080fd5b919050565b60008060408385031215620002b5578182fd5b620002c08362000285565b9150620002d06020840162000285565b90509250929050565b6121f180620002e96000396000f3fe608060405234801561001057600080fd5b50600436106102115760003560e01c8063745bd5a211610125578063a217fddf116100ad578063c5c036991161007c578063c5c0369914610480578063ca15c87314610493578063d547741f146104a6578063f2fde38b146104b9578063f5b541a6146104cc57600080fd5b8063a217fddf1461043f578063a843c51f14610447578063ae9f75e31461045a578063c377f7911461046d57600080fd5b80638a13eea7116100f45780638a13eea7146103e25780638da5cb5b146103f55780639010d07c1461040657806391d148541461041957806392425c591461042c57600080fd5b8063745bd5a21461039857806375b238fc146103a05780637ebf879c146103c75780638456cb59146103da57600080fd5b80632f2ff15d116101a85780633feb1bd8116101775780633feb1bd81461033157806354255be01461034457806359ba0f4b1461036b5780635c975abb1461037e578063715018a61461039057600080fd5b80632f2ff15d146102fb57806336568abe1461030e5780633cb40e16146103215780633f4ba83a1461032957600080fd5b8063206d54db116101e4578063206d54db1461027957806323b86fbe146102a4578063248a9ca3146102c55780632db46cc2146102e857600080fd5b806301ffc9a714610216578063040cf0201461023e57806306d63fed146102515780631de26e1614610266575b600080fd5b610229610224366004611f08565b6104e1565b60405190151581526020015b60405180910390f35b61022961024c366004611ee7565b61050c565b61026461025f366004611e3e565b6105e4565b005b610229610274366004611ee7565b6107b3565b61028c610287366004611e3e565b610873565b6040516001600160a01b039091168152602001610235565b6102b76102b2366004611dbb565b6108af565b604051908152602001610235565b6102b76102d3366004611e3e565b60009081526020819052604090206001015490565b61028c6102f6366004611e3e565b610926565b610264610309366004611e56565b61093c565b61026461031c366004611e56565b610963565b610264610985565b610264610b57565b61022961033f366004611e85565b610bb8565b60016002600080604080519485526020850193909352918301526060820152608001610235565b610264610379366004611dbb565b610cde565b600254600160a01b900460ff16610229565b610264610db3565b6102b7610e27565b6102b77fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b6102646103d5366004611dbb565b610e38565b610264610e6e565b60045461028c906001600160a01b031681565b6002546001600160a01b031661028c565b61028c610414366004611ee7565b610ec8565b610229610427366004611e56565b610ee0565b61026461043a366004611df3565b610f09565b6102b7600081565b610264610455366004611dbb565b610fa4565b610229610468366004611ebc565b610fd7565b6102b761047b366004611e3e565b61112e565b60055461028c906001600160a01b031681565b6102b76104a1366004611e3e565b611147565b6102646104b4366004611e56565b61115e565b6102646104c7366004611dbb565b611168565b6102b760008051602061219c83398151915281565b60006001600160e01b03198216635a05180f60e01b1480610506575061050682611272565b92915050565b600081600081116105385760405162461bcd60e51b815260040161052f9061201a565b60405180910390fd5b836105446006826112a7565b6105605760405162461bcd60e51b815260040161052f90612077565b60008051602061219c83398151915261057981336112b3565b6002600354141561059c5760405162461bcd60e51b815260040161052f906120a4565b6002600381905554600160a01b900460ff16156105cb5760405162461bcd60e51b815260040161052f90611ff0565b6105d58686611317565b60016003559695505050505050565b60008051602061219c8339815191526105fd81336112b3565b600260035414156106205760405162461bcd60e51b815260040161052f906120a4565b6002600381905554600160a01b900460ff161561064f5760405162461bcd60e51b815260040161052f90611ff0565b8161065b6006826112a7565b1561069a5760405162461bcd60e51b815260206004820152600f60248201526e4552525f555345525f45584953545360881b604482015260640161052f565b6005546040516322564ce960e01b8152600481018590526000916001600160a01b0316906322564ce990602401602060405180830381600087803b1580156106e157600080fd5b505af11580156106f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107199190611dd7565b90506001600160a01b0381166107655760405162461bcd60e51b815260206004820152601160248201527011549497d5d05313115517d19052531151607a1b604482015260640161052f565b6107716006858361143f565b506040516001600160a01b0382169085907f5fde7be6fd256edbbe1d991a982527a20d550875499314500d2e12fd1be2e83690600090a3505060016003555050565b600081600081116107d65760405162461bcd60e51b815260040161052f9061201a565b836107e26006826112a7565b6107fe5760405162461bcd60e51b815260040161052f90612077565b60008051602061219c83398151915261081781336112b3565b6002600354141561083a5760405162461bcd60e51b815260040161052f906120a4565b6002600381905554600160a01b900460ff16156108695760405162461bcd60e51b815260040161052f90611ff0565b6105d58686611455565b6000816108816006826112a7565b61089d5760405162461bcd60e51b815260040161052f90612077565b6108a86006846114ff565b9392505050565b600080829050806001600160a01b031663ab2f0e516040518163ffffffff1660e01b815260040160206040518083038186803b1580156108ee57600080fd5b505afa158015610902573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a89190611f30565b60008061093460068461150b565b949350505050565b6109468282611527565b600082815260016020526040902061095e908261125d565b505050565b61096d828261154d565b600082815260016020526040902061095e90826115c7565b6002546001600160a01b031633146109af5760405162461bcd60e51b815260040161052f90612042565b600254600160a01b900460ff166109ff5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161052f565b60026003541415610a225760405162461bcd60e51b815260040161052f906120a4565b6002600355600480546040516370a0823160e01b815230928101929092526000916001600160a01b03909116906370a082319060240160206040518083038186803b158015610a7057600080fd5b505afa158015610a84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa89190611f30565b6004549091506001600160a01b031663a9059cbb610ace6002546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401602060405180830381600087803b158015610b1657600080fd5b505af1158015610b2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b4e9190611e1e565b50506001600355565b6002546001600160a01b03163314610b815760405162461bcd60e51b815260040161052f90612042565b60026003541415610ba45760405162461bcd60e51b815260040161052f906120a4565b6002600355610bb16115dc565b6001600355565b60008160008111610bdb5760405162461bcd60e51b815260040161052f9061201a565b84610be76006826112a7565b610c035760405162461bcd60e51b815260040161052f90612077565b858480610c0f8361112e565b1015610c4e5760405162461bcd60e51b815260206004820152600e60248201526d4552525f4e4f5f42414c414e434560901b604482015260640161052f565b60008051602061219c833981519152610c6781336112b3565b60026003541415610c8a5760405162461bcd60e51b815260040161052f906120a4565b6002600381905554600160a01b900460ff1615610cb95760405162461bcd60e51b815260040161052f90611ff0565b610ccc610cc58a610873565b8989611679565b60016003559998505050505050505050565b6002546001600160a01b03163314610d085760405162461bcd60e51b815260040161052f90612042565b60005b610d1560066116ff565b811015610daf576000610d2960068361150b565b600554604051631cfa9cd160e11b81526001600160a01b0380841660048301528781166024830152929450911691506339f539a290604401600060405180830381600087803b158015610d7b57600080fd5b505af1158015610d8f573d6000803e3d6000fd5b5050505050610da860018261170a90919063ffffffff16565b9050610d0b565b5050565b6002546001600160a01b03163314610ddd5760405162461bcd60e51b815260040161052f90612042565b6002546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600280546001600160a01b0319169055565b6000610e3360066116ff565b905090565b6002546001600160a01b03163314610e625760405162461bcd60e51b815260040161052f90612042565b610e6b81611716565b50565b6002546001600160a01b03163314610e985760405162461bcd60e51b815260040161052f90612042565b60026003541415610ebb5760405162461bcd60e51b815260040161052f906120a4565b6002600355610bb1611762565b60008281526001602052604081206108a890836117c7565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6002546001600160a01b03163314610f335760405162461bcd60e51b815260040161052f90612042565b6000610f3e82610873565b60405163e8ea054b60e01b81526001600160a01b038581166004830152919250829182169063e8ea054b90602401600060405180830381600087803b158015610f8657600080fd5b505af1158015610f9a573d6000803e3d6000fd5b5050505050505050565b6002546001600160a01b03163314610fce5760405162461bcd60e51b815260040161052f90612042565b610e6b81611168565b60008160008111610ffa5760405162461bcd60e51b815260040161052f9061201a565b846110066006826112a7565b6110225760405162461bcd60e51b815260040161052f90612077565b85848061102e8361112e565b101561106d5760405162461bcd60e51b815260206004820152600e60248201526d4552525f4e4f5f42414c414e434560901b604482015260640161052f565b866110796006826112a7565b6110955760405162461bcd60e51b815260040161052f90612077565b60008051602061219c8339815191526110ae81336112b3565b600260035414156110d15760405162461bcd60e51b815260040161052f906120a4565b6002600381905554600160a01b900460ff16156111005760405162461bcd60e51b815260040161052f90611ff0565b61111b61110c8b610873565b6111158b610873565b8a611679565b60016003559a9950505050505050505050565b60008061113c6006846114ff565b90506108a8816108af565b6000818152600160205260408120610506906117d3565b61096d82826117dd565b6002546001600160a01b031633146111925760405162461bcd60e51b815260040161052f90612042565b6001600160a01b0381166111f75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161052f565b6002546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600280546001600160a01b0319166001600160a01b0392909216919091179055565b610daf8282611803565b60006108a8836001600160a01b038416611887565b60006001600160e01b03198216637965db0b60e01b148061050657506301ffc9a760e01b6001600160e01b0319831614610506565b60006108a883836118d6565b6112bd8282610ee0565b610daf576112d5816001600160a01b031660146118e2565b6112e08360206118e2565b6040516020016112f1929190611f48565b60408051601f198184030181529082905262461bcd60e51b825261052f91600401611fbd565b60008061132384610873565b604051632e1a7d4d60e01b8152600481018590529091506001600160a01b03821690632e1a7d4d90602401602060405180830381600087803b15801561136857600080fd5b505af115801561137c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113a09190611e1e565b5060048054604051630852cd8d60e31b81529182018590526001600160a01b0316906342966c6890602401600060405180830381600087803b1580156113e557600080fd5b505af11580156113f9573d6000803e3d6000fd5b50506040518581523392508691507ff62f20a4adbb89ff8dcdaf45470cad695fc6836ef5428e9327e5559e19ac6ef6906020015b60405180910390a35060019392505050565b600061093484846001600160a01b038516611ac4565b60008061146184610873565b600480546040516340c10f1960e01b81526001600160a01b03808516938201939093526024810187905292935016906340c10f1990604401600060405180830381600087803b1580156114b357600080fd5b505af11580156114c7573d6000803e3d6000fd5b50506040518581523392508691507f44619ddf3e3d73c6119aad5af53198c818ba8612dc3ad035e358493523bd681f9060200161142d565b60006108a88383611ae1565b600080808061151a8686611b51565b9097909650945050505050565b60008281526020819052604090206001015461154381336112b3565b61095e8383611803565b6001600160a01b03811633146115bd5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161052f565b610daf8282611b7c565b60006108a8836001600160a01b038416611be1565b600254600160a01b900460ff1661162c5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161052f565b6002805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6040516302ccb1b360e41b81526001600160a01b0383811660048301526024820183905260009190851690632ccb1b3090604401602060405180830381600087803b1580156116c757600080fd5b505af11580156116db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109349190611e1e565b600061050682611cf8565b60006108a882846120db565b600580546001600160a01b0319166001600160a01b03831690811790915560405181907f333c7678baf16017cf31e1d2f90143a62aab01a67a0807f6836a4304ceabb55590600090a350565b600254600160a01b900460ff161561178c5760405162461bcd60e51b815260040161052f90611ff0565b6002805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861165c3390565b60006108a88383611d03565b6000610506825490565b6000828152602081905260409020600101546117f981336112b3565b61095e8383611b7c565b61180d8282610ee0565b610daf576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556118433390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008181526001830160205260408120546118ce57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610506565b506000610506565b60006108a88383611d97565b606060006118f18360026120f3565b6118fc9060026120db565b67ffffffffffffffff81111561192257634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561194c576020820181803683370190505b509050600360fc1b8160008151811061197557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106119b257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006119d68460026120f3565b6119e19060016120db565b90505b6001811115611a75576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611a2357634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110611a4757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93611a6e81612159565b90506119e4565b5083156108a85760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161052f565b600082815260028401602052604081208290556109348484611daf565b600081815260028301602052604081205480151580611b055750611b0584846118d6565b6108a85760405162461bcd60e51b815260206004820152601e60248201527f456e756d657261626c654d61703a206e6f6e6578697374656e74206b65790000604482015260640161052f565b60008080611b5f85856117c7565b600081815260029690960160205260409095205494959350505050565b611b868282610ee0565b15610daf576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008181526001830160205260408120548015611cee576000611c05600183612112565b8554909150600090611c1990600190612112565b90506000866000018281548110611c4057634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080876000018481548110611c7157634e487b7160e01b600052603260045260246000fd5b600091825260208083209091019290925582815260018901909152604090208490558654879080611cb257634e487b7160e01b600052603160045260246000fd5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610506565b6000915050610506565b6000610506826117d3565b81546000908210611d615760405162461bcd60e51b815260206004820152602260248201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604482015261647360f01b606482015260840161052f565b826000018281548110611d8457634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b600081815260018301602052604081205415156108a8565b60006108a88383611887565b600060208284031215611dcc578081fd5b81356108a881612186565b600060208284031215611de8578081fd5b81516108a881612186565b60008060408385031215611e05578081fd5b8235611e1081612186565b946020939093013593505050565b600060208284031215611e2f578081fd5b815180151581146108a8578182fd5b600060208284031215611e4f578081fd5b5035919050565b60008060408385031215611e68578182fd5b823591506020830135611e7a81612186565b809150509250929050565b600080600060608486031215611e99578081fd5b833592506020840135611eab81612186565b929592945050506040919091013590565b600080600060608486031215611ed0578283fd5b505081359360208301359350604090920135919050565b60008060408385031215611ef9578182fd5b50508035926020909101359150565b600060208284031215611f19578081fd5b81356001600160e01b0319811681146108a8578182fd5b600060208284031215611f41578081fd5b5051919050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611f80816017850160208801612129565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351611fb1816028840160208801612129565b01602801949350505050565b6020815260008251806020840152611fdc816040850160208701612129565b601f01601f19169190910160400192915050565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252600e908201526d4552525f5a45524f5f56414c554560901b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601390820152724552525f555345525f4e4f545f45584953545360681b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600082198211156120ee576120ee612170565b500190565b600081600019048311821515161561210d5761210d612170565b500290565b60008282101561212457612124612170565b500390565b60005b8381101561214457818101518382015260200161212c565b83811115612153576000848401525b50505050565b60008161216857612168612170565b506000190190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b0381168114610e6b57600080fdfe97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929a264697066735822122005437a5bac5b1c4cf1a651a83dcbce1f7be1abf58042679096ebe5ac3dec2b4464736f6c634300080400330000000000000000000000009fa5c4b86d51a35c86140c6398780a1aa14423ee00000000000000000000000017c6c4273128923fdf3b1d4bf4947d117eabd3ed

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106102115760003560e01c8063745bd5a211610125578063a217fddf116100ad578063c5c036991161007c578063c5c0369914610480578063ca15c87314610493578063d547741f146104a6578063f2fde38b146104b9578063f5b541a6146104cc57600080fd5b8063a217fddf1461043f578063a843c51f14610447578063ae9f75e31461045a578063c377f7911461046d57600080fd5b80638a13eea7116100f45780638a13eea7146103e25780638da5cb5b146103f55780639010d07c1461040657806391d148541461041957806392425c591461042c57600080fd5b8063745bd5a21461039857806375b238fc146103a05780637ebf879c146103c75780638456cb59146103da57600080fd5b80632f2ff15d116101a85780633feb1bd8116101775780633feb1bd81461033157806354255be01461034457806359ba0f4b1461036b5780635c975abb1461037e578063715018a61461039057600080fd5b80632f2ff15d146102fb57806336568abe1461030e5780633cb40e16146103215780633f4ba83a1461032957600080fd5b8063206d54db116101e4578063206d54db1461027957806323b86fbe146102a4578063248a9ca3146102c55780632db46cc2146102e857600080fd5b806301ffc9a714610216578063040cf0201461023e57806306d63fed146102515780631de26e1614610266575b600080fd5b610229610224366004611f08565b6104e1565b60405190151581526020015b60405180910390f35b61022961024c366004611ee7565b61050c565b61026461025f366004611e3e565b6105e4565b005b610229610274366004611ee7565b6107b3565b61028c610287366004611e3e565b610873565b6040516001600160a01b039091168152602001610235565b6102b76102b2366004611dbb565b6108af565b604051908152602001610235565b6102b76102d3366004611e3e565b60009081526020819052604090206001015490565b61028c6102f6366004611e3e565b610926565b610264610309366004611e56565b61093c565b61026461031c366004611e56565b610963565b610264610985565b610264610b57565b61022961033f366004611e85565b610bb8565b60016002600080604080519485526020850193909352918301526060820152608001610235565b610264610379366004611dbb565b610cde565b600254600160a01b900460ff16610229565b610264610db3565b6102b7610e27565b6102b77fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b6102646103d5366004611dbb565b610e38565b610264610e6e565b60045461028c906001600160a01b031681565b6002546001600160a01b031661028c565b61028c610414366004611ee7565b610ec8565b610229610427366004611e56565b610ee0565b61026461043a366004611df3565b610f09565b6102b7600081565b610264610455366004611dbb565b610fa4565b610229610468366004611ebc565b610fd7565b6102b761047b366004611e3e565b61112e565b60055461028c906001600160a01b031681565b6102b76104a1366004611e3e565b611147565b6102646104b4366004611e56565b61115e565b6102646104c7366004611dbb565b611168565b6102b760008051602061219c83398151915281565b60006001600160e01b03198216635a05180f60e01b1480610506575061050682611272565b92915050565b600081600081116105385760405162461bcd60e51b815260040161052f9061201a565b60405180910390fd5b836105446006826112a7565b6105605760405162461bcd60e51b815260040161052f90612077565b60008051602061219c83398151915261057981336112b3565b6002600354141561059c5760405162461bcd60e51b815260040161052f906120a4565b6002600381905554600160a01b900460ff16156105cb5760405162461bcd60e51b815260040161052f90611ff0565b6105d58686611317565b60016003559695505050505050565b60008051602061219c8339815191526105fd81336112b3565b600260035414156106205760405162461bcd60e51b815260040161052f906120a4565b6002600381905554600160a01b900460ff161561064f5760405162461bcd60e51b815260040161052f90611ff0565b8161065b6006826112a7565b1561069a5760405162461bcd60e51b815260206004820152600f60248201526e4552525f555345525f45584953545360881b604482015260640161052f565b6005546040516322564ce960e01b8152600481018590526000916001600160a01b0316906322564ce990602401602060405180830381600087803b1580156106e157600080fd5b505af11580156106f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107199190611dd7565b90506001600160a01b0381166107655760405162461bcd60e51b815260206004820152601160248201527011549497d5d05313115517d19052531151607a1b604482015260640161052f565b6107716006858361143f565b506040516001600160a01b0382169085907f5fde7be6fd256edbbe1d991a982527a20d550875499314500d2e12fd1be2e83690600090a3505060016003555050565b600081600081116107d65760405162461bcd60e51b815260040161052f9061201a565b836107e26006826112a7565b6107fe5760405162461bcd60e51b815260040161052f90612077565b60008051602061219c83398151915261081781336112b3565b6002600354141561083a5760405162461bcd60e51b815260040161052f906120a4565b6002600381905554600160a01b900460ff16156108695760405162461bcd60e51b815260040161052f90611ff0565b6105d58686611455565b6000816108816006826112a7565b61089d5760405162461bcd60e51b815260040161052f90612077565b6108a86006846114ff565b9392505050565b600080829050806001600160a01b031663ab2f0e516040518163ffffffff1660e01b815260040160206040518083038186803b1580156108ee57600080fd5b505afa158015610902573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a89190611f30565b60008061093460068461150b565b949350505050565b6109468282611527565b600082815260016020526040902061095e908261125d565b505050565b61096d828261154d565b600082815260016020526040902061095e90826115c7565b6002546001600160a01b031633146109af5760405162461bcd60e51b815260040161052f90612042565b600254600160a01b900460ff166109ff5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161052f565b60026003541415610a225760405162461bcd60e51b815260040161052f906120a4565b6002600355600480546040516370a0823160e01b815230928101929092526000916001600160a01b03909116906370a082319060240160206040518083038186803b158015610a7057600080fd5b505afa158015610a84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa89190611f30565b6004549091506001600160a01b031663a9059cbb610ace6002546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401602060405180830381600087803b158015610b1657600080fd5b505af1158015610b2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b4e9190611e1e565b50506001600355565b6002546001600160a01b03163314610b815760405162461bcd60e51b815260040161052f90612042565b60026003541415610ba45760405162461bcd60e51b815260040161052f906120a4565b6002600355610bb16115dc565b6001600355565b60008160008111610bdb5760405162461bcd60e51b815260040161052f9061201a565b84610be76006826112a7565b610c035760405162461bcd60e51b815260040161052f90612077565b858480610c0f8361112e565b1015610c4e5760405162461bcd60e51b815260206004820152600e60248201526d4552525f4e4f5f42414c414e434560901b604482015260640161052f565b60008051602061219c833981519152610c6781336112b3565b60026003541415610c8a5760405162461bcd60e51b815260040161052f906120a4565b6002600381905554600160a01b900460ff1615610cb95760405162461bcd60e51b815260040161052f90611ff0565b610ccc610cc58a610873565b8989611679565b60016003559998505050505050505050565b6002546001600160a01b03163314610d085760405162461bcd60e51b815260040161052f90612042565b60005b610d1560066116ff565b811015610daf576000610d2960068361150b565b600554604051631cfa9cd160e11b81526001600160a01b0380841660048301528781166024830152929450911691506339f539a290604401600060405180830381600087803b158015610d7b57600080fd5b505af1158015610d8f573d6000803e3d6000fd5b5050505050610da860018261170a90919063ffffffff16565b9050610d0b565b5050565b6002546001600160a01b03163314610ddd5760405162461bcd60e51b815260040161052f90612042565b6002546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600280546001600160a01b0319169055565b6000610e3360066116ff565b905090565b6002546001600160a01b03163314610e625760405162461bcd60e51b815260040161052f90612042565b610e6b81611716565b50565b6002546001600160a01b03163314610e985760405162461bcd60e51b815260040161052f90612042565b60026003541415610ebb5760405162461bcd60e51b815260040161052f906120a4565b6002600355610bb1611762565b60008281526001602052604081206108a890836117c7565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6002546001600160a01b03163314610f335760405162461bcd60e51b815260040161052f90612042565b6000610f3e82610873565b60405163e8ea054b60e01b81526001600160a01b038581166004830152919250829182169063e8ea054b90602401600060405180830381600087803b158015610f8657600080fd5b505af1158015610f9a573d6000803e3d6000fd5b5050505050505050565b6002546001600160a01b03163314610fce5760405162461bcd60e51b815260040161052f90612042565b610e6b81611168565b60008160008111610ffa5760405162461bcd60e51b815260040161052f9061201a565b846110066006826112a7565b6110225760405162461bcd60e51b815260040161052f90612077565b85848061102e8361112e565b101561106d5760405162461bcd60e51b815260206004820152600e60248201526d4552525f4e4f5f42414c414e434560901b604482015260640161052f565b866110796006826112a7565b6110955760405162461bcd60e51b815260040161052f90612077565b60008051602061219c8339815191526110ae81336112b3565b600260035414156110d15760405162461bcd60e51b815260040161052f906120a4565b6002600381905554600160a01b900460ff16156111005760405162461bcd60e51b815260040161052f90611ff0565b61111b61110c8b610873565b6111158b610873565b8a611679565b60016003559a9950505050505050505050565b60008061113c6006846114ff565b90506108a8816108af565b6000818152600160205260408120610506906117d3565b61096d82826117dd565b6002546001600160a01b031633146111925760405162461bcd60e51b815260040161052f90612042565b6001600160a01b0381166111f75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161052f565b6002546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600280546001600160a01b0319166001600160a01b0392909216919091179055565b610daf8282611803565b60006108a8836001600160a01b038416611887565b60006001600160e01b03198216637965db0b60e01b148061050657506301ffc9a760e01b6001600160e01b0319831614610506565b60006108a883836118d6565b6112bd8282610ee0565b610daf576112d5816001600160a01b031660146118e2565b6112e08360206118e2565b6040516020016112f1929190611f48565b60408051601f198184030181529082905262461bcd60e51b825261052f91600401611fbd565b60008061132384610873565b604051632e1a7d4d60e01b8152600481018590529091506001600160a01b03821690632e1a7d4d90602401602060405180830381600087803b15801561136857600080fd5b505af115801561137c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113a09190611e1e565b5060048054604051630852cd8d60e31b81529182018590526001600160a01b0316906342966c6890602401600060405180830381600087803b1580156113e557600080fd5b505af11580156113f9573d6000803e3d6000fd5b50506040518581523392508691507ff62f20a4adbb89ff8dcdaf45470cad695fc6836ef5428e9327e5559e19ac6ef6906020015b60405180910390a35060019392505050565b600061093484846001600160a01b038516611ac4565b60008061146184610873565b600480546040516340c10f1960e01b81526001600160a01b03808516938201939093526024810187905292935016906340c10f1990604401600060405180830381600087803b1580156114b357600080fd5b505af11580156114c7573d6000803e3d6000fd5b50506040518581523392508691507f44619ddf3e3d73c6119aad5af53198c818ba8612dc3ad035e358493523bd681f9060200161142d565b60006108a88383611ae1565b600080808061151a8686611b51565b9097909650945050505050565b60008281526020819052604090206001015461154381336112b3565b61095e8383611803565b6001600160a01b03811633146115bd5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161052f565b610daf8282611b7c565b60006108a8836001600160a01b038416611be1565b600254600160a01b900460ff1661162c5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161052f565b6002805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6040516302ccb1b360e41b81526001600160a01b0383811660048301526024820183905260009190851690632ccb1b3090604401602060405180830381600087803b1580156116c757600080fd5b505af11580156116db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109349190611e1e565b600061050682611cf8565b60006108a882846120db565b600580546001600160a01b0319166001600160a01b03831690811790915560405181907f333c7678baf16017cf31e1d2f90143a62aab01a67a0807f6836a4304ceabb55590600090a350565b600254600160a01b900460ff161561178c5760405162461bcd60e51b815260040161052f90611ff0565b6002805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861165c3390565b60006108a88383611d03565b6000610506825490565b6000828152602081905260409020600101546117f981336112b3565b61095e8383611b7c565b61180d8282610ee0565b610daf576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556118433390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008181526001830160205260408120546118ce57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610506565b506000610506565b60006108a88383611d97565b606060006118f18360026120f3565b6118fc9060026120db565b67ffffffffffffffff81111561192257634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561194c576020820181803683370190505b509050600360fc1b8160008151811061197557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106119b257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006119d68460026120f3565b6119e19060016120db565b90505b6001811115611a75576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611a2357634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110611a4757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93611a6e81612159565b90506119e4565b5083156108a85760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161052f565b600082815260028401602052604081208290556109348484611daf565b600081815260028301602052604081205480151580611b055750611b0584846118d6565b6108a85760405162461bcd60e51b815260206004820152601e60248201527f456e756d657261626c654d61703a206e6f6e6578697374656e74206b65790000604482015260640161052f565b60008080611b5f85856117c7565b600081815260029690960160205260409095205494959350505050565b611b868282610ee0565b15610daf576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008181526001830160205260408120548015611cee576000611c05600183612112565b8554909150600090611c1990600190612112565b90506000866000018281548110611c4057634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080876000018481548110611c7157634e487b7160e01b600052603260045260246000fd5b600091825260208083209091019290925582815260018901909152604090208490558654879080611cb257634e487b7160e01b600052603160045260246000fd5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610506565b6000915050610506565b6000610506826117d3565b81546000908210611d615760405162461bcd60e51b815260206004820152602260248201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604482015261647360f01b606482015260840161052f565b826000018281548110611d8457634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b600081815260018301602052604081205415156108a8565b60006108a88383611887565b600060208284031215611dcc578081fd5b81356108a881612186565b600060208284031215611de8578081fd5b81516108a881612186565b60008060408385031215611e05578081fd5b8235611e1081612186565b946020939093013593505050565b600060208284031215611e2f578081fd5b815180151581146108a8578182fd5b600060208284031215611e4f578081fd5b5035919050565b60008060408385031215611e68578182fd5b823591506020830135611e7a81612186565b809150509250929050565b600080600060608486031215611e99578081fd5b833592506020840135611eab81612186565b929592945050506040919091013590565b600080600060608486031215611ed0578283fd5b505081359360208301359350604090920135919050565b60008060408385031215611ef9578182fd5b50508035926020909101359150565b600060208284031215611f19578081fd5b81356001600160e01b0319811681146108a8578182fd5b600060208284031215611f41578081fd5b5051919050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611f80816017850160208801612129565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351611fb1816028840160208801612129565b01602801949350505050565b6020815260008251806020840152611fdc816040850160208701612129565b601f01601f19169190910160400192915050565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252600e908201526d4552525f5a45524f5f56414c554560901b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601390820152724552525f555345525f4e4f545f45584953545360681b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600082198211156120ee576120ee612170565b500190565b600081600019048311821515161561210d5761210d612170565b500290565b60008282101561212457612124612170565b500390565b60005b8381101561214457818101518382015260200161212c565b83811115612153576000848401525b50505050565b60008161216857612168612170565b506000190190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b0381168114610e6b57600080fdfe97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929a264697066735822122005437a5bac5b1c4cf1a651a83dcbce1f7be1abf58042679096ebe5ac3dec2b4464736f6c63430008040033