ETH Price: $3,485.71 (+4.74%)

Contract

0x862EfD363a5577652500972BD983785b0637fF2F
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60806040122207872021-04-11 20:07:061323 days ago1618171626IN
 Create: StrongPoolV4
0 ETH0.2535988896

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
StrongPoolV4

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity Multiple files format)

File 1 of 20: StrongPoolV4.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

import "./IERC20.sol";
import "./SafeMath.sol";
import "./VoteInterface.sol";
import "./rewards.sol";

contract StrongPoolV4 {
  event MinedFor(address indexed miner, uint256 amount);
  event Mined(address indexed miner, uint256 amount);
  event MinedForVotesOnly(address indexed miner, uint256 amount);
  event UnminedForVotesOnly(address indexed miner, uint256 amount);
  event Unmined(address indexed miner, uint256 amount);
  event Claimed(address indexed miner, uint256 reward);

  using SafeMath for uint256;

  bool public initDone;
  address public admin;
  address public pendingAdmin;
  address public superAdmin;
  address public pendingSuperAdmin;
  address public parameterAdmin;
  address payable public feeCollector;

  IERC20 public strongToken;
  VoteInterface public vote;

  mapping(address => uint256) public minerBalance;
  uint256 public totalBalance;
  mapping(address => uint256) public minerBlockLastClaimedOn;

  mapping(address => uint256) public minerVotes;

  uint256 public rewardBalance;

  uint256 public rewardPerBlockNumerator;
  uint256 public rewardPerBlockDenominator;

  uint256 public miningFeeNumerator;
  uint256 public miningFeeDenominator;

  uint256 public unminingFeeNumerator;
  uint256 public unminingFeeDenominator;

  uint256 public claimingFeeNumerator;
  uint256 public claimingFeeDenominator;

  mapping(address => uint256) public inboundContractIndex;
  address[] public inboundContracts;
  mapping(address => bool) public inboundContractTrusted;

  uint256 public claimingFeeInWei;

  bool public removedTokens;

  uint256 public rewardPerBlockNumeratorNew;
  uint256 public rewardPerBlockDenominatorNew;
  uint256 public rewardPerBlockNewEffectiveBlock;

  function init(
    address voteAddress,
    address strongTokenAddress,
    address adminAddress,
    address superAdminAddress,
    uint256 rewardPerBlockNumeratorValue,
    uint256 rewardPerBlockDenominatorValue,
    uint256 miningFeeNumeratorValue,
    uint256 miningFeeDenominatorValue,
    uint256 unminingFeeNumeratorValue,
    uint256 unminingFeeDenominatorValue,
    uint256 claimingFeeNumeratorValue,
    uint256 claimingFeeDenominatorValue
  ) public {
    require(!initDone, "init done");
    vote = VoteInterface(voteAddress);
    strongToken = IERC20(strongTokenAddress);
    admin = adminAddress;
    superAdmin = superAdminAddress;
    rewardPerBlockNumerator = rewardPerBlockNumeratorValue;
    rewardPerBlockDenominator = rewardPerBlockDenominatorValue;
    miningFeeNumerator = miningFeeNumeratorValue;
    miningFeeDenominator = miningFeeDenominatorValue;
    unminingFeeNumerator = unminingFeeNumeratorValue;
    unminingFeeDenominator = unminingFeeDenominatorValue;
    claimingFeeNumerator = claimingFeeNumeratorValue;
    claimingFeeDenominator = claimingFeeDenominatorValue;
    initDone = true;
  }

  // ADMIN
  // *************************************************************************************
  function updateParameterAdmin(address newParameterAdmin) public {
    require(newParameterAdmin != address(0), "zero");
    require(msg.sender == superAdmin);
    parameterAdmin = newParameterAdmin;
  }

  function updateFeeCollector(address payable newFeeCollector) public {
    require(newFeeCollector != address(0), "zero");
    require(msg.sender == superAdmin);
    feeCollector = newFeeCollector;
  }

  function setPendingAdmin(address newPendingAdmin) public {
    require(newPendingAdmin != address(0), "zero");
    require(msg.sender == admin, "not admin");
    pendingAdmin = newPendingAdmin;
  }

  function acceptAdmin() public {
    require(msg.sender == pendingAdmin && msg.sender != address(0), "not pendingAdmin");
    admin = pendingAdmin;
    pendingAdmin = address(0);
  }

  function setPendingSuperAdmin(address newPendingSuperAdmin) public {
    require(newPendingSuperAdmin != address(0), "zero");
    require(msg.sender == superAdmin, "not superAdmin");
    pendingSuperAdmin = newPendingSuperAdmin;
  }

  function acceptSuperAdmin() public {
    require(msg.sender == pendingSuperAdmin && msg.sender != address(0), "not pendingSuperAdmin");
    superAdmin = pendingSuperAdmin;
    pendingSuperAdmin = address(0);
  }

  // INBOUND CONTRACTS
  // *************************************************************************************
  function addInboundContract(address contr) public {
    require(contr != address(0), "zero");
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin");
    if (inboundContracts.length != 0) {
      uint256 index = inboundContractIndex[contr];
      require(inboundContracts[index] != contr, "exists");
    }
    uint256 len = inboundContracts.length;
    inboundContractIndex[contr] = len;
    inboundContractTrusted[contr] = true;
    inboundContracts.push(contr);
  }

  function inboundContractTrustStatus(address contr, bool trustStatus) public {
    require(contr != address(0), "zero");
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin");
    uint256 index = inboundContractIndex[contr];
    require(inboundContracts[index] == contr, "not exists");
    inboundContractTrusted[contr] = trustStatus;
  }

  // REWARD
  // *************************************************************************************
  function updateRewardPerBlock(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin");
    require(denominator != 0, "invalid value");
    rewardPerBlockNumerator = numerator;
    rewardPerBlockDenominator = denominator;
  }

  function deposit(uint256 amount) public {
    require(msg.sender == superAdmin, "not an admin");
    require(amount > 0, "zero");
    strongToken.transferFrom(msg.sender, address(this), amount);
    rewardBalance = rewardBalance.add(amount);
  }

  function withdraw(address destination, uint256 amount) public {
    require(msg.sender == superAdmin, "not an admin");
    require(amount > 0, "zero");
    require(rewardBalance >= amount, "not enough");
    strongToken.transfer(destination, amount);
    rewardBalance = rewardBalance.sub(amount);
  }

  // FEES
  // *************************************************************************************
  function updateMiningFee(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin");
    require(denominator != 0, "invalid value");
    miningFeeNumerator = numerator;
    miningFeeDenominator = denominator;
  }

  function updateUnminingFee(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin");
    require(denominator != 0, "invalid value");
    unminingFeeNumerator = numerator;
    unminingFeeDenominator = denominator;
  }

  function updateClaimingFee(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin");
    require(denominator != 0, "invalid value");
    claimingFeeNumerator = numerator;
    claimingFeeDenominator = denominator;
  }

  // CORE
  // *************************************************************************************
  function mineForVotesOnly(uint256 amount) public {
    require(amount > 0, "zero");
    strongToken.transferFrom(msg.sender, address(this), amount);
    minerVotes[msg.sender] = minerVotes[msg.sender].add(amount);
    vote.updateVotes(msg.sender, amount, true);
    emit MinedForVotesOnly(msg.sender, amount);
  }

  function unmineForVotesOnly(uint256 amount) public {
    require(amount > 0, "zero");
    require(minerVotes[msg.sender] >= amount, "not enough");
    minerVotes[msg.sender] = minerVotes[msg.sender].sub(amount);
    vote.updateVotes(msg.sender, amount, false);
    strongToken.transfer(msg.sender, amount);
    emit UnminedForVotesOnly(msg.sender, amount);
  }

  function mineFor(address miner, uint256 amount) public {
    require(inboundContractTrusted[msg.sender], "not trusted");
    require(amount > 0, "zero");
    strongToken.transferFrom(msg.sender, address(this), amount);
    minerBalance[miner] = minerBalance[miner].add(amount);
    totalBalance = totalBalance.add(amount);
    if (minerBlockLastClaimedOn[miner] == 0) {
      minerBlockLastClaimedOn[miner] = block.number;
    }
    vote.updateVotes(miner, amount, true);
    emit MinedFor(miner, amount);
  }

  function mine(uint256 amount) public payable {
    require(amount > 0, "zero");
    uint256 fee = amount.mul(miningFeeNumerator).div(miningFeeDenominator);
    require(msg.value == fee, "invalid fee");
    feeCollector.transfer(msg.value);
    strongToken.transferFrom(msg.sender, address(this), amount);
    if (block.number > minerBlockLastClaimedOn[msg.sender]) {
      uint256 reward = getReward(msg.sender);
      if (reward > 0) {
        minerBalance[msg.sender] = minerBalance[msg.sender].add(reward);
        totalBalance = totalBalance.add(reward);
        rewardBalance = rewardBalance.sub(reward);
        vote.updateVotes(msg.sender, reward, true);
        minerBlockLastClaimedOn[msg.sender] = block.number;
      }
    }
    minerBalance[msg.sender] = minerBalance[msg.sender].add(amount);
    totalBalance = totalBalance.add(amount);
    if (minerBlockLastClaimedOn[msg.sender] == 0) {
      minerBlockLastClaimedOn[msg.sender] = block.number;
    }
    vote.updateVotes(msg.sender, amount, true);
    emit Mined(msg.sender, amount);
  }

  function unmine(uint256 amount) public payable {
    require(amount > 0, "zero");
    uint256 fee = amount.mul(unminingFeeNumerator).div(unminingFeeDenominator);
    require(msg.value == fee, "invalid fee");
    require(minerBalance[msg.sender] >= amount, "not enough");
    feeCollector.transfer(msg.value);
    bool unmineAll = (amount == minerBalance[msg.sender]);
    if (block.number > minerBlockLastClaimedOn[msg.sender]) {
      uint256 reward = getReward(msg.sender);
      if (reward > 0) {
        minerBalance[msg.sender] = minerBalance[msg.sender].add(reward);
        totalBalance = totalBalance.add(reward);
        rewardBalance = rewardBalance.sub(reward);
        vote.updateVotes(msg.sender, reward, true);
        minerBlockLastClaimedOn[msg.sender] = block.number;
      }
    }
    uint256 amountToUnmine = unmineAll ? minerBalance[msg.sender] : amount;
    minerBalance[msg.sender] = minerBalance[msg.sender].sub(amountToUnmine);
    totalBalance = totalBalance.sub(amountToUnmine);
    strongToken.transfer(msg.sender, amountToUnmine);
    vote.updateVotes(msg.sender, amountToUnmine, false);
    if (minerBalance[msg.sender] == 0) {
      minerBlockLastClaimedOn[msg.sender] = 0;
    }
    emit Unmined(msg.sender, amountToUnmine);
  }

  function claim(uint256 blockNumber) public payable {
    require(blockNumber <= block.number, "invalid block number");
    require(minerBlockLastClaimedOn[msg.sender] != 0, "error");
    require(blockNumber > minerBlockLastClaimedOn[msg.sender], "too soon");
    uint256 reward = getRewardByBlock(msg.sender, blockNumber);
    require(reward > 0, "no reward");
    uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);
    require(msg.value == fee, "invalid fee");
    feeCollector.transfer(msg.value);
    minerBalance[msg.sender] = minerBalance[msg.sender].add(reward);
    totalBalance = totalBalance.add(reward);
    rewardBalance = rewardBalance.sub(reward);
    minerBlockLastClaimedOn[msg.sender] = blockNumber;
    vote.updateVotes(msg.sender, reward, true);
    emit Claimed(msg.sender, reward);
  }

  function getReward(address miner) public view returns (uint256) {
    return getRewardByBlock(miner, block.number);
  }

  function getRewardByBlock(address miner, uint256 blockNumber) public view returns (uint256) {
    uint256 blockLastClaimedOn = minerBlockLastClaimedOn[miner];

    if (blockNumber > block.number) return 0;
    if (blockLastClaimedOn == 0) return 0;
    if (blockNumber < blockLastClaimedOn) return 0;
    if (totalBalance == 0) return 0;

    uint256[2] memory rewardBlocks = rewards.blocks(blockLastClaimedOn, rewardPerBlockNewEffectiveBlock, blockNumber);
    uint256 rewardOld = rewardPerBlockDenominator > 0 ? rewardBlocks[0].mul(rewardPerBlockNumerator).div(rewardPerBlockDenominator) : 0;
    uint256 rewardNew = rewardPerBlockDenominatorNew > 0 ? rewardBlocks[1].mul(rewardPerBlockNumeratorNew).div(rewardPerBlockDenominatorNew) : 0;

    return rewardOld.add(rewardNew).mul(minerBalance[miner]).div(totalBalance);
  }

  function updateRewardPerBlockNew(
    uint256 numerator,
    uint256 denominator,
    uint256 effectiveBlock
  ) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");

    rewardPerBlockNumeratorNew = numerator;
    rewardPerBlockDenominatorNew = denominator;
    rewardPerBlockNewEffectiveBlock = effectiveBlock != 0 ? effectiveBlock : block.number;
  }
}

File 2 of 20: Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

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

File 3 of 20: Counters.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "./SafeMath.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 Counters {
    using SafeMath 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);
    }
}

File 4 of 20: IERC1155Preset.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155Preset {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values);

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external;

    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);

    /**
     * @dev Creates `amount` new tokens for `to`, of token type `id`.
     *
     * See {ERC1155-_mint}.
     *
     * Requirements:
     *
     * - the caller must have the `MINTER_ROLE`.
     */
    function mint(address to, uint256 id, uint256 amount, bytes memory data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] variant of {mint}.
     */
    function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) external;

    function getOwnerIdByIndex(address owner, uint256 index) external view returns (uint256);

    function getOwnerIdIndex(address owner, uint256 id) external view returns (uint256);
}

File 5 of 20: IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 6 of 20: PoolV4.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

import "./IERC20.sol";
import "./SafeMath.sol";
import "./StrongPoolInterface.sol";
import "./rewards.sol";

contract PoolV4 {
  event Mined(address indexed miner, uint256 amount);
  event Unmined(address indexed miner, uint256 amount);
  event Claimed(address indexed miner, uint256 reward);

  using SafeMath for uint256;

  bool public initDone;
  address public admin;
  address public pendingAdmin;
  address public superAdmin;
  address public pendingSuperAdmin;
  address public parameterAdmin;
  address payable public feeCollector;

  IERC20 public token;
  IERC20 public strongToken;
  StrongPoolInterface public strongPool;

  mapping(address => uint256) public minerBalance;
  uint256 public totalBalance;
  mapping(address => uint256) public minerBlockLastClaimedOn;

  uint256 public rewardBalance;

  uint256 public rewardPerBlockNumerator;
  uint256 public rewardPerBlockDenominator;

  uint256 public miningFeeNumerator;
  uint256 public miningFeeDenominator;

  uint256 public unminingFeeNumerator;
  uint256 public unminingFeeDenominator;

  uint256 public claimingFeeNumerator;
  uint256 public claimingFeeDenominator;

  uint256 public claimingFeeInWei;

  uint256 public rewardPerBlockNumeratorNew;
  uint256 public rewardPerBlockDenominatorNew;
  uint256 public rewardPerBlockNewEffectiveBlock;

  function init(
    address strongTokenAddress,
    address tokenAddress,
    address strongPoolAddress,
    address adminAddress,
    address superAdminAddress,
    uint256 rewardPerBlockNumeratorValue,
    uint256 rewardPerBlockDenominatorValue,
    uint256 miningFeeNumeratorValue,
    uint256 miningFeeDenominatorValue,
    uint256 unminingFeeNumeratorValue,
    uint256 unminingFeeDenominatorValue,
    uint256 claimingFeeNumeratorValue,
    uint256 claimingFeeDenominatorValue
  ) public {
    require(!initDone, "init done");
    strongToken = IERC20(strongTokenAddress);
    token = IERC20(tokenAddress);
    strongPool = StrongPoolInterface(strongPoolAddress);
    admin = adminAddress;
    superAdmin = superAdminAddress;
    rewardPerBlockNumerator = rewardPerBlockNumeratorValue;
    rewardPerBlockDenominator = rewardPerBlockDenominatorValue;
    miningFeeNumerator = miningFeeNumeratorValue;
    miningFeeDenominator = miningFeeDenominatorValue;
    unminingFeeNumerator = unminingFeeNumeratorValue;
    unminingFeeDenominator = unminingFeeDenominatorValue;
    claimingFeeNumerator = claimingFeeNumeratorValue;
    claimingFeeDenominator = claimingFeeDenominatorValue;
    initDone = true;
  }

  // ADMIN
  // *************************************************************************************
  function updateParameterAdmin(address newParameterAdmin) public {
    require(newParameterAdmin != address(0), "zero");
    require(msg.sender == superAdmin);
    parameterAdmin = newParameterAdmin;
  }

  function setPendingAdmin(address newPendingAdmin) public {
    require(newPendingAdmin != address(0), "zero");
    require(msg.sender == admin, "not admin");
    pendingAdmin = newPendingAdmin;
  }

  function acceptAdmin() public {
    require(msg.sender == pendingAdmin && msg.sender != address(0), "not pendingAdmin");
    admin = pendingAdmin;
    pendingAdmin = address(0);
  }

  function setPendingSuperAdmin(address newPendingSuperAdmin) public {
    require(newPendingSuperAdmin != address(0), "zero");
    require(msg.sender == superAdmin, "not superAdmin");
    pendingSuperAdmin = newPendingSuperAdmin;
  }

  function acceptSuperAdmin() public {
    require(msg.sender == pendingSuperAdmin && msg.sender != address(0), "not pendingSuperAdmin");
    superAdmin = pendingSuperAdmin;
    pendingSuperAdmin = address(0);
  }

  // REWARD
  // *************************************************************************************
  function updateRewardPerBlock(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin");
    require(denominator != 0, "invalid value");
    rewardPerBlockNumerator = numerator;
    rewardPerBlockDenominator = denominator;
  }

  function deposit(uint256 amount) public {
    require(msg.sender == superAdmin, "not an admin");
    require(amount > 0, "zero");
    strongToken.transferFrom(msg.sender, address(this), amount);
    rewardBalance = rewardBalance.add(amount);
  }

  function withdraw(address destination, uint256 amount) public {
    require(msg.sender == superAdmin, "not an admin");
    require(amount > 0, "zero");
    require(rewardBalance >= amount, "not enough");
    strongToken.transfer(destination, amount);
    rewardBalance = rewardBalance.sub(amount);
  }

  // FEES
  // *************************************************************************************
  function updateFeeCollector(address payable newFeeCollector) public {
    require(newFeeCollector != address(0), "zero");
    require(msg.sender == superAdmin);
    feeCollector = newFeeCollector;
  }

  function updateMiningFee(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin");
    require(denominator != 0, "invalid value");
    miningFeeNumerator = numerator;
    miningFeeDenominator = denominator;
  }

  function updateUnminingFee(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin");
    require(denominator != 0, "invalid value");
    unminingFeeNumerator = numerator;
    unminingFeeDenominator = denominator;
  }

  function updateClaimingFee(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin");
    require(denominator != 0, "invalid value");
    claimingFeeNumerator = numerator;
    claimingFeeDenominator = denominator;
  }

  // CORE
  // *************************************************************************************
  function mine(uint256 amount) public payable {
    require(amount > 0, "zero");
    uint256 fee = amount.mul(miningFeeNumerator).div(miningFeeDenominator);
    require(msg.value == fee, "invalid fee");
    feeCollector.transfer(msg.value);
    if (block.number > minerBlockLastClaimedOn[msg.sender]) {
      uint256 reward = getReward(msg.sender);
      if (reward > 0) {
        rewardBalance = rewardBalance.sub(reward);
        strongToken.approve(address(strongPool), reward);
        strongPool.mineFor(msg.sender, reward);
        minerBlockLastClaimedOn[msg.sender] = block.number;
      }
    }
    token.transferFrom(msg.sender, address(this), amount);
    minerBalance[msg.sender] = minerBalance[msg.sender].add(amount);
    totalBalance = totalBalance.add(amount);
    if (minerBlockLastClaimedOn[msg.sender] == 0) {
      minerBlockLastClaimedOn[msg.sender] = block.number;
    }
    emit Mined(msg.sender, amount);
  }

  function unmine(uint256 amount) public payable {
    require(amount > 0, "zero");
    uint256 fee = amount.mul(unminingFeeNumerator).div(unminingFeeDenominator);
    require(msg.value == fee, "invalid fee");
    require(minerBalance[msg.sender] >= amount, "not enough");
    feeCollector.transfer(msg.value);
    if (block.number > minerBlockLastClaimedOn[msg.sender]) {
      uint256 reward = getReward(msg.sender);
      if (reward > 0) {
        rewardBalance = rewardBalance.sub(reward);
        strongToken.approve(address(strongPool), reward);
        strongPool.mineFor(msg.sender, reward);
        minerBlockLastClaimedOn[msg.sender] = block.number;
      }
    }
    minerBalance[msg.sender] = minerBalance[msg.sender].sub(amount);
    totalBalance = totalBalance.sub(amount);
    token.transfer(msg.sender, amount);
    if (minerBalance[msg.sender] == 0) {
      minerBlockLastClaimedOn[msg.sender] = 0;
    }
    emit Unmined(msg.sender, amount);
  }

  function claim(uint256 blockNumber) public payable {
    require(blockNumber <= block.number, "invalid block number");
    require(minerBlockLastClaimedOn[msg.sender] != 0, "error");
    require(blockNumber > minerBlockLastClaimedOn[msg.sender], "too soon");
    uint256 reward = getRewardByBlock(msg.sender, blockNumber);
    require(reward > 0, "no reward");
    uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);
    require(msg.value == fee, "invalid fee");
    feeCollector.transfer(msg.value);
    strongToken.approve(address(strongPool), reward);
    strongPool.mineFor(msg.sender, reward);
    rewardBalance = rewardBalance.sub(reward);
    minerBlockLastClaimedOn[msg.sender] = blockNumber;
    emit Claimed(msg.sender, reward);
  }

  function getReward(address miner) public view returns (uint256) {
    return getRewardByBlock(miner, block.number);
  }

  function getRewardByBlock(address miner, uint256 blockNumber) public view returns (uint256) {
    uint256 blockLastClaimedOn = minerBlockLastClaimedOn[miner];

    if (blockNumber > block.number) return 0;
    if (blockLastClaimedOn == 0) return 0;
    if (blockNumber < blockLastClaimedOn) return 0;
    if (totalBalance == 0) return 0;

    uint256[2] memory rewardBlocks = rewards.blocks(blockLastClaimedOn, rewardPerBlockNewEffectiveBlock, blockNumber);
    uint256 rewardOld = rewardPerBlockDenominator > 0 ? rewardBlocks[0].mul(rewardPerBlockNumerator).div(rewardPerBlockDenominator) : 0;
    uint256 rewardNew = rewardPerBlockDenominatorNew > 0 ? rewardBlocks[1].mul(rewardPerBlockNumeratorNew).div(rewardPerBlockDenominatorNew) : 0;

    return rewardOld.add(rewardNew).mul(minerBalance[miner]).div(totalBalance);
  }

  function updateRewardPerBlockNew(
    uint256 numerator,
    uint256 denominator,
    uint256 effectiveBlock
  ) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");

    rewardPerBlockNumeratorNew = numerator;
    rewardPerBlockDenominatorNew = denominator;
    rewardPerBlockNewEffectiveBlock = effectiveBlock != 0 ? effectiveBlock : block.number;
  }
}

File 7 of 20: rewards.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

import "./SafeMath.sol";

library rewards {

    using SafeMath for uint256;

    function blocks(uint256 lastClaimedOnBlock, uint256 newRewardBlock, uint256 blockNumber) internal pure returns (uint256[2] memory) {
        if (lastClaimedOnBlock >= blockNumber) return [uint256(0), uint256(0)];

        if (blockNumber <= newRewardBlock || newRewardBlock == 0) {
            return [blockNumber.sub(lastClaimedOnBlock), uint256(0)];
        }
        else if (lastClaimedOnBlock >= newRewardBlock) {
            return [uint256(0), blockNumber.sub(lastClaimedOnBlock)];
        }
        else {
            return [newRewardBlock.sub(lastClaimedOnBlock), blockNumber.sub(newRewardBlock)];
        }
    }

}

File 8 of 20: SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

        return c;
    }

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

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

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

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

        return c;
    }

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

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

        return c;
    }

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

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

File 9 of 20: ServiceInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

interface ServiceInterface {
  function claimingFeeNumerator() external view returns(uint256);

  function claimingFeeDenominator() external view returns(uint256);

  function doesNodeExist(address entity, uint128 nodeId) external view returns (bool);

  function getNodeId(address entity, uint128 nodeId) external view returns (bytes memory);

  function getReward(address entity, uint128 nodeId) external view returns (uint256);

  function getRewardByBlock(address entity, uint128 nodeId, uint256 blockNumber) external view returns (uint256);

  function getTraunch(address entity) external view returns (uint256);

  function isEntityActive(address entity) external view returns (bool);

  function claim(uint128 nodeId, uint256 blockNumber, bool toStrongPool) external payable;
}

File 10 of 20: ServiceInterfaceV10.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

interface ServiceInterfaceV10 {
  function traunch(address) external view returns(uint256);

  function claimingFeeNumerator() external view returns(uint256);

  function claimingFeeDenominator() external view returns(uint256);

  function doesNodeExist(address entity, uint128 nodeId) external view returns (bool);

  function getNodeId(address entity, uint128 nodeId) external view returns (bytes memory);

  function getReward(address entity, uint128 nodeId) external view returns (uint256);

  function getRewardByBlock(address entity, uint128 nodeId, uint256 blockNumber) external view returns (uint256);

  function isEntityActive(address entity) external view returns (bool);

  function claim(uint128 nodeId, uint256 blockNumber, bool toStrongPool) external payable;
}

File 11 of 20: ServiceV10.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

import "./IERC20.sol";
import "./SafeMath.sol";
import "./StrongPoolInterface.sol";
import "./IERC1155Preset.sol";
import "./StrongNFTBonusInterface.sol";
import "./rewards.sol";

