Address Details
contract

0x1C215fE12D3a25110A2BDDCa1eDAC21FaC4322B2

Contract Name
StakedETHIX
Creator
0x0c9ba5–ef362d at 0x0bcb7b–d9256f
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
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
22989147
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
StakedETHIX




Optimization enabled
true
Compiler version
v0.7.5+commit.eb77ed08




Optimization runs
200
EVM Version
istanbul




Verified at
2022-08-30T15:55:13.299686Z

contracts/token/StakedETHIX.sol

// SPDX-License-Identifier: gpl-3.0

pragma solidity 0.7.5;
pragma experimental ABIEncoderV2;

import './bases/staking/interfaces/ITransferHook.sol';
import './bases/staking/StakedToken.sol';

/**
 * @title StakedEthix
 * @notice StakedToken with ETHIX token as staked token
 * @author Aave / Ethichub
 **/
contract StakedETHIX is StakedToken {
    function initialize(
        IERC20Upgradeable stakedToken,
        ITransferHook ethixGovernance,
        uint256 cooldownSeconds,
        uint256 unstakeWindow,
        IReserve rewardsVault,
        address emissionManager,
        uint128 distributionDuration
    ) public initializer {
        __StakedToken_init(
            'Staked ETHIX',
            'stkETHIX',
            18,
            ethixGovernance,
            stakedToken,
            cooldownSeconds,
            unstakeWindow,
            rewardsVault,
            emissionManager,
            distributionDuration
        );
    }
}
        

/_openzeppelin/contracts-upgradeable/GSN/ContextUpgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;
import "../proxy/Initializable.sol";

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with 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 ContextUpgradeable is Initializable {
    function __Context_init() internal initializer {
        __Context_init_unchained();
    }

    function __Context_init_unchained() internal initializer {
    }
    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;
    }
    uint256[50] private __gap;
}
          

/_openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../utils/EnumerableSetUpgradeable.sol";
import "../utils/AddressUpgradeable.sol";
import "../GSN/ContextUpgradeable.sol";
import "../proxy/Initializable.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 AccessControlUpgradeable is Initializable, ContextUpgradeable {
    function __AccessControl_init() internal initializer {
        __Context_init_unchained();
        __AccessControl_init_unchained();
    }

    function __AccessControl_init_unchained() internal initializer {
    }
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;
    using AddressUpgradeable for address;

    struct RoleData {
        EnumerableSetUpgradeable.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());
        }
    }
    uint256[49] private __gap;
}
          

/_openzeppelin/contracts-upgradeable/math/MathUpgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library MathUpgradeable {
    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow, so we distribute
        return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
    }
}
          

/_openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.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 SafeMathUpgradeable {
    /**
     * @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-upgradeable/proxy/Initializable.sol

// SPDX-License-Identifier: MIT

// solhint-disable-next-line compiler-version
pragma solidity >=0.4.24 <0.8.0;


/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 * 
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.
 * 
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {

    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /// @dev Returns true if and only if the function is running in the constructor
    function _isConstructor() private view returns (bool) {
        // extcodesize checks the size of the code stored in an address, and
        // address returns the current address. Since the code is still not
        // deployed when running a constructor, any checks on its code size will
        // yield zero, making it an effective way to detect if a contract is
        // under construction or not.
        address self = address(this);
        uint256 cs;
        // solhint-disable-next-line no-inline-assembly
        assembly { cs := extcodesize(self) }
        return cs == 0;
    }
}
          

/_openzeppelin/contracts-upgradeable/token/ERC20/ERC20SnapshotUpgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../../math/SafeMathUpgradeable.sol";
import "../../utils/ArraysUpgradeable.sol";
import "../../utils/CountersUpgradeable.sol";
import "./ERC20Upgradeable.sol";
import "../../proxy/Initializable.sol";

/**
 * @dev This contract extends an ERC20 token with a snapshot mechanism. When a snapshot is created, the balances and
 * total supply at the time are recorded for later access.
 *
 * This can be used to safely create mechanisms based on token balances such as trustless dividends or weighted voting.
 * In naive implementations it's possible to perform a "double spend" attack by reusing the same balance from different
 * accounts. By using snapshots to calculate dividends or voting power, those attacks no longer apply. It can also be
 * used to create an efficient ERC20 forking mechanism.
 *
 * Snapshots are created by the internal {_snapshot} function, which will emit the {Snapshot} event and return a
 * snapshot id. To get the total supply at the time of a snapshot, call the function {totalSupplyAt} with the snapshot
 * id. To get the balance of an account at the time of a snapshot, call the {balanceOfAt} function with the snapshot id
 * and the account address.
 *
 * ==== Gas Costs
 *
 * Snapshots are efficient. Snapshot creation is _O(1)_. Retrieval of balances or total supply from a snapshot is _O(log
 * n)_ in the number of snapshots that have been created, although _n_ for a specific account will generally be much
 * smaller since identical balances in subsequent snapshots are stored as a single entry.
 *
 * There is a constant overhead for normal ERC20 transfers due to the additional snapshot bookkeeping. This overhead is
 * only significant for the first transfer that immediately follows a snapshot for a particular account. Subsequent
 * transfers will have normal cost until the next snapshot, and so on.
 */
abstract contract ERC20SnapshotUpgradeable is Initializable, ERC20Upgradeable {
    function __ERC20Snapshot_init() internal initializer {
        __Context_init_unchained();
        __ERC20Snapshot_init_unchained();
    }

    function __ERC20Snapshot_init_unchained() internal initializer {
    }
    // Inspired by Jordi Baylina's MiniMeToken to record historical balances:
    // https://github.com/Giveth/minimd/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol

    using SafeMathUpgradeable for uint256;
    using ArraysUpgradeable for uint256[];
    using CountersUpgradeable for CountersUpgradeable.Counter;

    // Snapshotted values have arrays of ids and the value corresponding to that id. These could be an array of a
    // Snapshot struct, but that would impede usage of functions that work on an array.
    struct Snapshots {
        uint256[] ids;
        uint256[] values;
    }

    mapping (address => Snapshots) private _accountBalanceSnapshots;
    Snapshots private _totalSupplySnapshots;

    // Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid.
    CountersUpgradeable.Counter private _currentSnapshotId;

    /**
     * @dev Emitted by {_snapshot} when a snapshot identified by `id` is created.
     */
    event Snapshot(uint256 id);

    /**
     * @dev Creates a new snapshot and returns its snapshot id.
     *
     * Emits a {Snapshot} event that contains the same id.
     *
     * {_snapshot} is `internal` and you have to decide how to expose it externally. Its usage may be restricted to a
     * set of accounts, for example using {AccessControl}, or it may be open to the public.
     *
     * [WARNING]
     * ====
     * While an open way of calling {_snapshot} is required for certain trust minimization mechanisms such as forking,
     * you must consider that it can potentially be used by attackers in two ways.
     *
     * First, it can be used to increase the cost of retrieval of values from snapshots, although it will grow
     * logarithmically thus rendering this attack ineffective in the long term. Second, it can be used to target
     * specific accounts and increase the cost of ERC20 transfers for them, in the ways specified in the Gas Costs
     * section above.
     *
     * We haven't measured the actual numbers; if this is something you're interested in please reach out to us.
     * ====
     */
    function _snapshot() internal virtual returns (uint256) {
        _currentSnapshotId.increment();

        uint256 currentId = _currentSnapshotId.current();
        emit Snapshot(currentId);
        return currentId;
    }

    /**
     * @dev Retrieves the balance of `account` at the time `snapshotId` was created.
     */
    function balanceOfAt(address account, uint256 snapshotId) public view returns (uint256) {
        (bool snapshotted, uint256 value) = _valueAt(snapshotId, _accountBalanceSnapshots[account]);

        return snapshotted ? value : balanceOf(account);
    }

    /**
     * @dev Retrieves the total supply at the time `snapshotId` was created.
     */
    function totalSupplyAt(uint256 snapshotId) public view returns(uint256) {
        (bool snapshotted, uint256 value) = _valueAt(snapshotId, _totalSupplySnapshots);

        return snapshotted ? value : totalSupply();
    }


    // Update balance and/or total supply snapshots before the values are modified. This is implemented
    // in the _beforeTokenTransfer hook, which is executed for _mint, _burn, and _transfer operations.
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
      super._beforeTokenTransfer(from, to, amount);

      if (from == address(0)) {
        // mint
        _updateAccountSnapshot(to);
        _updateTotalSupplySnapshot();
      } else if (to == address(0)) {
        // burn
        _updateAccountSnapshot(from);
        _updateTotalSupplySnapshot();
      } else {
        // transfer
        _updateAccountSnapshot(from);
        _updateAccountSnapshot(to);
      }
    }

    function _valueAt(uint256 snapshotId, Snapshots storage snapshots)
        private view returns (bool, uint256)
    {
        require(snapshotId > 0, "ERC20Snapshot: id is 0");
        // solhint-disable-next-line max-line-length
        require(snapshotId <= _currentSnapshotId.current(), "ERC20Snapshot: nonexistent id");

        // When a valid snapshot is queried, there are three possibilities:
        //  a) The queried value was not modified after the snapshot was taken. Therefore, a snapshot entry was never
        //  created for this id, and all stored snapshot ids are smaller than the requested one. The value that corresponds
        //  to this id is the current one.
        //  b) The queried value was modified after the snapshot was taken. Therefore, there will be an entry with the
        //  requested id, and its value is the one to return.
        //  c) More snapshots were created after the requested one, and the queried value was later modified. There will be
        //  no entry for the requested id: the value that corresponds to it is that of the smallest snapshot id that is
        //  larger than the requested one.
        //
        // In summary, we need to find an element in an array, returning the index of the smallest value that is larger if
        // it is not found, unless said value doesn't exist (e.g. when all values are smaller). Arrays.findUpperBound does
        // exactly this.

        uint256 index = snapshots.ids.findUpperBound(snapshotId);

        if (index == snapshots.ids.length) {
            return (false, 0);
        } else {
            return (true, snapshots.values[index]);
        }
    }

    function _updateAccountSnapshot(address account) private {
        _updateSnapshot(_accountBalanceSnapshots[account], balanceOf(account));
    }

    function _updateTotalSupplySnapshot() private {
        _updateSnapshot(_totalSupplySnapshots, totalSupply());
    }

    function _updateSnapshot(Snapshots storage snapshots, uint256 currentValue) private {
        uint256 currentId = _currentSnapshotId.current();
        if (_lastSnapshotId(snapshots.ids) < currentId) {
            snapshots.ids.push(currentId);
            snapshots.values.push(currentValue);
        }
    }

    function _lastSnapshotId(uint256[] storage ids) private view returns (uint256) {
        if (ids.length == 0) {
            return 0;
        } else {
            return ids[ids.length - 1];
        }
    }
    uint256[46] private __gap;
}
          

/_openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../../GSN/ContextUpgradeable.sol";
import "./IERC20Upgradeable.sol";
import "../../math/SafeMathUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../proxy/Initializable.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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable {
    using SafeMathUpgradeable for uint256;
    using AddressUpgradeable 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.
     */
    function __ERC20_init(string memory name_, string memory symbol_) internal initializer {
        __Context_init_unchained();
        __ERC20_init_unchained(name_, symbol_);
    }

    function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {
        _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 { }
    uint256[44] private __gap;
}
          

/_openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @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-upgradeable/token/ERC20/SafeERC20Upgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

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

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

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

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

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // 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(IERC20Upgradeable 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(IERC20Upgradeable 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(IERC20Upgradeable token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

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

