ETH Price: $3,919.07 (-0.38%)

Token

Furballs (FBL)
 

Overview

Max Total Supply

7,500 FBL

Holders

1,012

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A

Other Info

Filtered by Token Holder
0xfrogs.eth
Balance
0 FBL
0xae2333480433b186e78515a4b53c53e9522ec034
Loading...
Loading
Loading...
Loading
Loading...
Loading

OVERVIEW

Furballs are entirely on-chain, with a full interactive gameplay experience at Furballs.com.

# Exchange Pair Price  24H Volume % Volume

Contract Source Code Verified (Exact Match)

Contract Name:
Furballs

Compiler Version
v0.8.7+commit.e28d00a7

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 35 : Furballs.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.6;

// import "hardhat/console.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "./editions/IFurballEdition.sol";
import "./engines/ILootEngine.sol";
import "./engines/EngineA.sol";
import "./utils/FurLib.sol";
import "./utils/FurDefs.sol";
import "./utils/FurProxy.sol";
import "./utils/Moderated.sol";
import "./utils/Governance.sol";
import "./Fur.sol";
import "./Furgreement.sol";
// import "hardhat/console.sol";

/// @title Furballs
/// @author LFG Gaming LLC
/// @notice Mints Furballs on the Ethereum blockchain
/// @dev https://furballs.com/contract
contract Furballs is ERC721Enumerable, Moderated {
  Fur public fur;

  IFurballEdition[] public editions;

  ILootEngine public engine;

  Governance public governance;

  Furgreement public furgreement;

  // tokenId => furball data
  mapping(uint256 => FurLib.Furball) public furballs;

  // tokenId => all rewards assigned to that Furball
  mapping(uint256 => FurLib.Rewards) public collect;

  // The amount of time over which FUR/EXP is accrued (usually 3600=>1hour); used with test servers
  uint256 public intervalDuration;

  // When play/collect runs, returns rewards
  event Collection(uint256 tokenId, uint256 responseId);

  // Inventory change event
  event Inventory(uint256 tokenId, uint128 lootId, uint16 dropped);

  constructor(uint256 interval) ERC721("Furballs", "FBL") {
    intervalDuration = interval;
  }

  // -----------------------------------------------------------------------------------------------
  // Public transactions
  // -----------------------------------------------------------------------------------------------

  /// @notice Mints a new furball from the current edition (if there are any remaining)
  /// @dev Limits and fees are set by IFurballEdition
  function mint(address[] memory to, uint8 editionIndex, address actor) external {
    (address sender, uint8 permissions) = _approvedSender(actor);
    require(to.length == 1 || permissions >= FurLib.PERMISSION_MODERATOR, "MULT");

    for (uint8 i=0; i<to.length; i++) {
      fur.purchaseMint(sender, permissions, to[i], editions[editionIndex]);
      _spawn(to[i], editionIndex, 0);
    }
  }

  /// @notice Feeds the furball a snack
  /// @dev Delegates logic to fur
  function feed(FurLib.Feeding[] memory feedings, address actor) external {
    (address sender, uint8 permissions) = _approvedSender(actor);
    uint256 len = feedings.length;

    for (uint256 i=0; i<len; i++) {
      fur.purchaseSnack(sender, permissions, feedings[i].tokenId, feedings[i].snackId, feedings[i].count);
    }
  }

  /// @notice Begins exploration mode with the given furballs
  /// @dev Multiple furballs accepted at once to reduce gas fees
  /// @param tokenIds The furballs which should start exploring
  /// @param zone The explore zone (otherwize, zero for battle mode)
  function playMany(uint256[] memory tokenIds, uint32 zone, address actor) external {
    (address sender, uint8 permissions) = _approvedSender(actor);

    for (uint256 i=0; i<tokenIds.length; i++) {
      // Run reward collection
      _collect(tokenIds[i], sender, permissions);

      // Set new zone (if allowed; enterZone may throw)
      furballs[tokenIds[i]].zone = uint32(engine.enterZone(tokenIds[i], zone, tokenIds));
    }
  }

  /// @notice Re-dropping loot allows players to pay $FUR to re-roll an inventory slot
  /// @param tokenId The furball in question
  /// @param lootId The lootId in its inventory to re-roll
  function upgrade(
    uint256 tokenId, uint128 lootId, uint8 chances, address actor
  ) external {
    // Attempt upgrade (random chance).
    (address sender, uint8 permissions) = _approvedSender(actor);
    uint128 up = fur.purchaseUpgrade(_baseModifiers(tokenId), sender, permissions, tokenId, lootId, chances);
    if (up != 0) {
      _drop(tokenId, lootId, 1);
      _pickup(tokenId, up);
    }
  }

  /// @notice The LootEngine can directly send loot to a furball!
  /// @dev This allows for gameplay expansion, i.e., new game modes
  /// @param tokenId The furball to gain the loot
  /// @param lootId The loot ID being sent
  function pickup(uint256 tokenId, uint128 lootId) external gameAdmin {
    _pickup(tokenId, lootId);
  }

  /// @notice The LootEngine can cause a furball to drop loot!
  /// @dev This allows for gameplay expansion, i.e., new game modes
  /// @param tokenId The furball
  /// @param lootId The item to drop
  /// @param count the number of that item to drop
  function drop(uint256 tokenId, uint128 lootId, uint8 count) external gameAdmin {
    _drop(tokenId, lootId, count);
  }

  // -----------------------------------------------------------------------------------------------
  // Internal
  // -----------------------------------------------------------------------------------------------

  function _slotNum(uint256 tokenId, uint128 lootId) internal view returns(uint256) {
    for (uint8 i=0; i<furballs[tokenId].inventory.length; i++) {
      if (furballs[tokenId].inventory[i] / 256 == lootId) {
        return i + 1;
      }
    }
    return 0;
  }

  /// @notice Remove an inventory item from a furball
  function _drop(uint256 tokenId, uint128 lootId, uint8 count) internal {
    uint256 slot = _slotNum(tokenId, lootId);
    require(slot > 0 && slot <= uint32(furballs[tokenId].inventory.length), "SLOT");

    slot -= 1;
    uint8 stackSize = uint8(furballs[tokenId].inventory[slot] % 0x100);

    if (count == 0 || count >= stackSize) {
      // Drop entire stack
      uint16 len = uint16(furballs[tokenId].inventory.length);
      if (len > 1) {
        furballs[tokenId].inventory[slot] = furballs[tokenId].inventory[len - 1];
      }
      furballs[tokenId].inventory.pop();
      count = stackSize;
    } else {
      stackSize -= count;
      furballs[tokenId].inventory[slot] = uint256(lootId) * 0x100 + stackSize;
    }

    furballs[tokenId].weight -= count * engine.weightOf(lootId);
    emit Inventory(tokenId, lootId, count);
  }

  /// @notice Internal implementation of adding a single known loot item to a Furball
  function _pickup(uint256 tokenId, uint128 lootId) internal {
    require(lootId > 0, "LOOT");
    uint256 slotNum = _slotNum(tokenId, lootId);
    uint8 stackSize = 1;
    if (slotNum == 0) {
      furballs[tokenId].inventory.push(uint256(lootId) * 0x100 + stackSize);
    } else {
      stackSize += uint8(furballs[tokenId].inventory[slotNum - 1] % 0x100);
      require(stackSize < 0x100, "STACK");
      furballs[tokenId].inventory[slotNum - 1] = uint256(lootId) * 0x100 + stackSize;
    }

    furballs[tokenId].weight += engine.weightOf(lootId);
    emit Inventory(tokenId, lootId, 0);
  }

  /// @notice Calculates full reward modifier stack for a furball in a zone.
  function _rewardModifiers(
    FurLib.Furball memory fb, uint256 tokenId, address ownerContext, uint256 snackData
  ) internal view returns(FurLib.RewardModifiers memory reward) {
    uint16 energy = uint16(FurLib.extractBytes(snackData, FurLib.SNACK_BYTE_ENERGY, 2));
    uint16 happiness = uint16(FurLib.extractBytes(snackData, FurLib.SNACK_BYTE_HAPPINESS, 2));

    bool context = ownerContext != address(0);
    uint32 editionIndex = uint32(tokenId % 0x100);

    reward = FurLib.RewardModifiers(
      uint16(100 + fb.rarity),
      uint16(100 + fb.rarity - (editionIndex < 4 ? (editionIndex * 20) : 80)),
      uint16(100),
      happiness,
      energy,
      context ? fb.zone : 0
    );

    // Engine will consider inventory and team size in zone (17k)
    return engine.modifyReward(
      fb,
      editions[editionIndex].modifyReward(reward, tokenId),
      governance.getAccount(ownerContext),
      context
    );
  }

  /// @notice Common version of _rewardModifiers which excludes contextual data
  function _baseModifiers(uint256 tokenId) internal view returns(FurLib.RewardModifiers memory) {
    return _rewardModifiers(furballs[tokenId], tokenId, address(0), 0);
  }

  /// @notice Ends the current explore/battle and dispenses rewards
  /// @param tokenId The furball
  function _collect(uint256 tokenId, address sender, uint8 permissions) internal {
    FurLib.Furball memory furball = furballs[tokenId];
    address owner = ownerOf(tokenId);

    // The engine is allowed to force furballs into exploration mode
    // This allows it to end a battle early, which will be necessary in PvP
    require(owner == sender || permissions >= FurLib.PERMISSION_ADMIN, "OWN");

    // Scale duration to the time the edition has been live
    if (furball.last == 0) {
      uint64 launchedAt = uint64(editions[tokenId % 0x100].liveAt());
      require(launchedAt > 0 && launchedAt < uint64(block.timestamp), "PRE");
      furball.last = furball.birth > launchedAt ? furball.birth : launchedAt;
    }

    // Calculate modifiers to be used with this collection
    FurLib.RewardModifiers memory mods =
      _rewardModifiers(furball, tokenId, owner, fur.cleanSnacks(tokenId));

    // Reset the collection for this furball
    uint32 duration = uint32(uint64(block.timestamp) - furball.last);
    collect[tokenId].fur = 0;
    collect[tokenId].experience = 0;
    collect[tokenId].levels = 0;

    if (mods.zone >= 0x10000) {
      // Battle zones earn FUR and assign to the owner
      uint32 f = uint32(_calculateReward(duration, FurLib.FUR_PER_INTERVAL, mods.furPercent));
      if (f > 0) {
        fur.earn(owner, f);
        collect[tokenId].fur = f;
      }
    } else {
      // Explore zones earn EXP...
      uint32 exp = uint32(_calculateReward(duration, FurLib.EXP_PER_INTERVAL, mods.expPercent));
      (uint32 totalExp, uint16 levels) = engine.onExperience(furballs[tokenId], owner, exp);

      collect[tokenId].experience = exp;
      collect[tokenId].levels = levels;

      furballs[tokenId].level += levels;
      furballs[tokenId].experience = totalExp;
    }

    // Generate loot and assign to furball
    uint32 interval = uint32(intervalDuration);
    uint128 lootId = engine.dropLoot(duration / interval, mods);
    collect[tokenId].loot = lootId;
    if (lootId > 0) {
      _pickup(tokenId, lootId);
    }

    // Timestamp the last interaction for next cycle.
    furballs[tokenId].last = uint64(block.timestamp);

    // Emit the reward ID for frontend
    uint32 moves = furball.moves + 1;
    furballs[tokenId].moves = moves;
    emit Collection(tokenId, moves);
  }

  /// @notice Mints a new furball
  /// @dev Recursive function; generates randomization seed for the edition
  /// @param to The recipient of the furball
  /// @param nonce A recursive counter to prevent infinite loops
  function _spawn(address to, uint8 editionIndex, uint8 nonce) internal {
    require(nonce < 10, "SUPPLY");
    require(editionIndex < editions.length, "ED");

    IFurballEdition edition = editions[editionIndex];

    // Generate a random furball tokenId; if it fails to be unique, recurse!
    (uint256 tokenId, uint16 rarity) = edition.spawn();
    tokenId += editionIndex;
    if (_exists(tokenId)) return _spawn(to, editionIndex, nonce + 1);

    // Ensure that this wallet has not exceeded its per-edition mint-cap
    uint32 owned = edition.minted(to);
    require(owned < edition.maxMintable(to), "LIMIT");

    // Check the current edition's constraints (caller should have checked costs)
    uint16 cnt = edition.count();
    require(cnt < edition.maxCount(), "MAX");

    // Initialize the memory struct that represents the furball
    furballs[tokenId].number = uint32(totalSupply() + 1);
    furballs[tokenId].count = cnt;
    furballs[tokenId].rarity = rarity;
    furballs[tokenId].birth = uint64(block.timestamp);

    // Finally, mint the token and increment internal counters
    _mint(to, tokenId);

    edition.addCount(to, 1);
  }

  /// @notice Happens each time a furball changes wallets
  /// @dev Keeps track of the furball timestamp
  function _beforeTokenTransfer(
    address from,
    address to,
    uint256 tokenId
  ) internal override {
    super._beforeTokenTransfer(from, to, tokenId);

    // Update internal data states
    furballs[tokenId].trade = uint64(block.timestamp);

    // Delegate other logic to the engine
    engine.onTrade(furballs[tokenId], from, to);
  }

  // -----------------------------------------------------------------------------------------------
  // Game Engine & Moderation
  // -----------------------------------------------------------------------------------------------

  function stats(uint256 tokenId, bool contextual) public view returns(FurLib.FurballStats memory) {
    // Base stats are calculated without team size so this doesn't effect public metadata
    FurLib.Furball memory furball = furballs[tokenId];
    FurLib.RewardModifiers memory mods =
      _rewardModifiers(
        furball,
        tokenId,
        contextual ? ownerOf(tokenId) : address(0),
        contextual ? fur.snackEffects(tokenId) : 0
      );

    return FurLib.FurballStats(
      uint16(_calculateReward(intervalDuration, FurLib.EXP_PER_INTERVAL, mods.expPercent)),
      uint16(_calculateReward(intervalDuration, FurLib.FUR_PER_INTERVAL, mods.furPercent)),
      mods,
      furball,
      fur.snacks(tokenId)
    );
  }

  /// @notice This utility function is useful because it force-casts arguments to uint256
  function _calculateReward(
    uint256 duration, uint256 perInterval, uint256 percentBoost
  ) internal view returns(uint256) {
    uint256 interval = intervalDuration;
    return (duration * percentBoost * perInterval) / (100 * interval);
  }

  // -----------------------------------------------------------------------------------------------
  // Public Views/Accessors (for outside world)
  // -----------------------------------------------------------------------------------------------

  /// @notice Provides the OpenSea storefront
  /// @dev see https://docs.opensea.io/docs/contract-level-metadata
  function contractURI() public view returns (string memory) {
    return governance.metaURI();
  }

  /// @notice Provides the on-chain Furball asset
  /// @dev see https://docs.opensea.io/docs/metadata-standards
  function tokenURI(uint256 tokenId) public view override returns (string memory) {
    require(_exists(tokenId));
    return string(abi.encodePacked("data:application/json;base64,", FurLib.encode(abi.encodePacked(
      editions[tokenId % 0x100].tokenMetadata(
        engine.attributesMetadata(tokenId),
        tokenId,
        furballs[tokenId].number
      )
    ))));
  }

  // -----------------------------------------------------------------------------------------------
  // OpenSea Proxy
  // -----------------------------------------------------------------------------------------------

  /// @notice Whitelisting the proxy registies for secondary market transactions
  /// @dev See OpenSea ERC721Tradable
  function isApprovedForAll(address owner, address operator)
      override
      public
      view
      returns (bool)
  {
    return engine.canProxyTrades(owner, operator) || super.isApprovedForAll(owner, operator);
  }

  /// @notice This is used instead of msg.sender as transactions won't be sent by the original token owner, but by OpenSea.
  /// @dev See OpenSea ContentMixin
  function _msgSender()
    internal
    override
    view
    returns (address sender)
  {
    if (msg.sender == address(this)) {
      bytes memory array = msg.data;
      uint256 index = msg.data.length;
      assembly {
        // Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those.
        sender := and(
          mload(add(array, index)),
          0xffffffffffffffffffffffffffffffffffffffff
        )
      }
    } else {
      sender = msg.sender;
    }
    return sender;
  }

  // -----------------------------------------------------------------------------------------------
  // Configuration / Admin
  // -----------------------------------------------------------------------------------------------

  function setFur(address furAddress) external onlyAdmin {
    fur = Fur(furAddress);
  }

  function setFurgreement(address furgAddress) external onlyAdmin {
    furgreement = Furgreement(furgAddress);
  }

  function setGovernance(address addr) public onlyAdmin {
    governance = Governance(payable(addr));
  }

  function setEngine(address addr) public onlyAdmin {
    engine = ILootEngine(addr);
  }

  function addEdition(address addr, uint8 idx) public onlyAdmin {
    if (idx >= editions.length) {
      editions.push(IFurballEdition(addr));
    } else {
      editions[idx] = IFurballEdition(addr);
    }
  }

  function _isReady() internal view returns(bool) {
    return address(engine) != address(0) && editions.length > 0
      && address(fur) != address(0) && address(governance) != address(0);
  }

  /// @notice Handles auth of msg.sender against cheating and/or banning.
  /// @dev Pass nonzero sender to act as a proxy against the furgreement
  function _approvedSender(address sender) internal view returns (address, uint8) {
    // No sender (for gameplay) is approved until the necessary parts are online
    require(_isReady(), "!RDY");

    if (sender != address(0) && sender != msg.sender) {
      // Only the furgreement may request a proxied sender.
      require(msg.sender == address(furgreement), "PROXY");
    } else {
      // Zero input triggers sender calculation from msg args
      sender = _msgSender();
    }

    // All senders are validated thru engine logic.
    uint8 permissions = uint8(engine.approveSender(sender));

    // Zero-permissions indicate unauthorized.
    require(permissions > 0, "PLR");

    return (sender, permissions);
  }

  modifier gameAdmin() {
    (address sender, uint8 permissions) = _approvedSender(address(0));
    require(permissions >= FurLib.PERMISSION_ADMIN, "GAME");
    _;
  }
}