contract ServiceV10 {
  event Requested(address indexed miner);
  event Claimed(address indexed miner, uint256 reward);

  using SafeMath for uint256;
  bool public initDone;
  address public admin;
  address public pendingAdmin;
  address public superAdmin;
  address public pendingSuperAdmin;
  address public serviceAdmin;
  address public parameterAdmin;
  address payable public feeCollector;

  IERC20 public strongToken;
  StrongPoolInterface public strongPool;

  uint256 public rewardPerBlockNumerator;
  uint256 public rewardPerBlockDenominator;

  uint256 public naasRewardPerBlockNumerator;
  uint256 public naasRewardPerBlockDenominator;

  uint256 public claimingFeeNumerator;
  uint256 public claimingFeeDenominator;

  uint256 public requestingFeeInWei;

  uint256 public strongFeeInWei;

  uint256 public recurringFeeInWei;
  uint256 public recurringNaaSFeeInWei;
  uint256 public recurringPaymentCycleInBlocks;

  uint256 public rewardBalance;

  mapping(address => uint256) public entityBlockLastClaimedOn;

  address[] public entities;
  mapping(address => uint256) public entityIndex;
  mapping(address => bool) public entityActive;
  mapping(address => bool) public requestPending;
  mapping(address => bool) public entityIsNaaS;
  mapping(address => uint256) public paidOnBlock;
  uint256 public activeEntities;

  string public desciption;

  uint256 public claimingFeeInWei;

  uint256 public naasRequestingFeeInWei;

  uint256 public naasStrongFeeInWei;

  bool public removedTokens;

  mapping(address => uint256) public traunch;

  uint256 public currentTraunch;

  mapping(bytes => bool) public entityNodeIsActive;
  mapping(bytes => bool) public entityNodeIsBYON;
  mapping(bytes => uint256) public entityNodeTraunch;
  mapping(bytes => uint256) public entityNodePaidOnBlock;
  mapping(bytes => uint256) public entityNodeClaimedOnBlock;
  mapping(address => uint128) public entityNodeCount;

  event Paid(address indexed entity, uint128 nodeId, bool isBYON, bool isRenewal, uint256 upToBlockNumber);
  event Migrated(address indexed from, address indexed to, uint128 fromNodeId, uint128 toNodeId, bool isBYON);

  uint256 public rewardPerBlockNumeratorNew;
  uint256 public rewardPerBlockDenominatorNew;
  uint256 public naasRewardPerBlockNumeratorNew;
  uint256 public naasRewardPerBlockDenominatorNew;
  uint256 public rewardPerBlockNewEffectiveBlock;

  StrongNFTBonusInterface public strongNFTBonus;

  function init(
    address strongTokenAddress,
    address strongPoolAddress,
    address adminAddress,
    address superAdminAddress,
    uint256 rewardPerBlockNumeratorValue,
    uint256 rewardPerBlockDenominatorValue,
    uint256 naasRewardPerBlockNumeratorValue,
    uint256 naasRewardPerBlockDenominatorValue,
    uint256 requestingFeeInWeiValue,
    uint256 strongFeeInWeiValue,
    uint256 recurringFeeInWeiValue,
    uint256 recurringNaaSFeeInWeiValue,
    uint256 recurringPaymentCycleInBlocksValue,
    uint256 claimingFeeNumeratorValue,
    uint256 claimingFeeDenominatorValue,
    string memory desc
  ) public {
    require(!initDone, "init done");
    strongToken = IERC20(strongTokenAddress);
    strongPool = StrongPoolInterface(strongPoolAddress);
    admin = adminAddress;
    superAdmin = superAdminAddress;
    rewardPerBlockNumerator = rewardPerBlockNumeratorValue;
    rewardPerBlockDenominator = rewardPerBlockDenominatorValue;
    naasRewardPerBlockNumerator = naasRewardPerBlockNumeratorValue;
    naasRewardPerBlockDenominator = naasRewardPerBlockDenominatorValue;
    requestingFeeInWei = requestingFeeInWeiValue;
    strongFeeInWei = strongFeeInWeiValue;
    recurringFeeInWei = recurringFeeInWeiValue;
    recurringNaaSFeeInWei = recurringNaaSFeeInWeiValue;
    claimingFeeNumerator = claimingFeeNumeratorValue;
    claimingFeeDenominator = claimingFeeDenominatorValue;
    recurringPaymentCycleInBlocks = recurringPaymentCycleInBlocksValue;
    desciption = desc;
    initDone = true;
  }

  // ADMIN
  // *************************************************************************************

  function updateServiceAdmin(address newServiceAdmin) public {
    require(msg.sender == superAdmin);
    serviceAdmin = newServiceAdmin;
  }

  function updateParameterAdmin(address newParameterAdmin) public {
    require(newParameterAdmin != address(0), "zero");
    require(msg.sender == superAdmin);
    parameterAdmin = newParameterAdmin;
  }

  function updateFeeCollector(address payable newFeeCollector) public {
    require(newFeeCollector != address(0), "zero");
    require(msg.sender == superAdmin);
    feeCollector = newFeeCollector;
  }

  function setPendingAdmin(address newPendingAdmin) public {
    require(msg.sender == admin, "not admin");
    pendingAdmin = newPendingAdmin;
  }

  function acceptAdmin() public {
    require(msg.sender == pendingAdmin && msg.sender != address(0), "not pendingAdmin");
    admin = pendingAdmin;
    pendingAdmin = address(0);
  }

  function setPendingSuperAdmin(address newPendingSuperAdmin) public {
    require(msg.sender == superAdmin, "not superAdmin");
    pendingSuperAdmin = newPendingSuperAdmin;
  }

  function acceptSuperAdmin() public {
    require(msg.sender == pendingSuperAdmin && msg.sender != address(0), "not pendingSuperAdmin");
    superAdmin = pendingSuperAdmin;
    pendingSuperAdmin = address(0);
  }

  // ENTITIES
  // *************************************************************************************

  function getEntities() public view returns (address[] memory) {
    return entities;
  }

  function isEntityActive(address entity) public view returns (bool) {
    return entityActive[entity];
  }

  // TRAUNCH
  // *************************************************************************************

  function updateCurrentTraunch(uint256 value) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    currentTraunch = value;
  }

  // REWARD
  // *************************************************************************************

  function updateRewardPerBlock(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    require(denominator != 0, "invalid value");
    rewardPerBlockNumerator = numerator;
    rewardPerBlockDenominator = denominator;
  }

  function updateNaaSRewardPerBlock(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    require(denominator != 0, "invalid value");
    naasRewardPerBlockNumerator = numerator;
    naasRewardPerBlockDenominator = denominator;
  }

  function updateRewardPerBlockNew(
    uint256 numerator,
    uint256 denominator,
    uint256 numeratorNass,
    uint256 denominatorNass,
    uint256 effectiveBlock
  ) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");

    rewardPerBlockNumeratorNew = numerator;
    rewardPerBlockDenominatorNew = denominator;
    naasRewardPerBlockNumeratorNew = numeratorNass;
    naasRewardPerBlockDenominatorNew = denominatorNass;
    rewardPerBlockNewEffectiveBlock = effectiveBlock != 0 ? effectiveBlock : block.number;
  }

  function deposit(uint256 amount) public {
    require(msg.sender == superAdmin, "not admin");
    require(amount > 0, "zero");
    strongToken.transferFrom(msg.sender, address(this), amount);
    rewardBalance = rewardBalance.add(amount);
  }

  function withdraw(address destination, uint256 amount) public {
    require(msg.sender == superAdmin, "not admin");
    require(amount > 0, "zero");
    require(rewardBalance >= amount, "not enough");
    strongToken.transfer(destination, amount);
    rewardBalance = rewardBalance.sub(amount);
  }

  // FEES
  // *************************************************************************************

  function updateRequestingFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    requestingFeeInWei = feeInWei;
  }

  function updateStrongFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    strongFeeInWei = feeInWei;
  }

  function updateNaasRequestingFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    naasRequestingFeeInWei = feeInWei;
  }

  function updateNaasStrongFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    naasStrongFeeInWei = feeInWei;
  }

  function updateClaimingFee(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    require(denominator != 0, "invalid value");
    claimingFeeNumerator = numerator;
    claimingFeeDenominator = denominator;
  }

  function updateRecurringFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    recurringFeeInWei = feeInWei;
  }

  function updateRecurringNaaSFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    recurringNaaSFeeInWei = feeInWei;
  }

  function updateRecurringPaymentCycleInBlocks(uint256 blocks) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    require(blocks > 0, "zero");
    recurringPaymentCycleInBlocks = blocks;
  }

  // CORE
  // *************************************************************************************

  function requestAccess(bool isNaaS) public payable {
    uint256 rFee;
    uint256 sFee;

    if (hasLegacyNode(msg.sender)) {
      migrateLegacyNode(msg.sender);
    }

    uint128 nodeId = entityNodeCount[msg.sender] + 1;
    bytes memory id = getNodeId(msg.sender, nodeId);

    if (isNaaS) {
      rFee = naasRequestingFeeInWei;
      sFee = naasStrongFeeInWei;
      activeEntities = activeEntities.add(1);
    } else {
      rFee = requestingFeeInWei;
      sFee = strongFeeInWei;
      entityNodeIsBYON[id] = true;
    }

    require(msg.value == rFee, "invalid fee");

    entityNodePaidOnBlock[id] = block.number;
    entityNodeTraunch[id] = currentTraunch;
    entityNodeClaimedOnBlock[id] = block.number;
    entityNodeCount[msg.sender] = entityNodeCount[msg.sender] + 1;

    feeCollector.transfer(msg.value);
    strongToken.transferFrom(msg.sender, address(this), sFee);
    strongToken.transfer(feeCollector, sFee);

    emit Paid(msg.sender, nodeId, entityNodeIsBYON[id], false, entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks));
  }

  function setEntityActiveStatus(address entity, bool status) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, "not admin");
    uint256 index = entityIndex[entity];
    require(entities[index] == entity, "invalid entity");
    require(entityActive[entity] != status, "already set");
    entityActive[entity] = status;
    if (status) {
      activeEntities = activeEntities.add(1);
      entityBlockLastClaimedOn[entity] = block.number;
    } else {
      activeEntities = activeEntities.sub(1);
      entityBlockLastClaimedOn[entity] = 0;
    }
  }

  function payFee(uint128 nodeId) public payable {
    address sender = msg.sender == address(this) ? tx.origin : msg.sender;
    bytes memory id = getNodeId(sender, nodeId);
    uint256 blockLastPaidOn = entityNodePaidOnBlock[id];

    if (hasLegacyNode(sender)) {
      migrateLegacyNode(sender);
    }

    bool isExpired = block.number > blockLastPaidOn.add(recurringPaymentCycleInBlocks).add(recurringPaymentCycleInBlocks);

    require(doesNodeExist(sender, nodeId), "doesnt exist");
    require(isExpired == false || msg.sender == address(this), "too late");

    if (isExpired) {
      return;
    }

    if (entityNodeIsBYON[id]) {
      require(msg.value == recurringFeeInWei, "invalid fee");
    } else {
      require(msg.value == recurringNaaSFeeInWei, "invalid fee");
    }

    feeCollector.transfer(msg.value);
    entityNodePaidOnBlock[id] = entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks);

    emit Paid(sender, nodeId, entityNodeIsBYON[id], true, entityNodePaidOnBlock[id]);
  }

  function getReward(address entity, uint128 nodeId) public view returns (uint256) {
    return getRewardByBlock(entity, nodeId, block.number);
  }

  function getRewardByBlock(address entity, uint128 nodeId, uint256 blockNumber) public view returns (uint256) {
    bytes memory id = getNodeId(entity, nodeId);

    if (hasLegacyNode(entity)) {
      return getRewardByBlockLegacy(entity, blockNumber);
    }

    uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];

    if (blockNumber > block.number) return 0;
    if (blockLastClaimedOn == 0) return 0;
    if (blockNumber < blockLastClaimedOn) return 0;
    if (activeEntities == 0) return 0;
    if (entityNodeIsBYON[id] && !entityNodeIsActive[id]) return 0;

    uint256 rewardNumerator = entityNodeIsBYON[id] ? rewardPerBlockNumerator : naasRewardPerBlockNumerator;
    uint256 rewardDenominator = entityNodeIsBYON[id] ? rewardPerBlockDenominator : naasRewardPerBlockDenominator;
    uint256 newRewardNumerator = entityNodeIsBYON[id] ? rewardPerBlockNumeratorNew : naasRewardPerBlockNumeratorNew;
    uint256 newRewardDenominator = entityNodeIsBYON[id] ? rewardPerBlockDenominatorNew : naasRewardPerBlockDenominatorNew;

    uint256 bonus = address(strongNFTBonus) != address(0)
    ? strongNFTBonus.getBonus(entity, nodeId, blockLastClaimedOn, blockNumber)
    : 0;

    uint256[2] memory rewardBlocks = rewards.blocks(blockLastClaimedOn, rewardPerBlockNewEffectiveBlock, blockNumber);
    uint256 rewardOld = rewardDenominator > 0 ? rewardBlocks[0].mul(rewardNumerator).div(rewardDenominator) : 0;
    uint256 rewardNew = newRewardDenominator > 0 ? rewardBlocks[1].mul(newRewardNumerator).div(newRewardDenominator) : 0;

    return rewardOld.add(rewardNew).add(bonus);
  }

  function getRewardByBlockLegacy(address entity, uint256 blockNumber) public view returns (uint256) {
    if (blockNumber > block.number) return 0;
    if (entityBlockLastClaimedOn[entity] == 0) return 0;
    if (blockNumber < entityBlockLastClaimedOn[entity]) return 0;
    if (activeEntities == 0) return 0;
    uint256 blockResult = blockNumber.sub(entityBlockLastClaimedOn[entity]);
    uint256 rewardNumerator;
    uint256 rewardDenominator;
    if (entityIsNaaS[entity]) {
      rewardNumerator = naasRewardPerBlockNumerator;
      rewardDenominator = naasRewardPerBlockDenominator;
    } else {
      rewardNumerator = rewardPerBlockNumerator;
      rewardDenominator = rewardPerBlockDenominator;
    }
    uint256 rewardPerBlockResult = blockResult.mul(rewardNumerator).div(rewardDenominator);

    return rewardPerBlockResult;
  }

  function claim(uint128 nodeId, uint256 blockNumber, bool toStrongPool) public payable {
    address sender = msg.sender == address(this) || msg.sender == address(strongNFTBonus) ? tx.origin : msg.sender;
    bytes memory id = getNodeId(sender, nodeId);

    if (hasLegacyNode(sender)) {
      migrateLegacyNode(sender);
    }

    uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];
    uint256 blockLastPaidOn = entityNodePaidOnBlock[id];

    require(blockLastClaimedOn != 0, "never claimed");
    require(blockNumber <= block.number, "invalid block");
    require(blockNumber > blockLastClaimedOn, "too soon");
    require(!entityNodeIsBYON[id] || entityNodeIsActive[id], "not active");

    if (
      (!entityNodeIsBYON[id] && recurringNaaSFeeInWei != 0) || (entityNodeIsBYON[id] && recurringFeeInWei != 0)
    ) {
      require(blockNumber < blockLastPaidOn.add(recurringPaymentCycleInBlocks), "pay fee");
    }

    uint256 reward = getRewardByBlock(sender, nodeId, blockNumber);
    require(reward > 0, "no reward");

    uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);
    require(msg.value >= fee, "invalid fee");

    feeCollector.transfer(msg.value);

    if (toStrongPool) {
      strongToken.approve(address(strongPool), reward);
      strongPool.mineFor(sender, reward);
    } else {
      strongToken.transfer(sender, reward);
    }

    rewardBalance = rewardBalance.sub(reward);
    entityNodeClaimedOnBlock[id] = blockNumber;
    emit Claimed(sender, reward);
  }

  function getRewardAll(address entity, uint256 blockNumber) public view returns (uint256) {
    uint256 rewardsAll = 0;

    for (uint128 i = 1; i <= entityNodeCount[entity]; i++) {
      rewardsAll = rewardsAll.add(getRewardByBlock(entity, i, blockNumber > 0 ? blockNumber : block.number));
    }

    return rewardsAll;
  }

  function doesNodeExist(address entity, uint128 nodeId) public view returns (bool) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodePaidOnBlock[id] > 0;
  }

  function getNodeId(address entity, uint128 nodeId) public view returns (bytes memory) {
    uint128 id = nodeId != 0 ? nodeId : entityNodeCount[entity] + 1;
    return abi.encodePacked(entity, id);
  }

  function getNodePaidOn(address entity, uint128 nodeId) public view returns (uint256) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodePaidOnBlock[id];
  }

  function getNodeFee(address entity, uint128 nodeId) public view returns (uint256) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodeIsBYON[id] ? recurringFeeInWei : recurringNaaSFeeInWei;
  }

  function isNodeActive(address entity, uint128 nodeId) public view returns (bool) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodeIsActive[id] || !entityNodeIsBYON[id];
  }

  function isNodeBYON(address entity, uint128 nodeId) public view returns (bool) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodeIsBYON[id];
  }

  function hasLegacyNode(address entity) public view returns (bool) {
    return entityActive[entity] && entityNodeCount[entity] == 0;
  }

  function approveBYONNode(address entity, uint128 nodeId) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, "not admin");

    bytes memory id = getNodeId(entity, nodeId);
    entityNodeIsActive[id] = true;
    entityNodeClaimedOnBlock[id] = block.number;
    activeEntities = activeEntities.add(1);
  }

  function suspendBYONNode(address entity, uint128 nodeId) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, "not admin");

    bytes memory id = getNodeId(entity, nodeId);
    entityNodeIsActive[id] = false;
    activeEntities = activeEntities.sub(1);
  }

  function setNodeIsActive(address entity, uint128 nodeId, bool isActive) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, "not admin");
    bytes memory id = getNodeId(entity, nodeId);

    if (isActive && !entityNodeIsActive[id]) {
      activeEntities = activeEntities.add(1);
      entityNodeClaimedOnBlock[id] = block.number;
    }

    if (!isActive && entityNodeIsActive[id]) {
      activeEntities = activeEntities.sub(1);
    }

    entityNodeIsActive[id] = isActive;
  }

  function setNodeIsNaaS(address entity, uint128 nodeId, bool isNaaS) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, "not admin");
    bytes memory id = getNodeId(entity, nodeId);

    entityNodeIsBYON[id] = !isNaaS;
  }

  function migrateLegacyNode(address entity) private {
    bytes memory id = getNodeId(entity, 1);
    entityNodeClaimedOnBlock[id] = entityBlockLastClaimedOn[entity];
    entityNodePaidOnBlock[id] = paidOnBlock[entity];
    entityNodeTraunch[id] = traunch[entity];
    entityNodeIsBYON[id] = !entityIsNaaS[entity];
    if (entityNodeIsBYON[id]) {
      entityNodeIsActive[id] = true;
    }
    entityNodeCount[msg.sender] = 1;
  }

  function migrateNode(uint128 nodeId, address to) public {
    if (hasLegacyNode(msg.sender)) {
      migrateLegacyNode(msg.sender);
    }

    if (hasLegacyNode(to)) {
      migrateLegacyNode(to);
    }

    require(doesNodeExist(msg.sender, nodeId), "doesnt exist");

    uint128 toNodeId = entityNodeCount[to] + 1;
    bytes memory fromId = getNodeId(msg.sender, nodeId);
    bytes memory toId = getNodeId(to, toNodeId);

    // move node to another address
    entityNodeIsActive[toId] = entityNodeIsActive[fromId];
    entityNodeIsBYON[toId] = entityNodeIsBYON[fromId];
    entityNodePaidOnBlock[toId] = entityNodePaidOnBlock[fromId];
    entityNodeClaimedOnBlock[toId] = entityNodeClaimedOnBlock[fromId];
    entityNodeTraunch[toId] = entityNodeTraunch[fromId];
    entityNodeCount[to] = entityNodeCount[to] + 1;

    // deactivate node
    entityNodeIsActive[fromId] = false;
    entityNodePaidOnBlock[fromId] = 0;
    entityNodeClaimedOnBlock[fromId] = 0;
    entityNodeCount[msg.sender] = entityNodeCount[msg.sender] - 1;

    emit Migrated(msg.sender, to, nodeId, toNodeId, entityNodeIsBYON[fromId]);
  }

  function claimAll(uint256 blockNumber, bool toStrongPool) public payable {
    for (uint16 i = 1; i <= entityNodeCount[msg.sender]; i++) {
      uint256 reward = getRewardByBlock(msg.sender, i, blockNumber);
      uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);
      this.claim{value : fee}(i, blockNumber, toStrongPool);
    }
  }

  function payAll() public payable {
    for (uint16 i = 1; i <= entityNodeCount[msg.sender]; i++) {
      bytes memory id = getNodeId(msg.sender, i);
      uint256 fee = entityNodeIsBYON[id] ? recurringFeeInWei : recurringNaaSFeeInWei;
      this.payFee{value : fee}(i);
    }
  }

  function addNFTBonusContract(address _contract) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, "not admin");

    strongNFTBonus = StrongNFTBonusInterface(_contract);
  }
}

File 12 of 20: ServiceV11.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

import "./IERC20.sol";
import "./SafeMath.sol";
import "./StrongPoolInterface.sol";
import "./IERC1155Preset.sol";
import "./StrongNFTBonusInterface.sol";
import "./rewards.sol";