/_openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }

    /**
     * @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-upgradeable/utils/ArraysUpgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../math/MathUpgradeable.sol";

/**
 * @dev Collection of functions related to array types.
 */
library ArraysUpgradeable {
   /**
     * @dev Searches a sorted `array` and returns the first index that contains
     * a value greater or equal to `element`. If no such index exists (i.e. all
     * values in the array are strictly less than `element`), the array length is
     * returned. Time complexity O(log n).
     *
     * `array` is expected to be sorted in ascending order, and to contain no
     * repeated elements.
     */
    function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
        if (array.length == 0) {
            return 0;
        }

        uint256 low = 0;
        uint256 high = array.length;

        while (low < high) {
            uint256 mid = MathUpgradeable.average(low, high);

            // Note that mid will always be strictly less than high (i.e. it will be a valid array index)
            // because Math.average rounds down (it does integer division with truncation).
            if (array[mid] > element) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }

        // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
        if (low > 0 && array[low - 1] == element) {
            return low - 1;
        } else {
            return low;
        }
    }
}
          

/_openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../math/SafeMathUpgradeable.sol";

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath}
 * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
 * directly accessed.
 */
library CountersUpgradeable {
    using SafeMathUpgradeable for uint256;

    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        // The {SafeMath} overflow check can be skipped here, see the comment at the top
        counter._value += 1;
    }

    function decrement(Counter storage counter) internal {
        counter._value = counter._value.sub(1);
    }
}
          

/_openzeppelin/contracts-upgradeable/utils/EnumerableSetUpgradeable.sol

// SPDX-License-Identifier: MIT

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

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

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

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

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

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

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

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

/contracts/reserve/IReserve.sol

// SPDX-License-Identifier: gpl-3.0

pragma solidity 0.7.5;

interface IReserve {
    event Transfer(address indexed to, uint256 amount);
    event RescueFunds(address token, address indexed to, uint256 amount);

    function balance() external view returns (uint256);

    function transfer(address payable _to, uint256 _value) external returns (bool);

    function rescueFunds(
        address _tokenToRescue,
        address _to,
        uint256 _amount
    ) external;
}
          

/contracts/token/bases/staking/StakedToken.sol

// SPDX-License-Identifier: agpl-3.0

pragma solidity 0.7.5;
pragma experimental ABIEncoderV2;

import './StakingRewards.sol';

import './interfaces/IStakedToken.sol';
import './interfaces/ITransferHook.sol';

import '../../../reserve/IReserve.sol';

import './lib/EthixERC20Snapshot.sol';

import '@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC20/SafeERC20Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/proxy/Initializable.sol';

/**
 * @title StakedToken
 * @notice Contract to stake Ethix token, tokenize the position and get rewards, inheriting from a distribution manager contract
 * @author Aave / Ethichub
 **/
contract StakedToken is Initializable, IStakedToken, ICooldownManager, EthixERC20Snapshot, StakingRewards {
    using SafeERC20Upgradeable for IERC20Upgradeable;
    using SafeMathUpgradeable for uint256;

    IERC20Upgradeable public STAKED_TOKEN;
    uint256 public COOLDOWN_SECONDS;

    /// @notice Seconds available to redeem once the cooldown period is fullfilled
    uint256 public UNSTAKE_WINDOW;

    /// @notice IReserve to pull from the rewards, needs to have this contract as WITHDRAW role
    IReserve public REWARDS_VAULT;

    mapping(address => uint256) public stakerRewardsToClaim;
    mapping(address => uint256) public stakersCooldowns;

    event Staked(address indexed from, address indexed onBehalfOf, uint256 amount);
    event Redeem(address indexed from, address indexed to, uint256 amount);

    event RewardsAccrued(address user, uint256 amount);
    event RewardsClaimed(address indexed from, address indexed to, uint256 amount);

    event Cooldown(address indexed user);

    function __StakedToken_init(
        string memory name,
        string memory symbol,
        uint8 decimals,
        ITransferHook ethixGovernance,
        IERC20Upgradeable stakedToken,
        uint256 cooldownSeconds,
        uint256 unstakeWindow,
        IReserve rewardsVault,
        address emissionManager,
        uint128 distributionDuration
    ) internal initializer {
        __EthixERC20Snapshot_init(name, symbol);
        _setupDecimals(decimals);
        _setEthixGovernance(ethixGovernance);
        __StakingRewards_init(emissionManager, distributionDuration);
        STAKED_TOKEN = stakedToken;
        COOLDOWN_SECONDS = cooldownSeconds;
        UNSTAKE_WINDOW = unstakeWindow;
        REWARDS_VAULT = rewardsVault;
    }

    /**
     * @dev Stake tokens
     * @param onBehalfOf Address of staker
     * @param amount Amount to stake
     **/
    function stake(address onBehalfOf, uint256 amount) external virtual override {
        require(amount != 0, 'INVALID_ZERO_AMOUNT');
        uint256 balanceOfUser = balanceOf(onBehalfOf);

        uint256 accruedRewards =
            _updateUserAssetInternal(onBehalfOf, address(this), balanceOfUser, totalSupply());
        if (accruedRewards != 0) {
            emit RewardsAccrued(onBehalfOf, accruedRewards);
            stakerRewardsToClaim[onBehalfOf] = stakerRewardsToClaim[onBehalfOf].add(accruedRewards);
        }

        stakersCooldowns[onBehalfOf] = getNextCooldownTimestamp(
            0,
            amount,
            onBehalfOf,
            balanceOfUser
        );

        _mint(onBehalfOf, amount);
        IERC20Upgradeable(STAKED_TOKEN).safeTransferFrom(msg.sender, address(this), amount);

        emit Staked(msg.sender, onBehalfOf, amount);
    }

    /**
     * @dev Redeems staked tokens, and stop earning rewards
     * @param to Address to redeem to
     * @param amount Amount to redeem
     **/
    function redeem(address to, uint256 amount) external override {
        require(amount != 0, 'INVALID_ZERO_AMOUNT');
        //solium-disable-next-line
        uint256 cooldownStartTimestamp = stakersCooldowns[msg.sender];
        require(
            block.timestamp > cooldownStartTimestamp.add(COOLDOWN_SECONDS),
            'INSUFFICIENT_COOLDOWN'
        );
        require(
            block.timestamp.sub(cooldownStartTimestamp.add(COOLDOWN_SECONDS)) <= UNSTAKE_WINDOW,
            'UNSTAKE_WINDOW_FINISHED'
        );
        uint256 balanceOfMessageSender = balanceOf(msg.sender);

        uint256 amountToRedeem =
            (amount > balanceOfMessageSender) ? balanceOfMessageSender : amount;

        _updateCurrentUnclaimedRewards(msg.sender, balanceOfMessageSender, true);

        _burn(msg.sender, amountToRedeem);

        if (balanceOfMessageSender.sub(amountToRedeem) == 0) {
            stakersCooldowns[msg.sender] = 0;
        }

        IERC20Upgradeable(STAKED_TOKEN).safeTransfer(to, amountToRedeem);

        emit Redeem(msg.sender, to, amountToRedeem);
    }

    /**
     * @dev Claims an `amount` from Rewards reserve to the address `to`
     * @param to Address to stake for
     * @param amount Amount to stake
     **/
    function claimRewards(address payable to, uint256 amount) external override {
        uint256 newTotalRewards =
            _updateCurrentUnclaimedRewards(msg.sender, balanceOf(msg.sender), false);
        uint256 amountToClaim = (amount == type(uint256).max) ? newTotalRewards : amount;

        stakerRewardsToClaim[msg.sender] = newTotalRewards.sub(amountToClaim, 'INVALID_AMOUNT');

        require(REWARDS_VAULT.transfer(to, amountToClaim), 'ERROR_TRANSFER_FROM_VAULT');

        emit RewardsClaimed(msg.sender, to, amountToClaim);
    }

    /**
     * @dev Return the total rewards pending to claim by an staker
     * @param staker The staker address
     * @return The rewards
     */
    function getTotalRewardsBalance(address staker) external override view returns (uint256) {
        DistributionTypes.UserStakeInput[] memory userStakeInputs =
            new DistributionTypes.UserStakeInput[](1);
        userStakeInputs[0] = DistributionTypes.UserStakeInput({
            underlyingAsset: address(this),
            stakedByUser: balanceOf(staker),
            totalStaked: totalSupply()
        });
        return stakerRewardsToClaim[staker].add(_getUnclaimedRewards(staker, userStakeInputs));
    }


    /**
     * @dev Activates the cooldown period to unstake
     * - It can't be called if the user is not staking
     **/
    function cooldown() external override {
        require(balanceOf(msg.sender) != 0, 'INVALID_BALANCE_ON_COOLDOWN');
        //solium-disable-next-line
        stakersCooldowns[msg.sender] = block.timestamp;

        emit Cooldown(msg.sender);
    }

    /**
     * @dev editable the cooldown seconds
     * @param cooldownSeconds cooldown seconds
     */
    function setCooldown(uint256 cooldownSeconds) external override {
        require(hasRole(EMISSION_MANAGER_ROLE, msg.sender), 'ONLY_EMISSION_MANAGER');
        COOLDOWN_SECONDS = cooldownSeconds;
    }

    /**
     * @dev editable unstake window
     * @param unstakeWindow unstake window
     */
    function setUnstakeWindow(uint256 unstakeWindow) external override {
        require(hasRole(EMISSION_MANAGER_ROLE, msg.sender), 'ONLY_EMISSION_MANAGER');
        UNSTAKE_WINDOW = unstakeWindow;
    }

    /**
     * @dev Calculates the how is gonna be a new cooldown timestamp depending on the sender/receiver situation
     *  - If the timestamp of the sender is "better" or the timestamp of the recipient is 0, we take the one of the recipient
     *  - Weighted average of from/to cooldown timestamps if:
     *    # The sender doesn't have the cooldown activated (timestamp 0).
     *    # The sender timestamp is expired
     *    # The sender has a "worse" timestamp
     *  - If the receiver's cooldown timestamp expired (too old), the next is 0
     * @param _fromCooldownTimestamp Cooldown timestamp of the sender
     * @param _amountToReceive Amount
     * @param _toAddress Address of the recipient
     * @param _toBalance Current balance of the receiver
     * @return The new cooldown timestamp
     **/
    function getNextCooldownTimestamp(
        uint256 _fromCooldownTimestamp,
        uint256 _amountToReceive,
        address _toAddress,
        uint256 _toBalance
    ) public override returns (uint256) {
        uint256 toCooldownTimestamp = stakersCooldowns[_toAddress];
        if (toCooldownTimestamp == 0) {
            return 0;
        }

        uint256 minimalValidCooldownTimestamp =
            block.timestamp.sub(COOLDOWN_SECONDS).sub(UNSTAKE_WINDOW);

        if (minimalValidCooldownTimestamp > toCooldownTimestamp) {
            toCooldownTimestamp = 0;
        } else {
            uint256 fromCooldownTimestamp =
                (minimalValidCooldownTimestamp > _fromCooldownTimestamp)
                    ? block.timestamp
                    : _fromCooldownTimestamp;

            if (fromCooldownTimestamp < toCooldownTimestamp) {
                return toCooldownTimestamp;
            } else {
                toCooldownTimestamp = (
                    _amountToReceive.mul(fromCooldownTimestamp).add(
                        _toBalance.mul(toCooldownTimestamp)
                    )
                )
                    .div(_amountToReceive.add(_toBalance));
            }
        }
        stakersCooldowns[_toAddress] = toCooldownTimestamp;

        return toCooldownTimestamp;
    }

    /**
     * @dev Internal ERC20 _transfer of the tokenized staked tokens
     * @param from Address to transfer from
     * @param to Address to transfer to
     * @param amount Amount to transfer
     **/
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal override {
        uint256 balanceOfFrom = balanceOf(from);
        // Sender
        _updateCurrentUnclaimedRewards(from, balanceOfFrom, true);

        // Recipient
        if (from != to) {
            uint256 balanceOfTo = balanceOf(to);
            _updateCurrentUnclaimedRewards(to, balanceOfTo, true);

            uint256 previousSenderCooldown = stakersCooldowns[from];
            stakersCooldowns[to] = getNextCooldownTimestamp(
                previousSenderCooldown,
                amount,
                to,
                balanceOfTo
            );
            // if cooldown was set and whole balance of sender was transferred - clear cooldown
            if (balanceOfFrom == amount && previousSenderCooldown != 0) {
                stakersCooldowns[from] = 0;
            }
        }

        super._transfer(from, to, amount);
    }

    /**
     * @dev Updates the user state related with his accrued rewards
     * @param user Address of the user
     * @param userBalance The current balance of the user
     * @param updateStorage Boolean flag used to update or not the stakerRewardsToClaim of the user
     * @return The unclaimed rewards that were added to the total accrued
     **/
    function _updateCurrentUnclaimedRewards(
        address user,
        uint256 userBalance,
        bool updateStorage
    ) internal returns (uint256) {
        uint256 accruedRewards =
            _updateUserAssetInternal(user, address(this), userBalance, totalSupply());
        uint256 unclaimedRewards = stakerRewardsToClaim[user].add(accruedRewards);

        if (accruedRewards != 0) {
            if (updateStorage) {
                stakerRewardsToClaim[user] = unclaimedRewards;
            }
            emit RewardsAccrued(user, accruedRewards);
        }

        return unclaimedRewards;
    }
}
          

