ETH Price: $3,409.96 (+2.95%)

Contract

0x68fFCb1B5F8e5d035c3B4bf49F8F139F49E45509
 

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Mek Honey Jar Wi...212515962024-11-23 16:20:3520 mins ago1732378835IN
0x68fFCb1B...F49E45509
0 ETH0.0133216932.93602148
Mek Honey Jar Wi...212450372024-11-22 18:24:2322 hrs ago1732299863IN
0x68fFCb1B...F49E45509
0.11 ETH0.0020729212.73912946
Mek Honey Jar Wi...212433612024-11-22 12:46:2327 hrs ago1732279583IN
0x68fFCb1B...F49E45509
0.11 ETH0.0024896315.3
Mek Honey Jar Wi...212430082024-11-22 11:35:2329 hrs ago1732275323IN
0x68fFCb1B...F49E45509
0.11 ETH0.0018082410.05578829
Mek Honey Jar Wi...212423312024-11-22 9:19:2331 hrs ago1732267163IN
0x68fFCb1B...F49E45509
0.11 ETH0.0018764110.43491402
Mek Honey Jar Wi...212422602024-11-22 9:05:1131 hrs ago1732266311IN
0x68fFCb1B...F49E45509
0.11 ETH0.0016592110.19668117
Mek Honey Jar Wi...212419862024-11-22 8:09:5932 hrs ago1732262999IN
0x68fFCb1B...F49E45509
0 ETH0.001791349.54162167
Mek Honey Jar Wi...212418642024-11-22 7:45:2332 hrs ago1732261523IN
0x68fFCb1B...F49E45509
0.11 ETH0.001748119.7214376
Mek Honey Jar Wi...212418482024-11-22 7:42:1132 hrs ago1732261331IN
0x68fFCb1B...F49E45509
0 ETH0.0019840210.56796481
Mek Honey Jar Wi...212412962024-11-22 5:50:5934 hrs ago1732254659IN
0x68fFCb1B...F49E45509
0.11 ETH0.001676659.32401964
Mek Honey Jar Wi...212408022024-11-22 4:11:4736 hrs ago1732248707IN
0x68fFCb1B...F49E45509
0.11 ETH0.0021963512.2141263
Mek Honey Jar Wi...212405512024-11-22 3:21:3537 hrs ago1732245695IN
0x68fFCb1B...F49E45509
0.22 ETH0.0030560413.0063694
Mek Honey Jar Wi...212405482024-11-22 3:20:5937 hrs ago1732245659IN
0x68fFCb1B...F49E45509
0.11 ETH0.0023308812.9622555
Mek Honey Jar Wi...212405282024-11-22 3:16:5937 hrs ago1732245419IN
0x68fFCb1B...F49E45509
0 ETH0.0169574112.87630779
Mek Honey Jar Wi...212404892024-11-22 3:08:5937 hrs ago1732244939IN
0x68fFCb1B...F49E45509
0.11 ETH0.0018323610.18992165
Mek Honey Jar Wi...212404612024-11-22 3:03:2337 hrs ago1732244603IN
0x68fFCb1B...F49E45509
0 ETH0.0018280510.71292405
Mek Honey Jar Wi...212404472024-11-22 3:00:3537 hrs ago1732244435IN
0x68fFCb1B...F49E45509
0.11 ETH0.0019140610.64427506
Mek Honey Jar Wi...212404202024-11-22 2:55:1137 hrs ago1732244111IN
0x68fFCb1B...F49E45509
0.11 ETH0.0019040110.58836866
Mek Honey Jar Wi...212404092024-11-22 2:52:5937 hrs ago1732243979IN
0x68fFCb1B...F49E45509
0.11 ETH0.0019351211.89226948
Mek Honey Jar Wi...212403812024-11-22 2:47:2337 hrs ago1732243643IN
0x68fFCb1B...F49E45509
0 ETH0.0023025612.26464913
Mek Honey Jar Wi...212403512024-11-22 2:41:2337 hrs ago1732243283IN
0x68fFCb1B...F49E45509
0.11 ETH0.0026016914.46824115
Mek Honey Jar Wi...212403332024-11-22 2:37:4738 hrs ago1732243067IN
0x68fFCb1B...F49E45509
0.11 ETH0.0020002511.12360515
Mek Honey Jar Wi...212402932024-11-22 2:29:3538 hrs ago1732242575IN
0x68fFCb1B...F49E45509
0 ETH0.0021478611.44064172
Mek Honey Jar Wi...212402122024-11-22 2:13:1138 hrs ago1732241591IN
0x68fFCb1B...F49E45509
0.11 ETH0.0018881210.5
Mek Honey Jar Wi...212402112024-11-22 2:12:5938 hrs ago1732241579IN
0x68fFCb1B...F49E45509
0.11 ETH0.0018424610.24610807
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
212450372024-11-22 18:24:2322 hrs ago1732299863
0x68fFCb1B...F49E45509
0.085437 ETH
212450372024-11-22 18:24:2322 hrs ago1732299863
0x68fFCb1B...F49E45509
0.024563 ETH
212433612024-11-22 12:46:2327 hrs ago1732279583
0x68fFCb1B...F49E45509
0.085437 ETH
212433612024-11-22 12:46:2327 hrs ago1732279583
0x68fFCb1B...F49E45509
0.024563 ETH
212430082024-11-22 11:35:2329 hrs ago1732275323
0x68fFCb1B...F49E45509
0.085437 ETH
212430082024-11-22 11:35:2329 hrs ago1732275323
0x68fFCb1B...F49E45509
0.024563 ETH
212423312024-11-22 9:19:2331 hrs ago1732267163
0x68fFCb1B...F49E45509
0.085437 ETH
212423312024-11-22 9:19:2331 hrs ago1732267163
0x68fFCb1B...F49E45509
0.024563 ETH
212422602024-11-22 9:05:1131 hrs ago1732266311
0x68fFCb1B...F49E45509
0.085437 ETH
212422602024-11-22 9:05:1131 hrs ago1732266311
0x68fFCb1B...F49E45509
0.024563 ETH
212418642024-11-22 7:45:2332 hrs ago1732261523
0x68fFCb1B...F49E45509
0.085437 ETH
212418642024-11-22 7:45:2332 hrs ago1732261523
0x68fFCb1B...F49E45509
0.024563 ETH
212412962024-11-22 5:50:5934 hrs ago1732254659
0x68fFCb1B...F49E45509
0.085437 ETH
212412962024-11-22 5:50:5934 hrs ago1732254659
0x68fFCb1B...F49E45509
0.024563 ETH
212408022024-11-22 4:11:4736 hrs ago1732248707
0x68fFCb1B...F49E45509
0.085437 ETH
212408022024-11-22 4:11:4736 hrs ago1732248707
0x68fFCb1B...F49E45509
0.024563 ETH
212405512024-11-22 3:21:3537 hrs ago1732245695
0x68fFCb1B...F49E45509
0.170874 ETH
212405512024-11-22 3:21:3537 hrs ago1732245695
0x68fFCb1B...F49E45509
0.049126 ETH
212405482024-11-22 3:20:5937 hrs ago1732245659
0x68fFCb1B...F49E45509
0.085437 ETH
212405482024-11-22 3:20:5937 hrs ago1732245659
0x68fFCb1B...F49E45509
0.024563 ETH
212404892024-11-22 3:08:5937 hrs ago1732244939
0x68fFCb1B...F49E45509
0.085437 ETH
212404892024-11-22 3:08:5937 hrs ago1732244939
0x68fFCb1B...F49E45509
0.024563 ETH
212404472024-11-22 3:00:3537 hrs ago1732244435
0x68fFCb1B...F49E45509
0.085437 ETH
212404472024-11-22 3:00:3537 hrs ago1732244435
0x68fFCb1B...F49E45509
0.024563 ETH
212404202024-11-22 2:55:1137 hrs ago1732244111
0x68fFCb1B...F49E45509
0.085437 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
HoneyBox

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 10 runs

Other Settings:
default evmVersion
File 1 of 27 : HoneyBox.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import {ERC1155TokenReceiver} from "solmate/tokens/ERC1155.sol";
import {ERC721TokenReceiver} from "solmate/tokens/ERC721.sol";
import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol";
import {FixedPointMathLib} from "solmate/utils/FixedPointMathLib.sol";
import {ReentrancyGuard} from "solmate/utils/ReentrancyGuard.sol";

import {VRFCoordinatorV2Interface} from "@chainlink/interfaces/VRFCoordinatorV2Interface.sol";
import {VRFConsumerBaseV2} from "@chainlink/VRFConsumerBaseV2.sol";

import {GameRegistryConsumer} from "src/GameRegistryConsumer.sol";
import {IGatekeeper} from "src/IGatekeeper.sol";
import {IHoneyJar} from "src/IHoneyJar.sol";
import {Constants} from "src/Constants.sol";