contract ServiceV11 {
  event Requested(address indexed miner);
  event Claimed(address indexed miner, uint256 reward);

  using SafeMath for uint256;
  bool public initDone;
  address public admin;
  address public pendingAdmin;
  address public superAdmin;
  address public pendingSuperAdmin;
  address public serviceAdmin;
  address public parameterAdmin;
  address payable public feeCollector;

  IERC20 public strongToken;
  StrongPoolInterface public strongPool;

  uint256 public rewardPerBlockNumerator;
  uint256 public rewardPerBlockDenominator;

  uint256 public naasRewardPerBlockNumerator;
  uint256 public naasRewardPerBlockDenominator;

  uint256 public claimingFeeNumerator;
  uint256 public claimingFeeDenominator;

  uint256 public requestingFeeInWei;

  uint256 public strongFeeInWei;

  uint256 public recurringFeeInWei;
  uint256 public recurringNaaSFeeInWei;
  uint256 public recurringPaymentCycleInBlocks;

  uint256 public rewardBalance;

  mapping(address => uint256) public entityBlockLastClaimedOn;

  address[] public entities;
  mapping(address => uint256) public entityIndex;
  mapping(address => bool) public entityActive;
  mapping(address => bool) public requestPending;
  mapping(address => bool) public entityIsNaaS;
  mapping(address => uint256) public paidOnBlock;
  uint256 public activeEntities;

  string public desciption;

  uint256 public claimingFeeInWei;

  uint256 public naasRequestingFeeInWei;

  uint256 public naasStrongFeeInWei;

  bool public removedTokens;

  mapping(address => uint256) public traunch;

  uint256 public currentTraunch;

  mapping(bytes => bool) public entityNodeIsActive;
  mapping(bytes => bool) public entityNodeIsBYON;
  mapping(bytes => uint256) public entityNodeTraunch;
  mapping(bytes => uint256) public entityNodePaidOnBlock;
  mapping(bytes => uint256) public entityNodeClaimedOnBlock;
  mapping(address => uint128) public entityNodeCount;

  event Paid(address indexed entity, uint128 nodeId, bool isBYON, bool isRenewal, uint256 upToBlockNumber);
  event Migrated(address indexed from, address indexed to, uint128 fromNodeId, uint128 toNodeId, bool isBYON);

  uint256 public rewardPerBlockNumeratorNew;
  uint256 public rewardPerBlockDenominatorNew;
  uint256 public naasRewardPerBlockNumeratorNew;
  uint256 public naasRewardPerBlockDenominatorNew;
  uint256 public rewardPerBlockNewEffectiveBlock;

  StrongNFTBonusInterface public strongNFTBonus;

  uint256 public gracePeriodInBlocks;

  function init(
    address strongTokenAddress,
    address strongPoolAddress,
    address adminAddress,
    address superAdminAddress,
    uint256 rewardPerBlockNumeratorValue,
    uint256 rewardPerBlockDenominatorValue,
    uint256 naasRewardPerBlockNumeratorValue,
    uint256 naasRewardPerBlockDenominatorValue,
    uint256 requestingFeeInWeiValue,
    uint256 strongFeeInWeiValue,
    uint256 recurringFeeInWeiValue,
    uint256 recurringNaaSFeeInWeiValue,
    uint256 recurringPaymentCycleInBlocksValue,
    uint256 claimingFeeNumeratorValue,
    uint256 claimingFeeDenominatorValue,
    string memory desc
  ) public {
    require(!initDone, "init done");
    strongToken = IERC20(strongTokenAddress);
    strongPool = StrongPoolInterface(strongPoolAddress);
    admin = adminAddress;
    superAdmin = superAdminAddress;
    rewardPerBlockNumerator = rewardPerBlockNumeratorValue;
    rewardPerBlockDenominator = rewardPerBlockDenominatorValue;
    naasRewardPerBlockNumerator = naasRewardPerBlockNumeratorValue;
    naasRewardPerBlockDenominator = naasRewardPerBlockDenominatorValue;
    requestingFeeInWei = requestingFeeInWeiValue;
    strongFeeInWei = strongFeeInWeiValue;
    recurringFeeInWei = recurringFeeInWeiValue;
    recurringNaaSFeeInWei = recurringNaaSFeeInWeiValue;
    claimingFeeNumerator = claimingFeeNumeratorValue;
    claimingFeeDenominator = claimingFeeDenominatorValue;
    recurringPaymentCycleInBlocks = recurringPaymentCycleInBlocksValue;
    desciption = desc;
    initDone = true;
  }

  // ADMIN
  // *************************************************************************************

  function updateServiceAdmin(address newServiceAdmin) public {
    require(msg.sender == superAdmin);
    serviceAdmin = newServiceAdmin;
  }

  function updateParameterAdmin(address newParameterAdmin) public {
    require(newParameterAdmin != address(0), "zero");
    require(msg.sender == superAdmin);
    parameterAdmin = newParameterAdmin;
  }

  function updateFeeCollector(address payable newFeeCollector) public {
    require(newFeeCollector != address(0), "zero");
    require(msg.sender == superAdmin);
    feeCollector = newFeeCollector;
  }

  function setPendingAdmin(address newPendingAdmin) public {
    require(msg.sender == admin, "not admin");
    pendingAdmin = newPendingAdmin;
  }

  function acceptAdmin() public {
    require(msg.sender == pendingAdmin && msg.sender != address(0), "not pendingAdmin");
    admin = pendingAdmin;
    pendingAdmin = address(0);
  }

  function setPendingSuperAdmin(address newPendingSuperAdmin) public {
    require(msg.sender == superAdmin, "not superAdmin");
    pendingSuperAdmin = newPendingSuperAdmin;
  }

  function acceptSuperAdmin() public {
    require(msg.sender == pendingSuperAdmin && msg.sender != address(0), "not pendingSuperAdmin");
    superAdmin = pendingSuperAdmin;
    pendingSuperAdmin = address(0);
  }

  // ENTITIES
  // *************************************************************************************

  function isEntityActive(address entity) public view returns (bool) {
    return entityActive[entity] || (doesNodeExist(entity, 1) && !hasNodeExpired(entity, 1));
  }

  // REWARD
  // *************************************************************************************

  function updateRewardPerBlock(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    require(denominator != 0, "invalid value");
    rewardPerBlockNumerator = numerator;
    rewardPerBlockDenominator = denominator;
  }

  function updateNaaSRewardPerBlock(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    require(denominator != 0, "invalid value");
    naasRewardPerBlockNumerator = numerator;
    naasRewardPerBlockDenominator = denominator;
  }

  function updateRewardPerBlockNew(
    uint256 numerator,
    uint256 denominator,
    uint256 numeratorNass,
    uint256 denominatorNass,
    uint256 effectiveBlock
  ) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");

    rewardPerBlockNumeratorNew = numerator;
    rewardPerBlockDenominatorNew = denominator;
    naasRewardPerBlockNumeratorNew = numeratorNass;
    naasRewardPerBlockDenominatorNew = denominatorNass;
    rewardPerBlockNewEffectiveBlock = effectiveBlock != 0 ? effectiveBlock : block.number;
  }

  function deposit(uint256 amount) public {
    require(msg.sender == superAdmin, "not admin");
    require(amount > 0, "zero");
    strongToken.transferFrom(msg.sender, address(this), amount);
    rewardBalance = rewardBalance.add(amount);
  }

  function withdraw(address destination, uint256 amount) public {
    require(msg.sender == superAdmin, "not admin");
    require(amount > 0, "zero");
    require(rewardBalance >= amount, "not enough");
    strongToken.transfer(destination, amount);
    rewardBalance = rewardBalance.sub(amount);
  }

  // FEES
  // *************************************************************************************

  function updateRequestingFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    requestingFeeInWei = feeInWei;
  }

  function updateStrongFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    strongFeeInWei = feeInWei;
  }

  function updateNaasRequestingFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    naasRequestingFeeInWei = feeInWei;
  }

  function updateNaasStrongFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    naasStrongFeeInWei = feeInWei;
  }

  function updateClaimingFee(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    require(denominator != 0, "invalid value");
    claimingFeeNumerator = numerator;
    claimingFeeDenominator = denominator;
  }

  function updateRecurringFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    recurringFeeInWei = feeInWei;
  }

  function updateRecurringNaaSFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    recurringNaaSFeeInWei = feeInWei;
  }

  function updateRecurringPaymentCycleInBlocks(uint256 blocks) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    require(blocks > 0, "zero");
    recurringPaymentCycleInBlocks = blocks;
  }

  function updateGracePeriodInBlocks(uint256 blocks) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");
    require(blocks > 0, "zero");
    gracePeriodInBlocks = blocks;
  }

  // CORE
  // *************************************************************************************

  function requestAccess(bool isNaaS) public payable {
    uint256 rFee;
    uint256 sFee;

    if (hasLegacyNode(msg.sender)) {
      migrateLegacyNode(msg.sender);
    }

    uint128 nodeId = entityNodeCount[msg.sender] + 1;
    bytes memory id = getNodeId(msg.sender, nodeId);

    if (isNaaS) {
      rFee = naasRequestingFeeInWei;
      sFee = naasStrongFeeInWei;
      activeEntities = activeEntities.add(1);
    } else {
      rFee = requestingFeeInWei;
      sFee = strongFeeInWei;
      entityNodeIsBYON[id] = true;
    }

    require(msg.value == rFee, "invalid fee");

    entityNodePaidOnBlock[id] = block.number;
    entityNodeClaimedOnBlock[id] = block.number;
    entityNodeCount[msg.sender] = entityNodeCount[msg.sender] + 1;

    feeCollector.transfer(msg.value);
    strongToken.transferFrom(msg.sender, address(this), sFee);
    strongToken.transfer(feeCollector, sFee);

    emit Paid(msg.sender, nodeId, entityNodeIsBYON[id], false, entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks));
  }

  function setEntityActiveStatus(address entity, bool status) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, "not admin");
    uint256 index = entityIndex[entity];
    require(entities[index] == entity, "invalid entity");
    require(entityActive[entity] != status, "already set");
    entityActive[entity] = status;
    if (status) {
      activeEntities = activeEntities.add(1);
      entityBlockLastClaimedOn[entity] = block.number;
    } else {
      activeEntities = activeEntities.sub(1);
      entityBlockLastClaimedOn[entity] = 0;
    }
  }

  function payFee(uint128 nodeId) public payable {
    address sender = msg.sender == address(this) ? tx.origin : msg.sender;
    bytes memory id = getNodeId(sender, nodeId);

    if (hasLegacyNode(sender)) {
      migrateLegacyNode(sender);
    }

    bool isExpired = hasNodeExpired(msg.sender, nodeId);

    require(doesNodeExist(sender, nodeId), "doesnt exist");
    require(isExpired == false || msg.sender == address(this), "too late");

    if (isExpired) {
      return;
    }

    if (entityNodeIsBYON[id]) {
      require(msg.value == recurringFeeInWei, "invalid fee");
    } else {
      require(msg.value == recurringNaaSFeeInWei, "invalid fee");
    }

    feeCollector.transfer(msg.value);
    entityNodePaidOnBlock[id] = entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks);

    emit Paid(sender, nodeId, entityNodeIsBYON[id], true, entityNodePaidOnBlock[id]);
  }

  function getReward(address entity, uint128 nodeId) public view returns (uint256) {
    return getRewardByBlock(entity, nodeId, block.number);
  }

  function getRewardByBlock(address entity, uint128 nodeId, uint256 blockNumber) public view returns (uint256) {
    bytes memory id = getNodeId(entity, nodeId);

    if (hasLegacyNode(entity)) {
      return getRewardByBlockLegacy(entity, blockNumber);
    }

    uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];

    if (blockNumber > block.number) return 0;
    if (blockLastClaimedOn == 0) return 0;
    if (blockNumber < blockLastClaimedOn) return 0;
    if (activeEntities == 0) return 0;
    if (entityNodeIsBYON[id] && !entityNodeIsActive[id]) return 0;

    uint256 rewardNumerator = entityNodeIsBYON[id] ? rewardPerBlockNumerator : naasRewardPerBlockNumerator;
    uint256 rewardDenominator = entityNodeIsBYON[id] ? rewardPerBlockDenominator : naasRewardPerBlockDenominator;
    uint256 newRewardNumerator = entityNodeIsBYON[id] ? rewardPerBlockNumeratorNew : naasRewardPerBlockNumeratorNew;
    uint256 newRewardDenominator = entityNodeIsBYON[id] ? rewardPerBlockDenominatorNew : naasRewardPerBlockDenominatorNew;

    uint256 bonus = address(strongNFTBonus) != address(0)
    ? strongNFTBonus.getBonus(entity, nodeId, blockLastClaimedOn, blockNumber)
    : 0;

    uint256[2] memory rewardBlocks = rewards.blocks(blockLastClaimedOn, rewardPerBlockNewEffectiveBlock, blockNumber);
    uint256 rewardOld = rewardDenominator > 0 ? rewardBlocks[0].mul(rewardNumerator).div(rewardDenominator) : 0;
    uint256 rewardNew = newRewardDenominator > 0 ? rewardBlocks[1].mul(newRewardNumerator).div(newRewardDenominator) : 0;

    return rewardOld.add(rewardNew).add(bonus);
  }

  function getRewardByBlockLegacy(address entity, uint256 blockNumber) public view returns (uint256) {
    if (blockNumber > block.number) return 0;
    if (entityBlockLastClaimedOn[entity] == 0) return 0;
    if (blockNumber < entityBlockLastClaimedOn[entity]) return 0;
    if (activeEntities == 0) return 0;
    uint256 blockResult = blockNumber.sub(entityBlockLastClaimedOn[entity]);
    uint256 rewardNumerator;
    uint256 rewardDenominator;
    if (entityIsNaaS[entity]) {
      rewardNumerator = naasRewardPerBlockNumerator;
      rewardDenominator = naasRewardPerBlockDenominator;
    } else {
      rewardNumerator = rewardPerBlockNumerator;
      rewardDenominator = rewardPerBlockDenominator;
    }
    uint256 rewardPerBlockResult = blockResult.mul(rewardNumerator).div(rewardDenominator);

    return rewardPerBlockResult;
  }

  function claim(uint128 nodeId, uint256 blockNumber, bool toStrongPool) public payable {
    address sender = msg.sender == address(this) || msg.sender == address(strongNFTBonus) ? tx.origin : msg.sender;
    bytes memory id = getNodeId(sender, nodeId);

    if (hasLegacyNode(sender)) {
      migrateLegacyNode(sender);
    }

    uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];
    uint256 blockLastPaidOn = entityNodePaidOnBlock[id];

    require(blockLastClaimedOn != 0, "never claimed");
    require(blockNumber <= block.number, "invalid block");
    require(blockNumber > blockLastClaimedOn, "too soon");
    require(!entityNodeIsBYON[id] || entityNodeIsActive[id], "not active");

    if (
      (!entityNodeIsBYON[id] && recurringNaaSFeeInWei != 0) || (entityNodeIsBYON[id] && recurringFeeInWei != 0)
    ) {
      require(blockNumber < blockLastPaidOn.add(recurringPaymentCycleInBlocks), "pay fee");
    }

    uint256 reward = getRewardByBlock(sender, nodeId, blockNumber);
    require(reward > 0, "no reward");

    uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);
    require(msg.value >= fee, "invalid fee");

    feeCollector.transfer(msg.value);

    if (toStrongPool) {
      strongToken.approve(address(strongPool), reward);
      strongPool.mineFor(sender, reward);
    } else {
      strongToken.transfer(sender, reward);
    }

    rewardBalance = rewardBalance.sub(reward);
    entityNodeClaimedOnBlock[id] = blockNumber;
    emit Claimed(sender, reward);
  }

  function getRewardAll(address entity, uint256 blockNumber) public view returns (uint256) {
    uint256 rewardsAll = 0;

    for (uint128 i = 1; i <= entityNodeCount[entity]; i++) {
      rewardsAll = rewardsAll.add(getRewardByBlock(entity, i, blockNumber > 0 ? blockNumber : block.number));
    }

    return rewardsAll;
  }

  function doesNodeExist(address entity, uint128 nodeId) public view returns (bool) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodePaidOnBlock[id] > 0;
  }

  function hasNodeExpired(address entity, uint128 nodeId) public view returns (bool) {
    bytes memory id = getNodeId(entity, nodeId);
    uint256 blockLastPaidOn = entityNodePaidOnBlock[id];
    return block.number > blockLastPaidOn.add(recurringPaymentCycleInBlocks).add(gracePeriodInBlocks);
  }

  function getNodeId(address entity, uint128 nodeId) public view returns (bytes memory) {
    uint128 id = nodeId != 0 ? nodeId : entityNodeCount[entity] + 1;
    return abi.encodePacked(entity, id);
  }

  function getNodePaidOn(address entity, uint128 nodeId) public view returns (uint256) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodePaidOnBlock[id];
  }

  function getNodeFee(address entity, uint128 nodeId) public view returns (uint256) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodeIsBYON[id] ? recurringFeeInWei : recurringNaaSFeeInWei;
  }

  function isNodeActive(address entity, uint128 nodeId) public view returns (bool) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodeIsActive[id] || !entityNodeIsBYON[id];
  }

  function isNodeBYON(address entity, uint128 nodeId) public view returns (bool) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodeIsBYON[id];
  }

  function hasLegacyNode(address entity) public view returns (bool) {
    return entityActive[entity] && entityNodeCount[entity] == 0;
  }

  function approveBYONNode(address entity, uint128 nodeId) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, "not admin");

    bytes memory id = getNodeId(entity, nodeId);
    entityNodeIsActive[id] = true;
    entityNodeClaimedOnBlock[id] = block.number;
    activeEntities = activeEntities.add(1);
  }

  function suspendBYONNode(address entity, uint128 nodeId) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, "not admin");

    bytes memory id = getNodeId(entity, nodeId);
    entityNodeIsActive[id] = false;
    activeEntities = activeEntities.sub(1);
  }

  function setNodeIsActive(address entity, uint128 nodeId, bool isActive) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, "not admin");
    bytes memory id = getNodeId(entity, nodeId);

    if (isActive && !entityNodeIsActive[id]) {
      activeEntities = activeEntities.add(1);
      entityNodeClaimedOnBlock[id] = block.number;
    }

    if (!isActive && entityNodeIsActive[id]) {
      activeEntities = activeEntities.sub(1);
    }

    entityNodeIsActive[id] = isActive;
  }

  function setNodeIsNaaS(address entity, uint128 nodeId, bool isNaaS) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, "not admin");
    bytes memory id = getNodeId(entity, nodeId);

    entityNodeIsBYON[id] = !isNaaS;
  }

  function migrateLegacyNode(address entity) private {
    bytes memory id = getNodeId(entity, 1);
    entityNodeClaimedOnBlock[id] = entityBlockLastClaimedOn[entity];
    entityNodePaidOnBlock[id] = paidOnBlock[entity];
    entityNodeIsBYON[id] = !entityIsNaaS[entity];
    if (entityNodeIsBYON[id]) {
      entityNodeIsActive[id] = true;
    }
    entityNodeCount[msg.sender] = 1;
  }

  function migrateNode(uint128 nodeId, address to) public {
    if (hasLegacyNode(msg.sender)) {
      migrateLegacyNode(msg.sender);
    }

    if (hasLegacyNode(to)) {
      migrateLegacyNode(to);
    }

    require(doesNodeExist(msg.sender, nodeId), "doesnt exist");

    uint128 toNodeId = entityNodeCount[to] + 1;
    bytes memory fromId = getNodeId(msg.sender, nodeId);
    bytes memory toId = getNodeId(to, toNodeId);

    // move node to another address
    entityNodeIsActive[toId] = entityNodeIsActive[fromId];
    entityNodeIsBYON[toId] = entityNodeIsBYON[fromId];
    entityNodePaidOnBlock[toId] = entityNodePaidOnBlock[fromId];
    entityNodeClaimedOnBlock[toId] = entityNodeClaimedOnBlock[fromId];
    entityNodeCount[to] = entityNodeCount[to] + 1;

    // deactivate node
    entityNodeIsActive[fromId] = false;
    entityNodePaidOnBlock[fromId] = 0;
    entityNodeClaimedOnBlock[fromId] = 0;
    entityNodeCount[msg.sender] = entityNodeCount[msg.sender] - 1;

    emit Migrated(msg.sender, to, nodeId, toNodeId, entityNodeIsBYON[fromId]);
  }

  function claimAll(uint256 blockNumber, bool toStrongPool) public payable {
    for (uint16 i = 1; i <= entityNodeCount[msg.sender]; i++) {
      uint256 reward = getRewardByBlock(msg.sender, i, blockNumber);
      uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);
      this.claim{value : fee}(i, blockNumber, toStrongPool);
    }
  }

  function payAll() public payable {
    for (uint16 i = 1; i <= entityNodeCount[msg.sender]; i++) {
      bytes memory id = getNodeId(msg.sender, i);
      uint256 fee = entityNodeIsBYON[id] ? recurringFeeInWei : recurringNaaSFeeInWei;
      this.payFee{value : fee}(i);
    }
  }

  function addNFTBonusContract(address _contract) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, "not admin");

    strongNFTBonus = StrongNFTBonusInterface(_contract);
  }
}

File 13 of 20: ServiceV12.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

import "./IERC20.sol";
import "./SafeMath.sol";
import "./StrongPoolInterface.sol";
import "./IERC1155Preset.sol";
import "./StrongNFTBonusInterface.sol";
import "./rewards.sol";

contract ServiceV12 {
  event Requested(address indexed miner);
  event Claimed(address indexed miner, uint256 reward);

  using SafeMath for uint256;
  bool public initDone;
  address public admin;
  address public pendingAdmin;
  address public superAdmin;
  address public pendingSuperAdmin;
  address public serviceAdmin;
  address public parameterAdmin;
  address payable public feeCollector;

  IERC20 public strongToken;
  StrongPoolInterface public strongPool;

  uint256 public rewardPerBlockNumerator;
  uint256 public rewardPerBlockDenominator;

  uint256 public naasRewardPerBlockNumerator;
  uint256 public naasRewardPerBlockDenominator;

  uint256 public claimingFeeNumerator;
  uint256 public claimingFeeDenominator;

  uint256 public requestingFeeInWei;

  uint256 public strongFeeInWei;

  uint256 public recurringFeeInWei;
  uint256 public recurringNaaSFeeInWei;
  uint256 public recurringPaymentCycleInBlocks;

  uint256 public rewardBalance;

  mapping(address => uint256) public entityBlockLastClaimedOn;

  address[] public entities;
  mapping(address => uint256) public entityIndex;
  mapping(address => bool) public entityActive;
  mapping(address => bool) public requestPending;
  mapping(address => bool) public entityIsNaaS;
  mapping(address => uint256) public paidOnBlock;
  uint256 public activeEntities;

  string public desciption;

  uint256 public claimingFeeInWei;

  uint256 public naasRequestingFeeInWei;

  uint256 public naasStrongFeeInWei;

  bool public removedTokens;

  mapping(address => uint256) public traunch;

  uint256 public currentTraunch;

  mapping(bytes => bool) public entityNodeIsActive;
  mapping(bytes => bool) public entityNodeIsBYON;
  mapping(bytes => uint256) public entityNodeTraunch;
  mapping(bytes => uint256) public entityNodePaidOnBlock;
  mapping(bytes => uint256) public entityNodeClaimedOnBlock;
  mapping(address => uint128) public entityNodeCount;

  event Paid(address indexed entity, uint128 nodeId, bool isBYON, bool isRenewal, uint256 upToBlockNumber);
  event Migrated(address indexed from, address indexed to, uint128 fromNodeId, uint128 toNodeId, bool isBYON);

  uint256 public rewardPerBlockNumeratorNew;
  uint256 public rewardPerBlockDenominatorNew;
  uint256 public naasRewardPerBlockNumeratorNew;
  uint256 public naasRewardPerBlockDenominatorNew;
  uint256 public rewardPerBlockNewEffectiveBlock;

  StrongNFTBonusInterface public strongNFTBonus;

  uint256 public gracePeriodInBlocks;

  function init(
    address strongTokenAddress,
    address strongPoolAddress,
    address adminAddress,
    address superAdminAddress,
    uint256 rewardPerBlockNumeratorValue,
    uint256 rewardPerBlockDenominatorValue,
    uint256 naasRewardPerBlockNumeratorValue,
    uint256 naasRewardPerBlockDenominatorValue,
    uint256 requestingFeeInWeiValue,
    uint256 strongFeeInWeiValue,
    uint256 recurringFeeInWeiValue,
    uint256 recurringNaaSFeeInWeiValue,
    uint256 recurringPaymentCycleInBlocksValue,
    uint256 claimingFeeNumeratorValue,
    uint256 claimingFeeDenominatorValue,
    string memory desc
  ) public {
    require(!initDone, "init done");
    strongToken = IERC20(strongTokenAddress);
    strongPool = StrongPoolInterface(strongPoolAddress);
    admin = adminAddress;
    superAdmin = superAdminAddress;
    rewardPerBlockNumerator = rewardPerBlockNumeratorValue;
    rewardPerBlockDenominator = rewardPerBlockDenominatorValue;
    naasRewardPerBlockNumerator = naasRewardPerBlockNumeratorValue;
    naasRewardPerBlockDenominator = naasRewardPerBlockDenominatorValue;
    requestingFeeInWei = requestingFeeInWeiValue;
    strongFeeInWei = strongFeeInWeiValue;
    recurringFeeInWei = recurringFeeInWeiValue;
    recurringNaaSFeeInWei = recurringNaaSFeeInWeiValue;
    claimingFeeNumerator = claimingFeeNumeratorValue;
    claimingFeeDenominator = claimingFeeDenominatorValue;
    recurringPaymentCycleInBlocks = recurringPaymentCycleInBlocksValue;
    desciption = desc;
    initDone = true;
  }

  function updateServiceAdmin(address newServiceAdmin) public {
    require(msg.sender == superAdmin);
    serviceAdmin = newServiceAdmin;
  }

  function updateParameterAdmin(address newParameterAdmin) public {
    require(newParameterAdmin != address(0));
    require(msg.sender == superAdmin);
    parameterAdmin = newParameterAdmin;
  }

  function updateFeeCollector(address payable newFeeCollector) public {
    require(newFeeCollector != address(0));
    require(msg.sender == superAdmin);
    feeCollector = newFeeCollector;
  }

  function setPendingAdmin(address newPendingAdmin) public {
    require(msg.sender == admin);
    pendingAdmin = newPendingAdmin;
  }

  function acceptAdmin() public {
    require(msg.sender == pendingAdmin && msg.sender != address(0), "not pendingAdmin");
    admin = pendingAdmin;
    pendingAdmin = address(0);
  }

  function setPendingSuperAdmin(address newPendingSuperAdmin) public {
    require(msg.sender == superAdmin, "not superAdmin");
    pendingSuperAdmin = newPendingSuperAdmin;
  }

  function acceptSuperAdmin() public {
    require(msg.sender == pendingSuperAdmin && msg.sender != address(0), "not pendingSuperAdmin");
    superAdmin = pendingSuperAdmin;
    pendingSuperAdmin = address(0);
  }

  function isEntityActive(address entity) public view returns (bool) {
    return entityActive[entity] || (doesNodeExist(entity, 1) && !hasNodeExpired(entity, 1));
  }

  function updateRewardPerBlock(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
    require(denominator != 0);
    rewardPerBlockNumerator = numerator;
    rewardPerBlockDenominator = denominator;
  }

  function updateNaaSRewardPerBlock(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
    require(denominator != 0);
    naasRewardPerBlockNumerator = numerator;
    naasRewardPerBlockDenominator = denominator;
  }

  function updateRewardPerBlockNew(
    uint256 numerator,
    uint256 denominator,
    uint256 numeratorNass,
    uint256 denominatorNass,
    uint256 effectiveBlock
  ) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);

    rewardPerBlockNumeratorNew = numerator;
    rewardPerBlockDenominatorNew = denominator;
    naasRewardPerBlockNumeratorNew = numeratorNass;
    naasRewardPerBlockDenominatorNew = denominatorNass;
    rewardPerBlockNewEffectiveBlock = effectiveBlock != 0 ? effectiveBlock : block.number;
  }

  function deposit(uint256 amount) public {
    require(msg.sender == superAdmin);
    require(amount > 0);
    strongToken.transferFrom(msg.sender, address(this), amount);
    rewardBalance = rewardBalance.add(amount);
  }

  function withdraw(address destination, uint256 amount) public {
    require(msg.sender == superAdmin);
    require(amount > 0);
    require(rewardBalance >= amount, "not enough");
    strongToken.transfer(destination, amount);
    rewardBalance = rewardBalance.sub(amount);
  }

  function updateRequestingFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
    requestingFeeInWei = feeInWei;
  }

  function updateStrongFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
    strongFeeInWei = feeInWei;
  }

  function updateNaasRequestingFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
    naasRequestingFeeInWei = feeInWei;
  }

  function updateNaasStrongFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
    naasStrongFeeInWei = feeInWei;
  }

  function updateClaimingFee(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
    require(denominator != 0);
    claimingFeeNumerator = numerator;
    claimingFeeDenominator = denominator;
  }

  function updateRecurringFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
    recurringFeeInWei = feeInWei;
  }

  function updateRecurringNaaSFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
    recurringNaaSFeeInWei = feeInWei;
  }

  function updateRecurringPaymentCycleInBlocks(uint256 blocks) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
    require(blocks > 0);
    recurringPaymentCycleInBlocks = blocks;
  }

  function updateGracePeriodInBlocks(uint256 blocks) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin);
    require(blocks > 0);
    gracePeriodInBlocks = blocks;
  }

  function requestAccess(bool isNaaS) public payable {
    uint256 rFee;
    uint256 sFee;

    if (hasLegacyNode(msg.sender)) {
      migrateLegacyNode(msg.sender);
    }

    uint128 nodeId = entityNodeCount[msg.sender] + 1;
    bytes memory id = getNodeId(msg.sender, nodeId);

    if (isNaaS) {
      rFee = naasRequestingFeeInWei;
      sFee = naasStrongFeeInWei;
      activeEntities = activeEntities.add(1);
    } else {
      rFee = requestingFeeInWei;
      sFee = strongFeeInWei;
      entityNodeIsBYON[id] = true;
    }

    require(msg.value == rFee, "invalid fee");

    entityNodePaidOnBlock[id] = block.number;
    entityNodeClaimedOnBlock[id] = block.number;
    entityNodeCount[msg.sender] = entityNodeCount[msg.sender] + 1;

    feeCollector.transfer(msg.value);
    strongToken.transferFrom(msg.sender, address(this), sFee);
    strongToken.transfer(feeCollector, sFee);

    emit Paid(msg.sender, nodeId, entityNodeIsBYON[id], false, entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks));
  }

  function setEntityActiveStatus(address entity, bool status) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin);
    uint256 index = entityIndex[entity];
    require(entities[index] == entity, "invalid entity");
    require(entityActive[entity] != status, "already set");
    entityActive[entity] = status;
    if (status) {
      activeEntities = activeEntities.add(1);
      entityBlockLastClaimedOn[entity] = block.number;
    } else {
      activeEntities = activeEntities.sub(1);
      entityBlockLastClaimedOn[entity] = 0;
    }
  }

  function payFee(uint128 nodeId) public payable {
    address sender = msg.sender == address(this) ? tx.origin : msg.sender;
    bytes memory id = getNodeId(sender, nodeId);

    if (hasLegacyNode(sender)) {
      migrateLegacyNode(sender);
    }

    bool isExpired = hasNodeExpired(sender, nodeId);

    require(doesNodeExist(sender, nodeId), "doesnt exist");
    require(isExpired == false || msg.sender == address(this), "too late");

    if (isExpired) {
      return;
    }

    if (entityNodeIsBYON[id]) {
      require(msg.value == recurringFeeInWei, "invalid fee");
    } else {
      require(msg.value == recurringNaaSFeeInWei, "invalid fee");
    }

    feeCollector.transfer(msg.value);
    entityNodePaidOnBlock[id] = entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks);

    emit Paid(sender, nodeId, entityNodeIsBYON[id], true, entityNodePaidOnBlock[id]);
  }

  function getReward(address entity, uint128 nodeId) public view returns (uint256) {
    return getRewardByBlock(entity, nodeId, block.number);
  }

  function getRewardByBlock(address entity, uint128 nodeId, uint256 blockNumber) public view returns (uint256) {
    bytes memory id = getNodeId(entity, nodeId);

    if (hasLegacyNode(entity)) {
      return getRewardByBlockLegacy(entity, blockNumber);
    }

    uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];

    if (blockNumber > block.number) return 0;
    if (blockLastClaimedOn == 0) return 0;
    if (blockNumber < blockLastClaimedOn) return 0;
    if (activeEntities == 0) return 0;
    if (entityNodeIsBYON[id] && !entityNodeIsActive[id]) return 0;

    uint256 rewardNumerator = entityNodeIsBYON[id] ? rewardPerBlockNumerator : naasRewardPerBlockNumerator;
    uint256 rewardDenominator = entityNodeIsBYON[id] ? rewardPerBlockDenominator : naasRewardPerBlockDenominator;
    uint256 newRewardNumerator = entityNodeIsBYON[id] ? rewardPerBlockNumeratorNew : naasRewardPerBlockNumeratorNew;
    uint256 newRewardDenominator = entityNodeIsBYON[id] ? rewardPerBlockDenominatorNew : naasRewardPerBlockDenominatorNew;

    uint256 bonus = address(strongNFTBonus) != address(0)
    ? strongNFTBonus.getBonus(entity, nodeId, blockLastClaimedOn, blockNumber)
    : 0;

    uint256[2] memory rewardBlocks = rewards.blocks(blockLastClaimedOn, rewardPerBlockNewEffectiveBlock, blockNumber);
    uint256 rewardOld = rewardDenominator > 0 ? rewardBlocks[0].mul(rewardNumerator).div(rewardDenominator) : 0;
    uint256 rewardNew = newRewardDenominator > 0 ? rewardBlocks[1].mul(newRewardNumerator).div(newRewardDenominator) : 0;

    return rewardOld.add(rewardNew).add(bonus);
  }

  function getRewardByBlockLegacy(address entity, uint256 blockNumber) public view returns (uint256) {
    if (blockNumber > block.number) return 0;
    if (entityBlockLastClaimedOn[entity] == 0) return 0;
    if (blockNumber < entityBlockLastClaimedOn[entity]) return 0;
    if (activeEntities == 0) return 0;
    uint256 blockResult = blockNumber.sub(entityBlockLastClaimedOn[entity]);
    uint256 rewardNumerator;
    uint256 rewardDenominator;
    if (entityIsNaaS[entity]) {
      rewardNumerator = naasRewardPerBlockNumerator;
      rewardDenominator = naasRewardPerBlockDenominator;
    } else {
      rewardNumerator = rewardPerBlockNumerator;
      rewardDenominator = rewardPerBlockDenominator;
    }
    uint256 rewardPerBlockResult = blockResult.mul(rewardNumerator).div(rewardDenominator);

    return rewardPerBlockResult;
  }

  function claim(uint128 nodeId, uint256 blockNumber, bool toStrongPool) public payable {
    address sender = msg.sender == address(this) || msg.sender == address(strongNFTBonus) ? tx.origin : msg.sender;
    bytes memory id = getNodeId(sender, nodeId);

    if (hasLegacyNode(sender)) {
      migrateLegacyNode(sender);
    }

    uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];
    uint256 blockLastPaidOn = entityNodePaidOnBlock[id];

    require(blockLastClaimedOn != 0, "never claimed");
    require(blockNumber <= block.number, "invalid block");
    require(blockNumber > blockLastClaimedOn, "too soon");
    require(!entityNodeIsBYON[id] || entityNodeIsActive[id], "not active");

    if (
      (!entityNodeIsBYON[id] && recurringNaaSFeeInWei != 0) || (entityNodeIsBYON[id] && recurringFeeInWei != 0)
    ) {
      require(blockNumber < blockLastPaidOn.add(recurringPaymentCycleInBlocks), "pay fee");
    }

    uint256 reward = getRewardByBlock(sender, nodeId, blockNumber);
    require(reward > 0, "no reward");

    uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);
    require(msg.value >= fee, "invalid fee");

    feeCollector.transfer(msg.value);

    if (toStrongPool) {
      strongToken.approve(address(strongPool), reward);
      strongPool.mineFor(sender, reward);
    } else {
      strongToken.transfer(sender, reward);
    }

    rewardBalance = rewardBalance.sub(reward);
    entityNodeClaimedOnBlock[id] = blockNumber;
    emit Claimed(sender, reward);
  }

  function getRewardAll(address entity, uint256 blockNumber) public view returns (uint256) {
    uint256 rewardsAll = 0;

    for (uint128 i = 1; i <= entityNodeCount[entity]; i++) {
      rewardsAll = rewardsAll.add(getRewardByBlock(entity, i, blockNumber > 0 ? blockNumber : block.number));
    }

    return rewardsAll;
  }

  function doesNodeExist(address entity, uint128 nodeId) public view returns (bool) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodePaidOnBlock[id] > 0;
  }

  function hasNodeExpired(address entity, uint128 nodeId) public view returns (bool) {
    bytes memory id = getNodeId(entity, nodeId);
    uint256 blockLastPaidOn = entityNodePaidOnBlock[id];
    return block.number > blockLastPaidOn.add(recurringPaymentCycleInBlocks).add(gracePeriodInBlocks);
  }

  function getNodeId(address entity, uint128 nodeId) public view returns (bytes memory) {
    uint128 id = nodeId != 0 ? nodeId : entityNodeCount[entity] + 1;
    return abi.encodePacked(entity, id);
  }

  function getNodePaidOn(address entity, uint128 nodeId) public view returns (uint256) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodePaidOnBlock[id];
  }

  function getNodeFee(address entity, uint128 nodeId) public view returns (uint256) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodeIsBYON[id] ? recurringFeeInWei : recurringNaaSFeeInWei;
  }

  function isNodeActive(address entity, uint128 nodeId) public view returns (bool) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodeIsActive[id] || !entityNodeIsBYON[id];
  }

  function isNodeBYON(address entity, uint128 nodeId) public view returns (bool) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodeIsBYON[id];
  }

  function hasLegacyNode(address entity) public view returns (bool) {
    return entityActive[entity] && entityNodeCount[entity] == 0;
  }

  function approveBYONNode(address entity, uint128 nodeId) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin);

    bytes memory id = getNodeId(entity, nodeId);
    entityNodeIsActive[id] = true;
    entityNodeClaimedOnBlock[id] = block.number;
    activeEntities = activeEntities.add(1);
  }

  function suspendBYONNode(address entity, uint128 nodeId) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin);

    bytes memory id = getNodeId(entity, nodeId);
    entityNodeIsActive[id] = false;
    activeEntities = activeEntities.sub(1);
  }

  function setNodeIsActive(address entity, uint128 nodeId, bool isActive) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin);
    bytes memory id = getNodeId(entity, nodeId);

    if (isActive && !entityNodeIsActive[id]) {
      activeEntities = activeEntities.add(1);
      entityNodeClaimedOnBlock[id] = block.number;
    }

    if (!isActive && entityNodeIsActive[id]) {
      activeEntities = activeEntities.sub(1);
    }

    entityNodeIsActive[id] = isActive;
  }

  function setNodeIsNaaS(address entity, uint128 nodeId, bool isNaaS) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin);
    bytes memory id = getNodeId(entity, nodeId);

    entityNodeIsBYON[id] = !isNaaS;
  }

  function migrateLegacyNode(address entity) private {
    bytes memory id = getNodeId(entity, 1);
    entityNodeClaimedOnBlock[id] = entityBlockLastClaimedOn[entity];
    entityNodePaidOnBlock[id] = paidOnBlock[entity];
    entityNodeIsBYON[id] = !entityIsNaaS[entity];
    if (entityNodeIsBYON[id]) {
      entityNodeIsActive[id] = true;
    }
    entityNodeCount[msg.sender] = 1;
  }

  function migrateNode(uint128 nodeId, address to) public {
    if (hasLegacyNode(msg.sender)) {
      migrateLegacyNode(msg.sender);
    }

    if (hasLegacyNode(to)) {
      migrateLegacyNode(to);
    }

    require(doesNodeExist(msg.sender, nodeId), "doesnt exist");

    uint128 toNodeId = entityNodeCount[to] + 1;
    bytes memory fromId = getNodeId(msg.sender, nodeId);
    bytes memory toId = getNodeId(to, toNodeId);

    // move node to another address
    entityNodeIsActive[toId] = entityNodeIsActive[fromId];
    entityNodeIsBYON[toId] = entityNodeIsBYON[fromId];
    entityNodePaidOnBlock[toId] = entityNodePaidOnBlock[fromId];
    entityNodeClaimedOnBlock[toId] = entityNodeClaimedOnBlock[fromId];
    entityNodeCount[to] = entityNodeCount[to] + 1;

    // deactivate node
    entityNodeIsActive[fromId] = false;
    entityNodePaidOnBlock[fromId] = 0;
    entityNodeClaimedOnBlock[fromId] = 0;
    entityNodeCount[msg.sender] = entityNodeCount[msg.sender] - 1;

    emit Migrated(msg.sender, to, nodeId, toNodeId, entityNodeIsBYON[fromId]);
  }

  function claimAll(uint256 blockNumber, bool toStrongPool) public payable {
    for (uint16 i = 1; i <= entityNodeCount[msg.sender]; i++) {
      uint256 reward = getRewardByBlock(msg.sender, i, blockNumber);
      uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);
      this.claim{value : fee}(i, blockNumber, toStrongPool);
    }
  }

  function payAll() public payable {
    for (uint16 i = 1; i <= entityNodeCount[msg.sender]; i++) {
      bytes memory id = getNodeId(msg.sender, i);
      uint256 fee = entityNodeIsBYON[id] ? recurringFeeInWei : recurringNaaSFeeInWei;
      this.payFee{value : fee}(i);
    }
  }

  function addNFTBonusContract(address _contract) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin);

    strongNFTBonus = StrongNFTBonusInterface(_contract);
  }

  function payFeeAdmin(address entity, uint128[] memory nodes) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin);

    for (uint256 i = 0; i < nodes.length; i++) {
      uint128 nodeId = nodes[i];
      bytes memory id = getNodeId(entity, nodeId);
      entityNodePaidOnBlock[id] = entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks);

      emit Paid(entity, nodeId, entityNodeIsBYON[id], true, entityNodePaidOnBlock[id]);
    }
  }

}

