AVAX Price: $25.23 (-5.76%)
Gas: 1.5 nAVAX
 

Overview

AVAX Balance

Avalanche C-Chain LogoAvalanche C-Chain LogoAvalanche C-Chain Logo0 AVAX

AVAX Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Play Game571849462025-02-12 0:29:214 hrs ago1739320161IN
0x02C1eDfb...ee4c10e11
0.42 AVAX0.001452572.5
Play Game571776142025-02-11 20:45:168 hrs ago1739306716IN
0x02C1eDfb...ee4c10e11
0.105 AVAX0.00067791.5
Play Game571750122025-02-11 19:30:449 hrs ago1739302244IN
0x02C1eDfb...ee4c10e11
0.21 AVAX0.001161052.5
Play Game571749272025-02-11 19:28:329 hrs ago1739302112IN
0x02C1eDfb...ee4c10e11
3.15 AVAX0.001277122.75
Play Game571748852025-02-11 19:27:389 hrs ago1739302058IN
0x02C1eDfb...ee4c10e11
0.21 AVAX0.000580521.25
Play Game571748682025-02-11 19:27:049 hrs ago1739302024IN
0x02C1eDfb...ee4c10e11
0.42 AVAX0.000574341.18
Play Game571748422025-02-11 19:26:219 hrs ago1739301981IN
0x02C1eDfb...ee4c10e11
0.315 AVAX0.000768641.51
Play Game571748112025-02-11 19:25:389 hrs ago1739301938IN
0x02C1eDfb...ee4c10e11
0.21 AVAX0.000928842
Play Game571747862025-02-11 19:25:039 hrs ago1739301903IN
0x02C1eDfb...ee4c10e11
0.315 AVAX0.000641371.26
Play Game571747652025-02-11 19:24:229 hrs ago1739301862IN
0x02C1eDfb...ee4c10e11
0.42 AVAX0.000686291.41
Play Game571747372025-02-11 19:23:379 hrs ago1739301817IN
0x02C1eDfb...ee4c10e11
0.525 AVAX0.000717731.41
Play Game571747232025-02-11 19:23:079 hrs ago1739301787IN
0x02C1eDfb...ee4c10e11
0.315 AVAX0.000654831.41
Play Game571747062025-02-11 19:22:379 hrs ago1739301757IN
0x02C1eDfb...ee4c10e11
0.315 AVAX0.000580521.25
Play Game571746872025-02-11 19:21:599 hrs ago1739301719IN
0x02C1eDfb...ee4c10e11
0.42 AVAX0.000664161.25
Play Game571746692025-02-11 19:21:249 hrs ago1739301684IN
0x02C1eDfb...ee4c10e11
0.21 AVAX0.000574341.18
Play Game571746512025-02-11 19:20:509 hrs ago1739301650IN
0x02C1eDfb...ee4c10e11
0.315 AVAX0.000580521.25
Play Game571746342025-02-11 19:20:179 hrs ago1739301617IN
0x02C1eDfb...ee4c10e11
0.21 AVAX0.000608391.31
Play Game571746152025-02-11 19:19:379 hrs ago1739301577IN
0x02C1eDfb...ee4c10e11
0.315 AVAX0.000768631.51
Play Game571745902025-02-11 19:19:019 hrs ago1739301541IN
0x02C1eDfb...ee4c10e11
0.315 AVAX0.000768641.51
Play Game571745752025-02-11 19:18:319 hrs ago1739301511IN
0x02C1eDfb...ee4c10e11
0.21 AVAX0.001216842.5
Play Game571745562025-02-11 19:17:579 hrs ago1739301477IN
0x02C1eDfb...ee4c10e11
0.21 AVAX0.00146023
Play Game571745292025-02-11 19:17:229 hrs ago1739301442IN
0x02C1eDfb...ee4c10e11
0.21 AVAX0.001393263
Play Game571745102025-02-11 19:16:539 hrs ago1739301413IN
0x02C1eDfb...ee4c10e11
0.315 AVAX0.001527113
Play Game571744682025-02-11 19:16:069 hrs ago1739301366IN
0x02C1eDfb...ee4c10e11
0.21 AVAX0.00073011.5
Play Game571744382025-02-11 19:15:139 hrs ago1739301313IN
0x02C1eDfb...ee4c10e11
0.21 AVAX0.001216812.5
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To
571849462025-02-12 0:29:214 hrs ago1739320161
0x02C1eDfb...ee4c10e11
0.02 AVAX
571849462025-02-12 0:29:214 hrs ago1739320161
0x02C1eDfb...ee4c10e11
0.4 AVAX
571776142025-02-11 20:45:168 hrs ago1739306716
0x02C1eDfb...ee4c10e11
0.005 AVAX
571776142025-02-11 20:45:168 hrs ago1739306716
0x02C1eDfb...ee4c10e11
0.1 AVAX
571750122025-02-11 19:30:449 hrs ago1739302244
0x02C1eDfb...ee4c10e11
0.01 AVAX
571750122025-02-11 19:30:449 hrs ago1739302244
0x02C1eDfb...ee4c10e11
0.2 AVAX
571749272025-02-11 19:28:329 hrs ago1739302112
0x02C1eDfb...ee4c10e11
0.15 AVAX
571749272025-02-11 19:28:329 hrs ago1739302112
0x02C1eDfb...ee4c10e11
3 AVAX
571748852025-02-11 19:27:389 hrs ago1739302058
0x02C1eDfb...ee4c10e11
0.01 AVAX
571748852025-02-11 19:27:389 hrs ago1739302058
0x02C1eDfb...ee4c10e11
0.2 AVAX
571748682025-02-11 19:27:049 hrs ago1739302024
0x02C1eDfb...ee4c10e11
0.02 AVAX
571748682025-02-11 19:27:049 hrs ago1739302024
0x02C1eDfb...ee4c10e11
0.4 AVAX
571748422025-02-11 19:26:219 hrs ago1739301981
0x02C1eDfb...ee4c10e11
0.015 AVAX
571748422025-02-11 19:26:219 hrs ago1739301981
0x02C1eDfb...ee4c10e11
0.3 AVAX
571748112025-02-11 19:25:389 hrs ago1739301938
0x02C1eDfb...ee4c10e11
0.01 AVAX
571748112025-02-11 19:25:389 hrs ago1739301938
0x02C1eDfb...ee4c10e11
0.2 AVAX
571747862025-02-11 19:25:039 hrs ago1739301903
0x02C1eDfb...ee4c10e11
0.015 AVAX
571747862025-02-11 19:25:039 hrs ago1739301903
0x02C1eDfb...ee4c10e11
0.3 AVAX
571747652025-02-11 19:24:229 hrs ago1739301862
0x02C1eDfb...ee4c10e11
0.02 AVAX
571747652025-02-11 19:24:229 hrs ago1739301862
0x02C1eDfb...ee4c10e11
0.4 AVAX
571747372025-02-11 19:23:379 hrs ago1739301817
0x02C1eDfb...ee4c10e11
0.025 AVAX
571747372025-02-11 19:23:379 hrs ago1739301817
0x02C1eDfb...ee4c10e11
0.5 AVAX
571747232025-02-11 19:23:079 hrs ago1739301787
0x02C1eDfb...ee4c10e11
0.015 AVAX
571747232025-02-11 19:23:079 hrs ago1739301787
0x02C1eDfb...ee4c10e11
0.3 AVAX
571747062025-02-11 19:22:379 hrs ago1739301757
0x02C1eDfb...ee4c10e11
0.015 AVAX
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Roulette

Compiler Version
v0.8.22+commit.4fc1097e

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 24 : Roulette.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;

import "@openzeppelin/contracts/access/Ownable.sol";
import "../CentralGameBase.sol";
import "../GameBet.sol";
import "../GameVRF.sol";
import "../IRakeDistributor.sol";
import "../ITreasury.sol";