/// @title HoneyBox
/// @notice Revision of v1/BearCave.sol
/// @notice Manages bundling & storage of NFTs. Mints honeyJar ERC721s
contract HoneyBox is
    VRFConsumerBaseV2,
    ERC721TokenReceiver,
    ERC1155TokenReceiver,
    GameRegistryConsumer,
    ReentrancyGuard
{
    using SafeERC20 for IERC20;
    using FixedPointMathLib for uint256;

    /// @notice the lone sleepooor (single NFT)
    struct SleepingNFT {
        address tokenAddress;
        uint256 tokenId; // The ID of the sleeping NFT
        bool isERC1155;
    }

    /// @notice The bundle Config (Collection)
    struct SlumberParty {
        uint8 bundleId;
        uint256 specialHoneyJar; // defaults to 0
        uint256 publicMintTime; // block.timestamp that general public can start making honeyJars
        bool specialHoneyJarFound; // So tokenID=0 can't wake bear before special honey is found
        bool isAwake;
        SleepingNFT[] sleepoors;
    }

    /// @notice Configuration for minting for games occurring at the same time.
    struct MintConfig {
        uint32 maxHoneyJar; // Max # of generated honeys (Max of 4.2m)
        uint32 maxClaimableHoneyJar; // # of honeyJars that can be claimed (total)
        uint256 honeyJarPrice_ERC20;
        uint256 honeyJarPrice_ETH;
    }

    /**
     *  Game Errors
     */
    // Contract State
    error NotInitialized();
    error AlreadyInitialized();

    // Game state
    error PartyAlreadyWoke(uint8 bundleId);
    error GameInProgress();
    error AlreadyTooManyHoneyJars(uint8 bundleId);
    error SpecialHoneyJarNotFound(uint8 bundleId);
    error NotEnoughHoneyJarMinted(uint8 bundleId);
    error GeneralMintNotOpen(uint8 bundleId);
    error InvalidBundle(uint8 bundleId);
    error NotSleeping(uint8 bundleId);
    error TooManyBundles();

    // User Errors
    error NotOwnerOfSpecialHoneyJar(uint8 bundleId, uint256 honeyJarId);
    error InvalidInput(string method);
    error Claim_InvalidProof();
    error MekingTooManyHoneyJars(uint8 bundleId);
    error ZeroMint();
    error WrongAmount_ETH(uint256 expected, uint256 actual);

    /**
     * Events
     */
    event Initialized(MintConfig mintConfig);
    event SlumberPartyStarted(uint8 bundleId);
    event SlumberPartyAdded(uint8 bundleId);
    event SpecialHoneyJarFound(uint8 bundleId, uint256 honeyJarId);
    event MintConfigChanged(MintConfig mintConfig);
    event VRFConfigChanged(VRFConfig vrfConfig);
    event HoneyJarClaimed(uint256 bundleId, uint32 gateId, address player, uint256 amount);
    event PartyAwoke(uint8 bundleId, address player);

    /**
     * Configuration
     */
    IERC20 public immutable paymentToken; // OHM
    MintConfig public mintConfig;

    /**
     * Chainlink VRF Config
     */
    // The gas lane to use, which specifies the maximum gas price to bump to.
    // For a list of available gas lanes on each network,
    // see https://docs.chain.link/docs/vrf-contracts/#configurations

    struct VRFConfig {
        bytes32 keyHash;
        uint64 subId; // https://vrf.chain.link/goerli/new
        uint16 minConfirmations; // Default is 3
        uint32 callbackGasLimit; // enough for ~5 words
    }

    VRFConfig private vrfConfig;

    /**
     * bearPouch
     */
    address payable private immutable beekeeper; // rev share
    address payable private immutable jani;
    uint256 public immutable honeyJarShare; // as a WAD

    /**
     * Dependencies
     */
    IGatekeeper public immutable gatekeeper;
    IHoneyJar public immutable honeyJar;
    VRFCoordinatorV2Interface internal immutable vrfCoordinator;

    /**
     * Internal Storage
     */
    bool public initialized;
    SlumberParty[] public slumberPartyList; // list of slumberparties
    mapping(uint8 => SlumberParty) public slumberParties; //  bundleId --> bundle
    mapping(uint8 => uint32) public claimed; // bundleId -> numClaimed (free claims)
    mapping(uint256 => uint8) public rng; // Chainlink VRF request ID => bundleID
    mapping(uint256 => uint8) public honeyJarToParty; // Reverse mapping for honeyJar to bundle (needed for UI)
    mapping(uint8 => uint256[]) public honeyJarShelf; // List of Honeyjars associated with a particular bundle (SlumberParty)

    constructor(
        address _vrfCoordinator,
        address _gameRegistry,
        address _honeyJarAddress,
        address _paymentToken,
        address _gatekeeper,
        address _jani,
        address _beekeeper,
        uint256 _honeyJarShare
    ) VRFConsumerBaseV2(_vrfCoordinator) GameRegistryConsumer(_gameRegistry) {
        vrfCoordinator = VRFCoordinatorV2Interface(_vrfCoordinator);
        honeyJar = IHoneyJar(_honeyJarAddress);
        paymentToken = IERC20(_paymentToken);
        gatekeeper = IGatekeeper(_gatekeeper);
        jani = payable(_jani);
        beekeeper = payable(_beekeeper);
        honeyJarShare = _honeyJarShare;
    }

    /// @notice additional parameters that are required to get the game running
    /// @param vrfConfig_ Chainlink  configuration
    /// @param mintConfig_ needed for the specific game
    function initialize(VRFConfig calldata vrfConfig_, MintConfig calldata mintConfig_)
        external
        onlyRole(Constants.GAME_ADMIN)
    {
        if (initialized) revert AlreadyInitialized();

        initialized = true;
        vrfConfig = vrfConfig_;
        mintConfig = mintConfig_;

        emit Initialized(mintConfig);
    }

    /// @notice Who is partying without me?
    function getSlumberParty(uint8 _bundleId) external view returns (SlumberParty memory) {
        return slumberParties[_bundleId];
    }

    /// @notice Once a bundle is configured, transfers the configured assets into this contract.
    /// @notice Starts the gates within the Gatekeeper, which determine who is allowed early access and free claims
    /// @dev Bundles need to be preconfigured using addBundle from gameAdmin
    /// @dev publicMintTime is hardcoded to be 72 hours after calling this method.
    function puffPuffPassOut(uint8 bundleId_) external onlyRole(Constants.GAME_ADMIN) {
        SlumberParty storage slumberParty = slumberParties[bundleId_]; // Will throw index out of bounds if not valid bundleId_
        SleepingNFT[] storage sleepoors = slumberParty.sleepoors;
        uint256 sleeperCount = sleepoors.length;
        if (sleeperCount == 0) revert InvalidBundle(bundleId_);

        SleepingNFT storage sleepoor;

        uint256[] memory allStages = _getStages();
        uint256 publicMintOffset = allStages[allStages.length - 1];

        slumberParties[bundleId_].publicMintTime = block.timestamp + publicMintOffset;
        gatekeeper.startGatesForBundle(bundleId_);

        for (uint256 i = 0; i < sleeperCount; ++i) {
            sleepoor = sleepoors[i];

            if (sleepoor.isERC1155) {
                // ERC1155
                IERC1155(sleepoor.tokenAddress).safeTransferFrom(msg.sender, address(this), sleepoor.tokenId, 1, "");
            } else {
                //  ERC721
                IERC721(sleepoor.tokenAddress).safeTransferFrom(msg.sender, address(this), sleepoor.tokenId);
            }
        }
        emit SlumberPartyStarted(bundleId_);
    }

    /// @notice method stores the configuration for the sleeping NFTs
    // bundleId --> bundle --> []nfts
    function addBundle(address[] calldata tokenAddresses_, uint256[] calldata tokenIds_, bool[] calldata isERC1155_)
        external
        onlyRole(Constants.GAME_ADMIN)
        returns (uint8)
    {
        uint256 inputLength = tokenAddresses_.length;
        if (inputLength == 0 || inputLength != tokenIds_.length || inputLength != isERC1155_.length) {
            revert InvalidInput("addBundle");
        }

        if (slumberPartyList.length > 255) revert TooManyBundles();
        uint8 bundleId = uint8(slumberPartyList.length); // Will fail if we have >255 bundles

        // Add to the bundle mapping & list
        SlumberParty storage slumberParty = slumberPartyList.push(); // 0 initialized Bundle
        slumberParty.bundleId = bundleId;

        // Synthesize sleeper configs from input
        for (uint256 i = 0; i < inputLength; ++i) {
            slumberParty.sleepoors.push(SleepingNFT(tokenAddresses_[i], tokenIds_[i], isERC1155_[i]));
        }

        slumberParties[bundleId] = slumberParty;

        emit SlumberPartyAdded(bundleId);
        return bundleId;
    }

    /// @dev internal helper function to perform conditional checks for minting state
    function _canMintHoneyJar(uint8 bundleId_, uint256 amount_) internal view {
        if (!initialized) revert NotInitialized();
        SlumberParty storage party = slumberParties[bundleId_];

        if (party.bundleId != bundleId_) revert InvalidBundle(bundleId_);
        if (party.publicMintTime == 0) revert NotSleeping(bundleId_);
        if (party.isAwake) revert PartyAlreadyWoke(bundleId_);
        if (honeyJarShelf[bundleId_].length > mintConfig.maxHoneyJar) revert AlreadyTooManyHoneyJars(bundleId_);
        if (honeyJarShelf[bundleId_].length + amount_ > mintConfig.maxHoneyJar) {
            revert MekingTooManyHoneyJars(bundleId_);
        }
        if (amount_ == 0) revert ZeroMint();
    }

    /// @notice Allows players to mint honeyJar with a valid proof
    /// @param proofAmount the amount of free claims you are entitled to in the claim
    /// @param proof The proof from the gate that allows the player to mint
    /// @param mintAmount actual amount of honeyJars you want to mint.
    function earlyMekHoneyJarWithERC20(
        uint8 bundleId,
        uint32 gateId,
        uint32 proofAmount,
        bytes32[] calldata proof,
        uint256 mintAmount
    ) external returns (uint256) {
        _canMintHoneyJar(bundleId, mintAmount);
        // validateProof checks that gates are open
        bool validProof = gatekeeper.validateProof(bundleId, gateId, msg.sender, proofAmount, proof);
        if (!validProof) revert Claim_InvalidProof();
        return _distributeERC20AndMintHoneyJar(bundleId, mintAmount);
    }

    /// @notice Allows players to mint honeyJar with a valid proof (Taking ETH as payment)
    /// @param proofAmount the amount of free claims you are entitled to in the claim
    /// @param proof The proof from the gate that allows the player to mint
    /// @param mintAmount actual amount of honeyJars you want to mint.
    function earlyMekHoneyJarWithEth(
        uint8 bundleId,
        uint32 gateId,
        uint32 proofAmount,
        bytes32[] calldata proof,
        uint256 mintAmount
    ) external payable returns (uint256) {
        _canMintHoneyJar(bundleId, mintAmount);
        // validateProof checks that gates are open
        bool validProof = gatekeeper.validateProof(bundleId, gateId, msg.sender, proofAmount, proof); // This shit needs to be bulletproof
        if (!validProof) revert Claim_InvalidProof();
        return _distributeETHAndMintHoneyJar(bundleId, mintAmount);
    }

    function mekHoneyJarWithERC20(uint8 bundleId_, uint256 amount_) external returns (uint256) {
        _canMintHoneyJar(bundleId_, amount_);
        if (slumberParties[bundleId_].publicMintTime > block.timestamp) revert GeneralMintNotOpen(bundleId_);
        return _distributeERC20AndMintHoneyJar(bundleId_, amount_);
    }

    function mekHoneyJarWithETH(uint8 bundleId_, uint256 amount_) external payable returns (uint256) {
        _canMintHoneyJar(bundleId_, amount_);
        if (slumberParties[bundleId_].publicMintTime > block.timestamp) revert GeneralMintNotOpen(bundleId_);

        return _distributeETHAndMintHoneyJar(bundleId_, amount_);
    }

    /// @dev internal helper function to collect payment and mint honeyJar
    /// @return tokenID of minted honeyJar
    function _distributeERC20AndMintHoneyJar(uint8 bundleId_, uint256 amount_) internal returns (uint256) {
        uint256 price = mintConfig.honeyJarPrice_ERC20;
        _distribute(price * amount_);

        // Mint da honey
        return _mintHoneyJarForBear(msg.sender, bundleId_, amount_);
    }

    /// @dev internal helper function to collect payment and mint honeyJar
    /// @return tokenID of minted honeyJar
    function _distributeETHAndMintHoneyJar(uint8 bundleId_, uint256 amount_) internal returns (uint256) {
        uint256 price = mintConfig.honeyJarPrice_ETH;
        if (msg.value != price * amount_) revert WrongAmount_ETH(price * amount_, msg.value);

        _distribute(0);

        return _mintHoneyJarForBear(msg.sender, bundleId_, amount_);
    }

    /// @notice internal method to mint for a particular user
    /// @param to user to mint to
    /// @param bundleId_ the bea being minted for
    function _mintHoneyJarForBear(address to, uint8 bundleId_, uint256 amount_) internal returns (uint256) {
        uint256 tokenId = honeyJar.nextTokenId();
        honeyJar.batchMint(to, amount_);

        // Have a unique tokenId for a given bundleId
        for (uint256 i = 0; i < amount_; ++i) {
            honeyJarShelf[bundleId_].push(tokenId);
            honeyJarToParty[tokenId] = bundleId_;
            ++tokenId;
        }

        // Find the special honeyJar when the last honeyJar is minted.
        if (honeyJarShelf[bundleId_].length >= mintConfig.maxHoneyJar) {
            _findHoneyJar(bundleId_);
        }

        return tokenId - 1; // returns the lastID created
    }

    /// @notice Forcing function to find a bear.
    /// @notice Should only be called when the last honeyJars is minted.
    function _findHoneyJar(uint8 bundleId_) internal {
        uint256 requestId = vrfCoordinator.requestRandomWords(
            vrfConfig.keyHash, vrfConfig.subId, vrfConfig.minConfirmations, vrfConfig.callbackGasLimit, 2
        );
        rng[requestId] = bundleId_;
    }

    /// @notice the callback method that is called when VRF completes
    /// @param requestId requestId that is generated when initially calling VRF
    /// @param randomness an array of random numbers based on `numWords` config
    function fulfillRandomWords(uint256 requestId, uint256[] memory randomness) internal override {
        /// use requestID to get bundleId
        uint8 bundleId = rng[requestId];
        _setSpecialHoneyJar(bundleId, randomness[0]);
    }

    /// @notice helper function to set a random honeyJar as a winner
    /// @param bundleId self-explanatory
    /// @param randomNumber used to determine the index of the winning number
    function _setSpecialHoneyJar(uint8 bundleId, uint256 randomNumber) internal {
        uint256 numHoneyJars = honeyJarShelf[bundleId].length;
        uint256 specialHoneyIndex = randomNumber % numHoneyJars;
        uint256 specialHoneyJarId = honeyJarShelf[bundleId][specialHoneyIndex];

        SlumberParty storage party = slumberParties[bundleId];
        party.specialHoneyJarFound = true;
        party.specialHoneyJar = specialHoneyJarId;

        emit SpecialHoneyJarFound(bundleId, specialHoneyJarId);
    }

    /// @notice transfers sleeping NFTs to msg.sender if they hold the special honeyJar
    function openHotBox(uint8 bundleId_) external {
        // Check that msg.sender has the special honeyJar
        SlumberParty memory party = slumberParties[bundleId_];

        if (honeyJarShelf[bundleId_].length < mintConfig.maxHoneyJar) revert NotEnoughHoneyJarMinted(bundleId_);
        if (party.isAwake) revert PartyAlreadyWoke(bundleId_);
        if (!party.specialHoneyJarFound) revert SpecialHoneyJarNotFound(bundleId_);

        if (honeyJar.ownerOf(party.specialHoneyJar) != msg.sender) {
            revert NotOwnerOfSpecialHoneyJar(bundleId_, party.specialHoneyJar);
        }

        slumberParties[bundleId_].isAwake = true;

        SleepingNFT[] memory sleepoors = party.sleepoors;
        uint256 sleeperCount = sleepoors.length;

        SleepingNFT memory sleepoor;
        for (uint256 i = 0; i < sleeperCount; ++i) {
            sleepoor = sleepoors[i];

            if (sleepoor.isERC1155) {
                // ERC1155
                IERC1155(sleepoor.tokenAddress).safeTransferFrom(address(this), msg.sender, sleepoor.tokenId, 1, "");
            } else {
                //  ERC721
                IERC721(sleepoor.tokenAddress).safeTransferFrom(address(this), msg.sender, sleepoor.tokenId);
            }
        }

        emit PartyAwoke(bundleId_, msg.sender);
    }

    /**
     * BearPouch owner methods
     *      Can move into another contract for portability
     * depends on:
     *     Exclusive: beekeeper, jani, honeyJarShare
     *     shared: paymentToken
     */

    /// @dev requires that beekeeper and jani addresses are set.
    /// @param amountERC20 is zero if we're only distributing the ETH
    function _distribute(uint256 amountERC20) internal {
        uint256 beekeeperShareERC20 = amountERC20.mulWadUp(honeyJarShare);
        uint256 beekeeperShareETH = (msg.value).mulWadUp(honeyJarShare);

        if (beekeeperShareERC20 != 0) {
            paymentToken.safeTransferFrom(msg.sender, beekeeper, beekeeperShareERC20);
            paymentToken.safeTransferFrom(msg.sender, jani, amountERC20 - beekeeperShareERC20);
        }

        if (beekeeperShareETH != 0) {
            SafeTransferLib.safeTransferETH(beekeeper, beekeeperShareETH);
            SafeTransferLib.safeTransferETH(jani, msg.value - beekeeperShareETH);
        }
    }

    /**
     * Gatekeeper: for claiming free honeyJar
     * BearCave:
     *    - maxMintableHoneyJar per bundle
     *    - claimedHoneyJar per bundle // free
     *    - maxClaimableHoneyJar per bundle
     * Gatekeeper: (per bear)
     * Gates:
     *    - maxhoneyJarAvailable per gate
     *    - maxClaimable per gate
     *
     */

    /// @notice Allows a player to claim free HoneyJar based on elegibility (FCFS)
    /// @dev free claims are determined by the gatekeeper and the accounting is done in this method
    /// @param gateId id of gate from Gatekeeper.
    /// @param amount amount player is claiming
    /// @param proof valid proof that entitles msg.sender to amount.
    function claim(uint8 bundleId_, uint32 gateId, uint32 amount, bytes32[] calldata proof) public nonReentrant {
        // Gatekeeper tracks per-player/per-gate claims
        if (proof.length == 0) revert Claim_InvalidProof();
        uint32 numClaim = gatekeeper.calculateClaimable(bundleId_, gateId, msg.sender, amount, proof);
        if (numClaim == 0) {
            return;
        }

        // Track per bear freeClaims
        uint32 claimedAmount = claimed[bundleId_];
        if (numClaim + claimedAmount > mintConfig.maxClaimableHoneyJar) {
            numClaim = mintConfig.maxClaimableHoneyJar - claimedAmount;
        }
        // Check if the HoneyJars can be minted
        _canMintHoneyJar(bundleId_, numClaim); // Validating here because numClaims can change

        // Update the amount minted.
        claimed[bundleId_] += numClaim;

        // Can be combined with "claim" call above, but keeping separate to separate view + modification on gatekeeper
        gatekeeper.addClaimed(bundleId_, gateId, numClaim, proof);

        // If for some reason this fails, GG no honeyJar for you
        _mintHoneyJarForBear(msg.sender, bundleId_, numClaim);

        emit HoneyJarClaimed(bundleId_, gateId, msg.sender, numClaim);
    }

    /// @dev Helper function to process all free cams. More client-sided computation.
    /// @param bundleId_ the bundle to claim tokens for.
    /// @param gateIds the list of gates to claim. The txn will revert if an ID for an inactive gate is included.
    /// @param amounts the list of amounts being claimed for the repsective gates.
    /// @param proofs the list of proofs associated with the respective gates
    function claimAll(
        uint8 bundleId_,
        uint32[] calldata gateIds,
        uint32[] calldata amounts,
        bytes32[][] calldata proofs
    ) external {
        uint256 inputLength = proofs.length;
        if (inputLength != gateIds.length) revert InvalidInput("claimAll");
        if (inputLength != amounts.length) revert InvalidInput("claimAll");

        for (uint256 i = 0; i < inputLength; ++i) {
            claim(bundleId_, gateIds[i], amounts[i], proofs[i]);
        }
    }

    //=============== SETTERS ================//

    /**
     * Game setters
     *  These should not be called while a game is in progress to prevent hostage holding.
     */

    /// @notice Sets the max number NFTs (honeyJar) that can be generated from the deposit of a bear (asset)
    function setMaxHoneyJar(uint32 _maxhoneyJar) external onlyRole(Constants.GAME_ADMIN) {
        if (_isEnabled(address(this))) revert GameInProgress();
        mintConfig.maxHoneyJar = _maxhoneyJar;

        emit MintConfigChanged(mintConfig);
    }

    /// @notice sets the number of global free claims available
    function setMaxClaimableHoneyJar(uint32 _maxClaimableHoneyJar) external onlyRole(Constants.GAME_ADMIN) {
        if (_isEnabled(address(this))) revert GameInProgress();
        mintConfig.maxClaimableHoneyJar = _maxClaimableHoneyJar;

        emit MintConfigChanged(mintConfig);
    }

    /// @notice sets the price of the honeyJar in `paymentToken`
    function setHoneyJarPrice_ERC20(uint256 _honeyJarPrice) external onlyRole(Constants.GAME_ADMIN) {
        if (_isEnabled(address(this))) revert GameInProgress();
        mintConfig.honeyJarPrice_ERC20 = _honeyJarPrice;

        emit MintConfigChanged(mintConfig);
    }

    /// @notice sets the price of the honeyJar in `ETH`
    function setHoneyJarPrice_ETH(uint256 _honeyJarPrice) external onlyRole(Constants.GAME_ADMIN) {
        if (_isEnabled(address(this))) revert GameInProgress();
        mintConfig.honeyJarPrice_ETH = _honeyJarPrice;

        emit MintConfigChanged(mintConfig);
    }

    /**
     * Chainlink Setters
     */

    /// @notice Set from the following docs: https://docs.chain.link/docs/vrf-contracts/#configurations
    function setVRFConfig(VRFConfig calldata vrfConfig_) external onlyRole(Constants.GAME_ADMIN) {
        vrfConfig = vrfConfig_;
        emit VRFConfigChanged(vrfConfig_);
    }
}

File 2 of 27 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)

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`.
     *
     * 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;

    /**
     * @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 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * 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 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 the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

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

File 3 of 27 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

File 4 of 27 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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);

    /**
     * @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 `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, 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 `from` to `to` 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 from,
        address to,
        uint256 amount
    ) external returns (bool);
}

File 5 of 27 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";

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

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

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

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

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