File 14 of 20: ServiceV9.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

import "./IERC20.sol";
import "./SafeMath.sol";
import "./StrongPoolInterface.sol";

contract ServiceV9 {
  event Requested(address indexed miner);
  event Claimed(address indexed miner, uint256 reward);

  using SafeMath for uint256;
  bool public initDone;
  address public admin;
  address public pendingAdmin;
  address public superAdmin;
  address public pendingSuperAdmin;
  address public serviceAdmin;
  address public parameterAdmin;
  address payable public feeCollector;

  IERC20 public strongToken;
  StrongPoolInterface public strongPool;

  uint256 public rewardPerBlockNumerator;
  uint256 public rewardPerBlockDenominator;

  uint256 public naasRewardPerBlockNumerator;
  uint256 public naasRewardPerBlockDenominator;

  uint256 public claimingFeeNumerator;
  uint256 public claimingFeeDenominator;

  uint256 public requestingFeeInWei;

  uint256 public strongFeeInWei;

  uint256 public recurringFeeInWei;
  uint256 public recurringNaaSFeeInWei;
  uint256 public recurringPaymentCycleInBlocks;

  uint256 public rewardBalance;

  mapping(address => uint256) public entityBlockLastClaimedOn;

  address[] public entities;
  mapping(address => uint256) public entityIndex;
  mapping(address => bool) public entityActive;
  mapping(address => bool) public requestPending;
  mapping(address => bool) public entityIsNaaS;
  mapping(address => uint256) public paidOnBlock;
  uint256 public activeEntities;

  string public desciption;

  uint256 public claimingFeeInWei;

  uint256 public naasRequestingFeeInWei;

  uint256 public naasStrongFeeInWei;

  bool public removedTokens;

  mapping(address => uint256) public traunch;

  uint256 public currentTraunch;

  mapping(bytes => bool) public entityNodeIsActive;
  mapping(bytes => bool) public entityNodeIsBYON;
  mapping(bytes => uint256) public entityNodeTraunch;
  mapping(bytes => uint256) public entityNodePaidOnBlock;
  mapping(bytes => uint256) public entityNodeClaimedOnBlock;
  mapping(address => uint128) public entityNodeCount;

  event Paid(address indexed entity, uint128 nodeId, bool isBYON, bool isRenewal, uint256 upToBlockNumber);
  event Migrated(address indexed from, address indexed to, uint128 fromNodeId, uint128 toNodeId, bool isBYON);

  function init(
    address strongTokenAddress,
    address strongPoolAddress,
    address adminAddress,
    address superAdminAddress,
    uint256 rewardPerBlockNumeratorValue,
    uint256 rewardPerBlockDenominatorValue,
    uint256 naasRewardPerBlockNumeratorValue,
    uint256 naasRewardPerBlockDenominatorValue,
    uint256 requestingFeeInWeiValue,
    uint256 strongFeeInWeiValue,
    uint256 recurringFeeInWeiValue,
    uint256 recurringNaaSFeeInWeiValue,
    uint256 recurringPaymentCycleInBlocksValue,
    uint256 claimingFeeNumeratorValue,
    uint256 claimingFeeDenominatorValue,
    string memory desc
  ) public {
    require(!initDone, 'init done');
    strongToken = IERC20(strongTokenAddress);
    strongPool = StrongPoolInterface(strongPoolAddress);
    admin = adminAddress;
    superAdmin = superAdminAddress;
    rewardPerBlockNumerator = rewardPerBlockNumeratorValue;
    rewardPerBlockDenominator = rewardPerBlockDenominatorValue;
    naasRewardPerBlockNumerator = naasRewardPerBlockNumeratorValue;
    naasRewardPerBlockDenominator = naasRewardPerBlockDenominatorValue;
    requestingFeeInWei = requestingFeeInWeiValue;
    strongFeeInWei = strongFeeInWeiValue;
    recurringFeeInWei = recurringFeeInWeiValue;
    recurringNaaSFeeInWei = recurringNaaSFeeInWeiValue;
    claimingFeeNumerator = claimingFeeNumeratorValue;
    claimingFeeDenominator = claimingFeeDenominatorValue;
    recurringPaymentCycleInBlocks = recurringPaymentCycleInBlocksValue;
    desciption = desc;
    initDone = true;
  }

  // ADMIN
  // *************************************************************************************

  function updateServiceAdmin(address newServiceAdmin) public {
    require(msg.sender == superAdmin);
    serviceAdmin = newServiceAdmin;
  }

  function updateParameterAdmin(address newParameterAdmin) public {
    require(newParameterAdmin != address(0), 'zero');
    require(msg.sender == superAdmin);
    parameterAdmin = newParameterAdmin;
  }

  function updateFeeCollector(address payable newFeeCollector) public {
    require(newFeeCollector != address(0), 'zero');
    require(msg.sender == superAdmin);
    feeCollector = newFeeCollector;
  }

  function setPendingAdmin(address newPendingAdmin) public {
    require(msg.sender == admin, 'not admin');
    pendingAdmin = newPendingAdmin;
  }

  function acceptAdmin() public {
    require(msg.sender == pendingAdmin && msg.sender != address(0), 'not pendingAdmin');
    admin = pendingAdmin;
    pendingAdmin = address(0);
  }

  function setPendingSuperAdmin(address newPendingSuperAdmin) public {
    require(msg.sender == superAdmin, 'not superAdmin');
    pendingSuperAdmin = newPendingSuperAdmin;
  }

  function acceptSuperAdmin() public {
    require(msg.sender == pendingSuperAdmin && msg.sender != address(0), 'not pendingSuperAdmin');
    superAdmin = pendingSuperAdmin;
    pendingSuperAdmin = address(0);
  }

  // ENTITIES
  // *************************************************************************************

  function getEntities() public view returns (address[] memory) {
    return entities;
  }

  function isEntityActive(address entity) public view returns (bool) {
    return entityActive[entity];
  }

  // TRAUNCH
  // *************************************************************************************

  function updateCurrentTraunch(uint256 value) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, 'not an admin');
    currentTraunch = value;
  }

  function getTraunch(address entity) public view returns (uint256) {
    return traunch[entity];
  }

  // REWARD
  // *************************************************************************************

  function updateRewardPerBlock(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, 'not an admin');
    require(denominator != 0, 'invalid value');
    rewardPerBlockNumerator = numerator;
    rewardPerBlockDenominator = denominator;
  }

  function updateNaaSRewardPerBlock(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, 'not an admin');
    require(denominator != 0, 'invalid value');
    naasRewardPerBlockNumerator = numerator;
    naasRewardPerBlockDenominator = denominator;
  }

  function deposit(uint256 amount) public {
    require(msg.sender == superAdmin, 'not an admin');
    require(amount > 0, 'zero');
    strongToken.transferFrom(msg.sender, address(this), amount);
    rewardBalance = rewardBalance.add(amount);
  }

  function withdraw(address destination, uint256 amount) public {
    require(msg.sender == superAdmin, 'not an admin');
    require(amount > 0, 'zero');
    require(rewardBalance >= amount, 'not enough');
    strongToken.transfer(destination, amount);
    rewardBalance = rewardBalance.sub(amount);
  }

  function removeTokens() public {
    require(!removedTokens, 'already removed');
    require(msg.sender == superAdmin, 'not an admin');
    // removing 2500 STRONG tokens sent in this tx: 0xe27640beda32a5e49aad3b6692790b9d380ed25da0cf8dca7fd5f3258efa600a
    strongToken.transfer(superAdmin, 2500000000000000000000);
    removedTokens = true;
  }

  // FEES
  // *************************************************************************************

  function updateRequestingFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, 'not an admin');
    requestingFeeInWei = feeInWei;
  }

  function updateStrongFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, 'not an admin');
    strongFeeInWei = feeInWei;
  }

  function updateNaasRequestingFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, 'not an admin');
    naasRequestingFeeInWei = feeInWei;
  }

  function updateNaasStrongFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, 'not an admin');
    naasStrongFeeInWei = feeInWei;
  }

  function updateClaimingFee(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, 'not an admin');
    require(denominator != 0, 'invalid value');
    claimingFeeNumerator = numerator;
    claimingFeeDenominator = denominator;
  }

  function updateRecurringFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, 'not an admin');
    recurringFeeInWei = feeInWei;
  }

  function updateRecurringNaaSFee(uint256 feeInWei) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, 'not an admin');
    recurringNaaSFeeInWei = feeInWei;
  }

  function updateRecurringPaymentCycleInBlocks(uint256 blocks) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, 'not an admin');
    require(blocks > 0, 'zero');
    recurringPaymentCycleInBlocks = blocks;
  }

  // CORE
  // *************************************************************************************

  function requestAccess(bool isNaaS) public payable {
    uint256 rFee;
    uint256 sFee;

    if (hasLegacyNode(msg.sender)) {
      migrateLegacyNode(msg.sender);
    }

    uint128 nodeId = entityNodeCount[msg.sender] + 1;
    bytes memory id = getNodeId(msg.sender, nodeId);

    if (isNaaS) {
      rFee = naasRequestingFeeInWei;
      sFee = naasStrongFeeInWei;
      activeEntities = activeEntities.add(1);
    } else {
      rFee = requestingFeeInWei;
      sFee = strongFeeInWei;
      entityNodeIsBYON[id] = true;
    }

    require(msg.value == rFee, 'invalid fee');

    entityNodePaidOnBlock[id] = block.number;
    entityNodeTraunch[id] = currentTraunch;
    entityNodeClaimedOnBlock[id] = block.number;
    entityNodeCount[msg.sender] = entityNodeCount[msg.sender] + 1;

    feeCollector.transfer(msg.value);
    strongToken.transferFrom(msg.sender, address(this), sFee);
    strongToken.transfer(feeCollector, sFee);

    emit Paid(msg.sender, nodeId, entityNodeIsBYON[id], false, entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks));
  }

  function setEntityActiveStatus(address entity, bool status) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, 'not admin');
    uint256 index = entityIndex[entity];
    require(entities[index] == entity, 'invalid entity');
    require(entityActive[entity] != status, 'already set');
    entityActive[entity] = status;
    if (status) {
      activeEntities = activeEntities.add(1);
      entityBlockLastClaimedOn[entity] = block.number;
    } else {
      activeEntities = activeEntities.sub(1);
      entityBlockLastClaimedOn[entity] = 0;
    }
  }

  function setTraunch(address entity, uint256 value) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, 'not admin');

    traunch[entity] = value;
  }

  function payFee(uint128 nodeId) public payable {
    address sender = msg.sender == address(this) ? tx.origin : msg.sender;
    bytes memory id = getNodeId(sender, nodeId);

    if (hasLegacyNode(sender)) {
      migrateLegacyNode(sender);
    }

    require(doesNodeExist(sender, nodeId), 'doesnt exist');

    if (entityNodeIsBYON[id]) {
      require(msg.value == recurringFeeInWei, 'invalid fee');
    } else {
      require(msg.value == recurringNaaSFeeInWei, 'invalid fee');
    }

    feeCollector.transfer(msg.value);
    entityNodePaidOnBlock[id] = entityNodePaidOnBlock[id].add(recurringPaymentCycleInBlocks);

    emit Paid(sender, nodeId, entityNodeIsBYON[id], true, entityNodePaidOnBlock[id]);
  }

  function getReward(address entity, uint128 nodeId) public view returns (uint256) {
    return getRewardByBlock(entity, nodeId, block.number);
  }

  function getRewardByBlock(address entity, uint128 nodeId, uint256 blockNumber) public view returns (uint256) {
    bytes memory id = getNodeId(entity, nodeId);

    if (hasLegacyNode(entity)) {
      return getRewardByBlockLegacy(entity, blockNumber);
    }

    uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];

    if (blockNumber > block.number) return 0;
    if (blockLastClaimedOn == 0) return 0;
    if (blockNumber < blockLastClaimedOn) return 0;
    if (activeEntities == 0) return 0;
    if (entityNodeIsBYON[id] && !entityNodeIsActive[id]) return 0;

    uint256 blockResult = blockNumber.sub(blockLastClaimedOn);
    uint256 rewardNumerator;
    uint256 rewardDenominator;

    if (entityNodeIsBYON[id]) {
      rewardNumerator = rewardPerBlockNumerator;
      rewardDenominator = rewardPerBlockDenominator;
    } else {
      rewardNumerator = naasRewardPerBlockNumerator;
      rewardDenominator = naasRewardPerBlockDenominator;
    }

    uint256 rewardPerBlockResult = blockResult.mul(rewardNumerator).div(rewardDenominator);

    return rewardPerBlockResult;
  }

  function getRewardByBlockLegacy(address entity, uint256 blockNumber) public view returns (uint256) {
    if (blockNumber > block.number) return 0;
    if (entityBlockLastClaimedOn[entity] == 0) return 0;
    if (blockNumber < entityBlockLastClaimedOn[entity]) return 0;
    if (activeEntities == 0) return 0;
    uint256 blockResult = blockNumber.sub(entityBlockLastClaimedOn[entity]);
    uint256 rewardNumerator;
    uint256 rewardDenominator;
    if (entityIsNaaS[entity]) {
      rewardNumerator = naasRewardPerBlockNumerator;
      rewardDenominator = naasRewardPerBlockDenominator;
    } else {
      rewardNumerator = rewardPerBlockNumerator;
      rewardDenominator = rewardPerBlockDenominator;
    }
    uint256 rewardPerBlockResult = blockResult.mul(rewardNumerator).div(rewardDenominator);

    return rewardPerBlockResult;
  }

  function claim(uint128 nodeId, uint256 blockNumber, bool toStrongPool) public payable {
    address sender = msg.sender == address(this) ? tx.origin : msg.sender;
    bytes memory id = getNodeId(sender, nodeId);

    if (hasLegacyNode(sender)) {
      migrateLegacyNode(sender);
    }

    uint256 blockLastClaimedOn = entityNodeClaimedOnBlock[id] != 0 ? entityNodeClaimedOnBlock[id] : entityNodePaidOnBlock[id];
    uint256 blockLastPaidOn = entityNodePaidOnBlock[id];

    require(blockLastClaimedOn != 0, 'never claimed');
    require(blockNumber <= block.number, 'invalid block');
    require(blockNumber > blockLastClaimedOn, 'too soon');
    require(!entityNodeIsBYON[id] || entityNodeIsActive[id], 'not active');

    if (
      (!entityNodeIsBYON[id] && recurringNaaSFeeInWei != 0) || (entityNodeIsBYON[id] && recurringFeeInWei != 0)
    ) {
      require(blockNumber < blockLastPaidOn.add(recurringPaymentCycleInBlocks), 'pay fee');
    }

    uint256 reward = getRewardByBlock(sender, nodeId, blockNumber);
    require(reward > 0, 'no reward');

    uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);
    require(msg.value >= fee, 'invalid fee');

    feeCollector.transfer(msg.value);

    if (toStrongPool) {
      strongToken.approve(address(strongPool), reward);
      strongPool.mineFor(sender, reward);
    } else {
      strongToken.transfer(sender, reward);
    }

    rewardBalance = rewardBalance.sub(reward);
    entityNodeClaimedOnBlock[id] = blockNumber;
    emit Claimed(sender, reward);
  }

  function getRewardAll(address entity, uint256 blockNumber) public view returns (uint256) {
    uint256 rewardsAll = 0;

    for (uint128 i = 1; i <= entityNodeCount[entity]; i++) {
      rewardsAll = rewardsAll.add(getRewardByBlock(entity, i, blockNumber > 0 ? blockNumber : block.number));
    }

    return rewardsAll;
  }

  function doesNodeExist(address entity, uint128 nodeId) public view returns (bool) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodePaidOnBlock[id] > 0;
  }

  function getNodeId(address entity, uint128 nodeId) public view returns (bytes memory) {
    uint128 id = nodeId != 0 ? nodeId : entityNodeCount[entity] + 1;
    return abi.encodePacked(entity, id);
  }

  function getNodePaidOn(address entity, uint128 nodeId) public view returns (uint256) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodePaidOnBlock[id];
  }

  function getNodeFee(address entity, uint128 nodeId) public view returns (uint256) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodeIsBYON[id] ? recurringFeeInWei : recurringNaaSFeeInWei;
  }

  function isNodeActive(address entity, uint128 nodeId) public view returns (bool) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodeIsActive[id] || !entityNodeIsBYON[id];
  }

  function isNodeBYON(address entity, uint128 nodeId) public view returns (bool) {
    bytes memory id = getNodeId(entity, nodeId);
    return entityNodeIsBYON[id];
  }

  function hasLegacyNode(address entity) public view returns (bool) {
    return entityActive[entity] && entityNodeCount[entity] == 0;
  }

  function approveBYONNode(address entity, uint128 nodeId) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, 'not admin');

    bytes memory id = getNodeId(entity, nodeId);
    entityNodeIsActive[id] = true;
    entityNodeClaimedOnBlock[id] = block.number;
    activeEntities = activeEntities.add(1);
  }

  function suspendBYONNode(address entity, uint128 nodeId) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, 'not admin');

    bytes memory id = getNodeId(entity, nodeId);
    entityNodeIsActive[id] = false;
    activeEntities = activeEntities.sub(1);
  }

  function setNodeIsActive(address entity, uint128 nodeId, bool isActive) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, 'not admin');
    bytes memory id = getNodeId(entity, nodeId);

    if (isActive && !entityNodeIsActive[id]) {
      activeEntities = activeEntities.add(1);
      entityNodeClaimedOnBlock[id] = block.number;
    }

    if (!isActive && entityNodeIsActive[id]) {
      activeEntities = activeEntities.sub(1);
    }

    entityNodeIsActive[id] = isActive;
  }

  function setNodeIsNaaS(address entity, uint128 nodeId, bool isNaaS) public {
    require(msg.sender == admin || msg.sender == serviceAdmin || msg.sender == superAdmin, 'not admin');
    bytes memory id = getNodeId(entity, nodeId);

    entityNodeIsBYON[id] = !isNaaS;
  }

  function migrateLegacyNode(address entity) private {
    bytes memory id = getNodeId(entity, 1);
    entityNodeClaimedOnBlock[id] = entityBlockLastClaimedOn[entity];
    entityNodePaidOnBlock[id] = paidOnBlock[entity];
    entityNodeTraunch[id] = traunch[entity];
    entityNodeIsBYON[id] = !entityIsNaaS[entity];
    if (entityNodeIsBYON[id]) {
      entityNodeIsActive[id] = true;
    }
    entityNodeCount[msg.sender] = 1;
  }

  function migrateNode(uint128 nodeId, address to) public {
    if (hasLegacyNode(msg.sender)) {
      migrateLegacyNode(msg.sender);
    }

    if (hasLegacyNode(to)) {
      migrateLegacyNode(to);
    }

    require(doesNodeExist(msg.sender, nodeId), 'doesnt exist');

    uint128 toNodeId = entityNodeCount[to] + 1;
    bytes memory fromId = getNodeId(msg.sender, nodeId);
    bytes memory toId = getNodeId(to, toNodeId);

    // move node to another address
    entityNodeIsActive[toId] = entityNodeIsActive[fromId];
    entityNodeIsBYON[toId] = entityNodeIsBYON[fromId];
    entityNodePaidOnBlock[toId] = entityNodePaidOnBlock[fromId];
    entityNodeClaimedOnBlock[toId] = entityNodeClaimedOnBlock[fromId];
    entityNodeTraunch[toId] = entityNodeTraunch[fromId];
    entityNodeCount[to] = entityNodeCount[to] + 1;

    // deactivate node
    entityNodeIsActive[fromId] = false;
    entityNodePaidOnBlock[fromId] = 0;
    entityNodeClaimedOnBlock[fromId] = 0;
    entityNodeCount[msg.sender] = entityNodeCount[msg.sender] - 1;

    emit Migrated(msg.sender, to, nodeId, toNodeId, entityNodeIsBYON[fromId]);
  }

  function claimAll(uint256 blockNumber, bool toStrongPool) public payable {
    for (uint16 i = 1; i <= entityNodeCount[msg.sender]; i++) {
      uint256 reward = getRewardByBlock(msg.sender, i, blockNumber);
      uint256 fee = reward.mul(claimingFeeNumerator).div(claimingFeeDenominator);
      this.claim{ value: fee }(i, blockNumber, toStrongPool);
    }
  }

  function payAll() public payable {
    for (uint16 i = 1; i <= entityNodeCount[msg.sender]; i++) {
      bytes memory id = getNodeId(msg.sender, i);
      uint256 fee = entityNodeIsBYON[id] ? recurringFeeInWei : recurringNaaSFeeInWei;
      this.payFee{ value: fee }(i);
    }
  }
}