/// Roulette; supports a variety of bet types, spin the wheel to pick a number from 1-36.
contract Roulette is CentralGameBase, GameBet, GameVRF {
    /// Many types of bets are supported, disambiguated by this enum.
    /// Requires a betValue to know exactly what kind of bet is being placed.
    enum BetType {
        /// The exact number.
        NUMBER,

        /// Red (0)
        /// Black (1)
        RED_BLACK,

        /// Odd (0)
        /// Even (1)
        ODD_EVEN,

        /// 1-12 (0)
        /// 13-24 (1)
        /// 15-36 (2)
        THIRDS,

        /// 1-18 (0)
        /// 9-36 (1)
        HALVES,

        /// Every 3rd number in the series:
        /// 1-34 (0)
        /// 2-35 (1)
        /// 3-36 % 3 (2)
        ROWS,

        /// Three numbers in a column:
        /// M = N * 3
        /// [M + 1, M + 2, M + 3]
        /// From 0-11.
        COLUMNS,

        /// Two numbers vertically:
        /// M = 2 * N - (N // 2) + (N + 1) % 2
        /// [M, M+1]
        /// From 0-23.
        PAIR_V,

        /// Two numbers horizontally:
        /// M = N + 1
        /// [M, M+3]
        /// From 0-35.
        PAIR_H,

        ///First 2 are paired with 0, only 3 slots:
        /// 0: [0, 1, 2]
        /// 1: [0, 2, 3]
        /// Then apply the following formula:
        /// K = N - 2;
        /// M = 2 * K - (K // 2) + (K + 1) % 2
        /// [M, M+1, M+3, M+4]
        /// From 0-23
        CORNERS
    }

    /// An individual bet placed by the user.
    /// A game is composed of an array of bets, which don't need to be unique.
    struct Bet {
        /// Amount wagered in this bet.
        uint256 betAmount;
        /// The discriminator for the type of bet.
        BetType betType;
        /// Value used along with the betType to determine what the actual bet is.
        uint8 betValue;
    }

    /// Standardized game complete info.
    struct RoundInfo {
        RoundState state;
        uint256 sent;
        uint8 selected;
    }

    /// Emitted when game is started.
    event GameStarted(
        uint256 indexed gameId,
        address indexed creator,
        uint8 subgame,
        uint256 numRounds,
        uint256 betPerRound,
        uint256 rakePerRound,
        Bet[] choices,
        address referrer,
        FulfillmentMethod method
    );

    /// Emitted when game is fully completed with no other actions available.
    event WinnerPicked(uint256 indexed gameId, uint8 subgame, RoundInfo[] results);

    /// Per-game result payouts, by gameId.
    mapping(uint256 => uint256[37]) public payoutsByGameId;

    /// Contract can be funded.
    receive() external payable {}

    /// Constructor populates generic Chainlink values.
    constructor() GameVRF() {}

    /// Create a new game.
    /// The amounts in choices are interpreted as per-round bets.
    function playGame(
        uint256 numRounds,
        Bet[] memory userChoices,
        string memory referralCode,
        FulfillmentMethod method
    ) external payable isEOA isNotPaused isEnoughTreasury returns (uint256) {
        require(userChoices.length > 0, "Place at least one bet, pleb");

        uint256[37] memory payouts = calculatePayouts(userChoices);
        IRakeDistributor rakeDistributor = IRakeDistributor(rakeDistributorAddress);

        BetDetails memory details = getBetDetails(numRounds, userChoices, payouts, rakeDistributor);
        currentGameId++;
        GameInfo memory gi;
        gi.gameId = currentGameId;
        gi.betPerRound = details.betPerRound;
        gi.rakePerRound = details.rakePerRound;
        gi.creator = msg.sender;
        gi.referrer = rakeDistributor.getReferrerFromGamerAndCode(msg.sender, referralCode);
        gi.subgame = 9;
        gi.numRounds = numRounds;
        gi.state = GameState.CALCULATING;

        {
            (bool success,) = payable(treasuryAddress).call{value: details.bet}("");
            require(success, "Failed to send to treasury");
        }

        payoutsByGameId[gi.gameId] = payouts;
        gameById[gi.gameId] = gi;

        emit GameStarted(
            gi.gameId,
            msg.sender,
            gi.subgame,
            numRounds,
            gi.betPerRound,
            gi.rakePerRound,
            userChoices,
            gi.referrer,
            method
        );
        rakeDistributor.distributeReferredRake{value: details.rake}(gi.gameId, msg.sender, gi.referrer);
        _requestGameFulfillment(gi.gameId, method);
        return gi.gameId;
    }

    /// Receives the random number from VRF and calculates win/loss/tie.
    /// Transfers the appropriate amount of funds from treasury to the user on wins.
    function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal override {
        uint256 gameId = gameIdByRequestId[requestId];
        require(gameId != 0, "Request already fulfilled");

        GameInfo storage gi = gameById[gameId];
        require(gi.state == GameState.CALCULATING, "Game not waiting for results");

        uint256[37] memory payouts = payoutsByGameId[gameId];
        uint256 numRounds = gi.numRounds;

        RoundInfo[] memory results = new RoundInfo[](numRounds);
        uint256 amountToUser;

        for (uint256 i; i < numRounds; ++i) {
            uint256 roundRandom = uint256(keccak256(abi.encode(randomWords[0], i)));
            uint8 roundValue = uint8(roundRandom % 37);
            uint256 payout = payouts[roundValue];
            RoundInfo memory result = results[i];
            result.selected = roundValue;

            // Any payout in roulette is a win since all multipliers are greater than 1.
            if (payout > 0) {
                result.state = RoundState.WON;
                result.sent = payout;
                amountToUser += payout;
            } else {
                result.state = RoundState.LOST;
            }
        }

        emit WinnerPicked(gameId, gi.subgame, results);
        address creator = gi.creator;
        delete gameById[gameId];
        delete gameIdByRequestId[requestId];

        if (amountToUser > 0) {
            ITreasury(treasuryAddress).sendPayout(creator, amountToUser);
        }
    }

    /// Triggers VRF process for a given game in case of emergency.
    function forceRequestWinner(uint256 gameId, FulfillmentMethod method) external onlyOwner {
        GameInfo storage gi = gameById[gameId];
        require(gi.state != GameState.CLOSED, "already closed");
        _requestGameFulfillment(gi.gameId, method);
    }

    /// Roulette has a more complicated betting mechanism than most other games. We need to calculate the bet amount
    /// (and validate it) and also determine the highest possible payout for any number across all bets.
    function getBetDetails(uint256 numRounds, Bet[] memory userChoices, uint256[37] memory payouts, IRakeDistributor rakeDistributor) internal returns (BetDetails memory) {
        uint256 totalBet;
        for (uint256 i; i < userChoices.length; ++i) {
            totalBet += userChoices[i].betAmount;
        }

        uint256 maxPayout;
        for (uint256 i; i < 37; ++i) {
            uint256 p = payouts[i];
            if (p > maxPayout) {
                maxPayout = p;
            }
        }

        // Since individual bets are per-round, adjust values to the total amount.
        totalBet *= numRounds;
        maxPayout *= numRounds;

        BetDetails memory details = validateBetWithMaxPayoutValue(
            treasuryAddress.balance,
            rakeDistributor.getTotalRake(),
            numRounds,
            maxPayout
        );

        require(totalBet == details.bet, "tx value did not match bet value");

        return details;
    }

    /// Converts a list of bet inputs into a list of payouts for every possible selected number.
    function calculatePayouts(Bet[] memory bets) internal pure returns (uint256[37] memory payouts) {
        uint256 betCount = bets.length;
        for (uint256 bi; bi < betCount; ++bi) {
            Bet memory bet = bets[bi];
            require(bet.betAmount > 0, "Place a bet with amount greater than zero, pleb");

            if (bet.betType == BetType.NUMBER) {
                require(bet.betValue < 37, "numbers must be from 0-36");
                payouts[bet.betValue] += bet.betAmount * 36;
            } else if (bet.betType == BetType.RED_BLACK) {
                require(bet.betValue < 2, "red/black bet value must be 0 or 1");
                uint256 twoTimesBet = bet.betAmount * 2;
                for (uint256 j = 1 + bet.betValue; j < 11; j += 2) {
                    payouts[j] += twoTimesBet;
                }
                for (uint256 j = 12 - bet.betValue; j < 19; j += 2) {
                    payouts[j] += twoTimesBet;
                }
                for (uint256 j = 19 + bet.betValue; j < 29; j += 2) {
                    payouts[j] += twoTimesBet;
                }
                for (uint256 j = 30 - bet.betValue; j < 37; j += 2) {
                    payouts[j] += twoTimesBet;
                }
            } else if (bet.betType == BetType.ODD_EVEN) {
                require(bet.betValue < 2, "odd/even bet value must be 0 or 1");
                uint256 twoTimesBet = bet.betAmount * 2;
                for (uint256 j = 1 + bet.betValue; j < 37; j += 2) {
                    payouts[j] += twoTimesBet;
                }
            } else if (bet.betType == BetType.THIRDS) {
                require(bet.betValue < 3, "thirds bet value must be 0 or 1 or 2");
                uint8 start = 1 + 12 * bet.betValue;
                uint8 stop = start + 12;
                uint256 threeTimesBet = bet.betAmount * 3;
                for (uint256 j = start; j < stop; ++j) {
                    payouts[j] += threeTimesBet;
                }
            } else if (bet.betType == BetType.HALVES) {
                require(bet.betValue < 2, "halves bet value must be 0 or 1");
                uint8 start = 1 + 18 * bet.betValue;
                uint8 stop = start + 18;
                uint256 twoTimesBet = bet.betAmount * 2;
                for (uint256 j = start; j < stop; ++j) {
                    payouts[j] += twoTimesBet;
                }
            } else if (bet.betType == BetType.ROWS) {
                require(bet.betValue < 3, "rows bet value must be 0 or 1 or 2");
                uint256 threeTimesBet = bet.betAmount * 3;
                for (uint256 j = 1 + bet.betValue; j < 37; j += 3) {
                    payouts[j] += threeTimesBet;
                }
            } else if (bet.betType == BetType.COLUMNS) {
                require(bet.betValue < 12, "columns bet value must be less than 12");
                uint256 twelveTimesBet = bet.betAmount * 12;
                uint8 start = 3 * bet.betValue + 1;
                uint8 stop = start + 3;
                for (uint256 j = start; j < stop; ++j) {
                    payouts[j] += twelveTimesBet;
                }
            } else if (bet.betType == BetType.PAIR_V) {
                require(bet.betValue < 24, "vertical pair bet value must be less than 24");
                uint256 eighteenTimesBet = bet.betAmount * 18;
                uint8 n = bet.betValue;
                uint8 start = 2 * n - n / 2 + (n + 1) % 2;
                uint8 stop = start + 2;
                for (uint256 j = start; j < stop; ++j) {
                    payouts[j] += eighteenTimesBet;
                }
            } else if (bet.betType == BetType.PAIR_H) {
                require(bet.betValue < 36, "horizontal pair bet value must be less than 36");
                uint256 eighteenTimesBet = bet.betAmount * 18;
                uint8 n = bet.betValue;
                if (n < 3) {
                    // Betting on 1/2/3 includes 0 and one actual number.
                    payouts[0] += eighteenTimesBet;
                    payouts[n + 1] += eighteenTimesBet;
                } else {
                    uint8 m = n - 2; // 3 is the first 'normal' hz, adjust it to 1
                    payouts[m] += eighteenTimesBet; // left
                    payouts[m + 3] += eighteenTimesBet; // right
                }
            } else if (bet.betType == BetType.CORNERS) {
                require(bet.betValue < 24, "corners bet value must be less than 24");
                uint8 n = bet.betValue;
                if (n < 2) {
                    uint256 twelveTimesBet = bet.betAmount * 12;
                    payouts[0] += twelveTimesBet;
                    payouts[2] += twelveTimesBet;
                    // n=0 uses 1, n=1 uses 3
                    payouts[n * 2 + 1] += twelveTimesBet;
                } else {
                    uint256 nineTimesBet = bet.betAmount * 9;
                    uint8 k = n - 2;
                    uint8 m = 2 * k - k / 2 + (k + 1) % 2;
                    payouts[m] += nineTimesBet; // lower left
                    payouts[m + 1] += nineTimesBet; // upper left
                    payouts[m + 3] += nineTimesBet; // lower right
                    payouts[m + 4] += nineTimesBet; // upper right
                }
            } else {
                revert("internal error: unexpected bet type");
            }
        }
        return payouts;
    }

    /// Utility function for the front end to call to determine the maximum payout for a set of bets.
    function calculateMaxPayout(Bet[] memory userChoices) public pure returns (uint256 maxPayout) {
        require(userChoices.length > 0, "Place at least one bet, pleb");
        uint256[37] memory payouts = calculatePayouts(userChoices);

        for (uint256 i; i < 37; ++i) {
            uint256 p = payouts[i];
            if (p > maxPayout) {
                maxPayout = p;
            }
        }
        return maxPayout;
    }

    /// Compute the max bet, for use by the UI. Slightly trims the actual max amount.
    function getMaxBetPerRound(Bet[] memory userChoices) external view returns (uint256 safeMaxPotentialBet) {
        uint256 maxPotentialWin = treasuryAddress.balance / maxBetDivisor;
        uint256 maxPotentialBet = maxPotentialWin / calculateMaxPayout(userChoices);
        safeMaxPotentialBet = maxPotentialBet * 100 / 95;
    }
}

File 2 of 24 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 3 of 24 : CentralGameBase.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;

import "@openzeppelin/contracts/access/Ownable2Step.sol";
import "./Rescue.sol";
import "./ITreasury.sol";

/// Centralized handling of a lot of stuff our games need. All games inherit from this.
abstract contract CentralGameBase is Ownable2Step, Rescue {
    /// Status of an individual betting round in a game.
    /// Not all states apply to all games (e.g. TIE).
    enum RoundState {
        UNKNOWN, // Should never be used.
        LOST,
        TIE,
        WON
    }

    /// The status of the game, consisting of a set of rounds.
    enum GameState {
        /// Waiting for RNG.
        CALCULATING,
        /// Game is finalized and no actions can be taken.
        CLOSED,
        /// For PvP games, waiting for 1 or more other players.
        WAITING_FOR_PLAYER,
        /// For PvP games, the game creator canceled play.
        CANCELED
    }

    /// Every game played has a GameInfo created for it.
    /// The details for the individual game are stored separately per game.
    struct GameInfo {
        uint256 gameId;
        uint256 betPerRound;
        uint256 rakePerRound;
        uint256 numRounds;
        address creator;
        address referrer;
        uint8 subgame;
        GameState state;
    }

    /// Incrementing counter for the current gameId.
    uint256 public currentGameId;

    /// Standardized GameInfo structs mapped by gameId.
    mapping(uint256 => GameInfo) public gameById;

    /// Global switch to disallow play.
    bool public paused;

    /// Address of the rake distributor.
    address public rakeDistributorAddress;

    /// Address of the referral tracker
    address public referralTrackerAddress;

    /// Address of the treasury.
    address public treasuryAddress;

    /// Prevent contracts from playing with this modifier.
    modifier isEOA() {
        require(tx.origin == msg.sender, "No contracts allowed");
        _;
    }

    /// Prevent play when the game is paused.
    modifier isNotPaused() {
        require(!paused, "Game is paused");
        _;
    }

    modifier isEnoughTreasury() {
        require(!ITreasury(treasuryAddress).isTreasuryTooLow(), "Treasury is too low!");
        _;
    }

    /// Fetch details about an individual game.
    function getGameInfo(uint256 gameId) public view returns (GameInfo memory) {
        return gameById[gameId];
    }

    /// Fetch details about many games simultaneously.
    /// This is just a helper function for offline use.
    function getManyGameInfo(uint256[] memory gameIds) public view returns (GameInfo[] memory) {
        uint256 gameIdLength = gameIds.length;
        GameInfo[] memory ret = new GameInfo[](gameIdLength);
        for (uint256 i; i < gameIdLength; ++i) {
            ret[i] = gameById[gameIds[i]];
        }

        return ret;
    }

    function setPaused(bool paused_) public onlyOwner {
        paused = paused_;
    }

    function setRakeDistributorAddress(address rakeAddress) external onlyOwner {
        rakeDistributorAddress = rakeAddress;
    }

    function setTreasuryAddress(address _treasuryAddress) external onlyOwner {
        treasuryAddress = _treasuryAddress;
    }

    function setReferralTrackerAddress(address _referralTrackerAddress) external onlyOwner {
        referralTrackerAddress = _referralTrackerAddress;
    }

    function setCurrentGameId(uint256 gameId_) external onlyOwner {
        currentGameId = gameId_;
    }
}

File 4 of 24 : GameBet.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;

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