File 6 of 27 : ERC1155.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Minimalist and gas efficient standard ERC1155 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC1155.sol)
abstract contract ERC1155 {
    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event TransferSingle(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256 id,
        uint256 amount
    );

    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] amounts
    );

    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    event URI(string value, uint256 indexed id);

    /*//////////////////////////////////////////////////////////////
                             ERC1155 STORAGE
    //////////////////////////////////////////////////////////////*/

    mapping(address => mapping(uint256 => uint256)) public balanceOf;

    mapping(address => mapping(address => bool)) public isApprovedForAll;

    /*//////////////////////////////////////////////////////////////
                             METADATA LOGIC
    //////////////////////////////////////////////////////////////*/

    function uri(uint256 id) public view virtual returns (string memory);

    /*//////////////////////////////////////////////////////////////
                              ERC1155 LOGIC
    //////////////////////////////////////////////////////////////*/

    function setApprovalForAll(address operator, bool approved) public virtual {
        isApprovedForAll[msg.sender][operator] = approved;

        emit ApprovalForAll(msg.sender, operator, approved);
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) public virtual {
        require(msg.sender == from || isApprovedForAll[from][msg.sender], "NOT_AUTHORIZED");

        balanceOf[from][id] -= amount;
        balanceOf[to][id] += amount;

        emit TransferSingle(msg.sender, from, to, id, amount);

        require(
            to.code.length == 0
                ? to != address(0)
                : ERC1155TokenReceiver(to).onERC1155Received(msg.sender, from, id, amount, data) ==
                    ERC1155TokenReceiver.onERC1155Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) public virtual {
        require(ids.length == amounts.length, "LENGTH_MISMATCH");

        require(msg.sender == from || isApprovedForAll[from][msg.sender], "NOT_AUTHORIZED");

        // Storing these outside the loop saves ~15 gas per iteration.
        uint256 id;
        uint256 amount;

        for (uint256 i = 0; i < ids.length; ) {
            id = ids[i];
            amount = amounts[i];

            balanceOf[from][id] -= amount;
            balanceOf[to][id] += amount;

            // An array can't have a total length
            // larger than the max uint256 value.
            unchecked {
                ++i;
            }
        }

        emit TransferBatch(msg.sender, from, to, ids, amounts);

        require(
            to.code.length == 0
                ? to != address(0)
                : ERC1155TokenReceiver(to).onERC1155BatchReceived(msg.sender, from, ids, amounts, data) ==
                    ERC1155TokenReceiver.onERC1155BatchReceived.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function balanceOfBatch(address[] calldata owners, uint256[] calldata ids)
        public
        view
        virtual
        returns (uint256[] memory balances)
    {
        require(owners.length == ids.length, "LENGTH_MISMATCH");

        balances = new uint256[](owners.length);

        // Unchecked because the only math done is incrementing
        // the array index counter which cannot possibly overflow.
        unchecked {
            for (uint256 i = 0; i < owners.length; ++i) {
                balances[i] = balanceOf[owners[i]][ids[i]];
            }
        }
    }

    /*//////////////////////////////////////////////////////////////
                              ERC165 LOGIC
    //////////////////////////////////////////////////////////////*/

    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return
            interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
            interfaceId == 0xd9b67a26 || // ERC165 Interface ID for ERC1155
            interfaceId == 0x0e89341c; // ERC165 Interface ID for ERC1155MetadataURI
    }

    /*//////////////////////////////////////////////////////////////
                        INTERNAL MINT/BURN LOGIC
    //////////////////////////////////////////////////////////////*/

    function _mint(
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        balanceOf[to][id] += amount;

        emit TransferSingle(msg.sender, address(0), to, id, amount);

        require(
            to.code.length == 0
                ? to != address(0)
                : ERC1155TokenReceiver(to).onERC1155Received(msg.sender, address(0), id, amount, data) ==
                    ERC1155TokenReceiver.onERC1155Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function _batchMint(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        uint256 idsLength = ids.length; // Saves MLOADs.

        require(idsLength == amounts.length, "LENGTH_MISMATCH");

        for (uint256 i = 0; i < idsLength; ) {
            balanceOf[to][ids[i]] += amounts[i];

            // An array can't have a total length
            // larger than the max uint256 value.
            unchecked {
                ++i;
            }
        }

        emit TransferBatch(msg.sender, address(0), to, ids, amounts);

        require(
            to.code.length == 0
                ? to != address(0)
                : ERC1155TokenReceiver(to).onERC1155BatchReceived(msg.sender, address(0), ids, amounts, data) ==
                    ERC1155TokenReceiver.onERC1155BatchReceived.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function _batchBurn(
        address from,
        uint256[] memory ids,
        uint256[] memory amounts
    ) internal virtual {
        uint256 idsLength = ids.length; // Saves MLOADs.

        require(idsLength == amounts.length, "LENGTH_MISMATCH");

        for (uint256 i = 0; i < idsLength; ) {
            balanceOf[from][ids[i]] -= amounts[i];

            // An array can't have a total length
            // larger than the max uint256 value.
            unchecked {
                ++i;
            }
        }

        emit TransferBatch(msg.sender, from, address(0), ids, amounts);
    }

    function _burn(
        address from,
        uint256 id,
        uint256 amount
    ) internal virtual {
        balanceOf[from][id] -= amount;

        emit TransferSingle(msg.sender, from, address(0), id, amount);
    }
}

/// @notice A generic interface for a contract which properly accepts ERC1155 tokens.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC1155.sol)
abstract contract ERC1155TokenReceiver {
    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes calldata
    ) external virtual returns (bytes4) {
        return ERC1155TokenReceiver.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] calldata,
        uint256[] calldata,
        bytes calldata
    ) external virtual returns (bytes4) {
        return ERC1155TokenReceiver.onERC1155BatchReceived.selector;
    }
}

File 7 of 27 : ERC721.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Modern, minimalist, and gas efficient ERC-721 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol)
abstract contract ERC721 {
    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event Transfer(address indexed from, address indexed to, uint256 indexed id);

    event Approval(address indexed owner, address indexed spender, uint256 indexed id);

    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /*//////////////////////////////////////////////////////////////
                         METADATA STORAGE/LOGIC
    //////////////////////////////////////////////////////////////*/

    string public name;

    string public symbol;

    function tokenURI(uint256 id) public view virtual returns (string memory);

    /*//////////////////////////////////////////////////////////////
                      ERC721 BALANCE/OWNER STORAGE
    //////////////////////////////////////////////////////////////*/

    mapping(uint256 => address) internal _ownerOf;

    mapping(address => uint256) internal _balanceOf;

    function ownerOf(uint256 id) public view virtual returns (address owner) {
        require((owner = _ownerOf[id]) != address(0), "NOT_MINTED");
    }

    function balanceOf(address owner) public view virtual returns (uint256) {
        require(owner != address(0), "ZERO_ADDRESS");

        return _balanceOf[owner];
    }

    /*//////////////////////////////////////////////////////////////
                         ERC721 APPROVAL STORAGE
    //////////////////////////////////////////////////////////////*/

    mapping(uint256 => address) public getApproved;

    mapping(address => mapping(address => bool)) public isApprovedForAll;

    /*//////////////////////////////////////////////////////////////
                               CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    constructor(string memory _name, string memory _symbol) {
        name = _name;
        symbol = _symbol;
    }

    /*//////////////////////////////////////////////////////////////
                              ERC721 LOGIC
    //////////////////////////////////////////////////////////////*/

    function approve(address spender, uint256 id) public virtual {
        address owner = _ownerOf[id];

        require(msg.sender == owner || isApprovedForAll[owner][msg.sender], "NOT_AUTHORIZED");

        getApproved[id] = spender;

        emit Approval(owner, spender, id);
    }

    function setApprovalForAll(address operator, bool approved) public virtual {
        isApprovedForAll[msg.sender][operator] = approved;

        emit ApprovalForAll(msg.sender, operator, approved);
    }

    function transferFrom(
        address from,
        address to,
        uint256 id
    ) public virtual {
        require(from == _ownerOf[id], "WRONG_FROM");

        require(to != address(0), "INVALID_RECIPIENT");

        require(
            msg.sender == from || isApprovedForAll[from][msg.sender] || msg.sender == getApproved[id],
            "NOT_AUTHORIZED"
        );

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        unchecked {
            _balanceOf[from]--;

            _balanceOf[to]++;
        }

        _ownerOf[id] = to;

        delete getApproved[id];

        emit Transfer(from, to, id);
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 id
    ) public virtual {
        transferFrom(from, to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        bytes calldata data
    ) public virtual {
        transferFrom(from, to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    /*//////////////////////////////////////////////////////////////
                              ERC165 LOGIC
    //////////////////////////////////////////////////////////////*/

    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return
            interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
            interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
            interfaceId == 0x5b5e139f; // ERC165 Interface ID for ERC721Metadata
    }

    /*//////////////////////////////////////////////////////////////
                        INTERNAL MINT/BURN LOGIC
    //////////////////////////////////////////////////////////////*/

    function _mint(address to, uint256 id) internal virtual {
        require(to != address(0), "INVALID_RECIPIENT");

        require(_ownerOf[id] == address(0), "ALREADY_MINTED");

        // Counter overflow is incredibly unrealistic.
        unchecked {
            _balanceOf[to]++;
        }

        _ownerOf[id] = to;

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

    function _burn(uint256 id) internal virtual {
        address owner = _ownerOf[id];

        require(owner != address(0), "NOT_MINTED");

        // Ownership check above ensures no underflow.
        unchecked {
            _balanceOf[owner]--;
        }

        delete _ownerOf[id];

        delete getApproved[id];

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

    /*//////////////////////////////////////////////////////////////
                        INTERNAL SAFE MINT LOGIC
    //////////////////////////////////////////////////////////////*/

    function _safeMint(address to, uint256 id) internal virtual {
        _mint(to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, "") ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function _safeMint(
        address to,
        uint256 id,
        bytes memory data
    ) internal virtual {
        _mint(to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, data) ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }
}

/// @notice A generic interface for a contract which properly accepts ERC721 tokens.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol)
abstract contract ERC721TokenReceiver {
    function onERC721Received(
        address,
        address,
        uint256,
        bytes calldata
    ) external virtual returns (bytes4) {
        return ERC721TokenReceiver.onERC721Received.selector;
    }
}

File 8 of 27 : SafeTransferLib.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

import {ERC20} from "../tokens/ERC20.sol";

/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)
/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.
/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.
library SafeTransferLib {
    /*//////////////////////////////////////////////////////////////
                             ETH OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function safeTransferETH(address to, uint256 amount) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Transfer the ETH and store if it succeeded or not.
            success := call(gas(), to, amount, 0, 0, 0, 0)
        }

        require(success, "ETH_TRANSFER_FAILED");
    }

    /*//////////////////////////////////////////////////////////////
                            ERC20 OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function safeTransferFrom(
        ERC20 token,
        address from,
        address to,
        uint256 amount
    ) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata into memory, beginning with the function selector.
            mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
            mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument.
            mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument.
            mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument.

            success := and(
                // Set success to whether the call reverted, if not we check it either
                // returned exactly 1 (can't just be non-zero data), or had no return data.
                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
                // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.
                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                // Counterintuitively, this call must be positioned second to the or() call in the
                // surrounding and() call or else returndatasize() will be zero during the computation.
                call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)
            )
        }

        require(success, "TRANSFER_FROM_FAILED");
    }

    function safeTransfer(
        ERC20 token,
        address to,
        uint256 amount
    ) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata into memory, beginning with the function selector.
            mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
            mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
            mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.

            success := and(
                // Set success to whether the call reverted, if not we check it either
                // returned exactly 1 (can't just be non-zero data), or had no return data.
                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
                // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                // Counterintuitively, this call must be positioned second to the or() call in the
                // surrounding and() call or else returndatasize() will be zero during the computation.
                call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
            )
        }

        require(success, "TRANSFER_FAILED");
    }

    function safeApprove(
        ERC20 token,
        address to,
        uint256 amount
    ) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata into memory, beginning with the function selector.
            mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)
            mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
            mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.

            success := and(
                // Set success to whether the call reverted, if not we check it either
                // returned exactly 1 (can't just be non-zero data), or had no return data.
                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
                // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                // Counterintuitively, this call must be positioned second to the or() call in the
                // surrounding and() call or else returndatasize() will be zero during the computation.
                call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
            )
        }

        require(success, "APPROVE_FAILED");
    }
}

File 9 of 27 : FixedPointMathLib.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Arithmetic library with operations for fixed-point numbers.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)
/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)
library FixedPointMathLib {
    /*//////////////////////////////////////////////////////////////
                    SIMPLIFIED FIXED POINT OPERATIONS
    //////////////////////////////////////////////////////////////*/

    uint256 internal constant MAX_UINT256 = 2**256 - 1;

    uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.

    function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.
    }

    function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.
    }

    function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.
    }

    function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.
    }

    /*//////////////////////////////////////////////////////////////
                    LOW LEVEL FIXED POINT OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function mulDivDown(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))
            if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {
                revert(0, 0)
            }

            // Divide x * y by the denominator.
            z := div(mul(x, y), denominator)
        }
    }

    function mulDivUp(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))
            if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {
                revert(0, 0)
            }

            // If x * y modulo the denominator is strictly greater than 0,
            // 1 is added to round up the division of x * y by the denominator.
            z := add(gt(mod(mul(x, y), denominator), 0), div(mul(x, y), denominator))
        }
    }

    function rpow(
        uint256 x,
        uint256 n,
        uint256 scalar
    ) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            switch x
            case 0 {
                switch n
                case 0 {
                    // 0 ** 0 = 1
                    z := scalar
                }
                default {
                    // 0 ** n = 0
                    z := 0
                }
            }
            default {
                switch mod(n, 2)
                case 0 {
                    // If n is even, store scalar in z for now.
                    z := scalar
                }
                default {
                    // If n is odd, store x in z for now.
                    z := x
                }

                // Shifting right by 1 is like dividing by 2.
                let half := shr(1, scalar)

                for {
                    // Shift n right by 1 before looping to halve it.
                    n := shr(1, n)
                } n {
                    // Shift n right by 1 each iteration to halve it.
                    n := shr(1, n)
                } {
                    // Revert immediately if x ** 2 would overflow.
                    // Equivalent to iszero(eq(div(xx, x), x)) here.
                    if shr(128, x) {
                        revert(0, 0)
                    }

                    // Store x squared.
                    let xx := mul(x, x)

                    // Round to the nearest number.
                    let xxRound := add(xx, half)

                    // Revert if xx + half overflowed.
                    if lt(xxRound, xx) {
                        revert(0, 0)
                    }

                    // Set x to scaled xxRound.
                    x := div(xxRound, scalar)

                    // If n is even:
                    if mod(n, 2) {
                        // Compute z * x.
                        let zx := mul(z, x)

                        // If z * x overflowed:
                        if iszero(eq(div(zx, x), z)) {
                            // Revert if x is non-zero.
                            if iszero(iszero(x)) {
                                revert(0, 0)
                            }
                        }

                        // Round to the nearest number.
                        let zxRound := add(zx, half)

                        // Revert if zx + half overflowed.
                        if lt(zxRound, zx) {
                            revert(0, 0)
                        }

                        // Return properly scaled zxRound.
                        z := div(zxRound, scalar)
                    }
                }
            }
        }
    }

    /*//////////////////////////////////////////////////////////////
                        GENERAL NUMBER UTILITIES
    //////////////////////////////////////////////////////////////*/

    function sqrt(uint256 x) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            let y := x // We start y at x, which will help us make our initial estimate.

            z := 181 // The "correct" value is 1, but this saves a multiplication later.

            // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
            // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.

            // We check y >= 2^(k + 8) but shift right by k bits
            // each branch to ensure that if x >= 256, then y >= 256.
            if iszero(lt(y, 0x10000000000000000000000000000000000)) {
                y := shr(128, y)
                z := shl(64, z)
            }
            if iszero(lt(y, 0x1000000000000000000)) {
                y := shr(64, y)
                z := shl(32, z)
            }
            if iszero(lt(y, 0x10000000000)) {
                y := shr(32, y)
                z := shl(16, z)
            }
            if iszero(lt(y, 0x1000000)) {
                y := shr(16, y)
                z := shl(8, z)
            }

            // Goal was to get z*z*y within a small factor of x. More iterations could
            // get y in a tighter range. Currently, we will have y in [256, 256*2^16).
            // We ensured y >= 256 so that the relative difference between y and y+1 is small.
            // That's not possible if x < 256 but we can just verify those cases exhaustively.

            // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.
            // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.
            // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.

            // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range
            // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.

            // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate
            // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.

            // There is no overflow risk here since y < 2^136 after the first branch above.
            z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.

            // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))

            // If x+1 is a perfect square, the Babylonian method cycles between
            // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.
            // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
            // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.
            // If you don't care whether the floor or ceil square root is returned, you can remove this statement.
            z := sub(z, lt(div(x, z), z))
        }
    }

    function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Mod x by y. Note this will return
            // 0 instead of reverting if y is zero.
            z := mod(x, y)
        }
    }

    function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 r) {
        /// @solidity memory-safe-assembly
        assembly {
            // Divide x by y. Note this will return
            // 0 instead of reverting if y is zero.
            r := div(x, y)
        }
    }

    function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Add 1 to x * y if x % y > 0. Note this will
            // return 0 instead of reverting if y is zero.
            z := add(gt(mod(x, y), 0), div(x, y))
        }
    }
}

File 10 of 27 : ReentrancyGuard.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Gas optimized reentrancy protection for smart contracts.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/ReentrancyGuard.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/ReentrancyGuard.sol)
abstract contract ReentrancyGuard {
    uint256 private locked = 1;

    modifier nonReentrant() virtual {
        require(locked == 1, "REENTRANCY");

        locked = 2;

        _;

        locked = 1;
    }
}

File 11 of 27 : VRFCoordinatorV2Interface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface VRFCoordinatorV2Interface {
  /**
   * @notice Get configuration relevant for making requests
   * @return minimumRequestConfirmations global min for request confirmations
   * @return maxGasLimit global max for request gas limit
   * @return s_provingKeyHashes list of registered key hashes
   */
  function getRequestConfig()
    external
    view
    returns (
      uint16,
      uint32,
      bytes32[] memory
    );

  /**
   * @notice Request a set of random words.
   * @param keyHash - Corresponds to a particular oracle job which uses
   * that key for generating the VRF proof. Different keyHash's have different gas price
   * ceilings, so you can select a specific one to bound your maximum per request cost.
   * @param subId  - The ID of the VRF subscription. Must be funded
   * with the minimum subscription balance required for the selected keyHash.
   * @param minimumRequestConfirmations - How many blocks you'd like the
   * oracle to wait before responding to the request. See SECURITY CONSIDERATIONS
   * for why you may want to request more. The acceptable range is
   * [minimumRequestBlockConfirmations, 200].
   * @param callbackGasLimit - How much gas you'd like to receive in your
   * fulfillRandomWords callback. Note that gasleft() inside fulfillRandomWords
   * may be slightly less than this amount because of gas used calling the function
   * (argument decoding etc.), so you may need to request slightly more than you expect
   * to have inside fulfillRandomWords. The acceptable range is
   * [0, maxGasLimit]
   * @param numWords - The number of uint256 random values you'd like to receive
   * in your fulfillRandomWords callback. Note these numbers are expanded in a
   * secure way by the VRFCoordinator from a single random value supplied by the oracle.
   * @return requestId - A unique identifier of the request. Can be used to match
   * a request to a response in fulfillRandomWords.
   */
  function requestRandomWords(
    bytes32 keyHash,
    uint64 subId,
    uint16 minimumRequestConfirmations,
    uint32 callbackGasLimit,
    uint32 numWords
  ) external returns (uint256 requestId);

  /**
   * @notice Create a VRF subscription.
   * @return subId - A unique subscription id.
   * @dev You can manage the consumer set dynamically with addConsumer/removeConsumer.
   * @dev Note to fund the subscription, use transferAndCall. For example
   * @dev  LINKTOKEN.transferAndCall(
   * @dev    address(COORDINATOR),
   * @dev    amount,
   * @dev    abi.encode(subId));
   */
  function createSubscription() external returns (uint64 subId);

  /**
   * @notice Get a VRF subscription.
   * @param subId - ID of the subscription
   * @return balance - LINK balance of the subscription in juels.
   * @return reqCount - number of requests for this subscription, determines fee tier.
   * @return owner - owner of the subscription.
   * @return consumers - list of consumer address which are able to use this subscription.
   */
  function getSubscription(uint64 subId)
    external
    view
    returns (
      uint96 balance,
      uint64 reqCount,
      address owner,
      address[] memory consumers
    );

  /**
   * @notice Request subscription owner transfer.
   * @param subId - ID of the subscription
   * @param newOwner - proposed new owner of the subscription
   */
  function requestSubscriptionOwnerTransfer(uint64 subId, address newOwner) external;

  /**
   * @notice Request subscription owner transfer.
   * @param subId - ID of the subscription
   * @dev will revert if original owner of subId has
   * not requested that msg.sender become the new owner.
   */
  function acceptSubscriptionOwnerTransfer(uint64 subId) external;

  /**
   * @notice Add a consumer to a VRF subscription.
   * @param subId - ID of the subscription
   * @param consumer - New consumer which can use the subscription
   */
  function addConsumer(uint64 subId, address consumer) external;

  /**
   * @notice Remove a consumer from a VRF subscription.
   * @param subId - ID of the subscription
   * @param consumer - Consumer to remove from the subscription
   */
  function removeConsumer(uint64 subId, address consumer) external;

  /**
   * @notice Cancel a subscription
   * @param subId - ID of the subscription
   * @param to - Where to send the remaining LINK to
   */
  function cancelSubscription(uint64 subId, address to) external;

  /*
   * @notice Check to see if there exists a request commitment consumers
   * for all consumers and keyhashes for a given sub.
   * @param subId - ID of the subscription
   * @return true if there exists at least one unfulfilled request for the subscription, false
   * otherwise.
   */
  function pendingRequestExists(uint64 subId) external view returns (bool);
}