File 15 of 20: StrongNFTBonus.sol
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.6.8;

import "./ServiceInterface.sol";
import "./IERC1155Preset.sol";
import "./SafeMath.sol";
import "./Context.sol";

contract StrongNFTBonus is Context {

  using SafeMath for uint256;

  event Staked(address indexed sender, uint256 tokenId, uint128 nodeId, uint256 block);
  event Unstaked(address indexed sender, uint256 tokenId, uint128 nodeId, uint256 block);

  ServiceInterface public service;
  IERC1155Preset public nft;

  bool public initDone;

  address public serviceAdmin;
  address public superAdmin;

  string[] public nftBonusNames;
  mapping(string => uint256) public nftBonusLowerBound;
  mapping(string => uint256) public nftBonusUpperBound;
  mapping(string => uint256) public nftBonusValue;

  mapping(uint256 => uint256) public nftIdStakedForNodeId;
  mapping(address => mapping(uint128 => uint256)) public entityNodeStakedNftId;
  mapping(address => mapping(uint128 => uint256)) public entityNodeStakedNftBlock;

  function init(address serviceContract, address nftContract, address serviceAdminAddress, address superAdminAddress) public {
    require(initDone == false, "init done");

    serviceAdmin = serviceAdminAddress;
    superAdmin = superAdminAddress;
    service = ServiceInterface(serviceContract);
    nft = IERC1155Preset(nftContract);
    initDone = true;
  }

  function isNftStaked(uint256 _tokenId) public view returns (bool) {
    return nftIdStakedForNodeId[_tokenId] != 0;
  }

  function getNftStakedForNodeId(uint256 _tokenId) public view returns (uint256) {
    return nftIdStakedForNodeId[_tokenId];
  }

  function getStakedNftId(address _entity, uint128 _nodeId) public view returns (uint256) {
    return entityNodeStakedNftId[_entity][_nodeId];
  }

  function getStakedNftBlock(address _entity, uint128 _nodeId) public view returns (uint256) {
    return entityNodeStakedNftBlock[_entity][_nodeId];
  }

  function getBonus(address _entity, uint128 _nodeId, uint256 _fromBlock, uint256 _toBlock) public view returns (uint256) {
    uint256 nftId = entityNodeStakedNftId[_entity][_nodeId];

    if (nftId == 0) return 0;
    if (nftId < nftBonusLowerBound["BRONZE"]) return 0;
    if (nftId > nftBonusUpperBound["BRONZE"]) return 0;
    if (nft.balanceOf(_entity, nftId) == 0) return 0;
    if (_fromBlock >= _toBlock) return 0;

    uint256 stakedAtBlock = entityNodeStakedNftBlock[_entity][_nodeId];

    if (stakedAtBlock == 0) return 0;

    uint256 startFromBlock = stakedAtBlock > _fromBlock ? stakedAtBlock : _fromBlock;

    if (startFromBlock >= _toBlock) return 0;

    return _toBlock.sub(startFromBlock).mul(nftBonusValue["BRONZE"]);
  }

  function stakeNFT(uint256 _tokenId, uint128 _nodeId) public payable {
    require(nft.balanceOf(_msgSender(), _tokenId) != 0, "not enough");
    require(_tokenId >= nftBonusLowerBound["BRONZE"] && _tokenId <= nftBonusUpperBound["BRONZE"], "not eligible");
    require(nftIdStakedForNodeId[_tokenId] == 0, "already staked");
    require(service.doesNodeExist(_msgSender(), _nodeId), "node doesnt exist");

    nftIdStakedForNodeId[_tokenId] = _nodeId;
    entityNodeStakedNftId[_msgSender()][_nodeId] = _tokenId;
    entityNodeStakedNftBlock[_msgSender()][_nodeId] = block.number;

    emit Staked(msg.sender, _tokenId, _nodeId, block.number);
  }

  function unStakeNFT(uint256 _tokenId, uint128 _nodeId, uint256 _blockNumber) public payable {
    require(nft.balanceOf(_msgSender(), _tokenId) != 0, "not enough");
    require(nftIdStakedForNodeId[_tokenId] == _nodeId, "not this node");

    service.claim{value : msg.value}(_nodeId, _blockNumber, false);

    nftIdStakedForNodeId[_tokenId] = 0;
    entityNodeStakedNftId[_msgSender()][_nodeId] = 0;
    entityNodeStakedNftBlock[_msgSender()][_nodeId] = 0;

    emit Unstaked(msg.sender, _tokenId, _nodeId, _blockNumber);
  }

  function updateBonus(string memory _name, uint256 _lowerBound, uint256 _upperBound, uint256 _value) public {
    require(msg.sender == serviceAdmin || msg.sender == superAdmin, "not admin");

    bool alreadyExit = false;
    for (uint i = 0; i < nftBonusNames.length; i++) {
      if (keccak256(abi.encode(nftBonusNames[i])) == keccak256(abi.encode(_name))) {
        alreadyExit = true;
      }
    }

    if (!alreadyExit) {
      nftBonusNames.push(_name);
    }

    nftBonusLowerBound[_name] = _lowerBound;
    nftBonusUpperBound[_name] = _upperBound;
    nftBonusValue[_name] = _value;
  }

  function updateContracts(address serviceContract, address nftContract) public {
    require(msg.sender == superAdmin, "not admin");
    service = ServiceInterface(serviceContract);
    nft = IERC1155Preset(nftContract);
  }

  function updateServiceAdmin(address newServiceAdmin) public {
    require(msg.sender == superAdmin, "not admin");
    serviceAdmin = newServiceAdmin;
  }
}

File 16 of 20: StrongNFTBonusInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

interface StrongNFTBonusInterface {
  function getBonus(address _entity, uint128 _nodeId, uint256 _fromBlock, uint256 _toBlock) external view returns (uint256);
}

File 17 of 20: StrongNFTClaimerInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

interface StrongNFTClaimerInterface {
  function tokenNameAddressClaimed(string memory, address) external view returns(bool);
}

File 18 of 20: StrongPoolInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

interface StrongPoolInterface {
  function mineFor(address miner, uint256 amount) external;
}

File 19 of 20: VoteInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

interface VoteInterface {
  function getPriorProposalVotes(address account, uint256 blockNumber) external view returns (uint96);

  function updateVotes(
    address voter,
    uint256 rawAmount,
    bool adding
  ) external;
}

File 20 of 20: VoteV3.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;

import "./SafeMath.sol";
import "./IERC20.sol";
import "./StrongPoolInterface.sol";
import "./ServiceInterface.sol";
import "./rewards.sol";