abstract contract GameBet is Ownable2Step {
    /// Minimum allowed bet.
    uint256 public minBet = .5 ether;

    /// Maximum single bet amount is treasury divided by this.
    uint256 public maxBetDivisor = 20;

    /// Maxmimum number of rounds that can be played in a single game.
    //
    /// The total amount bet is the limiting factor, so this is just a reasonable-ness limit
    /// on the number of rounds allowed.
    uint256 public maxConsecutiveRounds = 10;

    /// Bet amounts per round must be a multiple of this
    uint256 public betMultiplePerRound = .01 ether;

    struct BetDetails {
        uint256 bet;
        uint256 rake;
        uint256 betPerRound;
        uint256 rakePerRound;
        uint256 payoutPerRound;
    }

    function validateBet(uint256 treasuryBalance, uint256 totalRake, uint256 numRounds) internal returns (BetDetails memory) {
        // TODO: this is retarded, pass the bet in instead?
        uint256 bet = (msg.value * 10000 / (totalRake + 10000));
        uint256 rake = msg.value - bet;

        require(bet >= minBet, "Gamble more, pleb");
        // TODO: This should probably apply to the potentialWin instead of the bet amount
        // Currently this assumes 2x win values?
        require(bet <= (treasuryBalance / maxBetDivisor), "Gamble less, king");

        require(numRounds > 0, "Gamble at least once, pleb");
        require(numRounds <= maxConsecutiveRounds, "Gamble fewer times, king");

        uint256 betPerRound = bet / numRounds;
        require(bet % numRounds == 0, "Gamble an amount divisible by your bets, pleb");
        require(betPerRound % betMultiplePerRound == 0, "Gamble the right amount per bet, pleb");

        uint256 rakePerRound = rake / numRounds;
        require(rake % numRounds == 0, "Internal error; wrong rake amount");

        return BetDetails({
            bet: bet,
            rake: rake,
            betPerRound: betPerRound,
            rakePerRound: rakePerRound,
            payoutPerRound: 0 // Not supported
        });
    }

    function validateBetWithPayout(uint256 treasuryBalance, uint256 totalRake, uint256 numRounds,
        uint256 betNumerator, uint256 betDenominator) internal returns (BetDetails memory) {
        uint256 bet = (msg.value * 10000 / (totalRake + 10000));
        uint256 maxPayoutValue = bet * betNumerator / betDenominator;
        return validateBetWithMaxPayoutValue(treasuryBalance, totalRake, numRounds, maxPayoutValue);
    }

    function validateBetWithMaxPayoutValue(uint256 treasuryBalance, uint256 totalRake, uint256 numRounds,
        uint256 maxPayoutValue) internal returns (BetDetails memory) {
        require(numRounds > 0, "Gamble at least one round, pleb");
        uint256 bet = (msg.value * 10000 / (totalRake + 10000));
        uint256 rake = msg.value - bet;

        require(bet >= minBet, "Gamble more, pleb");

        require(numRounds > 0, "Gamble at least once, pleb");
        require(numRounds <= maxConsecutiveRounds, "Gamble fewer times, king");

        uint256 betPerRound = bet / numRounds;
        require(bet % numRounds == 0, "Gamble an amount divisible by your bets, pleb");
        require(betPerRound % betMultiplePerRound == 0, "Gamble the right amount per bet, pleb");

        uint256 rakePerRound = rake / numRounds;
        require(rake % numRounds == 0, "Internal error; wrong rake amount");

        uint256 maxPayoutPerRound = maxPayoutValue / numRounds;
        require(betPerRound < maxPayoutPerRound, "Place a gamble that won't guarantee you lose, pleb");
        require(maxPayoutPerRound - betPerRound <= (treasuryBalance / maxBetDivisor), "Gamble less, king");

        return BetDetails({
            bet: bet,
            rake: rake,
            betPerRound: betPerRound,
            rakePerRound: rakePerRound,
            payoutPerRound: maxPayoutPerRound
        });
    }

    function setMinBet(uint256 minBet_) external onlyOwner {
        minBet = minBet_;
    }

    function setMaxBetDivisor(uint256 maxBetDivisor_) external onlyOwner {
        maxBetDivisor = maxBetDivisor_;
    }

    function setMaxConsecutiveRounds(uint256 maxConsecutiveRounds_) external onlyOwner {
        maxConsecutiveRounds = maxConsecutiveRounds_;
    }

    function setBetMultiplePerRound(uint256 betMultiplePerRound_) external onlyOwner {
        betMultiplePerRound = betMultiplePerRound_;
    }
}

File 5 of 24 : GameVRF.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;

import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import "@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol";
import "./FerdyMultiVRFConsumerBase.sol";

/// We have 3 different potential mechanisms for requesting randomness.
/// Avax: Chainlink / FerdyRNG
/// Base: FerdyRNG
/// FerdyNet: On-chain via difficulty parameter
//
// These utilities abstracts that fact from each game.
// The FerdyRNG and on-chain providers both copy the ChainLink coordinator mechanism.
abstract contract GameVRF is FerdyMultiVRFConsumerBase {
    enum FulfillmentMethod {
        CHAINLINK, // 0
        FERDY, // 1
        ONCHAIN // 2 - no longer used, was for ferdynet
    }

    struct CoordinatorInfo {
        bytes32 gasLane;
        address coordAddress;
        uint64 subscriptionId;
        uint32 callbackGasLimit;
    }

    mapping(FulfillmentMethod => CoordinatorInfo) private coordinatorInfoByMethod;
    /// Minimum on AVAX is 2; might need changing for other chains.
    uint16 private _requestConfirmations = 2;
    /// We always request one word, and just permute it in the fulfillment as required.
    uint32 private constant NUM_WORDS = 1;

    /// Game IDs mapped by VRF request ID.
    /// Keeps track of which request was for which game, so they can be fulfilled
    mapping(uint256 => uint256) public gameIdByRequestId;

    /// Emitted when a VRF request has been sent for a game.
    event RequestedGameWinner(uint256 indexed requestId, address indexed vrfCoordinator, uint256 indexed gameId);

    constructor() {}

    function setVRFCoordinatorInfoByMethod(FulfillmentMethod method, bytes32 gasLane, address coordAddress, uint64 subscriptionId, uint32 callbackGasLimit) external onlyOwner {
        coordinatorInfoByMethod[method] = CoordinatorInfo(gasLane, coordAddress, subscriptionId, callbackGasLimit);
        setVRFCoordinator(coordAddress, true);
    }

    /// Requests VRF for a game and tracks the mapping from request to game.
    function _requestGameFulfillment(uint256 gameId, FulfillmentMethod method) internal {
        address coordinatorAddress = coordinatorInfoByMethod[method].coordAddress;
        require(coordinatorAddress != address(0), "Invalid VRF address");
        VRFCoordinatorV2Interface vrfCoordinator = VRFCoordinatorV2Interface(coordinatorAddress);

        uint256 requestId = vrfCoordinator.requestRandomWords(
            coordinatorInfoByMethod[method].gasLane,
            coordinatorInfoByMethod[method].subscriptionId,
            _requestConfirmations,
            coordinatorInfoByMethod[method].callbackGasLimit,
            NUM_WORDS
        );

        gameIdByRequestId[requestId] = gameId;
    }

    function getRequestConfirmations() public view returns (uint16) {
        return _requestConfirmations;
    }

    function setRequestConfirmations(uint16 requestConfirmations) public onlyOwner {
        _requestConfirmations = requestConfirmations;
    }

    function getNumWords() public pure returns (uint256) {
        return NUM_WORDS;
    }
}

File 6 of 24 : IRakeDistributor.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;

interface IRakeDistributor {
    function getTotalRake() external view returns (uint256);

    function distributeReferredRake(uint256 gameId, address player, address referrer) external payable;

    function getReferrerFromGamerAndCode(address gamer, string memory referralCode) external view returns (address);

    function setOperator(address operator, bool isValid) external;
}

File 7 of 24 : ITreasury.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;

interface ITreasury {
    function sendPayout(address gamer, uint256 amount) external;

    function setGame(address game, bool isValid) external;

    function isTreasuryTooLow() external returns (bool);
}

File 8 of 24 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (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;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

File 9 of 24 : Ownable2Step.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.0;

import "./Ownable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

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

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

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
        _transferOwnership(sender);
    }
}

File 10 of 24 : Rescue.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/access/Ownable2Step.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

abstract contract Rescue is Ownable2Step {
    /// Withdraws native funds to contract owner in case of emergency.
    function rescueNative(uint256 amount) external onlyOwner {
        (bool success,) = payable(msg.sender).call{value: amount}("");
        require(success);
    }

    /// Withdraws ERC20 to contract owner in case of emergency.
    function rescueERC20(address tokenAddress) public onlyOwner {
        IERC20 token = IERC20(tokenAddress);
        token.transfer(msg.sender, token.balanceOf(address(this)));
    }

    /// Withdraws ERC721 to contract owner in case of emergency.
    function rescueERC721(address tokenAddress, uint256 tokenId) public onlyOwner {
        IERC721 token = IERC721(tokenAddress);
        token.transferFrom(address(this), msg.sender, tokenId);
    }
}

File 11 of 24 : 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 24 : 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 24 : FerdyMultiVRFConsumerBase.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;

/** ****************************************************************************
 * @notice Interface for contracts using VRF randomness
 * Modified version of Chainlinks VRFConsumerBase to use multiple coordinators
 * ***************************************************************************** 
 * 
 * @dev Calling contracts must inherit from VRFConsumerBase
 * 
 * @dev USAGE
 * 
 * @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 Colliding `requestId`s are cryptographically impossible as long as seeds
 * @dev differ.
**/

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

abstract contract FerdyMultiVRFConsumerBase is Ownable2Step {
    error OnlyCoordinatorCanFulfill(address have);

    /// List of coordinators that can send randomness.
    /// We support 3 different types, not just Chainlink.
    mapping(address => bool) private vrfCoordinators;

    function setVRFCoordinator(address coordinator, bool active) public onlyOwner {
        vrfCoordinators[coordinator] = active;
    }

    /**
     * @notice fulfillRandomWords handles the VRF response. Your contract must
     * @notice implement it.
     *
     * @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;

    // rawFulfillRandomWords 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 (vrfCoordinators[msg.sender] != true) {
            revert OnlyCoordinatorCanFulfill(msg.sender);
        }
        fulfillRandomWords(requestId, randomWords);
    }
}

File 14 of 24 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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 15 of 24 : ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

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

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

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

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

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

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

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

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

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

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _ownerOf(tokenId);
        require(owner != address(0), "ERC721: invalid token ID");
        return owner;
    }

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

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

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        _requireMinted(tokenId);

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

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

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

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

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        _requireMinted(tokenId);

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

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

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

        _transfer(from, to, tokenId);
    }

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

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

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

    /**
     * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
     */
    function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
        return _owners[tokenId];
    }

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

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

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

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

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

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

        // Check that tokenId was not minted by `_beforeTokenTransfer` hook
        require(!_exists(tokenId), "ERC721: token already minted");

        unchecked {
            // Will not overflow unless all 2**256 token ids are minted to the same owner.
            // Given that tokens are minted one by one, it is impossible in practice that
            // this ever happens. Might change if we allow batch minting.
            // The ERC fails to describe this case.
            _balances[to] += 1;
        }

        _owners[tokenId] = to;

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

        _afterTokenTransfer(address(0), to, tokenId, 1);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     * This is an internal function that does not check if the sender is authorized to operate on the token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);

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

        // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook
        owner = ERC721.ownerOf(tokenId);

        // Clear approvals
        delete _tokenApprovals[tokenId];

        unchecked {
            // Cannot overflow, as that would require more tokens to be burned/transferred
            // out than the owner initially received through minting and transferring in.
            _balances[owner] -= 1;
        }
        delete _owners[tokenId];

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

        _afterTokenTransfer(owner, address(0), tokenId, 1);
    }

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

        _beforeTokenTransfer(from, to, tokenId, 1);

        // Check that tokenId was not transferred by `_beforeTokenTransfer` hook
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");

        // Clear approvals from the previous owner
        delete _tokenApprovals[tokenId];

        unchecked {
            // `_balances[from]` cannot overflow for the same reason as described in `_burn`:
            // `from`'s balance is the number of token held, which is at least one before the current
            // transfer.
            // `_balances[to]` could overflow in the conditions described in `_mint`. That would require
            // all 2**256 token ids to be minted, which in practice is impossible.
            _balances[from] -= 1;
            _balances[to] += 1;
        }
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId, 1);
    }

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

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Reverts if the `tokenId` has not been minted yet.
     */
    function _requireMinted(uint256 tokenId) internal view virtual {
        require(_exists(tokenId), "ERC721: invalid token ID");
    }

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

    /**
     * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is
     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.
     * - When `from` is zero, the tokens will be minted for `to`.
     * - When `to` is zero, ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     * - `batchSize` is non-zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}

    /**
     * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is
     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.
     * - When `from` is zero, the tokens were minted for `to`.
     * - When `to` is zero, ``from``'s tokens were burned.
     * - `from` and `to` are never both zero.
     * - `batchSize` is non-zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}

    /**
     * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
     *
     * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant
     * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such
     * that `ownerOf(tokenId)` is `a`.
     */
    // solhint-disable-next-line func-name-mixedcase
    function __unsafe_increaseBalance(address account, uint256 amount) internal {
        _balances[account] += amount;
    }
}

File 16 of 24 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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 17 of 24 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

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

File 18 of 24 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

File 19 of 24 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [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://consensys.net/diligence/blog/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.8.0/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 24 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.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 `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

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

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

File 21 of 24 : 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 22 of 24 : 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 23 of 24 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 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 256, 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 << 3) < value ? 1 : 0);
        }
    }
}

File 24 of 24 : SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

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

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

