Address Details
contract

0xA4ebadF9f3C462F425aA0D1B9CAc4d0a158f7673

Contract Name
UBIController
Creator
0xc02b8b–fa8663 at 0x60f3f1–1d34ae
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
35 Transactions
Transfers
15 Transfers
Gas Used
13,270,189
Last Balance Update
5455615
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
UBIController




Optimization enabled
true
Compiler version
v0.6.12+commit.27d51765




Optimization runs
100
EVM Version
istanbul




Verified at
2022-09-30T11:54:11.720552Z

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

// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        emit NewUser(key, newUBIBeneficiaryAddress);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return ubiBeneficiaryAddress;
    }

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

/_openzeppelin/contracts/GSN/Context.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 GSN 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 payable) {
        return msg.sender;
    }

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

/_openzeppelin/contracts/access/AccessControl.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../utils/EnumerableSet.sol";
import "../utils/Address.sol";
import "../GSN/Context.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms.
 *
 * 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 {
    using EnumerableSet for EnumerableSet.AddressSet;
    using Address for address;

    struct RoleData {
        EnumerableSet.AddressSet 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 Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view returns (bool) {
        return _roles[role].members.contains(account);
    }

    /**
     * @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 returns (uint256) {
        return _roles[role].members.length();
    }

    /**
     * @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 returns (address) {
        return _roles[role].members.at(index);
    }

    /**
     * @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 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 {
        require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");

        _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 {
        require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");

        _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 {
        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, _roles[role].adminRole, adminRole);
        _roles[role].adminRole = adminRole;
    }

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

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

/_openzeppelin/contracts/access/Ownable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../GSN/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.
 */
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 () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view 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/math/SafeMath.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @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) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @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 sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

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

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * 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) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * 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) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts 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 mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}
          

/_openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../access/AccessControl.sol";
import "../GSN/Context.sol";
import "../token/ERC20/ERC20.sol";
import "../token/ERC20/ERC20Burnable.sol";
import "../token/ERC20/ERC20Pausable.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, AccessControl, 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) public 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/ERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../../GSN/Context.sol";
import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.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 {
    using SafeMath for uint256;
    using Address for address;

    mapping (address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name, string memory symbol) public {
        _name = name;
        _symbol = symbol;
        _decimals = 18;
    }

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

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view 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 {_setupDecimals} is
     * called.
     *
     * 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 returns (uint8) {
        return _decimals;
    }

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

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view 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);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        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].add(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) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        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);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(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 = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(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);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(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 Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal {
        _decimals = decimals_;
    }

    /**
     * @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/ERC20Burnable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../../GSN/Context.sol";
import "./ERC20.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 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance");

        _approve(account, _msgSender(), decreasedAllowance);
        _burn(account, amount);
    }
}
          

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

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "./ERC20.sol";
import "../../utils/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/IERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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/SafeERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "./IERC20.sol";
import "../../math/SafeMath.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 SafeMath for uint256;
    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).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        _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.6.2;

/**
 * @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 in 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");
        return _functionCallWithValue(target, data, value, errorMessage);
    }

    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        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/EnumerableMap.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/**
 * @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 {
    // 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 MapEntry {
        bytes32 _key;
        bytes32 _value;
    }

    struct Map {
        // Storage of map keys and values
        MapEntry[] _entries;

        // Position of the entry defined by a key in the `entries` array, plus 1
        // because index 0 means a key is not in the map.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @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) {
        // We read and store the key's index to prevent multiple reads from the same storage slot
        uint256 keyIndex = map._indexes[key];

        if (keyIndex == 0) { // Equivalent to !contains(map, key)
            map._entries.push(MapEntry({ _key: key, _value: value }));
            // The entry is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            map._indexes[key] = map._entries.length;
            return true;
        } else {
            map._entries[keyIndex - 1]._value = value;
            return false;
        }
    }

    /**
     * @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) {
        // We read and store the key's index to prevent multiple reads from the same storage slot
        uint256 keyIndex = map._indexes[key];

        if (keyIndex != 0) { // Equivalent to contains(map, key)
            // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one
            // in the array, and then remove the last entry (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = keyIndex - 1;
            uint256 lastIndex = map._entries.length - 1;

            // When the entry 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.

            MapEntry storage lastEntry = map._entries[lastIndex];

            // Move the last entry to the index where the entry to delete is
            map._entries[toDeleteIndex] = lastEntry;
            // Update the index for the moved entry
            map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved entry was stored
            map._entries.pop();

            // Delete the index for the deleted slot
            delete map._indexes[key];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @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._indexes[key] != 0;
    }

    /**
     * @dev Returns the number of key-value pairs in the map. O(1).
     */
    function _length(Map storage map) private view returns (uint256) {
        return map._entries.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) {
        require(map._entries.length > index, "EnumerableMap: index out of bounds");

        MapEntry storage entry = map._entries[index];
        return (entry._key, entry._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) {
        return _get(map, key, "EnumerableMap: nonexistent key");
    }

    /**
     * @dev Same as {_get}, with a custom error message when `key` is not in the map.
     */
    function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {
        uint256 keyIndex = map._indexes[key];
        require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)
        return map._entries[keyIndex - 1]._value; // All indexes are 1-based
    }

    // 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(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(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(uint256(_get(map._inner, bytes32(key))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     */
    function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
        return address(uint256(_get(map._inner, bytes32(key), errorMessage)));
    }
}
          