/contracts/token/bases/staking/StakingRewards.sol

// SPDX-License-Identifier: agpl-3.0

pragma solidity 0.7.5;
pragma experimental ABIEncoderV2;

import './lib/DistributionTypes.sol';
import './interfaces/IStakingRewards.sol';

import '@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol';
import '../../../utils/SafeMathUint128.sol';
import '@openzeppelin/contracts-upgradeable/proxy/Initializable.sol';
import '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol';

/**
 * @title StakingRewards
 * @notice Accounting contract to manage multiple staking distributions
 * @author Aave / Ethichub
 **/
contract StakingRewards is Initializable, IStakingRewards, AccessControlUpgradeable {
    bytes32 public constant EMISSION_MANAGER_ROLE = keccak256('EMISSION_MANAGER');
    using SafeMathUpgradeable for uint256;
    using SafeMathUint128 for uint128;

    struct AssetData {
        uint128 emissionPerSecond;
        uint128 lastUpdateTimestamp;
        uint256 index;
        mapping(address => uint256) users;
    }

    uint256 public DISTRIBUTION_END;

    uint8 constant public PRECISION = 18;

    mapping(address => AssetData) public assets;

    event AssetConfigUpdated(address indexed asset, uint256 emission);
    event AssetIndexUpdated(address indexed asset, uint256 index);
    event UserIndexUpdated(address indexed user, address indexed asset, uint256 index);
    event DistributionEndChanged(uint256 distributionEnd);

    function __StakingRewards_init(address emissionManager, uint256 distributionDuration)
        public
        initializer
    {
        __AccessControl_init_unchained();
        DISTRIBUTION_END = block.timestamp.add(distributionDuration);
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setupRole(EMISSION_MANAGER_ROLE, emissionManager);
    }

    /**
     * @dev Configures the distribution of rewards for a list of assets
     * @param assetsConfigInput The list of configurations to apply
     **/
    function configureAssets(DistributionTypes.AssetConfigInput[] memory assetsConfigInput)
        public
        override
    {
        require(hasRole(EMISSION_MANAGER_ROLE, msg.sender), 'ONLY_EMISSION_MANAGER');

        for (uint256 i = 0; i < assetsConfigInput.length; i++) {
            AssetData storage assetConfig = assets[assetsConfigInput[i].underlyingAsset];

            _updateAssetStateInternal(
                assetsConfigInput[i].underlyingAsset,
                assetConfig,
                assetsConfigInput[i].totalStaked
            );

            assetConfig.emissionPerSecond = assetsConfigInput[i].emissionPerSecond;

            emit AssetConfigUpdated(
                assetsConfigInput[i].underlyingAsset,
                assetsConfigInput[i].emissionPerSecond
            );
        }
    }

    /**
     * @notice Change distribution end datetime
     * @param _distributionEndDate new distribution end datetime (UNIX Timestamp)
     */
    function changeDistributionEndDate(uint256 _distributionEndDate) public override {
        require(hasRole(EMISSION_MANAGER_ROLE, msg.sender), 'ONLY_EMISSION_MANAGER');
        return _changeDistributionEndDate(_distributionEndDate);
    }

    /**
     * @notice Change distribution end datetime internal function
     * @param _distributionEndDate new distribution end datetime (UNIX Timestamp)
     */
    function _changeDistributionEndDate(uint256 _distributionEndDate) internal {
        DISTRIBUTION_END = _distributionEndDate;
        emit DistributionEndChanged(DISTRIBUTION_END);
    }

    /**
     * @dev Updates the state of one distribution, mainly rewards index and timestamp
     * @param underlyingAsset The address used as key in the distribution
     * @param assetConfig Storage pointer to the distribution's config
     * @param totalStaked Current total of staked assets for this distribution
     * @return The new distribution index
     **/
    function _updateAssetStateInternal(
        address underlyingAsset,
        AssetData storage assetConfig,
        uint256 totalStaked
    ) internal returns (uint256) {
        uint256 oldIndex = assetConfig.index;
        uint128 lastUpdateTimestamp = assetConfig.lastUpdateTimestamp;

        if (block.timestamp == lastUpdateTimestamp) {
            return oldIndex;
        }

        uint256 newIndex =
            _getAssetIndex(
                oldIndex,
                assetConfig.emissionPerSecond,
                lastUpdateTimestamp,
                totalStaked
            );

        if (newIndex != oldIndex) {
            assetConfig.index = newIndex;
            emit AssetIndexUpdated(underlyingAsset, newIndex);
        }

        assetConfig.lastUpdateTimestamp = uint128(block.timestamp);

        return newIndex;
    }

    /**
     * @dev Updates the state of an user in a distribution
     * @param user The user's address
     * @param asset The address of the reference asset of the distribution
     * @param stakedByUser Amount of tokens staked by the user in the distribution at the moment
     * @param totalStaked Total tokens staked in the distribution
     * @return The accrued rewards for the user until the moment
     **/
    function _updateUserAssetInternal(
        address user,
        address asset,
        uint256 stakedByUser,
        uint256 totalStaked
    ) internal returns (uint256) {
        AssetData storage assetData = assets[asset];
        uint256 userIndex = assetData.users[user];
        uint256 accruedRewards = 0;

        uint256 newIndex = _updateAssetStateInternal(asset, assetData, totalStaked);

        if (userIndex != newIndex) {
            if (stakedByUser != 0) {
                accruedRewards = _getRewards(stakedByUser, newIndex, userIndex);
            }

            assetData.users[user] = newIndex;
            emit UserIndexUpdated(user, asset, newIndex);
        }

        return accruedRewards;
    }

    /**
     * @dev Used by "frontend" stake contracts to update the data of an user when claiming rewards from there
     * @param user The address of the user
     * @param stakes List of structs of the user data related with his stake
     * @return The accrued rewards for the user until the moment
     **/
    function _claimRewards(address payable user, DistributionTypes.UserStakeInput[] memory stakes)
        internal
        returns (uint256)
    {
        uint256 accruedRewards = 0;

        for (uint256 i = 0; i < stakes.length; i++) {
            accruedRewards = accruedRewards.add(
                _updateUserAssetInternal(
                    user,
                    stakes[i].underlyingAsset,
                    stakes[i].stakedByUser,
                    stakes[i].totalStaked
                )
            );
        }

        return accruedRewards;
    }

    /**
     * @dev Return the accrued rewards for an user over a list of distribution
     * @param user The address of the user
     * @param stakes List of structs of the user data related with his stake
     * @return The accrued rewards for the user until the moment
     **/
    function _getUnclaimedRewards(address user, DistributionTypes.UserStakeInput[] memory stakes)
        internal
        view
        returns (uint256)
    {
        uint256 accruedRewards = 0;

        for (uint256 i = 0; i < stakes.length; i++) {
            AssetData storage assetConfig = assets[stakes[i].underlyingAsset];
            uint256 assetIndex =
                _getAssetIndex(
                    assetConfig.index,
                    assetConfig.emissionPerSecond,
                    assetConfig.lastUpdateTimestamp,
                    stakes[i].totalStaked
                );

            accruedRewards = accruedRewards.add(
                _getRewards(stakes[i].stakedByUser, assetIndex, assetConfig.users[user])
            );
        }
        return accruedRewards;
    }

    /**
     * @dev Internal function for the calculation of user's rewards on a distribution
     * @param principalUserBalance Amount staked by the user on a distribution
     * @param reserveIndex Current index of the distribution
     * @param userIndex Index stored for the user, representation his staking moment
     * @return The rewards
     **/
    function _getRewards(
        uint256 principalUserBalance,
        uint256 reserveIndex,
        uint256 userIndex
    ) internal view returns (uint256) {
        return principalUserBalance.mul(reserveIndex.sub(userIndex)).div(10**uint256(PRECISION));
    }

    /**
     * @dev Calculates the next value of an specific distribution index, with validations
     * @param currentIndex Current index of the distribution
     * @param emissionPerSecond Representing the total rewards distributed per second per asset unit, on the distribution
     * @param lastUpdateTimestamp Last moment this distribution was updated
     * @param totalBalance of tokens considered for the distribution
     * @return The new index.
     **/
    function _getAssetIndex(
        uint256 currentIndex,
        uint256 emissionPerSecond,
        uint128 lastUpdateTimestamp,
        uint256 totalBalance
    ) internal view returns (uint256) {
        if (
            emissionPerSecond == 0 ||
            totalBalance == 0 ||
            lastUpdateTimestamp == block.timestamp ||
            lastUpdateTimestamp >= DISTRIBUTION_END
        ) {
            return currentIndex;
        }

        uint256 currentTimestamp =
            block.timestamp > DISTRIBUTION_END ? DISTRIBUTION_END : block.timestamp;
        uint256 timeDelta = currentTimestamp.sub(lastUpdateTimestamp);
        return
            emissionPerSecond.mul(timeDelta).mul(10**uint256(PRECISION)).div(totalBalance).add(
                currentIndex
            );
    }

    /**
     * @dev Returns the data of an user on a distribution
     * @param user Address of the user
     * @param asset The address of the reference asset of the distribution
     * @return The new index
     **/
    function getUserAssetData(address user, address asset) public view returns (uint256) {
        return assets[asset].users[user];
    }
}
          

/contracts/token/bases/staking/interfaces/IStakedToken.sol

// SPDX-License-Identifier: agpl-3.0

pragma solidity 0.7.5;

interface IStakedToken {
    function stake(address to, uint256 amount) external;
    function redeem(address to, uint256 amount) external;
    function claimRewards(address payable to, uint256 amount) external;
    function getTotalRewardsBalance(address staker) external returns (uint256);
    function getNextCooldownTimestamp(
        uint256 fromCooldownTimestamp,
        uint256 amountToReceive,
        address toAddress,
        uint256 toBalance
        ) external returns (uint256);
}