Settings
{
  "remappings": [
    "@openzeppelin/=lib/openzeppelin-contracts/",
    "@chainlink/=lib/chainlink/",
    "chainlink/=lib/chainlink/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "openzeppelin/=lib/openzeppelin-contracts/contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "paris",
  "viaIR": false,
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"have","type":"address"}],"name":"OnlyCoordinatorCanFulfill","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"gameId","type":"uint256"},{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":false,"internalType":"uint8","name":"subgame","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"numRounds","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"betPerRound","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rakePerRound","type":"uint256"},{"components":[{"internalType":"uint256","name":"betAmount","type":"uint256"},{"internalType":"enum Roulette.BetType","name":"betType","type":"uint8"},{"internalType":"uint8","name":"betValue","type":"uint8"}],"indexed":false,"internalType":"struct Roulette.Bet[]","name":"choices","type":"tuple[]"},{"indexed":false,"internalType":"address","name":"referrer","type":"address"},{"indexed":false,"internalType":"enum GameVRF.FulfillmentMethod","name":"method","type":"uint8"}],"name":"GameStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"address","name":"vrfCoordinator","type":"address"},{"indexed":true,"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"RequestedGameWinner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"gameId","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"subgame","type":"uint8"},{"components":[{"internalType":"enum CentralGameBase.RoundState","name":"state","type":"uint8"},{"internalType":"uint256","name":"sent","type":"uint256"},{"internalType":"uint8","name":"selected","type":"uint8"}],"indexed":false,"internalType":"struct Roulette.RoundInfo[]","name":"results","type":"tuple[]"}],"name":"WinnerPicked","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"betMultiplePerRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"betAmount","type":"uint256"},{"internalType":"enum Roulette.BetType","name":"betType","type":"uint8"},{"internalType":"uint8","name":"betValue","type":"uint8"}],"internalType":"struct Roulette.Bet[]","name":"userChoices","type":"tuple[]"}],"name":"calculateMaxPayout","outputs":[{"internalType":"uint256","name":"maxPayout","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"currentGameId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"enum GameVRF.FulfillmentMethod","name":"method","type":"uint8"}],"name":"forceRequestWinner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"gameById","outputs":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"uint256","name":"betPerRound","type":"uint256"},{"internalType":"uint256","name":"rakePerRound","type":"uint256"},{"internalType":"uint256","name":"numRounds","type":"uint256"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"uint8","name":"subgame","type":"uint8"},{"internalType":"enum CentralGameBase.GameState","name":"state","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"gameIdByRequestId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"getGameInfo","outputs":[{"components":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"uint256","name":"betPerRound","type":"uint256"},{"internalType":"uint256","name":"rakePerRound","type":"uint256"},{"internalType":"uint256","name":"numRounds","type":"uint256"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"uint8","name":"subgame","type":"uint8"},{"internalType":"enum CentralGameBase.GameState","name":"state","type":"uint8"}],"internalType":"struct CentralGameBase.GameInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"gameIds","type":"uint256[]"}],"name":"getManyGameInfo","outputs":[{"components":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"uint256","name":"betPerRound","type":"uint256"},{"internalType":"uint256","name":"rakePerRound","type":"uint256"},{"internalType":"uint256","name":"numRounds","type":"uint256"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"uint8","name":"subgame","type":"uint8"},{"internalType":"enum CentralGameBase.GameState","name":"state","type":"uint8"}],"internalType":"struct CentralGameBase.GameInfo[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"betAmount","type":"uint256"},{"internalType":"enum Roulette.BetType","name":"betType","type":"uint8"},{"internalType":"uint8","name":"betValue","type":"uint8"}],"internalType":"struct Roulette.Bet[]","name":"userChoices","type":"tuple[]"}],"name":"getMaxBetPerRound","outputs":[{"internalType":"uint256","name":"safeMaxPotentialBet","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNumWords","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getRequestConfirmations","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxBetDivisor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxConsecutiveRounds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minBet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"payoutsByGameId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"numRounds","type":"uint256"},{"components":[{"internalType":"uint256","name":"betAmount","type":"uint256"},{"internalType":"enum Roulette.BetType","name":"betType","type":"uint8"},{"internalType":"uint8","name":"betValue","type":"uint8"}],"internalType":"struct Roulette.Bet[]","name":"userChoices","type":"tuple[]"},{"internalType":"string","name":"referralCode","type":"string"},{"internalType":"enum GameVRF.FulfillmentMethod","name":"method","type":"uint8"}],"name":"playGame","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"rakeDistributorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"rawFulfillRandomWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"referralTrackerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"rescueERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"rescueERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"rescueNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"betMultiplePerRound_","type":"uint256"}],"name":"setBetMultiplePerRound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId_","type":"uint256"}],"name":"setCurrentGameId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxBetDivisor_","type":"uint256"}],"name":"setMaxBetDivisor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxConsecutiveRounds_","type":"uint256"}],"name":"setMaxConsecutiveRounds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"minBet_","type":"uint256"}],"name":"setMinBet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"paused_","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"rakeAddress","type":"address"}],"name":"setRakeDistributorAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_referralTrackerAddress","type":"address"}],"name":"setReferralTrackerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"requestConfirmations","type":"uint16"}],"name":"setRequestConfirmations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasuryAddress","type":"address"}],"name":"setTreasuryAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"coordinator","type":"address"},{"internalType":"bool","name":"active","type":"bool"}],"name":"setVRFCoordinator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum GameVRF.FulfillmentMethod","name":"method","type":"uint8"},{"internalType":"bytes32","name":"gasLane","type":"bytes32"},{"internalType":"address","name":"coordAddress","type":"address"},{"internalType":"uint64","name":"subscriptionId","type":"uint64"},{"internalType":"uint32","name":"callbackGasLimit","type":"uint32"}],"name":"setVRFCoordinatorInfoByMethod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasuryAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040526706f05b59d3b200006007556014600855600a6009819055662386f26fc100009055600d805461ffff191660021790553480156200004157600080fd5b506200004d3362000053565b620000c1565b600180546001600160a01b03191690556200006e8162000071565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b613a1880620000d16000396000f3fe60806040526004361061024a5760003560e01c806379ba509711610139578063b4a91e1e116100b6578063ccf1719f1161007a578063ccf1719f14610724578063d39b5cbb1461073a578063d79818341461075f578063d9b61f681461077f578063e30c39781461079f578063f2fde38b146107bd57600080fd5b8063b4a91e1e14610677578063c072a4b8146106a4578063c20ee3fb146106c4578063c5f956af146106e4578063ccec37161461070457600080fd5b80639619367d116100fd5780639619367d146105eb5780639d4b950c146106015780639d8e7eac14610621578063a7f3606114610641578063b497b3541461066157600080fd5b806379ba5097146105445780638824f5a71461055957806388ea41b9146105795780638da5cb5b146105995780638f3d8252146105cb57600080fd5b8063454aa669116101c75780635c975abb1161018b5780635c975abb146104385780635f1b0fd8146104625780636605bfda14610485578063715018a6146104a557806376623022146104ba57600080fd5b8063454aa6691461039457806347e1d550146103b4578063536a3ddc146103e157806353a2c19a146103f75780635a3e2e8b1461040b57600080fd5b80631fe543e31161020e5780631fe543e31461030b57806321154ec51461032b5780632e35a3021461034b578063398497711461036b5780633eefe77e1461038157600080fd5b806305287f0c14610256578063160c3a141461027857806316c38b3c146102ab5780631bdb2d99146102cb5780631fa33a2a146102eb57600080fd5b3661025157005b600080fd5b34801561026257600080fd5b50610276610271366004613032565b6107dd565b005b34801561028457600080fd5b50610298610293366004613193565b6107ea565b6040519081526020015b60405180910390f35b3480156102b757600080fd5b506102766102c63660046131d5565b610841565b3480156102d757600080fd5b506102766102e6366004613222565b61085c565b3480156102f757600080fd5b5061027661030636600461329d565b610951565b34801561031757600080fd5b50610276610326366004613340565b610984565b34801561033757600080fd5b50610276610346366004613032565b6109ce565b34801561035757600080fd5b50610276610366366004613386565b6109db565b34801561037757600080fd5b5061029860085481565b61029861038f3660046133a3565b610a0b565b3480156103a057600080fd5b506102766103af366004613032565b610f17565b3480156103c057600080fd5b506103d46103cf366004613032565b610f74565b6040516102a29190613506565b3480156103ed57600080fd5b5061029860025481565b34801561040357600080fd5b506001610298565b34801561041757600080fd5b5061042b61042636600461351b565b61102b565b6040516102a2919061354f565b34801561044457600080fd5b506004546104529060ff1681565b60405190151581526020016102a2565b34801561046e57600080fd5b50600d5460405161ffff90911681526020016102a2565b34801561049157600080fd5b506102766104a0366004613386565b611186565b3480156104b157600080fd5b506102766111b0565b3480156104c657600080fd5b506105306104d5366004613032565b600360208190526000918252604090912080546001820154600283015493830154600484015460059094015492949193919290916001600160a01b03908116919081169060ff600160a01b8204811691600160a81b90041688565b6040516102a298979695949392919061359e565b34801561055057600080fd5b506102766111c4565b34801561056557600080fd5b506102766105743660046135f7565b61123e565b34801561058557600080fd5b50610276610594366004613032565b61125e565b3480156105a557600080fd5b506000546001600160a01b03165b6040516001600160a01b0390911681526020016102a2565b3480156105d757600080fd5b506102986105e6366004613193565b61126b565b3480156105f757600080fd5b5061029860075481565b34801561060d57600080fd5b5061027661061c366004613386565b61130d565b34801561062d57600080fd5b5061029861063c36600461361b565b611337565b34801561064d57600080fd5b5061027661065c36600461363d565b61135c565b34801561066d57600080fd5b5061029860095481565b34801561068357600080fd5b50610298610692366004613032565b600e6020526000908152604090205481565b3480156106b057600080fd5b506102766106bf366004613032565b6113e3565b3480156106d057600080fd5b506102766106df366004613032565b6113f0565b3480156106f057600080fd5b506006546105b3906001600160a01b031681565b34801561071057600080fd5b5061027661071f366004613386565b6113fd565b34801561073057600080fd5b50610298600a5481565b34801561074657600080fd5b506004546105b39061010090046001600160a01b031681565b34801561076b57600080fd5b5061027661077a366004613669565b6114e8565b34801561078b57600080fd5b506005546105b3906001600160a01b031681565b3480156107ab57600080fd5b506001546001600160a01b03166105b3565b3480156107c957600080fd5b506102766107d8366004613386565b61155d565b6107e56115ce565b600255565b600854600654600091829161080991906001600160a01b0316316136c1565b905060006108168461126b565b61082090836136c1565b9050605f61082f8260646136d5565b61083991906136c1565b949350505050565b6108496115ce565b6004805460ff1916911515919091179055565b6108646115ce565b6040518060800160405280858152602001846001600160a01b03168152602001836001600160401b031681526020018263ffffffff16815250600c60008760028111156108b3576108b3613476565b60028111156108c4576108c4613476565b815260208082019290925260409081016000208351815591830151600192830180549285015160609095015163ffffffff16600160e01b026001600160e01b036001600160401b03909616600160a01b026001600160e01b03199094166001600160a01b039093169290921792909217939093169290921790915561094a908490610951565b5050505050565b6109596115ce565b6001600160a01b03919091166000908152600b60205260409020805460ff1916911515919091179055565b336000908152600b602052604090205460ff1615156001146109c057604051637885129b60e01b81523360048201526024015b60405180910390fd5b6109ca8282611628565b5050565b6109d66115ce565b600855565b6109e36115ce565b600480546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6000323314610a535760405162461bcd60e51b8152602060048201526014602482015273139bc818dbdb9d1c9858dd1cc8185b1b1bddd95960621b60448201526064016109b7565b60045460ff1615610a975760405162461bcd60e51b815260206004820152600e60248201526d11d85b59481a5cc81c185d5cd95960921b60448201526064016109b7565b600660009054906101000a90046001600160a01b03166001600160a01b031663344049676040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610aec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b1091906136ec565b15610b545760405162461bcd60e51b8152602060048201526014602482015273547265617375727920697320746f6f206c6f772160601b60448201526064016109b7565b6000845111610ba55760405162461bcd60e51b815260206004820152601c60248201527f506c616365206174206c65617374206f6e65206265742c20706c65620000000060448201526064016109b7565b6000610bb0856119c6565b60045490915061010090046001600160a01b03166000610bd288888585612753565b600280549192506000610be483613709565b9190505550610bf1612f7e565b6002548152604080830151602083015260608301518183015233608083018190529051636431085f60e11b81526001600160a01b0385169163c86210be91610c3e91908b90600401613722565b602060405180830381865afa158015610c5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7f9190613781565b6001600160a01b031660a0820152600960c082015260608101899052600060e082018190525060065482516040516000926001600160a01b031691908381818185875af1925050503d8060008114610cf3576040519150601f19603f3d011682016040523d82523d6000602084013e610cf8565b606091505b5050905080610d495760405162461bcd60e51b815260206004820152601a60248201527f4661696c656420746f2073656e6420746f20747265617375727900000000000060448201526064016109b7565b5080516000908152600f60205260409020610d6690856025612fc0565b5080516000908152600360208181526040928390208451815590840151600182015591830151600283015560608301518282015560808301516004830180546001600160a01b039283166001600160a01b031990911617905560a084015160058401805460c087015160ff16600160a01b026001600160a81b031990911692909316919091179190911780825560e085015185949390929160ff60a81b191690600160a81b908490811115610e1d57610e1d613476565b0217905550905050336001600160a01b031681600001517f4f836ed4e2c181001ae79b838043a30569fb69372a2b78343a68cb4f8bf8f2d58360c001518c856020015186604001518e8860a001518e604051610e7f97969594939291906137b2565b60405180910390a36020820151815160a083015160405163919ac7ff60e01b815260048101929092523360248301526001600160a01b03908116604483015285169163919ac7ff916064016000604051808303818588803b158015610ee357600080fd5b505af1158015610ef7573d6000803e3d6000fd5b5050505050610f0a816000015187612908565b5198975050505050505050565b610f1f6115ce565b604051600090339083908381818185875af1925050503d8060008114610f61576040519150601f19603f3d011682016040523d82523d6000602084013e610f66565b606091505b50509050806109ca57600080fd5b610f7c612f7e565b6000828152600360208181526040928390208351610100810185528154815260018201549281019290925260028101549382019390935282820154606082015260048301546001600160a01b039081166080830152600584015490811660a083015260ff600160a01b8204811660c084015291939260e0850192600160a81b9092049091169081111561101157611011613476565b600381111561102257611022613476565b90525092915050565b80516060906000816001600160401b0381111561104a5761104a61304b565b60405190808252806020026020018201604052801561108357816020015b611070612f7e565b8152602001906001900390816110685790505b50905060005b8281101561117e57600360008683815181106110a7576110a761386a565b602090810291909101810151825281810192909252604090810160002081516101008101835281548152600182015493810193909352600281015491830191909152600380820154606084015260048201546001600160a01b039081166080850152600583015490811660a085015260ff600160a01b8204811660c086015260e0850192600160a81b909204169081111561114457611144613476565b600381111561115557611155613476565b8152505082828151811061116b5761116b61386a565b6020908102919091010152600101611089565b509392505050565b61118e6115ce565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6111b86115ce565b6111c26000612b25565b565b60015433906001600160a01b031681146112325760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016109b7565b61123b81612b25565b50565b6112466115ce565b600d805461ffff191661ffff92909216919091179055565b6112666115ce565b600755565b6000808251116112bd5760405162461bcd60e51b815260206004820152601c60248201527f506c616365206174206c65617374206f6e65206265742c20706c65620000000060448201526064016109b7565b60006112c8836119c6565b905060005b60258110156113065760008282602581106112ea576112ea61386a565b60200201519050838111156112fd578093505b506001016112cd565b5050919050565b6113156115ce565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b600f602052816000526040600020816025811061135357600080fd5b01549150829050565b6113646115ce565b600082815260036020526040902060016005820154600160a81b900460ff16600381111561139457611394613476565b036113d25760405162461bcd60e51b815260206004820152600e60248201526d185b1c9958591e4818db1bdcd95960921b60448201526064016109b7565b80546113de9083612908565b505050565b6113eb6115ce565b600955565b6113f86115ce565b600a55565b6114056115ce565b6040516370a0823160e01b815230600482015281906001600160a01b0382169063a9059cbb90339083906370a0823190602401602060405180830381865afa158015611455573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114799190613880565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af11580156114c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113de91906136ec565b6114f06115ce565b6040516323b872dd60e01b81523060048201523360248201526044810182905282906001600160a01b038216906323b872dd90606401600060405180830381600087803b15801561154057600080fd5b505af1158015611554573d6000803e3d6000fd5b50505050505050565b6115656115ce565b600180546001600160a01b0383166001600160a01b031990911681179091556115966000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000546001600160a01b031633146111c25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109b7565b6000828152600e6020526040812054908190036116875760405162461bcd60e51b815260206004820152601960248201527f5265717565737420616c72656164792066756c66696c6c65640000000000000060448201526064016109b7565b6000818152600360205260408120906005820154600160a81b900460ff1660038111156116b6576116b6613476565b146117035760405162461bcd60e51b815260206004820152601c60248201527f47616d65206e6f742077616974696e6720666f7220726573756c74730000000060448201526064016109b7565b6000828152600f602052604080822081516104a08101928390529160259082845b81548152602001906001019080831161172457505050505090506000826003015490506000816001600160401b038111156117615761176161304b565b6040519080825280602002602001820160405280156117ac57816020015b604080516060810182526000808252602080830182905292820152825260001990920191018161177f5790505b5090506000805b8381101561189a576000886000815181106117d0576117d061386a565b6020026020010151826040516020016117f3929190918252602082015260400190565b60408051601f1981840301815291905280516020909101209050600061181a602583613899565b90506000878260ff16602581106118335761183361386a565b60200201519050600086858151811061184e5761184e61386a565b602090810291909101015160ff841660408201529050811561188657600381526020810182905261187f82876138ad565b955061188b565b600181525b505050508060010190506117b3565b50600585015460405187917f265e62fce6507c510320cc65c5b8904884d3242797cdf96f080b558be587bec5916118dd91600160a01b900460ff169086906138c0565b60405180910390a26004808601546000888152600360208181526040808420848155600181018590556002810185905592830184905594820180546001600160a01b0319169055600590910180546001600160b01b03191690558b8252600e9052918220919091556001600160a01b031681156119bb5760065460405163cf8d133f60e01b81526001600160a01b038381166004830152602482018590529091169063cf8d133f90604401600060405180830381600087803b1580156119a257600080fd5b505af11580156119b6573d6000803e3d6000fd5b505050505b505050505050505050565b6119ce612ffe565b815160005b818110156113065760008482815181106119ef576119ef61386a565b602002602001015190506000816000015111611a655760405162461bcd60e51b815260206004820152602f60248201527f506c616365206120626574207769746820616d6f756e7420677265617465722060448201526e3a3430b7103d32b9379610383632b160891b60648201526084016109b7565b600081602001516009811115611a7d57611a7d613476565b03611b18576025816040015160ff1610611ad95760405162461bcd60e51b815260206004820152601960248201527f6e756d62657273206d7573742062652066726f6d20302d33360000000000000060448201526064016109b7565b8051611ae69060246136d5565b84826040015160ff1660258110611aff57611aff61386a565b60200201818151611b1091906138ad565b90525061274a565b600181602001516009811115611b3057611b30613476565b03611d1f576002816040015160ff1610611b975760405162461bcd60e51b815260206004820152602260248201527f7265642f626c61636b206265742076616c7565206d7573742062652030206f72604482015261203160f01b60648201526084016109b7565b8051600090611ba79060026136d5565b9050600082604001516001611bbc9190613936565b60ff1690505b600b811015611c045781868260258110611bde57611bde61386a565b60200201818151611bef91906138ad565b905250611bfd6002826138ad565b9050611bc2565b5060008260400151600c611c18919061394f565b60ff1690505b6013811015611c605781868260258110611c3a57611c3a61386a565b60200201818151611c4b91906138ad565b905250611c596002826138ad565b9050611c1e565b50600082604001516013611c749190613936565b60ff1690505b601d811015611cbc5781868260258110611c9657611c9661386a565b60200201818151611ca791906138ad565b905250611cb56002826138ad565b9050611c7a565b5060008260400151601e611cd0919061394f565b60ff1690505b6025811015611d185781868260258110611cf257611cf261386a565b60200201818151611d0391906138ad565b905250611d116002826138ad565b9050611cd6565b505061274a565b600281602001516009811115611d3757611d37613476565b03611e0a576002816040015160ff1610611d9d5760405162461bcd60e51b815260206004820152602160248201527f6f64642f6576656e206265742076616c7565206d7573742062652030206f72206044820152603160f81b60648201526084016109b7565b8051600090611dad9060026136d5565b9050600082604001516001611dc29190613936565b60ff1690505b6025811015611d185781868260258110611de457611de461386a565b60200201818151611df591906138ad565b905250611e036002826138ad565b9050611dc8565b600381602001516009811115611e2257611e22613476565b03611f14576003816040015160ff1610611e8a5760405162461bcd60e51b8152602060048201526024808201527f746869726473206265742076616c7565206d7573742062652030206f7220312060448201526337b9101960e11b60648201526084016109b7565b60008160400151600c611e9d9190613968565b611ea8906001613936565b90506000611eb782600c613936565b8351909150600090611eca9060036136d5565b905060ff83165b8260ff16811015611f0b5781888260258110611eef57611eef61386a565b60200201818151611f0091906138ad565b905250600101611ed1565b5050505061274a565b600481602001516009811115611f2c57611f2c613476565b03612009576002816040015160ff1610611f885760405162461bcd60e51b815260206004820152601f60248201527f68616c766573206265742076616c7565206d7573742062652030206f7220310060448201526064016109b7565b600081604001516012611f9b9190613968565b611fa6906001613936565b90506000611fb5826012613936565b8351909150600090611fc89060026136d5565b905060ff83165b8260ff16811015611f0b5781888260258110611fed57611fed61386a565b60200201818151611ffe91906138ad565b905250600101611fcf565b60058160200151600981111561202157612021613476565b036120f5576003816040015160ff16106120885760405162461bcd60e51b815260206004820152602260248201527f726f7773206265742076616c7565206d7573742062652030206f722031206f72604482015261101960f11b60648201526084016109b7565b80516000906120989060036136d5565b90506000826040015160016120ad9190613936565b60ff1690505b6025811015611d1857818682602581106120cf576120cf61386a565b602002018181516120e091906138ad565b9052506120ee6003826138ad565b90506120b3565b60068160200151600981111561210d5761210d613476565b036121f857600c816040015160ff16106121785760405162461bcd60e51b815260206004820152602660248201527f636f6c756d6e73206265742076616c7565206d757374206265206c65737320746044820152653430b710189960d11b60648201526084016109b7565b805160009061218890600c6136d5565b905060008260400151600361219d9190613968565b6121a8906001613936565b905060006121b7826003613936565b905060ff82165b8160ff16811015611f0b57838882602581106121dc576121dc61386a565b602002018181516121ed91906138ad565b9052506001016121be565b60078160200151600981111561221057612210613476565b03612336576018816040015160ff16106122815760405162461bcd60e51b815260206004820152602c60248201527f766572746963616c2070616972206265742076616c7565206d7573742062652060448201526b1b195cdcc81d1a185b880c8d60a21b60648201526084016109b7565b80516000906122919060126136d5565b6040830151909150600060026122a8836001613936565b6122b2919061398b565b6122bd6002846139ad565b6122c8846002613968565b6122d2919061394f565b6122dc9190613936565b905060006122eb826002613936565b905060ff82165b8160ff1681101561232c57848982602581106123105761231061386a565b6020020181815161232191906138ad565b9052506001016122f2565b505050505061274a565b60088160200151600981111561234e5761234e613476565b036124a7576024816040015160ff16106123c15760405162461bcd60e51b815260206004820152602e60248201527f686f72697a6f6e74616c2070616972206265742076616c7565206d757374206260448201526d32903632b9b9903a3430b710199b60911b60648201526084016109b7565b80516000906123d19060126136d5565b6040830151909150600360ff82161015612432578551829087906123f69083906138ad565b9052508186612406836001613936565b60ff16602581106124195761241961386a565b6020020181815161242a91906138ad565b905250611d18565b600061243f60028361394f565b905082878260ff16602581106124575761245761386a565b6020020181815161246891906138ad565b9052508287612478836003613936565b60ff166025811061248b5761248b61386a565b6020020181815161249c91906138ad565b90525050505061274a565b6009816020015160098111156124bf576124bf613476565b036126f6576018816040015160ff161061252a5760405162461bcd60e51b815260206004820152602660248201527f636f726e657273206265742076616c7565206d757374206265206c65737320746044820152651a185b880c8d60d21b60648201526084016109b7565b6040810151600260ff821610156125c057815160009061254b90600c6136d5565b86519091508190879061255f9083906138ad565b905250808660026020020181815161257791906138ad565b9052508086612587846002613968565b612592906001613936565b60ff16602581106125a5576125a561386a565b602002018181516125b691906138ad565b9052506126f09050565b81516000906125d09060096136d5565b905060006125df60028461394f565b9050600060026125f0836001613936565b6125fa919061398b565b6126056002846139ad565b612610846002613968565b61261a919061394f565b6126249190613936565b905082888260ff166025811061263c5761263c61386a565b6020020181815161264d91906138ad565b905250828861265d836001613936565b60ff16602581106126705761267061386a565b6020020181815161268191906138ad565b9052508288612691836003613936565b60ff16602581106126a4576126a461386a565b602002018181516126b591906138ad565b90525082886126c5836004613936565b60ff16602581106126d8576126d861386a565b602002018181516126e991906138ad565b9052505050505b5061274a565b60405162461bcd60e51b815260206004820152602360248201527f696e7465726e616c206572726f723a20756e657870656374656420626574207460448201526279706560e81b60648201526084016109b7565b506001016119d3565b6127856040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6000805b85518110156127c5578581815181106127a4576127a461386a565b602002602001015160000151826127bb91906138ad565b9150600101612789565b506000805b60258110156128035760008682602581106127e7576127e761386a565b60200201519050828111156127fa578092505b506001016127ca565b5061280e87836136d5565b915061281a87826136d5565b905060006128aa600660009054906101000a90046001600160a01b03166001600160a01b031631866001600160a01b031663e54c9f6b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561287f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128a39190613880565b8a85612b3e565b805190915083146128fd5760405162461bcd60e51b815260206004820181905260248201527f74782076616c756520646964206e6f74206d61746368206265742076616c756560448201526064016109b7565b979650505050505050565b6000600c600083600281111561292057612920613476565b600281111561293157612931613476565b81526020810191909152604001600020600101546001600160a01b03169050806129935760405162461bcd60e51b8152602060048201526013602482015272496e76616c696420565246206164647265737360681b60448201526064016109b7565b8060006001600160a01b038216635d3b1d30600c838760028111156129ba576129ba613476565b60028111156129cb576129cb613476565b815260200190815260200160002060000154600c60008860028111156129f3576129f3613476565b6002811115612a0457612a04613476565b815260200190815260200160002060010160149054906101000a90046001600160401b0316600d60009054906101000a900461ffff16600c60008a6002811115612a5057612a50613476565b6002811115612a6157612a61613476565b81526020810191909152604090810160002060019081015491516001600160e01b031960e088901b16815260048101959095526001600160401b03909316602485015261ffff909116604484015263ffffffff600160e01b909104166064830152608482015260a4016020604051808303816000875af1158015612ae9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b0d9190613880565b6000908152600e602052604090209490945550505050565b600180546001600160a01b031916905561123b81612f2e565b612b706040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b60008311612bc05760405162461bcd60e51b815260206004820152601f60248201527f47616d626c65206174206c65617374206f6e6520726f756e642c20706c65620060448201526064016109b7565b6000612bce856127106138ad565b612bda346127106136d5565b612be491906136c1565b90506000612bf282346139cf565b9050600754821015612c3a5760405162461bcd60e51b815260206004820152601160248201527023b0b6b136329036b7b9329610383632b160791b60448201526064016109b7565b60008511612c8a5760405162461bcd60e51b815260206004820152601a60248201527f47616d626c65206174206c65617374206f6e63652c20706c656200000000000060448201526064016109b7565b600954851115612cdc5760405162461bcd60e51b815260206004820152601860248201527f47616d626c652066657765722074696d65732c206b696e67000000000000000060448201526064016109b7565b6000612ce886846136c1565b9050612cf48684613899565b15612d575760405162461bcd60e51b815260206004820152602d60248201527f47616d626c6520616e20616d6f756e7420646976697369626c6520627920796f60448201526c3ab9103132ba399610383632b160991b60648201526084016109b7565b600a54612d649082613899565b15612dbf5760405162461bcd60e51b815260206004820152602560248201527f47616d626c652074686520726967687420616d6f756e7420706572206265742c60448201526410383632b160d91b60648201526084016109b7565b6000612dcb87846136c1565b9050612dd78784613899565b15612e2e5760405162461bcd60e51b815260206004820152602160248201527f496e7465726e616c206572726f723b2077726f6e672072616b6520616d6f756e6044820152601d60fa1b60648201526084016109b7565b6000612e3a88886136c1565b9050808310612ea65760405162461bcd60e51b815260206004820152603260248201527f506c61636520612067616d626c65207468617420776f6e27742067756172616e6044820152713a32b2903cb7ba903637b9b29610383632b160711b60648201526084016109b7565b600854612eb3908b6136c1565b612ebd84836139cf565b1115612eff5760405162461bcd60e51b815260206004820152601160248201527047616d626c65206c6573732c206b696e6760781b60448201526064016109b7565b6040805160a0810182529586526020860194909452928401919091526060830152608082015295945050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081018290529060e082015290565b8260258101928215612fee579160200282015b82811115612fee578251825591602001919060010190612fd3565b50612ffa92915061301d565b5090565b604051806104a001604052806025906020820280368337509192915050565b5b80821115612ffa576000815560010161301e565b60006020828403121561304457600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b03811182821017156130835761308361304b565b60405290565b604051601f8201601f191681016001600160401b03811182821017156130b1576130b161304b565b604052919050565b60006001600160401b038211156130d2576130d261304b565b5060051b60200190565b600082601f8301126130ed57600080fd5b813560206131026130fd836130b9565b613089565b8281526060928302850182019282820191908785111561312157600080fd5b8387015b858110156131865781818a03121561313d5760008081fd5b613145613061565b8135815285820135600a811061315b5760008081fd5b8187015260408281013560ff811681146131755760008081fd5b908201528452928401928101613125565b5090979650505050505050565b6000602082840312156131a557600080fd5b81356001600160401b038111156131bb57600080fd5b610839848285016130dc565b801515811461123b57600080fd5b6000602082840312156131e757600080fd5b81356131f2816131c7565b9392505050565b80356003811061320857600080fd5b919050565b6001600160a01b038116811461123b57600080fd5b600080600080600060a0868803121561323a57600080fd5b613243866131f9565b945060208601359350604086013561325a8161320d565b925060608601356001600160401b038116811461327657600080fd5b9150608086013563ffffffff8116811461328f57600080fd5b809150509295509295909350565b600080604083850312156132b057600080fd5b82356132bb8161320d565b915060208301356132cb816131c7565b809150509250929050565b600082601f8301126132e757600080fd5b813560206132f76130fd836130b9565b8083825260208201915060208460051b87010193508684111561331957600080fd5b602086015b84811015613335578035835291830191830161331e565b509695505050505050565b6000806040838503121561335357600080fd5b8235915060208301356001600160401b0381111561337057600080fd5b61337c858286016132d6565b9150509250929050565b60006020828403121561339857600080fd5b81356131f28161320d565b600080600080608085870312156133b957600080fd5b843593506020808601356001600160401b03808211156133d857600080fd5b6133e489838a016130dc565b955060408801359150808211156133fa57600080fd5b818801915088601f83011261340e57600080fd5b8135818111156134205761342061304b565b613432601f8201601f19168501613089565b9150808252898482850101111561344857600080fd5b808484018584013760008482840101525080945050505061346b606086016131f9565b905092959194509250565b634e487b7160e01b600052602160045260246000fd5b6004811061123b5761123b613476565b80518252602081015160208301526040810151604083015260608101516060830152608081015160018060a01b0380821660808501528060a08401511660a0850152505060ff60c08201511660c083015260e08101516134fb8161348c565b8060e0840152505050565b6101008101613515828461349c565b92915050565b60006020828403121561352d57600080fd5b81356001600160401b0381111561354357600080fd5b610839848285016132d6565b6020808252825182820181905260009190848201906040850190845b818110156135925761357e83855161349c565b92840192610100929092019160010161356b565b50909695505050505050565b8881526020810188905260408101879052606081018690526001600160a01b038581166080830152841660a082015260ff831660c082015261010081016135e48361348c565b8260e08301529998505050505050505050565b60006020828403121561360957600080fd5b813561ffff811681146131f257600080fd5b6000806040838503121561362e57600080fd5b50508035926020909101359150565b6000806040838503121561365057600080fd5b82359150613660602084016131f9565b90509250929050565b6000806040838503121561367c57600080fd5b82356136878161320d565b946020939093013593505050565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000826136d0576136d0613695565b500490565b8082028115828204841417613515576135156136ab565b6000602082840312156136fe57600080fd5b81516131f2816131c7565b60006001820161371b5761371b6136ab565b5060010190565b60018060a01b03831681526000602060406020840152835180604085015260005b8181101561375f57858101830151858201606001528201613743565b506000606082860101526060601f19601f830116850101925050509392505050565b60006020828403121561379357600080fd5b81516131f28161320d565b600381106137ae576137ae613476565b9052565b600060e0820160ff808b16845260208a602086015260408a604087015260608a606088015260e06080880152848a518087526101008901915060208c01965060005b818110156138335787518051845286810151600a811061381657613816613476565b8488015285015187168584015296850196918301916001016137f4565b50506001600160a01b038a1660a08901529550613851945050505050565b61385e60c083018461379e565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561389257600080fd5b5051919050565b6000826138a8576138a8613695565b500690565b80820180821115613515576135156136ab565b6000604080830160ff8087168552602060406020870152828751808552606094506060880191506020890160005b8281101561392657815180516139038161348c565b8552808601518686015288015186168885015292860192908401906001016138ee565b50919a9950505050505050505050565b60ff8181168382160190811115613515576135156136ab565b60ff8281168282160390811115613515576135156136ab565b60ff8181168382160290811690818114613984576139846136ab565b5092915050565b600060ff83168061399e5761399e613695565b8060ff84160691505092915050565b600060ff8316806139c0576139c0613695565b8060ff84160491505092915050565b81810381811115613515576135156136ab56fea264697066735822122065bf2932b156b7f89d1c37812dd56f5483305293ef4c70733f9f14e32f028bab64736f6c63430008160033