/_openzeppelin/contracts/utils/EnumerableSet.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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.0.0, only sets of type `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] = toDeleteIndex + 1; // All indexes are 1-based

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

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

/_openzeppelin/contracts/utils/Pausable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../GSN/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.
 */
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 () internal {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view 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/utils/ReentrancyGuard.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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].
 */
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 () internal {
        _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;
    }
}
          

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

// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @notice Store a new authorization 

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

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

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

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

// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/presets/ERC20PresetMinterPauser.sol";

interface IUBIBeneficiaryFactory {
    using SafeERC20 for IERC20;
    using SafeERC20 for ERC20PresetMinterPauser;

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

import "./IUBIBeneficiary.sol";

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

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

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

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

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

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

Contract ABI

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

Contract Creation Code

0x608060405268056bc75e2d631000006006553480156200001e57600080fd5b50604051620026ec380380620026ec833981810160405260808110156200004457600080fd5b50805160208201516040830151606090930151919290916000620000676200019b565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506000805460ff60a01b1916815560018055600280546001600160a01b038088166001600160a01b031992831617909255600380548784169083161790556004805486841692169190911780825560408051635a72982560e11b8152868516938101939093525192169163b4e5304a9160248082019260209290919082900301818787803b1580156200014257600080fd5b505af115801562000157573d6000803e3d6000fd5b505050506040513d60208110156200016e57600080fd5b5051600580546001600160a01b0319166001600160a01b03909216919091179055506200019f9350505050565b3390565b61253d80620001af6000396000f3fe608060405234801561001057600080fd5b506004361061018f5760003560e01c80636bb3130e116100e45780639a6e7fd1116100925780639a6e7fd114610408578063b8e2705914610410578063ba325b3d14610436578063bb0e1280146104a4578063c6fb17a1146104d3578063cf8bbcde146104f0578063f2fde38b146104f8578063f8713c951461051e5761018f565b80636bb3130e1461039d5780637062add1146103a5578063715018a6146103cb5780638456cb59146103d35780638da5cb5b146103db5780638f0d7e35146103e3578063953bdf3d146103eb5761018f565b806340dc08591161014157806340dc08591461029c5780634d89a08a146102c25780635a59f630146102df5780635ba9bd72146102fc5780635c975abb14610371578063685b41571461038d5780636b024330146103955761018f565b80630a3f3fa6146101945780630ea86ad8146101b85780631b633c53146101c05780633addc4e0146102375780633cb40e16146102665780633f4ba83a1461026e578063403f373114610276575b600080fd5b61019c610593565b604080516001600160a01b039092168252519081900360200190f35b61019c6105a2565b610235600480360360608110156101d657600080fd5b81359190810190604081016020820135600160201b8111156101f757600080fd5b82018360208201111561020957600080fd5b803590602001918460018302840111600160201b8311171561022a57600080fd5b9193509150356105b1565b005b6102546004803603602081101561024d57600080fd5b503561085e565b60408051918252519081900360200190f35b6102356108e0565b610235610ae5565b6102356004803603602081101561028c57600080fd5b50356001600160a01b0316610b96565b610235600480360360208110156102b257600080fd5b50356001600160a01b0316610c57565b610254600480360360208110156102d857600080fd5b5035610d63565b61019c600480360360208110156102f557600080fd5b5035610db1565b6102356004803603604081101561031257600080fd5b81359190810190604081016020820135600160201b81111561033357600080fd5b82018360208201111561034557600080fd5b803590602001918460018302840111600160201b8311171561036657600080fd5b509092509050610dc7565b610379610ec7565b604080519115158252519081900360200190f35b610235610ed7565b61019c611149565b610254611158565b610235600480360360208110156103bb57600080fd5b50356001600160a01b031661115e565b61023561120f565b6102356112b1565b61019c61135c565b61023561136b565b61019c6004803603602081101561040157600080fd5b50356114c4565b610254611504565b6102356004803603602081101561042657600080fd5b50356001600160a01b0316611515565b6102356004803603602081101561044c57600080fd5b810190602081018135600160201b81111561046657600080fd5b82018360208201111561047857600080fd5b803590602001918460018302840111600160201b8311171561049957600080fd5b509092509050611579565b610235600480360360808110156104ba57600080fd5b508035906020810135906040810135906060013561187f565b610235600480360360208110156104e957600080fd5b5035611991565b61019c611a1c565b6102356004803603602081101561050e57600080fd5b50356001600160a01b0316611a2b565b6102356004803603606081101561053457600080fd5b81359190810190604081016020820135600160201b81111561055557600080fd5b82018360208201111561056757600080fd5b803590602001918460018302840111600160201b8311171561058857600080fd5b919350915035611b99565b6005546001600160a01b031681565b6002546001600160a01b031681565b80600081116105f8576040805162461bcd60e51b815260206004820152600e60248201526d4552525f5a45524f5f56414c554560901b604482015290519081900360640190fd5b8482806106048361085e565b1015610648576040805162461bcd60e51b815260206004820152600e60248201526d4552525f4e4f5f42414c414e434560901b604482015290519081900360640190fd5b610650611d3e565b6000546001600160a01b039081169116146106a0576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b600260015414156106e6576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600155600054600160a01b900460ff161561073d576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b600061074a600789611d42565b600354604080516340c10f1960e01b81526001600160a01b038085166004830152602482018a905291519394509116916340c10f199160448082019260009290919082900301818387803b1580156107a157600080fd5b505af11580156107b5573d6000803e3d6000fd5b5050604080516367fac01360e01b81526024810189905260048101918252604481018a90528493506001600160a01b03841692506367fac013918b918b918b918190606401858580828437600081840152601f19601f820116905080830192505050945050505050600060405180830381600087803b15801561083757600080fd5b505af115801561084b573d6000803e3d6000fd5b5050600180555050505050505050505050565b60008061086c600784611d42565b90506000819050806001600160a01b031663ab2f0e516040518163ffffffff1660e01b815260040160206040518083038186803b1580156108ac57600080fd5b505afa1580156108c0573d6000803e3d6000fd5b505050506040513d60208110156108d657600080fd5b5051949350505050565b6108e8611d3e565b6000546001600160a01b03908116911614610938576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b600054600160a01b900460ff1661098d576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b600260015414156109d3576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600181905554604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015610a2357600080fd5b505afa158015610a37573d6000803e3d6000fd5b505050506040513d6020811015610a4d57600080fd5b50516002549091506001600160a01b031663a9059cbb610a6b61135c565b836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015610ab257600080fd5b505af1158015610ac6573d6000803e3d6000fd5b505050506040513d6020811015610adc57600080fd5b50506001805550565b610aed611d3e565b6000546001600160a01b03908116911614610b3d576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60026001541415610b83576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600155610b90611d55565b60018055565b610b9e611d3e565b6000546001600160a01b03908116911614610bee576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b6005546040805163403f373160e01b81526001600160a01b0384811660048301529151919092169163403f373191602480830192600092919082900301818387803b158015610c3c57600080fd5b505af1158015610c50573d6000803e3d6000fd5b5050505050565b610c5f611d3e565b6000546001600160a01b03908116911614610caf576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60005b610cbc6007611dfd565b811015610d5f576000610cd0600783611e08565b6004805460408051631cfa9cd160e11b81526001600160a01b038086169482019490945288841660248201529051939550911692506339f539a291604480830192600092919082900301818387803b158015610d2b57600080fd5b505af1158015610d3f573d6000803e3d6000fd5b5050505050610d58600182611e2490919063ffffffff16565b9050610cb2565b5050565b600080610d71600784611d42565b90506000819050806001600160a01b031663f1e462696040518163ffffffff1660e01b815260040160206040518083038186803b1580156108ac57600080fd5b600080610dbf600784611e08565b949350505050565b610dcf611d3e565b6000546001600160a01b03908116911614610e1f576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60026001541415610e65576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600155600054600160a01b900460ff1615610ebc576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b610adc838383611e7e565b600054600160a01b900460ff1690565b610edf611d3e565b6000546001600160a01b03908116911614610f2f576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b600054600160a01b900460ff16610f84576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b60026001541415610fca576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600181905554604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561101a57600080fd5b505afa15801561102e573d6000803e3d6000fd5b505050506040513d602081101561104457600080fd5b50516005546040805163c561d4b760e01b815290519293506000926001600160a01b039092169163c561d4b791600480820192602092909190829003018186803b15801561109157600080fd5b505afa1580156110a5573d6000803e3d6000fd5b505050506040513d60208110156110bb57600080fd5b50516002546040805163a9059cbb60e01b81526001600160a01b03808516600483015260248201879052915193945091169163a9059cbb916044808201926020929091908290030181600087803b15801561111557600080fd5b505af1158015611129573d6000803e3d6000fd5b505050506040513d602081101561113f57600080fd5b5050600180555050565b6003546001600160a01b031681565b60065481565b611166611d3e565b6000546001600160a01b039081169116146111b6576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b6004805460055460408051631cfa9cd160e11b81526001600160a01b03928316948101949094528482166024850152519116916339f539a291604480830192600092919082900301818387803b158015610c3c57600080fd5b611217611d3e565b6000546001600160a01b03908116911614611267576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6112b9611d3e565b6000546001600160a01b03908116911614611309576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b6002600154141561134f576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600155610b90611fa2565b6000546001600160a01b031690565b611373611d3e565b6000546001600160a01b039081169116146113c3576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60026001541415611409576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600155600054600160a01b900460ff1615611460576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b600560009054906101000a90046001600160a01b03166001600160a01b0316638f0d7e356040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156114b057600080fd5b505af115801561113f573d6000803e3d6000fd5b60408051808201909152601281527111549497d554d15497d393d517d1561254d560721b60208201526000906114fe906007908490612030565b92915050565b60006115106007611dfd565b905090565b61151d611d3e565b6000546001600160a01b0390811691161461156d576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b6115768161203d565b50565b611581611d3e565b6000546001600160a01b039081169116146115d1576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60026001541415611617576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600155600054600160a01b900460ff161561166e576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b8181604051808383808284376040519201829003909120935061169892506007915083905061208d565b156116dc576040805162461bcd60e51b815260206004820152600f60248201526e4552525f555345525f45584953545360881b604482015290519081900360640190fd5b60048054604051634f9bf3f360e01b81526020928101928352602481018590526000926001600160a01b0390921691634f9bf3f391879187918190604401848480828437600081840152601f19601f8201169050808301925050509350505050602060405180830381600087803b15801561175657600080fd5b505af115801561176a573d6000803e3d6000fd5b505050506040513d602081101561178057600080fd5b50516040519091506000908590859080838380828437604051920182900390912094506117b7935060079250849150859050612099565b506002546006546040805163a9059cbb60e01b81526001600160a01b03868116600483015260248201939093529051919092169163a9059cbb9160448083019260209291908290030181600087803b15801561181257600080fd5b505af1158015611826573d6000803e3d6000fd5b505050506040513d602081101561183c57600080fd5b50506040516001600160a01b0383169082907f5fde7be6fd256edbbe1d991a982527a20d550875499314500d2e12fd1be2e83690600090a3505060018055505050565b611887611d3e565b6000546001600160a01b039081169116146118d7576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60005b6118e46007611dfd565b811015610c505760006118f8600783611e08565b604080516301761c2560e71b8152600481018a905260248101899052604481018890526064810187905290519193508392506001600160a01b0383169163bb0e12809160848082019260009290919082900301818387803b15801561195c57600080fd5b505af1158015611970573d6000803e3d6000fd5b50505050505061198a600182611e2490919063ffffffff16565b90506118da565b611999611d3e565b6000546001600160a01b039081169116146119e9576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b600681905560405181907ffcd679f840f581cf9cd88a11ed3203bbf677d301b56dbdca72a855ac9674671d90600090a250565b6004546001600160a01b031681565b611a33611d3e565b6000546001600160a01b03908116911614611a83576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60005b611a906007611dfd565b811015611b2a576000611aa4600783611e08565b6040805163e8ea054b60e01b81526001600160a01b03878116600483015291519294508493509083169163e8ea054b9160248082019260009290919082900301818387803b158015611af557600080fd5b505af1158015611b09573d6000803e3d6000fd5b505050505050611b23600182611e2490919063ffffffff16565b9050611a86565b6005546040805163e8ea054b60e01b81526001600160a01b0385811660048301529151919092169163e8ea054b91602480830192600092919082900301818387803b158015611b7857600080fd5b505af1158015611b8c573d6000803e3d6000fd5b50505050610d5f826120af565b8060008111611be0576040805162461bcd60e51b815260206004820152600e60248201526d4552525f5a45524f5f56414c554560901b604482015290519081900360640190fd5b848280611bec8361085e565b1015611c30576040805162461bcd60e51b815260206004820152600e60248201526d4552525f4e4f5f42414c414e434560901b604482015290519081900360640190fd5b611c38611d3e565b6000546001600160a01b03908116911614611c88576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60026001541415611cce576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600155600054600160a01b900460ff1615611d25576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b611d31878787876121a7565b5050600180555050505050565b3390565b6000611d4e8383612245565b9392505050565b600054600160a01b900460ff16611daa576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa611de0611d3e565b604080516001600160a01b039092168252519081900360200190a1565b60006114fe82612287565b6000808080611e17868661228b565b9097909650945050505050565b600082820183811015611d4e576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000611e8b600785611d42565b6040516308214b4f60e41b81526020600482019081526024820185905291925082916000916001600160a01b03841691638214b4f091889188918190604401848480828437600081840152601f19601f8201169050808301925050509350505050602060405180830381600087803b158015611f0657600080fd5b505af1158015611f1a573d6000803e3d6000fd5b505050506040513d6020811015611f3057600080fd5b505160035460408051630852cd8d60e31b81526004810184905290519293506001600160a01b03909116916342966c689160248082019260009290919082900301818387803b158015611f8257600080fd5b505af1158015611f96573d6000803e3d6000fd5b50505050505050505050565b600054600160a01b900460ff1615611ff4576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611de0611d3e565b6000610dbf848484612306565b600480546001600160a01b0319166001600160a01b0383811691821792839055604051919216907f333c7678baf16017cf31e1d2f90143a62aab01a67a0807f6836a4304ceabb55590600090a350565b6000611d4e83836123d0565b6000610dbf84846001600160a01b0385166123e8565b6120b7611d3e565b6000546001600160a01b03908116911614612107576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b6001600160a01b03811661214c5760405162461bcd60e51b81526004018080602001828103825260268152602001806124a06026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60006121b4600786611d42565b600554604051637f20e06d60e11b8152602481018590526001600160a01b03918216604482018190526060600483019081526064830188905293945084939284169263fe41c0da928992899289928190608401868680828437600081840152601f19601f82011690508083019250505095505050505050600060405180830381600087803b158015611f8257600080fd5b6000611d4e83836040518060400160405280601e81526020017f456e756d657261626c654d61703a206e6f6e6578697374656e74206b65790000815250612306565b5490565b8154600090819083106122cf5760405162461bcd60e51b81526004018080602001828103825260228152602001806124c66022913960400191505060405180910390fd5b60008460000184815481106122e057fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b600082815260018401602052604081205482816123a15760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561236657818101518382015260200161234e565b50505050905090810190601f1680156123935780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b508460000160018203815481106123b457fe5b9060005260206000209060020201600101549150509392505050565b60009081526001919091016020526040902054151590565b60008281526001840160205260408120548061244d575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055611d4e565b8285600001600183038154811061246057fe5b9060005260206000209060020201600101819055506000915050611d4e56fe5265656e7472616e637947756172643a207265656e7472616e742063616c6c004f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a26469706673582212209f9442e690cda29468cee372b17558c1ec596ac891854e78a73dbb5690a1e24264736f6c634300060c0033000000000000000000000000874069fa1eb16d44d622f2e0ca25eea172369bc1000000000000000000000000a0a1b6154f3d41b75c7d1c14573d8edeedc773dd000000000000000000000000869c36349de9ebf1e29f6844340852039fa63d210000000000000000000000000000000000000000000000000000000000000001

Deployed ByteCode

0x608060405234801561001057600080fd5b506004361061018f5760003560e01c80636bb3130e116100e45780639a6e7fd1116100925780639a6e7fd114610408578063b8e2705914610410578063ba325b3d14610436578063bb0e1280146104a4578063c6fb17a1146104d3578063cf8bbcde146104f0578063f2fde38b146104f8578063f8713c951461051e5761018f565b80636bb3130e1461039d5780637062add1146103a5578063715018a6146103cb5780638456cb59146103d35780638da5cb5b146103db5780638f0d7e35146103e3578063953bdf3d146103eb5761018f565b806340dc08591161014157806340dc08591461029c5780634d89a08a146102c25780635a59f630146102df5780635ba9bd72146102fc5780635c975abb14610371578063685b41571461038d5780636b024330146103955761018f565b80630a3f3fa6146101945780630ea86ad8146101b85780631b633c53146101c05780633addc4e0146102375780633cb40e16146102665780633f4ba83a1461026e578063403f373114610276575b600080fd5b61019c610593565b604080516001600160a01b039092168252519081900360200190f35b61019c6105a2565b610235600480360360608110156101d657600080fd5b81359190810190604081016020820135600160201b8111156101f757600080fd5b82018360208201111561020957600080fd5b803590602001918460018302840111600160201b8311171561022a57600080fd5b9193509150356105b1565b005b6102546004803603602081101561024d57600080fd5b503561085e565b60408051918252519081900360200190f35b6102356108e0565b610235610ae5565b6102356004803603602081101561028c57600080fd5b50356001600160a01b0316610b96565b610235600480360360208110156102b257600080fd5b50356001600160a01b0316610c57565b610254600480360360208110156102d857600080fd5b5035610d63565b61019c600480360360208110156102f557600080fd5b5035610db1565b6102356004803603604081101561031257600080fd5b81359190810190604081016020820135600160201b81111561033357600080fd5b82018360208201111561034557600080fd5b803590602001918460018302840111600160201b8311171561036657600080fd5b509092509050610dc7565b610379610ec7565b604080519115158252519081900360200190f35b610235610ed7565b61019c611149565b610254611158565b610235600480360360208110156103bb57600080fd5b50356001600160a01b031661115e565b61023561120f565b6102356112b1565b61019c61135c565b61023561136b565b61019c6004803603602081101561040157600080fd5b50356114c4565b610254611504565b6102356004803603602081101561042657600080fd5b50356001600160a01b0316611515565b6102356004803603602081101561044c57600080fd5b810190602081018135600160201b81111561046657600080fd5b82018360208201111561047857600080fd5b803590602001918460018302840111600160201b8311171561049957600080fd5b509092509050611579565b610235600480360360808110156104ba57600080fd5b508035906020810135906040810135906060013561187f565b610235600480360360208110156104e957600080fd5b5035611991565b61019c611a1c565b6102356004803603602081101561050e57600080fd5b50356001600160a01b0316611a2b565b6102356004803603606081101561053457600080fd5b81359190810190604081016020820135600160201b81111561055557600080fd5b82018360208201111561056757600080fd5b803590602001918460018302840111600160201b8311171561058857600080fd5b919350915035611b99565b6005546001600160a01b031681565b6002546001600160a01b031681565b80600081116105f8576040805162461bcd60e51b815260206004820152600e60248201526d4552525f5a45524f5f56414c554560901b604482015290519081900360640190fd5b8482806106048361085e565b1015610648576040805162461bcd60e51b815260206004820152600e60248201526d4552525f4e4f5f42414c414e434560901b604482015290519081900360640190fd5b610650611d3e565b6000546001600160a01b039081169116146106a0576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b600260015414156106e6576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600155600054600160a01b900460ff161561073d576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b600061074a600789611d42565b600354604080516340c10f1960e01b81526001600160a01b038085166004830152602482018a905291519394509116916340c10f199160448082019260009290919082900301818387803b1580156107a157600080fd5b505af11580156107b5573d6000803e3d6000fd5b5050604080516367fac01360e01b81526024810189905260048101918252604481018a90528493506001600160a01b03841692506367fac013918b918b918b918190606401858580828437600081840152601f19601f820116905080830192505050945050505050600060405180830381600087803b15801561083757600080fd5b505af115801561084b573d6000803e3d6000fd5b5050600180555050505050505050505050565b60008061086c600784611d42565b90506000819050806001600160a01b031663ab2f0e516040518163ffffffff1660e01b815260040160206040518083038186803b1580156108ac57600080fd5b505afa1580156108c0573d6000803e3d6000fd5b505050506040513d60208110156108d657600080fd5b5051949350505050565b6108e8611d3e565b6000546001600160a01b03908116911614610938576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b600054600160a01b900460ff1661098d576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b600260015414156109d3576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600181905554604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015610a2357600080fd5b505afa158015610a37573d6000803e3d6000fd5b505050506040513d6020811015610a4d57600080fd5b50516002549091506001600160a01b031663a9059cbb610a6b61135c565b836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015610ab257600080fd5b505af1158015610ac6573d6000803e3d6000fd5b505050506040513d6020811015610adc57600080fd5b50506001805550565b610aed611d3e565b6000546001600160a01b03908116911614610b3d576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60026001541415610b83576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600155610b90611d55565b60018055565b610b9e611d3e565b6000546001600160a01b03908116911614610bee576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b6005546040805163403f373160e01b81526001600160a01b0384811660048301529151919092169163403f373191602480830192600092919082900301818387803b158015610c3c57600080fd5b505af1158015610c50573d6000803e3d6000fd5b5050505050565b610c5f611d3e565b6000546001600160a01b03908116911614610caf576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60005b610cbc6007611dfd565b811015610d5f576000610cd0600783611e08565b6004805460408051631cfa9cd160e11b81526001600160a01b038086169482019490945288841660248201529051939550911692506339f539a291604480830192600092919082900301818387803b158015610d2b57600080fd5b505af1158015610d3f573d6000803e3d6000fd5b5050505050610d58600182611e2490919063ffffffff16565b9050610cb2565b5050565b600080610d71600784611d42565b90506000819050806001600160a01b031663f1e462696040518163ffffffff1660e01b815260040160206040518083038186803b1580156108ac57600080fd5b600080610dbf600784611e08565b949350505050565b610dcf611d3e565b6000546001600160a01b03908116911614610e1f576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60026001541415610e65576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600155600054600160a01b900460ff1615610ebc576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b610adc838383611e7e565b600054600160a01b900460ff1690565b610edf611d3e565b6000546001600160a01b03908116911614610f2f576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b600054600160a01b900460ff16610f84576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b60026001541415610fca576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600181905554604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561101a57600080fd5b505afa15801561102e573d6000803e3d6000fd5b505050506040513d602081101561104457600080fd5b50516005546040805163c561d4b760e01b815290519293506000926001600160a01b039092169163c561d4b791600480820192602092909190829003018186803b15801561109157600080fd5b505afa1580156110a5573d6000803e3d6000fd5b505050506040513d60208110156110bb57600080fd5b50516002546040805163a9059cbb60e01b81526001600160a01b03808516600483015260248201879052915193945091169163a9059cbb916044808201926020929091908290030181600087803b15801561111557600080fd5b505af1158015611129573d6000803e3d6000fd5b505050506040513d602081101561113f57600080fd5b5050600180555050565b6003546001600160a01b031681565b60065481565b611166611d3e565b6000546001600160a01b039081169116146111b6576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b6004805460055460408051631cfa9cd160e11b81526001600160a01b03928316948101949094528482166024850152519116916339f539a291604480830192600092919082900301818387803b158015610c3c57600080fd5b611217611d3e565b6000546001600160a01b03908116911614611267576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6112b9611d3e565b6000546001600160a01b03908116911614611309576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b6002600154141561134f576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600155610b90611fa2565b6000546001600160a01b031690565b611373611d3e565b6000546001600160a01b039081169116146113c3576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60026001541415611409576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600155600054600160a01b900460ff1615611460576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b600560009054906101000a90046001600160a01b03166001600160a01b0316638f0d7e356040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156114b057600080fd5b505af115801561113f573d6000803e3d6000fd5b60408051808201909152601281527111549497d554d15497d393d517d1561254d560721b60208201526000906114fe906007908490612030565b92915050565b60006115106007611dfd565b905090565b61151d611d3e565b6000546001600160a01b0390811691161461156d576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b6115768161203d565b50565b611581611d3e565b6000546001600160a01b039081169116146115d1576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60026001541415611617576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600155600054600160a01b900460ff161561166e576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b8181604051808383808284376040519201829003909120935061169892506007915083905061208d565b156116dc576040805162461bcd60e51b815260206004820152600f60248201526e4552525f555345525f45584953545360881b604482015290519081900360640190fd5b60048054604051634f9bf3f360e01b81526020928101928352602481018590526000926001600160a01b0390921691634f9bf3f391879187918190604401848480828437600081840152601f19601f8201169050808301925050509350505050602060405180830381600087803b15801561175657600080fd5b505af115801561176a573d6000803e3d6000fd5b505050506040513d602081101561178057600080fd5b50516040519091506000908590859080838380828437604051920182900390912094506117b7935060079250849150859050612099565b506002546006546040805163a9059cbb60e01b81526001600160a01b03868116600483015260248201939093529051919092169163a9059cbb9160448083019260209291908290030181600087803b15801561181257600080fd5b505af1158015611826573d6000803e3d6000fd5b505050506040513d602081101561183c57600080fd5b50506040516001600160a01b0383169082907f5fde7be6fd256edbbe1d991a982527a20d550875499314500d2e12fd1be2e83690600090a3505060018055505050565b611887611d3e565b6000546001600160a01b039081169116146118d7576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60005b6118e46007611dfd565b811015610c505760006118f8600783611e08565b604080516301761c2560e71b8152600481018a905260248101899052604481018890526064810187905290519193508392506001600160a01b0383169163bb0e12809160848082019260009290919082900301818387803b15801561195c57600080fd5b505af1158015611970573d6000803e3d6000fd5b50505050505061198a600182611e2490919063ffffffff16565b90506118da565b611999611d3e565b6000546001600160a01b039081169116146119e9576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b600681905560405181907ffcd679f840f581cf9cd88a11ed3203bbf677d301b56dbdca72a855ac9674671d90600090a250565b6004546001600160a01b031681565b611a33611d3e565b6000546001600160a01b03908116911614611a83576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60005b611a906007611dfd565b811015611b2a576000611aa4600783611e08565b6040805163e8ea054b60e01b81526001600160a01b03878116600483015291519294508493509083169163e8ea054b9160248082019260009290919082900301818387803b158015611af557600080fd5b505af1158015611b09573d6000803e3d6000fd5b505050505050611b23600182611e2490919063ffffffff16565b9050611a86565b6005546040805163e8ea054b60e01b81526001600160a01b0385811660048301529151919092169163e8ea054b91602480830192600092919082900301818387803b158015611b7857600080fd5b505af1158015611b8c573d6000803e3d6000fd5b50505050610d5f826120af565b8060008111611be0576040805162461bcd60e51b815260206004820152600e60248201526d4552525f5a45524f5f56414c554560901b604482015290519081900360640190fd5b848280611bec8361085e565b1015611c30576040805162461bcd60e51b815260206004820152600e60248201526d4552525f4e4f5f42414c414e434560901b604482015290519081900360640190fd5b611c38611d3e565b6000546001600160a01b03908116911614611c88576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b60026001541415611cce576040805162461bcd60e51b815260206004820152601f6024820152600080516020612480833981519152604482015290519081900360640190fd5b6002600155600054600160a01b900460ff1615611d25576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b611d31878787876121a7565b5050600180555050505050565b3390565b6000611d4e8383612245565b9392505050565b600054600160a01b900460ff16611daa576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa611de0611d3e565b604080516001600160a01b039092168252519081900360200190a1565b60006114fe82612287565b6000808080611e17868661228b565b9097909650945050505050565b600082820183811015611d4e576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000611e8b600785611d42565b6040516308214b4f60e41b81526020600482019081526024820185905291925082916000916001600160a01b03841691638214b4f091889188918190604401848480828437600081840152601f19601f8201169050808301925050509350505050602060405180830381600087803b158015611f0657600080fd5b505af1158015611f1a573d6000803e3d6000fd5b505050506040513d6020811015611f3057600080fd5b505160035460408051630852cd8d60e31b81526004810184905290519293506001600160a01b03909116916342966c689160248082019260009290919082900301818387803b158015611f8257600080fd5b505af1158015611f96573d6000803e3d6000fd5b50505050505050505050565b600054600160a01b900460ff1615611ff4576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611de0611d3e565b6000610dbf848484612306565b600480546001600160a01b0319166001600160a01b0383811691821792839055604051919216907f333c7678baf16017cf31e1d2f90143a62aab01a67a0807f6836a4304ceabb55590600090a350565b6000611d4e83836123d0565b6000610dbf84846001600160a01b0385166123e8565b6120b7611d3e565b6000546001600160a01b03908116911614612107576040805162461bcd60e51b815260206004820181905260248201526000805160206124e8833981519152604482015290519081900360640190fd5b6001600160a01b03811661214c5760405162461bcd60e51b81526004018080602001828103825260268152602001806124a06026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60006121b4600786611d42565b600554604051637f20e06d60e11b8152602481018590526001600160a01b03918216604482018190526060600483019081526064830188905293945084939284169263fe41c0da928992899289928190608401868680828437600081840152601f19601f82011690508083019250505095505050505050600060405180830381600087803b158015611f8257600080fd5b6000611d4e83836040518060400160405280601e81526020017f456e756d657261626c654d61703a206e6f6e6578697374656e74206b65790000815250612306565b5490565b8154600090819083106122cf5760405162461bcd60e51b81526004018080602001828103825260228152602001806124c66022913960400191505060405180910390fd5b60008460000184815481106122e057fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b600082815260018401602052604081205482816123a15760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561236657818101518382015260200161234e565b50505050905090810190601f1680156123935780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b508460000160018203815481106123b457fe5b9060005260206000209060020201600101549150509392505050565b60009081526001919091016020526040902054151590565b60008281526001840160205260408120548061244d575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055611d4e565b8285600001600183038154811061246057fe5b9060005260206000209060020201600101819055506000915050611d4e56fe5265656e7472616e637947756172643a207265656e7472616e742063616c6c004f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a26469706673582212209f9442e690cda29468cee372b17558c1ec596ac891854e78a73dbb5690a1e24264736f6c634300060c0033