interface ICooldownManager {
    function cooldown() external;
    function setCooldown(uint256 cooldownSeconds) external;
    function setUnstakeWindow(uint256 unstakeWindow) external;
}
          

/contracts/token/bases/staking/interfaces/IStakingRewards.sol

// SPDX-License-Identifier: agpl-3.0

pragma solidity 0.7.5;
pragma experimental ABIEncoderV2;

import '../lib/DistributionTypes.sol';

interface IStakingRewards {
    function changeDistributionEndDate(uint256 date) external;
    function configureAssets(DistributionTypes.AssetConfigInput[] memory assetsConfigInput)
        external;
}
          

/contracts/token/bases/staking/interfaces/ITransferHook.sol

// SPDX-License-Identifier: agpl-3.0

pragma solidity 0.7.5;

interface ITransferHook {
    function onTransfer(
        address from,
        address to,
        uint256 amount
    ) external;
}
          

/contracts/token/bases/staking/lib/DistributionTypes.sol

// SPDX-License-Identifier: agpl-3.0

pragma solidity 0.7.5;
pragma experimental ABIEncoderV2;

library DistributionTypes {
    struct AssetConfigInput {
        uint128 emissionPerSecond;
        uint256 totalStaked;
        address underlyingAsset;
    }

    struct UserStakeInput {
        address underlyingAsset;
        uint256 stakedByUser;
        uint256 totalStaked;
    }
}
          

/contracts/token/bases/staking/lib/EthixERC20Snapshot.sol

// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.7.5;

import '../interfaces/ITransferHook.sol';

import '@openzeppelin/contracts-upgradeable/token/ERC20/ERC20SnapshotUpgradeable.sol';

/**
 * @title EthixERC20Snapshot
 * @notice Modified OZ ERC20Snapshot to add Aave stuff
 * @author Ethichub
 **/
contract EthixERC20Snapshot is ERC20SnapshotUpgradeable {

    function __EthixERC20Snapshot_init(string memory name_, string memory symbol_)
        public
        initializer
    {
        __ERC20Snapshot_init();
        __ERC20_init(name_, symbol_);
    }

    /// @dev reference to the Ethix governance contract to call (if initialized) on _beforeTokenTransfer
    /// !!! IMPORTANT The Ethix governance is considered a trustable contract, being its responsibility
    /// to control all potential reentrancies by calling back the this contract
    ITransferHook public _ethixGovernance;

    function _setEthixGovernance(ITransferHook ethixGovernance) internal virtual {
        _ethixGovernance = ethixGovernance;
    }

}
          