Deployed Bytecode

0x60806040526004361061024a5760003560e01c806379ba509711610139578063b4a91e1e116100b6578063ccf1719f1161007a578063ccf1719f14610724578063d39b5cbb1461073a578063d79818341461075f578063d9b61f681461077f578063e30c39781461079f578063f2fde38b146107bd57600080fd5b8063b4a91e1e14610677578063c072a4b8146106a4578063c20ee3fb146106c4578063c5f956af146106e4578063ccec37161461070457600080fd5b80639619367d116100fd5780639619367d146105eb5780639d4b950c146106015780639d8e7eac14610621578063a7f3606114610641578063b497b3541461066157600080fd5b806379ba5097146105445780638824f5a71461055957806388ea41b9146105795780638da5cb5b146105995780638f3d8252146105cb57600080fd5b8063454aa669116101c75780635c975abb1161018b5780635c975abb146104385780635f1b0fd8146104625780636605bfda14610485578063715018a6146104a557806376623022146104ba57600080fd5b8063454aa6691461039457806347e1d550146103b4578063536a3ddc146103e157806353a2c19a146103f75780635a3e2e8b1461040b57600080fd5b80631fe543e31161020e5780631fe543e31461030b57806321154ec51461032b5780632e35a3021461034b578063398497711461036b5780633eefe77e1461038157600080fd5b806305287f0c14610256578063160c3a141461027857806316c38b3c146102ab5780631bdb2d99146102cb5780631fa33a2a146102eb57600080fd5b3661025157005b600080fd5b34801561026257600080fd5b50610276610271366004613032565b6107dd565b005b34801561028457600080fd5b50610298610293366004613193565b6107ea565b6040519081526020015b60405180910390f35b3480156102b757600080fd5b506102766102c63660046131d5565b610841565b3480156102d757600080fd5b506102766102e6366004613222565b61085c565b3480156102f757600080fd5b5061027661030636600461329d565b610951565b34801561031757600080fd5b50610276610326366004613340565b610984565b34801561033757600080fd5b50610276610346366004613032565b6109ce565b34801561035757600080fd5b50610276610366366004613386565b6109db565b34801561037757600080fd5b5061029860085481565b61029861038f3660046133a3565b610a0b565b3480156103a057600080fd5b506102766103af366004613032565b610f17565b3480156103c057600080fd5b506103d46103cf366004613032565b610f74565b6040516102a29190613506565b3480156103ed57600080fd5b5061029860025481565b34801561040357600080fd5b506001610298565b34801561041757600080fd5b5061042b61042636600461351b565b61102b565b6040516102a2919061354f565b34801561044457600080fd5b506004546104529060ff1681565b60405190151581526020016102a2565b34801561046e57600080fd5b50600d5460405161ffff90911681526020016102a2565b34801561049157600080fd5b506102766104a0366004613386565b611186565b3480156104b157600080fd5b506102766111b0565b3480156104c657600080fd5b506105306104d5366004613032565b600360208190526000918252604090912080546001820154600283015493830154600484015460059094015492949193919290916001600160a01b03908116919081169060ff600160a01b8204811691600160a81b90041688565b6040516102a298979695949392919061359e565b34801561055057600080fd5b506102766111c4565b34801561056557600080fd5b506102766105743660046135f7565b61123e565b34801561058557600080fd5b50610276610594366004613032565b61125e565b3480156105a557600080fd5b506000546001600160a01b03165b6040516001600160a01b0390911681526020016102a2565b3480156105d757600080fd5b506102986105e6366004613193565b61126b565b3480156105f757600080fd5b5061029860075481565b34801561060d57600080fd5b5061027661061c366004613386565b61130d565b34801561062d57600080fd5b5061029861063c36600461361b565b611337565b34801561064d57600080fd5b5061027661065c36600461363d565b61135c565b34801561066d57600080fd5b5061029860095481565b34801561068357600080fd5b50610298610692366004613032565b600e6020526000908152604090205481565b3480156106b057600080fd5b506102766106bf366004613032565b6113e3565b3480156106d057600080fd5b506102766106df366004613032565b6113f0565b3480156106f057600080fd5b506006546105b3906001600160a01b031681565b34801561071057600080fd5b5061027661071f366004613386565b6113fd565b34801561073057600080fd5b50610298600a5481565b34801561074657600080fd5b506004546105b39061010090046001600160a01b031681565b34801561076b57600080fd5b5061027661077a366004613669565b6114e8565b34801561078b57600080fd5b506005546105b3906001600160a01b031681565b3480156107ab57600080fd5b506001546001600160a01b03166105b3565b3480156107c957600080fd5b506102766107d8366004613386565b61155d565b6107e56115ce565b600255565b600854600654600091829161080991906001600160a01b0316316136c1565b905060006108168461126b565b61082090836136c1565b9050605f61082f8260646136d5565b61083991906136c1565b949350505050565b6108496115ce565b6004805460ff1916911515919091179055565b6108646115ce565b6040518060800160405280858152602001846001600160a01b03168152602001836001600160401b031681526020018263ffffffff16815250600c60008760028111156108b3576108b3613476565b60028111156108c4576108c4613476565b815260208082019290925260409081016000208351815591830151600192830180549285015160609095015163ffffffff16600160e01b026001600160e01b036001600160401b03909616600160a01b026001600160e01b03199094166001600160a01b039093169290921792909217939093169290921790915561094a908490610951565b5050505050565b6109596115ce565b6001600160a01b03919091166000908152600b60205260409020805460ff1916911515919091179055565b336000908152600b602052604090205460ff1615156001146109c057604051637885129b60e01b81523360048201526024015b60405180910390fd5b6109ca8282611628565b5050565b6109d66115ce565b600855565b6109e36115ce565b600480546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6000323314610a535760405162461bcd60e51b8152602060048201526014602482015273139bc818dbdb9d1c9858dd1cc8185b1b1bddd95960621b60448201526064016109b7565b60045460ff1615610a975760405162461bcd60e51b815260206004820152600e60248201526d11d85b59481a5cc81c185d5cd95960921b60448201526064016109b7565b600660009054906101000a90046001600160a01b03166001600160a01b031663344049676040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610aec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b1091906136ec565b15610b545760405162461bcd60e51b8152602060048201526014602482015273547265617375727920697320746f6f206c6f772160601b60448201526064016109b7565b6000845111610ba55760405162461bcd60e51b815260206004820152601c60248201527f506c616365206174206c65617374206f6e65206265742c20706c65620000000060448201526064016109b7565b6000610bb0856119c6565b60045490915061010090046001600160a01b03166000610bd288888585612753565b600280549192506000610be483613709565b9190505550610bf1612f7e565b6002548152604080830151602083015260608301518183015233608083018190529051636431085f60e11b81526001600160a01b0385169163c86210be91610c3e91908b90600401613722565b602060405180830381865afa158015610c5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7f9190613781565b6001600160a01b031660a0820152600960c082015260608101899052600060e082018190525060065482516040516000926001600160a01b031691908381818185875af1925050503d8060008114610cf3576040519150601f19603f3d011682016040523d82523d6000602084013e610cf8565b606091505b5050905080610d495760405162461bcd60e51b815260206004820152601a60248201527f4661696c656420746f2073656e6420746f20747265617375727900000000000060448201526064016109b7565b5080516000908152600f60205260409020610d6690856025612fc0565b5080516000908152600360208181526040928390208451815590840151600182015591830151600283015560608301518282015560808301516004830180546001600160a01b039283166001600160a01b031990911617905560a084015160058401805460c087015160ff16600160a01b026001600160a81b031990911692909316919091179190911780825560e085015185949390929160ff60a81b191690600160a81b908490811115610e1d57610e1d613476565b0217905550905050336001600160a01b031681600001517f4f836ed4e2c181001ae79b838043a30569fb69372a2b78343a68cb4f8bf8f2d58360c001518c856020015186604001518e8860a001518e604051610e7f97969594939291906137b2565b60405180910390a36020820151815160a083015160405163919ac7ff60e01b815260048101929092523360248301526001600160a01b03908116604483015285169163919ac7ff916064016000604051808303818588803b158015610ee357600080fd5b505af1158015610ef7573d6000803e3d6000fd5b5050505050610f0a816000015187612908565b5198975050505050505050565b610f1f6115ce565b604051600090339083908381818185875af1925050503d8060008114610f61576040519150601f19603f3d011682016040523d82523d6000602084013e610f66565b606091505b50509050806109ca57600080fd5b610f7c612f7e565b6000828152600360208181526040928390208351610100810185528154815260018201549281019290925260028101549382019390935282820154606082015260048301546001600160a01b039081166080830152600584015490811660a083015260ff600160a01b8204811660c084015291939260e0850192600160a81b9092049091169081111561101157611011613476565b600381111561102257611022613476565b90525092915050565b80516060906000816001600160401b0381111561104a5761104a61304b565b60405190808252806020026020018201604052801561108357816020015b611070612f7e565b8152602001906001900390816110685790505b50905060005b8281101561117e57600360008683815181106110a7576110a761386a565b602090810291909101810151825281810192909252604090810160002081516101008101835281548152600182015493810193909352600281015491830191909152600380820154606084015260048201546001600160a01b039081166080850152600583015490811660a085015260ff600160a01b8204811660c086015260e0850192600160a81b909204169081111561114457611144613476565b600381111561115557611155613476565b8152505082828151811061116b5761116b61386a565b6020908102919091010152600101611089565b509392505050565b61118e6115ce565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6111b86115ce565b6111c26000612b25565b565b60015433906001600160a01b031681146112325760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084016109b7565b61123b81612b25565b50565b6112466115ce565b600d805461ffff191661ffff92909216919091179055565b6112666115ce565b600755565b6000808251116112bd5760405162461bcd60e51b815260206004820152601c60248201527f506c616365206174206c65617374206f6e65206265742c20706c65620000000060448201526064016109b7565b60006112c8836119c6565b905060005b60258110156113065760008282602581106112ea576112ea61386a565b60200201519050838111156112fd578093505b506001016112cd565b5050919050565b6113156115ce565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b600f602052816000526040600020816025811061135357600080fd5b01549150829050565b6113646115ce565b600082815260036020526040902060016005820154600160a81b900460ff16600381111561139457611394613476565b036113d25760405162461bcd60e51b815260206004820152600e60248201526d185b1c9958591e4818db1bdcd95960921b60448201526064016109b7565b80546113de9083612908565b505050565b6113eb6115ce565b600955565b6113f86115ce565b600a55565b6114056115ce565b6040516370a0823160e01b815230600482015281906001600160a01b0382169063a9059cbb90339083906370a0823190602401602060405180830381865afa158015611455573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114799190613880565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af11580156114c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113de91906136ec565b6114f06115ce565b6040516323b872dd60e01b81523060048201523360248201526044810182905282906001600160a01b038216906323b872dd90606401600060405180830381600087803b15801561154057600080fd5b505af1158015611554573d6000803e3d6000fd5b50505050505050565b6115656115ce565b600180546001600160a01b0383166001600160a01b031990911681179091556115966000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000546001600160a01b031633146111c25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109b7565b6000828152600e6020526040812054908190036116875760405162461bcd60e51b815260206004820152601960248201527f5265717565737420616c72656164792066756c66696c6c65640000000000000060448201526064016109b7565b6000818152600360205260408120906005820154600160a81b900460ff1660038111156116b6576116b6613476565b146117035760405162461bcd60e51b815260206004820152601c60248201527f47616d65206e6f742077616974696e6720666f7220726573756c74730000000060448201526064016109b7565b6000828152600f602052604080822081516104a08101928390529160259082845b81548152602001906001019080831161172457505050505090506000826003015490506000816001600160401b038111156117615761176161304b565b6040519080825280602002602001820160405280156117ac57816020015b604080516060810182526000808252602080830182905292820152825260001990920191018161177f5790505b5090506000805b8381101561189a576000886000815181106117d0576117d061386a565b6020026020010151826040516020016117f3929190918252602082015260400190565b60408051601f1981840301815291905280516020909101209050600061181a602583613899565b90506000878260ff16602581106118335761183361386a565b60200201519050600086858151811061184e5761184e61386a565b602090810291909101015160ff841660408201529050811561188657600381526020810182905261187f82876138ad565b955061188b565b600181525b505050508060010190506117b3565b50600585015460405187917f265e62fce6507c510320cc65c5b8904884d3242797cdf96f080b558be587bec5916118dd91600160a01b900460ff169086906138c0565b60405180910390a26004808601546000888152600360208181526040808420848155600181018590556002810185905592830184905594820180546001600160a01b0319169055600590910180546001600160b01b03191690558b8252600e9052918220919091556001600160a01b031681156119bb5760065460405163cf8d133f60e01b81526001600160a01b038381166004830152602482018590529091169063cf8d133f90604401600060405180830381600087803b1580156119a257600080fd5b505af11580156119b6573d6000803e3d6000fd5b505050505b505050505050505050565b6119ce612ffe565b815160005b818110156113065760008482815181106119ef576119ef61386a565b602002602001015190506000816000015111611a655760405162461bcd60e51b815260206004820152602f60248201527f506c616365206120626574207769746820616d6f756e7420677265617465722060448201526e3a3430b7103d32b9379610383632b160891b60648201526084016109b7565b600081602001516009811115611a7d57611a7d613476565b03611b18576025816040015160ff1610611ad95760405162461bcd60e51b815260206004820152601960248201527f6e756d62657273206d7573742062652066726f6d20302d33360000000000000060448201526064016109b7565b8051611ae69060246136d5565b84826040015160ff1660258110611aff57611aff61386a565b60200201818151611b1091906138ad565b90525061274a565b600181602001516009811115611b3057611b30613476565b03611d1f576002816040015160ff1610611b975760405162461bcd60e51b815260206004820152602260248201527f7265642f626c61636b206265742076616c7565206d7573742062652030206f72604482015261203160f01b60648201526084016109b7565b8051600090611ba79060026136d5565b9050600082604001516001611bbc9190613936565b60ff1690505b600b811015611c045781868260258110611bde57611bde61386a565b60200201818151611bef91906138ad565b905250611bfd6002826138ad565b9050611bc2565b5060008260400151600c611c18919061394f565b60ff1690505b6013811015611c605781868260258110611c3a57611c3a61386a565b60200201818151611c4b91906138ad565b905250611c596002826138ad565b9050611c1e565b50600082604001516013611c749190613936565b60ff1690505b601d811015611cbc5781868260258110611c9657611c9661386a565b60200201818151611ca791906138ad565b905250611cb56002826138ad565b9050611c7a565b5060008260400151601e611cd0919061394f565b60ff1690505b6025811015611d185781868260258110611cf257611cf261386a565b60200201818151611d0391906138ad565b905250611d116002826138ad565b9050611cd6565b505061274a565b600281602001516009811115611d3757611d37613476565b03611e0a576002816040015160ff1610611d9d5760405162461bcd60e51b815260206004820152602160248201527f6f64642f6576656e206265742076616c7565206d7573742062652030206f72206044820152603160f81b60648201526084016109b7565b8051600090611dad9060026136d5565b9050600082604001516001611dc29190613936565b60ff1690505b6025811015611d185781868260258110611de457611de461386a565b60200201818151611df591906138ad565b905250611e036002826138ad565b9050611dc8565b600381602001516009811115611e2257611e22613476565b03611f14576003816040015160ff1610611e8a5760405162461bcd60e51b8152602060048201526024808201527f746869726473206265742076616c7565206d7573742062652030206f7220312060448201526337b9101960e11b60648201526084016109b7565b60008160400151600c611e9d9190613968565b611ea8906001613936565b90506000611eb782600c613936565b8351909150600090611eca9060036136d5565b905060ff83165b8260ff16811015611f0b5781888260258110611eef57611eef61386a565b60200201818151611f0091906138ad565b905250600101611ed1565b5050505061274a565b600481602001516009811115611f2c57611f2c613476565b03612009576002816040015160ff1610611f885760405162461bcd60e51b815260206004820152601f60248201527f68616c766573206265742076616c7565206d7573742062652030206f7220310060448201526064016109b7565b600081604001516012611f9b9190613968565b611fa6906001613936565b90506000611fb5826012613936565b8351909150600090611fc89060026136d5565b905060ff83165b8260ff16811015611f0b5781888260258110611fed57611fed61386a565b60200201818151611ffe91906138ad565b905250600101611fcf565b60058160200151600981111561202157612021613476565b036120f5576003816040015160ff16106120885760405162461bcd60e51b815260206004820152602260248201527f726f7773206265742076616c7565206d7573742062652030206f722031206f72604482015261101960f11b60648201526084016109b7565b80516000906120989060036136d5565b90506000826040015160016120ad9190613936565b60ff1690505b6025811015611d1857818682602581106120cf576120cf61386a565b602002018181516120e091906138ad565b9052506120ee6003826138ad565b90506120b3565b60068160200151600981111561210d5761210d613476565b036121f857600c816040015160ff16106121785760405162461bcd60e51b815260206004820152602660248201527f636f6c756d6e73206265742076616c7565206d757374206265206c65737320746044820152653430b710189960d11b60648201526084016109b7565b805160009061218890600c6136d5565b905060008260400151600361219d9190613968565b6121a8906001613936565b905060006121b7826003613936565b905060ff82165b8160ff16811015611f0b57838882602581106121dc576121dc61386a565b602002018181516121ed91906138ad565b9052506001016121be565b60078160200151600981111561221057612210613476565b03612336576018816040015160ff16106122815760405162461bcd60e51b815260206004820152602c60248201527f766572746963616c2070616972206265742076616c7565206d7573742062652060448201526b1b195cdcc81d1a185b880c8d60a21b60648201526084016109b7565b80516000906122919060126136d5565b6040830151909150600060026122a8836001613936565b6122b2919061398b565b6122bd6002846139ad565b6122c8846002613968565b6122d2919061394f565b6122dc9190613936565b905060006122eb826002613936565b905060ff82165b8160ff1681101561232c57848982602581106123105761231061386a565b6020020181815161232191906138ad565b9052506001016122f2565b505050505061274a565b60088160200151600981111561234e5761234e613476565b036124a7576024816040015160ff16106123c15760405162461bcd60e51b815260206004820152602e60248201527f686f72697a6f6e74616c2070616972206265742076616c7565206d757374206260448201526d32903632b9b9903a3430b710199b60911b60648201526084016109b7565b80516000906123d19060126136d5565b6040830151909150600360ff82161015612432578551829087906123f69083906138ad565b9052508186612406836001613936565b60ff16602581106124195761241961386a565b6020020181815161242a91906138ad565b905250611d18565b600061243f60028361394f565b905082878260ff16602581106124575761245761386a565b6020020181815161246891906138ad565b9052508287612478836003613936565b60ff166025811061248b5761248b61386a565b6020020181815161249c91906138ad565b90525050505061274a565b6009816020015160098111156124bf576124bf613476565b036126f6576018816040015160ff161061252a5760405162461bcd60e51b815260206004820152602660248201527f636f726e657273206265742076616c7565206d757374206265206c65737320746044820152651a185b880c8d60d21b60648201526084016109b7565b6040810151600260ff821610156125c057815160009061254b90600c6136d5565b86519091508190879061255f9083906138ad565b905250808660026020020181815161257791906138ad565b9052508086612587846002613968565b612592906001613936565b60ff16602581106125a5576125a561386a565b602002018181516125b691906138ad565b9052506126f09050565b81516000906125d09060096136d5565b905060006125df60028461394f565b9050600060026125f0836001613936565b6125fa919061398b565b6126056002846139ad565b612610846002613968565b61261a919061394f565b6126249190613936565b905082888260ff166025811061263c5761263c61386a565b6020020181815161264d91906138ad565b905250828861265d836001613936565b60ff16602581106126705761267061386a565b6020020181815161268191906138ad565b9052508288612691836003613936565b60ff16602581106126a4576126a461386a565b602002018181516126b591906138ad565b90525082886126c5836004613936565b60ff16602581106126d8576126d861386a565b602002018181516126e991906138ad565b9052505050505b5061274a565b60405162461bcd60e51b815260206004820152602360248201527f696e7465726e616c206572726f723a20756e657870656374656420626574207460448201526279706560e81b60648201526084016109b7565b506001016119d3565b6127856040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6000805b85518110156127c5578581815181106127a4576127a461386a565b602002602001015160000151826127bb91906138ad565b9150600101612789565b506000805b60258110156128035760008682602581106127e7576127e761386a565b60200201519050828111156127fa578092505b506001016127ca565b5061280e87836136d5565b915061281a87826136d5565b905060006128aa600660009054906101000a90046001600160a01b03166001600160a01b031631866001600160a01b031663e54c9f6b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561287f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128a39190613880565b8a85612b3e565b805190915083146128fd5760405162461bcd60e51b815260206004820181905260248201527f74782076616c756520646964206e6f74206d61746368206265742076616c756560448201526064016109b7565b979650505050505050565b6000600c600083600281111561292057612920613476565b600281111561293157612931613476565b81526020810191909152604001600020600101546001600160a01b03169050806129935760405162461bcd60e51b8152602060048201526013602482015272496e76616c696420565246206164647265737360681b60448201526064016109b7565b8060006001600160a01b038216635d3b1d30600c838760028111156129ba576129ba613476565b60028111156129cb576129cb613476565b815260200190815260200160002060000154600c60008860028111156129f3576129f3613476565b6002811115612a0457612a04613476565b815260200190815260200160002060010160149054906101000a90046001600160401b0316600d60009054906101000a900461ffff16600c60008a6002811115612a5057612a50613476565b6002811115612a6157612a61613476565b81526020810191909152604090810160002060019081015491516001600160e01b031960e088901b16815260048101959095526001600160401b03909316602485015261ffff909116604484015263ffffffff600160e01b909104166064830152608482015260a4016020604051808303816000875af1158015612ae9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b0d9190613880565b6000908152600e602052604090209490945550505050565b600180546001600160a01b031916905561123b81612f2e565b612b706040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b60008311612bc05760405162461bcd60e51b815260206004820152601f60248201527f47616d626c65206174206c65617374206f6e6520726f756e642c20706c65620060448201526064016109b7565b6000612bce856127106138ad565b612bda346127106136d5565b612be491906136c1565b90506000612bf282346139cf565b9050600754821015612c3a5760405162461bcd60e51b815260206004820152601160248201527023b0b6b136329036b7b9329610383632b160791b60448201526064016109b7565b60008511612c8a5760405162461bcd60e51b815260206004820152601a60248201527f47616d626c65206174206c65617374206f6e63652c20706c656200000000000060448201526064016109b7565b600954851115612cdc5760405162461bcd60e51b815260206004820152601860248201527f47616d626c652066657765722074696d65732c206b696e67000000000000000060448201526064016109b7565b6000612ce886846136c1565b9050612cf48684613899565b15612d575760405162461bcd60e51b815260206004820152602d60248201527f47616d626c6520616e20616d6f756e7420646976697369626c6520627920796f60448201526c3ab9103132ba399610383632b160991b60648201526084016109b7565b600a54612d649082613899565b15612dbf5760405162461bcd60e51b815260206004820152602560248201527f47616d626c652074686520726967687420616d6f756e7420706572206265742c60448201526410383632b160d91b60648201526084016109b7565b6000612dcb87846136c1565b9050612dd78784613899565b15612e2e5760405162461bcd60e51b815260206004820152602160248201527f496e7465726e616c206572726f723b2077726f6e672072616b6520616d6f756e6044820152601d60fa1b60648201526084016109b7565b6000612e3a88886136c1565b9050808310612ea65760405162461bcd60e51b815260206004820152603260248201527f506c61636520612067616d626c65207468617420776f6e27742067756172616e6044820152713a32b2903cb7ba903637b9b29610383632b160711b60648201526084016109b7565b600854612eb3908b6136c1565b612ebd84836139cf565b1115612eff5760405162461bcd60e51b815260206004820152601160248201527047616d626c65206c6573732c206b696e6760781b60448201526064016109b7565b6040805160a0810182529586526020860194909452928401919091526060830152608082015295945050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081018290529060e082015290565b8260258101928215612fee579160200282015b82811115612fee578251825591602001919060010190612fd3565b50612ffa92915061301d565b5090565b604051806104a001604052806025906020820280368337509192915050565b5b80821115612ffa576000815560010161301e565b60006020828403121561304457600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b03811182821017156130835761308361304b565b60405290565b604051601f8201601f191681016001600160401b03811182821017156130b1576130b161304b565b604052919050565b60006001600160401b038211156130d2576130d261304b565b5060051b60200190565b600082601f8301126130ed57600080fd5b813560206131026130fd836130b9565b613089565b8281526060928302850182019282820191908785111561312157600080fd5b8387015b858110156131865781818a03121561313d5760008081fd5b613145613061565b8135815285820135600a811061315b5760008081fd5b8187015260408281013560ff811681146131755760008081fd5b908201528452928401928101613125565b5090979650505050505050565b6000602082840312156131a557600080fd5b81356001600160401b038111156131bb57600080fd5b610839848285016130dc565b801515811461123b57600080fd5b6000602082840312156131e757600080fd5b81356131f2816131c7565b9392505050565b80356003811061320857600080fd5b919050565b6001600160a01b038116811461123b57600080fd5b600080600080600060a0868803121561323a57600080fd5b613243866131f9565b945060208601359350604086013561325a8161320d565b925060608601356001600160401b038116811461327657600080fd5b9150608086013563ffffffff8116811461328f57600080fd5b809150509295509295909350565b600080604083850312156132b057600080fd5b82356132bb8161320d565b915060208301356132cb816131c7565b809150509250929050565b600082601f8301126132e757600080fd5b813560206132f76130fd836130b9565b8083825260208201915060208460051b87010193508684111561331957600080fd5b602086015b84811015613335578035835291830191830161331e565b509695505050505050565b6000806040838503121561335357600080fd5b8235915060208301356001600160401b0381111561337057600080fd5b61337c858286016132d6565b9150509250929050565b60006020828403121561339857600080fd5b81356131f28161320d565b600080600080608085870312156133b957600080fd5b843593506020808601356001600160401b03808211156133d857600080fd5b6133e489838a016130dc565b955060408801359150808211156133fa57600080fd5b818801915088601f83011261340e57600080fd5b8135818111156134205761342061304b565b613432601f8201601f19168501613089565b9150808252898482850101111561344857600080fd5b808484018584013760008482840101525080945050505061346b606086016131f9565b905092959194509250565b634e487b7160e01b600052602160045260246000fd5b6004811061123b5761123b613476565b80518252602081015160208301526040810151604083015260608101516060830152608081015160018060a01b0380821660808501528060a08401511660a0850152505060ff60c08201511660c083015260e08101516134fb8161348c565b8060e0840152505050565b6101008101613515828461349c565b92915050565b60006020828403121561352d57600080fd5b81356001600160401b0381111561354357600080fd5b610839848285016132d6565b6020808252825182820181905260009190848201906040850190845b818110156135925761357e83855161349c565b92840192610100929092019160010161356b565b50909695505050505050565b8881526020810188905260408101879052606081018690526001600160a01b038581166080830152841660a082015260ff831660c082015261010081016135e48361348c565b8260e08301529998505050505050505050565b60006020828403121561360957600080fd5b813561ffff811681146131f257600080fd5b6000806040838503121561362e57600080fd5b50508035926020909101359150565b6000806040838503121561365057600080fd5b82359150613660602084016131f9565b90509250929050565b6000806040838503121561367c57600080fd5b82356136878161320d565b946020939093013593505050565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000826136d0576136d0613695565b500490565b8082028115828204841417613515576135156136ab565b6000602082840312156136fe57600080fd5b81516131f2816131c7565b60006001820161371b5761371b6136ab565b5060010190565b60018060a01b03831681526000602060406020840152835180604085015260005b8181101561375f57858101830151858201606001528201613743565b506000606082860101526060601f19601f830116850101925050509392505050565b60006020828403121561379357600080fd5b81516131f28161320d565b600381106137ae576137ae613476565b9052565b600060e0820160ff808b16845260208a602086015260408a604087015260608a606088015260e06080880152848a518087526101008901915060208c01965060005b818110156138335787518051845286810151600a811061381657613816613476565b8488015285015187168584015296850196918301916001016137f4565b50506001600160a01b038a1660a08901529550613851945050505050565b61385e60c083018461379e565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561389257600080fd5b5051919050565b6000826138a8576138a8613695565b500690565b80820180821115613515576135156136ab565b6000604080830160ff8087168552602060406020870152828751808552606094506060880191506020890160005b8281101561392657815180516139038161348c565b8552808601518686015288015186168885015292860192908401906001016138ee565b50919a9950505050505050505050565b60ff8181168382160190811115613515576135156136ab565b60ff8281168282160390811115613515576135156136ab565b60ff8181168382160290811690818114613984576139846136ab565b5092915050565b600060ff83168061399e5761399e613695565b8060ff84160691505092915050565b600060ff8316806139c0576139c0613695565b8060ff84160491505092915050565b81810381811115613515576135156136ab56fea264697066735822122065bf2932b156b7f89d1c37812dd56f5483305293ef4c70733f9f14e32f028bab64736f6c63430008160033

Block Transaction 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
[ 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.