File 12 of 27 : VRFConsumerBaseV2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/** ****************************************************************************
 * @notice Interface for contracts using VRF randomness
 * *****************************************************************************
 * @dev PURPOSE
 *
 * @dev Reggie the Random Oracle (not his real job) wants to provide randomness
 * @dev to Vera the verifier in such a way that Vera can be sure he's not
 * @dev making his output up to suit himself. Reggie provides Vera a public key
 * @dev to which he knows the secret key. Each time Vera provides a seed to
 * @dev Reggie, he gives back a value which is computed completely
 * @dev deterministically from the seed and the secret key.
 *
 * @dev Reggie provides a proof by which Vera can verify that the output was
 * @dev correctly computed once Reggie tells it to her, but without that proof,
 * @dev the output is indistinguishable to her from a uniform random sample
 * @dev from the output space.
 *
 * @dev The purpose of this contract is to make it easy for unrelated contracts
 * @dev to talk to Vera the verifier about the work Reggie is doing, to provide
 * @dev simple access to a verifiable source of randomness. It ensures 2 things:
 * @dev 1. The fulfillment came from the VRFCoordinator
 * @dev 2. The consumer contract implements fulfillRandomWords.
 * *****************************************************************************
 * @dev USAGE
 *
 * @dev Calling contracts must inherit from VRFConsumerBase, and can
 * @dev initialize VRFConsumerBase's attributes in their constructor as
 * @dev shown:
 *
 * @dev   contract VRFConsumer {
 * @dev     constructor(<other arguments>, address _vrfCoordinator, address _link)
 * @dev       VRFConsumerBase(_vrfCoordinator) public {
 * @dev         <initialization with other arguments goes here>
 * @dev       }
 * @dev   }
 *
 * @dev The oracle will have given you an ID for the VRF keypair they have
 * @dev committed to (let's call it keyHash). Create subscription, fund it
 * @dev and your consumer contract as a consumer of it (see VRFCoordinatorInterface
 * @dev subscription management functions).
 * @dev Call requestRandomWords(keyHash, subId, minimumRequestConfirmations,
 * @dev callbackGasLimit, numWords),
 * @dev see (VRFCoordinatorInterface for a description of the arguments).
 *
 * @dev Once the VRFCoordinator has received and validated the oracle's response
 * @dev to your request, it will call your contract's fulfillRandomWords method.
 *
 * @dev The randomness argument to fulfillRandomWords is a set of random words
 * @dev generated from your requestId and the blockHash of the request.
 *
 * @dev If your contract could have concurrent requests open, you can use the
 * @dev requestId returned from requestRandomWords to track which response is associated
 * @dev with which randomness request.
 * @dev See "SECURITY CONSIDERATIONS" for principles to keep in mind,
 * @dev if your contract could have multiple requests in flight simultaneously.
 *
 * @dev Colliding `requestId`s are cryptographically impossible as long as seeds
 * @dev differ.
 *
 * *****************************************************************************
 * @dev SECURITY CONSIDERATIONS
 *
 * @dev A method with the ability to call your fulfillRandomness method directly
 * @dev could spoof a VRF response with any random value, so it's critical that
 * @dev it cannot be directly called by anything other than this base contract
 * @dev (specifically, by the VRFConsumerBase.rawFulfillRandomness method).
 *
 * @dev For your users to trust that your contract's random behavior is free
 * @dev from malicious interference, it's best if you can write it so that all
 * @dev behaviors implied by a VRF response are executed *during* your
 * @dev fulfillRandomness method. If your contract must store the response (or
 * @dev anything derived from it) and use it later, you must ensure that any
 * @dev user-significant behavior which depends on that stored value cannot be
 * @dev manipulated by a subsequent VRF request.
 *
 * @dev Similarly, both miners and the VRF oracle itself have some influence
 * @dev over the order in which VRF responses appear on the blockchain, so if
 * @dev your contract could have multiple VRF requests in flight simultaneously,
 * @dev you must ensure that the order in which the VRF responses arrive cannot
 * @dev be used to manipulate your contract's user-significant behavior.
 *
 * @dev Since the block hash of the block which contains the requestRandomness
 * @dev call is mixed into the input to the VRF *last*, a sufficiently powerful
 * @dev miner could, in principle, fork the blockchain to evict the block
 * @dev containing the request, forcing the request to be included in a
 * @dev different block with a different hash, and therefore a different input
 * @dev to the VRF. However, such an attack would incur a substantial economic
 * @dev cost. This cost scales with the number of blocks the VRF oracle waits
 * @dev until it calls responds to a request. It is for this reason that
 * @dev that you can signal to an oracle you'd like them to wait longer before
 * @dev responding to the request (however this is not enforced in the contract
 * @dev and so remains effective only in the case of unmodified oracle software).
 */
abstract contract VRFConsumerBaseV2 {
  error OnlyCoordinatorCanFulfill(address have, address want);
  address private immutable vrfCoordinator;

  /**
   * @param _vrfCoordinator address of VRFCoordinator contract
   */
  constructor(address _vrfCoordinator) {
    vrfCoordinator = _vrfCoordinator;
  }

  /**
   * @notice fulfillRandomness handles the VRF response. Your contract must
   * @notice implement it. See "SECURITY CONSIDERATIONS" above for important
   * @notice principles to keep in mind when implementing your fulfillRandomness
   * @notice method.
   *
   * @dev VRFConsumerBaseV2 expects its subcontracts to have a method with this
   * @dev signature, and will call it once it has verified the proof
   * @dev associated with the randomness. (It is triggered via a call to
   * @dev rawFulfillRandomness, below.)
   *
   * @param requestId The Id initially returned by requestRandomness
   * @param randomWords the VRF output expanded to the requested number of words
   */
  function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal virtual;

  // rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF
  // proof. rawFulfillRandomness then calls fulfillRandomness, after validating
  // the origin of the call
  function rawFulfillRandomWords(uint256 requestId, uint256[] memory randomWords) external {
    if (msg.sender != vrfCoordinator) {
      revert OnlyCoordinatorCanFulfill(msg.sender, vrfCoordinator);
    }
    fulfillRandomWords(requestId, randomWords);
  }
}

File 13 of 27 : GameRegistryConsumer.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import {GameRegistry} from "./GameRegistry.sol";

/// @title GameRegistryConsumer
/// @notice all contracts within the THJ universe should inherit from this contract.
abstract contract GameRegistryConsumer {
    GameRegistry public immutable gameRegistry;

    error GameRegistry_NoPermissions(string role, address user);
    error GameRegistry_StageOutOfBounds(uint8 index);

    modifier onlyRole(bytes32 role_) {
        if (!gameRegistry.hasRole(role_, msg.sender)) {
            revert GameRegistry_NoPermissions(string(abi.encodePacked(role_)), msg.sender);
        }
        _;
    }

    constructor(address gameRegistry_) {
        gameRegistry = GameRegistry(gameRegistry_);
    }

    function _isEnabled(address game_) internal view returns (bool enabled) {
        enabled = gameRegistry.games(game_);
    }

    /// @dev the last stageTime is generalMint
    function _getStages() internal view returns (uint256[] memory) {
        return gameRegistry.getStageTimes();
    }

    /// @dev just a helper function. For access to all stages you should use _getStages()
    function _getStage(uint8 stageIndex) internal view returns (uint256) {
        uint256[] memory stageTimes = gameRegistry.getStageTimes();
        if (stageIndex >= stageTimes.length) revert GameRegistry_StageOutOfBounds(stageIndex);

        return stageTimes[stageIndex];
    }

    function _hasRole(bytes32 role_) internal view returns (bool) {
        return gameRegistry.hasRole(role_, msg.sender);
    }
}

File 14 of 27 : IGatekeeper.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

interface IGatekeeper {
    struct Gate {
        bool enabled;
        uint8 stageIndex; // stage from [0-3] (range defined within GameRegistry)
        uint32 claimedCount; // # of claims already happened
        uint32 maxClaimable; // # of claims per gate
        bytes32 gateRoot;
        uint256 activeAt; // timestamp when active.
    }

    /// @notice validate how much a player can claim for a particular token and gate.
    /// @param bundleId the ID of the bundle in the game.
    /// @param index the gate index the player is claiming
    /// @param amount the exact number of tokens a player wants to claim
    /// @param proof merkle proof associated with the amount
    /// @return claimAmount the number of tokens available for claim
    function calculateClaimable(
        uint256 bundleId,
        uint256 index,
        address player,
        uint32 amount,
        bytes32[] calldata proof
    ) external returns (uint32 claimAmount);

    /// @notice Validates proof -- does not modify the state.
    /// @param bundleId the ID of the bundle in the game.
    /// @param index the gate index the player is claiming
    /// @param amount the exact number of tokens a player wants to claim
    /// @param proof merkle proof associated with the amount
    /// @return validProof boolean representing the validity of the proof given
    function validateProof(uint256 bundleId, uint256 index, address player, uint32 amount, bytes32[] calldata proof)
        external
        returns (bool validProof);

    // Permissioned Methods -- Should not be open for everyone to call.

    /// @notice Update internal accounting, can only be called by a game instance.
    /// @param bundleId the ID of the bundle in the game.
    /// @param numClaimed increases gate claimed count by this value
    /// @param gateId the gate index the player is claiming
    /// @param proof consumes the proof that is used by the claim
    function addClaimed(uint256 bundleId, uint256 gateId, uint32 numClaimed, bytes32[] calldata proof) external;

    /// @notice adds a gate to the gates array, should only be called by a gameAdmin
    /// @param bundleId the id of bundle in the GameInstance
    /// @param root_ merkle root associated with the gate
    /// @param maxClaimable_ free claimable limit for the gate being added
    /// @param stageIndex_ the corresponds to the stage array within the gameRegistry
    function addGate(uint256 bundleId, bytes32 root_, uint32 maxClaimable_, uint8 stageIndex_) external;

    /// @notice Called by a game when a game is started to set times of gates opening.
    /// @dev Uses the stages array within GameRegistry to program gate openings. Will revert if there no gate associated with the bundle
    function startGatesForBundle(uint256 bundleId) external;
}

File 15 of 27 : IHoneyJar.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";

interface IHoneyJar is IERC721 {
    function mintOne(address to) external returns (uint256);

    function mintTokenId(address to, uint256 tokenId) external;

    function batchMint(address to, uint256 amount) external;

    function burn(uint256 _id) external;

    function nextTokenId() external view returns (uint256);
}

File 16 of 27 : Constants.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

library Constants {
    /**
     * Could use ENUM however existing contracts are already using these so opting to keep things consistent.
     */
    bytes32 internal constant GAME_ADMIN = "GAME_ADMIN";
    bytes32 internal constant BEEKEEPER = "BEEKEEPER";
    bytes32 internal constant JANI = "JANI";

    // Contract instances
    bytes32 internal constant GAME_INSTANCE = "GAME_INSTANCE";
    bytes32 internal constant GATEKEEPER = "GATEKEEPER";

    // Special ERC permissions
    bytes32 internal constant MINTER = "MINTER";
    bytes32 internal constant BURNER = "BURNER";
}

File 17 of 27 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

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 18 of 27 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 19 of 27 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @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
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or 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 {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 20 of 27 : ERC20.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event Transfer(address indexed from, address indexed to, uint256 amount);

    event Approval(address indexed owner, address indexed spender, uint256 amount);

    /*//////////////////////////////////////////////////////////////
                            METADATA STORAGE
    //////////////////////////////////////////////////////////////*/

    string public name;

    string public symbol;

    uint8 public immutable decimals;

    /*//////////////////////////////////////////////////////////////
                              ERC20 STORAGE
    //////////////////////////////////////////////////////////////*/

    uint256 public totalSupply;

    mapping(address => uint256) public balanceOf;

    mapping(address => mapping(address => uint256)) public allowance;

    /*//////////////////////////////////////////////////////////////
                            EIP-2612 STORAGE
    //////////////////////////////////////////////////////////////*/

    uint256 internal immutable INITIAL_CHAIN_ID;

    bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;

    mapping(address => uint256) public nonces;

    /*//////////////////////////////////////////////////////////////
                               CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    constructor(
        string memory _name,
        string memory _symbol,
        uint8 _decimals
    ) {
        name = _name;
        symbol = _symbol;
        decimals = _decimals;

        INITIAL_CHAIN_ID = block.chainid;
        INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
    }

    /*//////////////////////////////////////////////////////////////
                               ERC20 LOGIC
    //////////////////////////////////////////////////////////////*/

    function approve(address spender, uint256 amount) public virtual returns (bool) {
        allowance[msg.sender][spender] = amount;

        emit Approval(msg.sender, spender, amount);

        return true;
    }

    function transfer(address to, uint256 amount) public virtual returns (bool) {
        balanceOf[msg.sender] -= amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(msg.sender, to, amount);

        return true;
    }

    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual returns (bool) {
        uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.

        if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;

        balanceOf[from] -= amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(from, to, amount);

        return true;
    }

    /*//////////////////////////////////////////////////////////////
                             EIP-2612 LOGIC
    //////////////////////////////////////////////////////////////*/

    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual {
        require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");

        // Unchecked because the only math done is incrementing
        // the owner's nonce which cannot realistically overflow.
        unchecked {
            address recoveredAddress = ecrecover(
                keccak256(
                    abi.encodePacked(
                        "\x19\x01",
                        DOMAIN_SEPARATOR(),
                        keccak256(
                            abi.encode(
                                keccak256(
                                    "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
                                ),
                                owner,
                                spender,
                                value,
                                nonces[owner]++,
                                deadline
                            )
                        )
                    )
                ),
                v,
                r,
                s
            );

            require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");

            allowance[recoveredAddress][spender] = value;
        }

        emit Approval(owner, spender, value);
    }

    function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
        return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
    }

    function computeDomainSeparator() internal view virtual returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
                    keccak256(bytes(name)),
                    keccak256("1"),
                    block.chainid,
                    address(this)
                )
            );
    }

    /*//////////////////////////////////////////////////////////////
                        INTERNAL MINT/BURN LOGIC
    //////////////////////////////////////////////////////////////*/

    function _mint(address to, uint256 amount) internal virtual {
        totalSupply += amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

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

    function _burn(address from, uint256 amount) internal virtual {
        balanceOf[from] -= amount;

        // Cannot underflow because a user's balance
        // will never be larger than the total supply.
        unchecked {
            totalSupply -= amount;
        }

        emit Transfer(from, address(0), amount);
    }
}

File 21 of 27 : GameRegistry.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {Constants} from "./Constants.sol";

/// @title GameRegistry
/// @notice Central repository that tracks games and permissions.
/// @dev All game contracts should use extend `GameRegistryConsumer` to have consistent permissioning
contract GameRegistry is AccessControl {
    uint256[] internal stageTimes;

    // Events
    event GameRegistered(address game);
    event GameStarted(address game);
    event GameStopped(address game);
    event StageTimesSet(uint256[] stageTimes);

    constructor() {
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setupRole(Constants.GAME_ADMIN, msg.sender);

        // Initial 4 stages
        stageTimes.push(0 hours);
        stageTimes.push(2 hours);
        stageTimes.push(4 hours);
    }

    mapping(address => bool) public games; // Address -> enabled

    /// @notice registers the game with the GameRegistry
    function registerGame(address game_) external onlyRole(Constants.GAME_ADMIN) {
        _grantRole(Constants.GAME_INSTANCE, game_);
        emit GameRegistered(game_);
    }

    /// @notice starts the game which grants it the minterRole within the THJ ecosystem and enables it.
    /// @notice enabling the game means that the game is in "progress"
    function startGame(address game_) external onlyRole(Constants.GAME_ADMIN) {
        _grantRole(Constants.MINTER, game_);
        games[game_] = true;
        emit GameStarted(game_);
    }

    /// @notice stops the game which removes the mintor role and sets enable = false
    function stopGame(address game_) external onlyRole(Constants.GAME_ADMIN) {
        _revokeRole(Constants.MINTER, game_);
        games[game_] = false;
        emit GameStopped(game_);
    }

    /**
     * Getters
     */
    function getStageTimes() external view returns (uint256[] memory) {
        return stageTimes;
    }

    /**
     * Bear Pouch setters (helper functions)
     * Can check roles directly since this is an access control
     */

    /// @notice sets the JANI role in the THJ game registry.
    function setJani(address jani_) external onlyRole(Constants.GAME_ADMIN) {
        _grantRole(Constants.JANI, jani_);
    }

    /// @notice sets the beeKeeper role in the THJ game registry.
    function setBeekeeper(address beeKeeper_) external onlyRole(Constants.GAME_ADMIN) {
        _grantRole(Constants.BEEKEEPER, beeKeeper_);
    }

    /// @notice If the stages need to be modified after this contract is created.
    function setStageTimes(uint256[] calldata _stageTimes) external onlyRole(Constants.GAME_ADMIN) {
        stageTimes = _stageTimes;
        emit StageTimesSet(stageTimes);
    }
}