/contracts/utils/SafeMathUint128.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.7.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 SafeMathUint128 {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint128 a, uint128 b) internal pure returns (uint128) {
        uint128 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(uint128 a, uint128 b) internal pure returns (uint128) {
        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(uint128 a, uint128 b, string memory errorMessage) internal pure returns (uint128) {
        require(b <= a, errorMessage);
        uint128 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(uint128 a, uint128 b) internal pure returns (uint128) {
        // 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;
        }

        uint128 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(uint128 a, uint128 b) internal pure returns (uint128) {
        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(uint128 a, uint128 b, string memory errorMessage) internal pure returns (uint128) {
        require(b > 0, errorMessage);
        uint128 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(uint128 a, uint128 b) internal pure returns (uint128) {
        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(uint128 a, uint128 b, string memory errorMessage) internal pure returns (uint128) {
        require(b != 0, errorMessage);
        return a % b;
    }
}
          

Contract ABI

[{"type":"event","name":"Approval","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"spender","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"AssetConfigUpdated","inputs":[{"type":"address","name":"asset","internalType":"address","indexed":true},{"type":"uint256","name":"emission","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"AssetIndexUpdated","inputs":[{"type":"address","name":"asset","internalType":"address","indexed":true},{"type":"uint256","name":"index","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Cooldown","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"DistributionEndChanged","inputs":[{"type":"uint256","name":"distributionEnd","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Redeem","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardsAccrued","inputs":[{"type":"address","name":"user","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardsClaimed","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Snapshot","inputs":[{"type":"uint256","name":"id","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Staked","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"onBehalfOf","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"UserIndexUpdated","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"address","name":"asset","internalType":"address","indexed":true},{"type":"uint256","name":"index","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"COOLDOWN_SECONDS","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"DISTRIBUTION_END","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"EMISSION_MANAGER_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"PRECISION","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IReserve"}],"name":"REWARDS_VAULT","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20Upgradeable"}],"name":"STAKED_TOKEN","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"UNSTAKE_WINDOW","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"__EthixERC20Snapshot_init","inputs":[{"type":"string","name":"name_","internalType":"string"},{"type":"string","name":"symbol_","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"__StakingRewards_init","inputs":[{"type":"address","name":"emissionManager","internalType":"address"},{"type":"uint256","name":"distributionDuration","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ITransferHook"}],"name":"_ethixGovernance","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"allowance","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"spender","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"approve","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint128","name":"emissionPerSecond","internalType":"uint128"},{"type":"uint128","name":"lastUpdateTimestamp","internalType":"uint128"},{"type":"uint256","name":"index","internalType":"uint256"}],"name":"assets","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOfAt","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"snapshotId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"changeDistributionEndDate","inputs":[{"type":"uint256","name":"_distributionEndDate","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimRewards","inputs":[{"type":"address","name":"to","internalType":"address payable"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"configureAssets","inputs":[{"type":"tuple[]","name":"assetsConfigInput","internalType":"struct DistributionTypes.AssetConfigInput[]","components":[{"type":"uint128","name":"emissionPerSecond","internalType":"uint128"},{"type":"uint256","name":"totalStaked","internalType":"uint256"},{"type":"address","name":"underlyingAsset","internalType":"address"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"cooldown","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"decimals","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"decreaseAllowance","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"subtractedValue","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getNextCooldownTimestamp","inputs":[{"type":"uint256","name":"_fromCooldownTimestamp","internalType":"uint256"},{"type":"uint256","name":"_amountToReceive","internalType":"uint256"},{"type":"address","name":"_toAddress","internalType":"address"},{"type":"uint256","name":"_toBalance","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getRoleMember","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getRoleMemberCount","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getTotalRewardsBalance","inputs":[{"type":"address","name":"staker","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getUserAssetData","inputs":[{"type":"address","name":"user","internalType":"address"},{"type":"address","name":"asset","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"increaseAllowance","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"addedValue","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"stakedToken","internalType":"contract IERC20Upgradeable"},{"type":"address","name":"ethixGovernance","internalType":"contract ITransferHook"},{"type":"uint256","name":"cooldownSeconds","internalType":"uint256"},{"type":"uint256","name":"unstakeWindow","internalType":"uint256"},{"type":"address","name":"rewardsVault","internalType":"contract IReserve"},{"type":"address","name":"emissionManager","internalType":"address"},{"type":"uint128","name":"distributionDuration","internalType":"uint128"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"redeem","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setCooldown","inputs":[{"type":"uint256","name":"cooldownSeconds","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setUnstakeWindow","inputs":[{"type":"uint256","name":"unstakeWindow","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"stake","inputs":[{"type":"address","name":"onBehalfOf","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"stakerRewardsToClaim","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"stakersCooldowns","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupplyAt","inputs":[{"type":"uint256","name":"snapshotId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transfer","inputs":[{"type":"address","name":"recipient","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transferFrom","inputs":[{"type":"address","name":"sender","internalType":"address"},{"type":"address","name":"recipient","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]}]
              

Contract Creation Code

0x608060405234801561001057600080fd5b506137aa806100206000396000f3fe608060405234801561001057600080fd5b506004361061028a5760003560e01c80639010d07c1161015c578063adc9772e116100ce578063ca15c87311610087578063ca15c87314610539578063d547741f1461054c578063dd62ed3e1461055f578063f11b818814610572578063f1cc432a14610594578063f8f10dfc146105a75761028a565b8063adc9772e146104d2578063b2a5dbfa146104e5578063b398741a146104f8578063b4f0e8c31461050b578063c1a9d6e914610513578063c3c9e42d146105265761028a565b8063981b24d011610120578063981b24d0146104765780639a99b4f014610489578063a217fddf1461049c578063a457c2d7146104a4578063a9059cbb146104b7578063aaf5eb68146104ca5761028a565b80639010d07c14610438578063919cd40f1461044b57806391d1485414610453578063946776cd1461046657806395d89b411461046e5761028a565b80633373ee4c116102005780635fe5952a116101b95780635fe5952a146103e757806370a08231146103ef57806372b49d6314610402578063787a08a61461040a5780637e90d7ef146104125780638dbefee2146104255761028a565b80633373ee4c14610380578063359c4a961461039357806336568abe1461039b57806339509351146103ae5780634ee2cd7e146103c15780634fc3f41a146103d45761028a565b806323b872dd1161025257806323b872dd1461030a578063248a9ca31461031d5780632752f89a146103305780632f2ff15d14610343578063312f6b8314610356578063313ce5671461036b5761028a565b806306fdde031461028f578063091030c3146102ad578063095ea7b3146102cd57806318160ddd146102ed5780631e9a6950146102f5575b600080fd5b6102976105ba565b6040516102a491906132e5565b60405180910390f35b6102c06102bb366004612f8a565b610650565b6040516102a491906132dc565b6102e06102db366004613049565b610662565b6040516102a491906132d1565b6102c0610680565b610308610303366004613049565b610686565b005b6102e0610318366004613009565b6107e7565b6102c061032b366004613129565b61086f565b61030861033e366004613129565b610887565b610308610351366004613141565b6108c7565b61035e61092e565b6040516102a491906132a4565b61037361093d565b6040516102a491906134a0565b6102c061038e366004612fd1565b610946565b6102c0610976565b6103086103a9366004613141565b61097c565b6102e06103bc366004613049565b6109dd565b6102c06103cf366004613049565b610a2b565b6103086103e2366004613129565b610a74565b61035e610aad565b6102c06103fd366004612f8a565b610abc565b6102c0610ad7565b610308610add565b6102c0610420366004612f8a565b610b3c565b6102c0610433366004612f8a565b610b4e565b61035e610446366004613165565b610bfd565b6102c0610c15565b6102e0610461366004613141565b610c1b565b61035e610c33565b610297610c42565b6102c0610484366004613129565b610ca3565b610308610497366004612fa6565b610cd3565b6102c0610e40565b6102e06104b2366004613049565b610e45565b6102e06104c5366004613049565b610ead565b610373610ec1565b6103086104e0366004613049565b610ec6565b6103086104f336600461305b565b61100e565b610308610506366004613049565b61117d565b6102c0611259565b610308610521366004613186565b61126b565b610308610534366004613205565b61136b565b6102c0610547366004613129565b61140a565b61030861055a366004613141565b611421565b6102c061056d366004612fd1565b61147a565b610585610580366004612f8a565b6114a5565b6040516102a49392919061347c565b6102c06105a2366004613266565b6114d3565b6103086105b5366004613129565b6115b1565b60368054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106465780601f1061061b57610100808354040283529160200191610646565b820191906000526020600020905b81548152906001019060200180831161062957829003601f168201915b5050505050905090565b60d16020526000908152604090205481565b600061067661066f6115ea565b84846115ee565b5060015b92915050565b60355490565b806106ac5760405162461bcd60e51b81526004016106a390613338565b60405180910390fd5b33600090815260d1602052604090205460cd546106ca9082906116da565b42116106e85760405162461bcd60e51b81526004016106a39061339c565b60ce5461070a61070360cd54846116da90919063ffffffff16565b4290611734565b11156107285760405162461bcd60e51b81526004016106a3906133fa565b600061073333610abc565b905060008184116107445783610746565b815b905061075433836001611776565b5061075f338261181a565b6107698282611734565b61077e5733600090815260d160205260408120555b60cc54610795906001600160a01b03168683611916565b846001600160a01b0316336001600160a01b03167fd12200efa34901b99367694174c3b0d32c99585fdf37c7c26892136ddd0836d9836040516107d891906132dc565b60405180910390a35050505050565b60006107f4848484611968565b610864846108006115ea565b61085f85604051806060016040528060288152602001613665602891396001600160a01b038a1660009081526034602052604081209061083e6115ea565b6001600160a01b031681526020810191909152604001600020549190611a34565b6115ee565b5060015b9392505050565b6000818152609860205260409020600201545b919050565b61089f60008051602061357e83398151915233610c1b565b6108bb5760405162461bcd60e51b81526004016106a3906133cb565b6108c481611acb565b50565b6000828152609860205260409020600201546108e5906104616115ea565b6109205760405162461bcd60e51b815260040180806020018281038252602f81526020018061352d602f913960400191505060405180910390fd5b61092a8282611b0b565b5050565b60cc546001600160a01b031681565b60385460ff1690565b6001600160a01b03808216600090815260cb60209081526040808320938616835260029093019052205492915050565b60ce5481565b6109846115ea565b6001600160a01b0316816001600160a01b0316146109d35760405162461bcd60e51b815260040180806020018281038252602f815260200180613746602f913960400191505060405180910390fd5b61092a8282611b74565b60006106766109ea6115ea565b8461085f85603460006109fb6115ea565b6001600160a01b03908116825260208083019390935260409182016000908120918c1681529252902054906116da565b6001600160a01b038216600090815260656020526040812081908190610a52908590611bdd565b9150915081610a6957610a6485610abc565b610a6b565b805b95945050505050565b610a8c60008051602061357e83398151915233610c1b565b610aa85760405162461bcd60e51b81526004016106a3906133cb565b60cd55565b6097546001600160a01b031681565b6001600160a01b031660009081526033602052604090205490565b60cd5481565b610ae633610abc565b610b025760405162461bcd60e51b81526004016106a390613431565b33600081815260d16020526040808220429055517ff52f50426b32362d3e6bb8cb36b7074756b224622def6352a59eac7f66ebe6e89190a2565b60d06020526000908152604090205481565b60408051600180825281830190925260009160609190816020015b610b71612ddd565b815260200190600190039081610b695790505090506040518060600160405280306001600160a01b03168152602001610ba985610abc565b8152602001610bb6610680565b81525081600081518110610bc657fe5b6020026020010181905250610868610bde8483611cda565b6001600160a01b038516600090815260d06020526040902054906116da565b60008281526098602052604081206108689083611dcb565b60ca5481565b60008281526098602052604081206108689083611dd7565b60cf546001600160a01b031681565b60378054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106465780601f1061061b57610100808354040283529160200191610646565b6000806000610cb3846066611bdd565b9150915081610cc957610cc4610680565b610ccb565b805b949350505050565b6000610ce933610ce233610abc565b6000611776565b905060006000198314610cfc5782610cfe565b815b9050610d3b816040518060400160405280600e81526020016d1253959053125117d05353d5539560921b81525084611a349092919063ffffffff16565b33600090815260d06020526040908190209190915560cf54905163a9059cbb60e01b81526001600160a01b039091169063a9059cbb90610d8190879085906004016132b8565b602060405180830381600087803b158015610d9b57600080fd5b505af1158015610daf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd39190613109565b610def5760405162461bcd60e51b81526004016106a390613365565b836001600160a01b0316336001600160a01b03167f9310ccfcb8de723f578a9e4282ea9f521f05ae40dc08f3068dfad528a65ee3c783604051610e3291906132dc565b60405180910390a350505050565b600081565b6000610676610e526115ea565b8461085f856040518060600160405280602581526020016137216025913960346000610e7c6115ea565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190611a34565b6000610676610eba6115ea565b8484611968565b601281565b80610ee35760405162461bcd60e51b81526004016106a390613338565b6000610eee83610abc565b90506000610f05843084610f00610680565b611dec565b90508015610f83577f2468f9268c60ad90e2d49edb0032c8a001e733ae888b3ab8e982edf535be1a768482604051610f3e9291906132b8565b60405180910390a16001600160a01b038416600090815260d06020526040902054610f6990826116da565b6001600160a01b038516600090815260d060205260409020555b610f9060008486856114d3565b6001600160a01b038516600090815260d16020526040902055610fb38484611eab565b60cc54610fcb906001600160a01b0316333086611f9d565b836001600160a01b0316336001600160a01b03167f5dac0c1b1112564a045ba943c9d50270893e8e826c49be8e7073adc713ab7bd785604051610e3291906132dc565b61102660008051602061357e83398151915233610c1b565b6110425760405162461bcd60e51b81526004016106a3906133cb565b60005b815181101561092a57600060cb600084848151811061106057fe5b6020026020010151604001516001600160a01b03166001600160a01b0316815260200190815260200160002090506110c783838151811061109d57fe5b602002602001015160400151828585815181106110b657fe5b602002602001015160200151611ff7565b508282815181106110d457fe5b60209081029190910101515181546fffffffffffffffffffffffffffffffff19166001600160801b03909116178155825183908390811061111157fe5b6020026020010151604001516001600160a01b03167f87fa03892a0556cb6b8f97e6d533a150d4d55fcbf275fff5fa003fa636bcc7fa84848151811061115357fe5b60200260200101516000015160405161116c9190613468565b60405180910390a250600101611045565b600054610100900460ff168061119657506111966120b4565b806111a4575060005460ff16155b6111df5760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff1615801561120a576000805460ff1961ff0019909116610100171660011790555b6112126120ba565b61121c42836116da565b60ca5561122a600033610920565b61124260008051602061357e83398151915284610920565b8015611254576000805461ff00191690555b505050565b60008051602061357e83398151915281565b600054610100900460ff168061128457506112846120b4565b80611292575060005460ff16155b6112cd5760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff161580156112f8576000805460ff1961ff0019909116610100171660011790555b61134f6040518060400160405280600c81526020016b0a6e8c2d6cac8408aa89092b60a31b815250604051806040016040528060088152602001670e6e8d68aa89092b60c31b81525060128a8c8b8b8b8b8b61215b565b8015611361576000805461ff00191690555b5050505050505050565b600054610100900460ff168061138457506113846120b4565b80611392575060005460ff16155b6113cd5760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff161580156113f8576000805460ff1961ff0019909116610100171660011790555b611400612270565b611242838361230d565b600081815260986020526040812061067a906123ac565b60008281526098602052604090206002015461143f906104616115ea565b6109d35760405162461bcd60e51b81526004018080602001828103825260308152602001806135e66030913960400191505060405180910390fd5b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b60cb60205260009081526040902080546001909101546001600160801b0380831692600160801b9004169083565b6001600160a01b038216600090815260d16020526040812054806114fb576000915050610ccb565b600061151e60ce5461151860cd544261173490919063ffffffff16565b90611734565b905081811115611531576000915061158b565b60008782116115405787611542565b425b90508281101561155757829350505050610ccb565b61158761156488876116da565b61158161157188876123b7565b61157b8b866123b7565b906116da565b90612410565b9250505b506001600160a01b038416600090815260d1602052604090208190559050949350505050565b6115c960008051602061357e83398151915233610c1b565b6115e55760405162461bcd60e51b81526004016106a3906133cb565b60ce55565b3390565b6001600160a01b0383166116335760405162461bcd60e51b81526004018080602001828103825260248152602001806136d36024913960400191505060405180910390fd5b6001600160a01b0382166116785760405162461bcd60e51b815260040180806020018281038252602281526020018061359e6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260346020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b600082820183811015610868576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600061086883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611a34565b600080611787853086610f00610680565b6001600160a01b038616600090815260d06020526040812054919250906117ae90836116da565b90508115610a6b5783156117d8576001600160a01b038616600090815260d0602052604090208190555b7f2468f9268c60ad90e2d49edb0032c8a001e733ae888b3ab8e982edf535be1a7686836040516118099291906132b8565b60405180910390a195945050505050565b6001600160a01b03821661185f5760405162461bcd60e51b815260040180806020018281038252602181526020018061368d6021913960400191505060405180910390fd5b61186b82600083612452565b6118a88160405180606001604052806022815260200161355c602291396001600160a01b0385166000908152603360205260409020549190611a34565b6001600160a01b0383166000908152603360205260409020556035546118ce9082611734565b6035556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526112549084906124aa565b600061197384610abc565b905061198184826001611776565b50826001600160a01b0316846001600160a01b031614611a235760006119a684610abc565b90506119b484826001611776565b506001600160a01b038516600090815260d160205260409020546119da818587856114d3565b6001600160a01b038616600090815260d160205260409020558284148015611a0157508015155b15611a20576001600160a01b038616600090815260d160205260408120555b50505b611a2e84848461255b565b50505050565b60008184841115611ac35760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611a88578181015183820152602001611a70565b50505050905090810190601f168015611ab55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60ca8190556040517f04719fa2f4e8205ff1369b5c7d2b3eb66c25570e7bf668ae7ccecb8fbd7ed52e90611b009083906132dc565b60405180910390a150565b6000828152609860205260409020611b2390826126b8565b1561092a57611b306115ea565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152609860205260409020611b8c90826126cd565b1561092a57611b996115ea565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60008060008411611c2e576040805162461bcd60e51b815260206004820152601660248201527504552433230536e617073686f743a20696420697320360541b604482015290519081900360640190fd5b611c3860686126e2565b841115611c8c576040805162461bcd60e51b815260206004820152601d60248201527f4552433230536e617073686f743a206e6f6e6578697374656e74206964000000604482015290519081900360640190fd5b6000611c9884866126e6565b8454909150811415611cb1576000809250925050611cd3565b6001846001018281548110611cc257fe5b906000526020600020015492509250505b9250929050565b600080805b8351811015611dc357600060cb6000868481518110611cfa57fe5b602090810291909101810151516001600160a01b031682528101919091526040016000908120600181015481548851929450611d62926001600160801b0380831692600160801b900416908a9088908110611d5157fe5b602002602001015160400151612787565b9050611db7611db0878581518110611d7657fe5b602002602001015160200151838560020160008c6001600160a01b03166001600160a01b0316815260200190815260200160002054612826565b85906116da565b93505050600101611cdf565b509392505050565b60006108688383612848565b6000610868836001600160a01b0384166128ac565b6001600160a01b03808416600090815260cb602090815260408083209388168352600284019091528120549091908280611e27888588611ff7565b9050808314611e9f578615611e4457611e41878285612826565b91505b6001600160a01b03808a1660008181526002870160205260409081902084905551918a16917fbb123b5c06d5408bbea3c4fef481578175cfb432e3b482c6186f02ed9086585b90611e969085906132dc565b60405180910390a35b50979650505050505050565b6001600160a01b038216611f06576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b611f1260008383612452565b603554611f1f90826116da565b6035556001600160a01b038216600090815260336020526040902054611f4590826116da565b6001600160a01b03831660008181526033602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611a2e9085906124aa565b6001820154825460009190600160801b90046001600160801b03164281141561202257509050610868565b845460009061203d9084906001600160801b03168488612787565b905082811461209157808660010181905550866001600160a01b03167f5777ca300dfe5bead41006fbce4389794dbc0ed8d6cccebfaf94630aa04184bc8260405161208891906132dc565b60405180910390a25b85546001600160801b03428116600160801b029116178655925050509392505050565b303b1590565b600054610100900460ff16806120d357506120d36120b4565b806120e1575060005460ff16155b61211c5760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff16158015612147576000805460ff1961ff0019909116610100171660011790555b80156108c4576000805461ff001916905550565b600054610100900460ff168061217457506121746120b4565b80612182575060005460ff16155b6121bd5760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff161580156121e8576000805460ff1961ff0019909116610100171660011790555b6121f28b8b61136b565b6121fb896128c4565b612204886128da565b61221783836001600160801b031661117d565b60cc80546001600160a01b03808a166001600160a01b03199283161790925560cd88905560ce87905560cf8054928716929091169190911790558015612263576000805461ff00191690555b5050505050505050505050565b600054610100900460ff168061228957506122896120b4565b80612297575060005460ff16155b6122d25760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff161580156122fd576000805460ff1961ff0019909116610100171660011790555b6123056120ba565b6121476120ba565b600054610100900460ff168061232657506123266120b4565b80612334575060005460ff16155b61236f5760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff1615801561239a576000805460ff1961ff0019909116610100171660011790555b6123a26120ba565b61124283836128fc565b600061067a826126e2565b6000826123c65750600061067a565b828202828482816123d357fe5b04146108685760405162461bcd60e51b81526004018080602001828103825260218152602001806136446021913960400191505060405180910390fd5b600061086883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506129d4565b61245d838383611254565b6001600160a01b0383166124815761247482612a39565b61247c612a63565b611254565b6001600160a01b0382166124985761247483612a39565b6124a183612a39565b61125482612a39565b60606124ff826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a729092919063ffffffff16565b8051909150156112545780806020019051602081101561251e57600080fd5b50516112545760405162461bcd60e51b815260040180806020018281038252602a8152602001806136f7602a913960400191505060405180910390fd5b6001600160a01b0383166125a05760405162461bcd60e51b81526004018080602001828103825260258152602001806136ae6025913960400191505060405180910390fd5b6001600160a01b0382166125e55760405162461bcd60e51b815260040180806020018281038252602381526020018061350a6023913960400191505060405180910390fd5b6125f0838383612452565b61262d816040518060600160405280602681526020016135c0602691396001600160a01b0386166000908152603360205260409020549190611a34565b6001600160a01b03808516600090815260336020526040808220939093559084168152205461265c90826116da565b6001600160a01b0380841660008181526033602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000610868836001600160a01b038416612a81565b6000610868836001600160a01b038416612acb565b5490565b81546000906126f75750600061067a565b82546000905b808210156127465760006127118383612b91565b90508486828154811061272057fe5b9060005260206000200154111561273957809150612740565b8060010192505b506126fd565b60008211801561276e57508385600184038154811061276157fe5b9060005260206000200154145b1561277f575060001901905061067a565b50905061067a565b6000831580612794575081155b806127a7575042836001600160801b0316145b806127bd575060ca54836001600160801b031610155b156127c9575083610ccb565b600060ca5442116127da57426127de565b60ca545b905060006127f5826001600160801b038716611734565b905061281b8761157b86611581670de0b6b3a76400006128158c886123b7565b906123b7565b979650505050505050565b6000610ccb670de0b6b3a76400006115816128418686611734565b87906123b7565b8154600090821061288a5760405162461bcd60e51b81526004018080602001828103825260228152602001806134e86022913960400191505060405180910390fd5b82600001828154811061289957fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b6038805460ff191660ff92909216919091179055565b609780546001600160a01b0319166001600160a01b0392909216919091179055565b600054610100900460ff168061291557506129156120b4565b80612923575060005460ff16155b61295e5760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff16158015612989576000805460ff1961ff0019909116610100171660011790555b825161299c906036906020860190612e07565b5081516129b0906037906020850190612e07565b506038805460ff191660121790558015611254576000805461ff0019169055505050565b60008183612a235760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611a88578181015183820152602001611a70565b506000838581612a2f57fe5b0495945050505050565b6001600160a01b03811660009081526065602052604090206108c490612a5e83610abc565b612bb6565b612a706066612a5e610680565b565b6060610ccb8484600085612c02565b6000612a8d83836128ac565b612ac35750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561067a565b50600061067a565b60008181526001830160205260408120548015612b875783546000198083019190810190600090879083908110612afe57fe5b9060005260206000200154905080876000018481548110612b1b57fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080612b4b57fe5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505061067a565b600091505061067a565b60006002808306600285060181612ba457fe5b04600283046002850401019392505050565b6000612bc260686126e2565b905080612bce84612d6f565b1015611254578254600180820185556000858152602080822090930193909355938401805494850181558252902090910155565b6060612c0d85612da4565b612c5e576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310612c9d5780518252601f199092019160209182019101612c7e565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612cff576040519150601f19603f3d011682016040523d82523d6000602084013e612d04565b606091505b50915091508115612d18579150610ccb9050565b805115612d285780518082602001fd5b60405162461bcd60e51b8152602060048201818152865160248401528651879391928392604401919085019080838360008315611a88578181015183820152602001611a70565b8054600090612d8057506000610882565b815482906000198101908110612d9257fe5b90600052602060002001549050610882565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590610ccb575050151592915050565b604051806060016040528060006001600160a01b0316815260200160008152602001600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282612e3d5760008555612e83565b82601f10612e5657805160ff1916838001178555612e83565b82800160010185558215612e83579182015b82811115612e83578251825591602001919060010190612e68565b50612e8f929150612e93565b5090565b5b80821115612e8f5760008155600101612e94565b600082601f830112612eb8578081fd5b813567ffffffffffffffff811115612ecc57fe5b612edf601f8201601f19166020016134ae565b9150808252836020828501011115612ef657600080fd5b8060208401602084013760009082016020015292915050565b600060608284031215612f20578081fd5b6040516060810181811067ffffffffffffffff82111715612f3d57fe5b604052905080612f4c83612f73565b8152602083013560208201526040830135612f66816134d2565b6040919091015292915050565b80356001600160801b038116811461088257600080fd5b600060208284031215612f9b578081fd5b8135610868816134d2565b60008060408385031215612fb8578081fd5b8235612fc3816134d2565b946020939093013593505050565b60008060408385031215612fe3578182fd5b8235612fee816134d2565b91506020830135612ffe816134d2565b809150509250929050565b60008060006060848603121561301d578081fd5b8335613028816134d2565b92506020840135613038816134d2565b929592945050506040919091013590565b60008060408385031215612fb8578182fd5b6000602080838503121561306d578182fd5b823567ffffffffffffffff80821115613084578384fd5b818501915085601f830112613097578384fd5b8135818111156130a357fe5b6130b084858302016134ae565b81815284810192508385016060808402860187018a10156130cf578788fd5b8795505b838610156130fb576130e58a83612f0f565b85526001959095019493860193908101906130d3565b509098975050505050505050565b60006020828403121561311a578081fd5b81518015158114610868578182fd5b60006020828403121561313a578081fd5b5035919050565b60008060408385031215613153578182fd5b823591506020830135612ffe816134d2565b60008060408385031215613177578182fd5b50508035926020909101359150565b600080600080600080600060e0888a0312156131a0578283fd5b87356131ab816134d2565b965060208801356131bb816134d2565b9550604088013594506060880135935060808801356131d9816134d2565b925060a08801356131e9816134d2565b91506131f760c08901612f73565b905092959891949750929550565b60008060408385031215613217578182fd5b823567ffffffffffffffff8082111561322e578384fd5b61323a86838701612ea8565b9350602085013591508082111561324f578283fd5b5061325c85828601612ea8565b9150509250929050565b6000806000806080858703121561327b578182fd5b84359350602085013592506040850135613294816134d2565b9396929550929360600135925050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b90815260200190565b6000602080835283518082850152825b81811015613311578581018301518582016040015282016132f5565b818111156133225783604083870101525b50601f01601f1916929092016040019392505050565b6020808252601390820152721253959053125117d6915493d7d05353d55395606a1b604082015260600190565b60208082526019908201527f4552524f525f5452414e534645525f46524f4d5f5641554c5400000000000000604082015260600190565b60208082526015908201527424a729aaa32324a1a4a2a72a2fa1a7a7a62227aba760591b604082015260600190565b60208082526015908201527427a7262cafa2a6a4a9a9a4a7a72fa6a0a720a3a2a960591b604082015260600190565b60208082526017908201527f554e5354414b455f57494e444f575f46494e4953484544000000000000000000604082015260600190565b6020808252601b908201527f494e56414c49445f42414c414e43455f4f4e5f434f4f4c444f574e0000000000604082015260600190565b6001600160801b0391909116815260200190565b6001600160801b039384168152919092166020820152604081019190915260600190565b60ff91909116815260200190565b60405181810167ffffffffffffffff811182821017156134ca57fe5b604052919050565b6001600160a01b03811681146108c457600080fdfe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e647345524332303a207472616e7366657220746f20746865207a65726f2061646472657373416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e7445524332303a206275726e20616d6f756e7420657863656564732062616c616e63650178ef1edee9408b9148e43c7402964baa5d7066a35d0ff56e2596c8e1dc0f6745524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b65496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a26469706673582212202aba800e04981d687dcdf95b299602d4d6f7a65cebda64ec24a81e10a5a8326664736f6c63430007050033

Deployed ByteCode

0x608060405234801561001057600080fd5b506004361061028a5760003560e01c80639010d07c1161015c578063adc9772e116100ce578063ca15c87311610087578063ca15c87314610539578063d547741f1461054c578063dd62ed3e1461055f578063f11b818814610572578063f1cc432a14610594578063f8f10dfc146105a75761028a565b8063adc9772e146104d2578063b2a5dbfa146104e5578063b398741a146104f8578063b4f0e8c31461050b578063c1a9d6e914610513578063c3c9e42d146105265761028a565b8063981b24d011610120578063981b24d0146104765780639a99b4f014610489578063a217fddf1461049c578063a457c2d7146104a4578063a9059cbb146104b7578063aaf5eb68146104ca5761028a565b80639010d07c14610438578063919cd40f1461044b57806391d1485414610453578063946776cd1461046657806395d89b411461046e5761028a565b80633373ee4c116102005780635fe5952a116101b95780635fe5952a146103e757806370a08231146103ef57806372b49d6314610402578063787a08a61461040a5780637e90d7ef146104125780638dbefee2146104255761028a565b80633373ee4c14610380578063359c4a961461039357806336568abe1461039b57806339509351146103ae5780634ee2cd7e146103c15780634fc3f41a146103d45761028a565b806323b872dd1161025257806323b872dd1461030a578063248a9ca31461031d5780632752f89a146103305780632f2ff15d14610343578063312f6b8314610356578063313ce5671461036b5761028a565b806306fdde031461028f578063091030c3146102ad578063095ea7b3146102cd57806318160ddd146102ed5780631e9a6950146102f5575b600080fd5b6102976105ba565b6040516102a491906132e5565b60405180910390f35b6102c06102bb366004612f8a565b610650565b6040516102a491906132dc565b6102e06102db366004613049565b610662565b6040516102a491906132d1565b6102c0610680565b610308610303366004613049565b610686565b005b6102e0610318366004613009565b6107e7565b6102c061032b366004613129565b61086f565b61030861033e366004613129565b610887565b610308610351366004613141565b6108c7565b61035e61092e565b6040516102a491906132a4565b61037361093d565b6040516102a491906134a0565b6102c061038e366004612fd1565b610946565b6102c0610976565b6103086103a9366004613141565b61097c565b6102e06103bc366004613049565b6109dd565b6102c06103cf366004613049565b610a2b565b6103086103e2366004613129565b610a74565b61035e610aad565b6102c06103fd366004612f8a565b610abc565b6102c0610ad7565b610308610add565b6102c0610420366004612f8a565b610b3c565b6102c0610433366004612f8a565b610b4e565b61035e610446366004613165565b610bfd565b6102c0610c15565b6102e0610461366004613141565b610c1b565b61035e610c33565b610297610c42565b6102c0610484366004613129565b610ca3565b610308610497366004612fa6565b610cd3565b6102c0610e40565b6102e06104b2366004613049565b610e45565b6102e06104c5366004613049565b610ead565b610373610ec1565b6103086104e0366004613049565b610ec6565b6103086104f336600461305b565b61100e565b610308610506366004613049565b61117d565b6102c0611259565b610308610521366004613186565b61126b565b610308610534366004613205565b61136b565b6102c0610547366004613129565b61140a565b61030861055a366004613141565b611421565b6102c061056d366004612fd1565b61147a565b610585610580366004612f8a565b6114a5565b6040516102a49392919061347c565b6102c06105a2366004613266565b6114d3565b6103086105b5366004613129565b6115b1565b60368054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106465780601f1061061b57610100808354040283529160200191610646565b820191906000526020600020905b81548152906001019060200180831161062957829003601f168201915b5050505050905090565b60d16020526000908152604090205481565b600061067661066f6115ea565b84846115ee565b5060015b92915050565b60355490565b806106ac5760405162461bcd60e51b81526004016106a390613338565b60405180910390fd5b33600090815260d1602052604090205460cd546106ca9082906116da565b42116106e85760405162461bcd60e51b81526004016106a39061339c565b60ce5461070a61070360cd54846116da90919063ffffffff16565b4290611734565b11156107285760405162461bcd60e51b81526004016106a3906133fa565b600061073333610abc565b905060008184116107445783610746565b815b905061075433836001611776565b5061075f338261181a565b6107698282611734565b61077e5733600090815260d160205260408120555b60cc54610795906001600160a01b03168683611916565b846001600160a01b0316336001600160a01b03167fd12200efa34901b99367694174c3b0d32c99585fdf37c7c26892136ddd0836d9836040516107d891906132dc565b60405180910390a35050505050565b60006107f4848484611968565b610864846108006115ea565b61085f85604051806060016040528060288152602001613665602891396001600160a01b038a1660009081526034602052604081209061083e6115ea565b6001600160a01b031681526020810191909152604001600020549190611a34565b6115ee565b5060015b9392505050565b6000818152609860205260409020600201545b919050565b61089f60008051602061357e83398151915233610c1b565b6108bb5760405162461bcd60e51b81526004016106a3906133cb565b6108c481611acb565b50565b6000828152609860205260409020600201546108e5906104616115ea565b6109205760405162461bcd60e51b815260040180806020018281038252602f81526020018061352d602f913960400191505060405180910390fd5b61092a8282611b0b565b5050565b60cc546001600160a01b031681565b60385460ff1690565b6001600160a01b03808216600090815260cb60209081526040808320938616835260029093019052205492915050565b60ce5481565b6109846115ea565b6001600160a01b0316816001600160a01b0316146109d35760405162461bcd60e51b815260040180806020018281038252602f815260200180613746602f913960400191505060405180910390fd5b61092a8282611b74565b60006106766109ea6115ea565b8461085f85603460006109fb6115ea565b6001600160a01b03908116825260208083019390935260409182016000908120918c1681529252902054906116da565b6001600160a01b038216600090815260656020526040812081908190610a52908590611bdd565b9150915081610a6957610a6485610abc565b610a6b565b805b95945050505050565b610a8c60008051602061357e83398151915233610c1b565b610aa85760405162461bcd60e51b81526004016106a3906133cb565b60cd55565b6097546001600160a01b031681565b6001600160a01b031660009081526033602052604090205490565b60cd5481565b610ae633610abc565b610b025760405162461bcd60e51b81526004016106a390613431565b33600081815260d16020526040808220429055517ff52f50426b32362d3e6bb8cb36b7074756b224622def6352a59eac7f66ebe6e89190a2565b60d06020526000908152604090205481565b60408051600180825281830190925260009160609190816020015b610b71612ddd565b815260200190600190039081610b695790505090506040518060600160405280306001600160a01b03168152602001610ba985610abc565b8152602001610bb6610680565b81525081600081518110610bc657fe5b6020026020010181905250610868610bde8483611cda565b6001600160a01b038516600090815260d06020526040902054906116da565b60008281526098602052604081206108689083611dcb565b60ca5481565b60008281526098602052604081206108689083611dd7565b60cf546001600160a01b031681565b60378054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106465780601f1061061b57610100808354040283529160200191610646565b6000806000610cb3846066611bdd565b9150915081610cc957610cc4610680565b610ccb565b805b949350505050565b6000610ce933610ce233610abc565b6000611776565b905060006000198314610cfc5782610cfe565b815b9050610d3b816040518060400160405280600e81526020016d1253959053125117d05353d5539560921b81525084611a349092919063ffffffff16565b33600090815260d06020526040908190209190915560cf54905163a9059cbb60e01b81526001600160a01b039091169063a9059cbb90610d8190879085906004016132b8565b602060405180830381600087803b158015610d9b57600080fd5b505af1158015610daf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd39190613109565b610def5760405162461bcd60e51b81526004016106a390613365565b836001600160a01b0316336001600160a01b03167f9310ccfcb8de723f578a9e4282ea9f521f05ae40dc08f3068dfad528a65ee3c783604051610e3291906132dc565b60405180910390a350505050565b600081565b6000610676610e526115ea565b8461085f856040518060600160405280602581526020016137216025913960346000610e7c6115ea565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190611a34565b6000610676610eba6115ea565b8484611968565b601281565b80610ee35760405162461bcd60e51b81526004016106a390613338565b6000610eee83610abc565b90506000610f05843084610f00610680565b611dec565b90508015610f83577f2468f9268c60ad90e2d49edb0032c8a001e733ae888b3ab8e982edf535be1a768482604051610f3e9291906132b8565b60405180910390a16001600160a01b038416600090815260d06020526040902054610f6990826116da565b6001600160a01b038516600090815260d060205260409020555b610f9060008486856114d3565b6001600160a01b038516600090815260d16020526040902055610fb38484611eab565b60cc54610fcb906001600160a01b0316333086611f9d565b836001600160a01b0316336001600160a01b03167f5dac0c1b1112564a045ba943c9d50270893e8e826c49be8e7073adc713ab7bd785604051610e3291906132dc565b61102660008051602061357e83398151915233610c1b565b6110425760405162461bcd60e51b81526004016106a3906133cb565b60005b815181101561092a57600060cb600084848151811061106057fe5b6020026020010151604001516001600160a01b03166001600160a01b0316815260200190815260200160002090506110c783838151811061109d57fe5b602002602001015160400151828585815181106110b657fe5b602002602001015160200151611ff7565b508282815181106110d457fe5b60209081029190910101515181546fffffffffffffffffffffffffffffffff19166001600160801b03909116178155825183908390811061111157fe5b6020026020010151604001516001600160a01b03167f87fa03892a0556cb6b8f97e6d533a150d4d55fcbf275fff5fa003fa636bcc7fa84848151811061115357fe5b60200260200101516000015160405161116c9190613468565b60405180910390a250600101611045565b600054610100900460ff168061119657506111966120b4565b806111a4575060005460ff16155b6111df5760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff1615801561120a576000805460ff1961ff0019909116610100171660011790555b6112126120ba565b61121c42836116da565b60ca5561122a600033610920565b61124260008051602061357e83398151915284610920565b8015611254576000805461ff00191690555b505050565b60008051602061357e83398151915281565b600054610100900460ff168061128457506112846120b4565b80611292575060005460ff16155b6112cd5760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff161580156112f8576000805460ff1961ff0019909116610100171660011790555b61134f6040518060400160405280600c81526020016b0a6e8c2d6cac8408aa89092b60a31b815250604051806040016040528060088152602001670e6e8d68aa89092b60c31b81525060128a8c8b8b8b8b8b61215b565b8015611361576000805461ff00191690555b5050505050505050565b600054610100900460ff168061138457506113846120b4565b80611392575060005460ff16155b6113cd5760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff161580156113f8576000805460ff1961ff0019909116610100171660011790555b611400612270565b611242838361230d565b600081815260986020526040812061067a906123ac565b60008281526098602052604090206002015461143f906104616115ea565b6109d35760405162461bcd60e51b81526004018080602001828103825260308152602001806135e66030913960400191505060405180910390fd5b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b60cb60205260009081526040902080546001909101546001600160801b0380831692600160801b9004169083565b6001600160a01b038216600090815260d16020526040812054806114fb576000915050610ccb565b600061151e60ce5461151860cd544261173490919063ffffffff16565b90611734565b905081811115611531576000915061158b565b60008782116115405787611542565b425b90508281101561155757829350505050610ccb565b61158761156488876116da565b61158161157188876123b7565b61157b8b866123b7565b906116da565b90612410565b9250505b506001600160a01b038416600090815260d1602052604090208190559050949350505050565b6115c960008051602061357e83398151915233610c1b565b6115e55760405162461bcd60e51b81526004016106a3906133cb565b60ce55565b3390565b6001600160a01b0383166116335760405162461bcd60e51b81526004018080602001828103825260248152602001806136d36024913960400191505060405180910390fd5b6001600160a01b0382166116785760405162461bcd60e51b815260040180806020018281038252602281526020018061359e6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260346020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b600082820183811015610868576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600061086883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611a34565b600080611787853086610f00610680565b6001600160a01b038616600090815260d06020526040812054919250906117ae90836116da565b90508115610a6b5783156117d8576001600160a01b038616600090815260d0602052604090208190555b7f2468f9268c60ad90e2d49edb0032c8a001e733ae888b3ab8e982edf535be1a7686836040516118099291906132b8565b60405180910390a195945050505050565b6001600160a01b03821661185f5760405162461bcd60e51b815260040180806020018281038252602181526020018061368d6021913960400191505060405180910390fd5b61186b82600083612452565b6118a88160405180606001604052806022815260200161355c602291396001600160a01b0385166000908152603360205260409020549190611a34565b6001600160a01b0383166000908152603360205260409020556035546118ce9082611734565b6035556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526112549084906124aa565b600061197384610abc565b905061198184826001611776565b50826001600160a01b0316846001600160a01b031614611a235760006119a684610abc565b90506119b484826001611776565b506001600160a01b038516600090815260d160205260409020546119da818587856114d3565b6001600160a01b038616600090815260d160205260409020558284148015611a0157508015155b15611a20576001600160a01b038616600090815260d160205260408120555b50505b611a2e84848461255b565b50505050565b60008184841115611ac35760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611a88578181015183820152602001611a70565b50505050905090810190601f168015611ab55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60ca8190556040517f04719fa2f4e8205ff1369b5c7d2b3eb66c25570e7bf668ae7ccecb8fbd7ed52e90611b009083906132dc565b60405180910390a150565b6000828152609860205260409020611b2390826126b8565b1561092a57611b306115ea565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152609860205260409020611b8c90826126cd565b1561092a57611b996115ea565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b60008060008411611c2e576040805162461bcd60e51b815260206004820152601660248201527504552433230536e617073686f743a20696420697320360541b604482015290519081900360640190fd5b611c3860686126e2565b841115611c8c576040805162461bcd60e51b815260206004820152601d60248201527f4552433230536e617073686f743a206e6f6e6578697374656e74206964000000604482015290519081900360640190fd5b6000611c9884866126e6565b8454909150811415611cb1576000809250925050611cd3565b6001846001018281548110611cc257fe5b906000526020600020015492509250505b9250929050565b600080805b8351811015611dc357600060cb6000868481518110611cfa57fe5b602090810291909101810151516001600160a01b031682528101919091526040016000908120600181015481548851929450611d62926001600160801b0380831692600160801b900416908a9088908110611d5157fe5b602002602001015160400151612787565b9050611db7611db0878581518110611d7657fe5b602002602001015160200151838560020160008c6001600160a01b03166001600160a01b0316815260200190815260200160002054612826565b85906116da565b93505050600101611cdf565b509392505050565b60006108688383612848565b6000610868836001600160a01b0384166128ac565b6001600160a01b03808416600090815260cb602090815260408083209388168352600284019091528120549091908280611e27888588611ff7565b9050808314611e9f578615611e4457611e41878285612826565b91505b6001600160a01b03808a1660008181526002870160205260409081902084905551918a16917fbb123b5c06d5408bbea3c4fef481578175cfb432e3b482c6186f02ed9086585b90611e969085906132dc565b60405180910390a35b50979650505050505050565b6001600160a01b038216611f06576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b611f1260008383612452565b603554611f1f90826116da565b6035556001600160a01b038216600090815260336020526040902054611f4590826116da565b6001600160a01b03831660008181526033602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611a2e9085906124aa565b6001820154825460009190600160801b90046001600160801b03164281141561202257509050610868565b845460009061203d9084906001600160801b03168488612787565b905082811461209157808660010181905550866001600160a01b03167f5777ca300dfe5bead41006fbce4389794dbc0ed8d6cccebfaf94630aa04184bc8260405161208891906132dc565b60405180910390a25b85546001600160801b03428116600160801b029116178655925050509392505050565b303b1590565b600054610100900460ff16806120d357506120d36120b4565b806120e1575060005460ff16155b61211c5760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff16158015612147576000805460ff1961ff0019909116610100171660011790555b80156108c4576000805461ff001916905550565b600054610100900460ff168061217457506121746120b4565b80612182575060005460ff16155b6121bd5760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff161580156121e8576000805460ff1961ff0019909116610100171660011790555b6121f28b8b61136b565b6121fb896128c4565b612204886128da565b61221783836001600160801b031661117d565b60cc80546001600160a01b03808a166001600160a01b03199283161790925560cd88905560ce87905560cf8054928716929091169190911790558015612263576000805461ff00191690555b5050505050505050505050565b600054610100900460ff168061228957506122896120b4565b80612297575060005460ff16155b6122d25760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff161580156122fd576000805460ff1961ff0019909116610100171660011790555b6123056120ba565b6121476120ba565b600054610100900460ff168061232657506123266120b4565b80612334575060005460ff16155b61236f5760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff1615801561239a576000805460ff1961ff0019909116610100171660011790555b6123a26120ba565b61124283836128fc565b600061067a826126e2565b6000826123c65750600061067a565b828202828482816123d357fe5b04146108685760405162461bcd60e51b81526004018080602001828103825260218152602001806136446021913960400191505060405180910390fd5b600061086883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506129d4565b61245d838383611254565b6001600160a01b0383166124815761247482612a39565b61247c612a63565b611254565b6001600160a01b0382166124985761247483612a39565b6124a183612a39565b61125482612a39565b60606124ff826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a729092919063ffffffff16565b8051909150156112545780806020019051602081101561251e57600080fd5b50516112545760405162461bcd60e51b815260040180806020018281038252602a8152602001806136f7602a913960400191505060405180910390fd5b6001600160a01b0383166125a05760405162461bcd60e51b81526004018080602001828103825260258152602001806136ae6025913960400191505060405180910390fd5b6001600160a01b0382166125e55760405162461bcd60e51b815260040180806020018281038252602381526020018061350a6023913960400191505060405180910390fd5b6125f0838383612452565b61262d816040518060600160405280602681526020016135c0602691396001600160a01b0386166000908152603360205260409020549190611a34565b6001600160a01b03808516600090815260336020526040808220939093559084168152205461265c90826116da565b6001600160a01b0380841660008181526033602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000610868836001600160a01b038416612a81565b6000610868836001600160a01b038416612acb565b5490565b81546000906126f75750600061067a565b82546000905b808210156127465760006127118383612b91565b90508486828154811061272057fe5b9060005260206000200154111561273957809150612740565b8060010192505b506126fd565b60008211801561276e57508385600184038154811061276157fe5b9060005260206000200154145b1561277f575060001901905061067a565b50905061067a565b6000831580612794575081155b806127a7575042836001600160801b0316145b806127bd575060ca54836001600160801b031610155b156127c9575083610ccb565b600060ca5442116127da57426127de565b60ca545b905060006127f5826001600160801b038716611734565b905061281b8761157b86611581670de0b6b3a76400006128158c886123b7565b906123b7565b979650505050505050565b6000610ccb670de0b6b3a76400006115816128418686611734565b87906123b7565b8154600090821061288a5760405162461bcd60e51b81526004018080602001828103825260228152602001806134e86022913960400191505060405180910390fd5b82600001828154811061289957fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b6038805460ff191660ff92909216919091179055565b609780546001600160a01b0319166001600160a01b0392909216919091179055565b600054610100900460ff168061291557506129156120b4565b80612923575060005460ff16155b61295e5760405162461bcd60e51b815260040180806020018281038252602e815260200180613616602e913960400191505060405180910390fd5b600054610100900460ff16158015612989576000805460ff1961ff0019909116610100171660011790555b825161299c906036906020860190612e07565b5081516129b0906037906020850190612e07565b506038805460ff191660121790558015611254576000805461ff0019169055505050565b60008183612a235760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611a88578181015183820152602001611a70565b506000838581612a2f57fe5b0495945050505050565b6001600160a01b03811660009081526065602052604090206108c490612a5e83610abc565b612bb6565b612a706066612a5e610680565b565b6060610ccb8484600085612c02565b6000612a8d83836128ac565b612ac35750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561067a565b50600061067a565b60008181526001830160205260408120548015612b875783546000198083019190810190600090879083908110612afe57fe5b9060005260206000200154905080876000018481548110612b1b57fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080612b4b57fe5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505061067a565b600091505061067a565b60006002808306600285060181612ba457fe5b04600283046002850401019392505050565b6000612bc260686126e2565b905080612bce84612d6f565b1015611254578254600180820185556000858152602080822090930193909355938401805494850181558252902090910155565b6060612c0d85612da4565b612c5e576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310612c9d5780518252601f199092019160209182019101612c7e565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612cff576040519150601f19603f3d011682016040523d82523d6000602084013e612d04565b606091505b50915091508115612d18579150610ccb9050565b805115612d285780518082602001fd5b60405162461bcd60e51b8152602060048201818152865160248401528651879391928392604401919085019080838360008315611a88578181015183820152602001611a70565b8054600090612d8057506000610882565b815482906000198101908110612d9257fe5b90600052602060002001549050610882565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590610ccb575050151592915050565b604051806060016040528060006001600160a01b0316815260200160008152602001600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282612e3d5760008555612e83565b82601f10612e5657805160ff1916838001178555612e83565b82800160010185558215612e83579182015b82811115612e83578251825591602001919060010190612e68565b50612e8f929150612e93565b5090565b5b80821115612e8f5760008155600101612e94565b600082601f830112612eb8578081fd5b813567ffffffffffffffff811115612ecc57fe5b612edf601f8201601f19166020016134ae565b9150808252836020828501011115612ef657600080fd5b8060208401602084013760009082016020015292915050565b600060608284031215612f20578081fd5b6040516060810181811067ffffffffffffffff82111715612f3d57fe5b604052905080612f4c83612f73565b8152602083013560208201526040830135612f66816134d2565b6040919091015292915050565b80356001600160801b038116811461088257600080fd5b600060208284031215612f9b578081fd5b8135610868816134d2565b60008060408385031215612fb8578081fd5b8235612fc3816134d2565b946020939093013593505050565b60008060408385031215612fe3578182fd5b8235612fee816134d2565b91506020830135612ffe816134d2565b809150509250929050565b60008060006060848603121561301d578081fd5b8335613028816134d2565b92506020840135613038816134d2565b929592945050506040919091013590565b60008060408385031215612fb8578182fd5b6000602080838503121561306d578182fd5b823567ffffffffffffffff80821115613084578384fd5b818501915085601f830112613097578384fd5b8135818111156130a357fe5b6130b084858302016134ae565b81815284810192508385016060808402860187018a10156130cf578788fd5b8795505b838610156130fb576130e58a83612f0f565b85526001959095019493860193908101906130d3565b509098975050505050505050565b60006020828403121561311a578081fd5b81518015158114610868578182fd5b60006020828403121561313a578081fd5b5035919050565b60008060408385031215613153578182fd5b823591506020830135612ffe816134d2565b60008060408385031215613177578182fd5b50508035926020909101359150565b600080600080600080600060e0888a0312156131a0578283fd5b87356131ab816134d2565b965060208801356131bb816134d2565b9550604088013594506060880135935060808801356131d9816134d2565b925060a08801356131e9816134d2565b91506131f760c08901612f73565b905092959891949750929550565b60008060408385031215613217578182fd5b823567ffffffffffffffff8082111561322e578384fd5b61323a86838701612ea8565b9350602085013591508082111561324f578283fd5b5061325c85828601612ea8565b9150509250929050565b6000806000806080858703121561327b578182fd5b84359350602085013592506040850135613294816134d2565b9396929550929360600135925050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b90815260200190565b6000602080835283518082850152825b81811015613311578581018301518582016040015282016132f5565b818111156133225783604083870101525b50601f01601f1916929092016040019392505050565b6020808252601390820152721253959053125117d6915493d7d05353d55395606a1b604082015260600190565b60208082526019908201527f4552524f525f5452414e534645525f46524f4d5f5641554c5400000000000000604082015260600190565b60208082526015908201527424a729aaa32324a1a4a2a72a2fa1a7a7a62227aba760591b604082015260600190565b60208082526015908201527427a7262cafa2a6a4a9a9a4a7a72fa6a0a720a3a2a960591b604082015260600190565b60208082526017908201527f554e5354414b455f57494e444f575f46494e4953484544000000000000000000604082015260600190565b6020808252601b908201527f494e56414c49445f42414c414e43455f4f4e5f434f4f4c444f574e0000000000604082015260600190565b6001600160801b0391909116815260200190565b6001600160801b039384168152919092166020820152604081019190915260600190565b60ff91909116815260200190565b60405181810167ffffffffffffffff811182821017156134ca57fe5b604052919050565b6001600160a01b03811681146108c457600080fdfe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e647345524332303a207472616e7366657220746f20746865207a65726f2061646472657373416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e7445524332303a206275726e20616d6f756e7420657863656564732062616c616e63650178ef1edee9408b9148e43c7402964baa5d7066a35d0ff56e2596c8e1dc0f6745524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b65496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a26469706673582212202aba800e04981d687dcdf95b299602d4d6f7a65cebda64ec24a81e10a5a8326664736f6c63430007050033