contract VoteV3 {
  event Voted(address indexed voter, address indexed service, address indexed entity, uint256 amount);
  event RecalledVote(address indexed voter, address indexed service, address indexed entity, uint256 amount);
  event Claimed(address indexed claimer, uint256 amount);
  event VotesAdded(address indexed miner, uint256 amount);
  event VotesSubtracted(address indexed miner, uint256 amount);
  event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);

  using SafeMath for uint256;

  StrongPoolInterface public strongPool;
  IERC20 public strongToken;

  bool public initDone;
  address public admin;
  address public pendingAdmin;
  address public superAdmin;
  address public pendingSuperAdmin;
  address public parameterAdmin;

  uint256 public rewardBalance;

  uint256 public voterRewardPerBlockNumerator;
  uint256 public voterRewardPerBlockDenominator;
  uint256 public entityRewardPerBlockNumerator;
  uint256 public entityRewardPerBlockDenominator;

  mapping(address => uint96) public balances;
  mapping(address => address) public delegates;

  mapping(address => mapping(uint32 => uint32)) public checkpointsFromBlock;
  mapping(address => mapping(uint32 => uint96)) public checkpointsVotes;
  mapping(address => uint32) public numCheckpoints;

  mapping(address => uint256) public voterVotesOut;
  uint256 public totalVotesOut;

  mapping(address => uint256) public serviceVotes;
  mapping(address => mapping(address => uint256)) public serviceEntityVotes;
  mapping(address => mapping(address => mapping(address => uint256))) public voterServiceEntityVotes;

  mapping(address => address[]) public voterServices;
  mapping(address => mapping(address => uint256)) public voterServiceIndex;

  mapping(address => mapping(address => address[])) public voterServiceEntities;
  mapping(address => mapping(address => mapping(address => uint256))) public voterServiceEntityIndex;

  mapping(address => uint256) public voterBlockLastClaimedOn;
  mapping(address => mapping(address => uint256)) public serviceEntityBlockLastClaimedOn;

  address[] public serviceContracts;
  mapping(address => uint256) public serviceContractIndex;
  mapping(address => bool) public serviceContractActive;

  uint256 public voterRewardPerBlockNumeratorNew;
  uint256 public voterRewardPerBlockDenominatorNew;
  uint256 public entityRewardPerBlockNumeratorNew;
  uint256 public entityRewardPerBlockDenominatorNew;
  uint256 public rewardPerBlockNewEffectiveBlock;

  function init(
    address strongTokenAddress,
    address strongPoolAddress,
    address adminAddress,
    address superAdminAddress,
    uint256 voterRewardPerBlockNumeratorValue,
    uint256 voterRewardPerBlockDenominatorValue,
    uint256 entityRewardPerBlockNumeratorValue,
    uint256 entityRewardPerBlockDenominatorValue
  ) public {
    require(!initDone, "init done");
    strongToken = IERC20(strongTokenAddress);
    strongPool = StrongPoolInterface(strongPoolAddress);
    admin = adminAddress;
    superAdmin = superAdminAddress;
    voterRewardPerBlockNumerator = voterRewardPerBlockNumeratorValue;
    voterRewardPerBlockDenominator = voterRewardPerBlockDenominatorValue;
    entityRewardPerBlockNumerator = entityRewardPerBlockNumeratorValue;
    entityRewardPerBlockDenominator = entityRewardPerBlockDenominatorValue;
    initDone = true;
  }

  // ADMIN
  // *************************************************************************************
  function updateParameterAdmin(address newParameterAdmin) public {
    require(newParameterAdmin != address(0), "zero");
    require(msg.sender == superAdmin);
    parameterAdmin = newParameterAdmin;
  }

  function setPendingAdmin(address newPendingAdmin) public {
    require(newPendingAdmin != address(0), "zero");
    require(msg.sender == admin, "not admin");
    pendingAdmin = newPendingAdmin;
  }

  function acceptAdmin() public {
    require(msg.sender == pendingAdmin && msg.sender != address(0), "not pendingAdmin");
    admin = pendingAdmin;
    pendingAdmin = address(0);
  }

  function setPendingSuperAdmin(address newPendingSuperAdmin) public {
    require(newPendingSuperAdmin != address(0), "zero");
    require(msg.sender == superAdmin, "not superAdmin");
    pendingSuperAdmin = newPendingSuperAdmin;
  }

  function acceptSuperAdmin() public {
    require(msg.sender == pendingSuperAdmin && msg.sender != address(0), "not pendingSuperAdmin");
    superAdmin = pendingSuperAdmin;
    pendingSuperAdmin = address(0);
  }

  // SERVICE CONTRACTS
  // *************************************************************************************
  function addServiceContract(address contr) public {
    require(contr != address(0), "zero");
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin");
    if (serviceContracts.length != 0) {
      uint256 index = serviceContractIndex[contr];
      require(serviceContracts[index] != contr, "exists");
    }
    uint256 len = serviceContracts.length;
    serviceContractIndex[contr] = len;
    serviceContractActive[contr] = true;
    serviceContracts.push(contr);
  }

  function updateServiceContractActiveStatus(address contr, bool activeStatus) public {
    require(contr != address(0), "zero");
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin");
    require(serviceContracts.length > 0, "zero");
    uint256 index = serviceContractIndex[contr];
    require(serviceContracts[index] == contr, "not exists");
    serviceContractActive[contr] = activeStatus;
  }

  function getServiceContracts() public view returns (address[] memory) {
    return serviceContracts;
  }

  // REWARD
  // *************************************************************************************
  function updateVoterRewardPerBlock(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin");
    require(denominator != 0, "invalid value");
    voterRewardPerBlockNumerator = numerator;
    voterRewardPerBlockDenominator = denominator;
  }

  function updateEntityRewardPerBlock(uint256 numerator, uint256 denominator) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not an admin");
    require(denominator != 0, "invalid value");
    entityRewardPerBlockNumerator = numerator;
    entityRewardPerBlockDenominator = denominator;
  }

  function deposit(uint256 amount) public {
    require(msg.sender == superAdmin, "not an admin");
    require(amount > 0, "zero");
    strongToken.transferFrom(msg.sender, address(this), amount);
    rewardBalance = rewardBalance.add(amount);
  }

  function withdraw(address destination, uint256 amount) public {
    require(msg.sender == superAdmin, "not an admin");
    require(amount > 0, "zero");
    require(rewardBalance >= amount, "not enough");
    strongToken.transfer(destination, amount);
    rewardBalance = rewardBalance.sub(amount);
  }

  // CORE
  // *************************************************************************************
  function getVoterServices(address voter) public view returns (address[] memory) {
    return voterServices[voter];
  }

  function getVoterServiceEntities(address voter, address service) public view returns (address[] memory) {
    return voterServiceEntities[voter][service];
  }

  function getVoterReward(address voter) public view returns (uint256) {
    uint256 blockLastClaimedOn = voterBlockLastClaimedOn[voter];

    if (totalVotesOut == 0) return 0;
    if (blockLastClaimedOn == 0) return 0;

    uint256[2] memory rewardBlocks = rewards.blocks(blockLastClaimedOn, rewardPerBlockNewEffectiveBlock, block.number);
    uint256 rewardOld = voterRewardPerBlockNumerator > 0 ? rewardBlocks[0].mul(voterRewardPerBlockNumerator).div(voterRewardPerBlockDenominator) : 0;
    uint256 rewardNew = voterRewardPerBlockNumeratorNew > 0 ? rewardBlocks[1].mul(voterRewardPerBlockNumeratorNew).div(voterRewardPerBlockDenominatorNew) : 0;

    return rewardOld.add(rewardNew).mul(voterVotesOut[voter]).div(totalVotesOut);
  }

  function getEntityReward(address service, address entity) public view returns (uint256) {
    uint256 blockLastClaimedOn = serviceEntityBlockLastClaimedOn[service][entity];

    if (serviceVotes[service] == 0) return 0;
    if (blockLastClaimedOn == 0) return 0;

    uint256[2] memory rewardBlocks = rewards.blocks(blockLastClaimedOn, rewardPerBlockNewEffectiveBlock, block.number);
    uint256 rewardOld = entityRewardPerBlockNumerator > 0 ? rewardBlocks[0].mul(entityRewardPerBlockNumerator).div(entityRewardPerBlockDenominator) : 0;
    uint256 rewardNew = entityRewardPerBlockNumeratorNew > 0 ? rewardBlocks[1].mul(entityRewardPerBlockNumeratorNew).div(entityRewardPerBlockDenominatorNew) : 0;

    return rewardOld.add(rewardNew).mul(serviceEntityVotes[service][entity]).div(serviceVotes[service]);
  }

  function vote(
    address service,
    address entity,
    uint256 amount
  ) public {
    require(amount > 0, "zero");
    require(uint256(_getAvailableServiceEntityVotes(msg.sender)) >= amount, "not enough");
    require(serviceContractActive[service], "service not active");
    require(ServiceInterface(service).isEntityActive(entity), "entity not active");

    uint256 serviceIndex = voterServiceIndex[msg.sender][service];
    if (voterServices[msg.sender].length == 0 || voterServices[msg.sender][serviceIndex] != service) {
      uint256 len = voterServices[msg.sender].length;
      voterServiceIndex[msg.sender][service] = len;
      voterServices[msg.sender].push(service);
    }

    uint256 entityIndex = voterServiceEntityIndex[msg.sender][service][entity];
    if (
      voterServiceEntities[msg.sender][service].length == 0 ||
      voterServiceEntities[msg.sender][service][entityIndex] != entity
    ) {
      uint256 len = voterServiceEntities[msg.sender][service].length;
      voterServiceEntityIndex[msg.sender][service][entity] = len;
      voterServiceEntities[msg.sender][service].push(entity);
    }

    if (block.number > voterBlockLastClaimedOn[msg.sender]) {
      uint256 reward = getVoterReward(msg.sender);
      if (reward > 0) {
        rewardBalance = rewardBalance.sub(reward);
        strongToken.approve(address(strongPool), reward);
        strongPool.mineFor(msg.sender, reward);
        voterBlockLastClaimedOn[msg.sender] = block.number;
      }
    }

    if (block.number > serviceEntityBlockLastClaimedOn[service][entity]) {
      uint256 reward = getEntityReward(service, entity);
      if (reward > 0) {
        rewardBalance = rewardBalance.sub(reward);
        strongToken.approve(address(strongPool), reward);
        strongPool.mineFor(entity, reward);
        serviceEntityBlockLastClaimedOn[service][entity] = block.number;
      }
    }

    serviceVotes[service] = serviceVotes[service].add(amount);
    serviceEntityVotes[service][entity] = serviceEntityVotes[service][entity].add(amount);
    voterServiceEntityVotes[msg.sender][service][entity] = voterServiceEntityVotes[msg.sender][service][entity].add(
      amount
    );

    voterVotesOut[msg.sender] = voterVotesOut[msg.sender].add(amount);
    totalVotesOut = totalVotesOut.add(amount);

    if (voterBlockLastClaimedOn[msg.sender] == 0) {
      voterBlockLastClaimedOn[msg.sender] = block.number;
    }

    if (serviceEntityBlockLastClaimedOn[service][entity] == 0) {
      serviceEntityBlockLastClaimedOn[service][entity] = block.number;
    }

    emit Voted(msg.sender, service, entity, amount);
  }

  function recallVote(
    address service,
    address entity,
    uint256 amount
  ) public {
    require(amount > 0, "zero");
    require(voterServiceEntityVotes[msg.sender][service][entity] >= amount, "not enough");

    if (block.number > voterBlockLastClaimedOn[msg.sender]) {
      uint256 reward = getVoterReward(msg.sender);
      if (reward > 0) {
        rewardBalance = rewardBalance.sub(reward);
        strongToken.approve(address(strongPool), reward);
        strongPool.mineFor(msg.sender, reward);
        voterBlockLastClaimedOn[msg.sender] = block.number;
      }
    }

    if (block.number > serviceEntityBlockLastClaimedOn[service][entity]) {
      uint256 reward = getEntityReward(service, entity);
      if (reward > 0) {
        rewardBalance = rewardBalance.sub(reward);
        strongToken.approve(address(strongPool), reward);
        strongPool.mineFor(entity, reward);
        serviceEntityBlockLastClaimedOn[service][entity] = block.number;
      }
    }

    serviceVotes[service] = serviceVotes[service].sub(amount);
    serviceEntityVotes[service][entity] = serviceEntityVotes[service][entity].sub(amount);
    voterServiceEntityVotes[msg.sender][service][entity] = voterServiceEntityVotes[msg.sender][service][entity].sub(
      amount
    );

    voterVotesOut[msg.sender] = voterVotesOut[msg.sender].sub(amount);
    totalVotesOut = totalVotesOut.sub(amount);

    if (voterVotesOut[msg.sender] == 0) {
      voterBlockLastClaimedOn[msg.sender] = 0;
    }

    if (serviceEntityVotes[service][entity] == 0) {
      serviceEntityBlockLastClaimedOn[service][entity] = 0;
    }
    emit RecalledVote(msg.sender, service, entity, amount);
  }

  function voterClaim() public {
    require(voterBlockLastClaimedOn[msg.sender] != 0, "error");
    require(block.number > voterBlockLastClaimedOn[msg.sender], "too soon");
    uint256 reward = getVoterReward(msg.sender);
    require(reward > 0, "no reward");
    rewardBalance = rewardBalance.sub(reward);
    strongToken.approve(address(strongPool), reward);
    strongPool.mineFor(msg.sender, reward);
    voterBlockLastClaimedOn[msg.sender] = block.number;
    emit Claimed(msg.sender, reward);
  }

  function entityClaim(address service) public {
    require(serviceEntityBlockLastClaimedOn[service][msg.sender] != 0, "error");
    require(block.number > serviceEntityBlockLastClaimedOn[service][msg.sender], "too soon");
    require(ServiceInterface(service).isEntityActive(msg.sender), "not active");
    uint256 reward = getEntityReward(service, msg.sender);
    require(reward > 0, "no reward");
    rewardBalance = rewardBalance.sub(reward);
    strongToken.approve(address(strongPool), reward);
    strongPool.mineFor(msg.sender, reward);
    serviceEntityBlockLastClaimedOn[service][msg.sender] = block.number;
    emit Claimed(msg.sender, reward);
  }

  function updateVotes(
    address voter,
    uint256 rawAmount,
    bool adding
  ) public {
    require(msg.sender == address(strongPool), "not strongPool");
    uint96 amount = _safe96(rawAmount, "amount exceeds 96 bits");
    if (adding) {
      _addVotes(voter, amount);
    } else {
      require(_getAvailableServiceEntityVotes(voter) >= amount, "recall votes");
      _subVotes(voter, amount);
    }
  }

  function getCurrentProposalVotes(address account) external view returns (uint96) {
    return _getCurrentProposalVotes(account);
  }

  function getPriorProposalVotes(address account, uint256 blockNumber) external view returns (uint96) {
    require(blockNumber < block.number, "not yet determined");
    uint32 nCheckpoints = numCheckpoints[account];
    if (nCheckpoints == 0) {
      return 0;
    }
    if (checkpointsFromBlock[account][nCheckpoints - 1] <= blockNumber) {
      return checkpointsVotes[account][nCheckpoints - 1];
    }
    if (checkpointsFromBlock[account][0] > blockNumber) {
      return 0;
    }
    uint32 lower = 0;
    uint32 upper = nCheckpoints - 1;
    while (upper > lower) {
      uint32 center = upper - (upper - lower) / 2;
      uint32 fromBlock = checkpointsFromBlock[account][center];
      uint96 votes = checkpointsVotes[account][center];
      if (fromBlock == blockNumber) {
        return votes;
      } else if (fromBlock < blockNumber) {
        lower = center;
      } else {
        upper = center - 1;
      }
    }
    return checkpointsVotes[account][lower];
  }

  function getAvailableServiceEntityVotes(address account) public view returns (uint96) {
    return _getAvailableServiceEntityVotes(account);
  }

  // SUPPORT
  // *************************************************************************************
  function _addVotes(address voter, uint96 amount) internal {
    require(voter != address(0), "zero address");
    balances[voter] = _add96(balances[voter], amount, "vote amount overflows");
    _addDelegates(voter, amount);
    emit VotesAdded(voter, amount);
  }

  function _subVotes(address voter, uint96 amount) internal {
    balances[voter] = _sub96(balances[voter], amount, "vote amount exceeds balance");
    _subtractDelegates(voter, amount);
    emit VotesSubtracted(voter, amount);
  }

  function _addDelegates(address miner, uint96 amount) internal {
    if (delegates[miner] == address(0)) {
      delegates[miner] = miner;
    }
    address currentDelegate = delegates[miner];
    _moveDelegates(address(0), currentDelegate, amount);
  }

  function _subtractDelegates(address miner, uint96 amount) internal {
    address currentDelegate = delegates[miner];
    _moveDelegates(currentDelegate, address(0), amount);
  }

  function _moveDelegates(
    address srcRep,
    address dstRep,
    uint96 amount
  ) internal {
    if (srcRep != dstRep && amount > 0) {
      if (srcRep != address(0)) {
        uint32 srcRepNum = numCheckpoints[srcRep];
        uint96 srcRepOld = srcRepNum > 0 ? checkpointsVotes[srcRep][srcRepNum - 1] : 0;
        uint96 srcRepNew = _sub96(srcRepOld, amount, "vote amount underflows");
        _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
      }
      if (dstRep != address(0)) {
        uint32 dstRepNum = numCheckpoints[dstRep];
        uint96 dstRepOld = dstRepNum > 0 ? checkpointsVotes[dstRep][dstRepNum - 1] : 0;
        uint96 dstRepNew = _add96(dstRepOld, amount, "vote amount overflows");
        _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
      }
    }
  }

  function _writeCheckpoint(
    address delegatee,
    uint32 nCheckpoints,
    uint96 oldVotes,
    uint96 newVotes
  ) internal {
    uint32 blockNumber = _safe32(block.number, "block number exceeds 32 bits");
    if (nCheckpoints > 0 && checkpointsFromBlock[delegatee][nCheckpoints - 1] == blockNumber) {
      checkpointsVotes[delegatee][nCheckpoints - 1] = newVotes;
    } else {
      checkpointsFromBlock[delegatee][nCheckpoints] = blockNumber;
      checkpointsVotes[delegatee][nCheckpoints] = newVotes;
      numCheckpoints[delegatee] = nCheckpoints + 1;
    }

    emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
  }

  function _safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) {
    require(n < 2**32, errorMessage);
    return uint32(n);
  }

  function _safe96(uint256 n, string memory errorMessage) internal pure returns (uint96) {
    require(n < 2**96, errorMessage);
    return uint96(n);
  }

  function _add96(
    uint96 a,
    uint96 b,
    string memory errorMessage
  ) internal pure returns (uint96) {
    uint96 c = a + b;
    require(c >= a, errorMessage);
    return c;
  }

  function _sub96(
    uint96 a,
    uint96 b,
    string memory errorMessage
  ) internal pure returns (uint96) {
    require(b <= a, errorMessage);
    return a - b;
  }

  function _getCurrentProposalVotes(address account) internal view returns (uint96) {
    uint32 nCheckpoints = numCheckpoints[account];
    return nCheckpoints > 0 ? checkpointsVotes[account][nCheckpoints - 1] : 0;
  }

  function _getAvailableServiceEntityVotes(address account) internal view returns (uint96) {
    uint96 proposalVotes = _getCurrentProposalVotes(account);
    return proposalVotes == 0 ? 0 : proposalVotes - _safe96(voterVotesOut[account], "voterVotesOut exceeds 96 bits");
  }

  function updateRewardPerBlockNew(
    uint256 numeratorVoter,
    uint256 denominatorVoter,
    uint256 numeratorEntity,
    uint256 denominatorEntity,
    uint256 effectiveBlock
  ) public {
    require(msg.sender == admin || msg.sender == parameterAdmin || msg.sender == superAdmin, "not admin");

    voterRewardPerBlockNumeratorNew = numeratorVoter;
    voterRewardPerBlockDenominatorNew = denominatorVoter;
    entityRewardPerBlockNumeratorNew = numeratorEntity;
    entityRewardPerBlockDenominatorNew = denominatorEntity;
    rewardPerBlockNewEffectiveBlock = effectiveBlock != 0 ? effectiveBlock : block.number;
  }
}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"miner","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"Claimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"miner","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Mined","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"miner","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"MinedFor","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"miner","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"MinedForVotesOnly","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"miner","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Unmined","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"miner","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UnminedForVotesOnly","type":"event"},{"inputs":[],"name":"acceptAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"acceptSuperAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"contr","type":"address"}],"name":"addInboundContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"claim","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"claimingFeeDenominator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimingFeeInWei","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimingFeeNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeCollector","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"miner","type":"address"}],"name":"getReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"miner","type":"address"},{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"getRewardByBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"inboundContractIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"contr","type":"address"},{"internalType":"bool","name":"trustStatus","type":"bool"}],"name":"inboundContractTrustStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"inboundContractTrusted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"inboundContracts","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"voteAddress","type":"address"},{"internalType":"address","name":"strongTokenAddress","type":"address"},{"internalType":"address","name":"adminAddress","type":"address"},{"internalType":"address","name":"superAdminAddress","type":"address"},{"internalType":"uint256","name":"rewardPerBlockNumeratorValue","type":"uint256"},{"internalType":"uint256","name":"rewardPerBlockDenominatorValue","type":"uint256"},{"internalType":"uint256","name":"miningFeeNumeratorValue","type":"uint256"},{"internalType":"uint256","name":"miningFeeDenominatorValue","type":"uint256"},{"internalType":"uint256","name":"unminingFeeNumeratorValue","type":"uint256"},{"internalType":"uint256","name":"unminingFeeDenominatorValue","type":"uint256"},{"internalType":"uint256","name":"claimingFeeNumeratorValue","type":"uint256"},{"internalType":"uint256","name":"claimingFeeDenominatorValue","type":"uint256"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initDone","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mine","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"miner","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mineFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mineForVotesOnly","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"minerBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"minerBlockLastClaimedOn","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"minerVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"miningFeeDenominator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"miningFeeNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"parameterAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingSuperAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"removedTokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerBlockDenominator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerBlockDenominatorNew","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerBlockNewEffectiveBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerBlockNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerBlockNumeratorNew","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newPendingAdmin","type":"address"}],"name":"setPendingAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newPendingSuperAdmin","type":"address"}],"name":"setPendingSuperAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"strongToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"superAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"unmine","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"unmineForVotesOnly","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unminingFeeDenominator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unminingFeeNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}],"name":"updateClaimingFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"newFeeCollector","type":"address"}],"name":"updateFeeCollector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}],"name":"updateMiningFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newParameterAdmin","type":"address"}],"name":"updateParameterAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}],"name":"updateRewardPerBlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"},{"internalType":"uint256","name":"effectiveBlock","type":"uint256"}],"name":"updateRewardPerBlockNew","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}],"name":"updateUnminingFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vote","outputs":[{"internalType":"contract VoteInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"destination","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50612ed3806100206000396000f3fe6080604052600436106103355760003560e01c806399e6f700116101ab578063c415b95c116100f7578063e7f9cefd11610095578063f3fef3a31161006f578063f3fef3a314610aae578063f426571514610ae7578063f851a44014610b04578063fed0a20e14610b1957610335565b8063e7f9cefd14610a6f578063ed5998da14610a84578063ef56a08b14610a9957610335565b8063d2c35ce8116100d1578063d2c35ce8146109c1578063d39ca7de146109f4578063db588ec214610a27578063e771e91a14610a3c57610335565b8063c415b95c14610964578063cb454ec914610979578063ce77beaf146109ac57610335565b8063b1dfb9b311610164578063c00007b01161013e578063c00007b0146108d4578063c0f0622d14610907578063c2acf7ea1461091c578063c2b2fdca1461094f57610335565b8063b1dfb9b31461082a578063b6b55f2514610863578063be69283e1461088d57610335565b806399e6f70014610755578063a84ffad51461076a578063aa5c3ab41461079a578063abb1c39b146107af578063ad7a672f146107df578063b0e8a45d146107f457610335565b806348028d6311610285578063683a229f1161022357806387f48f4e116101fd57806387f48f4e146106c85780638aa9a37f146106dd5780638b70f3591461070d578063965d61b91461074057610335565b8063683a229f1461061c5780637a5d5cf41461069e578063857d49d5146106b357610335565b80634dd18bf51161025f5780634dd18bf514610584578063546f9354146105b75780635b7f6ea8146105f2578063632a9a521461060757610335565b806348028d63146105285780634d04ad991461053d5780634d4748981461056757610335565b80631d851bbd116102f257806330d6a975116102cc57806330d6a9751461046c578063379607f5146104a557806337e4c4ae146104c257806340b584b4146104f557610335565b80631d851bbd1461042d578063267822471461044257806329575f6a1461045757610335565b806309a07fd21461033a5780630a8d1be2146103615780630e18b681146103935780630f07aa62146103a85780631246af89146103ee5780631988589814610418575b600080fd5b34801561034657600080fd5b5061034f610b2e565b60408051918252519081900360200190f35b34801561036d57600080fd5b506103916004803603604081101561038457600080fd5b5080359060200135610b34565b005b34801561039f57600080fd5b50610391610bfe565b3480156103b457600080fd5b506103d2600480360360208110156103cb57600080fd5b5035610c8d565b604080516001600160a01b039092168252519081900360200190f35b3480156103fa57600080fd5b506103916004803603602081101561041157600080fd5b5035610cb4565b34801561042457600080fd5b5061034f610e4d565b34801561043957600080fd5b5061034f610e53565b34801561044e57600080fd5b506103d2610e59565b34801561046357600080fd5b506103d2610e68565b34801561047857600080fd5b506103916004803603604081101561048f57600080fd5b506001600160a01b038135169060200135610e77565b610391600480360360208110156104bb57600080fd5b50356110c9565b3480156104ce57600080fd5b50610391600480360360208110156104e557600080fd5b50356001600160a01b03166113a2565b34801561050157600080fd5b506103916004803603602081101561051857600080fd5b50356001600160a01b0316611561565b34801561053457600080fd5b506103d26115de565b34801561054957600080fd5b506103916004803603602081101561056057600080fd5b50356115ed565b6103916004803603602081101561057d57600080fd5b50356117d1565b34801561059057600080fd5b50610391600480360360208110156105a757600080fd5b50356001600160a01b0316611b38565b3480156105c357600080fd5b50610391600480360360408110156105da57600080fd5b506001600160a01b0381351690602001351515611bee565b3480156105fe57600080fd5b5061034f611d59565b34801561061357600080fd5b506103d2611d5f565b34801561062857600080fd5b50610391600480360361018081101561064057600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359091169060808101359060a08101359060c08101359060e0810135906101008101359061012081013590610140810135906101600135611d6e565b3480156106aa57600080fd5b5061034f611e3c565b3480156106bf57600080fd5b506103d2611e42565b3480156106d457600080fd5b5061034f611e51565b3480156106e957600080fd5b506103916004803603604081101561070057600080fd5b5080359060200135611e57565b34801561071957600080fd5b5061034f6004803603602081101561073057600080fd5b50356001600160a01b0316611f21565b34801561074c57600080fd5b506103d2611f33565b34801561076157600080fd5b5061034f611f42565b34801561077657600080fd5b506103916004803603604081101561078d57600080fd5b5080359060200135611f48565b3480156107a657600080fd5b5061034f612012565b3480156107bb57600080fd5b50610391600480360360408110156107d257600080fd5b5080359060200135612018565b3480156107eb57600080fd5b5061034f6120e2565b34801561080057600080fd5b506103916004803603606081101561081757600080fd5b50803590602081013590604001356120e8565b34801561083657600080fd5b5061034f6004803603604081101561084d57600080fd5b506001600160a01b038135169060200135612181565b34801561086f57600080fd5b506103916004803603602081101561088657600080fd5b503561229c565b34801561089957600080fd5b506108c0600480360360208110156108b057600080fd5b50356001600160a01b03166123c1565b604080519115158252519081900360200190f35b3480156108e057600080fd5b5061034f600480360360208110156108f757600080fd5b50356001600160a01b03166123d6565b34801561091357600080fd5b506108c06123e2565b34801561092857600080fd5b5061034f6004803603602081101561093f57600080fd5b50356001600160a01b03166123eb565b34801561095b57600080fd5b5061034f6123fd565b34801561097057600080fd5b506103d2612403565b34801561098557600080fd5b5061034f6004803603602081101561099c57600080fd5b50356001600160a01b0316612412565b3480156109b857600080fd5b5061034f612424565b3480156109cd57600080fd5b50610391600480360360208110156109e457600080fd5b50356001600160a01b031661242a565b348015610a0057600080fd5b5061039160048036036020811015610a1757600080fd5b50356001600160a01b03166124a7565b348015610a3357600080fd5b5061034f61255d565b348015610a4857600080fd5b5061034f60048036036020811015610a5f57600080fd5b50356001600160a01b0316612563565b348015610a7b57600080fd5b50610391612575565b348015610a9057600080fd5b5061034f6125fe565b348015610aa557600080fd5b5061034f612604565b348015610aba57600080fd5b5061039160048036036040811015610ad157600080fd5b506001600160a01b03813516906020013561260a565b61039160048036036020811015610afd57600080fd5b5035612770565b348015610b1057600080fd5b506103d2612b56565b348015610b2557600080fd5b506108c0612b6a565b60135481565b60005461010090046001600160a01b0316331480610b5c57506004546001600160a01b031633145b80610b7157506002546001600160a01b031633145b610bb1576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b80610bf3576040805162461bcd60e51b815260206004820152600d60248201526c696e76616c69642076616c756560981b604482015290519081900360640190fd5b600d91909155600e55565b6001546001600160a01b031633148015610c1757503315155b610c5b576040805162461bcd60e51b815260206004820152601060248201526f3737ba103832b73234b733a0b236b4b760811b604482015290519081900360640190fd5b6001805460008054610100600160a81b0319166101006001600160a01b038416021790556001600160a01b0319169055565b60168181548110610c9a57fe5b6000918252602090912001546001600160a01b0316905081565b60008111610cf2576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b600654604080516323b872dd60e01b81523360048201523060248201526044810184905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b158015610d4c57600080fd5b505af1158015610d60573d6000803e3d6000fd5b505050506040513d6020811015610d7657600080fd5b5050336000908152600b6020526040902054610d929082612b73565b336000818152600b6020526040808220939093556007548351639fb9ec1160e01b81526004810193909352602483018590526001604484015292516001600160a01b0390931692639fb9ec1192606480820193929182900301818387803b158015610dfc57600080fd5b505af1158015610e10573d6000803e3d6000fd5b50506040805184815290513393507ff37db06620b96226404d091596ee3290dd042d17dc5c440a97876ffbb5d0886092509081900360200190a250565b600e5481565b601c5481565b6001546001600160a01b031681565b6002546001600160a01b031681565b3360009081526017602052604090205460ff16610ec9576040805162461bcd60e51b815260206004820152600b60248201526a1b9bdd081d1c9d5cdd195960aa1b604482015290519081900360640190fd5b60008111610f07576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b600654604080516323b872dd60e01b81523360048201523060248201526044810184905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b158015610f6157600080fd5b505af1158015610f75573d6000803e3d6000fd5b505050506040513d6020811015610f8b57600080fd5b50506001600160a01b038216600090815260086020526040902054610fb09082612b73565b6001600160a01b038316600090815260086020526040902055600954610fd69082612b73565b6009556001600160a01b0382166000908152600a6020526040902054611012576001600160a01b0382166000908152600a602052604090204390555b60075460408051639fb9ec1160e01b81526001600160a01b038581166004830152602482018590526001604483015291519190921691639fb9ec1191606480830192600092919082900301818387803b15801561106e57600080fd5b505af1158015611082573d6000803e3d6000fd5b50506040805184815290516001600160a01b03861693507f4995275d5fede9791a4f176a8aa7d0fea6c316f6ba53693c3acd58ee707a719692509081900360200190a25050565b43811115611115576040805162461bcd60e51b815260206004820152601460248201527334b73b30b634b210313637b1b590373ab6b132b960611b604482015290519081900360640190fd5b336000908152600a602052604090205461115e576040805162461bcd60e51b815260206004820152600560248201526432b93937b960d91b604482015290519081900360640190fd5b336000908152600a602052604090205481116111ac576040805162461bcd60e51b81526020600482015260086024820152673a37b79039b7b7b760c11b604482015290519081900360640190fd5b60006111b83383612181565b9050600081116111fb576040805162461bcd60e51b81526020600482015260096024820152681b9bc81c995dd85c9960ba1b604482015290519081900360640190fd5b600061121e60145461121860135485612bd490919063ffffffff16565b90612c2d565b9050803414611262576040805162461bcd60e51b815260206004820152600b60248201526a696e76616c69642066656560a81b604482015290519081900360640190fd5b6005546040516001600160a01b03909116903480156108fc02916000818181858888f1935050505015801561129b573d6000803e3d6000fd5b50336000908152600860205260409020546112b69083612b73565b336000908152600860205260409020556009546112d39083612b73565b600955600c546112e39083612c6f565b600c55336000818152600a60205260408082208690556007548151639fb9ec1160e01b81526004810194909452602484018690526001604485015290516001600160a01b0390911692639fb9ec1192606480830193919282900301818387803b15801561134f57600080fd5b505af1158015611363573d6000803e3d6000fd5b50506040805185815290513393507fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a92509081900360200190a2505050565b6001600160a01b0381166113e6576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b60005461010090046001600160a01b031633148061140e57506004546001600160a01b031633145b8061142357506002546001600160a01b031633145b611463576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b601654156114e8576001600160a01b038116600081815260156020526040902054601680549192918390811061149557fe5b6000918252602090912001546001600160a01b031614156114e6576040805162461bcd60e51b815260206004820152600660248201526565786973747360d01b604482015290519081900360640190fd5b505b601680546001600160a01b0390921660008181526015602090815260408083209590955560179052928320805460ff1916600190811790915582549081018355919092527fd833147d7dc355ba459fc788f669e58cfaf9dc25ddcd0702e87d69c7b51242890180546001600160a01b0319169091179055565b6001600160a01b0381166115a5576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b6002546001600160a01b031633146115bc57600080fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6003546001600160a01b031681565b6000811161162b576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b336000908152600b602052604090205481111561167c576040805162461bcd60e51b815260206004820152600a6024820152690dcdee840cadcdeeaced60b31b604482015290519081900360640190fd5b336000908152600b60205260409020546116969082612c6f565b336000818152600b6020526040808220939093556007548351639fb9ec1160e01b81526004810193909352602483018590526044830182905292516001600160a01b0390931692639fb9ec1192606480820193929182900301818387803b15801561170057600080fd5b505af1158015611714573d6000803e3d6000fd5b50506006546040805163a9059cbb60e01b81523360048201526024810186905290516001600160a01b03909216935063a9059cbb92506044808201926020929091908290030181600087803b15801561176c57600080fd5b505af1158015611780573d6000803e3d6000fd5b505050506040513d602081101561179657600080fd5b505060408051828152905133917f6d45e65025b4e5354fca7fcb828878818b16573fe504e384472faa881216dd5a919081900360200190a250565b6000811161180f576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b600061182c601054611218600f5485612bd490919063ffffffff16565b9050803414611870576040805162461bcd60e51b815260206004820152600b60248201526a696e76616c69642066656560a81b604482015290519081900360640190fd5b6005546040516001600160a01b03909116903480156108fc02916000818181858888f193505050501580156118a9573d6000803e3d6000fd5b50600654604080516323b872dd60e01b81523360048201523060248201526044810185905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b15801561190457600080fd5b505af1158015611918573d6000803e3d6000fd5b505050506040513d602081101561192e57600080fd5b5050336000908152600a6020526040902054431115611a2b576000611952336123d6565b90508015611a2957336000908152600860205260409020546119749082612b73565b336000908152600860205260409020556009546119919082612b73565b600955600c546119a19082612c6f565b600c5560075460408051639fb9ec1160e01b8152336004820152602481018490526001604482015290516001600160a01b0390921691639fb9ec119160648082019260009290919082900301818387803b1580156119fe57600080fd5b505af1158015611a12573d6000803e3d6000fd5b5050336000908152600a6020526040902043905550505b505b33600090815260086020526040902054611a459083612b73565b33600090815260086020526040902055600954611a629083612b73565b600955336000908152600a6020526040902054611a8c57336000908152600a602052604090204390555b60075460408051639fb9ec1160e01b8152336004820152602481018590526001604482015290516001600160a01b0390921691639fb9ec119160648082019260009290919082900301818387803b158015611ae657600080fd5b505af1158015611afa573d6000803e3d6000fd5b50506040805185815290513393507f3ad10ba9777a3bc21180a465e5459861d07cbdb271af9a0f10c993b365b760f892509081900360200190a25050565b6001600160a01b038116611b7c576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b60005461010090046001600160a01b03163314611bcc576040805162461bcd60e51b81526020600482015260096024820152683737ba1030b236b4b760b91b604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038216611c32576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b60005461010090046001600160a01b0316331480611c5a57506004546001600160a01b031633145b80611c6f57506002546001600160a01b031633145b611caf576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b6001600160a01b0382166000818152601560205260409020546016805491929183908110611cd957fe5b6000918252602090912001546001600160a01b031614611d2d576040805162461bcd60e51b815260206004820152600a6024820152696e6f742065786973747360b01b604482015290519081900360640190fd5b506001600160a01b03919091166000908152601760205260409020805460ff1916911515919091179055565b600f5481565b6007546001600160a01b031681565b60005460ff1615611db2576040805162461bcd60e51b8152602060048201526009602482015268696e697420646f6e6560b81b604482015290519081900360640190fd5b600780546001600160a01b03199081166001600160a01b039e8f16179091556006805482169c8e169c909c17909b556000805460028054909d169a8e169a909a17909b55600d97909755600e95909555600f93909355601091909155601155601255601355601455610100600160a81b03191661010091909316029190911760ff19166001179055565b601a5481565b6004546001600160a01b031681565b60145481565b60005461010090046001600160a01b0316331480611e7f57506004546001600160a01b031633145b80611e9457506002546001600160a01b031633145b611ed4576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b80611f16576040805162461bcd60e51b815260206004820152600d60248201526c696e76616c69642076616c756560981b604482015290519081900360640190fd5b601391909155601455565b600a6020526000908152604090205481565b6006546001600160a01b031681565b600d5481565b60005461010090046001600160a01b0316331480611f7057506004546001600160a01b031633145b80611f8557506002546001600160a01b031633145b611fc5576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b80612007576040805162461bcd60e51b815260206004820152600d60248201526c696e76616c69642076616c756560981b604482015290519081900360640190fd5b600f91909155601055565b600c5481565b60005461010090046001600160a01b031633148061204057506004546001600160a01b031633145b8061205557506002546001600160a01b031633145b612095576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b806120d7576040805162461bcd60e51b815260206004820152600d60248201526c696e76616c69642076616c756560981b604482015290519081900360640190fd5b601191909155601255565b60095481565b60005461010090046001600160a01b031633148061211057506004546001600160a01b031633145b8061212557506002546001600160a01b031633145b612162576040805162461bcd60e51b81526020600482015260096024820152683737ba1030b236b4b760b91b604482015290519081900360640190fd5b601a839055601b829055806121775743612179565b805b601c55505050565b6001600160a01b0382166000908152600a6020526040812054438311156121ac576000915050612296565b806121bb576000915050612296565b808310156121cd576000915050612296565b6009546121de576000915050612296565b6121e6612e5e565b6121f382601c5486612cb1565b9050600080600e541161220757600061222b565b61222b600e54611218600d548560006002811061222057fe5b602002015190612bd4565b9050600080601b541161223f576000612258565b612258601b54611218601a548660016002811061222057fe5b6009546001600160a01b03891660009081526008602052604090205491925061228f91611218906122898686612b73565b90612bd4565b9450505050505b92915050565b6002546001600160a01b031633146122ea576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b60008111612328576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b600654604080516323b872dd60e01b81523360048201523060248201526044810184905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b15801561238257600080fd5b505af1158015612396573d6000803e3d6000fd5b505050506040513d60208110156123ac57600080fd5b5050600c546123bb9082612b73565b600c5550565b60176020526000908152604090205460ff1681565b60006122968243612181565b60195460ff1681565b60156020526000908152604090205481565b60185481565b6005546001600160a01b031681565b600b6020526000908152604090205481565b60115481565b6001600160a01b03811661246e576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b6002546001600160a01b0316331461248557600080fd5b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166124eb576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b6002546001600160a01b0316331461253b576040805162461bcd60e51b815260206004820152600e60248201526d3737ba1039bab832b920b236b4b760911b604482015290519081900360640190fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b60125481565b60086020526000908152604090205481565b6003546001600160a01b03163314801561258e57503315155b6125d7576040805162461bcd60e51b81526020600482015260156024820152743737ba103832b73234b733a9bab832b920b236b4b760591b604482015290519081900360640190fd5b60038054600280546001600160a01b03199081166001600160a01b03841617909155169055565b601b5481565b60105481565b6002546001600160a01b03163314612658576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b60008111612696576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b80600c5410156126da576040805162461bcd60e51b815260206004820152600a6024820152690dcdee840cadcdeeaced60b31b604482015290519081900360640190fd5b6006546040805163a9059cbb60e01b81526001600160a01b038581166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b15801561273057600080fd5b505af1158015612744573d6000803e3d6000fd5b505050506040513d602081101561275a57600080fd5b5050600c546127699082612c6f565b600c555050565b600081116127ae576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b60006127cb60125461121860115485612bd490919063ffffffff16565b905080341461280f576040805162461bcd60e51b815260206004820152600b60248201526a696e76616c69642066656560a81b604482015290519081900360640190fd5b33600090815260086020526040902054821115612860576040805162461bcd60e51b815260206004820152600a6024820152690dcdee840cadcdeeaced60b31b604482015290519081900360640190fd5b6005546040516001600160a01b03909116903480156108fc02916000818181858888f19350505050158015612899573d6000803e3d6000fd5b5033600090815260086020908152604080832054600a90925290912054908314904311156129a55760006128cc336123d6565b905080156129a357336000908152600860205260409020546128ee9082612b73565b3360009081526008602052604090205560095461290b9082612b73565b600955600c5461291b9082612c6f565b600c5560075460408051639fb9ec1160e01b8152336004820152602481018490526001604482015290516001600160a01b0390921691639fb9ec119160648082019260009290919082900301818387803b15801561297857600080fd5b505af115801561298c573d6000803e3d6000fd5b5050336000908152600a6020526040902043905550505b505b6000816129b257836129c3565b336000908152600860205260409020545b336000908152600860205260409020549091506129e09082612c6f565b336000908152600860205260409020556009546129fd9082612c6f565b6009556006546040805163a9059cbb60e01b81523360048201526024810184905290516001600160a01b039092169163a9059cbb916044808201926020929091908290030181600087803b158015612a5457600080fd5b505af1158015612a68573d6000803e3d6000fd5b505050506040513d6020811015612a7e57600080fd5b505060075460408051639fb9ec1160e01b81523360048201526024810184905260006044820181905291516001600160a01b0390931692639fb9ec119260648084019391929182900301818387803b158015612ad957600080fd5b505af1158015612aed573d6000803e3d6000fd5b50503360009081526008602052604090205415159150612b1a905057336000908152600a60205260408120555b60408051828152905133917f53d02005d2e370ce08a8b60d65e07879891c336e6513821a3923f11854b54027919081900360200190a250505050565b60005461010090046001600160a01b031681565b60005460ff1681565b600082820183811015612bcd576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b600082612be357506000612296565b82820282848281612bf057fe5b0414612bcd5760405162461bcd60e51b8152600401808060200182810382526021815260200180612e7d6021913960400191505060405180910390fd5b6000612bcd83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612d62565b6000612bcd83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612e04565b612cb9612e5e565b818410612cda57506040805180820190915260008082526020820152612bcd565b8282111580612ce7575082155b15612d12576040805180820190915280612d018487612c6f565b815260200160008152509050612bcd565b828410612d3e57604080518082019091526000815260208101612d358487612c6f565b90529050612bcd565b6040805180820190915280612d538587612c6f565b8152602001612d358486612c6f565b60008183612dee5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612db3578181015183820152602001612d9b565b50505050905090810190601f168015612de05780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581612dfa57fe5b0495945050505050565b60008184841115612e565760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612db3578181015183820152602001612d9b565b505050900390565b6040518060400160405280600290602082028036833750919291505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220f642b1472fb190b44166602253d11a613cd7b7c5a7a56e19282a156bc42f0d4264736f6c634300060c0033

Deployed Bytecode