File 2 of 35 : ERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "./IERC721Enumerable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

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

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

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

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

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

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}

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

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. 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;`
 */
library Counters {
    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 {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

File 4 of 35 : IFurballEdition.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.6;

import "../utils/FurLib.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

/// @title IFurballEdition
/// @author LFG Gaming LLC
/// @notice Interface for a single edition within Furballs
interface IFurballEdition is IERC165 {
  function index() external view returns(uint8);
  function count() external view returns(uint16);
  function maxCount() external view returns (uint16); // total max count in this edition
  function addCount(address to, uint16 amount) external returns(bool);

  function liveAt() external view returns(uint64);
  function minted(address addr) external view returns(uint16);
  function maxMintable(address addr) external view returns(uint16);
  function maxAdoptable() external view returns (uint16); // how many can be adopted, out of the max?
  function purchaseFur() external view returns(uint256); // amount of FUR for buying

  function spawn() external returns (uint256, uint16);

  /// @notice Calculates the effects of the loot in a Furball's inventory
  function modifyReward(
    FurLib.RewardModifiers memory modifiers, uint256 tokenId
  ) external view returns(FurLib.RewardModifiers memory);

  /// @notice Renders a JSON object for tokenURI
  function tokenMetadata(
    bytes memory attributes, uint256 tokenId, uint256 number
  ) external view returns(bytes memory);
}

File 5 of 35 : ILootEngine.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.6;

import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "../editions/IFurballEdition.sol";
import "../utils/FurLib.sol";

/// @title ILootEngine
/// @author LFG Gaming LLC
/// @notice The loot engine is patchable by replacing the Furballs' engine with a new version
interface ILootEngine is IERC165 {
  /// @notice When a Furball comes back from exploration, potentially give it some loot.
  function dropLoot(uint32 intervals, FurLib.RewardModifiers memory mods) external returns(uint128);

  /// @notice Players can pay to re-roll their loot drop on a Furball
  function upgradeLoot(
    FurLib.RewardModifiers memory modifiers,
    address owner,
    uint128 lootId,
    uint8 chances
  ) external returns(uint128);

  /// @notice Some zones may have preconditions
  function enterZone(uint256 tokenId, uint32 zone, uint256[] memory team) external returns(uint256);

  /// @notice Calculates the effects of the loot in a Furball's inventory
  function modifyReward(
    FurLib.Furball memory furball,
    FurLib.RewardModifiers memory baseModifiers,
    FurLib.Account memory account,
    bool contextual
  ) external view returns(FurLib.RewardModifiers memory);

  /// @notice Loot can have different weight to help prevent over-powering a furball
  function weightOf(uint128 lootId) external pure returns (uint16);

  /// @notice JSON object for displaying metadata on OpenSea, etc.
  function attributesMetadata(uint256 tokenId) external view returns(bytes memory);

  /// @notice Get a potential snack for the furball by its ID
  function getSnack(uint32 snack) external view returns(FurLib.Snack memory);

  /// @notice Proxy registries are allowed to act as 3rd party trading platforms
  function canProxyTrades(address owner, address operator) external view returns(bool);

  /// @notice Authorization mechanics are upgradeable to account for security patches
  function approveSender(address sender) external view returns(uint);

  /// @notice Called when a Furball is traded to update delegate logic
  function onTrade(
    FurLib.Furball memory furball, address from, address to
  ) external;

  /// @notice Handles experience gain during collection
  function onExperience(
    FurLib.Furball memory furball, address owner, uint32 experience
  ) external returns(uint32 totalExp, uint16 level);

  /// @notice Gets called at the beginning of token render; could add underlaid artwork
  function render(uint256 tokenId) external view returns(string memory);

  /// @notice The loot engine can add descriptions to furballs metadata
  function furballDescription(uint256 tokenId) external view returns (string memory);
}

File 6 of 35 : EngineA.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.6;

import "./LootEngine.sol";

/// @title EngineA
/// @author LFG Gaming LLC
/// @notice Concrete implementation of LootEngine
contract EngineA is LootEngine {
  constructor(address furballs, address tradeProxy, address companyProxy)
    LootEngine(furballs, tradeProxy, companyProxy) { }
}

File 7 of 35 : FurLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.6;

/// @title FurLib
/// @author LFG Gaming LLC
/// @notice Utilities for Furballs
/// @dev Each of the structs are designed to fit within 256
library FurLib {
  // Metadata about a wallet.
  struct Account {
    uint64 created;       // First time this account received a furball
    uint32 numFurballs;   // Number of furballs it currently holds
    uint32 maxFurballs;   // Max it has ever held
    uint16 maxLevel;      // Max level of any furball it currently holds
    uint16 reputation;    // Value assigned by moderators to boost standing
    uint16 standing;      // Computed current standing
    uint8 permissions;    // 0 = user, 1 = moderator, 2 = admin, 3 = owner
  }

  // Key data structure given to clients for high-level furball access (furballs.stats)
  struct FurballStats {
    uint16 expRate;
    uint16 furRate;
    RewardModifiers modifiers;
    Furball definition;
    Snack[] snacks;
  }

  // The response from a single play session indicating rewards
  struct Rewards {
    uint16 levels;
    uint32 experience;
    uint32 fur;
    uint128 loot;
  }

  // Stored data structure in Furballs master contract which keeps track of mutable data
  struct Furball {
    uint32 number;        // Overall number, starting with 1
    uint16 count;         // Index within the collection
    uint16 rarity;        // Total rarity score for later boosts
    uint32 experience;    // EXP
    uint32 zone;          // When exploring, the zone number. Otherwise, battling.
    uint16 level;         // Current EXP => level; can change based on level up during collect
    uint16 weight;        // Total weight (number of items in inventory)
    uint64 birth;         // Timestamp of furball creation
    uint64 trade;         // Timestamp of last furball trading wallets
    uint64 last;          // Timestamp of last action (battle/explore)
    uint32 moves;         // The size of the collection array for this furball, which is move num.
    uint256[] inventory;  // IDs of items in inventory
  }

  // A runtime-calculated set of properties that can affect Furball production during collect()
  struct RewardModifiers {
    uint16 expPercent;
    uint16 furPercent;
    uint16 luckPercent;
    uint16 happinessPoints;
    uint16 energyPoints;
    uint32 zone;
  }

  // For sale via loot engine.
  struct Snack {
    uint32 snackId;       // Unique ID
    uint32 duration;      // How long it lasts, !expressed in intervals!
    uint16 furCost;       // How much FUR
    uint16 happiness;     // +happiness bost points
    uint16 energy;        // +energy boost points
    uint16 count;         // How many in stack?
    uint64 fed;           // When was it fed (if it is active)?
  }

  // Input to the feed() function for multi-play
  struct Feeding {
    uint256 tokenId;
    uint32 snackId;
    uint16 count;
  }

  uint32 public constant Max32 = type(uint32).max;

  uint8 public constant PERMISSION_USER = 1;
  uint8 public constant PERMISSION_MODERATOR = 2;
  uint8 public constant PERMISSION_ADMIN = 4;
  uint8 public constant PERMISSION_OWNER = 5;
  uint8 public constant PERMISSION_CONTRACT = 0x10;

  uint32 public constant EXP_PER_INTERVAL = 500;
  uint32 public constant FUR_PER_INTERVAL = 100;

  uint8 public constant LOOT_BYTE_STAT = 1;
  uint8 public constant LOOT_BYTE_RARITY = 2;

  uint8 public constant SNACK_BYTE_ENERGY = 0;
  uint8 public constant SNACK_BYTE_HAPPINESS = 2;

  uint256 public constant OnePercent = 1000;
  uint256 public constant OneHundredPercent = 100000;

  /// @notice Shortcut for equations that saves gas
  /// @dev The expression (0x100 ** byteNum) is expensive; this covers byte packing for editions.
  function bytePower(uint8 byteNum) internal pure returns (uint256) {
    if (byteNum == 0) return 0x1;
    if (byteNum == 1) return 0x100;
    if (byteNum == 2) return 0x10000;
    if (byteNum == 3) return 0x1000000;
    if (byteNum == 4) return 0x100000000;
    if (byteNum == 5) return 0x10000000000;
    if (byteNum == 6) return 0x1000000000000;
    if (byteNum == 7) return 0x100000000000000;
    if (byteNum == 8) return 0x10000000000000000;
    if (byteNum == 9) return 0x1000000000000000000;
    if (byteNum == 10) return 0x100000000000000000000;
    if (byteNum == 11) return 0x10000000000000000000000;
    if (byteNum == 12) return 0x1000000000000000000000000;
    return (0x100 ** byteNum);
  }

  /// @notice Helper to get a number of bytes from a value
  function extractBytes(uint value, uint8 startAt, uint8 numBytes) internal pure returns (uint) {
    return (value / bytePower(startAt)) % bytePower(numBytes);
  }

  /// @notice Converts exp into a sqrt-able number.
  function expToLevel(uint32 exp, uint32 maxExp) internal pure returns(uint256) {
    exp = exp > maxExp ? maxExp : exp;
    return sqrt(exp < 100 ? 0 : ((exp + exp - 100) / 100));
  }

  /// @notice Simple square root function using the Babylonian method
  function sqrt(uint32 x) internal pure returns(uint256) {
    if (x < 1) return 0;
    if (x < 4) return 1;
    uint z = (x + 1) / 2;
    uint y = x;
    while (z < y) {
      y = z;
      z = (x / z + z) / 2;
    }
    return y;
  }

  /// @notice Convert bytes into a hex str, e.g., an address str
  function bytesHex(bytes memory data) internal pure returns(string memory) {
    bytes memory alphabet = "0123456789abcdef";

    bytes memory str = new bytes(data.length * 2);
    for (uint i = 0; i < data.length; i++) {
        str[i*2] = alphabet[uint(uint8(data[i] >> 4))];
        str[1 + i*2] = alphabet[uint(uint8(data[i] & 0x0f))];
    }
    return string(str);
  }

  function uint2str(uint _i) internal pure returns (string memory _uintAsString) {
    if (_i == 0) {
      return "0";
    }
    uint j = _i;
    uint len;
    while (j != 0) {
      len++;
      j /= 10;
    }
    bytes memory bstr = new bytes(len);
    uint k = len;
    while (_i != 0) {
      k = k-1;
      uint8 temp = (48 + uint8(_i - _i / 10 * 10));
      bytes1 b1 = bytes1(temp);
      bstr[k] = b1;
      _i /= 10;
    }
    return string(bstr);
  }

  function encode(bytes memory data) internal pure returns (string memory) {
    if (data.length == 0) return "";

    string memory table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    uint256 encodedLen = 4 * ((data.length + 2) / 3);
    string memory result = new string(encodedLen + 32);

    assembly {
      mstore(result, encodedLen)
      let tablePtr := add(table, 1)

      let dataPtr := data
      let endPtr := add(dataPtr, mload(data))
      let resultPtr := add(result, 32)

      for {

      } lt(dataPtr, endPtr) {

      } {
        dataPtr := add(dataPtr, 3)
        let input := mload(dataPtr)
        mstore(
          resultPtr,
          shl(248, mload(add(tablePtr, and(shr(18, input), 0x3F))))
        )
        resultPtr := add(resultPtr, 1)
        mstore(
          resultPtr,
          shl(248, mload(add(tablePtr, and(shr(12, input), 0x3F))))
        )
        resultPtr := add(resultPtr, 1)
        mstore(
          resultPtr,
          shl(248, mload(add(tablePtr, and(shr(6, input), 0x3F))))
        )
        resultPtr := add(resultPtr, 1)
        mstore(
          resultPtr,
          shl(248, mload(add(tablePtr, and(input, 0x3F))))
        )
        resultPtr := add(resultPtr, 1)
      }

      switch mod(mload(data), 3)
      case 1 {
        mstore(sub(resultPtr, 2), shl(240, 0x3d3d))
      }
      case 2 {
        mstore(sub(resultPtr, 1), shl(248, 0x3d))
      }
    }

    return result;
  }
}

File 8 of 35 : FurDefs.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.6;

import "./FurLib.sol";

/// @title FurLib
/// @author LFG Gaming LLC
/// @notice Public utility library around game-specific equations and constants
library FurDefs {
  function rarityName(uint8 rarity) internal pure returns(string memory) {
    if (rarity == 0) return "Common";
    if (rarity == 1) return "Elite";
    if (rarity == 2) return "Mythic";
    if (rarity == 3) return "Legendary";
    return "Ultimate";
  }

  function raritySuffix(uint8 rarity) internal pure returns(string memory) {
    return rarity == 0 ? "" : string(abi.encodePacked(" (", rarityName(rarity), ")"));
  }

  function renderPoints(uint64 ptr, bytes memory data) internal pure returns (uint64, bytes memory) {
    uint8 cnt = uint8(data[ptr]);
    ptr++;
    bytes memory points = "";
    for (uint256 i=0; i<cnt; i++) {
      uint16 x = uint8(data[ptr]) * 256 + uint8(data[ptr + 1]);
      uint16 y = uint8(data[ptr + 2]) * 256 + uint8(data[ptr + 3]);
      points = abi.encodePacked(points, FurLib.uint2str(x), ',', FurLib.uint2str(y), i == (cnt - 1) ? '': ' ');
      ptr += 4;
    }
    return (ptr, abi.encodePacked('points="', points, '" '));
  }

  function renderTransform(uint64 ptr, bytes memory data) internal pure returns (uint64, bytes memory) {
    uint8 len = uint8(data[ptr]);
    ptr++;
    bytes memory points = "";
    for (uint256 i=0; i<len; i++) {
      bytes memory point = "";
      (ptr, point) =  unpackFloat(ptr, data);
      points = i == (len - 1) ? abi.encodePacked(points, point) : abi.encodePacked(points, point, ' ');
    }
    return (ptr, abi.encodePacked('transform="matrix(', points, ')" '));
  }

  function renderDisplay(uint64 ptr, bytes memory data) internal pure returns (uint64, bytes memory) {
    string[2] memory vals = ['inline', 'none'];
    return (ptr + 1, abi.encodePacked('display="', vals[uint8(data[ptr])], '" '));
  }

  function renderFloat(uint64 ptr, bytes memory data) internal pure returns (uint64, bytes memory) {
    uint8 propType = uint8(data[ptr]);
    string[2] memory floatMap = ['opacity', 'offset'];
    bytes memory floatVal = "";
    (ptr, floatVal) =  unpackFloat(ptr + 1, data);
    return (ptr, abi.encodePacked(floatMap[propType], '="', floatVal,'" '));
  }

  function  unpackFloat(uint64 ptr, bytes memory data) internal pure returns(uint64, bytes memory) {
    uint8 decimals = uint8(data[ptr]);
    ptr++;
    if (decimals == 0) return (ptr, '0');
    uint8 hi = decimals / 16;
    uint16 wholeNum = 0;
    decimals = decimals % 16;
    if (hi >= 10) {
      wholeNum = uint16(uint8(data[ptr]) * 256 + uint8(data[ptr + 1]));
      ptr += 2;
    } else if (hi >= 8) {
      wholeNum = uint16(uint8(data[ptr]));
      ptr++;
    }
    if (decimals == 0) return (ptr, abi.encodePacked(hi % 2 == 1 ? '-' : '', FurLib.uint2str(wholeNum)));

    bytes memory remainder = new bytes(decimals);
    for (uint8 d=0; d<decimals; d+=2) {
      remainder[d] = bytes1(48 + uint8(data[ptr] >> 4));
      if ((d + 1) < decimals) {
        remainder[d+1] = bytes1(48 + uint8(data[ptr] & 0x0f));
      }
      ptr++;
    }
    return (ptr, abi.encodePacked(hi % 2 == 1 ? '-' : '', FurLib.uint2str(wholeNum), '.', remainder));
  }

  function renderInt(uint64 ptr, bytes memory data) internal pure returns (uint64, bytes memory) {
    uint8 propType = uint8(data[ptr]);
    string[13] memory intMap = ['cx', 'cy', 'x', 'x1', 'x2', 'y', 'y1', 'y2', 'r', 'rx', 'ry', 'width', 'height'];
    uint16 val = uint16(uint8(data[ptr + 1]) * 256) + uint8(data[ptr + 2]);
    if (val >= 0x8000) {
      return (ptr + 3, abi.encodePacked(intMap[propType], '="-', FurLib.uint2str(uint32(0x10000 - val)),'" '));
    }
    return (ptr + 3, abi.encodePacked(intMap[propType], '="', FurLib.uint2str(val),'" '));
  }

  function renderStr(uint64 ptr, bytes memory data) internal pure returns(uint64, bytes memory) {
    string[4] memory strMap = ['id', 'enable-background', 'gradientUnits', 'gradientTransform'];
    uint8 t = uint8(data[ptr]);
    require(t < 4, 'STR');
    bytes memory str = "";
    (ptr, str) =  unpackStr(ptr + 1, data);
    return (ptr, abi.encodePacked(strMap[t], '="', str, '" '));
  }

  function unpackStr(uint64 ptr, bytes memory data) internal pure returns(uint64, bytes memory) {
    uint8 len = uint8(data[ptr]);
    bytes memory str = bytes(new string(len));
    for (uint8 i=0; i<len; i++) {
      str[i] = data[ptr + 1 + i];
    }
    return (ptr + 1 + len, str);
  }
}

File 9 of 35 : FurProxy.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.6;

import "../Furballs.sol";
import "./FurLib.sol";

/// @title FurProxy
/// @author LFG Gaming LLC
/// @notice Manages a link from a sub-contract back to the master Furballs contract
/// @dev Provides permissions by means of proxy
abstract contract FurProxy {
  Furballs public furballs;

  constructor(address furballsAddress) {
    furballs = Furballs(furballsAddress);
  }

  /// @notice Allow upgrading contract links
  function setFurballs(address addr) external onlyOwner {
    furballs = Furballs(addr);
  }

  /// @notice Proxied from permissions lookup
  modifier onlyOwner() {
    require(_permissions(msg.sender) >= FurLib.PERMISSION_OWNER, "OWN");
    _;
  }

  /// @notice Permission modifier for moderators (covers owner)
  modifier gameAdmin() {
    require(_permissions(msg.sender) >= FurLib.PERMISSION_ADMIN, "GAME");
    _;
  }

  /// @notice Permission modifier for moderators (covers admin)
  modifier gameModerators() {
    require(_permissions(msg.sender) >= FurLib.PERMISSION_MODERATOR, "MOD");
    _;
  }

  modifier onlyFurballs() {
    require(msg.sender == address(furballs), "FBL");
    _;
  }

  /// @notice Generalized permissions flag for a given address
  function _permissions(address addr) internal view returns (uint8) {
    // User permissions will return "zero" quickly if this didn't come from a wallet.
    uint8 permissions = _userPermissions(addr);
    if (permissions > 0) return permissions;

    if (addr == address(furballs) ||
      addr == address(furballs.engine()) ||
      addr == address(furballs.furgreement()) ||
      addr == address(furballs.governance()) ||
      addr == address(furballs.fur())
    ) {
      return FurLib.PERMISSION_CONTRACT;
    }
    return 0;
  }

  function _userPermissions(address addr) internal view returns (uint8) {
    // Invalid addresses include contracts an non-wallet interactions, which have no permissions
    if (addr == address(0)) return 0;
    uint256 size;
    assembly { size := extcodesize(addr) }
    if (addr != tx.origin || size != 0) return 0;

    if (addr == furballs.owner()) return FurLib.PERMISSION_OWNER;
    if (furballs.isAdmin(addr)) return FurLib.PERMISSION_ADMIN;
    if (furballs.isModerator(addr)) return FurLib.PERMISSION_MODERATOR;
    return FurLib.PERMISSION_USER;
  }
}

File 10 of 35 : Moderated.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.6;

import "@openzeppelin/contracts/access/Ownable.sol";

/// @title Moderated
/// @author LFG Gaming LLC
/// @notice Administration & moderation permissions utilities
abstract contract Moderated is Ownable {
  mapping (address => bool) public admins;
  mapping (address => bool) public moderators;

  function setAdmin(address addr, bool set) external onlyOwner {
    require(addr != address(0));
    admins[addr] = set;
  }

  /// @notice Moderated ownables may not be renounced (only transferred)
  function renounceOwnership() public override onlyOwner {
    require(false, 'OWN');
  }

  function setModerator(address mod, bool set) external onlyAdmin {
    require(mod != address(0));
    moderators[mod] = set;
  }

  function isAdmin(address addr) public virtual view returns(bool) {
    return owner() == addr || admins[addr];
  }

  function isModerator(address addr) public virtual view returns(bool) {
    return isAdmin(addr) || moderators[addr];
  }

  modifier onlyModerators() {
    require(isModerator(msg.sender), 'MOD');
    _;
  }

  modifier onlyAdmin() {
    require(isAdmin(msg.sender), 'ADMIN');
    _;
  }
}

File 11 of 35 : Governance.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.6;

import "./Stakeholders.sol";
import "./Community.sol";
import "./FurLib.sol";

/// @title Governance
/// @author LFG Gaming LLC
/// @notice Meta-tracker for Furballs; looks at the ecosystem (metadata, wallet counts, etc.)
/// @dev Shares is an ERC20; stakeholders is a payable
contract Governance is Stakeholders {
  /// @notice Where transaction fees are deposited
  address payable public treasury;

  /// @notice How much is the transaction fee, in basis points?
  uint16 public transactionFee = 250;

  /// @notice Used in contractURI for Furballs itself.
  string public metaName = "Furballs.com (Official)";

  /// @notice Used in contractURI for Furballs itself.
  string public metaDescription =
    "Furballs are entirely on-chain, with a full interactive gameplay experience at Furballs.com. "
    "There are 88 billion+ possible furball combinations in the first edition, each with their own special abilities"
    "... but only thousands minted per edition. Each edition has new artwork, game modes, and surprises.";

  // Tracks the MAX which are ever owned by a given address.
  mapping(address => FurLib.Account) private _account;

  // List of all addresses which have ever owned a furball.
  address[] public accounts;

  Community public community;

  constructor(address furballsAddress) Stakeholders(furballsAddress) {
    treasury = payable(this);
  }

  /// @notice Generic form of contractURI for on-chain packing.
  /// @dev Proxied from Furballs, but not called contractURI so as to not imply this ERC20 is tradeable.
  function metaURI() public view returns(string memory) {
    return string(abi.encodePacked("data:application/json;base64,", FurLib.encode(abi.encodePacked(
      '{"name": "', metaName,'", "description": "', metaDescription,'"',
      ', "external_link": "https://furballs.com"',
      ', "image": "https://furballs.com/images/pfp.png"',
      ', "seller_fee_basis_points": ', FurLib.uint2str(transactionFee),
      ', "fee_recipient": "0x', FurLib.bytesHex(abi.encodePacked(treasury)), '"}'
    ))));
  }

  /// @notice total count of accounts
  function numAccounts() external view returns(uint256) {
    return accounts.length;
  }

  /// @notice Update metadata for main contractURI
  function setMeta(string memory nameVal, string memory descVal) external gameAdmin {
    metaName = nameVal;
    metaDescription = descVal;
  }

  /// @notice The transaction fee can be adjusted
  function setTransactionFee(uint16 basisPoints) external gameAdmin {
    transactionFee = basisPoints;
  }

  /// @notice The treasury can be changed in only rare circumstances.
  function setTreasury(address treasuryAddress) external onlyOwner {
    treasury = payable(treasuryAddress);
  }

  /// @notice The treasury can be changed in only rare circumstances.
  function setCommunity(address communityAddress) external onlyOwner {
    community = Community(communityAddress);
  }

  /// @notice public accessor updates permissions
  function getAccount(address addr) external view returns (FurLib.Account memory) {
    FurLib.Account memory acc = _account[addr];
    acc.permissions = _userPermissions(addr);
    return acc;
  }

  /// @notice Public function allowing manual update of standings
  function updateStandings(address[] memory addrs) public {
    for (uint32 i=0; i<addrs.length; i++) {
      _updateStanding(addrs[i]);
    }
  }

  /// @notice Moderators may assign reputation to accounts
  function setReputation(address addr, uint16 rep) external gameModerators {
    _account[addr].reputation = rep;
  }

  /// @notice Tracks the max level an account has *obtained*
  function updateMaxLevel(address addr, uint16 level) external gameAdmin {
    if (_account[addr].maxLevel >= level) return;
    _account[addr].maxLevel = level;
    _updateStanding(addr);
  }

  /// @notice Recompute max stats for the account.
  function updateAccount(address addr, uint256 numFurballs) external gameAdmin {
    FurLib.Account memory acc = _account[addr];

    // Recompute account permissions for internal rewards
    uint8 permissions = _userPermissions(addr);
    if (permissions != acc.permissions) _account[addr].permissions = permissions;

    // New account created?
    if (acc.created == 0) _account[addr].created = uint64(block.timestamp);
    if (acc.numFurballs != numFurballs) _account[addr].numFurballs = uint32(numFurballs);

    // New max furballs?
    if (numFurballs > acc.maxFurballs) {
      if (acc.maxFurballs == 0) accounts.push(addr);
      _account[addr].maxFurballs = uint32(numFurballs);
    }
    _updateStanding(addr);
  }

  /// @notice Re-computes the account's standing
  function _updateStanding(address addr) internal {
    uint256 standing = 0;
    FurLib.Account memory acc = _account[addr];

    if (address(community) != address(0)) {
      // If community is patched in later...
      standing = community.update(acc, addr);
    } else {
      // Default computation of standing
      uint32 num = acc.numFurballs;
      if (num > 0) {
        standing = num * 10 + acc.maxLevel + acc.reputation;
      }
    }

    _account[addr].standing = uint16(standing);
  }
}

File 12 of 35 : Fur.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.6;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./Furballs.sol";
import "./editions/IFurballEdition.sol";
import "./utils/FurProxy.sol";

/// @title Fur
/// @author LFG Gaming LLC
/// @notice Utility token for in-game rewards in Furballs
contract Fur is ERC20, FurProxy {
  // n.b., this contract has some unusual tight-coupling between FUR and Furballs
  // Simple reason: this contract had more space, and is the only other allowed to know about ownership
  // Thus it serves as a sort of shop meta-store for Furballs

  // tokenId => mapping of fed _snacks
  mapping(uint256 => FurLib.Snack[]) public _snacks;

  // Internal cache for speed.
  uint256 private _intervalDuration;

  constructor(address furballsAddress) FurProxy(furballsAddress) ERC20("Fur", "FUR") {
    _intervalDuration = furballs.intervalDuration();
  }

  // -----------------------------------------------------------------------------------------------
  // Public
  // -----------------------------------------------------------------------------------------------

  /// @notice Returns the snacks currently applied to a Furball
  function snacks(uint256 tokenId) external view returns(FurLib.Snack[] memory) {
    return _snacks[tokenId];
  }

  /// @notice Write-function to cleanup the snacks for a token (remove expired)
  function cleanSnacks(uint256 tokenId) public returns (uint256) {
    if (_snacks[tokenId].length == 0) return 0;
    return _cleanSnack(tokenId, 0);
  }

  /// @notice The public accessor calculates the snack boosts
  function snackEffects(uint256 tokenId) external view returns(uint256) {
    uint16 hap = 0;
    uint16 en = 0;

    for (uint32 i=0; i<_snacks[tokenId].length && i <= FurLib.Max32; i++) {
      uint256 remaining = _snackTimeRemaning(_snacks[tokenId][i]);
      if (remaining > 0) {
        hap += _snacks[tokenId][i].happiness;
        en += _snacks[tokenId][i].energy;
      }
    }

    return (hap * 0x10000) + (en);
  }

  // -----------------------------------------------------------------------------------------------
  // GameAdmin
  // -----------------------------------------------------------------------------------------------

  /// @notice FUR can only be minted by furballs doing battle.
  function earn(address addr, uint256 amount) external gameAdmin {
    if (amount == 0) return;
    _mint(addr, amount);
  }

  /// @notice FUR can be spent by Furballs, or by the LootEngine (shopping, in the future)
  function spend(address addr, uint256 amount) external gameAdmin {
    _burn(addr, amount);
  }

  /// @notice Pay any necessary fees to mint a furball
  /// @dev Delegated logic from Furballs;
  function purchaseMint(
    address from, uint8 permissions, address to, IFurballEdition edition
  ) external gameAdmin returns (bool) {
    require(edition.maxMintable(to) > 0, "LIVE");
    uint32 cnt = edition.count();

    uint32 adoptable = edition.maxAdoptable();
    bool requiresPurchase = cnt >= adoptable;

    if (requiresPurchase) {
      // _gift will throw if cannot gift or cannot afford cost
      _gift(from, permissions, to, edition.purchaseFur());
    }
    return requiresPurchase;
  }

  /// @notice Attempts to purchase an upgrade for a loot item
  /// @dev Delegated logic from Furballs
  function purchaseUpgrade(
    FurLib.RewardModifiers memory modifiers,
    address from, uint8 permissions, uint256 tokenId, uint128 lootId, uint8 chances
  ) external gameAdmin returns(uint128) {
    address owner = furballs.ownerOf(tokenId);

    // _gift will throw if cannot gift or cannot afford cost
    _gift(from, permissions, owner, 500 * uint256(chances));

    return furballs.engine().upgradeLoot(modifiers, owner, lootId, chances);
  }

  /// @notice Attempts to purchase a snack using templates found in the engine
  /// @dev Delegated logic from Furballs
  function purchaseSnack(
    address from, uint8 permissions, uint256 tokenId, uint32 snackId, uint16 count
  ) external gameAdmin {
    FurLib.Snack memory snack = furballs.engine().getSnack(snackId);
    require(snack.count > 0, "COUNT");
    require(snack.fed == 0, "FED");

    // _gift will throw if cannot gift or cannot afford costQ
    _gift(from, permissions, furballs.ownerOf(tokenId), snack.furCost * count);

    uint256 snackData = _cleanSnack(tokenId, snack.snackId);
    uint32 existingSnackNumber = uint32(snackData / 0x100000000);
    snack.count *= count;
    if (existingSnackNumber > 0) {
      // Adding count effectively adds duration to the active snack
      _snacks[tokenId][existingSnackNumber - 1].count += snack.count;
    } else {
      // A new snack just gets pushed onto the array
      snack.fed = uint64(block.timestamp);
      _snacks[tokenId].push(snack);
    }
  }

  // -----------------------------------------------------------------------------------------------
  // Internal
  // -----------------------------------------------------------------------------------------------

  /// @notice Both removes inactive _snacks from a token and searches for a specific snack Id index
  /// @dev Both at once saves some size & ensures that the _snacks are frequently cleaned.
  /// @return The index+1 of the existing snack
  function _cleanSnack(uint256 tokenId, uint32 snackId) internal returns(uint256) {
    uint32 ret = 0;
    uint16 hap = 0;
    uint16 en = 0;
    for (uint32 i=1; i<=_snacks[tokenId].length && i <= FurLib.Max32; i++) {
      FurLib.Snack memory snack = _snacks[tokenId][i-1];
      // Has the snack transitioned from active to inactive?
      if (_snackTimeRemaning(snack) == 0) {
        if (_snacks[tokenId].length > 1) {
          _snacks[tokenId][i-1] = _snacks[tokenId][_snacks[tokenId].length - 1];
        }
        _snacks[tokenId].pop();
        i--; // Repeat this idx
        continue;
      }
      hap += snack.happiness;
      en += snack.energy;
      if (snackId != 0 && snack.snackId == snackId) {
        ret = i;
      }
    }
    return (ret * 0x100000000) + (hap * 0x10000) + (en);
  }

  /// @notice Check if the snack is active; returns 0 if inactive, otherwise the duration
  function _snackTimeRemaning(FurLib.Snack memory snack) internal view returns(uint256) {
    if (snack.fed == 0) return 0;
    uint256 expiresAt = uint256(snack.fed + (snack.count * snack.duration * _intervalDuration));
    return expiresAt <= block.timestamp ? 0 : (expiresAt - block.timestamp);
  }

  /// @notice Enforces (requires) only admins/game may give gifts
  /// @param to Whom is this being sent to?
  /// @return If this is a gift or not.
  function _gift(address from, uint8 permissions, address to, uint256 furCost) internal returns(bool) {
    bool isGift = to != from;

    // Only admins or game engine can send gifts (to != self), which are always free.
    require(!isGift || permissions >= FurLib.PERMISSION_ADMIN, "GIFT");

    if (!isGift && furCost > 0) {
      _burn(from, furCost);
    }

    return isGift;
  }
}

File 13 of 35 : Furgreement.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.6;

import "./Furballs.sol";
import "./utils/FurProxy.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";

/// @title Furballs
/// @author LFG Gaming LLC
/// @notice Has permissions to act as a proxy to the Furballs contract
/// @dev https://soliditydeveloper.com/ecrecover
contract Furgreement is EIP712, FurProxy {
  mapping(address => uint256) private nonces;

  address[] public addressQueue;

  mapping(address => PlayMove) public pendingMoves;

  // A "move to be made" in the sig queue
  struct PlayMove {
    uint32 zone;
    uint256[] tokenIds;
  }

  constructor(address furballsAddress) EIP712("Furgreement", "1") FurProxy(furballsAddress) { }

  /// @notice Proxy playMany to Furballs contract
  function playFromSignature(
    bytes memory signature,
    address owner,
    PlayMove memory move,
    uint256 deadline
  ) external {
    bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
      keccak256("playMany(address owner,PlayMove memory move,uint256 nonce,uint256 deadline)"),
      owner,
      move,
      nonces[owner],
      deadline
    )));

    address signer = ECDSA.recover(digest, signature);
    require(signer == owner, "playMany: invalid signature");
    require(signer != address(0), "ECDSA: invalid signature");

    require(block.timestamp < deadline, "playMany: signed transaction expired");
    nonces[owner]++;

    if (pendingMoves[owner].tokenIds.length == 0) {
      addressQueue.push(owner);
    }
    pendingMoves[owner] = move;
  }
}

File 14 of 35 : ERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: owner query for nonexistent token");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overriden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        require(operator != _msgSender(), "ERC721: approve to caller");

        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _safeTransfer(from, to, tokenId, _data);
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        require(_exists(tokenId), "ERC721: operator query for nonexistent token");
        address owner = ERC721.ownerOf(tokenId);
        return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, _data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param _data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721Receiver.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

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

File 15 of 35 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 16 of 35 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;
}

File 17 of 35 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 18 of 35 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 19 of 35 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

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

pragma solidity ^0.8.0;

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

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 21 of 35 : Strings.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 22 of 35 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

File 23 of 35 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

File 24 of 35 : LootEngine.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.6;

import "./ILootEngine.sol";
import "../editions/IFurballEdition.sol";
import "../Furballs.sol";
import "../utils/FurLib.sol";
import "../utils/FurProxy.sol";
import "../utils/ProxyRegistry.sol";
import "../utils/Dice.sol";
import "../utils/Governance.sol";
import "../utils/MetaData.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";

/// @title LootEngine
/// @author LFG Gaming LLC
/// @notice Base implementation of the loot engine
abstract contract LootEngine is ERC165, ILootEngine, Dice, FurProxy {
  ProxyRegistry private _proxies;

  // An address which may act on behalf of the owner (company)
  address public companyWalletProxy;

  // snackId to "definition" of the snack
  mapping(uint32 => FurLib.Snack) private _snacks;

  uint32 maxExperience = 2010000;

  constructor(
    address furballsAddress, address tradeProxy, address companyProxy
  ) FurProxy(furballsAddress) {
    _proxies = ProxyRegistry(tradeProxy);
    companyWalletProxy = companyProxy;

    _defineSnack(0x100, 24    ,  250, 15, 0);
    _defineSnack(0x200, 24 * 3,  750, 20, 0);
    _defineSnack(0x300, 24 * 7, 1500, 25, 0);
  }

  /// @notice Allows admins to configure the snack store.
  function setSnack(
    uint32 snackId, uint32 duration, uint16 furCost, uint16 hap, uint16 en
  ) external gameAdmin {
    _defineSnack(snackId, duration, furCost, hap, en);
  }

  /// @notice Loot can have different weight to help prevent over-powering a furball
  /// @dev Each point of weight can be offset by a point of energy; the result reduces luck
  function weightOf(uint128 lootId) external virtual override pure returns (uint16) {
    return 2;
  }

  /// @notice Gets called for Metadata
  function furballDescription(uint256 tokenId) external virtual override view returns (string memory) {
    return "";
  }

  /// @notice Gets called at the beginning of token render; could add underlaid artwork
  function render(uint256 tokenId) external virtual override view returns(string memory) {
    return "";
  }

  /// @notice Checking the zone may use _require to detect preconditions.
  function enterZone(
    uint256 tokenId, uint32 zone, uint256[] memory team
  ) external virtual override returns(uint256) {
    // Nothing to see here.
    return uint256(zone);
  }

  /// @notice Proxy logic is presently delegated to OpenSea-like contract
  function canProxyTrades(
    address owner, address operator
  ) external virtual override view onlyFurballs returns(bool) {
    if (address(_proxies) == address(0)) return false;
    return address(_proxies.proxies(owner)) == operator;
  }

  /// @notice Allow a player to play? Throws on error if not.
  /// @dev This is core gameplay security logic
  function approveSender(address sender) external virtual override view onlyFurballs returns(uint) {
    if (sender == companyWalletProxy && sender != address(0)) return FurLib.PERMISSION_OWNER;
    return _permissions(sender);
  }

  /// @notice Calculates new level for experience
  function onExperience(
    FurLib.Furball memory furball, address owner, uint32 experience
  ) external virtual override onlyFurballs returns(uint32 totalExp, uint16 levels) {
    if (experience == 0) return (0, 0);

    uint32 has = furball.experience;
    uint32 max = maxExperience;
    totalExp = (experience < max && has < (max - experience)) ? (has + experience) : max;

    // Calculate new level & check for level-up
    uint16 oldLevel = furball.level;
    uint16 level = uint16(FurLib.expToLevel(totalExp, max));
    levels = level > oldLevel ? (level - oldLevel) : 0;

    if (levels > 0) {
      // Update community standing
      furballs.governance().updateMaxLevel(owner, level);
    }

    return (totalExp, levels);
  }

  /// @notice The trade hook can update balances or assign rewards
  function onTrade(
    FurLib.Furball memory furball, address from, address to
  ) external virtual override onlyFurballs {
    Governance gov = furballs.governance();
    if (from != address(0)) gov.updateAccount(from, furballs.balanceOf(from) - 1);
    if (to != address(0)) gov.updateAccount(to, furballs.balanceOf(to) + 1);
  }

  /// @notice Attempt to upgrade a given piece of loot (item ID)
  function upgradeLoot(
    FurLib.RewardModifiers memory modifiers,
    address owner,
    uint128 lootId,
    uint8 chances
  ) external virtual override returns(uint128) {
    (uint8 rarity, uint8 stat) = _itemRarityStat(lootId);

    require(rarity > 0 && rarity < 3, "RARITY");
    uint32 chance = (rarity == 1 ? 75 : 25) * uint32(chances) + uint32(modifiers.luckPercent * 10);

    // Remove the 100% from loot, with 5% minimum chance
    chance = chance > 1050 ? (chance - 1000) : 50;

    // Even with many chances, odds are capped:
    if (chance > 750) chance = 750;

    uint32 threshold = (FurLib.Max32 / 1000) * (1000 - chance);
    uint256 rolled = (uint256(roll(modifiers.expPercent)));

    return rolled < threshold ? 0 : _packLoot(rarity + 1, stat);
  }

  /// @notice Main loot-drop functionm
  function dropLoot(
    uint32 intervals,
    FurLib.RewardModifiers memory modifiers
  ) external virtual override onlyFurballs returns(uint128) {
    // Only battles drop loot.
    if (modifiers.zone >= 0x10000) return 0;

    (uint8 rarity, uint8 stat) = rollRarityStat(
      uint32((intervals * uint256(modifiers.luckPercent)) /100), 0);
    return _packLoot(rarity, stat);
  }

  function _packLoot(uint16 rarity, uint16 stat) internal pure returns(uint128) {
    return rarity == 0 ? 0 : (uint16(rarity) * 0x10000) + (stat * 0x100);
  }

  /// @notice Core loot drop rarity randomization
  /// @dev exposes an interface helpful for the unit tests, but is not otherwise called publicly
  function rollRarityStat(uint32 chance, uint32 seed) public returns(uint8, uint8) {
    if (chance == 0) return (0, 0);
    uint32 threshold = 4320;
    uint32 rolled = roll(seed) % threshold;
    uint8 stat = uint8(rolled % 2);

    if (chance > threshold || rolled >= (threshold - chance)) return (3, stat);
    threshold -= chance;
    if (chance * 3 > threshold || rolled >= (threshold - chance * 3)) return (2, stat);
    threshold -= chance * 3;
    if (chance * 6 > threshold || rolled >= (threshold - chance * 6)) return (1, stat);
    return (0, stat);
  }

  /// @notice The snack shop has IDs for each snack definition
  function getSnack(uint32 snackId) external view virtual override returns(FurLib.Snack memory) {
    return _snacks[snackId];
  }

  /// @notice Layers on LootEngine modifiers to rewards
  function modifyReward(
    FurLib.Furball memory furball,
    FurLib.RewardModifiers memory modifiers,
    FurLib.Account memory account,
    bool contextual
  ) external virtual override view returns(FurLib.RewardModifiers memory) {
    // Use temporary variables instead of re-assignment
    uint16 energy = modifiers.energyPoints;
    uint16 weight = furball.weight;
    uint16 expPercent = modifiers.expPercent + modifiers.happinessPoints;
    uint16 luckPercent = modifiers.luckPercent + modifiers.happinessPoints;
    uint16 furPercent = modifiers.furPercent + _furBoost(furball.level) + energy;

    // First add in the inventory
    for (uint256 i=0; i<furball.inventory.length; i++) {
      uint128 lootId = uint128(furball.inventory[i] / 0x100);
      uint32 stackSize = uint32(furball.inventory[i] % 0x100);
      (uint8 rarity, uint8 stat) = _itemRarityStat(lootId);
      uint16 boost = uint16(_lootRarityBoost(rarity) * stackSize);
      if (stat == 0) {
        expPercent += boost;
      } else {
        furPercent += boost;
      }
    }

    // Team size boosts!
    uint256 teamSize = account.permissions < 2 ? account.numFurballs : 0;
    if (teamSize < 10 && teamSize > 1) {
      uint16 amt = uint16(2 * (teamSize - 1));
      expPercent += amt;
      furPercent += amt;
    }

    // ---------------------------------------------------------------------------------------------
    // Negative impacts come last, so subtraction does not underflow.
    // ---------------------------------------------------------------------------------------------

    // Penalties for whales.
    if (teamSize > 10) {
      uint16 amt = uint16(5 * (teamSize > 20 ? 10 : (teamSize - 10)));
      expPercent -= amt;
      furPercent -= amt;
    }

    // Calculate weight & reduce luck
    if (weight > 0) {
      if (energy > 0) {
        weight = (energy >= weight) ? 0 : (weight - energy);
      }
      if (weight > 0) {
        luckPercent = weight >= luckPercent ? 0 : (luckPercent - weight);
      }
    }

    modifiers.expPercent = expPercent;
    modifiers.furPercent = furPercent;
    modifiers.luckPercent = luckPercent;

    return modifiers;
  }

  /// @notice OpenSea metadata
  function attributesMetadata(
    uint256 tokenId
  ) external virtual override view returns(bytes memory) {
    FurLib.FurballStats memory stats = furballs.stats(tokenId, false);
    return abi.encodePacked(
      MetaData.traitValue("Level", stats.definition.level),
      MetaData.traitValue("Rare Genes Boost", stats.definition.rarity),
      MetaData.traitNumber("Edition", (tokenId % 0x100) + 1),
      MetaData.traitNumber("Unique Loot Collected", stats.definition.inventory.length),
      MetaData.traitBoost("EXP Boost", stats.modifiers.expPercent),
      MetaData.traitBoost("FUR Boost", stats.modifiers.furPercent),
      MetaData.traitDate("Acquired", stats.definition.trade),
      MetaData.traitDate("Birthday", stats.definition.birth)
    );
  }

  /// @notice Store a new snack definition
  function _defineSnack(
    uint32 snackId, uint32 duration, uint16 furCost, uint16 hap, uint16 en
  ) internal {
    _snacks[snackId].snackId = snackId;
    _snacks[snackId].duration = duration;
    _snacks[snackId].furCost = furCost;
    _snacks[snackId].happiness = hap;
    _snacks[snackId].energy = en;
    _snacks[snackId].count = 1;
    _snacks[snackId].fed = 0;
  }

  function _lootRarityBoost(uint16 rarity) internal pure returns (uint16) {
    if (rarity == 1) return 5;
    else if (rarity == 2) return 15;
    else if (rarity == 3) return 30;
    return 0;
  }

  /// @notice Gets the FUR boost for a given level
  function _furBoost(uint16 level) internal pure returns (uint16) {
    if (level >= 200) return 581;
    if (level < 25) return (2 * level);
    if (level < 50) return (5000 + (level - 25) * 225) / 100;
    if (level < 75) return (10625 + (level - 50) * 250) / 100;
    if (level < 100) return (16875 + (level - 75) * 275) / 100;
    if (level < 125) return (23750 + (level - 100) * 300) / 100;
    if (level < 150) return (31250 + (level - 125) * 325) / 100;
    if (level < 175) return (39375 + (level - 150) * 350) / 100;
    return (48125 + (level - 175) * 375) / 100;
  }

  /// @notice Unpacks an item, giving its rarity + stat
  function _itemRarityStat(uint128 lootId) internal pure returns (uint8, uint8) {
    return (
      uint8(FurLib.extractBytes(lootId, FurLib.LOOT_BYTE_RARITY, 1)),
      uint8(FurLib.extractBytes(lootId, FurLib.LOOT_BYTE_STAT, 1)));
  }

  function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
    return
      interfaceId == type(ILootEngine).interfaceId ||
      super.supportsInterface(interfaceId);
  }
}

File 25 of 35 : ProxyRegistry.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.6;

// Contract doesn't really provide anything...
contract OwnableDelegateProxy {}

// Required format for OpenSea of proxy delegate store
// https://github.com/ProjectOpenSea/opensea-creatures/blob/f7257a043e82fae8251eec2bdde37a44fee474c4/contracts/ERC721Tradable.sol
// https://etherscan.io/address/0xa5409ec958c83c3f309868babaca7c86dcb077c1#code
contract ProxyRegistry {
  mapping(address => OwnableDelegateProxy) public proxies;
}

File 26 of 35 : Dice.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.6;

import "./FurLib.sol";

/// @title Dice
/// @author LFG Gaming LLC
/// @notice Math utility functions that leverage storage and thus cannot be pure
abstract contract Dice {
  uint32 private LAST = 0; // Re-seed for PRNG

  /// @notice A PRNG which re-seeds itself with block information & another PRNG
  /// @dev This is unit-tested with monobit (frequency) and longestRunOfOnes
  function roll(uint32 seed) public returns (uint32) {
    LAST = uint32(uint256(keccak256(
      abi.encodePacked(block.timestamp, block.basefee, _prng(LAST == 0 ? seed : LAST)))
    ));
    return LAST;
  }

  /// @notice A PRNG based upon a Lehmer (Park-Miller) method
  /// @dev https://en.wikipedia.org/wiki/Lehmer_random_number_generator
  function _prng(uint32 seed) internal view returns (uint32) {
    uint64 nonce = seed == 0 ? uint32(block.timestamp) : seed;
    uint64 product = uint64(nonce) * 48271;
    uint32 x = uint32((product % 0x7fffffff) + (product >> 31));
    return (x & 0x7fffffff) + (x >> 31);
  }
}

File 27 of 35 : MetaData.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.6;

import "./FurLib.sol";

/// @title MetaData
/// @author LFG Gaming LLC
/// @notice Utilities for creating MetaData (e.g., OpenSea)
library MetaData {
  function trait(string memory traitType, string memory value) internal pure returns (bytes memory) {
    return abi.encodePacked('{"trait_type": "', traitType,'", "value": "', value, '"}, ');
  }

  function traitNumberDisplay(
    string memory traitType, string memory displayType, uint256 value
  ) internal pure returns (bytes memory) {
    return abi.encodePacked(
      '{"trait_type": "', traitType,
      bytes(displayType).length > 0 ? '", "display_type": "' : '', displayType,
      '", "value": ', FurLib.uint2str(value), '}, '
    );
  }

  function traitValue(string memory traitType, uint256 value) internal pure returns (bytes memory) {
    return traitNumberDisplay(traitType, "", value);
  }

  /// @notice Convert a modifier percentage (120%) into a metadata +20% boost
  function traitBoost(
    string memory traitType, uint256 percent
  ) internal pure returns (bytes memory) {
    return traitNumberDisplay(traitType, "boost_percentage", percent > 100 ? (percent - 100) : 0);
  }

  function traitNumber(
    string memory traitType, uint256 value
  ) internal pure returns (bytes memory) {
    return traitNumberDisplay(traitType, "number", value);
  }

  function traitDate(
    string memory traitType, uint256 value
  ) internal pure returns (bytes memory) {
    return traitNumberDisplay(traitType, "date", value);
  }
}

File 28 of 35 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _setOwner(_msgSender());
    }

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

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

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

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

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 29 of 35 : Stakeholders.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.6;

import "./FurProxy.sol";
import "./FurLib.sol";
import "../Furballs.sol";

/// @title Stakeholders
/// @author LFG Gaming LLC
/// @notice Tracks "percent ownership" of a smart contract, paying out according to schedule
/// @dev Acts as a treasury, receiving ETH funds and distributing them to stakeholders
abstract contract Stakeholders is FurProxy {
  // stakeholder values, in 1/1000th of a percent (received during withdrawls)
  mapping(address => uint64) public stakes;

  // List of stakeholders.
  address[] public stakeholders;

  // Where any remaining funds should be deposited. Defaults to contract creator.
  address payable public poolAddress;

  constructor(address furballsAddress) FurProxy(furballsAddress) {
    poolAddress = payable(msg.sender);
  }

  /// @notice Overflow pool of funds. Contains remaining funds from withdrawl.
  function setPool(address addr) public onlyOwner {
    poolAddress = payable(addr);
  }

  /// @notice Changes payout percentages.
  function setStakeholder(address addr, uint64 stake) public onlyOwner {
    if (!_hasStakeholder(addr)) {
      stakeholders.push(addr);
    }
    uint64 percent = stake;
    for (uint256 i=0; i<stakeholders.length; i++) {
      if (stakeholders[i] != addr) {
        percent += stakes[stakeholders[i]];
      }
    }

    require(percent <= FurLib.OneHundredPercent, "Invalid stake (exceeds 100%)");
    stakes[addr] = stake;
  }

  /// @notice Empties this contract's balance, paying out to stakeholders.
  function withdraw() external gameAdmin {
    uint256 balance = address(this).balance;
    require(balance >= FurLib.OneHundredPercent, "Insufficient balance");

    for (uint256 i=0; i<stakeholders.length; i++) {
      address addr = stakeholders[i];
      uint256 payout = balance * uint256(stakes[addr]) / FurLib.OneHundredPercent;
      if (payout > 0) {
        payable(addr).transfer(payout);
      }
    }
    uint256 remaining = address(this).balance;
    poolAddress.transfer(remaining);
  }

  /// @notice Check
  function _hasStakeholder(address addr) internal view returns(bool) {
    for (uint256 i=0; i<stakeholders.length; i++) {
      if (stakeholders[i] == addr) {
        return true;
      }
    }
    return false;
  }

  // -----------------------------------------------------------------------------------------------
  // Payable
  // -----------------------------------------------------------------------------------------------

  /// @notice This contract can be paid transaction fees, e.g., from OpenSea
  /// @dev The contractURI specifies itself as the recipient of transaction fees
  receive() external payable { }
}

File 30 of 35 : Community.sol
// SPDX-License-Identifier: BSD-3-Clause

/// @title Vote checkpointing for an ERC-721 token

/// @dev This ERC20 has been adopted from
///  https://github.com/nounsDAO/nouns-monorepo/blob/master/packages/nouns-contracts/contracts/base/ERC721Checkpointable.sol

/*********************************
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░██░░░████░░██░░░████░░░ *
 * ░░██████░░░████████░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 *********************************/

// LICENSE
// Community.sol uses and modifies part of Compound Lab's Comp.sol:
// https://github.com/compound-finance/compound-protocol/blob/ae4388e780a8d596d97619d9704a931a2752c2bc/contracts/Governance/Comp.sol
//
// Comp.sol source code Copyright 2020 Compound Labs, Inc. licensed under the BSD-3-Clause license.
// With modifications by Nounders DAO.
//
// Additional conditions of BSD-3-Clause can be found here: https://opensource.org/licenses/BSD-3-Clause
//
// MODIFICATIONS
// Checkpointing logic from Comp.sol has been used with the following modifications:
// - `delegates` is renamed to `_delegates` and is set to private
// - `delegates` is a public function that uses the `_delegates` mapping look-up, but unlike
//   Comp.sol, returns the delegator's own address if there is no delegate.
//   This avoids the delegator needing to "delegate to self" with an additional transaction
// - `_transferTokens()` is renamed `_beforeTokenTransfer()` and adapted to hook into OpenZeppelin's ERC721 hooks.

pragma solidity ^0.8.6;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./FurLib.sol";

/// @title Community
/// @author LFG Gaming LLC
/// @notice This is a derived token; it represents a weighted balance of the ERC721 token (Furballs).
/// @dev There is no fiscal interest in Community. This is simply a measured value of community voice.
contract Community is ERC20 {
    /// @notice A record of each accounts delegate
    mapping(address => address) private _delegates;

    /// @notice A checkpoint for marking number of votes from a given block
    struct Checkpoint {
        uint32 fromBlock;
        uint96 votes;
    }

    constructor() ERC20("FurballsCommunity", "FBLS") { }

    /// @notice A record of votes checkpoints for each account, by index
    mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;

    /// @notice The number of checkpoints for each account
    mapping(address => uint32) public numCheckpoints;

    /// @notice The EIP-712 typehash for the contract's domain
    bytes32 public constant DOMAIN_TYPEHASH =
        keccak256('EIP712Domain(string name,uint256 chainId,address verifyingContract)');

    /// @notice The EIP-712 typehash for the delegation struct used by the contract
    bytes32 public constant DELEGATION_TYPEHASH =
        keccak256('Delegation(address delegatee,uint256 nonce,uint256 expiry)');

    /// @notice A record of states for signing / validating signatures
    mapping(address => uint256) public nonces;

    /// @notice An event thats emitted when an account changes its delegate
    event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);

    /// @notice An event thats emitted when a delegate account's vote balance changes
    event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);

    /**
     * @notice The votes a delegator can delegate, which is the current balance of the delegator.
     * @dev Used when calling `_delegate()`
     */
    function votesToDelegate(address delegator) public view returns (uint96) {
        return safe96(balanceOf(delegator), 'Community::votesToDelegate: amount exceeds 96 bits');
    }

    /**
     * @notice Overrides the standard `Comp.sol` delegates mapping to return
     * the delegator's own address if they haven't delegated.
     * This avoids having to delegate to oneself.
     */
    function delegates(address delegator) public view returns (address) {
        address current = _delegates[delegator];
        return current == address(0) ? delegator : current;
    }


      /// @notice Sets the addresses' standing directly
      function update(FurLib.Account memory account, address addr) external returns (uint256) {
        require(false, 'NEED SECURITY');
        // uint256 balance = balanceOf(addr);
        // if (standing > balance) {
        //   _mint(addr, standing - balance);
        // } else if (standing < balance) {
        //   _burn(addr, balance - standing);
        // }
      }

    /**
     * @notice Adapted from `_transferTokens()` in `Comp.sol` to update delegate votes.
     * @dev hooks into OpenZeppelin's `ERC721._transfer`
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal override {
        super._beforeTokenTransfer(from, to, amount);

        require(from == address(0), "Votes may not be traded.");

        /// @notice Differs from `_transferTokens()` to use `delegates` override method to simulate auto-delegation
        _moveDelegates(delegates(from), delegates(to), uint96(amount));
    }

    /**
     * @notice Delegate votes from `msg.sender` to `delegatee`
     * @param delegatee The address to delegate votes to
     */
    function delegate(address delegatee) public {
        if (delegatee == address(0)) delegatee = msg.sender;
        return _delegate(msg.sender, delegatee);
    }

    /**
     * @notice Delegates votes from signatory to `delegatee`
     * @param delegatee The address to delegate votes to
     * @param nonce The contract state required to match the signature
     * @param expiry The time at which to expire the signature
     * @param v The recovery byte of the signature
     * @param r Half of the ECDSA signature pair
     * @param s Half of the ECDSA signature pair
     */
    function delegateBySig(
        address delegatee,
        uint256 nonce,
        uint256 expiry,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public {
        bytes32 domainSeparator = keccak256(
            abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this))
        );
        bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));
        bytes32 digest = keccak256(abi.encodePacked('\x19\x01', domainSeparator, structHash));
        address signatory = ecrecover(digest, v, r, s);
        require(signatory != address(0), 'Community::delegateBySig: invalid signature');
        require(nonce == nonces[signatory]++, 'Community::delegateBySig: invalid nonce');
        require(block.timestamp <= expiry, 'Community::delegateBySig: signature expired');
        return _delegate(signatory, delegatee);
    }

    /**
     * @notice Gets the current votes balance for `account`
     * @param account The address to get votes balance
     * @return The number of current votes for `account`
     */
    function getCurrentVotes(address account) external view returns (uint96) {
        uint32 nCheckpoints = numCheckpoints[account];
        return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
    }

    /**
     * @notice Determine the prior number of votes for an account as of a block number
     * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
     * @param account The address of the account to check
     * @param blockNumber The block number to get the vote balance at
     * @return The number of votes the account had as of the given block
     */
    function getPriorVotes(address account, uint256 blockNumber) public view returns (uint96) {
        require(blockNumber < block.number, 'Community::getPriorVotes: not yet determined');

        uint32 nCheckpoints = numCheckpoints[account];
        if (nCheckpoints == 0) {
            return 0;
        }

        // First check most recent balance
        if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
            return checkpoints[account][nCheckpoints - 1].votes;
        }

        // Next check implicit zero balance
        if (checkpoints[account][0].fromBlock > blockNumber) {
            return 0;
        }

        uint32 lower = 0;
        uint32 upper = nCheckpoints - 1;
        while (upper > lower) {
            uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
            Checkpoint memory cp = checkpoints[account][center];
            if (cp.fromBlock == blockNumber) {
                return cp.votes;
            } else if (cp.fromBlock < blockNumber) {
                lower = center;
            } else {
                upper = center - 1;
            }
        }
        return checkpoints[account][lower].votes;
    }

    function _delegate(address delegator, address delegatee) internal {
        /// @notice differs from `_delegate()` in `Comp.sol` to use `delegates` override method to simulate auto-delegation
        address currentDelegate = delegates(delegator);

        _delegates[delegator] = delegatee;

        emit DelegateChanged(delegator, currentDelegate, delegatee);

        uint96 amount = votesToDelegate(delegator);

        _moveDelegates(currentDelegate, delegatee, 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 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
                uint96 srcRepNew = sub96(srcRepOld, amount, 'Community::_moveDelegates: amount underflows');
                _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
            }

            if (dstRep != address(0)) {
                uint32 dstRepNum = numCheckpoints[dstRep];
                uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
                uint96 dstRepNew = add96(dstRepOld, amount, 'Community::_moveDelegates: amount overflows');
                _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
            }
        }
    }

    function _writeCheckpoint(
        address delegatee,
        uint32 nCheckpoints,
        uint96 oldVotes,
        uint96 newVotes
    ) internal {
        uint32 blockNumber = safe32(
            block.number,
            'Community::_writeCheckpoint: block number exceeds 32 bits'
        );

        if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
            checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
        } else {
            checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, 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 getChainId() internal view returns (uint256) {
        uint256 chainId;
        assembly {
            chainId := chainid()
        }
        return chainId;
    }
}

File 31 of 35 : ERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

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

        return true;
    }

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

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

        return true;
    }

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

        _beforeTokenTransfer(sender, recipient, amount);

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

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

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

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

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

        _afterTokenTransfer(address(0), account, amount);
    }

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

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

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

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

        _afterTokenTransfer(account, address(0), amount);
    }

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

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

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

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

File 32 of 35 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 33 of 35 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 34 of 35 : ECDSA.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s;
        uint8 v;
        assembly {
            s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
            v := add(shr(255, vs), 27)
        }
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 35 of 35 : draft-EIP712.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./ECDSA.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * _Available since v3.4._
 */
abstract contract EIP712 {
    /* solhint-disable var-name-mixedcase */
    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
    uint256 private immutable _CACHED_CHAIN_ID;

    bytes32 private immutable _HASHED_NAME;
    bytes32 private immutable _HASHED_VERSION;
    bytes32 private immutable _TYPE_HASH;

    /* solhint-enable var-name-mixedcase */

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        bytes32 typeHash = keccak256(
            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
        );
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
        _CACHED_CHAIN_ID = block.chainid;
        _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
        _TYPE_HASH = typeHash;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (block.chainid == _CACHED_CHAIN_ID) {
            return _CACHED_DOMAIN_SEPARATOR;
        } else {
            return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
        }
    }

    function _buildDomainSeparator(
        bytes32 typeHash,
        bytes32 nameHash,
        bytes32 versionHash
    ) private view returns (bytes32) {
        return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"interval","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"responseId","type":"uint256"}],"name":"Collection","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"lootId","type":"uint128"},{"indexed":false,"internalType":"uint16","name":"dropped","type":"uint16"}],"name":"Inventory","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint8","name":"idx","type":"uint8"}],"name":"addEdition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"admins","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"collect","outputs":[{"internalType":"uint16","name":"levels","type":"uint16"},{"internalType":"uint32","name":"experience","type":"uint32"},{"internalType":"uint32","name":"fur","type":"uint32"},{"internalType":"uint128","name":"loot","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"lootId","type":"uint128"},{"internalType":"uint8","name":"count","type":"uint8"}],"name":"drop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"editions","outputs":[{"internalType":"contract IFurballEdition","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"engine","outputs":[{"internalType":"contract ILootEngine","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint32","name":"snackId","type":"uint32"},{"internalType":"uint16","name":"count","type":"uint16"}],"internalType":"struct FurLib.Feeding[]","name":"feedings","type":"tuple[]"},{"internalType":"address","name":"actor","type":"address"}],"name":"feed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fur","outputs":[{"internalType":"contract Fur","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"furballs","outputs":[{"internalType":"uint32","name":"number","type":"uint32"},{"internalType":"uint16","name":"count","type":"uint16"},{"internalType":"uint16","name":"rarity","type":"uint16"},{"internalType":"uint32","name":"experience","type":"uint32"},{"internalType":"uint32","name":"zone","type":"uint32"},{"internalType":"uint16","name":"level","type":"uint16"},{"internalType":"uint16","name":"weight","type":"uint16"},{"internalType":"uint64","name":"birth","type":"uint64"},{"internalType":"uint64","name":"trade","type":"uint64"},{"internalType":"uint64","name":"last","type":"uint64"},{"internalType":"uint32","name":"moves","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"furgreement","outputs":[{"internalType":"contract Furgreement","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governance","outputs":[{"internalType":"contract Governance","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"intervalDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"isAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"isModerator","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"to","type":"address[]"},{"internalType":"uint8","name":"editionIndex","type":"uint8"},{"internalType":"address","name":"actor","type":"address"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"moderators","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"lootId","type":"uint128"}],"name":"pickup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint32","name":"zone","type":"uint32"},{"internalType":"address","name":"actor","type":"address"}],"name":"playMany","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"bool","name":"set","type":"bool"}],"name":"setAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"setEngine","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"furAddress","type":"address"}],"name":"setFur","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"furgAddress","type":"address"}],"name":"setFurgreement","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"setGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"mod","type":"address"},{"internalType":"bool","name":"set","type":"bool"}],"name":"setModerator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bool","name":"contextual","type":"bool"}],"name":"stats","outputs":[{"components":[{"internalType":"uint16","name":"expRate","type":"uint16"},{"internalType":"uint16","name":"furRate","type":"uint16"},{"components":[{"internalType":"uint16","name":"expPercent","type":"uint16"},{"internalType":"uint16","name":"furPercent","type":"uint16"},{"internalType":"uint16","name":"luckPercent","type":"uint16"},{"internalType":"uint16","name":"happinessPoints","type":"uint16"},{"internalType":"uint16","name":"energyPoints","type":"uint16"},{"internalType":"uint32","name":"zone","type":"uint32"}],"internalType":"struct FurLib.RewardModifiers","name":"modifiers","type":"tuple"},{"components":[{"internalType":"uint32","name":"number","type":"uint32"},{"internalType":"uint16","name":"count","type":"uint16"},{"internalType":"uint16","name":"rarity","type":"uint16"},{"internalType":"uint32","name":"experience","type":"uint32"},{"internalType":"uint32","name":"zone","type":"uint32"},{"internalType":"uint16","name":"level","type":"uint16"},{"internalType":"uint16","name":"weight","type":"uint16"},{"internalType":"uint64","name":"birth","type":"uint64"},{"internalType":"uint64","name":"trade","type":"uint64"},{"internalType":"uint64","name":"last","type":"uint64"},{"internalType":"uint32","name":"moves","type":"uint32"},{"internalType":"uint256[]","name":"inventory","type":"uint256[]"}],"internalType":"struct FurLib.Furball","name":"definition","type":"tuple"},{"components":[{"internalType":"uint32","name":"snackId","type":"uint32"},{"internalType":"uint32","name":"duration","type":"uint32"},{"internalType":"uint16","name":"furCost","type":"uint16"},{"internalType":"uint16","name":"happiness","type":"uint16"},{"internalType":"uint16","name":"energy","type":"uint16"},{"internalType":"uint16","name":"count","type":"uint16"},{"internalType":"uint64","name":"fed","type":"uint64"}],"internalType":"struct FurLib.Snack[]","name":"snacks","type":"tuple[]"}],"internalType":"struct FurLib.FurballStats","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"lootId","type":"uint128"},{"internalType":"uint8","name":"chances","type":"uint8"},{"internalType":"address","name":"actor","type":"address"}],"name":"upgrade","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b5060405162005c4238038062005c42833981016040819052620000349162000212565b604080518082018252600881526746757262616c6c7360c01b60208083019182528351808501909452600384526211909360ea1b9084015281519192916200007f916000916200016c565b508051620000959060019060208401906200016c565b505050620000b2620000ac620000bb60201b60201c565b6200011a565b60145562000269565b6000333014156200011457600080368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050503601516001600160a01b03169150620001179050565b50335b90565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b8280546200017a906200022c565b90600052602060002090601f0160209004810192826200019e5760008555620001e9565b82601f10620001b957805160ff1916838001178555620001e9565b82800160010185558215620001e9579182015b82811115620001e9578251825591602001919060010190620001cc565b50620001f7929150620001fb565b5090565b5b80821115620001f75760008155600101620001fc565b6000602082840312156200022557600080fd5b5051919050565b600181811c908216806200024157607f821691505b602082108114156200026357634e487b7160e01b600052602260045260246000fd5b50919050565b6159c980620002796000396000f3fe608060405234801561001057600080fd5b506004361061028a5760003560e01c80635ac025821161015c578063b88d4fde116100ce578063e31ac06911610087578063e31ac06914610637578063e7fe5e861461064a578063e8a3d48514610750578063e985e9c514610758578063f2fde38b1461076b578063fa6f39361461077e57600080fd5b8063b88d4fde14610550578063bb7907f114610563578063c87b56dd14610576578063c9d4623f14610589578063ce0277981461059c578063ce3f865f146105af57600080fd5b80638908573d116101205780638908573d146104eb5780638da5cb5b146104fe57806392eec6b21461050f57806395d89b4114610522578063a22cb4651461052a578063ab033ea91461053d57600080fd5b80635ac02582146104975780636352211e146104aa57806370a08231146104bd578063715018a6146104d0578063872cb445146104d857600080fd5b8063279c806e1161020057806342842e0e116101b957806342842e0e14610408578063429b62e51461041b5780634b0bddd21461043e5780634f6ccce714610451578063506f34ed146104645780635aa6e6751461048457600080fd5b8063279c806e146103a05780632ac4b19b146103b35780632f745c59146103c65780633076dc42146103d9578063392aeb8a146103e25780633ee2b01d146103f557600080fd5b806314d0f1ba1161025257806314d0f1ba1461031f57806318160ddd14610342578063207c1ff01461035457806323b872dd1461036757806323d379771461037a57806324d7806c1461038d57600080fd5b806301ffc9a71461028f57806306fdde03146102b7578063081812fc146102cc578063095ea7b3146102f75780630e830e491461030c575b600080fd5b6102a261029d36600461493e565b610791565b60405190151581526020015b60405180910390f35b6102bf6107bc565b6040516102ae919061508e565b6102df6102da366004614b5b565b61084e565b6040516001600160a01b0390911681526020016102ae565b61030a610305366004614563565b6108e8565b005b61030a61031a3660046143fd565b610a10565b6102a261032d3660046143fd565b600c6020526000908152604090205460ff1681565b6008545b6040519081526020016102ae565b61030a610362366004614bd7565b610a57565b61030a61037536600461444b565b610ab8565b61030a610388366004614bb2565b610af0565b6102a261039b3660046143fd565b610b4f565b6102df6103ae366004614b5b565b610b9c565b61030a6103c13660046145b9565b610bc6565b6103466103d4366004614563565b610d5f565b61034660145481565b61030a6103f0366004614c19565b610df5565b61030a61040336600461452c565b610ecb565b61030a61041636600461444b565b610f2e565b6102a26104293660046143fd565b600b6020526000908152604090205460ff1681565b61030a61044c36600461452c565b610f49565b61034661045f366004614b5b565b610fd0565b610477610472366004614b8d565b611063565b6040516102ae9190615198565b6010546102df906001600160a01b031681565b6011546102df906001600160a01b031681565b6102df6104b8366004614b5b565b61131e565b6103466104cb3660046143fd565b611395565b61030a61141c565b61030a6104e636600461458d565b611493565b61030a6104f93660046143fd565b61155e565b600a546001600160a01b03166102df565b600d546102df906001600160a01b031681565b6102bf6115a5565b61030a61053836600461452c565b6115b4565b61030a61054b3660046143fd565b6116b6565b61030a61055e366004614487565b6116fd565b61030a6105713660046143fd565b611736565b6102bf610584366004614b5b565b61177d565b600f546102df906001600160a01b031681565b61030a6105aa366004614882565b611930565b6105ff6105bd366004614b5b565b60136020526000908152604090205461ffff81169063ffffffff620100008204811691600160301b8104909116906001600160801b03600160501b9091041684565b6040805161ffff95909516855263ffffffff938416602086015291909216908301526001600160801b031660608201526080016102ae565b61030a610645366004614679565b611a73565b6106de610658366004614b5b565b6012602052600090815260409020805460019091015463ffffffff8083169261ffff6401000000008204811693600160301b8304821693600160401b808504821694600160601b8104831694600160801b808304821695600160901b8404909216946001600160401b03600160a01b90940484169483851694908404169291909104168b565b6040805163ffffffff9c8d16815261ffff9b8c166020820152998b16908a0152968a166060890152948916608088015292871660a0870152951660c08501526001600160401b0394851660e08501528416610100840152929092166101208201529116610140820152610160016102ae565b6102bf611b9c565b6102a2610766366004614418565b611c22565b61030a6107793660046143fd565b611cdf565b6102a261078c3660046143fd565b611d99565b60006001600160e01b0319821663780e9d6360e01b14806107b657506107b682611dc9565b92915050565b6060600080546107cb906157f1565b80601f01602080910402602001604051908101604052809291908181526020018280546107f7906157f1565b80156108445780601f1061081957610100808354040283529160200191610844565b820191906000526020600020905b81548152906001019060200180831161082757829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108cc5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006108f38261131e565b9050806001600160a01b0316836001600160a01b031614156109615760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108c3565b806001600160a01b0316610973611e19565b6001600160a01b0316148061098f575061098f81610766611e19565b610a015760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016108c3565b610a0b8383611e76565b505050565b610a1933610b4f565b610a355760405162461bcd60e51b81526004016108c390615179565b600f80546001600160a01b0319166001600160a01b0392909216919091179055565b600080610a646000611ee4565b9092509050600460ff82161015610aa65760405162461bcd60e51b81526004016108c39060208082526004908201526347414d4560e01b604082015260600190565b610ab185858561205c565b5050505050565b610ac9610ac3611e19565b82612393565b610ae55760405162461bcd60e51b81526004016108c390615128565b610a0b83838361246a565b600080610afd6000611ee4565b9092509050600460ff82161015610b3f5760405162461bcd60e51b81526004016108c39060208082526004908201526347414d4560e01b604082015260600190565b610b498484612615565b50505050565b6000816001600160a01b0316610b6d600a546001600160a01b031690565b6001600160a01b031614806107b65750506001600160a01b03166000908152600b602052604090205460ff1690565b600e8181548110610bac57600080fd5b6000918252602090912001546001600160a01b0316905081565b600080610bd283611ee4565b91509150845160011480610bea5750600260ff821610155b610c1f5760405162461bcd60e51b81526004016108c3906020808252600490820152631355531560e21b604082015260600190565b60005b85518160ff161015610d5757600d5486516001600160a01b03909116906353fce67090859085908a9060ff8716908110610c5e57610c5e6158bd565b6020026020010151600e8a60ff1681548110610c7c57610c7c6158bd565b60009182526020909120015460405160e086901b6001600160e01b03191681526001600160a01b03948516600482015260ff90931660248401529083166044830152919091166064820152608401602060405180830381600087803b158015610ce457600080fd5b505af1158015610cf8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1c9190614921565b50610d45868260ff1681518110610d3557610d356158bd565b60200260200101518660006128ce565b80610d4f81615847565b915050610c22565b505050505050565b6000610d6a83611395565b8210610dcc5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016108c3565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600080610e0183611ee4565b600d5491935091506000906001600160a01b03166378353db6610e2389612dbe565b85858b8b8b6040518763ffffffff1660e01b8152600401610e49969594939291906153a6565b602060405180830381600087803b158015610e6357600080fd5b505af1158015610e77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9b9190614b21565b90506001600160801b03811615610ec257610eb88787600161205c565b610ec28782612615565b50505050505050565b610ed433610b4f565b610ef05760405162461bcd60e51b81526004016108c390615179565b6001600160a01b038216610f0357600080fd5b6001600160a01b03919091166000908152600c60205260409020805460ff1916911515919091179055565b610a0b838383604051806020016040528060008152506116fd565b610f51611e19565b6001600160a01b0316610f6c600a546001600160a01b031690565b6001600160a01b031614610f925760405162461bcd60e51b81526004016108c3906150f3565b6001600160a01b038216610fa557600080fd5b6001600160a01b03919091166000908152600b60205260409020805460ff1916911515919091179055565b6000610fdb60085490565b821061103e5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016108c3565b60088281548110611051576110516158bd565b90600052602060002001549050919050565b61106b6142a2565b6000838152601260209081526040808320815161018081018352815463ffffffff808216835261ffff6401000000008304811684880152600160301b8304811684870152600160401b80840483166060860152600160601b840483166080860152600160801b808504831660a0870152600160901b850490921660c08601526001600160401b03600160a01b909404841660e08601526001860154808516610100870152908104909316610120850152909104166101408201526002820180548451818702810187019095528085529194929361016086019390929083018282801561117657602002820191906000526020600020905b815481526020019060010190808311611162575b5050505050815250509050600061122a82868661119457600061119d565b61119d8861131e565b876111a9576000612ee2565b600d5460405163df03984d60e01b8152600481018b90526001600160a01b039091169063df03984d9060240160206040518083038186803b1580156111ed57600080fd5b505afa158015611201573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112259190614b74565b612ee2565b90506040518060a001604052806112546014546101f463ffffffff16856000015161ffff1661318b565b61ffff168152602001611279601454606463ffffffff16856020015161ffff1661318b565b61ffff168152602081018390526040808201859052600d549051633251ac5f60e21b8152600481018990526060909201916001600160a01b039091169063c946b17c9060240160006040518083038186803b1580156112d757600080fd5b505afa1580156112eb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611313919081019061475f565b905295945050505050565b6000818152600260205260408120546001600160a01b0316806107b65760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016108c3565b60006001600160a01b0382166114005760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016108c3565b506001600160a01b031660009081526003602052604090205490565b611424611e19565b6001600160a01b031661143f600a546001600160a01b031690565b6001600160a01b0316146114655760405162461bcd60e51b81526004016108c3906150f3565b60405162461bcd60e51b815260206004820152600360248201526227aba760e91b60448201526064016108c3565b61149c33610b4f565b6114b85760405162461bcd60e51b81526004016108c390615179565b600e5460ff82161061151557600e80546001810182556000919091527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd0180546001600160a01b0384166001600160a01b03199091161790555050565b81600e8260ff168154811061152c5761152c6158bd565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505050565b61156733610b4f565b6115835760405162461bcd60e51b81526004016108c390615179565b601180546001600160a01b0319166001600160a01b0392909216919091179055565b6060600180546107cb906157f1565b6115bc611e19565b6001600160a01b0316826001600160a01b0316141561161d5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108c3565b806005600061162a611e19565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff19169215159290921790915561166e611e19565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516116aa911515815260200190565b60405180910390a35050565b6116bf33610b4f565b6116db5760405162461bcd60e51b81526004016108c390615179565b601080546001600160a01b0319166001600160a01b0392909216919091179055565b61170e611708611e19565b83612393565b61172a5760405162461bcd60e51b81526004016108c390615128565b610b49848484846131c4565b61173f33610b4f565b61175b5760405162461bcd60e51b81526004016108c390615179565b600d80546001600160a01b0319166001600160a01b0392909216919091179055565b6000818152600260205260409020546060906001600160a01b03166117a157600080fd5b61190a600e6117b261010085615867565b815481106117c2576117c26158bd565b600091825260209091200154600f54604051635d0b221560e11b8152600481018690526001600160a01b0392831692630114b12292169063ba16442a9060240160006040518083038186803b15801561181a57600080fd5b505afa15801561182e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118569190810190614978565b600086815260126020526040908190205490516001600160e01b031960e085901b1681526118929291889163ffffffff9091169060040161505f565b60006040518083038186803b1580156118aa57600080fd5b505afa1580156118be573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118e69190810190614978565b6040516020016118f69190614fcb565b6040516020818303038152906040526131f7565b60405160200161191a9190614fe7565b6040516020818303038152906040529050919050565b60008061193c83611ee4565b9150915060005b8551811015610d5757611970868281518110611961576119616158bd565b6020026020010151848461335e565b600f5486516001600160a01b0390911690631f92cdcc90889084908110611999576119996158bd565b602002602001015187896040518463ffffffff1660e01b81526004016119c193929190615415565b602060405180830381600087803b1580156119db57600080fd5b505af11580156119ef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a139190614b74565b60126000888481518110611a2957611a296158bd565b60200260200101518152602001908152602001600020600001600c6101000a81548163ffffffff021916908363ffffffff1602179055508080611a6b9061582c565b915050611943565b600080611a7f83611ee4565b8551919350915060005b81811015610d5757600d5486516001600160a01b03909116906357a49b3a90869086908a9086908110611abe57611abe6158bd565b6020026020010151600001518a8681518110611adc57611adc6158bd565b6020026020010151602001518b8781518110611afa57611afa6158bd565b602090810291909101015160409081015190516001600160e01b031960e088901b1681526001600160a01b03909516600486015260ff9093166024850152604484019190915263ffffffff16606483015261ffff16608482015260a401600060405180830381600087803b158015611b7157600080fd5b505af1158015611b85573d6000803e3d6000fd5b505050508080611b949061582c565b915050611a89565b60105460408051636760578760e01b815290516060926001600160a01b0316916367605787916004808301926000929190829003018186803b158015611be157600080fd5b505afa158015611bf5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c1d9190810190614978565b905090565b600f5460405163317452ff60e21b81526001600160a01b0384811660048301528381166024830152600092169063c5d14bfc9060440160206040518083038186803b158015611c7057600080fd5b505afa158015611c84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca89190614921565b80611cd857506001600160a01b0380841660009081526005602090815260408083209386168352929052205460ff165b9392505050565b611ce7611e19565b6001600160a01b0316611d02600a546001600160a01b031690565b6001600160a01b031614611d285760405162461bcd60e51b81526004016108c3906150f3565b6001600160a01b038116611d8d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108c3565b611d9681613abe565b50565b6000611da482610b4f565b806107b65750506001600160a01b03166000908152600c602052604090205460ff1690565b60006001600160e01b031982166380ac58cd60e01b1480611dfa57506001600160e01b03198216635b5e139f60e01b145b806107b657506301ffc9a760e01b6001600160e01b03198316146107b6565b600033301415611e7057600080368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050503601516001600160a01b03169150611e739050565b50335b90565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611eab8261131e565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080611eef613b10565b611f245760405162461bcd60e51b81526004016108c3906020808252600490820152632152445960e01b604082015260600190565b6001600160a01b03831615801590611f4557506001600160a01b0383163314155b15611f91576011546001600160a01b03163314611f8c5760405162461bcd60e51b815260206004820152600560248201526450524f585960d81b60448201526064016108c3565b611f9c565b611f99611e19565b92505b600f546040516308e9cdb760e11b81526001600160a01b03858116600483015260009216906311d39b6e9060240160206040518083038186803b158015611fe257600080fd5b505afa158015611ff6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061201a9190614b74565b905060008160ff16116120555760405162461bcd60e51b815260206004820152600360248201526228262960e91b60448201526064016108c3565b9293915050565b60006120688484613b5d565b9050600081118015612091575060008481526012602052604090206002015463ffffffff168111155b6120c65760405162461bcd60e51b81526004016108c39060208082526004908201526314d313d560e21b604082015260600190565b6120d160018261574e565b905060006101006012600087815260200190815260200160002060020183815481106120ff576120ff6158bd565b90600052602060002001546121149190615867565b905060ff8316158061212c57508060ff168360ff1610155b156121fe57600085815260126020526040902060020154600161ffff821611156121bf57600086815260126020526040902060020161216c60018361572b565b61ffff1681548110612180576121806158bd565b90600052602060002001546012600088815260200190815260200160002060020184815481106121b2576121b26158bd565b6000918252602090912001555b60008681526012602052604090206002018054806121df576121df6158a7565b600190038181906000526020600020016000905590558193505061225d565b61220883826157a2565b905060ff81166122236001600160801b0386166101006156e9565b61222d919061553e565b6000868152601260205260409020600201805484908110612250576122506158bd565b6000918252602090912001555b600f5460405163122b671160e11b81526001600160801b03861660048201526001600160a01b0390911690632456ce229060240160206040518083038186803b1580156122a957600080fd5b505afa1580156122bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122e19190614b3e565b6122ee9060ff85166156bf565b6000868152601260208190526040909120805490919061231a908490600160901b900461ffff1661572b565b92506101000a81548161ffff021916908361ffff1602179055507f4b92ed7b627ee98572d071c75059084d237989679601c929c880f1fe14119cdd858585604051612384939291909283526001600160801b0391909116602083015260ff16604082015260600190565b60405180910390a15050505050565b6000818152600260205260408120546001600160a01b031661240c5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108c3565b60006124178361131e565b9050806001600160a01b0316846001600160a01b031614806124525750836001600160a01b03166124478461084e565b6001600160a01b0316145b8061246257506124628185611c22565b949350505050565b826001600160a01b031661247d8261131e565b6001600160a01b0316146124e55760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016108c3565b6001600160a01b0382166125475760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108c3565b612552838383613bff565b61255d600082611e76565b6001600160a01b038316600090815260036020526040812080546001929061258690849061574e565b90915550506001600160a01b03821660009081526003602052604081208054600192906125b490849061553e565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000816001600160801b0316116126575760405162461bcd60e51b81526004016108c3906020808252600490820152631313d3d560e21b604082015260600190565b60006126638383613b5d565b90506001816126bb57600084815260126020526040902060020160ff82166126966001600160801b0386166101006156e9565b6126a0919061553e565b815460018101835560009283526020909220909101556127a4565b6000848152601260205260409020610100906002016126db60018561574e565b815481106126eb576126eb6158bd565b90600052602060002001546127009190615867565b61270a9082615575565b90506101008160ff16106127485760405162461bcd60e51b8152602060048201526005602482015264535441434b60d81b60448201526064016108c3565b60ff81166127616001600160801b0385166101006156e9565b61276b919061553e565b600085815260126020526040902060020161278760018561574e565b81548110612797576127976158bd565b6000918252602090912001555b600f5460405163122b671160e11b81526001600160801b03851660048201526001600160a01b0390911690632456ce229060240160206040518083038186803b1580156127f057600080fd5b505afa158015612804573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128289190614b3e565b60008581526012602081905260409091208054909190612854908490600160901b900461ffff16615518565b92506101000a81548161ffff021916908361ffff1602179055507f4b92ed7b627ee98572d071c75059084d237989679601c929c880f1fe14119cdd848460006040516128c0939291909283526001600160801b0391909116602083015261ffff16604082015260600190565b60405180910390a150505050565b600a8160ff161061290a5760405162461bcd60e51b8152602060048201526006602482015265535550504c5960d01b60448201526064016108c3565b600e5460ff8316106129435760405162461bcd60e51b8152602060048201526002602482015261115160f21b60448201526064016108c3565b6000600e8360ff168154811061295b5761295b6158bd565b600091825260208220015460408051635aa3d76d60e11b815281516001600160a01b0390931694508392859263b547aeda926004808201939182900301818787803b1580156129a957600080fd5b505af11580156129bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e19190614c6a565b90925090506129f360ff86168361553e565b6000818152600260205260409020549092506001600160a01b031615612a2857610d578686612a23876001615575565b6128ce565b604051631e7269c560e01b81526001600160a01b03878116600483015260009190851690631e7269c59060240160206040518083038186803b158015612a6d57600080fd5b505afa158015612a81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aa59190614b3e565b604051635ed88ecf60e01b81526001600160a01b03898116600483015261ffff92909216925090851690635ed88ecf9060240160206040518083038186803b158015612af057600080fd5b505afa158015612b04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b289190614b3e565b61ffff168163ffffffff1610612b685760405162461bcd60e51b8152602060048201526005602482015264131253525560da1b60448201526064016108c3565b6000846001600160a01b03166306661abd6040518163ffffffff1660e01b815260040160206040518083038186803b158015612ba357600080fd5b505afa158015612bb7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bdb9190614b3e565b9050846001600160a01b0316639ef2d87a6040518163ffffffff1660e01b815260040160206040518083038186803b158015612c1657600080fd5b505afa158015612c2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c4e9190614b3e565b61ffff168161ffff1610612c8a5760405162461bcd60e51b815260206004820152600360248201526209a82b60eb1b60448201526064016108c3565b600854612c9890600161553e565b6000858152601260205260409020805463ffffffff9290921665ffffffffffff199092169190911764010000000061ffff84811691909102919091177fffffffff0000000000000000ffffffffffffffffffffffff0000ffffffffffff16600160301b9186169190910267ffffffffffffffff60a01b191617600160a01b426001600160401b031602179055612d2e8885613c97565b6040516001625e138560e01b031981526001600160a01b0389811660048301526001602483015286169063ffa1ec7b90604401602060405180830381600087803b158015612d7b57600080fd5b505af1158015612d8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612db39190614921565b505050505050505050565b612dc6614334565b600082815260126020908152604091829020825161018081018452815463ffffffff808216835261ffff6401000000008304811684870152600160301b8304811684880152600160401b80840483166060860152600160601b840483166080860152600160801b808504831660a0870152600160901b850490921660c08601526001600160401b03600160a01b909404841660e08601526001860154808516610100870152908104909316610120850152909104166101408201526002820180548551818602810186019096528086526107b6959294610160860193929190830182828015612ed457602002820191906000526020600020905b815481526020019060010190808311612ec0575b505050505081525050836000805b612eea614334565b6000612ef98360006002613de5565b90506000612f0984600280613de5565b90506001600160a01b03851615156000612f2561010089615867565b90506040518060c001604052808a604001516064612f439190615518565b61ffff16815260200160048363ffffffff1610612f61576050612f6c565b612f6c836014615708565b60408c0151612f7c906064615518565b61ffff16612f8a9190615765565b61ffff90811682526064602083015285811660408301528616606082015260800183612fb7576000612fbd565b8a608001515b63ffffffff168152509450600f60009054906101000a90046001600160a01b03166001600160a01b0316633fa72f678a600e8463ffffffff1681548110613006576130066158bd565b6000918252602090912001546040516397bac7c560e01b81526001600160a01b03909116906397bac7c590613041908b908f906004016153fa565b60c06040518083038186803b15801561305957600080fd5b505afa15801561306d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130919190614a77565b60105460405163fbcbc0f160e01b81526001600160a01b038d811660048301529091169063fbcbc0f19060240160e06040518083038186803b1580156130d657600080fd5b505afa1580156130ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061310e91906149c0565b866040518563ffffffff1660e01b815260040161312e9493929190615293565b60c06040518083038186803b15801561314657600080fd5b505afa15801561315a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061317e9190614a77565b9998505050505050505050565b60145460009061319c8160646156e9565b846131a785886156e9565b6131b191906156e9565b6131bb919061559a565b95945050505050565b6131cf84848461246a565b6131db84848484613e0d565b610b495760405162461bcd60e51b81526004016108c3906150a1565b606081516000141561321757505060408051602081019091526000815290565b60006040518060600160405280604081526020016159546040913990506000600384516002613246919061553e565b613250919061559a565b61325b9060046156e9565b9050600061326a82602061553e565b6001600160401b03811115613281576132816158d3565b6040519080825280601f01601f1916602001820160405280156132ab576020820181803683370190505b509050818152600183018586518101602084015b818310156133195760039283018051603f601282901c811687015160f890811b8552600c83901c8216880151811b6001860152600683901c8216880151811b60028601529116860151901b938201939093526004016132bf565b600389510660018114613333576002811461334457613350565b613d3d60f01b600119830152613350565b603d60f81b6000198301525b509398975050505050505050565b6000838152601260209081526040808320815161018081018352815463ffffffff808216835261ffff6401000000008304811684880152600160301b8304811684870152600160401b80840483166060860152600160601b840483166080860152600160801b808504831660a0870152600160901b850490921660c08601526001600160401b03600160a01b909404841660e08601526001860154808516610100870152908104909316610120850152909104166101408201526002820180548451818702810187019095528085529194929361016086019390929083018282801561346957602002820191906000526020600020905b815481526020019060010190808311613455575b5050505050815250509050600061347f8561131e565b9050836001600160a01b0316816001600160a01b031614806134a55750600460ff841610155b6134d75760405162461bcd60e51b815260206004820152600360248201526227aba760e91b60448201526064016108c3565b6101208201516001600160401b0316613623576000600e6134fa61010088615867565b8154811061350a5761350a6158bd565b60009182526020918290200154604080516329fc5dcd60e11b815290516001600160a01b03909216926353f8bb9a92600480840193829003018186803b15801561355357600080fd5b505afa158015613567573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061358b9190614cbe565b90506000816001600160401b03161180156135b75750426001600160401b0316816001600160401b0316105b6135e95760405162461bcd60e51b815260206004820152600360248201526250524560e81b60448201526064016108c3565b806001600160401b03168360e001516001600160401b03161161360c5780613612565b8260e001515b6001600160401b0316610120840152505b600d5460405163fbc70c9760e01b815260048101879052600091613688918591899186916001600160a01b03169063fbc70c9790602401602060405180830381600087803b15801561367457600080fd5b505af1158015611201573d6000803e3d6000fd5b905060008361012001514261369d9190615782565b6000888152601360205260409020805469ffffffffffffffffffff1916905560a08301519091506201000063ffffffff909116106137a45760006136f78263ffffffff16606463ffffffff16856020015161ffff1661318b565b905063ffffffff81161561379e57600d5460405163b02bf4b960e01b81526001600160a01b03868116600483015263ffffffff841660248301529091169063b02bf4b990604401600060405180830381600087803b15801561375857600080fd5b505af115801561376c573d6000803e3d6000fd5b5050506000898152601360205260409020805469ffffffff0000000000001916600160301b63ffffffff851602179055505b50613918565b60006137c78263ffffffff166101f463ffffffff16856000015161ffff1661318b565b600f5460008a815260126020526040808220905163714cfd6960e01b8152939450909283926001600160a01b03169163714cfd699161380d91908a90889060040161536d565b6040805180830381600087803b15801561382657600080fd5b505af115801561383a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061385e9190614c8f565b60008c8152601360209081526040808320805465ffffffffffff19166201000063ffffffff8b160261ffff19161761ffff868116919091179091556012909252909120805493955091935083926010916138c2918591600160801b90910416615518565b825461ffff9182166101009390930a928302919092021990911617905550506000898152601260205260409020805463ffffffff909216600160401b026bffffffff000000000000000019909216919091179055505b601454600f546000906001600160a01b0316630ba758f461393984866155ae565b866040518363ffffffff1660e01b815260040161395792919061543a565b602060405180830381600087803b15801561397157600080fd5b505af1158015613985573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139a99190614b21565b60008a815260136020526040902080546fffffffffffffffffffffffffffffffff60501b1916600160501b6001600160801b03841690810291909117909155909150156139fa576139fa8982612615565b6000898152601260205260408120600190810180546fffffffffffffffff00000000000000001916600160401b426001600160401b031602179055610140880151613a4491615556565b60008b815260126020908152604091829020600101805463ffffffff60801b1916600160801b63ffffffff86169081029190911790915582518e8152918201529192507f075f755287452a199f075e4a7501bd3c4c98ccfa9544fee7eac3d04d658fedf4910160405180910390a150505050505050505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600f546000906001600160a01b031615801590613b2e5750600e5415155b8015613b445750600d546001600160a01b031615155b8015611c1d5750506010546001600160a01b0316151590565b6000805b60008481526012602052604090206002015460ff82161015613bf557600084815260126020526040902060020180546001600160801b038516916101009160ff8516908110613bb257613bb26158bd565b9060005260206000200154613bc7919061559a565b1415613be357613bd8816001615575565b60ff169150506107b6565b80613bed81615847565b915050613b61565b5060009392505050565b613c0a838383613f1e565b6000818152601260205260409081902060018101805467ffffffffffffffff1916426001600160401b0316179055600f54915163183e599560e31b81526001600160a01b039092169163c1f2cca891613c69918790879060040161533a565b600060405180830381600087803b158015613c8357600080fd5b505af1158015610ec2573d6000803e3d6000fd5b6001600160a01b038216613ced5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108c3565b6000818152600260205260409020546001600160a01b031615613d525760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108c3565b613d5e60008383613bff565b6001600160a01b0382166000908152600360205260408120805460019290613d8790849061553e565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000613df082613fd6565b613df984613fd6565b613e03908661559a565b6124629190615867565b60006001600160a01b0384163b15613f1657836001600160a01b031663150b7a02613e36611e19565b8786866040518563ffffffff1660e01b8152600401613e58949392919061502c565b602060405180830381600087803b158015613e7257600080fd5b505af1925050508015613ea2575060408051601f3d908101601f19168201909252613e9f9181019061495b565b60015b613efc573d808015613ed0576040519150601f19603f3d011682016040523d82523d6000602084013e613ed5565b606091505b508051613ef45760405162461bcd60e51b81526004016108c3906150a1565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612462565b506001612462565b6001600160a01b038316613f7957613f7481600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b613f9c565b816001600160a01b0316836001600160a01b031614613f9c57613f9c8382614112565b6001600160a01b038216613fb357610a0b816141af565b826001600160a01b0316826001600160a01b031614610a0b57610a0b828261425e565b600060ff8216613fe857506001919050565b8160ff1660011415613ffd5750610100919050565b8160ff1660021415614013575062010000919050565b8160ff166003141561402a57506301000000919050565b8160ff16600414156140425750640100000000919050565b8160ff166005141561405b575065010000000000919050565b8160ff16600614156140725750600160301b919050565b8160ff166007141561408d5750670100000000000000919050565b8160ff16600814156140a45750600160401b919050565b8160ff16600914156140c157506901000000000000000000919050565b8160ff16600a14156140d85750600160501b919050565b8160ff16600b14156140ef5750600160581b919050565b8160ff16600c14156141065750600160601b919050565b6107b682610100615614565b6000600161411f84611395565b614129919061574e565b60008381526007602052604090205490915080821461417c576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906141c19060019061574e565b600083815260096020526040812054600880549394509092849081106141e9576141e96158bd565b90600052602060002001549050806008838154811061420a5761420a6158bd565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480614242576142426158a7565b6001900381819060005260206000200160009055905550505050565b600061426983611395565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6040805160a081018252600080825260208201529081016142c1614334565b815260408051610180810182526000808252602082810182905292820181905260608083018290526080830182905260a0830182905260c0830182905260e08301829052610100830182905261012083018290526101408301919091526101608201529101908152602001606081525090565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a081019190915290565b600061437c614377846154f1565b61549e565b905082815283838301111561439057600080fd5b611cd88360208301846157c5565b80356001600160a01b03811681146143b557600080fd5b919050565b80516143b581615922565b80356143b581615932565b80516001600160401b03811681146143b557600080fd5b80356143b581615944565b80516143b581615944565b60006020828403121561440f57600080fd5b611cd88261439e565b6000806040838503121561442b57600080fd5b6144348361439e565b91506144426020840161439e565b90509250929050565b60008060006060848603121561446057600080fd5b6144698461439e565b92506144776020850161439e565b9150604084013590509250925092565b6000806000806080858703121561449d57600080fd5b6144a68561439e565b93506144b46020860161439e565b92506040850135915060608501356001600160401b038111156144d657600080fd5b8501601f810187136144e757600080fd5b80356144f5614377826154f1565b81815288602083850101111561450a57600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b6000806040838503121561453f57600080fd5b6145488361439e565b91506020830135614558816158e9565b809150509250929050565b6000806040838503121561457657600080fd5b61457f8361439e565b946020939093013593505050565b600080604083850312156145a057600080fd5b6145a98361439e565b9150602083013561455881615944565b6000806000606084860312156145ce57600080fd5b83356001600160401b038111156145e457600080fd5b8401601f810186136145f557600080fd5b80356020614605614377836154ce565b8083825282820191508285018a848660051b880101111561462557600080fd5b600095505b8486101561464f5761463b8161439e565b83526001959095019491830191830161462a565b50965061465f90508782016143e7565b94505050506146706040850161439e565b90509250925092565b600080604080848603121561468d57600080fd5b83356001600160401b038111156146a357600080fd5b8401601f810186136146b457600080fd5b803560206146c4614377836154ce565b828152818101908483016060808602870185018c10156146e357600080fd5b60009650865b8681101561473f5781838e0312156146ff578788fd5b614707615454565b833581528684013561471881615932565b81880152838a013561472981615922565b818b0152855293850193918101916001016146e9565b505050809750505061475281880161439e565b9450505050509250929050565b6000602080838503121561477257600080fd5b82516001600160401b0381111561478857600080fd5b8301601f8101851361479957600080fd5b80516147a7614377826154ce565b8181528381019083850160e0808502860187018a10156147c657600080fd5b60009550855b858110156148735781838c0312156147e2578687fd5b6147ea61547c565b83516147f581615932565b81528389015161480481615932565b818a015260408481015161481781615922565b9082015260608481015161482a81615922565b90820152608061483b8582016143ba565b9082015260a061484c8582016143ba565b9082015260c061485d8582016143d0565b90820152855293870193918101916001016147cc565b50919998505050505050505050565b60008060006060848603121561489757600080fd5b83356001600160401b038111156148ad57600080fd5b8401601f810186136148be57600080fd5b803560206148ce614377836154ce565b8083825282820191508285018a848660051b88010111156148ee57600080fd5b600095505b848610156149115780358352600195909501949183019183016148f3565b50965061465f90508782016143c5565b60006020828403121561493357600080fd5b8151611cd8816158e9565b60006020828403121561495057600080fd5b8135611cd8816158f7565b60006020828403121561496d57600080fd5b8151611cd8816158f7565b60006020828403121561498a57600080fd5b81516001600160401b038111156149a057600080fd5b8201601f810184136149b157600080fd5b61246284825160208401614369565b600060e082840312156149d257600080fd5b60405160e081018181106001600160401b03821117156149f4576149f46158d3565b604052614a00836143d0565b81526020830151614a1081615932565b60208201526040830151614a2381615932565b60408201526060830151614a3681615922565b60608201526080830151614a4981615922565b6080820152614a5a60a084016143ba565b60a0820152614a6b60c084016143f2565b60c08201529392505050565b600060c08284031215614a8957600080fd5b60405160c081018181106001600160401b0382111715614aab57614aab6158d3565b6040528251614ab981615922565b81526020830151614ac981615922565b60208201526040830151614adc81615922565b60408201526060830151614aef81615922565b60608201526080830151614b0281615922565b608082015260a0830151614b1581615932565b60a08201529392505050565b600060208284031215614b3357600080fd5b8151611cd88161590d565b600060208284031215614b5057600080fd5b8151611cd881615922565b600060208284031215614b6d57600080fd5b5035919050565b600060208284031215614b8657600080fd5b5051919050565b60008060408385031215614ba057600080fd5b823591506020830135614558816158e9565b60008060408385031215614bc557600080fd5b8235915060208301356145588161590d565b600080600060608486031215614bec57600080fd5b833592506020840135614bfe8161590d565b91506040840135614c0e81615944565b809150509250925092565b60008060008060808587031215614c2f57600080fd5b843593506020850135614c418161590d565b92506040850135614c5181615944565b9150614c5f6060860161439e565b905092959194509250565b60008060408385031215614c7d57600080fd5b82519150602083015161455881615922565b60008060408385031215614ca257600080fd5b8251614cad81615932565b602084015190925061455881615922565b600060208284031215614cd057600080fd5b611cd8826143d0565b600081518084526020808501945080840160005b83811015614d0957815187529582019590820190600101614ced565b509495945050505050565b6000815480845260208085019450836000528060002060005b83811015614d0957815487529582019560019182019101614d2d565b60008151808452614d618160208601602086016157c5565b601f01601f19169290920160200192915050565b805163ffffffff16825260006101806020830151614d99602086018261ffff169052565b506040830151614daf604086018261ffff169052565b506060830151614dc7606086018263ffffffff169052565b506080830151614ddf608086018263ffffffff169052565b5060a0830151614df560a086018261ffff169052565b5060c0830151614e0b60c086018261ffff169052565b5060e0830151614e2660e08601826001600160401b03169052565b50610100838101516001600160401b039081169186019190915261012080850151909116908501526101408084015163ffffffff169085015261016080840151818601839052614e7883870182614cd9565b9695505050505050565b805463ffffffff80821684526000916101809161ffff614ead60208801828560201c1661ffff169052565b614ec260408801828560301c1661ffff169052565b614ed960608801838560401c1663ffffffff169052565b614ef060808801838560601c1663ffffffff169052565b614f0560a08801828560801c1661ffff169052565b614f1a60c08801828560901c1661ffff169052565b506001600160401b0360a09290921c821660e08701526001850154808316610100880152604081901c83166101208801529150614f656101408701828460801c1663ffffffff169052565b50508061016085015261246281850160028501614d14565b61ffff8082511683528060208301511660208401528060408301511660408401528060608301511660608401528060808301511660808401525063ffffffff60a08201511660a08301525050565b60008251614fdd8184602087016157c5565b9190910192915050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081526000825161501f81601d8501602087016157c5565b91909101601d0192915050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090614e7890830184614d49565b6060815260006150726060830186614d49565b905083602083015263ffffffff83166040830152949350505050565b602081526000611cd86020830184614d49565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60208082526005908201526420a226a4a760d91b604082015260600190565b6000602080835261ffff80855116828501528185015160408282168187015280870151915060606151cb81880184614f7d565b808801519250610140806101208901526151e9610160890185614d75565b60808a8101518a8303601f1901938b019390935282518083529288019550908701916000905b80821015615283578651805163ffffffff90811686528a820151168a86015286810151891687860152858101518916868601528381015189168486015260a08082015161ffff169086015260c0908101516001600160401b0316908501529588019560e0909301926001919091019061520f565b50919a9950505050505050505050565b60006101e08083526152a781840188614d75565b9150506152b76020830186614f7d565b83516001600160401b031660e0830152602084015163ffffffff908116610100840152604085015116610120830152606084015161ffff90811661014084015260808501511661016083015260a084015161531961018084018261ffff169052565b5060c084015160ff166101a08301528215156101c083015295945050505050565b60608152600061534d6060830186614e82565b6001600160a01b0394851660208401529290931660409091015292915050565b6060815260006153806060830186614e82565b6001600160a01b039490941660208301525063ffffffff91909116604090910152919050565b61016081016153b58289614f7d565b6001600160a01b039690961660c082015260ff94851660e08201526101008101939093526001600160801b039190911661012083015290911661014090910152919050565b60e081016154088285614f7d565b8260c08301529392505050565b83815263ffffffff831660208201526060604082015260006131bb6060830184614cd9565b63ffffffff8316815260e08101611cd86020830184614f7d565b604051606081016001600160401b0381118282101715615476576154766158d3565b60405290565b60405160e081016001600160401b0381118282101715615476576154766158d3565b604051601f8201601f191681016001600160401b03811182821017156154c6576154c66158d3565b604052919050565b60006001600160401b038211156154e7576154e76158d3565b5060051b60200190565b60006001600160401b0382111561550a5761550a6158d3565b50601f01601f191660200190565b600061ffff8083168185168083038211156155355761553561587b565b01949350505050565b600082198211156155515761555161587b565b500190565b600063ffffffff8083168185168083038211156155355761553561587b565b600060ff821660ff84168060ff038211156155925761559261587b565b019392505050565b6000826155a9576155a9615891565b500490565b600063ffffffff808416806155c5576155c5615891565b92169190910492915050565b600181815b8085111561560c5781600019048211156155f2576155f261587b565b808516156155ff57918102915b93841c93908002906155d6565b509250929050565b6000611cd860ff84168360008261562d575060016107b6565b8161563a575060006107b6565b8160018114615650576002811461565a57615676565b60019150506107b6565b60ff84111561566b5761566b61587b565b50506001821b6107b6565b5060208310610133831016604e8410600b8410161715615699575081810a6107b6565b6156a383836155d1565b80600019048211156156b7576156b761587b565b029392505050565b600061ffff808316818516818304811182151516156156e0576156e061587b565b02949350505050565b60008160001904831182151516156157035761570361587b565b500290565b600063ffffffff808316818516818304811182151516156156e0576156e061587b565b600061ffff838116908316818110156157465761574661587b565b039392505050565b6000828210156157605761576061587b565b500390565b600063ffffffff838116908316818110156157465761574661587b565b60006001600160401b03838116908316818110156157465761574661587b565b600060ff821660ff8416808210156157bc576157bc61587b565b90039392505050565b60005b838110156157e05781810151838201526020016157c8565b83811115610b495750506000910152565b600181811c9082168061580557607f821691505b6020821081141561582657634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156158405761584061587b565b5060010190565b600060ff821660ff81141561585e5761585e61587b565b60010192915050565b60008261587657615876615891565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b8015158114611d9657600080fd5b6001600160e01b031981168114611d9657600080fd5b6001600160801b0381168114611d9657600080fd5b61ffff81168114611d9657600080fd5b63ffffffff81168114611d9657600080fd5b60ff81168114611d9657600080fdfe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa264697066735822122040cf72a4f8d48f233c7eed697e729f0a821dbc67785173b4474fc6604845ecaa64736f6c634300080700330000000000000000000000000000000000000000000000000000000000000e10

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061028a5760003560e01c80635ac025821161015c578063b88d4fde116100ce578063e31ac06911610087578063e31ac06914610637578063e7fe5e861461064a578063e8a3d48514610750578063e985e9c514610758578063f2fde38b1461076b578063fa6f39361461077e57600080fd5b8063b88d4fde14610550578063bb7907f114610563578063c87b56dd14610576578063c9d4623f14610589578063ce0277981461059c578063ce3f865f146105af57600080fd5b80638908573d116101205780638908573d146104eb5780638da5cb5b146104fe57806392eec6b21461050f57806395d89b4114610522578063a22cb4651461052a578063ab033ea91461053d57600080fd5b80635ac02582146104975780636352211e146104aa57806370a08231146104bd578063715018a6146104d0578063872cb445146104d857600080fd5b8063279c806e1161020057806342842e0e116101b957806342842e0e14610408578063429b62e51461041b5780634b0bddd21461043e5780634f6ccce714610451578063506f34ed146104645780635aa6e6751461048457600080fd5b8063279c806e146103a05780632ac4b19b146103b35780632f745c59146103c65780633076dc42146103d9578063392aeb8a146103e25780633ee2b01d146103f557600080fd5b806314d0f1ba1161025257806314d0f1ba1461031f57806318160ddd14610342578063207c1ff01461035457806323b872dd1461036757806323d379771461037a57806324d7806c1461038d57600080fd5b806301ffc9a71461028f57806306fdde03146102b7578063081812fc146102cc578063095ea7b3146102f75780630e830e491461030c575b600080fd5b6102a261029d36600461493e565b610791565b60405190151581526020015b60405180910390f35b6102bf6107bc565b6040516102ae919061508e565b6102df6102da366004614b5b565b61084e565b6040516001600160a01b0390911681526020016102ae565b61030a610305366004614563565b6108e8565b005b61030a61031a3660046143fd565b610a10565b6102a261032d3660046143fd565b600c6020526000908152604090205460ff1681565b6008545b6040519081526020016102ae565b61030a610362366004614bd7565b610a57565b61030a61037536600461444b565b610ab8565b61030a610388366004614bb2565b610af0565b6102a261039b3660046143fd565b610b4f565b6102df6103ae366004614b5b565b610b9c565b61030a6103c13660046145b9565b610bc6565b6103466103d4366004614563565b610d5f565b61034660145481565b61030a6103f0366004614c19565b610df5565b61030a61040336600461452c565b610ecb565b61030a61041636600461444b565b610f2e565b6102a26104293660046143fd565b600b6020526000908152604090205460ff1681565b61030a61044c36600461452c565b610f49565b61034661045f366004614b5b565b610fd0565b610477610472366004614b8d565b611063565b6040516102ae9190615198565b6010546102df906001600160a01b031681565b6011546102df906001600160a01b031681565b6102df6104b8366004614b5b565b61131e565b6103466104cb3660046143fd565b611395565b61030a61141c565b61030a6104e636600461458d565b611493565b61030a6104f93660046143fd565b61155e565b600a546001600160a01b03166102df565b600d546102df906001600160a01b031681565b6102bf6115a5565b61030a61053836600461452c565b6115b4565b61030a61054b3660046143fd565b6116b6565b61030a61055e366004614487565b6116fd565b61030a6105713660046143fd565b611736565b6102bf610584366004614b5b565b61177d565b600f546102df906001600160a01b031681565b61030a6105aa366004614882565b611930565b6105ff6105bd366004614b5b565b60136020526000908152604090205461ffff81169063ffffffff620100008204811691600160301b8104909116906001600160801b03600160501b9091041684565b6040805161ffff95909516855263ffffffff938416602086015291909216908301526001600160801b031660608201526080016102ae565b61030a610645366004614679565b611a73565b6106de610658366004614b5b565b6012602052600090815260409020805460019091015463ffffffff8083169261ffff6401000000008204811693600160301b8304821693600160401b808504821694600160601b8104831694600160801b808304821695600160901b8404909216946001600160401b03600160a01b90940484169483851694908404169291909104168b565b6040805163ffffffff9c8d16815261ffff9b8c166020820152998b16908a0152968a166060890152948916608088015292871660a0870152951660c08501526001600160401b0394851660e08501528416610100840152929092166101208201529116610140820152610160016102ae565b6102bf611b9c565b6102a2610766366004614418565b611c22565b61030a6107793660046143fd565b611cdf565b6102a261078c3660046143fd565b611d99565b60006001600160e01b0319821663780e9d6360e01b14806107b657506107b682611dc9565b92915050565b6060600080546107cb906157f1565b80601f01602080910402602001604051908101604052809291908181526020018280546107f7906157f1565b80156108445780601f1061081957610100808354040283529160200191610844565b820191906000526020600020905b81548152906001019060200180831161082757829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108cc5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006108f38261131e565b9050806001600160a01b0316836001600160a01b031614156109615760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108c3565b806001600160a01b0316610973611e19565b6001600160a01b0316148061098f575061098f81610766611e19565b610a015760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016108c3565b610a0b8383611e76565b505050565b610a1933610b4f565b610a355760405162461bcd60e51b81526004016108c390615179565b600f80546001600160a01b0319166001600160a01b0392909216919091179055565b600080610a646000611ee4565b9092509050600460ff82161015610aa65760405162461bcd60e51b81526004016108c39060208082526004908201526347414d4560e01b604082015260600190565b610ab185858561205c565b5050505050565b610ac9610ac3611e19565b82612393565b610ae55760405162461bcd60e51b81526004016108c390615128565b610a0b83838361246a565b600080610afd6000611ee4565b9092509050600460ff82161015610b3f5760405162461bcd60e51b81526004016108c39060208082526004908201526347414d4560e01b604082015260600190565b610b498484612615565b50505050565b6000816001600160a01b0316610b6d600a546001600160a01b031690565b6001600160a01b031614806107b65750506001600160a01b03166000908152600b602052604090205460ff1690565b600e8181548110610bac57600080fd5b6000918252602090912001546001600160a01b0316905081565b600080610bd283611ee4565b91509150845160011480610bea5750600260ff821610155b610c1f5760405162461bcd60e51b81526004016108c3906020808252600490820152631355531560e21b604082015260600190565b60005b85518160ff161015610d5757600d5486516001600160a01b03909116906353fce67090859085908a9060ff8716908110610c5e57610c5e6158bd565b6020026020010151600e8a60ff1681548110610c7c57610c7c6158bd565b60009182526020909120015460405160e086901b6001600160e01b03191681526001600160a01b03948516600482015260ff90931660248401529083166044830152919091166064820152608401602060405180830381600087803b158015610ce457600080fd5b505af1158015610cf8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1c9190614921565b50610d45868260ff1681518110610d3557610d356158bd565b60200260200101518660006128ce565b80610d4f81615847565b915050610c22565b505050505050565b6000610d6a83611395565b8210610dcc5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016108c3565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600080610e0183611ee4565b600d5491935091506000906001600160a01b03166378353db6610e2389612dbe565b85858b8b8b6040518763ffffffff1660e01b8152600401610e49969594939291906153a6565b602060405180830381600087803b158015610e6357600080fd5b505af1158015610e77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9b9190614b21565b90506001600160801b03811615610ec257610eb88787600161205c565b610ec28782612615565b50505050505050565b610ed433610b4f565b610ef05760405162461bcd60e51b81526004016108c390615179565b6001600160a01b038216610f0357600080fd5b6001600160a01b03919091166000908152600c60205260409020805460ff1916911515919091179055565b610a0b838383604051806020016040528060008152506116fd565b610f51611e19565b6001600160a01b0316610f6c600a546001600160a01b031690565b6001600160a01b031614610f925760405162461bcd60e51b81526004016108c3906150f3565b6001600160a01b038216610fa557600080fd5b6001600160a01b03919091166000908152600b60205260409020805460ff1916911515919091179055565b6000610fdb60085490565b821061103e5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016108c3565b60088281548110611051576110516158bd565b90600052602060002001549050919050565b61106b6142a2565b6000838152601260209081526040808320815161018081018352815463ffffffff808216835261ffff6401000000008304811684880152600160301b8304811684870152600160401b80840483166060860152600160601b840483166080860152600160801b808504831660a0870152600160901b850490921660c08601526001600160401b03600160a01b909404841660e08601526001860154808516610100870152908104909316610120850152909104166101408201526002820180548451818702810187019095528085529194929361016086019390929083018282801561117657602002820191906000526020600020905b815481526020019060010190808311611162575b5050505050815250509050600061122a82868661119457600061119d565b61119d8861131e565b876111a9576000612ee2565b600d5460405163df03984d60e01b8152600481018b90526001600160a01b039091169063df03984d9060240160206040518083038186803b1580156111ed57600080fd5b505afa158015611201573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112259190614b74565b612ee2565b90506040518060a001604052806112546014546101f463ffffffff16856000015161ffff1661318b565b61ffff168152602001611279601454606463ffffffff16856020015161ffff1661318b565b61ffff168152602081018390526040808201859052600d549051633251ac5f60e21b8152600481018990526060909201916001600160a01b039091169063c946b17c9060240160006040518083038186803b1580156112d757600080fd5b505afa1580156112eb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611313919081019061475f565b905295945050505050565b6000818152600260205260408120546001600160a01b0316806107b65760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016108c3565b60006001600160a01b0382166114005760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016108c3565b506001600160a01b031660009081526003602052604090205490565b611424611e19565b6001600160a01b031661143f600a546001600160a01b031690565b6001600160a01b0316146114655760405162461bcd60e51b81526004016108c3906150f3565b60405162461bcd60e51b815260206004820152600360248201526227aba760e91b60448201526064016108c3565b61149c33610b4f565b6114b85760405162461bcd60e51b81526004016108c390615179565b600e5460ff82161061151557600e80546001810182556000919091527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd0180546001600160a01b0384166001600160a01b03199091161790555050565b81600e8260ff168154811061152c5761152c6158bd565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505050565b61156733610b4f565b6115835760405162461bcd60e51b81526004016108c390615179565b601180546001600160a01b0319166001600160a01b0392909216919091179055565b6060600180546107cb906157f1565b6115bc611e19565b6001600160a01b0316826001600160a01b0316141561161d5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108c3565b806005600061162a611e19565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff19169215159290921790915561166e611e19565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516116aa911515815260200190565b60405180910390a35050565b6116bf33610b4f565b6116db5760405162461bcd60e51b81526004016108c390615179565b601080546001600160a01b0319166001600160a01b0392909216919091179055565b61170e611708611e19565b83612393565b61172a5760405162461bcd60e51b81526004016108c390615128565b610b49848484846131c4565b61173f33610b4f565b61175b5760405162461bcd60e51b81526004016108c390615179565b600d80546001600160a01b0319166001600160a01b0392909216919091179055565b6000818152600260205260409020546060906001600160a01b03166117a157600080fd5b61190a600e6117b261010085615867565b815481106117c2576117c26158bd565b600091825260209091200154600f54604051635d0b221560e11b8152600481018690526001600160a01b0392831692630114b12292169063ba16442a9060240160006040518083038186803b15801561181a57600080fd5b505afa15801561182e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118569190810190614978565b600086815260126020526040908190205490516001600160e01b031960e085901b1681526118929291889163ffffffff9091169060040161505f565b60006040518083038186803b1580156118aa57600080fd5b505afa1580156118be573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118e69190810190614978565b6040516020016118f69190614fcb565b6040516020818303038152906040526131f7565b60405160200161191a9190614fe7565b6040516020818303038152906040529050919050565b60008061193c83611ee4565b9150915060005b8551811015610d5757611970868281518110611961576119616158bd565b6020026020010151848461335e565b600f5486516001600160a01b0390911690631f92cdcc90889084908110611999576119996158bd565b602002602001015187896040518463ffffffff1660e01b81526004016119c193929190615415565b602060405180830381600087803b1580156119db57600080fd5b505af11580156119ef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a139190614b74565b60126000888481518110611a2957611a296158bd565b60200260200101518152602001908152602001600020600001600c6101000a81548163ffffffff021916908363ffffffff1602179055508080611a6b9061582c565b915050611943565b600080611a7f83611ee4565b8551919350915060005b81811015610d5757600d5486516001600160a01b03909116906357a49b3a90869086908a9086908110611abe57611abe6158bd565b6020026020010151600001518a8681518110611adc57611adc6158bd565b6020026020010151602001518b8781518110611afa57611afa6158bd565b602090810291909101015160409081015190516001600160e01b031960e088901b1681526001600160a01b03909516600486015260ff9093166024850152604484019190915263ffffffff16606483015261ffff16608482015260a401600060405180830381600087803b158015611b7157600080fd5b505af1158015611b85573d6000803e3d6000fd5b505050508080611b949061582c565b915050611a89565b60105460408051636760578760e01b815290516060926001600160a01b0316916367605787916004808301926000929190829003018186803b158015611be157600080fd5b505afa158015611bf5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c1d9190810190614978565b905090565b600f5460405163317452ff60e21b81526001600160a01b0384811660048301528381166024830152600092169063c5d14bfc9060440160206040518083038186803b158015611c7057600080fd5b505afa158015611c84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca89190614921565b80611cd857506001600160a01b0380841660009081526005602090815260408083209386168352929052205460ff165b9392505050565b611ce7611e19565b6001600160a01b0316611d02600a546001600160a01b031690565b6001600160a01b031614611d285760405162461bcd60e51b81526004016108c3906150f3565b6001600160a01b038116611d8d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108c3565b611d9681613abe565b50565b6000611da482610b4f565b806107b65750506001600160a01b03166000908152600c602052604090205460ff1690565b60006001600160e01b031982166380ac58cd60e01b1480611dfa57506001600160e01b03198216635b5e139f60e01b145b806107b657506301ffc9a760e01b6001600160e01b03198316146107b6565b600033301415611e7057600080368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050503601516001600160a01b03169150611e739050565b50335b90565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611eab8261131e565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080611eef613b10565b611f245760405162461bcd60e51b81526004016108c3906020808252600490820152632152445960e01b604082015260600190565b6001600160a01b03831615801590611f4557506001600160a01b0383163314155b15611f91576011546001600160a01b03163314611f8c5760405162461bcd60e51b815260206004820152600560248201526450524f585960d81b60448201526064016108c3565b611f9c565b611f99611e19565b92505b600f546040516308e9cdb760e11b81526001600160a01b03858116600483015260009216906311d39b6e9060240160206040518083038186803b158015611fe257600080fd5b505afa158015611ff6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061201a9190614b74565b905060008160ff16116120555760405162461bcd60e51b815260206004820152600360248201526228262960e91b60448201526064016108c3565b9293915050565b60006120688484613b5d565b9050600081118015612091575060008481526012602052604090206002015463ffffffff168111155b6120c65760405162461bcd60e51b81526004016108c39060208082526004908201526314d313d560e21b604082015260600190565b6120d160018261574e565b905060006101006012600087815260200190815260200160002060020183815481106120ff576120ff6158bd565b90600052602060002001546121149190615867565b905060ff8316158061212c57508060ff168360ff1610155b156121fe57600085815260126020526040902060020154600161ffff821611156121bf57600086815260126020526040902060020161216c60018361572b565b61ffff1681548110612180576121806158bd565b90600052602060002001546012600088815260200190815260200160002060020184815481106121b2576121b26158bd565b6000918252602090912001555b60008681526012602052604090206002018054806121df576121df6158a7565b600190038181906000526020600020016000905590558193505061225d565b61220883826157a2565b905060ff81166122236001600160801b0386166101006156e9565b61222d919061553e565b6000868152601260205260409020600201805484908110612250576122506158bd565b6000918252602090912001555b600f5460405163122b671160e11b81526001600160801b03861660048201526001600160a01b0390911690632456ce229060240160206040518083038186803b1580156122a957600080fd5b505afa1580156122bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122e19190614b3e565b6122ee9060ff85166156bf565b6000868152601260208190526040909120805490919061231a908490600160901b900461ffff1661572b565b92506101000a81548161ffff021916908361ffff1602179055507f4b92ed7b627ee98572d071c75059084d237989679601c929c880f1fe14119cdd858585604051612384939291909283526001600160801b0391909116602083015260ff16604082015260600190565b60405180910390a15050505050565b6000818152600260205260408120546001600160a01b031661240c5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108c3565b60006124178361131e565b9050806001600160a01b0316846001600160a01b031614806124525750836001600160a01b03166124478461084e565b6001600160a01b0316145b8061246257506124628185611c22565b949350505050565b826001600160a01b031661247d8261131e565b6001600160a01b0316146124e55760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016108c3565b6001600160a01b0382166125475760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108c3565b612552838383613bff565b61255d600082611e76565b6001600160a01b038316600090815260036020526040812080546001929061258690849061574e565b90915550506001600160a01b03821660009081526003602052604081208054600192906125b490849061553e565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000816001600160801b0316116126575760405162461bcd60e51b81526004016108c3906020808252600490820152631313d3d560e21b604082015260600190565b60006126638383613b5d565b90506001816126bb57600084815260126020526040902060020160ff82166126966001600160801b0386166101006156e9565b6126a0919061553e565b815460018101835560009283526020909220909101556127a4565b6000848152601260205260409020610100906002016126db60018561574e565b815481106126eb576126eb6158bd565b90600052602060002001546127009190615867565b61270a9082615575565b90506101008160ff16106127485760405162461bcd60e51b8152602060048201526005602482015264535441434b60d81b60448201526064016108c3565b60ff81166127616001600160801b0385166101006156e9565b61276b919061553e565b600085815260126020526040902060020161278760018561574e565b81548110612797576127976158bd565b6000918252602090912001555b600f5460405163122b671160e11b81526001600160801b03851660048201526001600160a01b0390911690632456ce229060240160206040518083038186803b1580156127f057600080fd5b505afa158015612804573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128289190614b3e565b60008581526012602081905260409091208054909190612854908490600160901b900461ffff16615518565b92506101000a81548161ffff021916908361ffff1602179055507f4b92ed7b627ee98572d071c75059084d237989679601c929c880f1fe14119cdd848460006040516128c0939291909283526001600160801b0391909116602083015261ffff16604082015260600190565b60405180910390a150505050565b600a8160ff161061290a5760405162461bcd60e51b8152602060048201526006602482015265535550504c5960d01b60448201526064016108c3565b600e5460ff8316106129435760405162461bcd60e51b8152602060048201526002602482015261115160f21b60448201526064016108c3565b6000600e8360ff168154811061295b5761295b6158bd565b600091825260208220015460408051635aa3d76d60e11b815281516001600160a01b0390931694508392859263b547aeda926004808201939182900301818787803b1580156129a957600080fd5b505af11580156129bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e19190614c6a565b90925090506129f360ff86168361553e565b6000818152600260205260409020549092506001600160a01b031615612a2857610d578686612a23876001615575565b6128ce565b604051631e7269c560e01b81526001600160a01b03878116600483015260009190851690631e7269c59060240160206040518083038186803b158015612a6d57600080fd5b505afa158015612a81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aa59190614b3e565b604051635ed88ecf60e01b81526001600160a01b03898116600483015261ffff92909216925090851690635ed88ecf9060240160206040518083038186803b158015612af057600080fd5b505afa158015612b04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b289190614b3e565b61ffff168163ffffffff1610612b685760405162461bcd60e51b8152602060048201526005602482015264131253525560da1b60448201526064016108c3565b6000846001600160a01b03166306661abd6040518163ffffffff1660e01b815260040160206040518083038186803b158015612ba357600080fd5b505afa158015612bb7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bdb9190614b3e565b9050846001600160a01b0316639ef2d87a6040518163ffffffff1660e01b815260040160206040518083038186803b158015612c1657600080fd5b505afa158015612c2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c4e9190614b3e565b61ffff168161ffff1610612c8a5760405162461bcd60e51b815260206004820152600360248201526209a82b60eb1b60448201526064016108c3565b600854612c9890600161553e565b6000858152601260205260409020805463ffffffff9290921665ffffffffffff199092169190911764010000000061ffff84811691909102919091177fffffffff0000000000000000ffffffffffffffffffffffff0000ffffffffffff16600160301b9186169190910267ffffffffffffffff60a01b191617600160a01b426001600160401b031602179055612d2e8885613c97565b6040516001625e138560e01b031981526001600160a01b0389811660048301526001602483015286169063ffa1ec7b90604401602060405180830381600087803b158015612d7b57600080fd5b505af1158015612d8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612db39190614921565b505050505050505050565b612dc6614334565b600082815260126020908152604091829020825161018081018452815463ffffffff808216835261ffff6401000000008304811684870152600160301b8304811684880152600160401b80840483166060860152600160601b840483166080860152600160801b808504831660a0870152600160901b850490921660c08601526001600160401b03600160a01b909404841660e08601526001860154808516610100870152908104909316610120850152909104166101408201526002820180548551818602810186019096528086526107b6959294610160860193929190830182828015612ed457602002820191906000526020600020905b815481526020019060010190808311612ec0575b505050505081525050836000805b612eea614334565b6000612ef98360006002613de5565b90506000612f0984600280613de5565b90506001600160a01b03851615156000612f2561010089615867565b90506040518060c001604052808a604001516064612f439190615518565b61ffff16815260200160048363ffffffff1610612f61576050612f6c565b612f6c836014615708565b60408c0151612f7c906064615518565b61ffff16612f8a9190615765565b61ffff90811682526064602083015285811660408301528616606082015260800183612fb7576000612fbd565b8a608001515b63ffffffff168152509450600f60009054906101000a90046001600160a01b03166001600160a01b0316633fa72f678a600e8463ffffffff1681548110613006576130066158bd565b6000918252602090912001546040516397bac7c560e01b81526001600160a01b03909116906397bac7c590613041908b908f906004016153fa565b60c06040518083038186803b15801561305957600080fd5b505afa15801561306d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130919190614a77565b60105460405163fbcbc0f160e01b81526001600160a01b038d811660048301529091169063fbcbc0f19060240160e06040518083038186803b1580156130d657600080fd5b505afa1580156130ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061310e91906149c0565b866040518563ffffffff1660e01b815260040161312e9493929190615293565b60c06040518083038186803b15801561314657600080fd5b505afa15801561315a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061317e9190614a77565b9998505050505050505050565b60145460009061319c8160646156e9565b846131a785886156e9565b6131b191906156e9565b6131bb919061559a565b95945050505050565b6131cf84848461246a565b6131db84848484613e0d565b610b495760405162461bcd60e51b81526004016108c3906150a1565b606081516000141561321757505060408051602081019091526000815290565b60006040518060600160405280604081526020016159546040913990506000600384516002613246919061553e565b613250919061559a565b61325b9060046156e9565b9050600061326a82602061553e565b6001600160401b03811115613281576132816158d3565b6040519080825280601f01601f1916602001820160405280156132ab576020820181803683370190505b509050818152600183018586518101602084015b818310156133195760039283018051603f601282901c811687015160f890811b8552600c83901c8216880151811b6001860152600683901c8216880151811b60028601529116860151901b938201939093526004016132bf565b600389510660018114613333576002811461334457613350565b613d3d60f01b600119830152613350565b603d60f81b6000198301525b509398975050505050505050565b6000838152601260209081526040808320815161018081018352815463ffffffff808216835261ffff6401000000008304811684880152600160301b8304811684870152600160401b80840483166060860152600160601b840483166080860152600160801b808504831660a0870152600160901b850490921660c08601526001600160401b03600160a01b909404841660e08601526001860154808516610100870152908104909316610120850152909104166101408201526002820180548451818702810187019095528085529194929361016086019390929083018282801561346957602002820191906000526020600020905b815481526020019060010190808311613455575b5050505050815250509050600061347f8561131e565b9050836001600160a01b0316816001600160a01b031614806134a55750600460ff841610155b6134d75760405162461bcd60e51b815260206004820152600360248201526227aba760e91b60448201526064016108c3565b6101208201516001600160401b0316613623576000600e6134fa61010088615867565b8154811061350a5761350a6158bd565b60009182526020918290200154604080516329fc5dcd60e11b815290516001600160a01b03909216926353f8bb9a92600480840193829003018186803b15801561355357600080fd5b505afa158015613567573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061358b9190614cbe565b90506000816001600160401b03161180156135b75750426001600160401b0316816001600160401b0316105b6135e95760405162461bcd60e51b815260206004820152600360248201526250524560e81b60448201526064016108c3565b806001600160401b03168360e001516001600160401b03161161360c5780613612565b8260e001515b6001600160401b0316610120840152505b600d5460405163fbc70c9760e01b815260048101879052600091613688918591899186916001600160a01b03169063fbc70c9790602401602060405180830381600087803b15801561367457600080fd5b505af1158015611201573d6000803e3d6000fd5b905060008361012001514261369d9190615782565b6000888152601360205260409020805469ffffffffffffffffffff1916905560a08301519091506201000063ffffffff909116106137a45760006136f78263ffffffff16606463ffffffff16856020015161ffff1661318b565b905063ffffffff81161561379e57600d5460405163b02bf4b960e01b81526001600160a01b03868116600483015263ffffffff841660248301529091169063b02bf4b990604401600060405180830381600087803b15801561375857600080fd5b505af115801561376c573d6000803e3d6000fd5b5050506000898152601360205260409020805469ffffffff0000000000001916600160301b63ffffffff851602179055505b50613918565b60006137c78263ffffffff166101f463ffffffff16856000015161ffff1661318b565b600f5460008a815260126020526040808220905163714cfd6960e01b8152939450909283926001600160a01b03169163714cfd699161380d91908a90889060040161536d565b6040805180830381600087803b15801561382657600080fd5b505af115801561383a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061385e9190614c8f565b60008c8152601360209081526040808320805465ffffffffffff19166201000063ffffffff8b160261ffff19161761ffff868116919091179091556012909252909120805493955091935083926010916138c2918591600160801b90910416615518565b825461ffff9182166101009390930a928302919092021990911617905550506000898152601260205260409020805463ffffffff909216600160401b026bffffffff000000000000000019909216919091179055505b601454600f546000906001600160a01b0316630ba758f461393984866155ae565b866040518363ffffffff1660e01b815260040161395792919061543a565b602060405180830381600087803b15801561397157600080fd5b505af1158015613985573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139a99190614b21565b60008a815260136020526040902080546fffffffffffffffffffffffffffffffff60501b1916600160501b6001600160801b03841690810291909117909155909150156139fa576139fa8982612615565b6000898152601260205260408120600190810180546fffffffffffffffff00000000000000001916600160401b426001600160401b031602179055610140880151613a4491615556565b60008b815260126020908152604091829020600101805463ffffffff60801b1916600160801b63ffffffff86169081029190911790915582518e8152918201529192507f075f755287452a199f075e4a7501bd3c4c98ccfa9544fee7eac3d04d658fedf4910160405180910390a150505050505050505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600f546000906001600160a01b031615801590613b2e5750600e5415155b8015613b445750600d546001600160a01b031615155b8015611c1d5750506010546001600160a01b0316151590565b6000805b60008481526012602052604090206002015460ff82161015613bf557600084815260126020526040902060020180546001600160801b038516916101009160ff8516908110613bb257613bb26158bd565b9060005260206000200154613bc7919061559a565b1415613be357613bd8816001615575565b60ff169150506107b6565b80613bed81615847565b915050613b61565b5060009392505050565b613c0a838383613f1e565b6000818152601260205260409081902060018101805467ffffffffffffffff1916426001600160401b0316179055600f54915163183e599560e31b81526001600160a01b039092169163c1f2cca891613c69918790879060040161533a565b600060405180830381600087803b158015613c8357600080fd5b505af1158015610ec2573d6000803e3d6000fd5b6001600160a01b038216613ced5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108c3565b6000818152600260205260409020546001600160a01b031615613d525760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108c3565b613d5e60008383613bff565b6001600160a01b0382166000908152600360205260408120805460019290613d8790849061553e565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000613df082613fd6565b613df984613fd6565b613e03908661559a565b6124629190615867565b60006001600160a01b0384163b15613f1657836001600160a01b031663150b7a02613e36611e19565b8786866040518563ffffffff1660e01b8152600401613e58949392919061502c565b602060405180830381600087803b158015613e7257600080fd5b505af1925050508015613ea2575060408051601f3d908101601f19168201909252613e9f9181019061495b565b60015b613efc573d808015613ed0576040519150601f19603f3d011682016040523d82523d6000602084013e613ed5565b606091505b508051613ef45760405162461bcd60e51b81526004016108c3906150a1565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612462565b506001612462565b6001600160a01b038316613f7957613f7481600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b613f9c565b816001600160a01b0316836001600160a01b031614613f9c57613f9c8382614112565b6001600160a01b038216613fb357610a0b816141af565b826001600160a01b0316826001600160a01b031614610a0b57610a0b828261425e565b600060ff8216613fe857506001919050565b8160ff1660011415613ffd5750610100919050565b8160ff1660021415614013575062010000919050565b8160ff166003141561402a57506301000000919050565b8160ff16600414156140425750640100000000919050565b8160ff166005141561405b575065010000000000919050565b8160ff16600614156140725750600160301b919050565b8160ff166007141561408d5750670100000000000000919050565b8160ff16600814156140a45750600160401b919050565b8160ff16600914156140c157506901000000000000000000919050565b8160ff16600a14156140d85750600160501b919050565b8160ff16600b14156140ef5750600160581b919050565b8160ff16600c14156141065750600160601b919050565b6107b682610100615614565b6000600161411f84611395565b614129919061574e565b60008381526007602052604090205490915080821461417c576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906141c19060019061574e565b600083815260096020526040812054600880549394509092849081106141e9576141e96158bd565b90600052602060002001549050806008838154811061420a5761420a6158bd565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480614242576142426158a7565b6001900381819060005260206000200160009055905550505050565b600061426983611395565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6040805160a081018252600080825260208201529081016142c1614334565b815260408051610180810182526000808252602082810182905292820181905260608083018290526080830182905260a0830182905260c0830182905260e08301829052610100830182905261012083018290526101408301919091526101608201529101908152602001606081525090565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a081019190915290565b600061437c614377846154f1565b61549e565b905082815283838301111561439057600080fd5b611cd88360208301846157c5565b80356001600160a01b03811681146143b557600080fd5b919050565b80516143b581615922565b80356143b581615932565b80516001600160401b03811681146143b557600080fd5b80356143b581615944565b80516143b581615944565b60006020828403121561440f57600080fd5b611cd88261439e565b6000806040838503121561442b57600080fd5b6144348361439e565b91506144426020840161439e565b90509250929050565b60008060006060848603121561446057600080fd5b6144698461439e565b92506144776020850161439e565b9150604084013590509250925092565b6000806000806080858703121561449d57600080fd5b6144a68561439e565b93506144b46020860161439e565b92506040850135915060608501356001600160401b038111156144d657600080fd5b8501601f810187136144e757600080fd5b80356144f5614377826154f1565b81815288602083850101111561450a57600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b6000806040838503121561453f57600080fd5b6145488361439e565b91506020830135614558816158e9565b809150509250929050565b6000806040838503121561457657600080fd5b61457f8361439e565b946020939093013593505050565b600080604083850312156145a057600080fd5b6145a98361439e565b9150602083013561455881615944565b6000806000606084860312156145ce57600080fd5b83356001600160401b038111156145e457600080fd5b8401601f810186136145f557600080fd5b80356020614605614377836154ce565b8083825282820191508285018a848660051b880101111561462557600080fd5b600095505b8486101561464f5761463b8161439e565b83526001959095019491830191830161462a565b50965061465f90508782016143e7565b94505050506146706040850161439e565b90509250925092565b600080604080848603121561468d57600080fd5b83356001600160401b038111156146a357600080fd5b8401601f810186136146b457600080fd5b803560206146c4614377836154ce565b828152818101908483016060808602870185018c10156146e357600080fd5b60009650865b8681101561473f5781838e0312156146ff578788fd5b614707615454565b833581528684013561471881615932565b81880152838a013561472981615922565b818b0152855293850193918101916001016146e9565b505050809750505061475281880161439e565b9450505050509250929050565b6000602080838503121561477257600080fd5b82516001600160401b0381111561478857600080fd5b8301601f8101851361479957600080fd5b80516147a7614377826154ce565b8181528381019083850160e0808502860187018a10156147c657600080fd5b60009550855b858110156148735781838c0312156147e2578687fd5b6147ea61547c565b83516147f581615932565b81528389015161480481615932565b818a015260408481015161481781615922565b9082015260608481015161482a81615922565b90820152608061483b8582016143ba565b9082015260a061484c8582016143ba565b9082015260c061485d8582016143d0565b90820152855293870193918101916001016147cc565b50919998505050505050505050565b60008060006060848603121561489757600080fd5b83356001600160401b038111156148ad57600080fd5b8401601f810186136148be57600080fd5b803560206148ce614377836154ce565b8083825282820191508285018a848660051b88010111156148ee57600080fd5b600095505b848610156149115780358352600195909501949183019183016148f3565b50965061465f90508782016143c5565b60006020828403121561493357600080fd5b8151611cd8816158e9565b60006020828403121561495057600080fd5b8135611cd8816158f7565b60006020828403121561496d57600080fd5b8151611cd8816158f7565b60006020828403121561498a57600080fd5b81516001600160401b038111156149a057600080fd5b8201601f810184136149b157600080fd5b61246284825160208401614369565b600060e082840312156149d257600080fd5b60405160e081018181106001600160401b03821117156149f4576149f46158d3565b604052614a00836143d0565b81526020830151614a1081615932565b60208201526040830151614a2381615932565b60408201526060830151614a3681615922565b60608201526080830151614a4981615922565b6080820152614a5a60a084016143ba565b60a0820152614a6b60c084016143f2565b60c08201529392505050565b600060c08284031215614a8957600080fd5b60405160c081018181106001600160401b0382111715614aab57614aab6158d3565b6040528251614ab981615922565b81526020830151614ac981615922565b60208201526040830151614adc81615922565b60408201526060830151614aef81615922565b60608201526080830151614b0281615922565b608082015260a0830151614b1581615932565b60a08201529392505050565b600060208284031215614b3357600080fd5b8151611cd88161590d565b600060208284031215614b5057600080fd5b8151611cd881615922565b600060208284031215614b6d57600080fd5b5035919050565b600060208284031215614b8657600080fd5b5051919050565b60008060408385031215614ba057600080fd5b823591506020830135614558816158e9565b60008060408385031215614bc557600080fd5b8235915060208301356145588161590d565b600080600060608486031215614bec57600080fd5b833592506020840135614bfe8161590d565b91506040840135614c0e81615944565b809150509250925092565b60008060008060808587031215614c2f57600080fd5b843593506020850135614c418161590d565b92506040850135614c5181615944565b9150614c5f6060860161439e565b905092959194509250565b60008060408385031215614c7d57600080fd5b82519150602083015161455881615922565b60008060408385031215614ca257600080fd5b8251614cad81615932565b602084015190925061455881615922565b600060208284031215614cd057600080fd5b611cd8826143d0565b600081518084526020808501945080840160005b83811015614d0957815187529582019590820190600101614ced565b509495945050505050565b6000815480845260208085019450836000528060002060005b83811015614d0957815487529582019560019182019101614d2d565b60008151808452614d618160208601602086016157c5565b601f01601f19169290920160200192915050565b805163ffffffff16825260006101806020830151614d99602086018261ffff169052565b506040830151614daf604086018261ffff169052565b506060830151614dc7606086018263ffffffff169052565b506080830151614ddf608086018263ffffffff169052565b5060a0830151614df560a086018261ffff169052565b5060c0830151614e0b60c086018261ffff169052565b5060e0830151614e2660e08601826001600160401b03169052565b50610100838101516001600160401b039081169186019190915261012080850151909116908501526101408084015163ffffffff169085015261016080840151818601839052614e7883870182614cd9565b9695505050505050565b805463ffffffff80821684526000916101809161ffff614ead60208801828560201c1661ffff169052565b614ec260408801828560301c1661ffff169052565b614ed960608801838560401c1663ffffffff169052565b614ef060808801838560601c1663ffffffff169052565b614f0560a08801828560801c1661ffff169052565b614f1a60c08801828560901c1661ffff169052565b506001600160401b0360a09290921c821660e08701526001850154808316610100880152604081901c83166101208801529150614f656101408701828460801c1663ffffffff169052565b50508061016085015261246281850160028501614d14565b61ffff8082511683528060208301511660208401528060408301511660408401528060608301511660608401528060808301511660808401525063ffffffff60a08201511660a08301525050565b60008251614fdd8184602087016157c5565b9190910192915050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081526000825161501f81601d8501602087016157c5565b91909101601d0192915050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090614e7890830184614d49565b6060815260006150726060830186614d49565b905083602083015263ffffffff83166040830152949350505050565b602081526000611cd86020830184614d49565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60208082526005908201526420a226a4a760d91b604082015260600190565b6000602080835261ffff80855116828501528185015160408282168187015280870151915060606151cb81880184614f7d565b808801519250610140806101208901526151e9610160890185614d75565b60808a8101518a8303601f1901938b019390935282518083529288019550908701916000905b80821015615283578651805163ffffffff90811686528a820151168a86015286810151891687860152858101518916868601528381015189168486015260a08082015161ffff169086015260c0908101516001600160401b0316908501529588019560e0909301926001919091019061520f565b50919a9950505050505050505050565b60006101e08083526152a781840188614d75565b9150506152b76020830186614f7d565b83516001600160401b031660e0830152602084015163ffffffff908116610100840152604085015116610120830152606084015161ffff90811661014084015260808501511661016083015260a084015161531961018084018261ffff169052565b5060c084015160ff166101a08301528215156101c083015295945050505050565b60608152600061534d6060830186614e82565b6001600160a01b0394851660208401529290931660409091015292915050565b6060815260006153806060830186614e82565b6001600160a01b039490941660208301525063ffffffff91909116604090910152919050565b61016081016153b58289614f7d565b6001600160a01b039690961660c082015260ff94851660e08201526101008101939093526001600160801b039190911661012083015290911661014090910152919050565b60e081016154088285614f7d565b8260c08301529392505050565b83815263ffffffff831660208201526060604082015260006131bb6060830184614cd9565b63ffffffff8316815260e08101611cd86020830184614f7d565b604051606081016001600160401b0381118282101715615476576154766158d3565b60405290565b60405160e081016001600160401b0381118282101715615476576154766158d3565b604051601f8201601f191681016001600160401b03811182821017156154c6576154c66158d3565b604052919050565b60006001600160401b038211156154e7576154e76158d3565b5060051b60200190565b60006001600160401b0382111561550a5761550a6158d3565b50601f01601f191660200190565b600061ffff8083168185168083038211156155355761553561587b565b01949350505050565b600082198211156155515761555161587b565b500190565b600063ffffffff8083168185168083038211156155355761553561587b565b600060ff821660ff84168060ff038211156155925761559261587b565b019392505050565b6000826155a9576155a9615891565b500490565b600063ffffffff808416806155c5576155c5615891565b92169190910492915050565b600181815b8085111561560c5781600019048211156155f2576155f261587b565b808516156155ff57918102915b93841c93908002906155d6565b509250929050565b6000611cd860ff84168360008261562d575060016107b6565b8161563a575060006107b6565b8160018114615650576002811461565a57615676565b60019150506107b6565b60ff84111561566b5761566b61587b565b50506001821b6107b6565b5060208310610133831016604e8410600b8410161715615699575081810a6107b6565b6156a383836155d1565b80600019048211156156b7576156b761587b565b029392505050565b600061ffff808316818516818304811182151516156156e0576156e061587b565b02949350505050565b60008160001904831182151516156157035761570361587b565b500290565b600063ffffffff808316818516818304811182151516156156e0576156e061587b565b600061ffff838116908316818110156157465761574661587b565b039392505050565b6000828210156157605761576061587b565b500390565b600063ffffffff838116908316818110156157465761574661587b565b60006001600160401b03838116908316818110156157465761574661587b565b600060ff821660ff8416808210156157bc576157bc61587b565b90039392505050565b60005b838110156157e05781810151838201526020016157c8565b83811115610b495750506000910152565b600181811c9082168061580557607f821691505b6020821081141561582657634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156158405761584061587b565b5060010190565b600060ff821660ff81141561585e5761585e61587b565b60010192915050565b60008261587657615876615891565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b8015158114611d9657600080fd5b6001600160e01b031981168114611d9657600080fd5b6001600160801b0381168114611d9657600080fd5b61ffff81168114611d9657600080fd5b63ffffffff81168114611d9657600080fd5b60ff81168114611d9657600080fdfe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa264697066735822122040cf72a4f8d48f233c7eed697e729f0a821dbc67785173b4474fc6604845ecaa64736f6c63430008070033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000000000000000000000000000000000000000000e10

-----Decoded View---------------
Arg [0] : interval (uint256): 3600

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000e10


Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.