File 22 of 27 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

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

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(account),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 23 of 27 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 24 of 27 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

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 25 of 27 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @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] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

File 26 of 27 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

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 27 of 27 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

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

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

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

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

Settings
{
  "remappings": [
    "@chainlink/=lib/chainlink-brownie-contracts/contracts/src/v0.8/",
    "@layerzero/=lib/solidity-examples/contracts/",
    "@openzeppelin/=lib/openzeppelin-contracts/",
    "ERC721A/=lib/ERC721A/contracts/",
    "chainlink-brownie-contracts/=lib/chainlink-brownie-contracts/contracts/src/v0.8/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "dual-ownership-nft/=lib/dual-ownership-nft/contracts/",
    "forge-std/=lib/forge-std/src/",
    "murky/=lib/murky/src/",
    "openzeppelin-contracts/=lib/murky/lib/openzeppelin-contracts/",
    "solidity-examples/=lib/solidity-examples/contracts/",
    "solmate/=lib/solmate/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 10
  },
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_vrfCoordinator","type":"address"},{"internalType":"address","name":"_gameRegistry","type":"address"},{"internalType":"address","name":"_honeyJarAddress","type":"address"},{"internalType":"address","name":"_paymentToken","type":"address"},{"internalType":"address","name":"_gatekeeper","type":"address"},{"internalType":"address","name":"_jani","type":"address"},{"internalType":"address","name":"_beekeeper","type":"address"},{"internalType":"uint256","name":"_honeyJarShare","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyInitialized","type":"error"},{"inputs":[{"internalType":"uint8","name":"bundleId","type":"uint8"}],"name":"AlreadyTooManyHoneyJars","type":"error"},{"inputs":[],"name":"Claim_InvalidProof","type":"error"},{"inputs":[],"name":"GameInProgress","type":"error"},{"inputs":[{"internalType":"string","name":"role","type":"string"},{"internalType":"address","name":"user","type":"address"}],"name":"GameRegistry_NoPermissions","type":"error"},{"inputs":[{"internalType":"uint8","name":"index","type":"uint8"}],"name":"GameRegistry_StageOutOfBounds","type":"error"},{"inputs":[{"internalType":"uint8","name":"bundleId","type":"uint8"}],"name":"GeneralMintNotOpen","type":"error"},{"inputs":[{"internalType":"uint8","name":"bundleId","type":"uint8"}],"name":"InvalidBundle","type":"error"},{"inputs":[{"internalType":"string","name":"method","type":"string"}],"name":"InvalidInput","type":"error"},{"inputs":[{"internalType":"uint8","name":"bundleId","type":"uint8"}],"name":"MekingTooManyHoneyJars","type":"error"},{"inputs":[{"internalType":"uint8","name":"bundleId","type":"uint8"}],"name":"NotEnoughHoneyJarMinted","type":"error"},{"inputs":[],"name":"NotInitialized","type":"error"},{"inputs":[{"internalType":"uint8","name":"bundleId","type":"uint8"},{"internalType":"uint256","name":"honeyJarId","type":"uint256"}],"name":"NotOwnerOfSpecialHoneyJar","type":"error"},{"inputs":[{"internalType":"uint8","name":"bundleId","type":"uint8"}],"name":"NotSleeping","type":"error"},{"inputs":[{"internalType":"address","name":"have","type":"address"},{"internalType":"address","name":"want","type":"address"}],"name":"OnlyCoordinatorCanFulfill","type":"error"},{"inputs":[{"internalType":"uint8","name":"bundleId","type":"uint8"}],"name":"PartyAlreadyWoke","type":"error"},{"inputs":[{"internalType":"uint8","name":"bundleId","type":"uint8"}],"name":"SpecialHoneyJarNotFound","type":"error"},{"inputs":[],"name":"TooManyBundles","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"actual","type":"uint256"}],"name":"WrongAmount_ETH","type":"error"},{"inputs":[],"name":"ZeroMint","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"bundleId","type":"uint256"},{"indexed":false,"internalType":"uint32","name":"gateId","type":"uint32"},{"indexed":false,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"HoneyJarClaimed","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint32","name":"maxHoneyJar","type":"uint32"},{"internalType":"uint32","name":"maxClaimableHoneyJar","type":"uint32"},{"internalType":"uint256","name":"honeyJarPrice_ERC20","type":"uint256"},{"internalType":"uint256","name":"honeyJarPrice_ETH","type":"uint256"}],"indexed":false,"internalType":"struct HoneyBox.MintConfig","name":"mintConfig","type":"tuple"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint32","name":"maxHoneyJar","type":"uint32"},{"internalType":"uint32","name":"maxClaimableHoneyJar","type":"uint32"},{"internalType":"uint256","name":"honeyJarPrice_ERC20","type":"uint256"},{"internalType":"uint256","name":"honeyJarPrice_ETH","type":"uint256"}],"indexed":false,"internalType":"struct HoneyBox.MintConfig","name":"mintConfig","type":"tuple"}],"name":"MintConfigChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"bundleId","type":"uint8"},{"indexed":false,"internalType":"address","name":"player","type":"address"}],"name":"PartyAwoke","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"bundleId","type":"uint8"}],"name":"SlumberPartyAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"bundleId","type":"uint8"}],"name":"SlumberPartyStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"bundleId","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"honeyJarId","type":"uint256"}],"name":"SpecialHoneyJarFound","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"bytes32","name":"keyHash","type":"bytes32"},{"internalType":"uint64","name":"subId","type":"uint64"},{"internalType":"uint16","name":"minConfirmations","type":"uint16"},{"internalType":"uint32","name":"callbackGasLimit","type":"uint32"}],"indexed":false,"internalType":"struct HoneyBox.VRFConfig","name":"vrfConfig","type":"tuple"}],"name":"VRFConfigChanged","type":"event"},{"inputs":[{"internalType":"address[]","name":"tokenAddresses_","type":"address[]"},{"internalType":"uint256[]","name":"tokenIds_","type":"uint256[]"},{"internalType":"bool[]","name":"isERC1155_","type":"bool[]"}],"name":"addBundle","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"bundleId_","type":"uint8"},{"internalType":"uint32","name":"gateId","type":"uint32"},{"internalType":"uint32","name":"amount","type":"uint32"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"bundleId_","type":"uint8"},{"internalType":"uint32[]","name":"gateIds","type":"uint32[]"},{"internalType":"uint32[]","name":"amounts","type":"uint32[]"},{"internalType":"bytes32[][]","name":"proofs","type":"bytes32[][]"}],"name":"claimAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"}],"name":"claimed","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"bundleId","type":"uint8"},{"internalType":"uint32","name":"gateId","type":"uint32"},{"internalType":"uint32","name":"proofAmount","type":"uint32"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"name":"earlyMekHoneyJarWithERC20","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"bundleId","type":"uint8"},{"internalType":"uint32","name":"gateId","type":"uint32"},{"internalType":"uint32","name":"proofAmount","type":"uint32"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"name":"earlyMekHoneyJarWithEth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"gameRegistry","outputs":[{"internalType":"contract GameRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gatekeeper","outputs":[{"internalType":"contract IGatekeeper","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"_bundleId","type":"uint8"}],"name":"getSlumberParty","outputs":[{"components":[{"internalType":"uint8","name":"bundleId","type":"uint8"},{"internalType":"uint256","name":"specialHoneyJar","type":"uint256"},{"internalType":"uint256","name":"publicMintTime","type":"uint256"},{"internalType":"bool","name":"specialHoneyJarFound","type":"bool"},{"internalType":"bool","name":"isAwake","type":"bool"},{"components":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bool","name":"isERC1155","type":"bool"}],"internalType":"struct HoneyBox.SleepingNFT[]","name":"sleepoors","type":"tuple[]"}],"internalType":"struct HoneyBox.SlumberParty","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"honeyJar","outputs":[{"internalType":"contract IHoneyJar","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"honeyJarShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"honeyJarShelf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"honeyJarToParty","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"keyHash","type":"bytes32"},{"internalType":"uint64","name":"subId","type":"uint64"},{"internalType":"uint16","name":"minConfirmations","type":"uint16"},{"internalType":"uint32","name":"callbackGasLimit","type":"uint32"}],"internalType":"struct HoneyBox.VRFConfig","name":"vrfConfig_","type":"tuple"},{"components":[{"internalType":"uint32","name":"maxHoneyJar","type":"uint32"},{"internalType":"uint32","name":"maxClaimableHoneyJar","type":"uint32"},{"internalType":"uint256","name":"honeyJarPrice_ERC20","type":"uint256"},{"internalType":"uint256","name":"honeyJarPrice_ETH","type":"uint256"}],"internalType":"struct HoneyBox.MintConfig","name":"mintConfig_","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"bundleId_","type":"uint8"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"mekHoneyJarWithERC20","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"bundleId_","type":"uint8"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"mekHoneyJarWithETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"mintConfig","outputs":[{"internalType":"uint32","name":"maxHoneyJar","type":"uint32"},{"internalType":"uint32","name":"maxClaimableHoneyJar","type":"uint32"},{"internalType":"uint256","name":"honeyJarPrice_ERC20","type":"uint256"},{"internalType":"uint256","name":"honeyJarPrice_ETH","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"bundleId_","type":"uint8"}],"name":"openHotBox","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paymentToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"bundleId_","type":"uint8"}],"name":"puffPuffPassOut","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"rawFulfillRandomWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rng","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_honeyJarPrice","type":"uint256"}],"name":"setHoneyJarPrice_ERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_honeyJarPrice","type":"uint256"}],"name":"setHoneyJarPrice_ETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_maxClaimableHoneyJar","type":"uint32"}],"name":"setMaxClaimableHoneyJar","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_maxhoneyJar","type":"uint32"}],"name":"setMaxHoneyJar","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"keyHash","type":"bytes32"},{"internalType":"uint64","name":"subId","type":"uint64"},{"internalType":"uint16","name":"minConfirmations","type":"uint16"},{"internalType":"uint32","name":"callbackGasLimit","type":"uint32"}],"internalType":"struct HoneyBox.VRFConfig","name":"vrfConfig_","type":"tuple"}],"name":"setVRFConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"}],"name":"slumberParties","outputs":[{"internalType":"uint8","name":"bundleId","type":"uint8"},{"internalType":"uint256","name":"specialHoneyJar","type":"uint256"},{"internalType":"uint256","name":"publicMintTime","type":"uint256"},{"internalType":"bool","name":"specialHoneyJarFound","type":"bool"},{"internalType":"bool","name":"isAwake","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"slumberPartyList","outputs":[{"internalType":"uint8","name":"bundleId","type":"uint8"},{"internalType":"uint256","name":"specialHoneyJar","type":"uint256"},{"internalType":"uint256","name":"publicMintTime","type":"uint256"},{"internalType":"bool","name":"specialHoneyJarFound","type":"bool"},{"internalType":"bool","name":"isAwake","type":"bool"}],"stateMutability":"view","type":"function"}]

6101a060405260016000553480156200001757600080fd5b5060405162003bdf38038062003bdf8339810160408190526200003a916200009d565b6001600160a01b03978816608081905296881660a052610180969096529386166101605291851660c05284166101405283166101005290911660e052610120526200013c565b80516001600160a01b03811681146200009857600080fd5b919050565b600080600080600080600080610100898b031215620000bb57600080fd5b620000c68962000080565b9750620000d660208a0162000080565b9650620000e660408a0162000080565b9550620000f660608a0162000080565b94506200010660808a0162000080565b93506200011660a08a0162000080565b92506200012660c08a0162000080565b915060e089015190509295985092959890939650565b60805160a05160c05160e05161010051610120516101405161016051610180516139836200025c60003960006127b30152600081816102cb0152818161168501528181612375015261241e01526000818161054d01528181610e45015281816110390152818161145f01528181611e010152611f4d01526000818161043e015281816125e8015261261601526000818161269d015261272d015260008181612672015261270301526000818161034c0152818161264f01526126d001526000818161066d015281816107c30152818161097701528181610a8201528181610d020152818161110301528181611a2401528181611b6401528181611ca90152818161209801526122e70152600081816108d4015261091601526139836000f3fe60806040526004361061017e5760003560e01c80630119f8e7146101835780630e51f480146101d8578063114728d7146101fa578063150b7a021461024a578063158ef93e1461028f5780631c7c7326146102b95780631fe543e3146102fa5780632e2f22bf1461031a5780633013ce291461033a578063332e6f511461036e57806333639ace1461038e5780633ad726e4146103bc578063467bf809146103dc57806353f836db146103ef57806354274b041461042c57806359219f94146104605780635f36b826146104805780636761b37a146104c85780637029c6a6146104db57806378b664f4146104fb57806381177c4e1461051b578063a59c9c271461053b578063a5cc22761461056f578063a8f554721461059c578063b11a3b4a146105bc578063b2c80f61146105ec578063b45ac4371461060c578063bc197c811461062c578063da0907551461065b578063e7cc72441461068f578063eaa4b620146106e7578063eeef51bf14610707578063f23a6e6114610727575b600080fd5b34801561018f57600080fd5b506101a361019e366004612bf3565b610754565b6040805160ff9096168652602086019490945292840191909152151560608301521515608082015260a0015b60405180910390f35b3480156101e457600080fd5b506101f86101f3366004612c24565b61079d565b005b34801561020657600080fd5b506101a3610215366004612c56565b600860205260009081526040902080546001820154600283015460039093015460ff9283169391928181169161010090041685565b34801561025657600080fd5b50610276610265366004612cd1565b630a85bd0160e11b95945050505050565b6040516001600160e01b031990911681526020016101cf565b34801561029b57600080fd5b506006546102a99060ff1681565b60405190151581526020016101cf565b3480156102c557600080fd5b506102ed7f000000000000000000000000000000000000000000000000000000000000000081565b6040516101cf9190612d43565b34801561030657600080fd5b506101f8610315366004612dc0565b6108c9565b34801561032657600080fd5b506101f8610335366004612e73565b610951565b34801561034657600080fd5b506102ed7f000000000000000000000000000000000000000000000000000000000000000081565b34801561037a57600080fd5b506101f8610389366004612bf3565b610a5c565b34801561039a57600080fd5b506103ae6103a9366004612e97565b610b5a565b6040519081526020016101cf565b3480156103c857600080fd5b506101f86103d7366004612f05565b610bb1565b6103ae6103ea366004612e97565b610c8e565b3480156103fb57600080fd5b5061041f61040a366004612bf3565b600a6020526000908152604090205460ff1681565b6040516101cf9190612faf565b34801561043857600080fd5b506103ae7f000000000000000000000000000000000000000000000000000000000000000081565b34801561046c57600080fd5b506101f861047b366004612c56565b610cdc565b34801561048c57600080fd5b506104b361049b366004612c56565b60096020526000908152604090205463ffffffff1681565b60405163ffffffff90911681526020016101cf565b6103ae6104d6366004612fbd565b611013565b3480156104e757600080fd5b5061041f6104f636600461303e565b6110f1565b34801561050757600080fd5b506103ae610516366004612fbd565b611439565b34801561052757600080fd5b506101f8610536366004612c56565b61150b565b34801561054757600080fd5b506102ed7f000000000000000000000000000000000000000000000000000000000000000081565b34801561057b57600080fd5b5061058f61058a366004612c56565b6118e0565b6040516101cf91906130d7565b3480156105a857600080fd5b506101f86105b7366004613187565b6119fe565b3480156105c857600080fd5b5061041f6105d7366004612bf3565b600b6020526000908152604090205460ff1681565b3480156105f857600080fd5b506101f8610607366004612e73565b611b3e565b34801561061857600080fd5b506103ae610627366004612e97565b611c52565b34801561063857600080fd5b506102766106473660046131bd565b63bc197c8160e01b98975050505050505050565b34801561066757600080fd5b506102ed7f000000000000000000000000000000000000000000000000000000000000000081565b34801561069b57600080fd5b506001546002546003546106bf9263ffffffff80821693600160201b909204169184565b6040805163ffffffff95861681529490931660208501529183015260608201526080016101cf565b3480156106f357600080fd5b506101f8610702366004612bf3565b611c83565b34801561071357600080fd5b506101f861072236600461327b565b611d81565b34801561073357600080fd5b506102766107423660046132e3565b63f23a6e6160e01b9695505050505050565b6007818154811061076457600080fd5b6000918252602090912060059091020180546001820154600283015460039093015460ff92831694509092918181169161010090041685565b604051632474521560e21b81526923a0a6a2afa0a226a4a760b11b906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906391d14854906107fa908490339060040161334c565b602060405180830381865afa158015610817573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061083b9190613371565b61087e576040805160208101839052015b60408051601f1981840301815290829052637ed408ef60e11b82526108759133906004016133de565b60405180910390fd5b81600461088b828261342d565b9050507fcc3e9f4613d259f7b849187c7cf7a214776701c55ec26c67fb291825861194db826040516108bd91906134a2565b60405180910390a15050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146109435760405163073e64fd60e21b81523360048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166024820152604401610875565b61094d8282612041565b5050565b604051632474521560e21b81526923a0a6a2afa0a226a4a760b11b906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906391d14854906109ae908490339060040161334c565b602060405180830381865afa1580156109cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ef9190613371565b610a045760408051602081018390520161084c565b610a0d3061207e565b15610a2b57604051633497d0d160e21b815260040160405180910390fd5b6001805463ffffffff191663ffffffff841617815560405160008051602061392e833981519152916108bd916134fe565b604051632474521560e21b81526923a0a6a2afa0a226a4a760b11b906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906391d1485490610ab9908490339060040161334c565b602060405180830381865afa158015610ad6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610afa9190613371565b610b0f5760408051602081018390520161084c565b610b183061207e565b15610b3657604051633497d0d160e21b815260040160405180910390fd5b600382905560405160008051602061392e833981519152906108bd906001906134fe565b6000610b66838361210e565b60ff8316600090815260086020526040902060020154421015610b9e578260405163441344c760e11b81526004016108759190612faf565b610ba8838361226b565b90505b92915050565b80858114610bd25760405163d647364f60e01b81526004016108759061352f565b808414610bf25760405163d647364f60e01b81526004016108759061352f565b60005b81811015610c8357610c7389898984818110610c1357610c13613551565b9050602002016020810190610c289190612e73565b888885818110610c3a57610c3a613551565b9050602002016020810190610c4f9190612e73565b878786818110610c6157610c61613551565b90506020028101906107229190613567565b610c7c816135c6565b9050610bf5565b505050505050505050565b6000610c9a838361210e565b60ff8316600090815260086020526040902060020154421015610cd2578260405163441344c760e11b81526004016108759190612faf565b610ba88383612296565b604051632474521560e21b81526923a0a6a2afa0a226a4a760b11b906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906391d1485490610d39908490339060040161334c565b602060405180830381865afa158015610d56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7a9190613371565b610d8f5760408051602081018390520161084c565b60ff821660009081526008602052604081206004810180549192909190819003610dd15784604051600162b185b160e01b031981526004016108759190612faf565b600080610ddc6122e3565b905060008160018351610def91906135df565b81518110610dff57610dff613551565b602002602001015190508042610e1591906135f2565b60ff8916600090815260086020526040908190206002019190915551637c9a8a8b60e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690637c9a8a8b90610e7a908b90600401612faf565b600060405180830381600087803b158015610e9457600080fd5b505af1158015610ea8573d6000803e3d6000fd5b5050505060005b84811015610fd157858181548110610ec957610ec9613551565b60009182526020909120600390910201600281015490945060ff1615610f58578354600180860154604051637921219560e11b81526001600160a01b039093169263f242432a92610f21923392309290600401613605565b600060405180830381600087803b158015610f3b57600080fd5b505af1158015610f4f573d6000803e3d6000fd5b50505050610fc1565b83546001850154604051632142170760e11b81526001600160a01b03909216916342842e0e91610f8e913391309160040161363d565b600060405180830381600087803b158015610fa857600080fd5b505af1158015610fbc573d6000803e3d6000fd5b505050505b610fca816135c6565b9050610eaf565b507fb1e7034f601612c7ada6292d6e1877a8740b5ac037181626c7ef4219039ff61d886040516110019190612faf565b60405180910390a15050505050505050565b600061101f878361210e565b604051630c3c43e160e41b81526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063c3c43e1090611078908b908b9033908c908c908c90600401613693565b6020604051808303816000875af1158015611097573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110bb9190613371565b9050806110db576040516301285a3f60e41b815260040160405180910390fd5b6110e58884612296565b98975050505050505050565b60006923a0a6a2afa0a226a4a760b11b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166391d1485482336040518363ffffffff1660e01b815260040161114f92919061334c565b602060405180830381865afa15801561116c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111909190613371565b6111a55760408051602081018390520161084c565b868015806111b35750808614155b806111be5750808414155b156111f85760405163d647364f60e01b815260206004820152600960248201526861646442756e646c6560b81b6044820152606401610875565b60075460ff101561121c5760405163347a11a960e01b815260040160405180910390fd5b6007805460018101825560009182527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6886005820201805460ff191660ff831617815590915b83811015611362578160040160405180606001604052808e8e8581811061128a5761128a613551565b905060200201602081019061129f91906136d5565b6001600160a01b031681526020018c8c858181106112bf576112bf613551565b9050602002013581526020018a8a858181106112dd576112dd613551565b90506020020160208101906112f291906136f2565b151590528154600180820184556000938452602093849020835160039093020180546001600160a01b0319166001600160a01b039093169290921782559282015192810192909255604001516002909101805460ff191691151591909117905561135b816135c6565b9050611261565b5060ff80831660009081526008602052604090208254815460ff199081169184169190911782556001808501549083015560028085015490830155600380850180549184018054928616151593831684178155905461010090819004909516151590940261ff001990921661ffff199091161717909155600480830180548493926113f09290840191612b2b565b509050507f17f6c880535245b8de708485aed842d45639141362d1a6d151a64e2f11bcd639826040516114239190612faf565b60405180910390a1509998505050505050505050565b6000611445878361210e565b604051630c3c43e160e41b81526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063c3c43e109061149e908b908b9033908c908c908c90600401613693565b6020604051808303816000875af11580156114bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e19190613371565b905080611501576040516301285a3f60e41b815260040160405180910390fd5b6110e5888461226b565b60ff8082166000908152600860209081526040808320815160c081018352815486168152600182015481850152600282015481840152600382015480871615156060830152610100900490951615156080860152600481018054835181860281018601909452808452949594919360a08601939290879084015b828210156115df576000848152602090819020604080516060810182526003860290920180546001600160a01b031683526001808201548486015260029091015460ff161515918301919091529083529092019101611585565b5050509152505060015460ff84166000908152600c602052604090205491925063ffffffff161115611626578160405163180985e960e11b81526004016108759190612faf565b80608001511561164b5781604051638c12ede760e01b81526004016108759190612faf565b806060015161166f5781604051637cd083f560e01b81526004016108759190612faf565b60208101516040516331a9108f60e11b815233917f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031691636352211e916116c49160040190815260200190565b602060405180830381865afa1580156116e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611705919061370f565b6001600160a01b03161461173e5760208101516040516384780cab60e01b815260ff841660048201526024810191909152604401610875565b60ff82166000908152600860209081526040808320600301805461ff00191661010017905560a084015180518251606081018452858152938401859052918301939093529060005b8281101561189d578381815181106117a0576117a0613551565b602002602001015191508160400151156118245781516020830151604051637921219560e11b81526001600160a01b039092169163f242432a916117ed9130913391600190600401613605565b600060405180830381600087803b15801561180757600080fd5b505af115801561181b573d6000803e3d6000fd5b5050505061188d565b81516020830151604051632142170760e11b81526001600160a01b03909216916342842e0e9161185a913091339160040161363d565b600060405180830381600087803b15801561187457600080fd5b505af1158015611888573d6000803e3d6000fd5b505050505b611896816135c6565b9050611786565b506040805160ff871681523360208201527f846524fd2962b32c5f9f4cdc91ad7faf9e325986147a50f935ce2b7198ef2b1f910160405180910390a15050505050565b6119206040518060c00160405280600060ff1681526020016000815260200160008152602001600015158152602001600015158152602001606081525090565b60ff8083166000908152600860209081526040808320815160c081018352815486168152600182015481850152600282015481840152600382015480871615156060830152610100900490951615156080860152600481018054835181860281018601909452808452919460a087019491929184015b828210156119f0576000848152602090819020604080516060810182526003860290920180546001600160a01b031683526001808201548486015260029091015460ff161515918301919091529083529092019101611996565b505050915250909392505050565b604051632474521560e21b81526923a0a6a2afa0a226a4a760b11b906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906391d1485490611a5b908490339060040161334c565b602060405180830381865afa158015611a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a9c9190613371565b611ab15760408051602081018390520161084c565b60065460ff1615611ad45760405162dc149f60e41b815260040160405180910390fd5b6006805460ff19166001179055826004611aee828261342d565b508290506001611afe828261372c565b9050507f7dbc7344a75a1d1f4bc8ee6fac2781b881cbc08d46f769c0871e951f0f71da836001604051611b3191906134fe565b60405180910390a1505050565b604051632474521560e21b81526923a0a6a2afa0a226a4a760b11b906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906391d1485490611b9b908490339060040161334c565b602060405180830381865afa158015611bb8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bdc9190613371565b611bf15760408051602081018390520161084c565b611bfa3061207e565b15611c1857604051633497d0d160e21b815260040160405180910390fd5b6001805463ffffffff60201b1916600160201b63ffffffff85160217815560405160008051602061392e833981519152916108bd916134fe565b600c6020528160005260406000208181548110611c6e57600080fd5b90600052602060002001600091509150505481565b604051632474521560e21b81526923a0a6a2afa0a226a4a760b11b906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906391d1485490611ce0908490339060040161334c565b602060405180830381865afa158015611cfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d219190613371565b611d365760408051602081018390520161084c565b611d3f3061207e565b15611d5d57604051633497d0d160e21b815260040160405180910390fd5b600282905560405160008051602061392e833981519152906108bd906001906134fe565b600054600114611dc05760405162461bcd60e51b815260206004820152600a6024820152695245454e5452414e435960b01b6044820152606401610875565b60026000908155819003611de7576040516301285a3f60e41b815260040160405180910390fd5b60405163ae43f23560e01b81526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063ae43f23590611e40908990899033908a908a908a90600401613693565b6020604051808303816000875af1158015611e5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e839190613796565b90508063ffffffff16600003611e995750612035565b60ff861660009081526009602052604090205460015463ffffffff91821691600160201b90910416611ecb82846137b3565b63ffffffff161115611ef557600154611ef2908290600160201b900463ffffffff166137d7565b91505b611f05878363ffffffff1661210e565b60ff871660009081526009602052604081208054849290611f2d90849063ffffffff166137b3565b92506101000a81548163ffffffff021916908363ffffffff1602179055507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637310c0ca88888588886040518663ffffffff1660e01b8152600401611f9f9594939291906137f4565b600060405180830381600087803b158015611fb957600080fd5b505af1158015611fcd573d6000803e3d6000fd5b50505050611fe233888463ffffffff16612370565b506040805160ff8916815263ffffffff888116602083015233828401528416606082015290517f35eb2186610c2470faf6f3a29417ac4be5492cef3ef18c72186a646cb7ecfc489181900360800190a150505b50506001600055505050565b6000828152600a6020526040812054825160ff90911691612079918391859161206c5761206c613551565b602002602001015161251f565b505050565b6040516379131a1960e01b81526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906379131a19906120cd908590600401612d43565b602060405180830381865afa1580156120ea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bab9190613371565b60065460ff16612131576040516321c4e35760e21b815260040160405180910390fd5b60ff808316600081815260086020526040902080549092161461216c5782604051600162b185b160e01b031981526004016108759190612faf565b80600201546000036121935782604051637860b95160e11b81526004016108759190612faf565b6003810154610100900460ff16156121c05782604051638c12ede760e01b81526004016108759190612faf565b60015460ff84166000908152600c602052604090205463ffffffff90911610156121ff5782604051634f8acceb60e11b81526004016108759190612faf565b60015460ff84166000908152600c602052604090205463ffffffff909116906122299084906135f2565b111561224a5782604051639a12305360e01b81526004016108759190612faf565b816000036120795760405163a776bb4d60e01b815260040160405180910390fd5b60025460009061228361227e8483613827565b6125e0565b61228e338585612370565b949350505050565b6003546000906122a68382613827565b34146122d9576122b68382613827565b60405163c8116dcf60e01b81526004810191909152346024820152604401610875565b61228360006125e0565b60607f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630db5274e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015612343573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261236b919081019061383e565b905090565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166375794a3c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123f591906138c3565b6040516343508b0560e01b81526001600160a01b038781166004830152602482018690529192507f0000000000000000000000000000000000000000000000000000000000000000909116906343508b0590604401600060405180830381600087803b15801561246457600080fd5b505af1158015612478573d6000803e3d6000fd5b5050505060005b838110156124de5760ff85166000818152600c60209081526040808320805460018101825590845282842001869055858352600b9091529020805460ff191690911790556124cc826135c6565b91506124d7816135c6565b905061247f565b5060015460ff85166000908152600c602052604090205463ffffffff9091161161250b5761250b8461275b565b6125166001826135df565b95945050505050565b60ff82166000908152600c60205260408120549061253d82846138dc565b60ff85166000908152600c60205260408120805492935090918390811061256657612566613551565b60009182526020808320919091015460ff88168084526008835260409384902060038101805460ff191660019081179091558101839055845191825292810182905290935090917f80130e9dfae6ecee471f4d3ad808d3e4850cd827e642e455956ec8bbc6923406910160405180910390a1505050505050565b600061260c827f000000000000000000000000000000000000000000000000000000000000000061284c565b9050600061263a347f000000000000000000000000000000000000000000000000000000000000000061284c565b905081156126f8576126976001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016337f000000000000000000000000000000000000000000000000000000000000000085612861565b6126f8337f00000000000000000000000000000000000000000000000000000000000000006126c685876135df565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016929190612861565b8015612079576127287f0000000000000000000000000000000000000000000000000000000000000000826128bf565b6120797f000000000000000000000000000000000000000000000000000000000000000061275683346135df565b6128bf565b600480546005546040516305d3b1d360e41b8152928301919091526001600160401b0381166024830152600160401b810461ffff166044830152600160501b900463ffffffff166064820152600260848201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690635d3b1d309060a4016020604051808303816000875af1158015612804573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061282891906138c3565b6000908152600a60205260409020805460ff191660ff939093169290921790915550565b6000610ba88383670de0b6b3a7640000612910565b6128b9846323b872dd60e01b8585856040516024016128829392919061363d565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612936565b50505050565b600080600080600085875af19050806120795760405162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b6044820152606401610875565b600082600019048411830215820261292757600080fd5b50910281810615159190040190565b600061298b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a089092919063ffffffff16565b80519091501561207957808060200190518101906129a99190613371565b6120795760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610875565b606061228e848460008585600080866001600160a01b03168587604051612a2f91906138fe565b60006040518083038185875af1925050503d8060008114612a6c576040519150601f19603f3d011682016040523d82523d6000602084013e612a71565b606091505b5091509150612a8287838387612a8d565b979650505050505050565b60608315612afc578251600003612af5576001600160a01b0385163b612af55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610875565b508161228e565b61228e8383815115612b115781518083602001fd5b8060405162461bcd60e51b8152600401610875919061391a565b828054828255906000526020600020906003028101928215612bb15760005260206000209160030282015b82811115612bb157825482546001600160a01b0319166001600160a01b0390911617825560018084015490830155600280840154908301805460ff909216151560ff1990921691909117905560039283019290910190612b56565b50612bbd929150612bc1565b5090565b5b80821115612bbd5780546001600160a01b03191681556000600182015560028101805460ff19169055600301612bc2565b600060208284031215612c0557600080fd5b5035919050565b600060808284031215612c1e57600080fd5b50919050565b600060808284031215612c3657600080fd5b610ba88383612c0c565b803560ff81168114612c5157600080fd5b919050565b600060208284031215612c6857600080fd5b610ba882612c40565b6001600160a01b0381168114612c8657600080fd5b50565b60008083601f840112612c9b57600080fd5b5081356001600160401b03811115612cb257600080fd5b602083019150836020828501011115612cca57600080fd5b9250929050565b600080600080600060808688031215612ce957600080fd5b8535612cf481612c71565b94506020860135612d0481612c71565b93506040860135925060608601356001600160401b03811115612d2657600080fd5b612d3288828901612c89565b969995985093965092949392505050565b6001600160a01b0391909116815260200190565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715612d9557612d95612d57565b604052919050565b60006001600160401b03821115612db657612db6612d57565b5060051b60200190565b60008060408385031215612dd357600080fd5b823591506020808401356001600160401b03811115612df157600080fd5b8401601f81018613612e0257600080fd5b8035612e15612e1082612d9d565b612d6d565b81815260059190911b82018301908381019088831115612e3457600080fd5b928401925b82841015612e5257833582529284019290840190612e39565b80955050505050509250929050565b63ffffffff81168114612c8657600080fd5b600060208284031215612e8557600080fd5b8135612e9081612e61565b9392505050565b60008060408385031215612eaa57600080fd5b612eb383612c40565b946020939093013593505050565b60008083601f840112612ed357600080fd5b5081356001600160401b03811115612eea57600080fd5b6020830191508360208260051b8501011115612cca57600080fd5b60008060008060008060006080888a031215612f2057600080fd5b612f2988612c40565b965060208801356001600160401b0380821115612f4557600080fd5b612f518b838c01612ec1565b909850965060408a0135915080821115612f6a57600080fd5b612f768b838c01612ec1565b909650945060608a0135915080821115612f8f57600080fd5b50612f9c8a828b01612ec1565b989b979a50959850939692959293505050565b60ff91909116815260200190565b60008060008060008060a08789031215612fd657600080fd5b612fdf87612c40565b95506020870135612fef81612e61565b94506040870135612fff81612e61565b935060608701356001600160401b0381111561301a57600080fd5b61302689828a01612ec1565b979a9699509497949695608090950135949350505050565b6000806000806000806060878903121561305757600080fd5b86356001600160401b038082111561306e57600080fd5b61307a8a838b01612ec1565b9098509650602089013591508082111561309357600080fd5b61309f8a838b01612ec1565b909650945060408901359150808211156130b857600080fd5b506130c589828a01612ec1565b979a9699509497509295939492505050565b6000602080835260e0830160ff8551168285015281850151604081818701528087015191506060828188015280880151151560808801526080880151151560a088015260a0880151925060c080880152838351808652610100890191508685019550600094505b8085101561317a57855180516001600160a01b03168352878101518884015284015115158483015294860194600194909401939082019061313e565b5098975050505050505050565b600080610100838503121561319b57600080fd5b6131a58484612c0c565b91506131b48460808501612c0c565b90509250929050565b60008060008060008060008060a0898b0312156131d957600080fd5b88356131e481612c71565b975060208901356131f481612c71565b965060408901356001600160401b038082111561321057600080fd5b61321c8c838d01612ec1565b909850965060608b013591508082111561323557600080fd5b6132418c838d01612ec1565b909650945060808b013591508082111561325a57600080fd5b506132678b828c01612c89565b999c989b5096995094979396929594505050565b60008060008060006080868803121561329357600080fd5b61329c86612c40565b945060208601356132ac81612e61565b935060408601356132bc81612e61565b925060608601356001600160401b038111156132d757600080fd5b612d3288828901612ec1565b60008060008060008060a087890312156132fc57600080fd5b863561330781612c71565b9550602087013561331781612c71565b9450604087013593506060870135925060808701356001600160401b0381111561334057600080fd5b6130c589828a01612c89565b9182526001600160a01b0316602082015260400190565b8015158114612c8657600080fd5b60006020828403121561338357600080fd5b8151612e9081613363565b60005b838110156133a9578181015183820152602001613391565b50506000910152565b600081518084526133ca81602086016020860161338e565b601f01601f19169290920160200192915050565b6040815260006133f160408301856133b2565b905060018060a01b03831660208301529392505050565b6001600160401b0381168114612c8657600080fd5b61ffff81168114612c8657600080fd5b8135815560018101602083013561344381613408565b815460408501356134538161341d565b606086013561346181612e61565b60409190911b61ffff60401b166001600160701b0319929092166001600160401b0393909316929092171760509190911b63ffffffff60501b161790555050565b813581526080810160208301356134b881613408565b6001600160401b0316602083015260408301356134d48161341d565b61ffff16604083015260608301356134eb81612e61565b63ffffffff811660608401525092915050565b815463ffffffff8082168352602091821c169082015260018201546040820152600290910154606082015260800190565b60208082526008908201526718db185a5b505b1b60c21b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261357e57600080fd5b8301803591506001600160401b0382111561359857600080fd5b6020019150600581901b3603821315612cca57600080fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016135d8576135d86135b0565b5060010190565b81810381811115610bab57610bab6135b0565b80820180821115610bab57610bab6135b0565b6001600160a01b0394851681529290931660208301526040820152606081019190915260a06080820181905260009082015260c00190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b81835260006001600160fb1b0383111561367a57600080fd5b8260051b80836020870137939093016020019392505050565b60ff8716815263ffffffff86811660208301526001600160a01b03861660408301528416606082015260a0608082018190526000906110e59083018486613661565b6000602082840312156136e757600080fd5b8135612e9081612c71565b60006020828403121561370457600080fd5b8135612e9081613363565b60006020828403121561372157600080fd5b8151612e9081612c71565b813561373781612e61565b63ffffffff8116905081548163ffffffff198216178355602084013561375c81612e61565b6001600160401b03199190911690911760209190911b63ffffffff60201b1617815560408201356001820155606090910135600290910155565b6000602082840312156137a857600080fd5b8151612e9081612e61565b63ffffffff8181168382160190808211156137d0576137d06135b0565b5092915050565b63ffffffff8281168282160390808211156137d0576137d06135b0565b60ff86168152600063ffffffff808716602084015280861660408401525060806060830152612a82608083018486613661565b8082028115828204841417610bab57610bab6135b0565b6000602080838503121561385157600080fd5b82516001600160401b0381111561386757600080fd5b8301601f8101851361387857600080fd5b8051613886612e1082612d9d565b81815260059190911b820183019083810190878311156138a557600080fd5b928401925b82841015612a82578351825292840192908401906138aa565b6000602082840312156138d557600080fd5b5051919050565b6000826138f957634e487b7160e01b600052601260045260246000fd5b500690565b6000825161391081846020870161338e565b9190910192915050565b602081526000610ba860208301846133b256fed168ea0c23f28c79e79434ab061118c9928940fddf526760e980a0b2a9a5771ba264697066735822122000ed51f2b32f2ca5a95d8272776392bba8517d5245cc4afd1af10a465b5336ab64736f6c634300081100330000000000000000000000000000000000000000000000000000000000000020000000000000000000000000ec420b0d0da852359e0d6a31ec322ab502c788a2000000000000000000000000a20cf9b0874c3e46b344deaeea9c2e0c3e1db37d00000000000000000000000064aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5000000000000000000000000b5ce6c18e7c9b3f0a223641ef84889df878f42b300000000000000000000000025542fd6204bbbe570e358b9ebeb391513980c3400000000000000000000000067edbbf1531b28551f2075223d8a30a9ae457eca0000000000000000000000000000000000000000000000000319522aba584000

Deployed Bytecode

0x60806040526004361061017e5760003560e01c80630119f8e7146101835780630e51f480146101d8578063114728d7146101fa578063150b7a021461024a578063158ef93e1461028f5780631c7c7326146102b95780631fe543e3146102fa5780632e2f22bf1461031a5780633013ce291461033a578063332e6f511461036e57806333639ace1461038e5780633ad726e4146103bc578063467bf809146103dc57806353f836db146103ef57806354274b041461042c57806359219f94146104605780635f36b826146104805780636761b37a146104c85780637029c6a6146104db57806378b664f4146104fb57806381177c4e1461051b578063a59c9c271461053b578063a5cc22761461056f578063a8f554721461059c578063b11a3b4a146105bc578063b2c80f61146105ec578063b45ac4371461060c578063bc197c811461062c578063da0907551461065b578063e7cc72441461068f578063eaa4b620146106e7578063eeef51bf14610707578063f23a6e6114610727575b600080fd5b34801561018f57600080fd5b506101a361019e366004612bf3565b610754565b6040805160ff9096168652602086019490945292840191909152151560608301521515608082015260a0015b60405180910390f35b3480156101e457600080fd5b506101f86101f3366004612c24565b61079d565b005b34801561020657600080fd5b506101a3610215366004612c56565b600860205260009081526040902080546001820154600283015460039093015460ff9283169391928181169161010090041685565b34801561025657600080fd5b50610276610265366004612cd1565b630a85bd0160e11b95945050505050565b6040516001600160e01b031990911681526020016101cf565b34801561029b57600080fd5b506006546102a99060ff1681565b60405190151581526020016101cf565b3480156102c557600080fd5b506102ed7f000000000000000000000000a20cf9b0874c3e46b344deaeea9c2e0c3e1db37d81565b6040516101cf9190612d43565b34801561030657600080fd5b506101f8610315366004612dc0565b6108c9565b34801561032657600080fd5b506101f8610335366004612e73565b610951565b34801561034657600080fd5b506102ed7f00000000000000000000000064aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d581565b34801561037a57600080fd5b506101f8610389366004612bf3565b610a5c565b34801561039a57600080fd5b506103ae6103a9366004612e97565b610b5a565b6040519081526020016101cf565b3480156103c857600080fd5b506101f86103d7366004612f05565b610bb1565b6103ae6103ea366004612e97565b610c8e565b3480156103fb57600080fd5b5061041f61040a366004612bf3565b600a6020526000908152604090205460ff1681565b6040516101cf9190612faf565b34801561043857600080fd5b506103ae7f0000000000000000000000000000000000000000000000000319522aba58400081565b34801561046c57600080fd5b506101f861047b366004612c56565b610cdc565b34801561048c57600080fd5b506104b361049b366004612c56565b60096020526000908152604090205463ffffffff1681565b60405163ffffffff90911681526020016101cf565b6103ae6104d6366004612fbd565b611013565b3480156104e757600080fd5b5061041f6104f636600461303e565b6110f1565b34801561050757600080fd5b506103ae610516366004612fbd565b611439565b34801561052757600080fd5b506101f8610536366004612c56565b61150b565b34801561054757600080fd5b506102ed7f000000000000000000000000b5ce6c18e7c9b3f0a223641ef84889df878f42b381565b34801561057b57600080fd5b5061058f61058a366004612c56565b6118e0565b6040516101cf91906130d7565b3480156105a857600080fd5b506101f86105b7366004613187565b6119fe565b3480156105c857600080fd5b5061041f6105d7366004612bf3565b600b6020526000908152604090205460ff1681565b3480156105f857600080fd5b506101f8610607366004612e73565b611b3e565b34801561061857600080fd5b506103ae610627366004612e97565b611c52565b34801561063857600080fd5b506102766106473660046131bd565b63bc197c8160e01b98975050505050505050565b34801561066757600080fd5b506102ed7f000000000000000000000000ec420b0d0da852359e0d6a31ec322ab502c788a281565b34801561069b57600080fd5b506001546002546003546106bf9263ffffffff80821693600160201b909204169184565b6040805163ffffffff95861681529490931660208501529183015260608201526080016101cf565b3480156106f357600080fd5b506101f8610702366004612bf3565b611c83565b34801561071357600080fd5b506101f861072236600461327b565b611d81565b34801561073357600080fd5b506102766107423660046132e3565b63f23a6e6160e01b9695505050505050565b6007818154811061076457600080fd5b6000918252602090912060059091020180546001820154600283015460039093015460ff92831694509092918181169161010090041685565b604051632474521560e21b81526923a0a6a2afa0a226a4a760b11b906001600160a01b037f000000000000000000000000ec420b0d0da852359e0d6a31ec322ab502c788a216906391d14854906107fa908490339060040161334c565b602060405180830381865afa158015610817573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061083b9190613371565b61087e576040805160208101839052015b60408051601f1981840301815290829052637ed408ef60e11b82526108759133906004016133de565b60405180910390fd5b81600461088b828261342d565b9050507fcc3e9f4613d259f7b849187c7cf7a214776701c55ec26c67fb291825861194db826040516108bd91906134a2565b60405180910390a15050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000002016146109435760405163073e64fd60e21b81523360048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000020166024820152604401610875565b61094d8282612041565b5050565b604051632474521560e21b81526923a0a6a2afa0a226a4a760b11b906001600160a01b037f000000000000000000000000ec420b0d0da852359e0d6a31ec322ab502c788a216906391d14854906109ae908490339060040161334c565b602060405180830381865afa1580156109cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ef9190613371565b610a045760408051602081018390520161084c565b610a0d3061207e565b15610a2b57604051633497d0d160e21b815260040160405180910390fd5b6001805463ffffffff191663ffffffff841617815560405160008051602061392e833981519152916108bd916134fe565b604051632474521560e21b81526923a0a6a2afa0a226a4a760b11b906001600160a01b037f000000000000000000000000ec420b0d0da852359e0d6a31ec322ab502c788a216906391d1485490610ab9908490339060040161334c565b602060405180830381865afa158015610ad6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610afa9190613371565b610b0f5760408051602081018390520161084c565b610b183061207e565b15610b3657604051633497d0d160e21b815260040160405180910390fd5b600382905560405160008051602061392e833981519152906108bd906001906134fe565b6000610b66838361210e565b60ff8316600090815260086020526040902060020154421015610b9e578260405163441344c760e11b81526004016108759190612faf565b610ba8838361226b565b90505b92915050565b80858114610bd25760405163d647364f60e01b81526004016108759061352f565b808414610bf25760405163d647364f60e01b81526004016108759061352f565b60005b81811015610c8357610c7389898984818110610c1357610c13613551565b9050602002016020810190610c289190612e73565b888885818110610c3a57610c3a613551565b9050602002016020810190610c4f9190612e73565b878786818110610c6157610c61613551565b90506020028101906107229190613567565b610c7c816135c6565b9050610bf5565b505050505050505050565b6000610c9a838361210e565b60ff8316600090815260086020526040902060020154421015610cd2578260405163441344c760e11b81526004016108759190612faf565b610ba88383612296565b604051632474521560e21b81526923a0a6a2afa0a226a4a760b11b906001600160a01b037f000000000000000000000000ec420b0d0da852359e0d6a31ec322ab502c788a216906391d1485490610d39908490339060040161334c565b602060405180830381865afa158015610d56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7a9190613371565b610d8f5760408051602081018390520161084c565b60ff821660009081526008602052604081206004810180549192909190819003610dd15784604051600162b185b160e01b031981526004016108759190612faf565b600080610ddc6122e3565b905060008160018351610def91906135df565b81518110610dff57610dff613551565b602002602001015190508042610e1591906135f2565b60ff8916600090815260086020526040908190206002019190915551637c9a8a8b60e01b81526001600160a01b037f000000000000000000000000b5ce6c18e7c9b3f0a223641ef84889df878f42b31690637c9a8a8b90610e7a908b90600401612faf565b600060405180830381600087803b158015610e9457600080fd5b505af1158015610ea8573d6000803e3d6000fd5b5050505060005b84811015610fd157858181548110610ec957610ec9613551565b60009182526020909120600390910201600281015490945060ff1615610f58578354600180860154604051637921219560e11b81526001600160a01b039093169263f242432a92610f21923392309290600401613605565b600060405180830381600087803b158015610f3b57600080fd5b505af1158015610f4f573d6000803e3d6000fd5b50505050610fc1565b83546001850154604051632142170760e11b81526001600160a01b03909216916342842e0e91610f8e913391309160040161363d565b600060405180830381600087803b158015610fa857600080fd5b505af1158015610fbc573d6000803e3d6000fd5b505050505b610fca816135c6565b9050610eaf565b507fb1e7034f601612c7ada6292d6e1877a8740b5ac037181626c7ef4219039ff61d886040516110019190612faf565b60405180910390a15050505050505050565b600061101f878361210e565b604051630c3c43e160e41b81526000906001600160a01b037f000000000000000000000000b5ce6c18e7c9b3f0a223641ef84889df878f42b3169063c3c43e1090611078908b908b9033908c908c908c90600401613693565b6020604051808303816000875af1158015611097573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110bb9190613371565b9050806110db576040516301285a3f60e41b815260040160405180910390fd5b6110e58884612296565b98975050505050505050565b60006923a0a6a2afa0a226a4a760b11b7f000000000000000000000000ec420b0d0da852359e0d6a31ec322ab502c788a26001600160a01b03166391d1485482336040518363ffffffff1660e01b815260040161114f92919061334c565b602060405180830381865afa15801561116c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111909190613371565b6111a55760408051602081018390520161084c565b868015806111b35750808614155b806111be5750808414155b156111f85760405163d647364f60e01b815260206004820152600960248201526861646442756e646c6560b81b6044820152606401610875565b60075460ff101561121c5760405163347a11a960e01b815260040160405180910390fd5b6007805460018101825560009182527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6886005820201805460ff191660ff831617815590915b83811015611362578160040160405180606001604052808e8e8581811061128a5761128a613551565b905060200201602081019061129f91906136d5565b6001600160a01b031681526020018c8c858181106112bf576112bf613551565b9050602002013581526020018a8a858181106112dd576112dd613551565b90506020020160208101906112f291906136f2565b151590528154600180820184556000938452602093849020835160039093020180546001600160a01b0319166001600160a01b039093169290921782559282015192810192909255604001516002909101805460ff191691151591909117905561135b816135c6565b9050611261565b5060ff80831660009081526008602052604090208254815460ff199081169184169190911782556001808501549083015560028085015490830155600380850180549184018054928616151593831684178155905461010090819004909516151590940261ff001990921661ffff199091161717909155600480830180548493926113f09290840191612b2b565b509050507f17f6c880535245b8de708485aed842d45639141362d1a6d151a64e2f11bcd639826040516114239190612faf565b60405180910390a1509998505050505050505050565b6000611445878361210e565b604051630c3c43e160e41b81526000906001600160a01b037f000000000000000000000000b5ce6c18e7c9b3f0a223641ef84889df878f42b3169063c3c43e109061149e908b908b9033908c908c908c90600401613693565b6020604051808303816000875af11580156114bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e19190613371565b905080611501576040516301285a3f60e41b815260040160405180910390fd5b6110e5888461226b565b60ff8082166000908152600860209081526040808320815160c081018352815486168152600182015481850152600282015481840152600382015480871615156060830152610100900490951615156080860152600481018054835181860281018601909452808452949594919360a08601939290879084015b828210156115df576000848152602090819020604080516060810182526003860290920180546001600160a01b031683526001808201548486015260029091015460ff161515918301919091529083529092019101611585565b5050509152505060015460ff84166000908152600c602052604090205491925063ffffffff161115611626578160405163180985e960e11b81526004016108759190612faf565b80608001511561164b5781604051638c12ede760e01b81526004016108759190612faf565b806060015161166f5781604051637cd083f560e01b81526004016108759190612faf565b60208101516040516331a9108f60e11b815233917f000000000000000000000000a20cf9b0874c3e46b344deaeea9c2e0c3e1db37d6001600160a01b031691636352211e916116c49160040190815260200190565b602060405180830381865afa1580156116e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611705919061370f565b6001600160a01b03161461173e5760208101516040516384780cab60e01b815260ff841660048201526024810191909152604401610875565b60ff82166000908152600860209081526040808320600301805461ff00191661010017905560a084015180518251606081018452858152938401859052918301939093529060005b8281101561189d578381815181106117a0576117a0613551565b602002602001015191508160400151156118245781516020830151604051637921219560e11b81526001600160a01b039092169163f242432a916117ed9130913391600190600401613605565b600060405180830381600087803b15801561180757600080fd5b505af115801561181b573d6000803e3d6000fd5b5050505061188d565b81516020830151604051632142170760e11b81526001600160a01b03909216916342842e0e9161185a913091339160040161363d565b600060405180830381600087803b15801561187457600080fd5b505af1158015611888573d6000803e3d6000fd5b505050505b611896816135c6565b9050611786565b506040805160ff871681523360208201527f846524fd2962b32c5f9f4cdc91ad7faf9e325986147a50f935ce2b7198ef2b1f910160405180910390a15050505050565b6119206040518060c00160405280600060ff1681526020016000815260200160008152602001600015158152602001600015158152602001606081525090565b60ff8083166000908152600860209081526040808320815160c081018352815486168152600182015481850152600282015481840152600382015480871615156060830152610100900490951615156080860152600481018054835181860281018601909452808452919460a087019491929184015b828210156119f0576000848152602090819020604080516060810182526003860290920180546001600160a01b031683526001808201548486015260029091015460ff161515918301919091529083529092019101611996565b505050915250909392505050565b604051632474521560e21b81526923a0a6a2afa0a226a4a760b11b906001600160a01b037f000000000000000000000000ec420b0d0da852359e0d6a31ec322ab502c788a216906391d1485490611a5b908490339060040161334c565b602060405180830381865afa158015611a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a9c9190613371565b611ab15760408051602081018390520161084c565b60065460ff1615611ad45760405162dc149f60e41b815260040160405180910390fd5b6006805460ff19166001179055826004611aee828261342d565b508290506001611afe828261372c565b9050507f7dbc7344a75a1d1f4bc8ee6fac2781b881cbc08d46f769c0871e951f0f71da836001604051611b3191906134fe565b60405180910390a1505050565b604051632474521560e21b81526923a0a6a2afa0a226a4a760b11b906001600160a01b037f000000000000000000000000ec420b0d0da852359e0d6a31ec322ab502c788a216906391d1485490611b9b908490339060040161334c565b602060405180830381865afa158015611bb8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bdc9190613371565b611bf15760408051602081018390520161084c565b611bfa3061207e565b15611c1857604051633497d0d160e21b815260040160405180910390fd5b6001805463ffffffff60201b1916600160201b63ffffffff85160217815560405160008051602061392e833981519152916108bd916134fe565b600c6020528160005260406000208181548110611c6e57600080fd5b90600052602060002001600091509150505481565b604051632474521560e21b81526923a0a6a2afa0a226a4a760b11b906001600160a01b037f000000000000000000000000ec420b0d0da852359e0d6a31ec322ab502c788a216906391d1485490611ce0908490339060040161334c565b602060405180830381865afa158015611cfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d219190613371565b611d365760408051602081018390520161084c565b611d3f3061207e565b15611d5d57604051633497d0d160e21b815260040160405180910390fd5b600282905560405160008051602061392e833981519152906108bd906001906134fe565b600054600114611dc05760405162461bcd60e51b815260206004820152600a6024820152695245454e5452414e435960b01b6044820152606401610875565b60026000908155819003611de7576040516301285a3f60e41b815260040160405180910390fd5b60405163ae43f23560e01b81526000906001600160a01b037f000000000000000000000000b5ce6c18e7c9b3f0a223641ef84889df878f42b3169063ae43f23590611e40908990899033908a908a908a90600401613693565b6020604051808303816000875af1158015611e5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e839190613796565b90508063ffffffff16600003611e995750612035565b60ff861660009081526009602052604090205460015463ffffffff91821691600160201b90910416611ecb82846137b3565b63ffffffff161115611ef557600154611ef2908290600160201b900463ffffffff166137d7565b91505b611f05878363ffffffff1661210e565b60ff871660009081526009602052604081208054849290611f2d90849063ffffffff166137b3565b92506101000a81548163ffffffff021916908363ffffffff1602179055507f000000000000000000000000b5ce6c18e7c9b3f0a223641ef84889df878f42b36001600160a01b0316637310c0ca88888588886040518663ffffffff1660e01b8152600401611f9f9594939291906137f4565b600060405180830381600087803b158015611fb957600080fd5b505af1158015611fcd573d6000803e3d6000fd5b50505050611fe233888463ffffffff16612370565b506040805160ff8916815263ffffffff888116602083015233828401528416606082015290517f35eb2186610c2470faf6f3a29417ac4be5492cef3ef18c72186a646cb7ecfc489181900360800190a150505b50506001600055505050565b6000828152600a6020526040812054825160ff90911691612079918391859161206c5761206c613551565b602002602001015161251f565b505050565b6040516379131a1960e01b81526000906001600160a01b037f000000000000000000000000ec420b0d0da852359e0d6a31ec322ab502c788a216906379131a19906120cd908590600401612d43565b602060405180830381865afa1580156120ea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bab9190613371565b60065460ff16612131576040516321c4e35760e21b815260040160405180910390fd5b60ff808316600081815260086020526040902080549092161461216c5782604051600162b185b160e01b031981526004016108759190612faf565b80600201546000036121935782604051637860b95160e11b81526004016108759190612faf565b6003810154610100900460ff16156121c05782604051638c12ede760e01b81526004016108759190612faf565b60015460ff84166000908152600c602052604090205463ffffffff90911610156121ff5782604051634f8acceb60e11b81526004016108759190612faf565b60015460ff84166000908152600c602052604090205463ffffffff909116906122299084906135f2565b111561224a5782604051639a12305360e01b81526004016108759190612faf565b816000036120795760405163a776bb4d60e01b815260040160405180910390fd5b60025460009061228361227e8483613827565b6125e0565b61228e338585612370565b949350505050565b6003546000906122a68382613827565b34146122d9576122b68382613827565b60405163c8116dcf60e01b81526004810191909152346024820152604401610875565b61228360006125e0565b60607f000000000000000000000000ec420b0d0da852359e0d6a31ec322ab502c788a26001600160a01b0316630db5274e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015612343573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261236b919081019061383e565b905090565b6000807f000000000000000000000000a20cf9b0874c3e46b344deaeea9c2e0c3e1db37d6001600160a01b03166375794a3c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123f591906138c3565b6040516343508b0560e01b81526001600160a01b038781166004830152602482018690529192507f000000000000000000000000a20cf9b0874c3e46b344deaeea9c2e0c3e1db37d909116906343508b0590604401600060405180830381600087803b15801561246457600080fd5b505af1158015612478573d6000803e3d6000fd5b5050505060005b838110156124de5760ff85166000818152600c60209081526040808320805460018101825590845282842001869055858352600b9091529020805460ff191690911790556124cc826135c6565b91506124d7816135c6565b905061247f565b5060015460ff85166000908152600c602052604090205463ffffffff9091161161250b5761250b8461275b565b6125166001826135df565b95945050505050565b60ff82166000908152600c60205260408120549061253d82846138dc565b60ff85166000908152600c60205260408120805492935090918390811061256657612566613551565b60009182526020808320919091015460ff88168084526008835260409384902060038101805460ff191660019081179091558101839055845191825292810182905290935090917f80130e9dfae6ecee471f4d3ad808d3e4850cd827e642e455956ec8bbc6923406910160405180910390a1505050505050565b600061260c827f0000000000000000000000000000000000000000000000000319522aba58400061284c565b9050600061263a347f0000000000000000000000000000000000000000000000000319522aba58400061284c565b905081156126f8576126976001600160a01b037f00000000000000000000000064aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d516337f00000000000000000000000067edbbf1531b28551f2075223d8a30a9ae457eca85612861565b6126f8337f00000000000000000000000025542fd6204bbbe570e358b9ebeb391513980c346126c685876135df565b6001600160a01b037f00000000000000000000000064aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d516929190612861565b8015612079576127287f00000000000000000000000067edbbf1531b28551f2075223d8a30a9ae457eca826128bf565b6120797f00000000000000000000000025542fd6204bbbe570e358b9ebeb391513980c3461275683346135df565b6128bf565b600480546005546040516305d3b1d360e41b8152928301919091526001600160401b0381166024830152600160401b810461ffff166044830152600160501b900463ffffffff166064820152600260848201526000907f00000000000000000000000000000000000000000000000000000000000000206001600160a01b031690635d3b1d309060a4016020604051808303816000875af1158015612804573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061282891906138c3565b6000908152600a60205260409020805460ff191660ff939093169290921790915550565b6000610ba88383670de0b6b3a7640000612910565b6128b9846323b872dd60e01b8585856040516024016128829392919061363d565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612936565b50505050565b600080600080600085875af19050806120795760405162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b6044820152606401610875565b600082600019048411830215820261292757600080fd5b50910281810615159190040190565b600061298b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a089092919063ffffffff16565b80519091501561207957808060200190518101906129a99190613371565b6120795760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610875565b606061228e848460008585600080866001600160a01b03168587604051612a2f91906138fe565b60006040518083038185875af1925050503d8060008114612a6c576040519150601f19603f3d011682016040523d82523d6000602084013e612a71565b606091505b5091509150612a8287838387612a8d565b979650505050505050565b60608315612afc578251600003612af5576001600160a01b0385163b612af55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610875565b508161228e565b61228e8383815115612b115781518083602001fd5b8060405162461bcd60e51b8152600401610875919061391a565b828054828255906000526020600020906003028101928215612bb15760005260206000209160030282015b82811115612bb157825482546001600160a01b0319166001600160a01b0390911617825560018084015490830155600280840154908301805460ff909216151560ff1990921691909117905560039283019290910190612b56565b50612bbd929150612bc1565b5090565b5b80821115612bbd5780546001600160a01b03191681556000600182015560028101805460ff19169055600301612bc2565b600060208284031215612c0557600080fd5b5035919050565b600060808284031215612c1e57600080fd5b50919050565b600060808284031215612c3657600080fd5b610ba88383612c0c565b803560ff81168114612c5157600080fd5b919050565b600060208284031215612c6857600080fd5b610ba882612c40565b6001600160a01b0381168114612c8657600080fd5b50565b60008083601f840112612c9b57600080fd5b5081356001600160401b03811115612cb257600080fd5b602083019150836020828501011115612cca57600080fd5b9250929050565b600080600080600060808688031215612ce957600080fd5b8535612cf481612c71565b94506020860135612d0481612c71565b93506040860135925060608601356001600160401b03811115612d2657600080fd5b612d3288828901612c89565b969995985093965092949392505050565b6001600160a01b0391909116815260200190565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715612d9557612d95612d57565b604052919050565b60006001600160401b03821115612db657612db6612d57565b5060051b60200190565b60008060408385031215612dd357600080fd5b823591506020808401356001600160401b03811115612df157600080fd5b8401601f81018613612e0257600080fd5b8035612e15612e1082612d9d565b612d6d565b81815260059190911b82018301908381019088831115612e3457600080fd5b928401925b82841015612e5257833582529284019290840190612e39565b80955050505050509250929050565b63ffffffff81168114612c8657600080fd5b600060208284031215612e8557600080fd5b8135612e9081612e61565b9392505050565b60008060408385031215612eaa57600080fd5b612eb383612c40565b946020939093013593505050565b60008083601f840112612ed357600080fd5b5081356001600160401b03811115612eea57600080fd5b6020830191508360208260051b8501011115612cca57600080fd5b60008060008060008060006080888a031215612f2057600080fd5b612f2988612c40565b965060208801356001600160401b0380821115612f4557600080fd5b612f518b838c01612ec1565b909850965060408a0135915080821115612f6a57600080fd5b612f768b838c01612ec1565b909650945060608a0135915080821115612f8f57600080fd5b50612f9c8a828b01612ec1565b989b979a50959850939692959293505050565b60ff91909116815260200190565b60008060008060008060a08789031215612fd657600080fd5b612fdf87612c40565b95506020870135612fef81612e61565b94506040870135612fff81612e61565b935060608701356001600160401b0381111561301a57600080fd5b61302689828a01612ec1565b979a9699509497949695608090950135949350505050565b6000806000806000806060878903121561305757600080fd5b86356001600160401b038082111561306e57600080fd5b61307a8a838b01612ec1565b9098509650602089013591508082111561309357600080fd5b61309f8a838b01612ec1565b909650945060408901359150808211156130b857600080fd5b506130c589828a01612ec1565b979a9699509497509295939492505050565b6000602080835260e0830160ff8551168285015281850151604081818701528087015191506060828188015280880151151560808801526080880151151560a088015260a0880151925060c080880152838351808652610100890191508685019550600094505b8085101561317a57855180516001600160a01b03168352878101518884015284015115158483015294860194600194909401939082019061313e565b5098975050505050505050565b600080610100838503121561319b57600080fd5b6131a58484612c0c565b91506131b48460808501612c0c565b90509250929050565b60008060008060008060008060a0898b0312156131d957600080fd5b88356131e481612c71565b975060208901356131f481612c71565b965060408901356001600160401b038082111561321057600080fd5b61321c8c838d01612ec1565b909850965060608b013591508082111561323557600080fd5b6132418c838d01612ec1565b909650945060808b013591508082111561325a57600080fd5b506132678b828c01612c89565b999c989b5096995094979396929594505050565b60008060008060006080868803121561329357600080fd5b61329c86612c40565b945060208601356132ac81612e61565b935060408601356132bc81612e61565b925060608601356001600160401b038111156132d757600080fd5b612d3288828901612ec1565b60008060008060008060a087890312156132fc57600080fd5b863561330781612c71565b9550602087013561331781612c71565b9450604087013593506060870135925060808701356001600160401b0381111561334057600080fd5b6130c589828a01612c89565b9182526001600160a01b0316602082015260400190565b8015158114612c8657600080fd5b60006020828403121561338357600080fd5b8151612e9081613363565b60005b838110156133a9578181015183820152602001613391565b50506000910152565b600081518084526133ca81602086016020860161338e565b601f01601f19169290920160200192915050565b6040815260006133f160408301856133b2565b905060018060a01b03831660208301529392505050565b6001600160401b0381168114612c8657600080fd5b61ffff81168114612c8657600080fd5b8135815560018101602083013561344381613408565b815460408501356134538161341d565b606086013561346181612e61565b60409190911b61ffff60401b166001600160701b0319929092166001600160401b0393909316929092171760509190911b63ffffffff60501b161790555050565b813581526080810160208301356134b881613408565b6001600160401b0316602083015260408301356134d48161341d565b61ffff16604083015260608301356134eb81612e61565b63ffffffff811660608401525092915050565b815463ffffffff8082168352602091821c169082015260018201546040820152600290910154606082015260800190565b60208082526008908201526718db185a5b505b1b60c21b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261357e57600080fd5b8301803591506001600160401b0382111561359857600080fd5b6020019150600581901b3603821315612cca57600080fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016135d8576135d86135b0565b5060010190565b81810381811115610bab57610bab6135b0565b80820180821115610bab57610bab6135b0565b6001600160a01b0394851681529290931660208301526040820152606081019190915260a06080820181905260009082015260c00190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b81835260006001600160fb1b0383111561367a57600080fd5b8260051b80836020870137939093016020019392505050565b60ff8716815263ffffffff86811660208301526001600160a01b03861660408301528416606082015260a0608082018190526000906110e59083018486613661565b6000602082840312156136e757600080fd5b8135612e9081612c71565b60006020828403121561370457600080fd5b8135612e9081613363565b60006020828403121561372157600080fd5b8151612e9081612c71565b813561373781612e61565b63ffffffff8116905081548163ffffffff198216178355602084013561375c81612e61565b6001600160401b03199190911690911760209190911b63ffffffff60201b1617815560408201356001820155606090910135600290910155565b6000602082840312156137a857600080fd5b8151612e9081612e61565b63ffffffff8181168382160190808211156137d0576137d06135b0565b5092915050565b63ffffffff8281168282160390808211156137d0576137d06135b0565b60ff86168152600063ffffffff808716602084015280861660408401525060806060830152612a82608083018486613661565b8082028115828204841417610bab57610bab6135b0565b6000602080838503121561385157600080fd5b82516001600160401b0381111561386757600080fd5b8301601f8101851361387857600080fd5b8051613886612e1082612d9d565b81815260059190911b820183019083810190878311156138a557600080fd5b928401925b82841015612a82578351825292840192908401906138aa565b6000602082840312156138d557600080fd5b5051919050565b6000826138f957634e487b7160e01b600052601260045260246000fd5b500690565b6000825161391081846020870161338e565b9190910192915050565b602081526000610ba860208301846133b256fed168ea0c23f28c79e79434ab061118c9928940fddf526760e980a0b2a9a5771ba264697066735822122000ed51f2b32f2ca5a95d8272776392bba8517d5245cc4afd1af10a465b5336ab64736f6c63430008110033

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

0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000ec420b0d0da852359e0d6a31ec322ab502c788a2000000000000000000000000a20cf9b0874c3e46b344deaeea9c2e0c3e1db37d00000000000000000000000064aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5000000000000000000000000b5ce6c18e7c9b3f0a223641ef84889df878f42b300000000000000000000000025542fd6204bbbe570e358b9ebeb391513980c3400000000000000000000000067edbbf1531b28551f2075223d8a30a9ae457eca0000000000000000000000000000000000000000000000000319522aba584000

-----Decoded View---------------
Arg [0] : _vrfCoordinator (address): 0x0000000000000000000000000000000000000020
Arg [1] : _gameRegistry (address): 0xeC420B0d0dA852359e0D6a31Ec322AB502C788a2
Arg [2] : _honeyJarAddress (address): 0xa20CF9B0874c3E46b344DEAEEa9c2e0C3E1db37d
Arg [3] : _paymentToken (address): 0x64aa3364F17a4D01c6f1751Fd97C2BD3D7e7f1D5
Arg [4] : _gatekeeper (address): 0xB5cE6c18E7c9B3f0a223641Ef84889df878f42B3
Arg [5] : _jani (address): 0x25542Fd6204bbBe570E358B9ebeb391513980c34
Arg [6] : _beekeeper (address): 0x67EDbbF1531b28551f2075223D8a30a9AE457ECa
Arg [7] : _honeyJarShare (uint256): 223300000000000000

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000020
Arg [1] : 000000000000000000000000ec420b0d0da852359e0d6a31ec322ab502c788a2
Arg [2] : 000000000000000000000000a20cf9b0874c3e46b344deaeea9c2e0c3e1db37d
Arg [3] : 00000000000000000000000064aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5
Arg [4] : 000000000000000000000000b5ce6c18e7c9b3f0a223641ef84889df878f42b3
Arg [5] : 00000000000000000000000025542fd6204bbbe570e358b9ebeb391513980c34
Arg [6] : 00000000000000000000000067edbbf1531b28551f2075223d8a30a9ae457eca
Arg [7] : 0000000000000000000000000000000000000000000000000319522aba584000


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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