0x6080604052600436106103355760003560e01c806399e6f700116101ab578063c415b95c116100f7578063e7f9cefd11610095578063f3fef3a31161006f578063f3fef3a314610aae578063f426571514610ae7578063f851a44014610b04578063fed0a20e14610b1957610335565b8063e7f9cefd14610a6f578063ed5998da14610a84578063ef56a08b14610a9957610335565b8063d2c35ce8116100d1578063d2c35ce8146109c1578063d39ca7de146109f4578063db588ec214610a27578063e771e91a14610a3c57610335565b8063c415b95c14610964578063cb454ec914610979578063ce77beaf146109ac57610335565b8063b1dfb9b311610164578063c00007b01161013e578063c00007b0146108d4578063c0f0622d14610907578063c2acf7ea1461091c578063c2b2fdca1461094f57610335565b8063b1dfb9b31461082a578063b6b55f2514610863578063be69283e1461088d57610335565b806399e6f70014610755578063a84ffad51461076a578063aa5c3ab41461079a578063abb1c39b146107af578063ad7a672f146107df578063b0e8a45d146107f457610335565b806348028d6311610285578063683a229f1161022357806387f48f4e116101fd57806387f48f4e146106c85780638aa9a37f146106dd5780638b70f3591461070d578063965d61b91461074057610335565b8063683a229f1461061c5780637a5d5cf41461069e578063857d49d5146106b357610335565b80634dd18bf51161025f5780634dd18bf514610584578063546f9354146105b75780635b7f6ea8146105f2578063632a9a521461060757610335565b806348028d63146105285780634d04ad991461053d5780634d4748981461056757610335565b80631d851bbd116102f257806330d6a975116102cc57806330d6a9751461046c578063379607f5146104a557806337e4c4ae146104c257806340b584b4146104f557610335565b80631d851bbd1461042d578063267822471461044257806329575f6a1461045757610335565b806309a07fd21461033a5780630a8d1be2146103615780630e18b681146103935780630f07aa62146103a85780631246af89146103ee5780631988589814610418575b600080fd5b34801561034657600080fd5b5061034f610b2e565b60408051918252519081900360200190f35b34801561036d57600080fd5b506103916004803603604081101561038457600080fd5b5080359060200135610b34565b005b34801561039f57600080fd5b50610391610bfe565b3480156103b457600080fd5b506103d2600480360360208110156103cb57600080fd5b5035610c8d565b604080516001600160a01b039092168252519081900360200190f35b3480156103fa57600080fd5b506103916004803603602081101561041157600080fd5b5035610cb4565b34801561042457600080fd5b5061034f610e4d565b34801561043957600080fd5b5061034f610e53565b34801561044e57600080fd5b506103d2610e59565b34801561046357600080fd5b506103d2610e68565b34801561047857600080fd5b506103916004803603604081101561048f57600080fd5b506001600160a01b038135169060200135610e77565b610391600480360360208110156104bb57600080fd5b50356110c9565b3480156104ce57600080fd5b50610391600480360360208110156104e557600080fd5b50356001600160a01b03166113a2565b34801561050157600080fd5b506103916004803603602081101561051857600080fd5b50356001600160a01b0316611561565b34801561053457600080fd5b506103d26115de565b34801561054957600080fd5b506103916004803603602081101561056057600080fd5b50356115ed565b6103916004803603602081101561057d57600080fd5b50356117d1565b34801561059057600080fd5b50610391600480360360208110156105a757600080fd5b50356001600160a01b0316611b38565b3480156105c357600080fd5b50610391600480360360408110156105da57600080fd5b506001600160a01b0381351690602001351515611bee565b3480156105fe57600080fd5b5061034f611d59565b34801561061357600080fd5b506103d2611d5f565b34801561062857600080fd5b50610391600480360361018081101561064057600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359091169060808101359060a08101359060c08101359060e0810135906101008101359061012081013590610140810135906101600135611d6e565b3480156106aa57600080fd5b5061034f611e3c565b3480156106bf57600080fd5b506103d2611e42565b3480156106d457600080fd5b5061034f611e51565b3480156106e957600080fd5b506103916004803603604081101561070057600080fd5b5080359060200135611e57565b34801561071957600080fd5b5061034f6004803603602081101561073057600080fd5b50356001600160a01b0316611f21565b34801561074c57600080fd5b506103d2611f33565b34801561076157600080fd5b5061034f611f42565b34801561077657600080fd5b506103916004803603604081101561078d57600080fd5b5080359060200135611f48565b3480156107a657600080fd5b5061034f612012565b3480156107bb57600080fd5b50610391600480360360408110156107d257600080fd5b5080359060200135612018565b3480156107eb57600080fd5b5061034f6120e2565b34801561080057600080fd5b506103916004803603606081101561081757600080fd5b50803590602081013590604001356120e8565b34801561083657600080fd5b5061034f6004803603604081101561084d57600080fd5b506001600160a01b038135169060200135612181565b34801561086f57600080fd5b506103916004803603602081101561088657600080fd5b503561229c565b34801561089957600080fd5b506108c0600480360360208110156108b057600080fd5b50356001600160a01b03166123c1565b604080519115158252519081900360200190f35b3480156108e057600080fd5b5061034f600480360360208110156108f757600080fd5b50356001600160a01b03166123d6565b34801561091357600080fd5b506108c06123e2565b34801561092857600080fd5b5061034f6004803603602081101561093f57600080fd5b50356001600160a01b03166123eb565b34801561095b57600080fd5b5061034f6123fd565b34801561097057600080fd5b506103d2612403565b34801561098557600080fd5b5061034f6004803603602081101561099c57600080fd5b50356001600160a01b0316612412565b3480156109b857600080fd5b5061034f612424565b3480156109cd57600080fd5b50610391600480360360208110156109e457600080fd5b50356001600160a01b031661242a565b348015610a0057600080fd5b5061039160048036036020811015610a1757600080fd5b50356001600160a01b03166124a7565b348015610a3357600080fd5b5061034f61255d565b348015610a4857600080fd5b5061034f60048036036020811015610a5f57600080fd5b50356001600160a01b0316612563565b348015610a7b57600080fd5b50610391612575565b348015610a9057600080fd5b5061034f6125fe565b348015610aa557600080fd5b5061034f612604565b348015610aba57600080fd5b5061039160048036036040811015610ad157600080fd5b506001600160a01b03813516906020013561260a565b61039160048036036020811015610afd57600080fd5b5035612770565b348015610b1057600080fd5b506103d2612b56565b348015610b2557600080fd5b506108c0612b6a565b60135481565b60005461010090046001600160a01b0316331480610b5c57506004546001600160a01b031633145b80610b7157506002546001600160a01b031633145b610bb1576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b80610bf3576040805162461bcd60e51b815260206004820152600d60248201526c696e76616c69642076616c756560981b604482015290519081900360640190fd5b600d91909155600e55565b6001546001600160a01b031633148015610c1757503315155b610c5b576040805162461bcd60e51b815260206004820152601060248201526f3737ba103832b73234b733a0b236b4b760811b604482015290519081900360640190fd5b6001805460008054610100600160a81b0319166101006001600160a01b038416021790556001600160a01b0319169055565b60168181548110610c9a57fe5b6000918252602090912001546001600160a01b0316905081565b60008111610cf2576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b600654604080516323b872dd60e01b81523360048201523060248201526044810184905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b158015610d4c57600080fd5b505af1158015610d60573d6000803e3d6000fd5b505050506040513d6020811015610d7657600080fd5b5050336000908152600b6020526040902054610d929082612b73565b336000818152600b6020526040808220939093556007548351639fb9ec1160e01b81526004810193909352602483018590526001604484015292516001600160a01b0390931692639fb9ec1192606480820193929182900301818387803b158015610dfc57600080fd5b505af1158015610e10573d6000803e3d6000fd5b50506040805184815290513393507ff37db06620b96226404d091596ee3290dd042d17dc5c440a97876ffbb5d0886092509081900360200190a250565b600e5481565b601c5481565b6001546001600160a01b031681565b6002546001600160a01b031681565b3360009081526017602052604090205460ff16610ec9576040805162461bcd60e51b815260206004820152600b60248201526a1b9bdd081d1c9d5cdd195960aa1b604482015290519081900360640190fd5b60008111610f07576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b600654604080516323b872dd60e01b81523360048201523060248201526044810184905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b158015610f6157600080fd5b505af1158015610f75573d6000803e3d6000fd5b505050506040513d6020811015610f8b57600080fd5b50506001600160a01b038216600090815260086020526040902054610fb09082612b73565b6001600160a01b038316600090815260086020526040902055600954610fd69082612b73565b6009556001600160a01b0382166000908152600a6020526040902054611012576001600160a01b0382166000908152600a602052604090204390555b60075460408051639fb9ec1160e01b81526001600160a01b038581166004830152602482018590526001604483015291519190921691639fb9ec1191606480830192600092919082900301818387803b15801561106e57600080fd5b505af1158015611082573d6000803e3d6000fd5b50506040805184815290516001600160a01b03861693507f4995275d5fede9791a4f176a8aa7d0fea6c316f6ba53693c3acd58ee707a719692509081900360200190a25050565b43811115611115576040805162461bcd60e51b815260206004820152601460248201527334b73b30b634b210313637b1b590373ab6b132b960611b604482015290519081900360640190fd5b336000908152600a602052604090205461115e576040805162461bcd60e51b815260206004820152600560248201526432b93937b960d91b604482015290519081900360640190fd5b336000908152600a602052604090205481116111ac576040805162461bcd60e51b81526020600482015260086024820152673a37b79039b7b7b760c11b604482015290519081900360640190fd5b60006111b83383612181565b9050600081116111fb576040805162461bcd60e51b81526020600482015260096024820152681b9bc81c995dd85c9960ba1b604482015290519081900360640190fd5b600061121e60145461121860135485612bd490919063ffffffff16565b90612c2d565b9050803414611262576040805162461bcd60e51b815260206004820152600b60248201526a696e76616c69642066656560a81b604482015290519081900360640190fd5b6005546040516001600160a01b03909116903480156108fc02916000818181858888f1935050505015801561129b573d6000803e3d6000fd5b50336000908152600860205260409020546112b69083612b73565b336000908152600860205260409020556009546112d39083612b73565b600955600c546112e39083612c6f565b600c55336000818152600a60205260408082208690556007548151639fb9ec1160e01b81526004810194909452602484018690526001604485015290516001600160a01b0390911692639fb9ec1192606480830193919282900301818387803b15801561134f57600080fd5b505af1158015611363573d6000803e3d6000fd5b50506040805185815290513393507fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a92509081900360200190a2505050565b6001600160a01b0381166113e6576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b60005461010090046001600160a01b031633148061140e57506004546001600160a01b031633145b8061142357506002546001600160a01b031633145b611463576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b601654156114e8576001600160a01b038116600081815260156020526040902054601680549192918390811061149557fe5b6000918252602090912001546001600160a01b031614156114e6576040805162461bcd60e51b815260206004820152600660248201526565786973747360d01b604482015290519081900360640190fd5b505b601680546001600160a01b0390921660008181526015602090815260408083209590955560179052928320805460ff1916600190811790915582549081018355919092527fd833147d7dc355ba459fc788f669e58cfaf9dc25ddcd0702e87d69c7b51242890180546001600160a01b0319169091179055565b6001600160a01b0381166115a5576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b6002546001600160a01b031633146115bc57600080fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6003546001600160a01b031681565b6000811161162b576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b336000908152600b602052604090205481111561167c576040805162461bcd60e51b815260206004820152600a6024820152690dcdee840cadcdeeaced60b31b604482015290519081900360640190fd5b336000908152600b60205260409020546116969082612c6f565b336000818152600b6020526040808220939093556007548351639fb9ec1160e01b81526004810193909352602483018590526044830182905292516001600160a01b0390931692639fb9ec1192606480820193929182900301818387803b15801561170057600080fd5b505af1158015611714573d6000803e3d6000fd5b50506006546040805163a9059cbb60e01b81523360048201526024810186905290516001600160a01b03909216935063a9059cbb92506044808201926020929091908290030181600087803b15801561176c57600080fd5b505af1158015611780573d6000803e3d6000fd5b505050506040513d602081101561179657600080fd5b505060408051828152905133917f6d45e65025b4e5354fca7fcb828878818b16573fe504e384472faa881216dd5a919081900360200190a250565b6000811161180f576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b600061182c601054611218600f5485612bd490919063ffffffff16565b9050803414611870576040805162461bcd60e51b815260206004820152600b60248201526a696e76616c69642066656560a81b604482015290519081900360640190fd5b6005546040516001600160a01b03909116903480156108fc02916000818181858888f193505050501580156118a9573d6000803e3d6000fd5b50600654604080516323b872dd60e01b81523360048201523060248201526044810185905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b15801561190457600080fd5b505af1158015611918573d6000803e3d6000fd5b505050506040513d602081101561192e57600080fd5b5050336000908152600a6020526040902054431115611a2b576000611952336123d6565b90508015611a2957336000908152600860205260409020546119749082612b73565b336000908152600860205260409020556009546119919082612b73565b600955600c546119a19082612c6f565b600c5560075460408051639fb9ec1160e01b8152336004820152602481018490526001604482015290516001600160a01b0390921691639fb9ec119160648082019260009290919082900301818387803b1580156119fe57600080fd5b505af1158015611a12573d6000803e3d6000fd5b5050336000908152600a6020526040902043905550505b505b33600090815260086020526040902054611a459083612b73565b33600090815260086020526040902055600954611a629083612b73565b600955336000908152600a6020526040902054611a8c57336000908152600a602052604090204390555b60075460408051639fb9ec1160e01b8152336004820152602481018590526001604482015290516001600160a01b0390921691639fb9ec119160648082019260009290919082900301818387803b158015611ae657600080fd5b505af1158015611afa573d6000803e3d6000fd5b50506040805185815290513393507f3ad10ba9777a3bc21180a465e5459861d07cbdb271af9a0f10c993b365b760f892509081900360200190a25050565b6001600160a01b038116611b7c576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b60005461010090046001600160a01b03163314611bcc576040805162461bcd60e51b81526020600482015260096024820152683737ba1030b236b4b760b91b604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038216611c32576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b60005461010090046001600160a01b0316331480611c5a57506004546001600160a01b031633145b80611c6f57506002546001600160a01b031633145b611caf576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b6001600160a01b0382166000818152601560205260409020546016805491929183908110611cd957fe5b6000918252602090912001546001600160a01b031614611d2d576040805162461bcd60e51b815260206004820152600a6024820152696e6f742065786973747360b01b604482015290519081900360640190fd5b506001600160a01b03919091166000908152601760205260409020805460ff1916911515919091179055565b600f5481565b6007546001600160a01b031681565b60005460ff1615611db2576040805162461bcd60e51b8152602060048201526009602482015268696e697420646f6e6560b81b604482015290519081900360640190fd5b600780546001600160a01b03199081166001600160a01b039e8f16179091556006805482169c8e169c909c17909b556000805460028054909d169a8e169a909a17909b55600d97909755600e95909555600f93909355601091909155601155601255601355601455610100600160a81b03191661010091909316029190911760ff19166001179055565b601a5481565b6004546001600160a01b031681565b60145481565b60005461010090046001600160a01b0316331480611e7f57506004546001600160a01b031633145b80611e9457506002546001600160a01b031633145b611ed4576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b80611f16576040805162461bcd60e51b815260206004820152600d60248201526c696e76616c69642076616c756560981b604482015290519081900360640190fd5b601391909155601455565b600a6020526000908152604090205481565b6006546001600160a01b031681565b600d5481565b60005461010090046001600160a01b0316331480611f7057506004546001600160a01b031633145b80611f8557506002546001600160a01b031633145b611fc5576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b80612007576040805162461bcd60e51b815260206004820152600d60248201526c696e76616c69642076616c756560981b604482015290519081900360640190fd5b600f91909155601055565b600c5481565b60005461010090046001600160a01b031633148061204057506004546001600160a01b031633145b8061205557506002546001600160a01b031633145b612095576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b806120d7576040805162461bcd60e51b815260206004820152600d60248201526c696e76616c69642076616c756560981b604482015290519081900360640190fd5b601191909155601255565b60095481565b60005461010090046001600160a01b031633148061211057506004546001600160a01b031633145b8061212557506002546001600160a01b031633145b612162576040805162461bcd60e51b81526020600482015260096024820152683737ba1030b236b4b760b91b604482015290519081900360640190fd5b601a839055601b829055806121775743612179565b805b601c55505050565b6001600160a01b0382166000908152600a6020526040812054438311156121ac576000915050612296565b806121bb576000915050612296565b808310156121cd576000915050612296565b6009546121de576000915050612296565b6121e6612e5e565b6121f382601c5486612cb1565b9050600080600e541161220757600061222b565b61222b600e54611218600d548560006002811061222057fe5b602002015190612bd4565b9050600080601b541161223f576000612258565b612258601b54611218601a548660016002811061222057fe5b6009546001600160a01b03891660009081526008602052604090205491925061228f91611218906122898686612b73565b90612bd4565b9450505050505b92915050565b6002546001600160a01b031633146122ea576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b60008111612328576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b600654604080516323b872dd60e01b81523360048201523060248201526044810184905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b15801561238257600080fd5b505af1158015612396573d6000803e3d6000fd5b505050506040513d60208110156123ac57600080fd5b5050600c546123bb9082612b73565b600c5550565b60176020526000908152604090205460ff1681565b60006122968243612181565b60195460ff1681565b60156020526000908152604090205481565b60185481565b6005546001600160a01b031681565b600b6020526000908152604090205481565b60115481565b6001600160a01b03811661246e576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b6002546001600160a01b0316331461248557600080fd5b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166124eb576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b6002546001600160a01b0316331461253b576040805162461bcd60e51b815260206004820152600e60248201526d3737ba1039bab832b920b236b4b760911b604482015290519081900360640190fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b60125481565b60086020526000908152604090205481565b6003546001600160a01b03163314801561258e57503315155b6125d7576040805162461bcd60e51b81526020600482015260156024820152743737ba103832b73234b733a9bab832b920b236b4b760591b604482015290519081900360640190fd5b60038054600280546001600160a01b03199081166001600160a01b03841617909155169055565b601b5481565b60105481565b6002546001600160a01b03163314612658576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b60008111612696576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b80600c5410156126da576040805162461bcd60e51b815260206004820152600a6024820152690dcdee840cadcdeeaced60b31b604482015290519081900360640190fd5b6006546040805163a9059cbb60e01b81526001600160a01b038581166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b15801561273057600080fd5b505af1158015612744573d6000803e3d6000fd5b505050506040513d602081101561275a57600080fd5b5050600c546127699082612c6f565b600c555050565b600081116127ae576040805162461bcd60e51b815260206004808301919091526024820152637a65726f60e01b604482015290519081900360640190fd5b60006127cb60125461121860115485612bd490919063ffffffff16565b905080341461280f576040805162461bcd60e51b815260206004820152600b60248201526a696e76616c69642066656560a81b604482015290519081900360640190fd5b33600090815260086020526040902054821115612860576040805162461bcd60e51b815260206004820152600a6024820152690dcdee840cadcdeeaced60b31b604482015290519081900360640190fd5b6005546040516001600160a01b03909116903480156108fc02916000818181858888f19350505050158015612899573d6000803e3d6000fd5b5033600090815260086020908152604080832054600a90925290912054908314904311156129a55760006128cc336123d6565b905080156129a357336000908152600860205260409020546128ee9082612b73565b3360009081526008602052604090205560095461290b9082612b73565b600955600c5461291b9082612c6f565b600c5560075460408051639fb9ec1160e01b8152336004820152602481018490526001604482015290516001600160a01b0390921691639fb9ec119160648082019260009290919082900301818387803b15801561297857600080fd5b505af115801561298c573d6000803e3d6000fd5b5050336000908152600a6020526040902043905550505b505b6000816129b257836129c3565b336000908152600860205260409020545b336000908152600860205260409020549091506129e09082612c6f565b336000908152600860205260409020556009546129fd9082612c6f565b6009556006546040805163a9059cbb60e01b81523360048201526024810184905290516001600160a01b039092169163a9059cbb916044808201926020929091908290030181600087803b158015612a5457600080fd5b505af1158015612a68573d6000803e3d6000fd5b505050506040513d6020811015612a7e57600080fd5b505060075460408051639fb9ec1160e01b81523360048201526024810184905260006044820181905291516001600160a01b0390931692639fb9ec119260648084019391929182900301818387803b158015612ad957600080fd5b505af1158015612aed573d6000803e3d6000fd5b50503360009081526008602052604090205415159150612b1a905057336000908152600a60205260408120555b60408051828152905133917f53d02005d2e370ce08a8b60d65e07879891c336e6513821a3923f11854b54027919081900360200190a250505050565b60005461010090046001600160a01b031681565b60005460ff1681565b600082820183811015612bcd576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b600082612be357506000612296565b82820282848281612bf057fe5b0414612bcd5760405162461bcd60e51b8152600401808060200182810382526021815260200180612e7d6021913960400191505060405180910390fd5b6000612bcd83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612d62565b6000612bcd83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612e04565b612cb9612e5e565b818410612cda57506040805180820190915260008082526020820152612bcd565b8282111580612ce7575082155b15612d12576040805180820190915280612d018487612c6f565b815260200160008152509050612bcd565b828410612d3e57604080518082019091526000815260208101612d358487612c6f565b90529050612bcd565b6040805180820190915280612d538587612c6f565b8152602001612d358486612c6f565b60008183612dee5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612db3578181015183820152602001612d9b565b50505050905090810190601f168015612de05780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581612dfa57fe5b0495945050505050565b60008184841115612e565760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612db3578181015183820152602001612d9b565b505050900390565b6040518060400160405280600290602082028036833750919291505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220f642b1472fb190b44166602253d11a613cd7b7c5a7a56e19282a156bc42f0d4264736f6c634300060c0033

Deployed Bytecode Sourcemap

161:12984:16:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1325:35;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;5384:326;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5384:326:16;;;;;;;:::i;:::-;;3610:181;;;;;;;;;;;;;:::i;1465:33::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1465:33:16;;:::i;:::-;;;;-1:-1:-1;;;;;1465:33:16;;;;;;;;;;;;;;7427:313;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;7427:313:16;;:::i;1122:40::-;;;;;;;;;;;;;:::i;1719:46::-;;;;;;;;;;;;;:::i;624:27::-;;;;;;;;;;;;;:::i;655:25::-;;;;;;;;;;;;;:::i;8108:509::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;8108:509:16;;;;;;;;:::i;10941:830::-;;;;;;;;;;;;;;;;-1:-1:-1;10941:830:16;;:::i;4360:521::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;4360:521:16;-1:-1:-1;;;;;4360:521:16;;:::i;2999:202::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;2999:202:16;-1:-1:-1;;;;;2999:202:16;;:::i;684:32::-;;;;;;;;;;;;;:::i;7744:360::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;7744:360:16;;:::i;8621:1053::-;;;;;;;;;;;;;;;;-1:-1:-1;8621:1053:16;;:::i;3409:197::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;3409:197:16;-1:-1:-1;;;;;3409:197:16;;:::i;4885:392::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;4885:392:16;;;;;;;;;;:::i;1167:33::-;;;;;;;;;;;;;:::i;822:25::-;;;;;;;;;;;;;:::i;1770:1123::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;1770:1123:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;1627:41::-;;;;;;;;;;;;;:::i;720:29::-;;;;;;;;;;;;;:::i;1364:37::-;;;;;;;;;;;;;:::i;7005:317::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;7005:317:16;;;;;;;:::i;934:58::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;934:58:16;-1:-1:-1;;;;;934:58:16;;:::i;793:25::-;;;;;;;;;;;;;:::i;1080:38::-;;;;;;;;;;;;;:::i;6369:311::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;6369:311:16;;;;;;;:::i;1047:28::-;;;;;;;;;;;;;:::i;6684:317::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;6684:317:16;;;;;;;:::i;903:27::-;;;;;;;;;;;;;:::i;12727:416::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;12727:416:16;;;;;;;;;;;;:::i;11898:825::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;11898:825:16;;;;;;;;:::i;5714:245::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5714:245:16;;:::i;1502:54::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1502:54:16;-1:-1:-1;;;;;1502:54:16;;:::i;:::-;;;;;;;;;;;;;;;;;;11775:119;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;11775:119:16;-1:-1:-1;;;;;11775:119:16;;:::i;1597:25::-;;;;;;;;;;;;;:::i;1406:55::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1406:55:16;-1:-1:-1;;;;;1406:55:16;;:::i;1561:31::-;;;;;;;;;;;;;:::i;753:35::-;;;;;;;;;;;;;:::i;997:45::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;997:45:16;-1:-1:-1;;;;;997:45:16;;:::i;1244:35::-;;;;;;;;;;;;;:::i;3205:200::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;3205:200:16;-1:-1:-1;;;;;3205:200:16;;:::i;3795:232::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;3795:232:16;-1:-1:-1;;;;;3795:232:16;;:::i;1283:37::-;;;;;;;;;;;;;:::i;852:47::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;852:47:16;-1:-1:-1;;;;;852:47:16;;:::i;4031:211::-;;;;;;;;;;;;;:::i;1672:43::-;;;;;;;;;;;;;:::i;1204:35::-;;;;;;;;;;;;;:::i;5963:301::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;5963:301:16;;;;;;;;:::i;9678:1259::-;;;;;;;;;;;;;;;;-1:-1:-1;9678:1259:16;;:::i;600:20::-;;;;;;;;;;;;;:::i;576:::-;;;;;;;;;;;;;:::i;1325:35::-;;;;:::o;5384:326::-;5489:5;;;;;-1:-1:-1;;;;;5489:5:16;5475:10;:19;;:51;;-1:-1:-1;5512:14:16;;-1:-1:-1;;;;;5512:14:16;5498:10;:28;5475:51;:79;;;-1:-1:-1;5544:10:16;;-1:-1:-1;;;;;5544:10:16;5530;:24;5475:79;5467:104;;;;;-1:-1:-1;;;5467:104:16;;;;;;;;;;;;-1:-1:-1;;;5467:104:16;;;;;;;;;;;;;;;5585:16;5577:42;;;;;-1:-1:-1;;;5577:42:16;;;;;;;;;;;;-1:-1:-1;;;5577:42:16;;;;;;;;;;;;;;;5625:23;:35;;;;5666:25;:39;5384:326::o;3610:181::-;3668:12;;-1:-1:-1;;;;;3668:12:16;3654:10;:26;:54;;;;-1:-1:-1;3684:10:16;:24;;3654:54;3646:83;;;;;-1:-1:-1;;;3646:83:16;;;;;;;;;;;;-1:-1:-1;;;3646:83:16;;;;;;;;;;;;;;;3743:12;;;;3735:20;;-1:-1:-1;;;;;;3735:20:16;3743:12;-1:-1:-1;;;;;3743:12:16;;3735:20;;;;-1:-1:-1;;;;;;3761:25:16;;;3610:181::o;1465:33::-;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;1465:33:16;;-1:-1:-1;1465:33:16;:::o;7427:313::-;7499:1;7490:6;:10;7482:27;;;;;-1:-1:-1;;;7482:27:16;;;;;;;;;;;;;;;-1:-1:-1;;;7482:27:16;;;;;;;;;;;;;;;7515:11;;:59;;;-1:-1:-1;;;7515:59:16;;7540:10;7515:59;;;;7560:4;7515:59;;;;;;;;;;;;-1:-1:-1;;;;;7515:11:16;;;;:24;;:59;;;;;;;;;;;;;;;:11;;:59;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;7616:10:16;7605:22;;;;:10;7515:59;7605:22;;;;;:34;;7632:6;7605:26;:34::i;:::-;7591:10;7580:22;;;;:10;:22;;;;;;:59;;;;7645:4;;:42;;-1:-1:-1;;;7645:42:16;;;;;;;;;;;;;;;:4;:42;;;;;;-1:-1:-1;;;;;7645:4:16;;;;:16;;:42;;;;;7580:22;7645:42;;;;;;7580:22;7645:4;:42;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;7698:37:16;;;;;;;;7716:10;;-1:-1:-1;7698:37:16;;-1:-1:-1;7698:37:16;;;;;;;;7427:313;:::o;1122:40::-;;;;:::o;1719:46::-;;;;:::o;624:27::-;;;-1:-1:-1;;;;;624:27:16;;:::o;655:25::-;;;-1:-1:-1;;;;;655:25:16;;:::o;8108:509::-;8200:10;8177:34;;;;:22;:34;;;;;;;;8169:58;;;;;-1:-1:-1;;;8169:58:16;;;;;;;;;;;;-1:-1:-1;;;8169:58:16;;;;;;;;;;;;;;;8250:1;8241:6;:10;8233:27;;;;;-1:-1:-1;;;8233:27:16;;;;;;;;;;;;;;;-1:-1:-1;;;8233:27:16;;;;;;;;;;;;;;;8266:11;;:59;;;-1:-1:-1;;;8266:59:16;;8291:10;8266:59;;;;8311:4;8266:59;;;;;;;;;;;;-1:-1:-1;;;;;8266:11:16;;;;:24;;:59;;;;;;;;;;;;;;;:11;;:59;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;;8353:19:16;;;;;;:12;8266:59;8353:19;;;;;:31;;8377:6;8353:23;:31::i;:::-;-1:-1:-1;;;;;8331:19:16;;;;;;:12;:19;;;;;:53;8405:12;;:24;;8422:6;8405:16;:24::i;:::-;8390:12;:39;-1:-1:-1;;;;;8439:30:16;;;;;;:23;:30;;;;;;8435:101;;-1:-1:-1;;;;;8484:30:16;;;;;;:23;:30;;;;;8517:12;8484:45;;8435:101;8541:4;;:37;;;-1:-1:-1;;;8541:37:16;;-1:-1:-1;;;;;8541:37:16;;;;;;;;;;;;;:4;:37;;;;;;:4;;;;;:16;;:37;;;;;:4;;:37;;;;;;;:4;;:37;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;8589:23:16;;;;;;;;-1:-1:-1;;;;;8589:23:16;;;-1:-1:-1;8589:23:16;;-1:-1:-1;8589:23:16;;;;;;;;8108:509;;:::o;10941:830::-;11021:12;11006:11;:27;;10998:60;;;;;-1:-1:-1;;;10998:60:16;;;;;;;;;;;;-1:-1:-1;;;10998:60:16;;;;;;;;;;;;;;;11096:10;11072:35;;;;:23;:35;;;;;;11064:58;;;;;-1:-1:-1;;;11064:58:16;;;;;;;;;;;;-1:-1:-1;;;11064:58:16;;;;;;;;;;;;;;;11174:10;11150:35;;;;:23;:35;;;;;;11136:49;;11128:70;;;;;-1:-1:-1;;;11128:70:16;;;;;;;;;;;;-1:-1:-1;;;11128:70:16;;;;;;;;;;;;;;;11204:14;11221:41;11238:10;11250:11;11221:16;:41::i;:::-;11204:58;;11285:1;11276:6;:10;11268:32;;;;;-1:-1:-1;;;11268:32:16;;;;;;;;;;;;-1:-1:-1;;;11268:32:16;;;;;;;;;;;;;;;11306:11;11320:60;11357:22;;11320:32;11331:20;;11320:6;:10;;:32;;;;:::i;:::-;:36;;:60::i;:::-;11306:74;;11407:3;11394:9;:16;11386:40;;;;;-1:-1:-1;;;11386:40:16;;;;;;;;;;;;-1:-1:-1;;;11386:40:16;;;;;;;;;;;;;;;11432:12;;:32;;-1:-1:-1;;;;;11432:12:16;;;;11454:9;11432:32;;;;;:12;:32;:12;:32;11454:9;11432:12;:32;;;;;;;;;;;;;;;;;;;;-1:-1:-1;11510:10:16;11497:24;;;;:12;:24;;;;;;:36;;11526:6;11497:28;:36::i;:::-;11483:10;11470:24;;;;:12;:24;;;;;:63;11554:12;;:24;;11571:6;11554:16;:24::i;:::-;11539:12;:39;11600:13;;:25;;11618:6;11600:17;:25::i;:::-;11584:13;:41;11655:10;11631:35;;;;:23;:35;;;;;;:49;;;11686:4;;:42;;-1:-1:-1;;;11686:42:16;;;;;;;;;;;;;;;:4;:42;;;;;;-1:-1:-1;;;;;11686:4:16;;;;:16;;:42;;;;;11631:35;;11686:42;;;;;11631:35;11686:4;:42;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;11739:27:16;;;;;;;;11747:10;;-1:-1:-1;11739:27:16;;-1:-1:-1;11739:27:16;;;;;;;;10941:830;;;:::o;4360:521::-;-1:-1:-1;;;;;4424:19:16;;4416:36;;;;;-1:-1:-1;;;4416:36:16;;;;;;;;;;;;;;;-1:-1:-1;;;4416:36:16;;;;;;;;;;;;;;;4480:5;;;;;-1:-1:-1;;;;;4480:5:16;4466:10;:19;;:51;;-1:-1:-1;4503:14:16;;-1:-1:-1;;;;;4503:14:16;4489:10;:28;4466:51;:79;;;-1:-1:-1;4535:10:16;;-1:-1:-1;;;;;4535:10:16;4521;:24;4466:79;4458:104;;;;;-1:-1:-1;;;4458:104:16;;;;;;;;;;;;-1:-1:-1;;;4458:104:16;;;;;;;;;;;;;;;4572:16;:23;:28;4568:151;;-1:-1:-1;;;;;4626:27:16;;4610:13;4626:27;;;:20;:27;;;;;;4669:16;:23;;4626:27;;;;;4669:23;;;;;;;;;;;;;;;;-1:-1:-1;;;;;4669:23:16;:32;;4661:51;;;;;-1:-1:-1;;;4661:51:16;;;;;;;;;;;;-1:-1:-1;;;4661:51:16;;;;;;;;;;;;;;;4568:151;;4738:16;:23;;-1:-1:-1;;;;;4767:27:16;;;4724:11;4767:27;;;:20;:27;;;;;;;;:33;;;;4806:22;:29;;;;;:36;;-1:-1:-1;;4806:36:16;4838:4;4806:36;;;;;;4848:28;;;;;;;;;;;;;;;-1:-1:-1;;;;;;4848:28:16;;;;;;4360:521::o;2999:202::-;-1:-1:-1;;;;;3077:31:16;;3069:48;;;;;-1:-1:-1;;;3069:48:16;;;;;;;;;;;;;;;-1:-1:-1;;;3069:48:16;;;;;;;;;;;;;;;3145:10;;-1:-1:-1;;;;;3145:10:16;3131;:24;3123:33;;;;;;3162:14;:34;;-1:-1:-1;;;;;;3162:34:16;-1:-1:-1;;;;;3162:34:16;;;;;;;;;;2999:202::o;684:32::-;;;-1:-1:-1;;;;;684:32:16;;:::o;7744:360::-;7818:1;7809:6;:10;7801:27;;;;;-1:-1:-1;;;7801:27:16;;;;;;;;;;;;;;;-1:-1:-1;;;7801:27:16;;;;;;;;;;;;;;;7853:10;7842:22;;;;:10;:22;;;;;;:32;-1:-1:-1;7842:32:16;7834:55;;;;;-1:-1:-1;;;7834:55:16;;;;;;;;;;;;-1:-1:-1;;;7834:55:16;;;;;;;;;;;;;;;7931:10;7920:22;;;;:10;:22;;;;;;:34;;7947:6;7920:26;:34::i;:::-;7906:10;7895:22;;;;:10;:22;;;;;;:59;;;;7960:4;;:43;;-1:-1:-1;;;7960:43:16;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;7960:4:16;;;;:16;;:43;;;;;7895:22;7960:43;;;;;;7895:22;7960:4;:43;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;8009:11:16;;:40;;;-1:-1:-1;;;8009:40:16;;8030:10;8009:40;;;;;;;;;;;;-1:-1:-1;;;;;8009:11:16;;;;-1:-1:-1;8009:20:16;;-1:-1:-1;8009:40:16;;;;;;;;;;;;;;;:11;;:40;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;8060:39:16;;;;;;;;8080:10;;8060:39;;;;;;8009:40;8060:39;;;7744:360;:::o;8621:1053::-;8689:1;8680:6;:10;8672:27;;;;;-1:-1:-1;;;8672:27:16;;;;;;;;;;;;;;;-1:-1:-1;;;8672:27:16;;;;;;;;;;;;;;;8705:11;8719:56;8754:20;;8719:30;8730:18;;8719:6;:10;;:30;;;;:::i;:56::-;8705:70;;8802:3;8789:9;:16;8781:40;;;;;-1:-1:-1;;;8781:40:16;;;;;;;;;;;;-1:-1:-1;;;8781:40:16;;;;;;;;;;;;;;;8827:12;;:32;;-1:-1:-1;;;;;8827:12:16;;;;8849:9;8827:32;;;;;:12;:32;:12;:32;8849:9;8827:12;:32;;;;;;;;;;;;;;;;;;;;-1:-1:-1;8865:11:16;;:59;;;-1:-1:-1;;;8865:59:16;;8890:10;8865:59;;;;8910:4;8865:59;;;;;;;;;;;;-1:-1:-1;;;;;8865:11:16;;;;:24;;:59;;;;;;;;;;;;;;;:11;;:59;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;8973:10:16;8949:35;;;;:23;8865:59;8949:35;;;;;8934:12;:50;8930:426;;;8994:14;9011:21;9021:10;9011:9;:21::i;:::-;8994:38;-1:-1:-1;9044:10:16;;9040:310;;9106:10;9093:24;;;;:12;:24;;;;;;:36;;9122:6;9093:28;:36::i;:::-;9079:10;9066:24;;;;:12;:24;;;;;:63;9154:12;;:24;;9171:6;9154:16;:24::i;:::-;9139:12;:39;9204:13;;:25;;9222:6;9204:17;:25::i;:::-;9188:13;:41;9239:4;;:42;;;-1:-1:-1;;;9239:42:16;;9256:10;9239:42;;;;;;;;;;:4;:42;;;;;;-1:-1:-1;;;;;9239:4:16;;;;:16;;:42;;;;;:4;;:42;;;;;;;;:4;;:42;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;9315:10:16;9291:35;;;;:23;:35;;;;;9329:12;9291:50;;-1:-1:-1;;9040:310:16;8930:426;;9401:10;9388:24;;;;:12;:24;;;;;;:36;;9417:6;9388:28;:36::i;:::-;9374:10;9361:24;;;;:12;:24;;;;;:63;9445:12;;:24;;9462:6;9445:16;:24::i;:::-;9430:12;:39;9503:10;9479:35;;;;:23;:35;;;;;;9475:111;;9553:10;9529:35;;;;:23;:35;;;;;9567:12;9529:50;;9475:111;9591:4;;:42;;;-1:-1:-1;;;9591:42:16;;9608:10;9591:42;;;;;;;;;;:4;:42;;;;;;-1:-1:-1;;;;;9591:4:16;;;;:16;;:42;;;;;:4;;:42;;;;;;;;:4;;:42;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;9644:25:16;;;;;;;;9650:10;;-1:-1:-1;9644:25:16;;-1:-1:-1;9644:25:16;;;;;;;;8621:1053;;:::o;3409:197::-;-1:-1:-1;;;;;3480:29:16;;3472:46;;;;;-1:-1:-1;;;3472:46:16;;;;;;;;;;;;;;;-1:-1:-1;;;3472:46:16;;;;;;;;;;;;;;;3546:5;;;;;-1:-1:-1;;;;;3546:5:16;3532:10;:19;3524:41;;;;;-1:-1:-1;;;3524:41:16;;;;;;;;;;;;-1:-1:-1;;;3524:41:16;;;;;;;;;;;;;;;3571:12;:30;;-1:-1:-1;;;;;;3571:30:16;-1:-1:-1;;;;;3571:30:16;;;;;;;;;;3409:197::o;4885:392::-;-1:-1:-1;;;;;4975:19:16;;4967:36;;;;;-1:-1:-1;;;4967:36:16;;;;;;;;;;;;;;;-1:-1:-1;;;4967:36:16;;;;;;;;;;;;;;;5031:5;;;;;-1:-1:-1;;;;;5031:5:16;5017:10;:19;;:51;;-1:-1:-1;5054:14:16;;-1:-1:-1;;;;;5054:14:16;5040:10;:28;5017:51;:79;;;-1:-1:-1;5086:10:16;;-1:-1:-1;;;;;5086:10:16;5072;:24;5017:79;5009:104;;;;;-1:-1:-1;;;5009:104:16;;;;;;;;;;;;-1:-1:-1;;;5009:104:16;;;;;;;;;;;;;;;-1:-1:-1;;;;;5135:27:16;;5119:13;5135:27;;;:20;:27;;;;;;5176:16;:23;;5135:27;;;;;5176:23;;;;;;;;;;;;;;;;-1:-1:-1;;;;;5176:23:16;:32;5168:55;;;;;-1:-1:-1;;;5168:55:16;;;;;;;;;;;;-1:-1:-1;;;5168:55:16;;;;;;;;;;;;;;;-1:-1:-1;;;;;;5229:29:16;;;;;;;;:22;:29;;;;;:43;;-1:-1:-1;;5229:43:16;;;;;;;;;;4885:392::o;1167:33::-;;;;:::o;822:25::-;;;-1:-1:-1;;;;;822:25:16;;:::o;1770:1123::-;2246:8;;;;2245:9;2237:31;;;;;-1:-1:-1;;;2237:31:16;;;;;;;;;;;;-1:-1:-1;;;2237:31:16;;;;;;;;;;;;;;;2274:4;:33;;-1:-1:-1;;;;;;2274:33:16;;;-1:-1:-1;;;;;2274:33:16;;;;;;;2313:11;:40;;;;;;;;;;;;;;-1:-1:-1;2359:20:16;;2385:10;:30;;;;;;;;;;;;;;;2421:23;:54;;;;2481:25;:58;;;;2545:18;:44;;;;2595:20;:48;;;;2649:20;:48;2703:22;:52;2761:20;:48;2815:22;:52;-1:-1:-1;;;;;;2359:20:16;2274:33;2359:20;;;;;;;;;-1:-1:-1;;2873:15:16;-1:-1:-1;2873:15:16;;;1770:1123::o;1627:41::-;;;;:::o;720:29::-;;;-1:-1:-1;;;;;720:29:16;;:::o;1364:37::-;;;;:::o;7005:317::-;7107:5;;;;;-1:-1:-1;;;;;7107:5:16;7093:10;:19;;:51;;-1:-1:-1;7130:14:16;;-1:-1:-1;;;;;7130:14:16;7116:10;:28;7093:51;:79;;;-1:-1:-1;7162:10:16;;-1:-1:-1;;;;;7162:10:16;7148;:24;7093:79;7085:104;;;;;-1:-1:-1;;;7085:104:16;;;;;;;;;;;;-1:-1:-1;;;7085:104:16;;;;;;;;;;;;;;;7203:16;7195:42;;;;;-1:-1:-1;;;7195:42:16;;;;;;;;;;;;-1:-1:-1;;;7195:42:16;;;;;;;;;;;;;;;7243:20;:32;;;;7281:22;:36;7005:317::o;934:58::-;;;;;;;;;;;;;:::o;793:25::-;;;-1:-1:-1;;;;;793:25:16;;:::o;1080:38::-;;;;:::o;6369:311::-;6469:5;;;;;-1:-1:-1;;;;;6469:5:16;6455:10;:19;;:51;;-1:-1:-1;6492:14:16;;-1:-1:-1;;;;;6492:14:16;6478:10;:28;6455:51;:79;;;-1:-1:-1;6524:10:16;;-1:-1:-1;;;;;6524:10:16;6510;:24;6455:79;6447:104;;;;;-1:-1:-1;;;6447:104:16;;;;;;;;;;;;-1:-1:-1;;;6447:104:16;;;;;;;;;;;;;;;6565:16;6557:42;;;;;-1:-1:-1;;;6557:42:16;;;;;;;;;;;;-1:-1:-1;;;6557:42:16;;;;;;;;;;;;;;;6605:18;:30;;;;6641:20;:34;6369:311::o;1047:28::-;;;;:::o;6684:317::-;6786:5;;;;;-1:-1:-1;;;;;6786:5:16;6772:10;:19;;:51;;-1:-1:-1;6809:14:16;;-1:-1:-1;;;;;6809:14:16;6795:10;:28;6772:51;:79;;;-1:-1:-1;6841:10:16;;-1:-1:-1;;;;;6841:10:16;6827;:24;6772:79;6764:104;;;;;-1:-1:-1;;;6764:104:16;;;;;;;;;;;;-1:-1:-1;;;6764:104:16;;;;;;;;;;;;;;;6882:16;6874:42;;;;;-1:-1:-1;;;6874:42:16;;;;;;;;;;;;-1:-1:-1;;;6874:42:16;;;;;;;;;;;;;;;6922:20;:32;;;;6960:22;:36;6684:317::o;903:27::-;;;;:::o;12727:416::-;12875:5;;;;;-1:-1:-1;;;;;12875:5:16;12861:10;:19;;:51;;-1:-1:-1;12898:14:16;;-1:-1:-1;;;;;12898:14:16;12884:10;:28;12861:51;:79;;;-1:-1:-1;12930:10:16;;-1:-1:-1;;;;;12930:10:16;12916;:24;12861:79;12853:101;;;;;-1:-1:-1;;;12853:101:16;;;;;;;;;;;;-1:-1:-1;;;12853:101:16;;;;;;;;;;;;;;;12961:26;:38;;;13005:28;:42;;;13087:19;:51;;13126:12;13087:51;;;13109:14;13087:51;13053:31;:85;-1:-1:-1;;;12727:416:16:o;11898:825::-;-1:-1:-1;;;;;12025:30:16;;11981:7;12025:30;;;:23;:30;;;;;;12080:12;12066:26;;12062:40;;;12101:1;12094:8;;;;;12062:40;12112:23;12108:37;;12144:1;12137:8;;;;;12108:37;12169:18;12155:11;:32;12151:46;;;12196:1;12189:8;;;;;12151:46;12207:12;;12203:31;;12233:1;12226:8;;;;;12203:31;12241:30;;:::i;:::-;12274:80;12289:18;12309:31;;12342:11;12274:14;:80::i;:::-;12241:113;;12360:17;12408:1;12380:25;;:29;:111;;12490:1;12380:111;;;12412:75;12461:25;;12412:44;12432:23;;12412:12;12425:1;12412:15;;;;;;;;;;;;:19;:44::i;:75::-;12360:131;;12497:17;12548:1;12517:28;;:32;:120;;12636:1;12517:120;;;12552:81;12604:28;;12552:47;12572:26;;12552:12;12565:1;12552:15;;;;;;:81;12705:12;;-1:-1:-1;;;;;12680:19:16;;;;;;:12;:19;;;;;;12497:140;;-1:-1:-1;12651:67:16;;:49;;:24;:9;12497:140;12651:13;:24::i;:::-;:28;;:49::i;:67::-;12644:74;;;;;;11898:825;;;;;:::o;5714:245::-;5782:10;;-1:-1:-1;;;;;5782:10:16;5768;:24;5760:49;;;;;-1:-1:-1;;;5760:49:16;;;;;;;;;;;;-1:-1:-1;;;5760:49:16;;;;;;;;;;;;;;;5832:1;5823:6;:10;5815:27;;;;;-1:-1:-1;;;5815:27:16;;;;;;;;;;;;;;;-1:-1:-1;;;5815:27:16;;;;;;;;;;;;;;;5848:11;;:59;;;-1:-1:-1;;;5848:59:16;;5873:10;5848:59;;;;5893:4;5848:59;;;;;;;;;;;;-1:-1:-1;;;;;5848:11:16;;;;:24;;:59;;;;;;;;;;;;;;;:11;;:59;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;5929:13:16;;:25;;5947:6;5929:17;:25::i;:::-;5913:13;:41;-1:-1:-1;5714:245:16:o;1502:54::-;;;;;;;;;;;;;;;:::o;11775:119::-;11830:7;11852:37;11869:5;11876:12;11852:16;:37::i;1597:25::-;;;;;;:::o;1406:55::-;;;;;;;;;;;;;:::o;1561:31::-;;;;:::o;753:35::-;;;-1:-1:-1;;;;;753:35:16;;:::o;997:45::-;;;;;;;;;;;;;:::o;1244:35::-;;;;:::o;3205:200::-;-1:-1:-1;;;;;3287:29:16;;3279:46;;;;;-1:-1:-1;;;3279:46:16;;;;;;;;;;;;;;;-1:-1:-1;;;3279:46:16;;;;;;;;;;;;;;;3353:10;;-1:-1:-1;;;;;3353:10:16;3339;:24;3331:33;;;;;;3370:12;:30;;-1:-1:-1;;;;;;3370:30:16;-1:-1:-1;;;;;3370:30:16;;;;;;;;;;3205:200::o;3795:232::-;-1:-1:-1;;;;;3876:34:16;;3868:51;;;;;-1:-1:-1;;;3868:51:16;;;;;;;;;;;;;;;-1:-1:-1;;;3868:51:16;;;;;;;;;;;;;;;3947:10;;-1:-1:-1;;;;;3947:10:16;3933;:24;3925:51;;;;;-1:-1:-1;;;3925:51:16;;;;;;;;;;;;-1:-1:-1;;;3925:51:16;;;;;;;;;;;;;;;3982:17;:40;;-1:-1:-1;;;;;;3982:40:16;-1:-1:-1;;;;;3982:40:16;;;;;;;;;;3795:232::o;1283:37::-;;;;:::o;852:47::-;;;;;;;;;;;;;:::o;4031:211::-;4094:17;;-1:-1:-1;;;;;4094:17:16;4080:10;:31;:59;;;;-1:-1:-1;4115:10:16;:24;;4080:59;4072:93;;;;;-1:-1:-1;;;4072:93:16;;;;;;;;;;;;-1:-1:-1;;;4072:93:16;;;;;;;;;;;;;;;4184:17;;;4171:10;:30;;-1:-1:-1;;;;;;4171:30:16;;;-1:-1:-1;;;;;4184:17:16;;4171:30;;;;4207;;;4031:211::o;1672:43::-;;;;:::o;1204:35::-;;;;:::o;5963:301::-;6053:10;;-1:-1:-1;;;;;6053:10:16;6039;:24;6031:49;;;;;-1:-1:-1;;;6031:49:16;;;;;;;;;;;;-1:-1:-1;;;6031:49:16;;;;;;;;;;;;;;;6103:1;6094:6;:10;6086:27;;;;;-1:-1:-1;;;6086:27:16;;;;;;;;;;;;;;;-1:-1:-1;;;6086:27:16;;;;;;;;;;;;;;;6144:6;6127:13;;:23;;6119:46;;;;;-1:-1:-1;;;6119:46:16;;;;;;;;;;;;-1:-1:-1;;;6119:46:16;;;;;;;;;;;;;;;6171:11;;:41;;;-1:-1:-1;;;6171:41:16;;-1:-1:-1;;;;;6171:41:16;;;;;;;;;;;;;;;:11;;;;;:20;;:41;;;;;;;;;;;;;;:11;;:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;6234:13:16;;:25;;6252:6;6234:17;:25::i;:::-;6218:13;:41;-1:-1:-1;;5963:301:16:o;9678:1259::-;9748:1;9739:6;:10;9731:27;;;;;-1:-1:-1;;;9731:27:16;;;;;;;;;;;;;;;-1:-1:-1;;;9731:27:16;;;;;;;;;;;;;;;9764:11;9778:60;9815:22;;9778:32;9789:20;;9778:6;:10;;:32;;;;:::i;:60::-;9764:74;;9865:3;9852:9;:16;9844:40;;;;;-1:-1:-1;;;9844:40:16;;;;;;;;;;;;-1:-1:-1;;;9844:40:16;;;;;;;;;;;;;;;9911:10;9898:24;;;;:12;:24;;;;;;:34;-1:-1:-1;9898:34:16;9890:57;;;;;-1:-1:-1;;;9890:57:16;;;;;;;;;;;;-1:-1:-1;;;9890:57:16;;;;;;;;;;;;;;;9953:12;;:32;;-1:-1:-1;;;;;9953:12:16;;;;9975:9;9953:32;;;;;:12;:32;:12;:32;9975:9;9953:12;:32;;;;;;;;;;;;;;;;;;;;-1:-1:-1;10032:10:16;9991:14;10019:24;;;:12;:24;;;;;;;;;10069:23;:35;;;;;;;10009:34;;;;10054:12;:50;10050:426;;;10114:14;10131:21;10141:10;10131:9;:21::i;:::-;10114:38;-1:-1:-1;10164:10:16;;10160:310;;10226:10;10213:24;;;;:12;:24;;;;;;:36;;10242:6;10213:28;:36::i;:::-;10199:10;10186:24;;;;:12;:24;;;;;:63;10274:12;;:24;;10291:6;10274:16;:24::i;:::-;10259:12;:39;10324:13;;:25;;10342:6;10324:17;:25::i;:::-;10308:13;:41;10359:4;;:42;;;-1:-1:-1;;;10359:42:16;;10376:10;10359:42;;;;;;;;;;:4;:42;;;;;;-1:-1:-1;;;;;10359:4:16;;;;:16;;:42;;;;;:4;;:42;;;;;;;;:4;;:42;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;10435:10:16;10411:35;;;;:23;:35;;;;;10449:12;10411:50;;-1:-1:-1;;10160:310:16;10050:426;;10481:22;10506:9;:45;;10545:6;10506:45;;;10531:10;10518:24;;;;:12;:24;;;;;;10506:45;10597:10;10584:24;;;;:12;:24;;;;;;10481:70;;-1:-1:-1;10584:44:16;;10481:70;10584:28;:44::i;:::-;10570:10;10557:24;;;;:12;:24;;;;;:71;10649:12;;:32;;10666:14;10649:16;:32::i;:::-;10634:12;:47;10687:11;;:48;;;-1:-1:-1;;;10687:48:16;;10708:10;10687:48;;;;;;;;;;;;-1:-1:-1;;;;;10687:11:16;;;;:20;;:48;;;;;;;;;;;;;;;:11;;:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;10741:4:16;;:51;;;-1:-1:-1;;;10741:51:16;;10758:10;10741:51;;;;;;;;;;:4;:51;;;;;;;;-1:-1:-1;;;;;10741:4:16;;;;:16;;:51;;;;;:4;;:51;;;;;;:4;;:51;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;10815:10:16;10802:24;;;;:12;:24;;;;;;:29;10798:89;;-1:-1:-1;10798:89:16;;-1:-1:-1;10798:89:16;10865:10;10879:1;10841:35;;;:23;:35;;;;;:39;10798:89;10897:35;;;;;;;;10905:10;;10897:35;;;;;;;;;;9678:1259;;;;:::o;600:20::-;;;;;;-1:-1:-1;;;;;600:20:16;;:::o;576:::-;;;;;;:::o;882:176:5:-;940:7;971:5;;;994:6;;;;986:46;;;;;-1:-1:-1;;;986:46:5;;;;;;;;;;;;;;;;;;;;;;;;;;;;1050:1;882:176;-1:-1:-1;;;882:176:5:o;2188:459::-;2246:7;2487:6;2483:45;;-1:-1:-1;2516:1:5;2509:8;;2483:45;2550:5;;;2554:1;2550;:5;:1;2573:5;;;;;:10;2565:56;;;;-1:-1:-1;;;2565:56:5;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3109:130;3167:7;3193:39;3197:1;3200;3193:39;;;;;;;;;;;;;;;;;:3;:39::i;1329:134::-;1387:7;1413:43;1417:1;1420;1413:43;;;;;;;;;;;;;;;;;:3;:43::i;139:623:19:-;251:17;;:::i;:::-;306:11;284:18;:33;280:70;;-1:-1:-1;319:31:19;;;;;;;;;-1:-1:-1;319:31:19;;;;;;;;;280:70;380:14;365:11;:29;;:52;;;-1:-1:-1;398:19:19;;365:52;361:395;;;433:56;;;;;;;;;;441:35;:11;457:18;441:15;:35::i;:::-;433:56;;;;486:1;433:56;;;;;;;361:395;540:14;518:18;:36;514:242;;570:56;;;;;;;;;-1:-1:-1;570:56:19;;;;;590:35;:11;606:18;590:15;:35::i;:::-;570:56;;;-1:-1:-1;570:56:19;;514:242;665:80;;;;;;;;;;673:38;:14;692:18;673;:38::i;:::-;665:80;;;;713:31;:11;729:14;713:15;:31::i;3721:272:5:-;3807:7;3841:12;3834:5;3826:28;;;;-1:-1:-1;;;3826:28:5;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3864:9;3880:1;3876;:5;;;;;;;3721:272;-1:-1:-1;;;;;3721:272:5:o;1754:187::-;1840:7;1875:12;1867:6;;;;1859:29;;;;-1:-1:-1;;;1859:29:5;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;1910:5:5;;;1754:187::o;-1:-1:-1:-;;;;;;;;;;;;;;;;;;;;;;;;:::o

Swarm Source

ipfs://f642b1472fb190b44166602253d11a613cd7b7c5a7a56e19282a156bc42f0d42

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.