APE Price: $0.19 (-1.67%)

Contract

0x7F66d16A488Eae9e2B61BfB186fD94bBA3611416

Overview

APE Balance

Apechain LogoApechain LogoApechain Logo868,452.517897622605985792 APE

APE Value

$162,814.82 (@ $0.19/APE)

More Info

Private Name Tags

TokenTracker

Multichain Info

N/A
Transaction Hash
Block
From
To
Withdraw Liquidi...326519352026-01-21 16:46:003 days ago1769013960IN
0x7F66d16A...BA3611416
0 APE0.00548995101.68276
Withdraw Liquidi...326464882026-01-21 12:23:243 days ago1768998204IN
0x7F66d16A...BA3611416
0 APE0.00548995101.68276
Withdraw Liquidi...326462492026-01-21 12:15:413 days ago1768997741IN
0x7F66d16A...BA3611416
0 APE0.00548995101.68276
Withdraw Liquidi...325605982026-01-19 7:02:355 days ago1768806155IN
0x7F66d16A...BA3611416
0 APE0.00548873101.68276
Deposit Liquidit...322709082026-01-11 17:11:4313 days ago1768151503IN
0x7F66d16A...BA3611416
500 APE0.01384553101.68276
Withdraw Liquidi...318324392025-12-31 15:54:1324 days ago1767196453IN
0x7F66d16A...BA3611416
0 APE0.00690527101.68276
Withdraw Liquidi...318229672025-12-31 9:59:4524 days ago1767175185IN
0x7F66d16A...BA3611416
0 APE0.00690771101.68276
Deposit Liquidit...316731862025-12-28 0:01:2327 days ago1766880083IN
0x7F66d16A...BA3611416
708.795 APE0.01384675101.68276
Deposit Liquidit...315146832025-12-24 11:29:5431 days ago1766575794IN
0x7F66d16A...BA3611416
100 APE0.01384553101.68276
Deposit Liquidit...313884812025-12-21 18:06:0634 days ago1766340366IN
0x7F66d16A...BA3611416
500 APE0.01384553101.68276
Withdraw Liquidi...311292562025-12-18 2:49:2937 days ago1766026169IN
0x7F66d16A...BA3611416
0 APE0.00548995101.68276
Withdraw Liquidi...310192942025-12-15 23:37:4939 days ago1765841869IN
0x7F66d16A...BA3611416
0 APE0.00548751101.68276
Resolve Parlay309093592025-12-13 22:06:2842 days ago1765663588IN
0x7F66d16A...BA3611416
0 APE0.32112574101.68276
Resolve Parlay309092402025-12-13 22:02:3642 days ago1765663356IN
0x7F66d16A...BA3611416
0 APE0.32511171101.68276
Resolve Parlay309092352025-12-13 22:02:2842 days ago1765663348IN
0x7F66d16A...BA3611416
0 APE0.32169517101.68276
Resolve Parlay309092292025-12-13 22:02:2142 days ago1765663341IN
0x7F66d16A...BA3611416
0 APE0.31600093101.68276
Resolve Parlay309091652025-12-13 22:00:3542 days ago1765663235IN
0x7F66d16A...BA3611416
0 APE0.31648006101.68276
Resolve Parlay309091572025-12-13 22:00:2642 days ago1765663226IN
0x7F66d16A...BA3611416
0 APE0.31135525101.68276
Resolve Parlay309091532025-12-13 22:00:1942 days ago1765663219IN
0x7F66d16A...BA3611416
0 APE0.31135525101.68276
Resolve Parlay309091482025-12-13 22:00:1242 days ago1765663212IN
0x7F66d16A...BA3611416
0 APE0.31648006101.68276
Resolve Parlay309091412025-12-13 22:00:0542 days ago1765663205IN
0x7F66d16A...BA3611416
0 APE0.31648006101.68276
Resolve Parlay309091352025-12-13 21:59:5742 days ago1765663197IN
0x7F66d16A...BA3611416
0 APE0.31648006101.68276
Resolve Parlay309091272025-12-13 21:59:4742 days ago1765663187IN
0x7F66d16A...BA3611416
0 APE0.31761891101.68276
Resolve Parlay309091212025-12-13 21:59:4042 days ago1765663180IN
0x7F66d16A...BA3611416
0 APE0.31135525101.68276
Resolve Parlay309091122025-12-13 21:59:3242 days ago1765663172IN
0x7F66d16A...BA3611416
0 APE0.30907756101.68276
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
326519352026-01-21 16:46:003 days ago1769013960
0x7F66d16A...BA3611416
240,486.24119603 APE
326464882026-01-21 12:23:243 days ago1768998204
0x7F66d16A...BA3611416
320,648.32159471 APE
326462492026-01-21 12:15:413 days ago1768997741
0x7F66d16A...BA3611416
427,531.09545962 APE
325605982026-01-19 7:02:355 days ago1768806155
0x7F66d16A...BA3611416
35,000 APE
318324392025-12-31 15:54:1324 days ago1767196453
0x7F66d16A...BA3611416
2.09115662 APE
318324392025-12-31 15:54:1324 days ago1767196453
0x7F66d16A...BA3611416
9.90884337 APE
318229672025-12-31 9:59:4524 days ago1767175185
0x7F66d16A...BA3611416
12.20474281 APE
318229672025-12-31 9:59:4524 days ago1767175185
0x7F66d16A...BA3611416
6,542.79525718 APE
311292562025-12-18 2:49:2937 days ago1766026169
0x7F66d16A...BA3611416
1,079.4469449 APE
310192942025-12-15 23:37:4939 days ago1765841869
0x7F66d16A...BA3611416
1,495.8 APE
309093592025-12-13 22:06:2842 days ago1765663588
0x7F66d16A...BA3611416
6.48 APE
309093592025-12-13 22:06:2842 days ago1765663588
0x7F66d16A...BA3611416
155.52 APE
309092402025-12-13 22:02:3642 days ago1765663356
0x7F66d16A...BA3611416
3.84 APE
309092402025-12-13 22:02:3642 days ago1765663356
0x7F66d16A...BA3611416
92.16 APE
309092352025-12-13 22:02:2842 days ago1765663348
0x7F66d16A...BA3611416
3.546 APE
309092352025-12-13 22:02:2842 days ago1765663348
0x7F66d16A...BA3611416
85.104 APE
309092292025-12-13 22:02:2142 days ago1765663341
0x7F66d16A...BA3611416
4.096512 APE
309092292025-12-13 22:02:2142 days ago1765663341
0x7F66d16A...BA3611416
98.316288 APE
306172842025-12-09 3:35:3646 days ago1765251336
0x7F66d16A...BA3611416
2.90063836 APE
306172842025-12-09 3:35:3646 days ago1765251336
0x7F66d16A...BA3611416
997.09936163 APE
306170992025-12-09 3:32:2546 days ago1765251145
0x7F66d16A...BA3611416
2.45358731 APE
306170992025-12-09 3:32:2546 days ago1765251145
0x7F66d16A...BA3611416
997.54641268 APE
304647652025-12-07 4:33:5748 days ago1765082037
0x7F66d16A...BA3611416
0.47604373 APE
304647652025-12-07 4:33:5748 days ago1765082037
0x7F66d16A...BA3611416
199.52395626 APE
296781502025-12-02 17:47:3153 days ago1764697651
0x7F66d16A...BA3611416
0.1503465 APE
View All Internal Transactions

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
APENativeDecentralizedParlayPlatform

Compiler Version
v0.8.24+commit.e11b9ed9

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion, MIT license
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

contract APENativeDecentralizedParlayPlatform is
    Ownable,
    ERC721URIStorage,
    ReentrancyGuard,
    Pausable
{
    using SafeERC20 for IERC20;

    IERC721 public nftContract;

    struct Parlay {
        uint256 tokenId;
        string id;
        uint256 odds;
        uint256 wager;
        bool outcome;
        bool resolved;
        bool voided;
    }

    struct UserStats {
        uint256 totalBets;
        uint256 totalBetAmount;
        uint256 totalGamesWon;
        uint256 totalWinAmount;
        uint256 totalGamesLost;
        uint256 totalLossAmount;
    }
    mapping(address => UserStats) public userStats;

    mapping(uint256 => Parlay) public tokenIdToParlay;
    uint256 public totalLiquidityPool;
    uint256 public totalBetAmount;
    mapping(address => uint256) public depositTimestamp;
    uint256 public constant LOCK_PERIOD = 30 days;
    mapping(address => uint256) public liquidityProviders;
    address[] public liquidityProviderAddresses;
    mapping(address => uint256) public providerIndex;
    uint256 public nextTokenId;
    uint256[] public unresolvedParlays;
    mapping(uint256 => uint256) public unresolvedParlayIndex;
    uint256 public winningFee = 400000; // 4% (stored as 400000 / 10000000)
    uint256 public totalLiability;
    mapping(address => bool) public hasPlayed;
    address[] public allPlayers;
    mapping(address => uint256) public providerEarnings;
    mapping(address => uint256) public providerLosses;

    event BetPlaced(address indexed user, uint256 wager, uint256 tokenId);
    event LiquidityDeposited(address indexed provider, uint256 amount);
    event LiquidityWithdrawn(address indexed provider, uint256 amount);
    event ParlayResolved(
        address indexed user,
        uint256 tokenId,
        bool outcome,
        uint256 payout
    );
    event ParlayVoided(uint256 tokenId);
    event WinningFeeUpdated(uint256 newFee);

    constructor(
        address _nftContract,
        address _owner
    ) Ownable(_owner) ERC721("ParlayNFT", "PLNFT") {
        nftContract = IERC721(_nftContract);
    }

    function placeBet(
        string memory id,
        uint256 odds,
        uint256 wager,
        string memory tokenURI
    ) external payable nonReentrant whenNotPaused {
        require(msg.value > 0, "Wager must be greater than 0");
        require(odds > 0, "Odds must be greater than 0");
        require(totalLiquidityPool > 0, "No liquidity available");

        uint256 actualWager = msg.value;
        // Calculate potential payout based on net received (after tax)
        uint256 potentialPayout = (actualWager * odds) / 1e18 - actualWager;
        require(
            potentialPayout <= (totalLiquidityPool * 15) / 100,
            "Potential win exceeds 15% of liquidity pool"
        );

        uint256 totalLiabilityAfterBet = totalLiability + potentialPayout;

        require(
            totalLiabilityAfterBet <= totalLiquidityPool,
            "Insufficient liquidity to cover potential payout"
        );
        totalLiability += potentialPayout;

        uint256 tokenId = nextTokenId++;
        _safeMint(msg.sender, tokenId);
        _setTokenURI(tokenId, tokenURI);

        tokenIdToParlay[tokenId] = Parlay({
            id: id,
            tokenId: tokenId,
            odds: odds,
            wager: actualWager,
            outcome: false,
            resolved: false,
            voided: false
        });

        unresolvedParlayIndex[tokenId] = unresolvedParlays.length;
        unresolvedParlays.push(tokenId);
        totalBetAmount += actualWager;

        userStats[msg.sender].totalBets += 1;
        userStats[msg.sender].totalBetAmount += actualWager;

        if (!hasPlayed[msg.sender]) {
            hasPlayed[msg.sender] = true;
            allPlayers.push(msg.sender);
        }

        emit BetPlaced(msg.sender, actualWager, tokenId);
    }

    function depositLiquidity(
        uint256 amount
    ) external payable nonReentrant whenNotPaused {
        require(
            nftContract.balanceOf(msg.sender) > 0,
            "Must own at least one NFT to deposit liquidity"
        );
        require(msg.value > 0, "Deposit must be greater than 0");
        uint256 actualAmount = msg.value;

        if (liquidityProviders[msg.sender] == 0) {
            liquidityProviderAddresses.push(msg.sender);
            depositTimestamp[msg.sender] = block.timestamp;
            providerIndex[msg.sender] = liquidityProviderAddresses.length - 1;
        }
        liquidityProviders[msg.sender] += actualAmount;
        totalLiquidityPool += actualAmount;

        emit LiquidityDeposited(msg.sender, actualAmount);
    }

    function withdrawLiquidity(
        uint256 amount
    ) external nonReentrant whenNotPaused {
        require(amount > 0, "Withdrawal amount must be greater than 0");
        require(
            amount <= liquidityProviders[msg.sender],
            "Insufficient liquidity for provider"
        );

        uint256 lockedUntil = depositTimestamp[msg.sender] + LOCK_PERIOD;
        require(block.timestamp >= lockedUntil, "Liquidity is locked");

        uint256 remainingLiquidity = totalLiquidityPool - amount;
        require(
            totalLiability <= remainingLiquidity,
            "Withdrawal would leave insufficient coverage for active bets"
        );

        // Performance fee logic
        uint256 deposited = liquidityProviders[msg.sender];
        uint256 earnings = providerEarnings[msg.sender];
        uint256 losses = providerLosses[msg.sender];

        // Net profit = earnings - losses
        if (earnings > losses) {
            uint256 netProfit = earnings - losses;

            // If user is withdrawing part of their liquidity, prorate the profit
            uint256 proratedProfit = (netProfit * amount) / deposited;

            // 4% fee on that prorated profit
            uint256 fee = (proratedProfit * winningFee) / 10000000;
            uint256 payout = amount - fee;

            liquidityProviders[msg.sender] -= amount;
            totalLiquidityPool -= amount;

            (bool sent, ) = payable(msg.sender).call{value: payout}("");
            require(sent, "ETH transfer failed");

            // For sending fees to owner
            (bool feeSent, ) = payable(owner()).call{value: fee}("");
            require(feeSent, "Fee transfer failed");
        } else {
            // No profit → no fee
            liquidityProviders[msg.sender] -= amount;
            totalLiquidityPool -= amount;

            (bool sent, ) = payable(msg.sender).call{value: amount}("");
            require(sent, "ETH transfer failed");
        }

        if (liquidityProviders[msg.sender] == 0) {
            uint256 index = providerIndex[msg.sender];
            uint256 lastIndex = liquidityProviderAddresses.length - 1;

            if (index != lastIndex) {
                address lastProvider = liquidityProviderAddresses[lastIndex];
                liquidityProviderAddresses[index] = lastProvider;
                providerIndex[lastProvider] = index;
            }

            liquidityProviderAddresses.pop();
            delete providerIndex[msg.sender];
            delete depositTimestamp[msg.sender];
            delete providerEarnings[msg.sender];
            delete providerLosses[msg.sender];
        }

        emit LiquidityWithdrawn(msg.sender, amount);
    }

    function resolveParlay(
        uint256 tokenId,
        bool outcome
    ) external onlyOwner nonReentrant whenNotPaused {
        Parlay storage parlay = tokenIdToParlay[tokenId];
        require(!parlay.voided, "Parlay already canceled");
        require(!parlay.resolved, "Parlay already resolved");

        parlay.resolved = true;
        parlay.outcome = outcome;

        address user = ownerOf(tokenId);

        // Remove from unresolvedParlays
        _removeUnresolvedParlay(tokenId);

        uint256 providerCount = liquidityProviderAddresses.length;
        address[] memory providers = new address[](providerCount);
        uint256[] memory amounts = new uint256[](providerCount);
        uint256 totalProviderLiquidity = 0;

        for (uint256 i = 0; i < providerCount; i++) {
            address provider = liquidityProviderAddresses[i];
            uint256 amount = liquidityProviders[provider];
            providers[i] = provider;
            amounts[i] = amount;
            totalProviderLiquidity += amount;
        }

        if (outcome) {
            // Win: calculate gross payout
            uint256 payoutAmount = (parlay.wager * parlay.odds) / 1e18;
            require(
                payoutAmount <= (totalLiquidityPool * 15) / 100,
                "Payout exceeds 15% of pool"
            );
            uint256 fee = (payoutAmount * winningFee) / 10000000;
            uint256 amountToDeduct = payoutAmount - parlay.wager;
            uint256 finalPayout = payoutAmount - fee;

            // Deduct full payout (including fee) from providers
            for (uint256 i = 0; i < providers.length; i++) {
                address provider = providers[i];
                uint256 share = (amounts[i] * amountToDeduct) /
                    totalProviderLiquidity;
                liquidityProviders[provider] -= share;
                providerLosses[provider] += share;
            }

            totalLiquidityPool -= amountToDeduct;
            totalLiability -= amountToDeduct;

            (bool sent, ) = payable(user).call{value: finalPayout}("");
            require(sent, "ETH transfer failed");

            (bool feeSent, ) = payable(owner()).call{value: fee}("");
            require(feeSent, "ETH transfer failed");

            userStats[user].totalGamesWon += 1;
            userStats[user].totalWinAmount += finalPayout;

            emit ParlayResolved(user, tokenId, outcome, finalPayout);
        } else {
            // Loss: distribute wager to providers
            for (uint256 i = 0; i < providers.length; i++) {
                address provider = providers[i];
                uint256 share = (amounts[i] * parlay.wager) /
                    totalProviderLiquidity;
                liquidityProviders[provider] += share;
                providerEarnings[provider] += share;
            }
            totalLiquidityPool += parlay.wager;
            uint256 potentialPayout = (parlay.wager * parlay.odds) /
                1e18 -
                parlay.wager;
            totalLiability -= potentialPayout;
            userStats[user].totalGamesLost += 1;
            userStats[user].totalLossAmount += parlay.wager;

            emit ParlayResolved(user, tokenId, outcome, 0);
        }
    }

    function cancelParlay(uint256 tokenId) external onlyOwner nonReentrant {
        require(
            tokenIdToParlay[tokenId].resolved == false,
            "Parlay already resolved"
        );
        require(
            tokenIdToParlay[tokenId].voided == false,
            "Parlay already canceled"
        );

        Parlay storage parlay = tokenIdToParlay[tokenId];
        parlay.voided = true;
        address user = ownerOf(tokenId);

        (bool sent, ) = payable(user).call{value: parlay.wager}("");
        require(sent, "ETH transfer failed");

        totalBetAmount -= parlay.wager;
        uint256 potentialPayout = (parlay.wager * parlay.odds) /
            1e18 -
            parlay.wager;
        totalLiability -= potentialPayout;

        _removeUnresolvedParlay(tokenId);

        emit ParlayVoided(tokenId);
    }

    function getUserParlays(
        address user
    ) external view returns (Parlay[] memory) {
        uint256 balance = balanceOf(user);
        Parlay[] memory parlays = new Parlay[](balance);

        if (balance == 0) return parlays;

        uint256 currentIndex = 0;
        for (uint256 i = 0; i < nextTokenId; i++) {
            try this.ownerOf(i) returns (address owner) {
                if (owner == user) {
                    parlays[currentIndex] = tokenIdToParlay[i];
                    currentIndex++;
                }
            } catch {
                continue;
            }
        }

        return parlays;
    }

    function getUnresolvedParlays() external view returns (Parlay[] memory) {
        uint256 unresolvedCount = unresolvedParlays.length;
        Parlay[] memory parlaysTemp = new Parlay[](unresolvedCount);

        for (uint256 i = 0; i < unresolvedCount; i++) {
            uint256 tokenId = unresolvedParlays[i];
            parlaysTemp[i] = tokenIdToParlay[tokenId];
        }

        return parlaysTemp;
    }

    function getUnresolvedParlaysLength() external view returns (uint256) {
        return unresolvedParlays.length;
    }

    function getLiquidityProviderDetails(
        address provider
    )
        external
        view
        returns (uint256 deposit, uint256 earnings, uint256 losses)
    {
        return (
            liquidityProviders[provider],
            providerEarnings[provider],
            providerLosses[provider]
        );
    }

    function setWinningFee(uint256 newFee) external onlyOwner {
        winningFee = newFee;
        emit WinningFeeUpdated(newFee);
    }

    function _removeUnresolvedParlay(uint256 tokenId) internal {
        uint256 index = unresolvedParlayIndex[tokenId];
        uint256 lastTokenId = unresolvedParlays[unresolvedParlays.length - 1];

        unresolvedParlays[index] = lastTokenId;
        unresolvedParlayIndex[lastTokenId] = index;

        unresolvedParlays.pop();
        delete unresolvedParlayIndex[tokenId];
    }

    function pause() external onlyOwner {
        _pause();
    }

    function unpause() external onlyOwner {
        _unpause();
    }

    function getUserStats(
        address user
    ) external view returns (UserStats memory) {
        return userStats[user];
    }

    function getAllPlayers() external view returns (address[] memory) {
        return allPlayers;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../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.
 *
 * The initial owner is set to the address provided by the deployer. 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;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @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 {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @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 {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _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);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

/**
 * @dev Standard ERC20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}

File 4 of 31 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../utils/introspection/IERC165.sol";

File 5 of 31 : IERC4906.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4906.sol)

pragma solidity ^0.8.20;

import {IERC165} from "./IERC165.sol";
import {IERC721} from "./IERC721.sol";

/// @title EIP-721 Metadata Update Extension
interface IERC4906 is IERC165, IERC721 {
    /// @dev This event emits when the metadata of a token is changed.
    /// So that the third-party platforms such as NFT market could
    /// timely update the images and related attributes of the NFT.
    event MetadataUpdate(uint256 _tokenId);

    /// @dev This event emits when the metadata of a range of tokens is changed.
    /// So that the third-party platforms such as NFT market could
    /// timely update the images and related attributes of the NFTs.
    event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);
}

File 6 of 31 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC721.sol)

pragma solidity ^0.8.20;

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 */
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
    mapping(address account => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

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

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

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

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

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

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

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, value);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `value`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `value`.
     */
    function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, value);
        _transfer(from, to, value);
        return true;
    }

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _transfer(address from, address to, uint256 value) internal {
        if (from == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        if (to == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(from, to, value);
    }

    /**
     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
     * this function.
     *
     * Emits a {Transfer} event.
     */
    function _update(address from, address to, uint256 value) internal virtual {
        if (from == address(0)) {
            // Overflow check required: The rest of the code assumes that totalSupply never overflows
            _totalSupply += value;
        } else {
            uint256 fromBalance = _balances[from];
            if (fromBalance < value) {
                revert ERC20InsufficientBalance(from, fromBalance, value);
            }
            unchecked {
                // Overflow not possible: value <= fromBalance <= totalSupply.
                _balances[from] = fromBalance - value;
            }
        }

        if (to == address(0)) {
            unchecked {
                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
                _totalSupply -= value;
            }
        } else {
            unchecked {
                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
                _balances[to] += value;
            }
        }

        emit Transfer(from, to, value);
    }

    /**
     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
     * Relies on the `_update` mechanism
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _mint(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(address(0), account, value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
     * Relies on the `_update` mechanism.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead
     */
    function _burn(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        _update(account, address(0), value);
    }

    /**
     * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address owner, address spender, uint256 value) internal {
        _approve(owner, spender, value, true);
    }

    /**
     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
     *
     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
     * `Approval` event during `transferFrom` operations.
     *
     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
     * true using the following override:
     * ```
     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
     *     super._approve(owner, spender, value, true);
     * }
     * ```
     *
     * Requirements are the same as {_approve}.
     */
    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
        if (owner == address(0)) {
            revert ERC20InvalidApprover(address(0));
        }
        if (spender == address(0)) {
            revert ERC20InvalidSpender(address(0));
        }
        _allowances[owner][spender] = value;
        if (emitEvent) {
            emit Approval(owner, spender, value);
        }
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `value`.
     *
     * Does not update the allowance value in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Does not emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            if (currentAllowance < value) {
                revert ERC20InsufficientAllowance(spender, currentAllowance, value);
            }
            unchecked {
                _approve(owner, spender, currentAllowance - value, false);
            }
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";

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

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

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

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}

File 12 of 31 : ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.20;

import {IERC721} from "./IERC721.sol";
import {IERC721Receiver} from "./IERC721Receiver.sol";
import {IERC721Metadata} from "./extensions/IERC721Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {Strings} from "../../utils/Strings.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {IERC721Errors} from "../../interfaces/draft-IERC6093.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}.
 */
abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Errors {
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    mapping(uint256 tokenId => address) private _owners;

    mapping(address owner => uint256) private _balances;

    mapping(uint256 tokenId => address) private _tokenApprovals;

    mapping(address owner => mapping(address operator => 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 returns (uint256) {
        if (owner == address(0)) {
            revert ERC721InvalidOwner(address(0));
        }
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual returns (address) {
        return _requireOwned(tokenId);
    }

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

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

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

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string.concat(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 {
        _approve(to, tokenId, _msgSender());
    }

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

        return _getApproved(tokenId);
    }

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

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

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(address from, address to, uint256 tokenId) public virtual {
        if (to == address(0)) {
            revert ERC721InvalidReceiver(address(0));
        }
        // Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists
        // (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.
        address previousOwner = _update(to, tokenId, _msgSender());
        if (previousOwner != from) {
            revert ERC721IncorrectOwner(from, tokenId, previousOwner);
        }
    }

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

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual {
        transferFrom(from, to, tokenId);
        _checkOnERC721Received(from, to, tokenId, data);
    }

    /**
     * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
     *
     * IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the
     * core ERC721 logic MUST be matched with the use of {_increaseBalance} to keep balances
     * consistent with ownership. The invariant to preserve is 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`.
     */
    function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
        return _owners[tokenId];
    }

    /**
     * @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted.
     */
    function _getApproved(uint256 tokenId) internal view virtual returns (address) {
        return _tokenApprovals[tokenId];
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in
     * particular (ignoring whether it is owned by `owner`).
     *
     * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
     * assumption.
     */
    function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {
        return
            spender != address(0) &&
            (owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);
    }

    /**
     * @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner.
     * Reverts if `spender` does not have approval from the provided `owner` for the given token or for all its assets
     * the `spender` for the specific `tokenId`.
     *
     * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
     * assumption.
     */
    function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual {
        if (!_isAuthorized(owner, spender, tokenId)) {
            if (owner == address(0)) {
                revert ERC721NonexistentToken(tokenId);
            } else {
                revert ERC721InsufficientApproval(spender, tokenId);
            }
        }
    }

    /**
     * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
     *
     * NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that
     * a uint256 would ever overflow from increments when these increments are bounded to uint128 values.
     *
     * WARNING: Increasing an account's balance using this function tends to be paired with an override of the
     * {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership
     * remain consistent with one another.
     */
    function _increaseBalance(address account, uint128 value) internal virtual {
        unchecked {
            _balances[account] += value;
        }
    }

    /**
     * @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner
     * (or `to`) is the zero address. Returns the owner of the `tokenId` before the update.
     *
     * The `auth` argument is optional. If the value passed is non 0, then this function will check that
     * `auth` is either the owner of the token, or approved to operate on the token (by the owner).
     *
     * Emits a {Transfer} event.
     *
     * NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.
     */
    function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) {
        address from = _ownerOf(tokenId);

        // Perform (optional) operator check
        if (auth != address(0)) {
            _checkAuthorized(from, auth, tokenId);
        }

        // Execute the update
        if (from != address(0)) {
            // Clear approval. No need to re-authorize or emit the Approval event
            _approve(address(0), tokenId, address(0), false);

            unchecked {
                _balances[from] -= 1;
            }
        }

        if (to != address(0)) {
            unchecked {
                _balances[to] += 1;
            }
        }

        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        return from;
    }

    /**
     * @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 {
        if (to == address(0)) {
            revert ERC721InvalidReceiver(address(0));
        }
        address previousOwner = _update(to, tokenId, address(0));
        if (previousOwner != address(0)) {
            revert ERC721InvalidSender(address(0));
        }
    }

    /**
     * @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance.
     *
     * 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 {
        _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);
        _checkOnERC721Received(address(0), to, tokenId, data);
    }

    /**
     * @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 {
        address previousOwner = _update(address(0), tokenId, address(0));
        if (previousOwner == address(0)) {
            revert ERC721NonexistentToken(tokenId);
        }
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(address from, address to, uint256 tokenId) internal {
        if (to == address(0)) {
            revert ERC721InvalidReceiver(address(0));
        }
        address previousOwner = _update(to, tokenId, address(0));
        if (previousOwner == address(0)) {
            revert ERC721NonexistentToken(tokenId);
        } else if (previousOwner != from) {
            revert ERC721IncorrectOwner(from, tokenId, previousOwner);
        }
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients
     * are aware of the ERC721 standard 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 like {safeTransferFrom} in the sense that it invokes
     * {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `tokenId` token must exist and be owned by `from`.
     * - `to` cannot be the zero address.
     * - `from` cannot be the zero address.
     * - 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) internal {
        _safeTransfer(from, to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
        _transfer(from, to, tokenId);
        _checkOnERC721Received(from, to, tokenId, data);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is
     * either the owner of the token, or approved to operate on all tokens held by this owner.
     *
     * Emits an {Approval} event.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address to, uint256 tokenId, address auth) internal {
        _approve(to, tokenId, auth, true);
    }

    /**
     * @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not
     * emitted in the context of transfers.
     */
    function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual {
        // Avoid reading the owner unless necessary
        if (emitEvent || auth != address(0)) {
            address owner = _requireOwned(tokenId);

            // We do not use _isAuthorized because single-token approvals should not be able to call approve
            if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) {
                revert ERC721InvalidApprover(auth);
            }

            if (emitEvent) {
                emit Approval(owner, to, tokenId);
            }
        }

        _tokenApprovals[tokenId] = to;
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Requirements:
     * - operator can't be the address zero.
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
        if (operator == address(0)) {
            revert ERC721InvalidOperator(operator);
        }
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned).
     * Returns the owner.
     *
     * Overrides to ownership logic should be done to {_ownerOf}.
     */
    function _requireOwned(uint256 tokenId) internal view returns (address) {
        address owner = _ownerOf(tokenId);
        if (owner == address(0)) {
            revert ERC721NonexistentToken(tokenId);
        }
        return owner;
    }

    /**
     * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target address. This will revert if the
     * recipient doesn't accept the token transfer. 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
     */
    function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data) private {
        if (to.code.length > 0) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
                if (retval != IERC721Receiver.onERC721Received.selector) {
                    revert ERC721InvalidReceiver(to);
                }
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert ERC721InvalidReceiver(to);
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/ERC721URIStorage.sol)

pragma solidity ^0.8.20;

import {ERC721} from "../ERC721.sol";
import {Strings} from "../../../utils/Strings.sol";
import {IERC4906} from "../../../interfaces/IERC4906.sol";
import {IERC165} from "../../../interfaces/IERC165.sol";

/**
 * @dev ERC721 token with storage based token URI management.
 */
abstract contract ERC721URIStorage is IERC4906, ERC721 {
    using Strings for uint256;

    // Interface ID as defined in ERC-4906. This does not correspond to a traditional interface ID as ERC-4906 only
    // defines events and does not include any external function.
    bytes4 private constant ERC4906_INTERFACE_ID = bytes4(0x49064906);

    // Optional mapping for token URIs
    mapping(uint256 tokenId => string) private _tokenURIs;

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

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

        string memory _tokenURI = _tokenURIs[tokenId];
        string memory base = _baseURI();

        // If there is no base URI, return the token URI.
        if (bytes(base).length == 0) {
            return _tokenURI;
        }
        // If both are set, concatenate the baseURI and tokenURI (via string.concat).
        if (bytes(_tokenURI).length > 0) {
            return string.concat(base, _tokenURI);
        }

        return super.tokenURI(tokenId);
    }

    /**
     * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
     *
     * Emits {MetadataUpdate}.
     */
    function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
        _tokenURIs[tokenId] = _tokenURI;
        emit MetadataUpdate(tokenId);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.20;

import {IERC721} from "../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);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../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 address zero.
     *
     * 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 16 of 31 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.20;

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @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.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * 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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) 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 FailedInnerCall();
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "./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);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @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 towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // (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 = x * y; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                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.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

            ///////////////////////////////////////////////
            // 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.

            uint256 twos = denominator & (0 - denominator);
            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 (unsignedRoundsUp(rounding) && 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
     * towards zero.
     *
     * 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 + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * 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 + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10 of a positive value rounded towards zero.
     * 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 + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256 of a positive value rounded towards zero.
     * 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 + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
        }
    }

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.20;

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    bool private _paused;

    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        _status = ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)

pragma solidity ^0.8.20;

import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";

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

    /**
     * @dev The `value` string doesn't fit in the specified `length`.
     */
    error StringsInsufficientHexLength(uint256 value, uint256 length);

    /**
     * @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), HEX_DIGITS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toStringSigned(int256 value) internal pure returns (string memory) {
        return string.concat(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) {
        uint256 localValue = value;
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = HEX_DIGITS[localValue & 0xf];
            localValue >>= 4;
        }
        if (localValue != 0) {
            revert StringsInsufficientHexLength(value, length);
        }
        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 bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

contract APEDecentralizedParlayPlatform is
    Ownable,
    ERC721URIStorage,
    ReentrancyGuard,
    Pausable
{
    using SafeERC20 for IERC20;

    IERC20 public token;
    IERC721 public nftContract;

    struct Parlay {
        uint256 tokenId;
        string id;
        uint256 odds;
        uint256 wager;
        bool outcome;
        bool resolved;
        bool voided;
    }

    struct UserStats {
        uint256 totalBets;
        uint256 totalBetAmount;
        uint256 totalGamesWon;
        uint256 totalWinAmount;
        uint256 totalGamesLost;
        uint256 totalLossAmount;
    }
    mapping(address => UserStats) public userStats;

    mapping(uint256 => Parlay) public tokenIdToParlay;
    uint256 public totalLiquidityPool;
    uint256 public totalBetAmount;
    mapping(address => uint256) public depositTimestamp;
    uint256 public constant LOCK_PERIOD = 30 days;
    mapping(address => uint256) public liquidityProviders;
    address[] public liquidityProviderAddresses;
    mapping(address => uint256) public providerIndex;
    uint256 public nextTokenId;
    uint256[] public unresolvedParlays;
    mapping(uint256 => uint256) public unresolvedParlayIndex;
    uint256 public winningFee = 400000; // 4% (stored as 400000 / 10000000)
    uint256 public totalLiability;
    mapping(address => bool) public hasPlayed;
    address[] public allPlayers;
    mapping(address => uint256) public providerEarnings;
    mapping(address => uint256) public providerLosses;

    event BetPlaced(address indexed user, uint256 wager, uint256 tokenId);
    event LiquidityDeposited(address indexed provider, uint256 amount);
    event LiquidityWithdrawn(address indexed provider, uint256 amount);
    event ParlayResolved(
        address indexed user,
        uint256 tokenId,
        bool outcome,
        uint256 payout
    );
    event ParlayVoided(uint256 tokenId);
    event WinningFeeUpdated(uint256 newFee);

    constructor(
        IERC20 _token,
        address _nftContract,
        address _owner
    ) Ownable(_owner) ERC721("ParlayNFT", "PLNFT") {
        token = _token;
        nftContract = IERC721(_nftContract);
    }

    function placeBet(
        string memory id,
        uint256 odds,
        uint256 wager,
        string memory tokenURI
    ) external nonReentrant whenNotPaused {
        require(wager > 0, "Wager must be greater than 0");
        require(odds > 0, "Odds must be greater than 0");
        require(totalLiquidityPool > 0, "No liquidity available");

        uint256 actualWager = wager;
        // Calculate potential payout based on net received (after tax)
        uint256 potentialPayout = (actualWager * odds) / 1e18 - actualWager;
        require(
            potentialPayout <= (totalLiquidityPool * 15) / 100,
            "Potential win exceeds 15% of liquidity pool"
        );

        uint256 totalLiabilityAfterBet = totalLiability + potentialPayout;

        require(
            totalLiabilityAfterBet <= totalLiquidityPool,
            "Insufficient liquidity to cover potential payout"
        );
        totalLiability += potentialPayout;

        token.safeTransferFrom(msg.sender, address(this), wager);

        uint256 tokenId = nextTokenId++;
        _safeMint(msg.sender, tokenId);
        _setTokenURI(tokenId, tokenURI);

        tokenIdToParlay[tokenId] = Parlay({
            id: id,
            tokenId: tokenId,
            odds: odds,
            wager: actualWager,
            outcome: false,
            resolved: false,
            voided: false
        });

        unresolvedParlayIndex[tokenId] = unresolvedParlays.length;
        unresolvedParlays.push(tokenId);
        totalBetAmount += actualWager;

        userStats[msg.sender].totalBets += 1;
        userStats[msg.sender].totalBetAmount += actualWager;

        if (!hasPlayed[msg.sender]) {
            hasPlayed[msg.sender] = true;
            allPlayers.push(msg.sender);
        }

        emit BetPlaced(msg.sender, actualWager, tokenId);
    }

    function depositLiquidity(
        uint256 amount
    ) external nonReentrant whenNotPaused {
        require(
            nftContract.balanceOf(msg.sender) > 0,
            "Must own at least one NFT to deposit liquidity"
        );
        require(amount > 0, "Deposit must be greater than 0");
        uint256 actualAmount = amount;
        token.safeTransferFrom(msg.sender, address(this), amount);

        if (liquidityProviders[msg.sender] == 0) {
            liquidityProviderAddresses.push(msg.sender);
            depositTimestamp[msg.sender] = block.timestamp;
            providerIndex[msg.sender] = liquidityProviderAddresses.length - 1;
        }
        liquidityProviders[msg.sender] += actualAmount;
        totalLiquidityPool += actualAmount;

        emit LiquidityDeposited(msg.sender, actualAmount);
    }

    function withdrawLiquidity(
        uint256 amount
    ) external nonReentrant whenNotPaused {
        require(amount > 0, "Withdrawal amount must be greater than 0");
        require(
            amount <= liquidityProviders[msg.sender],
            "Insufficient liquidity for provider"
        );

        uint256 lockedUntil = depositTimestamp[msg.sender] + LOCK_PERIOD;
        require(block.timestamp >= lockedUntil, "Liquidity is locked");

        uint256 remainingLiquidity = totalLiquidityPool - amount;
        require(
            totalLiability <= remainingLiquidity,
            "Withdrawal would leave insufficient coverage for active bets"
        );

        // Performance fee logic
        uint256 deposited = liquidityProviders[msg.sender];
        uint256 earnings = providerEarnings[msg.sender];
        uint256 losses = providerLosses[msg.sender];

        // Net profit = earnings - losses
        if (earnings > losses) {
            uint256 netProfit = earnings - losses;

            // If user is withdrawing part of their liquidity, prorate the profit
            uint256 proratedProfit = (netProfit * amount) / deposited;

            // 4% fee on that prorated profit
            uint256 fee = (proratedProfit * winningFee) / 10000000;
            uint256 payout = amount - fee;

            liquidityProviders[msg.sender] -= amount;
            totalLiquidityPool -= amount;

            token.safeTransfer(msg.sender, payout);
            token.safeTransfer(owner(), fee);
        } else {
            // No profit → no fee
            liquidityProviders[msg.sender] -= amount;
            totalLiquidityPool -= amount;
            token.safeTransfer(msg.sender, amount);
        }

        if (liquidityProviders[msg.sender] == 0) {
            uint256 index = providerIndex[msg.sender];
            uint256 lastIndex = liquidityProviderAddresses.length - 1;

            if (index != lastIndex) {
                address lastProvider = liquidityProviderAddresses[lastIndex];
                liquidityProviderAddresses[index] = lastProvider;
                providerIndex[lastProvider] = index;
            }

            liquidityProviderAddresses.pop();
            delete providerIndex[msg.sender];
            delete depositTimestamp[msg.sender];
            delete providerEarnings[msg.sender];
            delete providerLosses[msg.sender];
        }

        emit LiquidityWithdrawn(msg.sender, amount);
    }

    function resolveParlay(
        uint256 tokenId,
        bool outcome
    ) external onlyOwner nonReentrant whenNotPaused {
        Parlay storage parlay = tokenIdToParlay[tokenId];
        require(!parlay.voided, "Parlay already canceled");
        require(!parlay.resolved, "Parlay already resolved");

        parlay.resolved = true;
        parlay.outcome = outcome;

        address user = ownerOf(tokenId);

        // Remove from unresolvedParlays
        _removeUnresolvedParlay(tokenId);

        uint256 providerCount = liquidityProviderAddresses.length;
        address[] memory providers = new address[](providerCount);
        uint256[] memory amounts = new uint256[](providerCount);
        uint256 totalProviderLiquidity = 0;

        for (uint256 i = 0; i < providerCount; i++) {
            address provider = liquidityProviderAddresses[i];
            uint256 amount = liquidityProviders[provider];
            providers[i] = provider;
            amounts[i] = amount;
            totalProviderLiquidity += amount;
        }

        if (outcome) {
            // Win: calculate gross payout
            uint256 payoutAmount = (parlay.wager * parlay.odds) / 1e18;
            require(
                payoutAmount <= (totalLiquidityPool * 15) / 100,
                "Payout exceeds 15% of pool"
            );
            uint256 fee = (payoutAmount * winningFee) / 10000000;
            uint256 amountToDeduct = payoutAmount - parlay.wager;
            uint256 finalPayout = payoutAmount - fee;

            // Deduct full payout (including fee) from providers
            for (uint256 i = 0; i < providers.length; i++) {
                address provider = providers[i];
                uint256 share = (amounts[i] * amountToDeduct) /
                    totalProviderLiquidity;
                liquidityProviders[provider] -= share;
                providerLosses[provider] += share;
            }

            totalLiquidityPool -= amountToDeduct;
            totalLiability -= amountToDeduct;

            token.safeTransfer(user, finalPayout);
            token.safeTransfer(owner(), fee);
            userStats[user].totalGamesWon += 1;
            userStats[user].totalWinAmount += finalPayout;

            emit ParlayResolved(user, tokenId, outcome, finalPayout);
        } else {
            // Loss: distribute wager to providers
            for (uint256 i = 0; i < providers.length; i++) {
                address provider = providers[i];
                uint256 share = (amounts[i] * parlay.wager) /
                    totalProviderLiquidity;
                liquidityProviders[provider] += share;
                providerEarnings[provider] += share;
            }
            totalLiquidityPool += parlay.wager;
            uint256 potentialPayout = (parlay.wager * parlay.odds) /
                1e18 -
                parlay.wager;
            totalLiability -= potentialPayout;
            userStats[user].totalGamesLost += 1;
            userStats[user].totalLossAmount += parlay.wager;

            emit ParlayResolved(user, tokenId, outcome, 0);
        }
    }

    function cancelParlay(uint256 tokenId) external onlyOwner nonReentrant {
        require(
            tokenIdToParlay[tokenId].resolved == false,
            "Parlay already resolved"
        );
        require(
            tokenIdToParlay[tokenId].voided == false,
            "Parlay already canceled"
        );

        Parlay storage parlay = tokenIdToParlay[tokenId];
        parlay.voided = true;
        address user = ownerOf(tokenId);
        token.safeTransfer(user, parlay.wager);
        totalBetAmount -= parlay.wager;
        uint256 potentialPayout = (parlay.wager * parlay.odds) /
            1e18 -
            parlay.wager;
        totalLiability -= potentialPayout;

        _removeUnresolvedParlay(tokenId);

        emit ParlayVoided(tokenId);
    }

    function getUserParlays(
        address user
    ) external view returns (Parlay[] memory) {
        uint256 balance = balanceOf(user);
        Parlay[] memory parlays = new Parlay[](balance);

        if (balance == 0) return parlays;

        uint256 currentIndex = 0;
        for (uint256 i = 0; i < nextTokenId; i++) {
            try this.ownerOf(i) returns (address owner) {
                if (owner == user) {
                    parlays[currentIndex] = tokenIdToParlay[i];
                    currentIndex++;
                }
            } catch {
                continue;
            }
        }

        return parlays;
    }

    function getUnresolvedParlays() external view returns (Parlay[] memory) {
        uint256 unresolvedCount = unresolvedParlays.length;
        Parlay[] memory parlaysTemp = new Parlay[](unresolvedCount);

        for (uint256 i = 0; i < unresolvedCount; i++) {
            uint256 tokenId = unresolvedParlays[i];
            parlaysTemp[i] = tokenIdToParlay[tokenId];
        }

        return parlaysTemp;
    }

    function getUnresolvedParlaysLength() external view returns (uint256) {
        return unresolvedParlays.length;
    }

    function getLiquidityProviderDetails(
        address provider
    )
        external
        view
        returns (uint256 deposit, uint256 earnings, uint256 losses)
    {
        return (
            liquidityProviders[provider],
            providerEarnings[provider],
            providerLosses[provider]
        );
    }

    function setWinningFee(uint256 newFee) external onlyOwner {
        winningFee = newFee;
        emit WinningFeeUpdated(newFee);
    }

    function _removeUnresolvedParlay(uint256 tokenId) internal {
        uint256 index = unresolvedParlayIndex[tokenId];
        uint256 lastTokenId = unresolvedParlays[unresolvedParlays.length - 1];

        unresolvedParlays[index] = lastTokenId;
        unresolvedParlayIndex[lastTokenId] = index;

        unresolvedParlays.pop();
        delete unresolvedParlayIndex[tokenId];
    }

    function pause() external onlyOwner {
        _pause();
    }

    function unpause() external onlyOwner {
        _unpause();
    }

    function getUserStats(
        address user
    ) external view returns (UserStats memory) {
        return userStats[user];
    }

    function getAllPlayers() external view returns (address[] memory) {
        return allPlayers;
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";

contract APEPredicts is ReentrancyGuard, Ownable, Pausable {
    uint256 public feePercentage = 42; // Default fee percentage (4.2%)
    uint256 public creatorFeePercentile = 100; // Creator fee percentage (10% represented as 100 basis points)

    enum GameType {
        Election,
        Coin
    }

    struct Game {
        uint256 id;
        string gameName;
        string banner;
        GameType gameType;
        string candidateA;
        string candidateB;
        uint256 initialPrice;
        uint256 finalPrice;
        uint256 expiryTime;
        uint256 lockTime;
        uint256 totalPoolA;
        uint256 totalPoolB;
        bool resolved;
        uint256 winnerPool;
        uint256 feePercent;
        string market;
        address creator;
        uint status; // 1 pending 2 rejected 3 approved 4 cancelled
    }

    struct GameDeposit {
        address user;
        uint256 amount;
        uint256 timestamp;
        uint8 pool;
    }

    struct LeaderboardEntry {
        address player;
        uint256 totalDeposits;
        uint256 totalWinnings;
    }

    mapping(uint256 => Game) public games;
    mapping(uint256 => mapping(address => uint256)) public depositsA;
    mapping(uint256 => mapping(address => uint256)) public depositsB;

    mapping(uint256 => GameDeposit[]) public depositHistory;
    mapping(address => LeaderboardEntry) public leaderboard;

    address[] public players;

    uint256 public gameCount;

    constructor() Ownable(msg.sender) {}

    event GameCreated(
        uint256 gameId,
        string gameName,
        GameType gameType,
        string candidateA,
        string candidateB,
        uint256 initialPrice,
        uint256 expiryTime,
        uint256 lockTime,
        uint256 feePercent,
        string banner,
        address creator,
        uint status
    );

    event Deposit(
        address indexed user,
        uint256 gameId,
        uint256 amount,
        uint8 option
    );

    event GameResolved(uint256 gameId, uint8 winner);
    event Payout(address indexed user, uint256 gameId, uint256 amount);
    event FeeUpdated(uint256 newfeePercentage);
    event GameCancelled(uint256 gameId);

    modifier gameNotLocked(uint256 gameId) {
        require(
            block.timestamp < games[gameId].lockTime,
            "Deposits are locked for this game"
        );
        _;
    }

    modifier gameApproved(uint256 gameId) {
        require(games[gameId].status == 3, "Game not approved or canceled");
        _;
    }

    modifier gameNotExpired(uint256 gameId) {
        require(block.timestamp < games[gameId].expiryTime, "game has expired");
        _;
    }

    modifier gameResolved(uint256 gameId) {
        require(games[gameId].resolved, "Game has not been resolved yet");
        _;
    }

    function _createGame(
        string memory _gameName,
        GameType _gameType,
        string memory _candidateA,
        string memory _candidateB,
        uint256 _initialPrice,
        uint256 _expiryTime,
        uint256 _lockTime,
        string memory _market,
        string memory _banner,
        address _creator,
        uint _status
    ) internal {
        require(_expiryTime > block.timestamp, "Expiry must be in the future");
        require(_lockTime < _expiryTime, "Lock time must be before expiry");

        gameCount++;
        games[gameCount] = Game({
            id: gameCount,
            gameName: _gameName,
            gameType: _gameType,
            candidateA: _candidateA,
            candidateB: _candidateB,
            initialPrice: _initialPrice,
            finalPrice: 0,
            expiryTime: _expiryTime,
            lockTime: _lockTime,
            totalPoolA: 0,
            totalPoolB: 0,
            resolved: false,
            winnerPool: 0,
            feePercent: feePercentage,
            market: _market,
            banner: _banner,
            creator: _creator,
            status: _status
        });

        emit GameCreated(
            gameCount,
            _gameName,
            _gameType,
            _candidateA,
            _candidateB,
            _initialPrice,
            _expiryTime,
            _lockTime,
            feePercentage,
            _banner,
            _creator,
            _status
        );
    }

    function createElectionGame(
        string memory _gameName,
        uint256 _expiryTime,
        uint256 _lockTime,
        string memory _market,
        string memory _candidateA,
        string memory _candidateB,
        string memory _banner,
        address _creator
    ) public {
        _createGame(
            _gameName,
            GameType.Election,
            _candidateA,
            _candidateB,
            0,
            _expiryTime,
            _lockTime,
            _market,
            _banner,
            owner() == msg.sender ? owner() : _creator,
            3
        );
    }

    function createCoinGame(
        string memory _gameName,
        uint256 _expiryTime,
        uint256 _lockTime,
        string memory _market,
        uint256 _initialPrice,
        string memory _banner,
        address _creator
    ) public {
        _createGame(
            _gameName,
            GameType.Coin,
            "", // No candidates for Coin game
            "",
            _initialPrice,
            _expiryTime,
            _lockTime,
            _market,
            _banner,
            owner() == msg.sender ? owner() : _creator,
            3
        );
    }

    function updateGameStatus(uint256 gameId, uint newStatus) public onlyOwner {
        Game storage game = games[gameId];
        game.status = newStatus;
    }

    function resolveGame(
        uint256 gameId,
        uint8 winner,
        uint256 _finalPrice
    ) public gameApproved(gameId) onlyOwner {
        Game storage game = games[gameId];
        require(!game.resolved, "game already resolved");
        require(winner == 1 || winner == 2, "Invalid winner");
        require(block.timestamp >= game.expiryTime, "Game not yet expired");
        game.resolved = true;
        game.winnerPool = winner;

        if (game.gameType == GameType.Coin) {
            game.finalPrice = _finalPrice;
        }

        uint256 losingPool = winner == 1 ? game.totalPoolB : game.totalPoolA;

        uint256 totalFee = (losingPool * feePercentage) / 1000;
        uint256 creatorFee = (totalFee * creatorFeePercentile) / 1000;
        uint256 ownerFee = totalFee - creatorFee;

        if (game.creator == owner()) {
            payable(owner()).transfer(totalFee);
        } else {
            payable(owner()).transfer(ownerFee);
            payable(game.creator).transfer(creatorFee);
        }

        emit GameResolved(gameId, winner);
    }

    function getGameDetails(
        uint256 gameId
    ) public view returns (Game memory game, GameDeposit[] memory deposits) {
        game = games[gameId];
        deposits = depositHistory[gameId];
    }

    function getGames(
        bool includeResolved,
        uint status,
        address creator
    ) public view returns (Game[] memory) {
        uint256 count = 0;
        for (uint256 i = 1; i <= gameCount; i++) {
            if (
                games[i].resolved == includeResolved &&
                games[i].status == status &&
                (creator == address(0) || games[i].creator == creator)
            ) {
                count++;
            }
        }

        Game[] memory gamesList = new Game[](count);

        uint256 index = 0;
        for (uint256 i = 1; i <= gameCount; i++) {
            if (
                games[i].resolved == includeResolved &&
                games[i].status == status &&
                (creator == address(0) || games[i].creator == creator)
            ) {
                gamesList[index] = games[i];
                index++;
            }
        }

        return gamesList;
    }

    function deposit(
        uint256 gameId,
        uint8 option
    )
        public
        payable
        gameApproved(gameId)
        gameNotLocked(gameId)
        gameNotExpired(gameId)
        nonReentrant
        whenNotPaused
    {
        require(option == 1 || option == 2, "Invalid option");
        require(msg.value > 0, "Deposit must be greater than 0");
        Game storage game = games[gameId];
        require(!game.resolved, "Game already resolved");
        depositHistory[gameId].push(
            GameDeposit({
                user: msg.sender,
                amount: msg.value,
                timestamp: block.timestamp,
                pool: option
            })
        );

        if (option == 1) {
            depositsA[gameId][msg.sender] += msg.value;
            games[gameId].totalPoolA += msg.value;
        } else {
            depositsB[gameId][msg.sender] += msg.value;
            games[gameId].totalPoolB += msg.value;
        }

        if (leaderboard[msg.sender].player == address(0)) {
            players.push(msg.sender);
            leaderboard[msg.sender].player = msg.sender;
        }

        leaderboard[msg.sender].totalDeposits += msg.value;

        emit Deposit(msg.sender, gameId, msg.value, option);
    }

    function getDepositsForGame(
        uint256 gameId
    ) public view returns (GameDeposit[] memory) {
        return depositHistory[gameId];
    }

    function getClaimableOrPendingGames(
        address user
    )
        public
        view
        returns (
            uint256[] memory claimableGameIds,
            uint256[] memory pendingGameIds
        )
    {
        uint256 claimableCount = 0;
        uint256 pendingCount = 0;

        for (uint256 i = 1; i <= gameCount; i++) {
            Game storage game = games[i];

            if (!game.resolved) {
                if (depositsA[i][user] > 0 || depositsB[i][user] > 0) {
                    pendingCount++;
                }
            } else {
                if (
                    (game.winnerPool == 1 && depositsA[i][user] > 0) ||
                    (game.winnerPool == 2 && depositsB[i][user] > 0)
                ) {
                    claimableCount++;
                }
            }
        }

        claimableGameIds = new uint256[](claimableCount);
        pendingGameIds = new uint256[](pendingCount);

        uint256 claimableIndex = 0;
        uint256 pendingIndex = 0;

        for (uint256 i = 1; i <= gameCount; i++) {
            Game storage game = games[i];

            if (!game.resolved) {
                if (depositsA[i][user] > 0 || depositsB[i][user] > 0) {
                    pendingGameIds[pendingIndex++] = i;
                }
            } else {
                if (
                    (game.winnerPool == 1 && depositsA[i][user] > 0) ||
                    (game.winnerPool == 2 && depositsB[i][user] > 0)
                ) {
                    claimableGameIds[claimableIndex++] = i;
                }
            }
        }
    }

    function claim(
        uint256 gameId
    ) public gameResolved(gameId) nonReentrant whenNotPaused {
        uint256 userShare = 0;
        Game storage game = games[gameId];

        if (game.winnerPool == 1) {
            uint256 userDeposit = depositsA[gameId][msg.sender];
            require(userDeposit > 0, "No deposit in winning pool");
            uint256 totalWinningPool = game.totalPoolA;
            uint256 losingPool = game.totalPoolB;
            uint256 fee = (losingPool * game.feePercent) / 1000;
            uint256 rewardPool = losingPool - fee;

            userShare =
                userDeposit +
                (userDeposit * rewardPool) /
                totalWinningPool;
            depositsA[gameId][msg.sender] = 0;
        } else if (game.winnerPool == 2) {
            uint256 userDeposit = depositsB[gameId][msg.sender];
            require(userDeposit > 0, "No deposit in winning pool");
            uint256 totalWinningPool = game.totalPoolB;
            uint256 losingPool = game.totalPoolA;
            uint256 fee = (losingPool * game.feePercent) / 1000; // Use 1000 for percentage
            uint256 rewardPool = losingPool - fee;

            userShare =
                userDeposit +
                (userDeposit * rewardPool) /
                totalWinningPool;
            depositsB[gameId][msg.sender] = 0;
        }

        leaderboard[msg.sender].totalWinnings += userShare;
        payable(msg.sender).transfer(userShare);
        emit Payout(msg.sender, gameId, userShare);
    }

    function updateCreatorFeePercentage(
        uint256 _newPercentile
    ) external onlyOwner {
        require(_newPercentile <= 1000, "Creator fee cannot exceed 100%");
        creatorFeePercentile = _newPercentile;
    }

    function updateFeePercentage(uint256 newfeePercentage) public onlyOwner {
        require(
            newfeePercentage <= 1000,
            "Default fee percent must be <= 1000"
        );
        feePercentage = newfeePercentage;
        emit FeeUpdated(newfeePercentage);
    }

    function withdraw(uint256 amount) public onlyOwner nonReentrant {
        require(address(this).balance >= amount, "Insufficient balance");
        payable(owner()).transfer(amount);
    }

    function getLeaderboard() public view returns (LeaderboardEntry[] memory) {
        uint256 entryCount = 0;

        for (uint256 i = 0; i < players.length; i++) {
            if (
                leaderboard[players[i]].totalWinnings > 0 ||
                leaderboard[players[i]].totalDeposits > 0
            ) {
                entryCount++;
            }
        }

        LeaderboardEntry[] memory entries = new LeaderboardEntry[](entryCount);
        uint256 index = 0;

        for (uint256 i = 0; i < players.length; i++) {
            if (
                leaderboard[players[i]].totalWinnings > 0 ||
                leaderboard[players[i]].totalDeposits > 0
            ) {
                entries[index] = LeaderboardEntry({
                    player: players[i],
                    totalDeposits: leaderboard[players[i]].totalDeposits,
                    totalWinnings: leaderboard[players[i]].totalWinnings
                });
                index++;
            }
        }

        return entries;
    }

    function cancelGame(uint256 gameId) public onlyOwner {
        Game storage game = games[gameId];
        require(!game.resolved, "Game already resolved");
        require(game.status == 3, "Only approved games can be cancelled");

        game.status = 4; // Set to cancelled
        emit GameCancelled(gameId);
    }

    function refund(uint256 gameId) public nonReentrant whenNotPaused {
        Game storage game = games[gameId];
        require(game.status == 4, "Game is not cancelled");

        uint256 refundAmount = 0;

        if (depositsA[gameId][msg.sender] > 0) {
            refundAmount += depositsA[gameId][msg.sender];
            depositsA[gameId][msg.sender] = 0;
            game.totalPoolA -= refundAmount;
        }

        if (depositsB[gameId][msg.sender] > 0) {
            refundAmount += depositsB[gameId][msg.sender];
            depositsB[gameId][msg.sender] = 0;
            game.totalPoolB -= refundAmount;
        }

        require(refundAmount > 0, "No deposits to refund");
        payable(msg.sender).transfer(refundAmount);
    }

    function pause() external onlyOwner {
        _pause();
    }

    function unpause() external onlyOwner {
        _unpause();
    }

    function getTotalPlayers() public view returns (uint256) {
        return players.length;
    }

    function getPlayersSlice(
        uint256 start,
        uint256 count
    ) public view returns (address[] memory) {
        uint256 total = players.length;
        require(start < total, "Start index out of bounds");

        uint256 end = start + count;
        if (end > total) {
            end = total;
        }

        address[] memory result = new address[](end - start);
        for (uint256 i = start; i < end; i++) {
            result[i - start] = players[i];
        }

        return result;
    }

    function getLeaderboardEntry(
        address player
    ) public view returns (LeaderboardEntry memory) {
        return leaderboard[player];
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";

contract ArbitrumPredicts is ReentrancyGuard, Ownable, Pausable {
    using SafeERC20 for IERC20;

    IERC20 public token;
    uint256 public feePercentage = 42; // Default fee percentage (4.2%)
    uint256 public creatorFeePercentile = 100; // Creator fee percentage (10% represented as 100 basis points)

    enum GameType {
        Election,
        Coin
    }

    struct Game {
        uint256 id;
        string gameName;
        string banner;
        GameType gameType;
        string candidateA;
        string candidateB;
        uint256 initialPrice;
        uint256 finalPrice;
        uint256 expiryTime;
        uint256 lockTime;
        uint256 totalPoolA;
        uint256 totalPoolB;
        bool resolved;
        uint256 winnerPool;
        uint256 feePercent;
        string market;
        address creator;
        uint status; // 1 pending 2 rejected 3 approved 4 cancelled
    }

    struct GameDeposit {
        address user;
        uint256 amount;
        uint256 timestamp;
        uint8 pool;
    }

    struct LeaderboardEntry {
        address player;
        uint256 totalDeposits;
        uint256 totalWinnings;
    }

    mapping(uint256 => Game) public games;
    mapping(uint256 => mapping(address => uint256)) public depositsA;
    mapping(uint256 => mapping(address => uint256)) public depositsB;

    mapping(uint256 => GameDeposit[]) public depositHistory;
    mapping(address => LeaderboardEntry) public leaderboard;

    address[] public players;

    uint256 public gameCount;

    constructor(IERC20 _token) Ownable(msg.sender) {
        token = _token;
    }

    event GameCreated(
        uint256 gameId,
        string gameName,
        GameType gameType,
        string candidateA,
        string candidateB,
        uint256 initialPrice,
        uint256 expiryTime,
        uint256 lockTime,
        uint256 feePercent,
        string banner,
        address creator,
        uint status
    );

    event Deposit(
        address indexed user,
        uint256 gameId,
        uint256 amount,
        uint8 option
    );

    event GameResolved(uint256 gameId, uint8 winner);
    event Payout(address indexed user, uint256 gameId, uint256 amount);
    event FeeUpdated(uint256 newfeePercentage);
    event GameCancelled(uint256 gameId);

    modifier gameNotLocked(uint256 gameId) {
        require(
            block.timestamp < games[gameId].lockTime,
            "Deposits are locked for this game"
        );
        _;
    }

    modifier gameApproved(uint256 gameId) {
        require(games[gameId].status == 3, "Game not approved or canceled");
        _;
    }

    modifier gameNotExpired(uint256 gameId) {
        require(block.timestamp < games[gameId].expiryTime, "game has expired");
        _;
    }

    modifier gameResolved(uint256 gameId) {
        require(games[gameId].resolved, "Game has not been resolved yet");
        _;
    }

    function _createGame(
        string memory _gameName,
        GameType _gameType,
        string memory _candidateA,
        string memory _candidateB,
        uint256 _initialPrice,
        uint256 _expiryTime,
        uint256 _lockTime,
        string memory _market,
        string memory _banner,
        address _creator,
        uint _status
    ) internal {
        require(_expiryTime > block.timestamp, "Expiry must be in the future");
        require(_lockTime < _expiryTime, "Lock time must be before expiry");

        gameCount++;
        games[gameCount] = Game({
            id: gameCount,
            gameName: _gameName,
            gameType: _gameType,
            candidateA: _candidateA,
            candidateB: _candidateB,
            initialPrice: _initialPrice,
            finalPrice: 0,
            expiryTime: _expiryTime,
            lockTime: _lockTime,
            totalPoolA: 0,
            totalPoolB: 0,
            resolved: false,
            winnerPool: 0,
            feePercent: feePercentage,
            market: _market,
            banner: _banner,
            creator: _creator,
            status: _status
        });

        emit GameCreated(
            gameCount,
            _gameName,
            _gameType,
            _candidateA,
            _candidateB,
            _initialPrice,
            _expiryTime,
            _lockTime,
            feePercentage,
            _banner,
            _creator,
            _status
        );
    }

    function createElectionGame(
        string memory _gameName,
        uint256 _expiryTime,
        uint256 _lockTime,
        string memory _market,
        string memory _candidateA,
        string memory _candidateB,
        string memory _banner,
        address _creator
    ) public {
        _createGame(
            _gameName,
            GameType.Election,
            _candidateA,
            _candidateB,
            0,
            _expiryTime,
            _lockTime,
            _market,
            _banner,
            owner() == msg.sender ? owner() : _creator,
            3 // now approved for every one
        );
    }

    function createCoinGame(
        string memory _gameName,
        uint256 _expiryTime,
        uint256 _lockTime,
        string memory _market,
        uint256 _initialPrice,
        string memory _banner,
        address _creator
    ) public {
        _createGame(
            _gameName,
            GameType.Coin,
            "", // No candidates for Coin game
            "",
            _initialPrice,
            _expiryTime,
            _lockTime,
            _market,
            _banner,
            owner() == msg.sender ? owner() : _creator,
            3 // now approved for every one
        );
    }

    function updateGameStatus(uint256 gameId, uint newStatus) public onlyOwner {
        Game storage game = games[gameId];
        game.status = newStatus;
    }

    function resolveGame(
        uint256 gameId,
        uint8 winner,
        uint256 _finalPrice
    ) public gameApproved(gameId) onlyOwner nonReentrant {
        Game storage game = games[gameId];
        require(!game.resolved, "game already resolved");
        require(winner == 1 || winner == 2, "Invalid winner");
        require(block.timestamp >= game.expiryTime, "Game not yet expired");

        game.resolved = true;
        game.winnerPool = winner;

        if (game.gameType == GameType.Coin) {
            game.finalPrice = _finalPrice;
        }

        uint256 losingPool = winner == 1 ? game.totalPoolB : game.totalPoolA;

        uint256 totalFee = (losingPool * feePercentage) / 1000;
        uint256 creatorFee = (totalFee * creatorFeePercentile) / 1000;
        uint256 ownerFee = totalFee - creatorFee;

        if (game.creator == owner()) {
            token.safeTransfer(owner(), totalFee);
        } else {
            token.safeTransfer(owner(), ownerFee);
            token.safeTransfer(game.creator, creatorFee);
        }

        emit GameResolved(gameId, winner);
    }

    function getGameDetails(
        uint256 gameId
    ) public view returns (Game memory game, GameDeposit[] memory deposits) {
        game = games[gameId];
        deposits = depositHistory[gameId];
    }

    function getGames(
        bool includeResolved,
        uint status,
        address creator
    ) public view returns (Game[] memory) {
        uint256 count = 0;
        for (uint256 i = 1; i <= gameCount; i++) {
            if (
                games[i].resolved == includeResolved &&
                games[i].status == status &&
                (creator == address(0) || games[i].creator == creator)
            ) {
                count++;
            }
        }

        Game[] memory gamesList = new Game[](count);

        uint256 index = 0;
        for (uint256 i = 1; i <= gameCount; i++) {
            if (
                games[i].resolved == includeResolved &&
                games[i].status == status &&
                (creator == address(0) || games[i].creator == creator)
            ) {
                gamesList[index] = games[i];
                index++;
            }
        }

        return gamesList;
    }

    function deposit(
        uint256 gameId,
        uint8 option,
        uint256 amount
    )
        public
        gameApproved(gameId)
        gameNotLocked(gameId)
        gameNotExpired(gameId)
        nonReentrant
    {
        require(option == 1 || option == 2, "Invalid option");
        require(amount > 0, "Deposit must be greater than 0");
        Game storage game = games[gameId];
        require(!game.resolved, "Game already resolved");

        token.safeTransferFrom(msg.sender, address(this), amount);

        depositHistory[gameId].push(
            GameDeposit({
                user: msg.sender,
                amount: amount,
                timestamp: block.timestamp,
                pool: option
            })
        );

        if (option == 1) {
            depositsA[gameId][msg.sender] += amount;
            games[gameId].totalPoolA += amount;
        } else {
            depositsB[gameId][msg.sender] += amount;
            games[gameId].totalPoolB += amount;
        }

        if (leaderboard[msg.sender].player == address(0)) {
            players.push(msg.sender);
            leaderboard[msg.sender].player = msg.sender;
        }

        leaderboard[msg.sender].totalDeposits += amount;

        emit Deposit(msg.sender, gameId, amount, option);
    }

    function getDepositsForGame(
        uint256 gameId
    ) public view returns (GameDeposit[] memory) {
        return depositHistory[gameId];
    }

    function getClaimableOrPendingGames(
        address user
    )
        public
        view
        returns (
            uint256[] memory claimableGameIds,
            uint256[] memory pendingGameIds
        )
    {
        uint256 claimableCount = 0;
        uint256 pendingCount = 0;

        for (uint256 i = 1; i <= gameCount; i++) {
            Game storage game = games[i];

            if (!game.resolved) {
                if (depositsA[i][user] > 0 || depositsB[i][user] > 0) {
                    pendingCount++;
                }
            } else {
                if (
                    (game.winnerPool == 1 && depositsA[i][user] > 0) ||
                    (game.winnerPool == 2 && depositsB[i][user] > 0)
                ) {
                    claimableCount++;
                }
            }
        }

        claimableGameIds = new uint256[](claimableCount);
        pendingGameIds = new uint256[](pendingCount);

        uint256 claimableIndex = 0;
        uint256 pendingIndex = 0;

        for (uint256 i = 1; i <= gameCount; i++) {
            Game storage game = games[i];

            if (!game.resolved) {
                if (depositsA[i][user] > 0 || depositsB[i][user] > 0) {
                    pendingGameIds[pendingIndex++] = i;
                }
            } else {
                if (
                    (game.winnerPool == 1 && depositsA[i][user] > 0) ||
                    (game.winnerPool == 2 && depositsB[i][user] > 0)
                ) {
                    claimableGameIds[claimableIndex++] = i;
                }
            }
        }
    }

    function claim(uint256 gameId) public gameResolved(gameId) nonReentrant {
        uint256 userShare = 0;
        Game storage game = games[gameId];

        if (game.winnerPool == 1) {
            uint256 userDeposit = depositsA[gameId][msg.sender];
            require(userDeposit > 0, "No deposit in winning pool");
            uint256 totalWinningPool = game.totalPoolA;
            uint256 losingPool = game.totalPoolB;
            uint256 fee = (losingPool * game.feePercent) / 1000;
            uint256 rewardPool = losingPool - fee;

            userShare =
                userDeposit +
                (userDeposit * rewardPool) /
                totalWinningPool;
            depositsA[gameId][msg.sender] = 0;
        } else if (game.winnerPool == 2) {
            uint256 userDeposit = depositsB[gameId][msg.sender];
            require(userDeposit > 0, "No deposit in winning pool");
            uint256 totalWinningPool = game.totalPoolB;
            uint256 losingPool = game.totalPoolA;
            uint256 fee = (losingPool * game.feePercent) / 1000; // Use 1000 for percentage
            uint256 rewardPool = losingPool - fee;

            userShare =
                userDeposit +
                (userDeposit * rewardPool) /
                totalWinningPool;
            depositsB[gameId][msg.sender] = 0;
        }

        leaderboard[msg.sender].totalWinnings += userShare;
        token.safeTransfer(msg.sender, userShare);
        emit Payout(msg.sender, gameId, userShare);
    }

    function updateCreatorFeePercentage(
        uint256 _newPercentile
    ) external onlyOwner {
        require(_newPercentile <= 1000, "Creator fee cannot exceed 100%");
        creatorFeePercentile = _newPercentile;
    }

    function updateFeePercentage(uint256 newfeePercentage) public onlyOwner {
        require(
            newfeePercentage <= 1000,
            "Default fee percent must be <= 1000"
        );
        feePercentage = newfeePercentage;
        emit FeeUpdated(newfeePercentage);
    }

    function withdraw(uint256 amount) public onlyOwner nonReentrant {
        require(
            token.balanceOf(address(this)) >= amount,
            "Insufficient balance"
        );
        token.safeTransfer(owner(), amount);
    }

    function getLeaderboard() public view returns (LeaderboardEntry[] memory) {
        uint256 entryCount = 0;

        for (uint256 i = 0; i < players.length; i++) {
            if (
                leaderboard[players[i]].totalWinnings > 0 ||
                leaderboard[players[i]].totalDeposits > 0
            ) {
                entryCount++;
            }
        }

        LeaderboardEntry[] memory entries = new LeaderboardEntry[](entryCount);
        uint256 index = 0;

        for (uint256 i = 0; i < players.length; i++) {
            if (
                leaderboard[players[i]].totalWinnings > 0 ||
                leaderboard[players[i]].totalDeposits > 0
            ) {
                entries[index] = LeaderboardEntry({
                    player: players[i],
                    totalDeposits: leaderboard[players[i]].totalDeposits,
                    totalWinnings: leaderboard[players[i]].totalWinnings
                });
                index++;
            }
        }

        return entries;
    }

    function cancelGame(uint256 gameId) public onlyOwner {
        Game storage game = games[gameId];
        require(!game.resolved, "Game already resolved");
        require(game.status == 3, "Only approved games can be cancelled");

        game.status = 4; // Set to cancelled
        emit GameCancelled(gameId);
    }

    function refund(uint256 gameId) public nonReentrant {
        Game storage game = games[gameId];
        require(game.status == 4, "Game is not cancelled");

        uint256 refundAmount = 0;

        if (depositsA[gameId][msg.sender] > 0) {
            refundAmount += depositsA[gameId][msg.sender];
            depositsA[gameId][msg.sender] = 0;
            game.totalPoolA -= refundAmount;
        }

        if (depositsB[gameId][msg.sender] > 0) {
            refundAmount += depositsB[gameId][msg.sender];
            depositsB[gameId][msg.sender] = 0;
            game.totalPoolB -= refundAmount;
        }

        require(refundAmount > 0, "No deposits to refund");
        token.safeTransfer(msg.sender, refundAmount);
    }

    function getTotalPlayers() public view returns (uint256) {
        return players.length;
    }

    function getPlayersSlice(
        uint256 start,
        uint256 count
    ) public view returns (address[] memory) {
        uint256 total = players.length;
        require(start < total, "Start index out of bounds");

        uint256 end = start + count;
        if (end > total) {
            end = total;
        }

        address[] memory result = new address[](end - start);
        for (uint256 i = start; i < end; i++) {
            result[i - start] = players[i];
        }

        return result;
    }

    function getLeaderboardEntry(
        address player
    ) public view returns (LeaderboardEntry memory) {
        return leaderboard[player];
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

contract DecentralizedParlayPlatform is
    Ownable,
    ERC721URIStorage,
    ReentrancyGuard,
    Pausable
{
    using SafeERC20 for IERC20;

    IERC721 public nftContract;

    struct Parlay {
        uint256 tokenId;
        string id;
        uint256 odds;
        uint256 wager;
        bool outcome;
        bool resolved;
        bool voided;
    }

    struct UserStats {
        uint256 totalBets;
        uint256 totalBetAmount;
        uint256 totalGamesWon;
        uint256 totalWinAmount;
        uint256 totalGamesLost;
        uint256 totalLossAmount;
    }
    mapping(address => UserStats) public userStats;

    mapping(uint256 => Parlay) public tokenIdToParlay;
    uint256 public totalLiquidityPool;
    uint256 public totalBetAmount;
    mapping(address => uint256) public depositTimestamp;
    uint256 public constant LOCK_PERIOD = 30 days;
    mapping(address => uint256) public liquidityProviders;
    address[] public liquidityProviderAddresses;
    mapping(address => uint256) public providerIndex;
    uint256 public nextTokenId;
    uint256[] public unresolvedParlays;
    mapping(uint256 => uint256) public unresolvedParlayIndex;
    uint256 public winningFee = 400000; // 4% (stored as 400000 / 10000000)
    uint256 public totalLiability;
    mapping(address => bool) public hasPlayed;
    address[] public allPlayers;
    mapping(address => uint256) public providerEarnings;
    mapping(address => uint256) public providerLosses;

    event BetPlaced(address indexed user, uint256 wager, uint256 tokenId);
    event LiquidityDeposited(address indexed provider, uint256 amount);
    event LiquidityWithdrawn(address indexed provider, uint256 amount);
    event ParlayResolved(
        address indexed user,
        uint256 tokenId,
        bool outcome,
        uint256 payout
    );
    event ParlayVoided(uint256 tokenId);
    event WinningFeeUpdated(uint256 newFee);

    constructor(
        address _nftContract
    ) Ownable(msg.sender) ERC721("ParlayNFT", "PLNFT") {
        nftContract = IERC721(_nftContract);
    }

    function placeBet(
        string memory id,
        uint256 odds,
        uint256 wager,
        string memory tokenURI
    ) external payable nonReentrant whenNotPaused {
        require(msg.value > 0, "Wager must be greater than 0");
        require(odds > 0, "Odds must be greater than 0");
        require(totalLiquidityPool > 0, "No liquidity available");

        uint256 actualWager = msg.value;
        // Calculate potential payout based on net received (after tax)
        uint256 potentialPayout = (actualWager * odds) / 1e18 - actualWager;
        require(
            potentialPayout <= (totalLiquidityPool * 15) / 100,
            "Potential win exceeds 15% of liquidity pool"
        );

        uint256 totalLiabilityAfterBet = totalLiability + potentialPayout;

        require(
            totalLiabilityAfterBet <= totalLiquidityPool,
            "Insufficient liquidity to cover potential payout"
        );
        totalLiability += potentialPayout;

        uint256 tokenId = nextTokenId++;
        _safeMint(msg.sender, tokenId);
        _setTokenURI(tokenId, tokenURI);

        tokenIdToParlay[tokenId] = Parlay({
            id: id,
            tokenId: tokenId,
            odds: odds,
            wager: actualWager,
            outcome: false,
            resolved: false,
            voided: false
        });

        unresolvedParlayIndex[tokenId] = unresolvedParlays.length;
        unresolvedParlays.push(tokenId);
        totalBetAmount += actualWager;

        userStats[msg.sender].totalBets += 1;
        userStats[msg.sender].totalBetAmount += actualWager;

        if (!hasPlayed[msg.sender]) {
            hasPlayed[msg.sender] = true;
            allPlayers.push(msg.sender);
        }

        emit BetPlaced(msg.sender, actualWager, tokenId);
    }

    function depositLiquidity(
        uint256 amount
    ) external payable nonReentrant whenNotPaused {
        require(
            nftContract.balanceOf(msg.sender) > 0,
            "Must own at least one NFT to deposit liquidity"
        );
        require(msg.value > 0, "Deposit must be greater than 0");
        uint256 actualAmount = msg.value;

        if (liquidityProviders[msg.sender] == 0) {
            liquidityProviderAddresses.push(msg.sender);
            depositTimestamp[msg.sender] = block.timestamp;
            providerIndex[msg.sender] = liquidityProviderAddresses.length - 1;
        }
        liquidityProviders[msg.sender] += actualAmount;
        totalLiquidityPool += actualAmount;

        emit LiquidityDeposited(msg.sender, actualAmount);
    }

    function withdrawLiquidity(
        uint256 amount
    ) external nonReentrant whenNotPaused {
        require(amount > 0, "Withdrawal amount must be greater than 0");
        require(
            amount <= liquidityProviders[msg.sender],
            "Insufficient liquidity for provider"
        );

        uint256 lockedUntil = depositTimestamp[msg.sender] + LOCK_PERIOD;
        require(block.timestamp >= lockedUntil, "Liquidity is locked");

        uint256 remainingLiquidity = totalLiquidityPool - amount;
        require(
            totalLiability <= remainingLiquidity,
            "Withdrawal would leave insufficient coverage for active bets"
        );

        // Performance fee logic
        uint256 deposited = liquidityProviders[msg.sender];
        uint256 earnings = providerEarnings[msg.sender];
        uint256 losses = providerLosses[msg.sender];

        // Net profit = earnings - losses
        if (earnings > losses) {
            uint256 netProfit = earnings - losses;

            // If user is withdrawing part of their liquidity, prorate the profit
            uint256 proratedProfit = (netProfit * amount) / deposited;

            // 4% fee on that prorated profit
            uint256 fee = (proratedProfit * winningFee) / 10000000;
            uint256 payout = amount - fee;

            liquidityProviders[msg.sender] -= amount;
            totalLiquidityPool -= amount;

            (bool sent, ) = payable(msg.sender).call{value: payout}("");
            require(sent, "ETH transfer failed");

            // For sending fees to owner
            (bool feeSent, ) = payable(owner()).call{value: fee}("");
            require(feeSent, "Fee transfer failed");
        } else {
            // No profit → no fee
            liquidityProviders[msg.sender] -= amount;
            totalLiquidityPool -= amount;

            (bool sent, ) = payable(msg.sender).call{value: amount}("");
            require(sent, "ETH transfer failed");
        }

        if (liquidityProviders[msg.sender] == 0) {
            uint256 index = providerIndex[msg.sender];
            uint256 lastIndex = liquidityProviderAddresses.length - 1;

            if (index != lastIndex) {
                address lastProvider = liquidityProviderAddresses[lastIndex];
                liquidityProviderAddresses[index] = lastProvider;
                providerIndex[lastProvider] = index;
            }

            liquidityProviderAddresses.pop();
            delete providerIndex[msg.sender];
            delete depositTimestamp[msg.sender];
            delete providerEarnings[msg.sender];
            delete providerLosses[msg.sender];
        }

        emit LiquidityWithdrawn(msg.sender, amount);
    }

    function resolveParlay(
        uint256 tokenId,
        bool outcome
    ) external onlyOwner nonReentrant whenNotPaused {
        Parlay storage parlay = tokenIdToParlay[tokenId];
        require(!parlay.voided, "Parlay already canceled");
        require(!parlay.resolved, "Parlay already resolved");

        parlay.resolved = true;
        parlay.outcome = outcome;

        address user = ownerOf(tokenId);

        // Remove from unresolvedParlays
        _removeUnresolvedParlay(tokenId);

        uint256 providerCount = liquidityProviderAddresses.length;
        address[] memory providers = new address[](providerCount);
        uint256[] memory amounts = new uint256[](providerCount);
        uint256 totalProviderLiquidity = 0;

        for (uint256 i = 0; i < providerCount; i++) {
            address provider = liquidityProviderAddresses[i];
            uint256 amount = liquidityProviders[provider];
            providers[i] = provider;
            amounts[i] = amount;
            totalProviderLiquidity += amount;
        }

        if (outcome) {
            // Win: calculate gross payout
            uint256 payoutAmount = (parlay.wager * parlay.odds) / 1e18;
            require(
                payoutAmount <= (totalLiquidityPool * 15) / 100,
                "Payout exceeds 15% of pool"
            );
            uint256 fee = (payoutAmount * winningFee) / 10000000;
            uint256 amountToDeduct = payoutAmount - parlay.wager;
            uint256 finalPayout = payoutAmount - fee;

            // Deduct full payout (including fee) from providers
            for (uint256 i = 0; i < providers.length; i++) {
                address provider = providers[i];
                uint256 share = (amounts[i] * amountToDeduct) /
                    totalProviderLiquidity;
                liquidityProviders[provider] -= share;
                providerLosses[provider] += share;
            }

            totalLiquidityPool -= amountToDeduct;
            totalLiability -= amountToDeduct;

            (bool sent, ) = payable(user).call{value: finalPayout}("");
            require(sent, "ETH transfer failed");

            (bool feeSent, ) = payable(owner()).call{value: fee}("");
            require(feeSent, "ETH transfer failed");

            userStats[user].totalGamesWon += 1;
            userStats[user].totalWinAmount += finalPayout;

            emit ParlayResolved(user, tokenId, outcome, finalPayout);
        } else {
            // Loss: distribute wager to providers
            for (uint256 i = 0; i < providers.length; i++) {
                address provider = providers[i];
                uint256 share = (amounts[i] * parlay.wager) /
                    totalProviderLiquidity;
                liquidityProviders[provider] += share;
                providerEarnings[provider] += share;
            }
            totalLiquidityPool += parlay.wager;
            uint256 potentialPayout = (parlay.wager * parlay.odds) /
                1e18 -
                parlay.wager;
            totalLiability -= potentialPayout;
            userStats[user].totalGamesLost += 1;
            userStats[user].totalLossAmount += parlay.wager;

            emit ParlayResolved(user, tokenId, outcome, 0);
        }
    }

    function cancelParlay(uint256 tokenId) external onlyOwner nonReentrant {
        require(
            tokenIdToParlay[tokenId].resolved == false,
            "Parlay already resolved"
        );
        require(
            tokenIdToParlay[tokenId].voided == false,
            "Parlay already canceled"
        );

        Parlay storage parlay = tokenIdToParlay[tokenId];
        parlay.voided = true;
        address user = ownerOf(tokenId);

        (bool sent, ) = payable(user).call{value: parlay.wager}("");
        require(sent, "ETH transfer failed");

        totalBetAmount -= parlay.wager;
        uint256 potentialPayout = (parlay.wager * parlay.odds) /
            1e18 -
            parlay.wager;
        totalLiability -= potentialPayout;

        _removeUnresolvedParlay(tokenId);

        emit ParlayVoided(tokenId);
    }

    function getUserParlays(
        address user
    ) external view returns (Parlay[] memory) {
        uint256 balance = balanceOf(user);
        Parlay[] memory parlays = new Parlay[](balance);

        if (balance == 0) return parlays;

        uint256 currentIndex = 0;
        for (uint256 i = 0; i < nextTokenId; i++) {
            try this.ownerOf(i) returns (address owner) {
                if (owner == user) {
                    parlays[currentIndex] = tokenIdToParlay[i];
                    currentIndex++;
                }
            } catch {
                continue;
            }
        }

        return parlays;
    }

    function getUnresolvedParlays() external view returns (Parlay[] memory) {
        uint256 unresolvedCount = unresolvedParlays.length;
        Parlay[] memory parlaysTemp = new Parlay[](unresolvedCount);

        for (uint256 i = 0; i < unresolvedCount; i++) {
            uint256 tokenId = unresolvedParlays[i];
            parlaysTemp[i] = tokenIdToParlay[tokenId];
        }

        return parlaysTemp;
    }

    function getUnresolvedParlaysLength() external view returns (uint256) {
        return unresolvedParlays.length;
    }

    function getLiquidityProviderDetails(
        address provider
    )
        external
        view
        returns (uint256 deposit, uint256 earnings, uint256 losses)
    {
        return (
            liquidityProviders[provider],
            providerEarnings[provider],
            providerLosses[provider]
        );
    }

    function setWinningFee(uint256 newFee) external onlyOwner {
        winningFee = newFee;
        emit WinningFeeUpdated(newFee);
    }

    function _removeUnresolvedParlay(uint256 tokenId) internal {
        uint256 index = unresolvedParlayIndex[tokenId];
        uint256 lastTokenId = unresolvedParlays[unresolvedParlays.length - 1];

        unresolvedParlays[index] = lastTokenId;
        unresolvedParlayIndex[lastTokenId] = index;

        unresolvedParlays.pop();
        delete unresolvedParlayIndex[tokenId];
    }

    function pause() external onlyOwner {
        _pause();
    }

    function unpause() external onlyOwner {
        _unpause();
    }

    function getUserStats(
        address user
    ) external view returns (UserStats memory) {
        return userStats[user];
    }

    function getAllPlayers() external view returns (address[] memory) {
        return allPlayers;
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./DecentralizedParlayPlatform.sol";

contract DPPRebateContract is Ownable, ReentrancyGuard {
    using SafeERC20 for IERC20;

    IERC721 public immutable nftContract;
    IERC20 public immutable erc20Token;
    DecentralizedParlayPlatform public immutable parlayContract;

    mapping(uint256 => bool) public nftDeposited; // Track deposited NFTs
    mapping(address => uint256) public userDeposits; // Track how many NFTs each user deposited
    mapping(address => bool) public isWhitelisted; // Whitelist mapping
    mapping(address => uint256) public whitelistLimit; // Per-user deposit limit

    address[] public whitelistAddresses; // List of all whitelisted users

    uint256 public fixedReward; // Fixed reward for all NFTs
    uint256 public totalDepositedFunds; // Tracks total funds deposited by admin
    uint256 public minWagerRequired; // Minimum wager required for deposit

    event NFTDeposited(address indexed user, uint256 tokenId, uint256 reward);
    event FundsDeposited(address indexed admin, uint256 amount);
    event ExcessFundsWithdrawn(address indexed admin, uint256 amount);
    event MinWagerUpdated(uint256 newMinWager);
    event Whitelisted(address indexed user, bool status, uint256 limit);
    event WhitelistLimitUpdated(address indexed user, uint256 newLimit);
    event RoundReset();

    constructor(
        address _nftContract,
        address _erc20Token,
        address _parlayContract
    ) Ownable(msg.sender) {
        require(_nftContract != address(0), "Invalid NFT contract");
        require(_erc20Token != address(0), "Invalid ERC-20 contract");
        require(_parlayContract != address(0), "Invalid Parlay contract");

        nftContract = IERC721(_nftContract);
        erc20Token = IERC20(_erc20Token);
        parlayContract = DecentralizedParlayPlatform(_parlayContract);
    }

    modifier onlyWhitelisted() {
        require(isWhitelisted[msg.sender], "Not whitelisted");
        _;
    }

    function depositNFT(
        uint256 parlayTokenId
    ) external nonReentrant onlyWhitelisted {
        require(
            nftContract.ownerOf(parlayTokenId) == msg.sender,
            "Not NFT owner"
        );
        require(!nftDeposited[parlayTokenId], "NFT already deposited");
        require(
            totalDepositedFunds >= fixedReward,
            "Insufficient contract balance"
        );
        require(
            userDeposits[msg.sender] < whitelistLimit[msg.sender],
            "Deposit limit reached"
        );

        (
            uint256 tokenId,
            string memory id,
            uint256 odds,
            uint256 wager,
            bool outcome,
            bool resolved,
            bool voided
        ) = parlayContract.tokenIdToParlay(parlayTokenId);
        uint256 parlayWager = wager;

        require(parlayWager >= minWagerRequired, "Wager below required amount");

        // Mark NFT as deposited
        nftDeposited[parlayTokenId] = true;
        userDeposits[msg.sender] += 1;

        erc20Token.safeTransfer(msg.sender, fixedReward);
        totalDepositedFunds -= fixedReward;

        emit NFTDeposited(msg.sender, parlayTokenId, fixedReward);
    }

    function depositFunds(uint256 amount) external onlyOwner {
        erc20Token.safeTransferFrom(msg.sender, address(this), amount);
        totalDepositedFunds += amount;

        emit FundsDeposited(msg.sender, amount);
    }

    function withdrawExcessFunds(uint256 amount) external onlyOwner {
        require(
            amount <= totalDepositedFunds,
            "Withdraw amount exceeds contract balance"
        );
        erc20Token.safeTransfer(owner(), amount);

        totalDepositedFunds -= amount;

        emit ExcessFundsWithdrawn(msg.sender, amount);
    }

    function setFixedReward(uint256 _rewardAmount) external onlyOwner {
        require(_rewardAmount > 0, "Reward must be greater than zero");
        fixedReward = _rewardAmount;
    }

    function setMinWagerRequired(uint256 _minWager) external onlyOwner {
        require(_minWager > 0, "Minimum wager must be greater than zero");
        minWagerRequired = _minWager;
        emit MinWagerUpdated(_minWager);
    }

    function getContractBalance() external view returns (uint256) {
        return totalDepositedFunds;
    }

    // Whitelist Management
    function addToWhitelist(address user, uint256 limit) external onlyOwner {
        require(!isWhitelisted[user], "User already whitelisted");
        require(limit > 0, "Limit must be greater than zero");
        isWhitelisted[user] = true;
        whitelistLimit[user] = limit;
        whitelistAddresses.push(user); // Add to list of whitelisted addresses
        emit Whitelisted(user, true, limit);
    }

    function addMultipleToWhitelist(
        address[] calldata users,
        uint256 limit
    ) external onlyOwner {
        require(limit > 0, "Limit must be greater than zero");

        for (uint256 i = 0; i < users.length; i++) {
            if (isWhitelisted[users[i]]) {
                continue;
            }

            isWhitelisted[users[i]] = true;
            whitelistLimit[users[i]] = limit;
            whitelistAddresses.push(users[i]);
            emit Whitelisted(users[i], true, limit);
        }
    }

    function removeFromWhitelist(address user) external onlyOwner {
        require(isWhitelisted[user], "User not whitelisted");
        isWhitelisted[user] = false;
        whitelistLimit[user] = 0; // Reset limit
        for (uint256 i = 0; i < whitelistAddresses.length; i++) {
            if (whitelistAddresses[i] == user) {
                whitelistAddresses[i] = whitelistAddresses[
                    whitelistAddresses.length - 1
                ]; // Move last element to deleted slot
                whitelistAddresses.pop(); // Remove last element
                break;
            }
        }
        emit Whitelisted(user, false, 0);
    }

    function setWhitelistLimit(
        address user,
        uint256 newLimit
    ) external onlyOwner {
        require(isWhitelisted[user], "User not whitelisted");
        require(newLimit > 0, "Limit must be greater than zero");
        whitelistLimit[user] = newLimit;
        emit WhitelistLimitUpdated(user, newLimit);
    }

    function resetRound() external onlyOwner {
        for (uint256 i = 0; i < whitelistAddresses.length; i++) {
            address user = whitelistAddresses[i];
            isWhitelisted[user] = false;
            whitelistLimit[user] = 0;
        }

        delete whitelistAddresses;

        emit RoundReset();
    }

    // Get list of all whitelisted addresses
    function getWhitelistedUsers() external view returns (address[] memory) {
        return whitelistAddresses;
    }

    function checkParlay(
        uint256 parlayTokenId
    ) external view returns (uint256, uint256) {
        (
            uint256 tokenId,
            string memory id,
            uint256 odds,
            uint256 wager,
            bool outcome,
            bool resolved,
            bool voided
        ) = parlayContract.tokenIdToParlay(parlayTokenId);
        uint256 parlayWager = wager;
        return (parlayWager, minWagerRequired);
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

contract TestERC20 is ERC20 {
    constructor(string memory name, string memory symbol) ERC20(name, symbol) {}

    function mint(address to, uint256 amount) public {
        _mint(to, amount);
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "viaIR": true,
  "evmVersion": "paris",
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_nftContract","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721IncorrectOwner","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721InsufficientApproval","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC721InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC721InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721InvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC721InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC721InvalidSender","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721NonexistentToken","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_toTokenId","type":"uint256"}],"name":"BatchMetadataUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"wager","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"BetPlaced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LiquidityDeposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LiquidityWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"MetadataUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"outcome","type":"bool"},{"indexed":false,"internalType":"uint256","name":"payout","type":"uint256"}],"name":"ParlayResolved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ParlayVoided","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"WinningFeeUpdated","type":"event"},{"inputs":[],"name":"LOCK_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allPlayers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"cancelParlay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositLiquidity","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"depositTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllPlayers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"provider","type":"address"}],"name":"getLiquidityProviderDetails","outputs":[{"internalType":"uint256","name":"deposit","type":"uint256"},{"internalType":"uint256","name":"earnings","type":"uint256"},{"internalType":"uint256","name":"losses","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUnresolvedParlays","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"id","type":"string"},{"internalType":"uint256","name":"odds","type":"uint256"},{"internalType":"uint256","name":"wager","type":"uint256"},{"internalType":"bool","name":"outcome","type":"bool"},{"internalType":"bool","name":"resolved","type":"bool"},{"internalType":"bool","name":"voided","type":"bool"}],"internalType":"struct APENativeDecentralizedParlayPlatform.Parlay[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUnresolvedParlaysLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getUserParlays","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"id","type":"string"},{"internalType":"uint256","name":"odds","type":"uint256"},{"internalType":"uint256","name":"wager","type":"uint256"},{"internalType":"bool","name":"outcome","type":"bool"},{"internalType":"bool","name":"resolved","type":"bool"},{"internalType":"bool","name":"voided","type":"bool"}],"internalType":"struct APENativeDecentralizedParlayPlatform.Parlay[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getUserStats","outputs":[{"components":[{"internalType":"uint256","name":"totalBets","type":"uint256"},{"internalType":"uint256","name":"totalBetAmount","type":"uint256"},{"internalType":"uint256","name":"totalGamesWon","type":"uint256"},{"internalType":"uint256","name":"totalWinAmount","type":"uint256"},{"internalType":"uint256","name":"totalGamesLost","type":"uint256"},{"internalType":"uint256","name":"totalLossAmount","type":"uint256"}],"internalType":"struct APENativeDecentralizedParlayPlatform.UserStats","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"hasPlayed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"liquidityProviderAddresses","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"liquidityProviders","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftContract","outputs":[{"internalType":"contract IERC721","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"id","type":"string"},{"internalType":"uint256","name":"odds","type":"uint256"},{"internalType":"uint256","name":"wager","type":"uint256"},{"internalType":"string","name":"tokenURI","type":"string"}],"name":"placeBet","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"providerEarnings","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"providerIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"providerLosses","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bool","name":"outcome","type":"bool"}],"name":"resolveParlay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"setWinningFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenIdToParlay","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"id","type":"string"},{"internalType":"uint256","name":"odds","type":"uint256"},{"internalType":"uint256","name":"wager","type":"uint256"},{"internalType":"bool","name":"outcome","type":"bool"},{"internalType":"bool","name":"resolved","type":"bool"},{"internalType":"bool","name":"voided","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBetAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalLiability","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalLiquidityPool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"unresolvedParlayIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"unresolvedParlays","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userStats","outputs":[{"internalType":"uint256","name":"totalBets","type":"uint256"},{"internalType":"uint256","name":"totalBetAmount","type":"uint256"},{"internalType":"uint256","name":"totalGamesWon","type":"uint256"},{"internalType":"uint256","name":"totalWinAmount","type":"uint256"},{"internalType":"uint256","name":"totalGamesLost","type":"uint256"},{"internalType":"uint256","name":"totalLossAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"winningFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608034620003db57601f601f196001600160401b03620036853881900384810184168601919083831187841017620003e0578087926040948552833981010312620003db576200004f8462000416565b926200005f602080960162000416565b926200006a620003f6565b93600985526814185c9b185e53919560ba1b878601526200008a620003f6565b6005815264141313919560da1b88820152916001600160a01b039182168015620003c257600080546001600160a01b03198116831782559093167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08480a38551858111620003ae5760019687548881811c91168015620003a3575b8b8210146200038f579081878493116200033c575b508a90878311600114620002d9578592620002cd575b5050600019600383901b1c191690871b1786555b8251948511620002b9576002548681811c91168015620002ae575b898210146200029a5784811162000251575b5087938511600114620001ea5750839495965092620001de575b5050600019600383901b1c191690821b176002555b60089081556009805462061a806015556001600160a81b0319169290911b610100600160a81b031691909117905560405161325990816200042c8239f35b0151905038806200018b565b849392919316966002845280842093905b8882106200023957505083859697106200021f575b505050811b01600255620001a0565b015160001960f88460031b161c1916905538808062000210565b808785968294968601518155019501930190620001fb565b600283528883208580880160051c8201928b891062000290575b0160051c019087905b8281106200028457505062000171565b84815501879062000274565b925081926200026b565b634e487b7160e01b83526022600452602483fd5b90607f16906200015f565b634e487b7160e01b82526041600452602482fd5b01519050388062000130565b90848a9416918487528c8720928d88905b8282106200032457505084116200030a575b505050811b01865562000144565b015160001960f88460031b161c19169055388080620002fc565b8385015186558d979095019493840193018e620002ea565b9091508885528a85208780850160051c8201928d861062000385575b918b91869594930160051c01915b828110620003765750506200011a565b8781558594508b910162000366565b9250819262000358565b634e487b7160e01b85526022600452602485fd5b90607f169062000105565b634e487b7160e01b83526041600452602483fd5b604051631e4fbdf760e01b815260006004820152602490fd5b600080fd5b634e487b7160e01b600052604160045260246000fd5b60408051919082016001600160401b03811183821017620003e057604052565b51906001600160a01b0382168203620003db5756fe608080604052600436101561001357600080fd5b60003560e01c90816301ffc9a714612665575080630544ce5e1461260a57806306fdde031461255c578063081812fc1461251e578063095ea7b3146124375780630a861f2a14611fe05780630fc2934914611fc2578063143e058d14611f88578063159a659414611f4e5780631820cabb14611f305780631ef7b43014611f1257806323b872dd14611efb5780632643076214611edd57806332d0bbe314611e9e5780633f4ba83a14611e3457806342842e0e14611e06578063467979aa14611dd657806346b00d0414611d9c5780634e43603a14611cca5780635c975abb14611ca7578063613f459414611c895780636352211e14611c595780636eb115a314611b885780636ff49dee14611a6b57806370a0823114611a40578063715018a6146119e757806371d3122f1461150657806372b513d5146114ba578063750d05c51461142a57806375794a3c1461140c57806376d58e1a146111f25780638456cb59146111985780638a65d874146111275780638da5cb5b146110fe57806395d89b411461101b578063961a6b0714610fef5780639e87018014610f94578063a22cb46514610ee9578063a276426914610eb2578063abe99dff14610e70578063b88d4fde14610e03578063c87b56dd14610da6578063d56d229d14610d79578063dbd9426714610d3f578063e66e1c1b1461044e578063e985e9c5146103f8578063eca338b7146103da578063efa1c48214610312578063f2fde38b146102845763f32d11a61461024557600080fd5b3461027f57602036600319011261027f576001600160a01b03610266612798565b16600052601a6020526020604060002054604051908152f35b600080fd5b3461027f57602036600319011261027f5761029d612798565b6102a5613038565b6001600160a01b039081169081156102f957600054826bffffffffffffffffffffffff60a01b821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b3461027f57600036600319011261027f57604051806018548083526020809301809160186000527fb13d2d76d1f4b7be834882e410b3e3a8afaf69f83600ae24db354391d2378d2e9060005b868282106103bd57868661037482880383612947565b604051928392818401908285525180915260408401929160005b82811061039d57505050500390f35b83516001600160a01b03168552869550938101939281019260010161038e565b83546001600160a01b03168552909301926001928301920161035e565b3461027f57600036600319011261027f576020601354604051908152f35b3461027f57604036600319011261027f57610411612798565b6104196127ae565b9060018060a01b03809116600052600660205260406000209116600052602052602060ff604060002054166040519015158152f35b608036600319011261027f5760043567ffffffffffffffff811161027f5761047a903690600401612a61565b60643567ffffffffffffffff811161027f5761049a903690600401612a61565b906104a3612ff7565b6104ab61301a565b3415610cfa5760243515610cb557600c548015610c77576104e134670de0b6b3a76400006104db60243534612b0b565b04612a8c565b600f8202828104600f036108d657606490048111610c1e57601654916105078284612a7f565b11610bc05761051591612a7f565b60165560125461052481612d72565b6012556040516105338161292b565b600081523315610ba7576000828152600360205260409020546001600160a01b031680610b70575b3360005260046020526040600020600181540190558260005260036020526040600020336bffffffffffffffffffffffff60a01b8254161790558233827fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4610b5757333b610a69575b508060005260076020526040600020835167ffffffffffffffff81116108c0576105f282546128b9565b601f8111610a25575b506020601f82116001146109bc5781929394956000926109b1575b50508160011b916000199060031b1c19161790555b7ff8e1a15aba9398e019f0b49df1a4fde98ee17ae345cb5f6b5e2c27f5033e8ce76020604051838152a16040516106618161290f565b81815260208101928352602435604082015234606082015260006080820152600060a0820152600060c082015281600052600b602052604060002092815184555192835167ffffffffffffffff81116108c0576106c160018301546128b9565b601f811161096a575b506020601f82116001146108f757819060049495966000926108ec575b50508160011b916000199060031b1c19161760018201555b6040830151600282015560608301516003820155019061073160808201511515839060ff801983541691151516179055565b60a081015115159061ff0062ff000060c08554930151151560101b169260081b169062ffff0019161717905560135481600052601460205280604060002055600160401b90818110156108c057826107928260016107ab9401601355612721565b90919082549060031b91821b91600019901b1916179055565b6107b734600d54612a7f565b600d5533600052600a6020526040600020805490600182018092116108d6575533600052600a60205260016040600020016107f3348254612a7f565b90553360005260176020526040600020805460ff811615610848575b836040519034825260208201527e1ecf1d0c4d22f324b3ecb9cdf0e5f772bc74ac104e6626f4b3845433d0310560403392a26001600855005b60ff19166001179055601854908110156108c05760018101806018558110156108aa5760186000527fb13d2d76d1f4b7be834882e410b3e3a8afaf69f83600ae24db354391d2378d2e0180546001600160a01b0319163317905581808061080f565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b0151905086806106e7565b6001830160005260206000209560005b601f198416811061095257509582916004959697600194601f19811610610939575b505050811b0160018201556106ff565b015160001960f88460031b161c19169055868080610929565b82820151885560019097019660209283019201610907565b600183016000526020600020601f830160051c8101602084106109aa575b601f830160051c8201811061099e5750506106ca565b60008155600101610988565b5080610988565b015190508580610616565b8260005260206000209060005b601f1984168110610a0d575060019394959683601f198116106109f4575b505050811b01905561062b565b015160001960f88460031b161c191690558580806109e7565b9091602060018192858b0151815501930191016109c9565b826000526020600020601f830160051c810160208410610a62575b601f830160051c82018110610a565750506105fb565b60008155600101610a40565b5080610a40565b60405160208180610aa3630a85bd0160e11b9586835233600484015260006024840152876044840152608060648401526084830190612758565b03816000335af160009181610b12575b50610ae557610ac0612a99565b80519081610ae057604051633250574960e11b8152336004820152602490fd5b602001fd5b6001600160e01b03191603610afa57836105c8565b604051633250574960e11b8152336004820152602490fd5b9091506020813d602011610b4f575b81610b2e60209383612947565b8101031261027f57516001600160e01b03198116810361027f579086610ab3565b3d9150610b21565b6040516339e3563760e11b815260006004820152602490fd5b600083815260056020526040902080546001600160a01b03191690558060005260046020526040600020600019815401905561055b565b604051633250574960e11b815260006004820152602490fd5b60405162461bcd60e51b815260206004820152603060248201527f496e73756666696369656e74206c697175696469747920746f20636f7665722060448201526f1c1bdd195b9d1a585b081c185e5bdd5d60821b6064820152608490fd5b60405162461bcd60e51b815260206004820152602b60248201527f506f74656e7469616c2077696e206578636565647320313525206f66206c697160448201526a1d5a591a5d1e481c1bdbdb60aa1b6064820152608490fd5b60405162461bcd60e51b81526020600482015260166024820152754e6f206c697175696469747920617661696c61626c6560501b6044820152606490fd5b60405162461bcd60e51b815260206004820152601b60248201527f4f646473206d7573742062652067726561746572207468616e203000000000006044820152606490fd5b60405162461bcd60e51b815260206004820152601c60248201527f5761676572206d7573742062652067726561746572207468616e2030000000006044820152606490fd5b3461027f57602036600319011261027f576001600160a01b03610d60612798565b16600052600f6020526020604060002054604051908152f35b3461027f57600036600319011261027f5760095460405160089190911c6001600160a01b03168152602090f35b3461027f57602036600319011261027f57600435610dc381612fbc565b506000526007602052610dff610ddc6040600020612969565b6000604051610dea8161292b565b52604051918291602083526020830190612758565b0390f35b3461027f57608036600319011261027f57610e1c612798565b610e246127ae565b906044356064359267ffffffffffffffff841161027f573660238501121561027f57610e5d610e6e943690602481600401359101612a2a565b92610e69838383612b3e565b61310a565b005b3461027f57602036600319011261027f5760043560105481101561027f57610e996020916126ea565b905460405160039290921b1c6001600160a01b03168152f35b3461027f57602036600319011261027f5760043560135481101561027f57610edb602091612721565b90546040519160031b1c8152f35b3461027f57604036600319011261027f57610f02612798565b610f0a6128aa565b6001600160a01b03909116908115610f7b57336000526006602052604060002082600052602052610f4b8160406000209060ff801983541691151516179055565b60405190151581527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a3005b604051630b61174360e31b815260048101839052602490fd5b3461027f57602036600319011261027f576001600160a01b03610fb5612798565b16600052600f60205260606040600020546019602052604060002054601a6020526040600020549060405192835260208301526040820152f35b3461027f57602036600319011261027f5760043560005260146020526020604060002054604051908152f35b3461027f57600036600319011261027f5760405160025460008261103e836128b9565b91828252602093600190856001821691826000146110de575050600114611081575b5061106d92500383612947565b610dff604051928284938452830190612758565b84915060026000527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace906000915b8583106110c657505061106d935082010185611060565b805483890185015287945086939092019181016110af565b60ff19168582015261106d95151560051b85010192508791506110609050565b3461027f57600036600319011261027f576000546040516001600160a01b039091168152602090f35b3461027f57602036600319011261027f576001600160a01b03611148612798565b16600052600a60205260c0604060002080549060018101549060028101546003820154906005600484015493015493604051958652602086015260408501526060840152608083015260a0820152f35b3461027f57600036600319011261027f576111b1613038565b6111b961301a565b600160ff1960095416176009557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b60208060031936011261027f57611207612ff7565b61120f61301a565b6009546040516370a0823160e01b81523360048201529082908290602490829060081c6001600160a01b03165afa908115611400576000916113d3575b50156113785734156113345733600052600f8152604060002054156112c3575b600f81526040600020611280348254612a7f565b905561128e34600c54612a7f565b600c557f7ff07ce9a287649537e4b012e45cf012d90228b12e2b56bb03515a6b5436fcdf604051913483523392a26001600855005b601054600160401b8110156108c0576112e581600161130393016010556126ea565b81546001600160a01b0360039290921b91821b19163390911b179055565b33600052600e81524260406000205560105460001981019081116108d657336000526011825260406000205561126c565b6064906040519062461bcd60e51b82526004820152601e60248201527f4465706f736974206d7573742062652067726561746572207468616e203000006044820152fd5b6084906040519062461bcd60e51b82526004820152602e60248201527f4d757374206f776e206174206c65617374206f6e65204e465420746f2064657060448201526d6f736974206c697175696469747960901b6064820152fd5b90508181813d83116113f9575b6113ea8183612947565b8101031261027f57518261124c565b503d6113e0565b6040513d6000823e3d90fd5b3461027f57600036600319011261027f576020601254604051908152f35b3461027f57602036600319011261027f57600435600052600b6020526040600020805461145960018301612969565b9160ff6002820154916004600382015491015490611489604051968796875260e0602088015260e0870190612758565b936040860152606085015281811615156080850152818160081c16151560a085015260101c16151560c08301520390f35b3461027f57602036600319011261027f577fd7a7aca8ac2146ba66e2f8ffea6e6f25e23cf729fb8b8248ce0e76b233159c9060206004356114f9613038565b80601555604051908152a1005b3461027f57604036600319011261027f5761151f6128aa565b611527613038565b61152f612ff7565b61153761301a565b6004356000526020600b815260406000209161158f8160048501610100815461156660ff8260101c1615612f37565b61157660ff8260081c1615612eeb565b61ff0019161781559060ff801983541691151516179055565b61159a600435612fbc565b906115a6600435613064565b6010546115b281612cc4565b916115c06040519384612947565b8183526115cc82612cc4565b601f199390840136878301376115e183612cc4565b936115ef6040519586612947565b8385526115fb84612cc4565b0136878601376000926000905b808210611994575050811561184557670de0b6b3a7640000611633600260038a015499015489612b0b565b0491600c5495600f96600f810290808204600f14901517156108d6576064900484116118005761168161167b98996298968061167160155488612b0b565b04998a9187612a8c565b95612a8c565b9060005b84518110156116fb57808b898b6116c48b6116bf8c6116b9888e6116b160019c8d8060a01b0392612d5e565b511697612d5e565b51612b0b565b612b1e565b92826000525260406000206116da838254612a8c565b9055600052601a8d526116f36040600020918254612a7f565b905501611685565b509550955096956117659350600080938193509161172b829361172081600c54612a8c565b600c55601654612a8c565b601655611750828080808c6001600160a01b038d165af161174a612a99565b50612ac9565b81546001600160a01b03165af161174a612a99565b60018060a01b038116600052600a8352600260406000200191825493600185018095116108d6577fe7db757cc58a6abba8e0d333214766106612b162c07b48ce656d3cf127b7f9df946060945560018060a01b038316600052600a815260036040600020016117d5838254612a7f565b9055604080516004358152961515918701919091528501526001600160a01b031692a25b6001600855005b60405162461bcd60e51b815260048101899052601a60248201527f5061796f7574206578636565647320313525206f6620706f6f6c0000000000006044820152606490fd5b90506000959495939192939160038601925b82518110156118cb576001906001600160a01b036118758286612d5e565b5116611891876116bf611888858c612d5e565b51895490612b0b565b9080600052600f8b5260406000206118aa838254612a7f565b905560005260198a526118c36040600020918254612a7f565b905501611857565b509350509261190a9150611902906118e68554600c54612a7f565b600c55670de0b6b3a76400006104db6002875493015483612b0b565b601654612a8c565b60165560018060a01b03169182600052600a8152600460406000200190815492600184018094116108d6577fe7db757cc58a6abba8e0d333214766106612b162c07b48ce656d3cf127b7f9df93606093555484600052600a82526119776005604060002001918254612a7f565b9055600060405191600435835282015260006040820152a26117f9565b90936119df6001916119a5876126ea565b848060a01b0391549060031b1c169081600052600f8b52604060002054916119cd8988612d5e565b52816119d9898b612d5e565b52612a7f565b940190611608565b3461027f57600036600319011261027f57611a00613038565b600080546001600160a01b0319811682556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b3461027f57602036600319011261027f576020611a63611a5e612798565b612f83565b604051908152f35b3461027f57602036600319011261027f577f1d85d6358e097b812307bb282f1503e6b779778d2992a5aeff513c1eb8dbbe536020600435611aaa613038565b611ab2612ff7565b80600052600b8252611ad260ff60046040600020015460081c1615612eeb565b80600052600b8252611af260ff60046040600020015460101c1615612f37565b6000818152600b83526040902060048101805462ff0000191662010000179055611b6e9061190290670de0b6b3a76400006104db60026001600160a01b03611b3988612fbc565b16611b54600080808060038a01958654905af161174a612a99565b611b618154600d54612a8c565b600d555493015483612b0b565b601655611b7a81613064565b604051908152a16001600855005b3461027f57600036600319011261027f57601354611ba581612cdc565b9060005b818110611bbe5760405180610dff85826127f9565b80611bca600192612721565b9054600391821b1c6000526004602091600b835260406000209060405193611bf18561290f565b82548552611c00878401612969565b90850152600282015460408501528101546060840152015460ff9081811615156080840152818160081c16151560a084015260101c16151560c0820152611c478286612d5e565b52611c528185612d5e565b5001611ba9565b3461027f57602036600319011261027f576020611c77600435612fbc565b6040516001600160a01b039091168152f35b3461027f57600036600319011261027f576020600d54604051908152f35b3461027f57600036600319011261027f57602060ff600954166040519015158152f35b3461027f57602036600319011261027f57611ce3612798565b600060a0604051611cf3816128f3565b828152826020820152826040820152826060820152826080820152015260018060a01b0316600052600a60205260c06040600020604051611d33816128f3565b8154918282526001810154602083019081526002820154604084019081526003830154916060850192835260a0600560048601549560808801968752015495019485526040519586525160208601525160408501525160608401525160808301525160a0820152f35b3461027f57602036600319011261027f576001600160a01b03611dbd612798565b16600052600e6020526020604060002054604051908152f35b3461027f57602036600319011261027f57610dff611dfa611df5612798565b612d81565b604051918291826127f9565b3461027f57610e6e611e17366127c4565b9060405192611e258461292b565b60008452610e69838383612b3e565b3461027f57600036600319011261027f57611e4d613038565b60095460ff811615611e8c5760ff19166009557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b604051638dfc202b60e01b8152600490fd5b3461027f57602036600319011261027f576001600160a01b03611ebf612798565b166000526017602052602060ff604060002054166040519015158152f35b3461027f57600036600319011261027f576020601554604051908152f35b3461027f57610e6e611f0c366127c4565b91612b3e565b3461027f57600036600319011261027f576020600c54604051908152f35b3461027f57600036600319011261027f57602060405162278d008152f35b3461027f57602036600319011261027f576001600160a01b03611f6f612798565b1660005260196020526020604060002054604051908152f35b3461027f57602036600319011261027f576001600160a01b03611fa9612798565b1660005260116020526020604060002054604051908152f35b3461027f57600036600319011261027f576020601654604051908152f35b3461027f5760208060031936011261027f5760043590611ffe612ff7565b61200661301a565b81156123e25733600052600f815260406000205482116123925733600052600e815260406000205462278d0081018091116108d65742106123585761204d82600c54612a8c565b601654116122ee5733600052600f81526040600020546019825282604060002054601a8452604060002054928382116000146122ac57629896806120b16120a8600096936116bf88976120a38998978998612a8c565b612b0b565b60155490612b0b565b046120f6828080806120c3868d612a8c565b338252600f8c528c6120da60408420918254612a8c565b90556120e88d600c54612a8c565b600c55335af161174a612a99565b81546001600160a01b03165af161210b612a99565b5015612272575b33600052600f815260406000205415612158575b7fb1cce8684b4ffa8667b4577654e61ee3480d661ee9c27522ac80e211f6bd4d25906040519283523392a26001600855005b601181526040600020546010546000199291908381019081116108d657808203612218575b5050601054918215612202577fb1cce8684b4ffa8667b4577654e61ee3480d661ee9c27522ac80e211f6bd4d2592016121b5816126ea565b81549060018060a01b039060031b1b19169055601055336000526011815260006040812055600e8152600060408120556019815260006040812055601a8152600060408120559050612126565b634e487b7160e01b600052603160045260246000fd5b612221906126ea565b905460039190911b1c6001600160a01b031661225e81612240846126ea565b90919060018060a01b038084549260031b9316831b921b1916179055565b60005260118252604060002055838061217d565b6064906040519062461bcd60e51b825260048201526013602482015272119959481d1c985b9cd9995c8819985a5b1959606a1b6044820152fd5b50505050600f815260406000206122c4838254612a8c565b90556122d282600c54612a8c565b600c556122e9600080808086335af161174a612a99565b612112565b6084906040519062461bcd60e51b82526004820152603c60248201527f5769746864726177616c20776f756c64206c6561766520696e7375666669636960448201527f656e7420636f76657261676520666f72206163746976652062657473000000006064820152fd5b6064906040519062461bcd60e51b825260048201526013602482015272131a5c5d5a591a5d1e481a5cc81b1bd8dad959606a1b6044820152fd5b6084906040519062461bcd60e51b82526004820152602360248201527f496e73756666696369656e74206c697175696469747920666f722070726f76696044820152623232b960e91b6064820152fd5b6084906040519062461bcd60e51b82526004820152602860248201527f5769746864726177616c20616d6f756e74206d75737420626520677265617465604482015267072207468616e20360c41b6064820152fd5b3461027f57604036600319011261027f57612450612798565b60243561245c81612fbc565b3315158061250b575b806124de575b6124c6576001600160a01b039283169282918491167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600080a4600090815260056020526040902080546001600160a01b0319169091179055005b60405163a9fbf51f60e01b8152336004820152602490fd5b5060018060a01b038116600052600660205260406000203360005260205260ff604060002054161561246b565b506001600160a01b038116331415612465565b3461027f57602036600319011261027f5760043561253b81612fbc565b506000526005602052602060018060a01b0360406000205416604051908152f35b3461027f57600036600319011261027f57604051600060018260015492612582846128b9565b92838352602094856001821691826000146110de5750506001146125ad575061106d92500383612947565b84915060016000527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6906000915b8583106125f257505061106d935082010185611060565b805483890185015287945086939092019181016125db565b3461027f57602036600319011261027f5760043560185481101561027f5760186000527fb13d2d76d1f4b7be834882e410b3e3a8afaf69f83600ae24db354391d2378d2e01546040516001600160a01b039091168152602090f35b3461027f57602036600319011261027f576004359063ffffffff60e01b821680920361027f57602091632483248360e11b81149081156126a7575b5015158152f35b6380ac58cd60e01b8114915081156126d9575b81156126c8575b50836126a0565b6301ffc9a760e01b149050836126c1565b635b5e139f60e01b811491506126ba565b6010548110156108aa5760106000527f1b6847dc741a1b0cd08d278845f9d819d87b734759afb55fe2de5cb82a9ae6720190600090565b6013548110156108aa5760136000527f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a0900190600090565b919082519283825260005b848110612784575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201612763565b600435906001600160a01b038216820361027f57565b602435906001600160a01b038216820361027f57565b606090600319011261027f576001600160a01b0390600435828116810361027f5791602435908116810361027f579060443590565b6020808201908083528351809252604092604081018260408560051b8401019601946000925b858410612830575050505050505090565b909192939495968580600192603f198582030187528a519061286360e08351835284840151908086850152830190612758565b9187810151888301526060808201519083015260808082015115159083015260a08082015115159083015260c080910151151591015299019401940192959493919061281f565b60243590811515820361027f57565b90600182811c921680156128e9575b60208310146128d357565b634e487b7160e01b600052602260045260246000fd5b91607f16916128c8565b60c0810190811067ffffffffffffffff8211176108c057604052565b60e0810190811067ffffffffffffffff8211176108c057604052565b6020810190811067ffffffffffffffff8211176108c057604052565b90601f8019910116810190811067ffffffffffffffff8211176108c057604052565b9060405191826000825461297c816128b9565b908184526020946001916001811690816000146129ec57506001146129ad575b5050506129ab92500383612947565b565b600090815285812095935091905b8183106129d45750506129ab935082010138808061299c565b855488840185015294850194879450918301916129bb565b925050506129ab94925060ff191682840152151560051b82010138808061299c565b67ffffffffffffffff81116108c057601f01601f191660200190565b929192612a3682612a0e565b91612a446040519384612947565b82948184528183011161027f578281602093846000960137010152565b9080601f8301121561027f57816020612a7c93359101612a2a565b90565b919082018092116108d657565b919082039182116108d657565b3d15612ac4573d90612aaa82612a0e565b91612ab86040519384612947565b82523d6000602084013e565b606090565b15612ad057565b60405162461bcd60e51b8152602060048201526013602482015272115512081d1c985b9cd9995c8819985a5b1959606a1b6044820152606490fd5b818102929181159184041417156108d657565b8115612b28570490565b634e487b7160e01b600052601260045260246000fd5b6001600160a01b039182169290918315610ba757600092828452826020956003875260409684888820541696879133151580612c2e575b509060037fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9284612bfb575b858352600481528b8320805460010190558683525289812080546001600160a01b0319168517905580a41692838303612bda5750505050565b6064945051926364283d7b60e01b8452600484015260248301526044820152fd5b600087815260056020526040902080546001600160a01b0319169055848352600481528b83208054600019019055612ba1565b91939450915080612c83575b15612c4a57859291879138612b75565b878688612c67576024915190637e27328960e01b82526004820152fd5b604491519063177e802f60e01b82523360048301526024820152fd5b503387148015612ca8575b80612c3a5750858252600581523385898420541614612c3a565b5086825260068152878220338352815260ff8883205416612c8e565b67ffffffffffffffff81116108c05760051b60200190565b90612ce682612cc4565b604090612cf66040519182612947565b8381528093612d07601f1991612cc4565b019160005b838110612d195750505050565b6020908251612d278161290f565b600081526060600084918083850152818785015283015260006080830152600060a0830152600060c0830152828601015201612d0c565b80518210156108aa5760209160051b010190565b60001981146108d65760010190565b612d8a81612f83565b90612d9482612cdc565b9115612ee757601254906000805b838110612db0575050505090565b604080516331a9108f60e11b8152600480820184905260209290918381602481305afa8091600091612ea3575b5090612df157505050506001905b01612da2565b6001600160a01b03878116911614612e0f575b505050600190612deb565b91839491612e9a93600195600052600b83528060002090805193612e328561290f565b82548552612e41888401612969565b9085015260028201549084015260038101546060840152015460ff9081811615156080840152818160081c16151560a084015260101c16151560c0820152612e898289612d5e565b52612e948188612d5e565b50612d72565b91903880612e04565b8581813d8311612ee0575b612eb88183612947565b81010312612edc5751906001600160a01b0382168203612ed9575038612ddd565b80fd5b5080fd5b503d612eae565b5090565b15612ef257565b60405162461bcd60e51b815260206004820152601760248201527f5061726c617920616c7265616479207265736f6c7665640000000000000000006044820152606490fd5b15612f3e57565b60405162461bcd60e51b815260206004820152601760248201527f5061726c617920616c72656164792063616e63656c65640000000000000000006044820152606490fd5b6001600160a01b03168015612fa357600052600460205260406000205490565b6040516322718ad960e21b815260006004820152602490fd5b6000818152600360205260409020546001600160a01b0316908115612fdf575090565b60249060405190637e27328960e01b82526004820152fd5b600260085414613008576002600855565b604051633ee5aeb560e01b8152600490fd5b60ff6009541661302657565b60405163d93c066560e01b8152600490fd5b6000546001600160a01b0316330361304c57565b60405163118cdaa760e01b8152336004820152602490fd5b6000908082526014602052604082205460135490600019918281019081116130f65761308f90612721565b90549060031b1c6130a38161079284612721565b84526014602052604084205560135480156130e2578101906130c482612721565b909182549160031b1b19169055601355815260146020526040812055565b634e487b7160e01b84526031600452602484fd5b634e487b7160e01b85526011600452602485fd5b9190803b613119575b50505050565b61315b60018060a01b0380921694604051938493630a85bd0160e11b968786523360048701521660248501526044840152608060648401526084830190612758565b03906020816000938185885af1908290826131da575b50506131a95782613180612a99565b80519190826131a257604051633250574960e11b815260048101839052602490fd5b9050602001fd5b6001600160e01b031916036131c2575038808080613113565b60249060405190633250574960e11b82526004820152fd5b909192506020813d60201161321b575b816131f760209383612947565b81010312612edc5751906001600160e01b031982168203612ed95750903880613171565b3d91506131ea56fea26469706673582212202d82d4223245eef649a404a1d802d9b8b9a69eaee962748b891fdb3e3508b16364736f6c634300081800330000000000000000000000001b16c0b69d4a30c42c92c873c4873787afcbec5c000000000000000000000000f9565242ad9a71d57940a81b11a3723d5f1d2097

Deployed Bytecode

0x608080604052600436101561001357600080fd5b60003560e01c90816301ffc9a714612665575080630544ce5e1461260a57806306fdde031461255c578063081812fc1461251e578063095ea7b3146124375780630a861f2a14611fe05780630fc2934914611fc2578063143e058d14611f88578063159a659414611f4e5780631820cabb14611f305780631ef7b43014611f1257806323b872dd14611efb5780632643076214611edd57806332d0bbe314611e9e5780633f4ba83a14611e3457806342842e0e14611e06578063467979aa14611dd657806346b00d0414611d9c5780634e43603a14611cca5780635c975abb14611ca7578063613f459414611c895780636352211e14611c595780636eb115a314611b885780636ff49dee14611a6b57806370a0823114611a40578063715018a6146119e757806371d3122f1461150657806372b513d5146114ba578063750d05c51461142a57806375794a3c1461140c57806376d58e1a146111f25780638456cb59146111985780638a65d874146111275780638da5cb5b146110fe57806395d89b411461101b578063961a6b0714610fef5780639e87018014610f94578063a22cb46514610ee9578063a276426914610eb2578063abe99dff14610e70578063b88d4fde14610e03578063c87b56dd14610da6578063d56d229d14610d79578063dbd9426714610d3f578063e66e1c1b1461044e578063e985e9c5146103f8578063eca338b7146103da578063efa1c48214610312578063f2fde38b146102845763f32d11a61461024557600080fd5b3461027f57602036600319011261027f576001600160a01b03610266612798565b16600052601a6020526020604060002054604051908152f35b600080fd5b3461027f57602036600319011261027f5761029d612798565b6102a5613038565b6001600160a01b039081169081156102f957600054826bffffffffffffffffffffffff60a01b821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b3461027f57600036600319011261027f57604051806018548083526020809301809160186000527fb13d2d76d1f4b7be834882e410b3e3a8afaf69f83600ae24db354391d2378d2e9060005b868282106103bd57868661037482880383612947565b604051928392818401908285525180915260408401929160005b82811061039d57505050500390f35b83516001600160a01b03168552869550938101939281019260010161038e565b83546001600160a01b03168552909301926001928301920161035e565b3461027f57600036600319011261027f576020601354604051908152f35b3461027f57604036600319011261027f57610411612798565b6104196127ae565b9060018060a01b03809116600052600660205260406000209116600052602052602060ff604060002054166040519015158152f35b608036600319011261027f5760043567ffffffffffffffff811161027f5761047a903690600401612a61565b60643567ffffffffffffffff811161027f5761049a903690600401612a61565b906104a3612ff7565b6104ab61301a565b3415610cfa5760243515610cb557600c548015610c77576104e134670de0b6b3a76400006104db60243534612b0b565b04612a8c565b600f8202828104600f036108d657606490048111610c1e57601654916105078284612a7f565b11610bc05761051591612a7f565b60165560125461052481612d72565b6012556040516105338161292b565b600081523315610ba7576000828152600360205260409020546001600160a01b031680610b70575b3360005260046020526040600020600181540190558260005260036020526040600020336bffffffffffffffffffffffff60a01b8254161790558233827fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4610b5757333b610a69575b508060005260076020526040600020835167ffffffffffffffff81116108c0576105f282546128b9565b601f8111610a25575b506020601f82116001146109bc5781929394956000926109b1575b50508160011b916000199060031b1c19161790555b7ff8e1a15aba9398e019f0b49df1a4fde98ee17ae345cb5f6b5e2c27f5033e8ce76020604051838152a16040516106618161290f565b81815260208101928352602435604082015234606082015260006080820152600060a0820152600060c082015281600052600b602052604060002092815184555192835167ffffffffffffffff81116108c0576106c160018301546128b9565b601f811161096a575b506020601f82116001146108f757819060049495966000926108ec575b50508160011b916000199060031b1c19161760018201555b6040830151600282015560608301516003820155019061073160808201511515839060ff801983541691151516179055565b60a081015115159061ff0062ff000060c08554930151151560101b169260081b169062ffff0019161717905560135481600052601460205280604060002055600160401b90818110156108c057826107928260016107ab9401601355612721565b90919082549060031b91821b91600019901b1916179055565b6107b734600d54612a7f565b600d5533600052600a6020526040600020805490600182018092116108d6575533600052600a60205260016040600020016107f3348254612a7f565b90553360005260176020526040600020805460ff811615610848575b836040519034825260208201527e1ecf1d0c4d22f324b3ecb9cdf0e5f772bc74ac104e6626f4b3845433d0310560403392a26001600855005b60ff19166001179055601854908110156108c05760018101806018558110156108aa5760186000527fb13d2d76d1f4b7be834882e410b3e3a8afaf69f83600ae24db354391d2378d2e0180546001600160a01b0319163317905581808061080f565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b0151905086806106e7565b6001830160005260206000209560005b601f198416811061095257509582916004959697600194601f19811610610939575b505050811b0160018201556106ff565b015160001960f88460031b161c19169055868080610929565b82820151885560019097019660209283019201610907565b600183016000526020600020601f830160051c8101602084106109aa575b601f830160051c8201811061099e5750506106ca565b60008155600101610988565b5080610988565b015190508580610616565b8260005260206000209060005b601f1984168110610a0d575060019394959683601f198116106109f4575b505050811b01905561062b565b015160001960f88460031b161c191690558580806109e7565b9091602060018192858b0151815501930191016109c9565b826000526020600020601f830160051c810160208410610a62575b601f830160051c82018110610a565750506105fb565b60008155600101610a40565b5080610a40565b60405160208180610aa3630a85bd0160e11b9586835233600484015260006024840152876044840152608060648401526084830190612758565b03816000335af160009181610b12575b50610ae557610ac0612a99565b80519081610ae057604051633250574960e11b8152336004820152602490fd5b602001fd5b6001600160e01b03191603610afa57836105c8565b604051633250574960e11b8152336004820152602490fd5b9091506020813d602011610b4f575b81610b2e60209383612947565b8101031261027f57516001600160e01b03198116810361027f579086610ab3565b3d9150610b21565b6040516339e3563760e11b815260006004820152602490fd5b600083815260056020526040902080546001600160a01b03191690558060005260046020526040600020600019815401905561055b565b604051633250574960e11b815260006004820152602490fd5b60405162461bcd60e51b815260206004820152603060248201527f496e73756666696369656e74206c697175696469747920746f20636f7665722060448201526f1c1bdd195b9d1a585b081c185e5bdd5d60821b6064820152608490fd5b60405162461bcd60e51b815260206004820152602b60248201527f506f74656e7469616c2077696e206578636565647320313525206f66206c697160448201526a1d5a591a5d1e481c1bdbdb60aa1b6064820152608490fd5b60405162461bcd60e51b81526020600482015260166024820152754e6f206c697175696469747920617661696c61626c6560501b6044820152606490fd5b60405162461bcd60e51b815260206004820152601b60248201527f4f646473206d7573742062652067726561746572207468616e203000000000006044820152606490fd5b60405162461bcd60e51b815260206004820152601c60248201527f5761676572206d7573742062652067726561746572207468616e2030000000006044820152606490fd5b3461027f57602036600319011261027f576001600160a01b03610d60612798565b16600052600f6020526020604060002054604051908152f35b3461027f57600036600319011261027f5760095460405160089190911c6001600160a01b03168152602090f35b3461027f57602036600319011261027f57600435610dc381612fbc565b506000526007602052610dff610ddc6040600020612969565b6000604051610dea8161292b565b52604051918291602083526020830190612758565b0390f35b3461027f57608036600319011261027f57610e1c612798565b610e246127ae565b906044356064359267ffffffffffffffff841161027f573660238501121561027f57610e5d610e6e943690602481600401359101612a2a565b92610e69838383612b3e565b61310a565b005b3461027f57602036600319011261027f5760043560105481101561027f57610e996020916126ea565b905460405160039290921b1c6001600160a01b03168152f35b3461027f57602036600319011261027f5760043560135481101561027f57610edb602091612721565b90546040519160031b1c8152f35b3461027f57604036600319011261027f57610f02612798565b610f0a6128aa565b6001600160a01b03909116908115610f7b57336000526006602052604060002082600052602052610f4b8160406000209060ff801983541691151516179055565b60405190151581527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a3005b604051630b61174360e31b815260048101839052602490fd5b3461027f57602036600319011261027f576001600160a01b03610fb5612798565b16600052600f60205260606040600020546019602052604060002054601a6020526040600020549060405192835260208301526040820152f35b3461027f57602036600319011261027f5760043560005260146020526020604060002054604051908152f35b3461027f57600036600319011261027f5760405160025460008261103e836128b9565b91828252602093600190856001821691826000146110de575050600114611081575b5061106d92500383612947565b610dff604051928284938452830190612758565b84915060026000527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace906000915b8583106110c657505061106d935082010185611060565b805483890185015287945086939092019181016110af565b60ff19168582015261106d95151560051b85010192508791506110609050565b3461027f57600036600319011261027f576000546040516001600160a01b039091168152602090f35b3461027f57602036600319011261027f576001600160a01b03611148612798565b16600052600a60205260c0604060002080549060018101549060028101546003820154906005600484015493015493604051958652602086015260408501526060840152608083015260a0820152f35b3461027f57600036600319011261027f576111b1613038565b6111b961301a565b600160ff1960095416176009557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b60208060031936011261027f57611207612ff7565b61120f61301a565b6009546040516370a0823160e01b81523360048201529082908290602490829060081c6001600160a01b03165afa908115611400576000916113d3575b50156113785734156113345733600052600f8152604060002054156112c3575b600f81526040600020611280348254612a7f565b905561128e34600c54612a7f565b600c557f7ff07ce9a287649537e4b012e45cf012d90228b12e2b56bb03515a6b5436fcdf604051913483523392a26001600855005b601054600160401b8110156108c0576112e581600161130393016010556126ea565b81546001600160a01b0360039290921b91821b19163390911b179055565b33600052600e81524260406000205560105460001981019081116108d657336000526011825260406000205561126c565b6064906040519062461bcd60e51b82526004820152601e60248201527f4465706f736974206d7573742062652067726561746572207468616e203000006044820152fd5b6084906040519062461bcd60e51b82526004820152602e60248201527f4d757374206f776e206174206c65617374206f6e65204e465420746f2064657060448201526d6f736974206c697175696469747960901b6064820152fd5b90508181813d83116113f9575b6113ea8183612947565b8101031261027f57518261124c565b503d6113e0565b6040513d6000823e3d90fd5b3461027f57600036600319011261027f576020601254604051908152f35b3461027f57602036600319011261027f57600435600052600b6020526040600020805461145960018301612969565b9160ff6002820154916004600382015491015490611489604051968796875260e0602088015260e0870190612758565b936040860152606085015281811615156080850152818160081c16151560a085015260101c16151560c08301520390f35b3461027f57602036600319011261027f577fd7a7aca8ac2146ba66e2f8ffea6e6f25e23cf729fb8b8248ce0e76b233159c9060206004356114f9613038565b80601555604051908152a1005b3461027f57604036600319011261027f5761151f6128aa565b611527613038565b61152f612ff7565b61153761301a565b6004356000526020600b815260406000209161158f8160048501610100815461156660ff8260101c1615612f37565b61157660ff8260081c1615612eeb565b61ff0019161781559060ff801983541691151516179055565b61159a600435612fbc565b906115a6600435613064565b6010546115b281612cc4565b916115c06040519384612947565b8183526115cc82612cc4565b601f199390840136878301376115e183612cc4565b936115ef6040519586612947565b8385526115fb84612cc4565b0136878601376000926000905b808210611994575050811561184557670de0b6b3a7640000611633600260038a015499015489612b0b565b0491600c5495600f96600f810290808204600f14901517156108d6576064900484116118005761168161167b98996298968061167160155488612b0b565b04998a9187612a8c565b95612a8c565b9060005b84518110156116fb57808b898b6116c48b6116bf8c6116b9888e6116b160019c8d8060a01b0392612d5e565b511697612d5e565b51612b0b565b612b1e565b92826000525260406000206116da838254612a8c565b9055600052601a8d526116f36040600020918254612a7f565b905501611685565b509550955096956117659350600080938193509161172b829361172081600c54612a8c565b600c55601654612a8c565b601655611750828080808c6001600160a01b038d165af161174a612a99565b50612ac9565b81546001600160a01b03165af161174a612a99565b60018060a01b038116600052600a8352600260406000200191825493600185018095116108d6577fe7db757cc58a6abba8e0d333214766106612b162c07b48ce656d3cf127b7f9df946060945560018060a01b038316600052600a815260036040600020016117d5838254612a7f565b9055604080516004358152961515918701919091528501526001600160a01b031692a25b6001600855005b60405162461bcd60e51b815260048101899052601a60248201527f5061796f7574206578636565647320313525206f6620706f6f6c0000000000006044820152606490fd5b90506000959495939192939160038601925b82518110156118cb576001906001600160a01b036118758286612d5e565b5116611891876116bf611888858c612d5e565b51895490612b0b565b9080600052600f8b5260406000206118aa838254612a7f565b905560005260198a526118c36040600020918254612a7f565b905501611857565b509350509261190a9150611902906118e68554600c54612a7f565b600c55670de0b6b3a76400006104db6002875493015483612b0b565b601654612a8c565b60165560018060a01b03169182600052600a8152600460406000200190815492600184018094116108d6577fe7db757cc58a6abba8e0d333214766106612b162c07b48ce656d3cf127b7f9df93606093555484600052600a82526119776005604060002001918254612a7f565b9055600060405191600435835282015260006040820152a26117f9565b90936119df6001916119a5876126ea565b848060a01b0391549060031b1c169081600052600f8b52604060002054916119cd8988612d5e565b52816119d9898b612d5e565b52612a7f565b940190611608565b3461027f57600036600319011261027f57611a00613038565b600080546001600160a01b0319811682556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b3461027f57602036600319011261027f576020611a63611a5e612798565b612f83565b604051908152f35b3461027f57602036600319011261027f577f1d85d6358e097b812307bb282f1503e6b779778d2992a5aeff513c1eb8dbbe536020600435611aaa613038565b611ab2612ff7565b80600052600b8252611ad260ff60046040600020015460081c1615612eeb565b80600052600b8252611af260ff60046040600020015460101c1615612f37565b6000818152600b83526040902060048101805462ff0000191662010000179055611b6e9061190290670de0b6b3a76400006104db60026001600160a01b03611b3988612fbc565b16611b54600080808060038a01958654905af161174a612a99565b611b618154600d54612a8c565b600d555493015483612b0b565b601655611b7a81613064565b604051908152a16001600855005b3461027f57600036600319011261027f57601354611ba581612cdc565b9060005b818110611bbe5760405180610dff85826127f9565b80611bca600192612721565b9054600391821b1c6000526004602091600b835260406000209060405193611bf18561290f565b82548552611c00878401612969565b90850152600282015460408501528101546060840152015460ff9081811615156080840152818160081c16151560a084015260101c16151560c0820152611c478286612d5e565b52611c528185612d5e565b5001611ba9565b3461027f57602036600319011261027f576020611c77600435612fbc565b6040516001600160a01b039091168152f35b3461027f57600036600319011261027f576020600d54604051908152f35b3461027f57600036600319011261027f57602060ff600954166040519015158152f35b3461027f57602036600319011261027f57611ce3612798565b600060a0604051611cf3816128f3565b828152826020820152826040820152826060820152826080820152015260018060a01b0316600052600a60205260c06040600020604051611d33816128f3565b8154918282526001810154602083019081526002820154604084019081526003830154916060850192835260a0600560048601549560808801968752015495019485526040519586525160208601525160408501525160608401525160808301525160a0820152f35b3461027f57602036600319011261027f576001600160a01b03611dbd612798565b16600052600e6020526020604060002054604051908152f35b3461027f57602036600319011261027f57610dff611dfa611df5612798565b612d81565b604051918291826127f9565b3461027f57610e6e611e17366127c4565b9060405192611e258461292b565b60008452610e69838383612b3e565b3461027f57600036600319011261027f57611e4d613038565b60095460ff811615611e8c5760ff19166009557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b604051638dfc202b60e01b8152600490fd5b3461027f57602036600319011261027f576001600160a01b03611ebf612798565b166000526017602052602060ff604060002054166040519015158152f35b3461027f57600036600319011261027f576020601554604051908152f35b3461027f57610e6e611f0c366127c4565b91612b3e565b3461027f57600036600319011261027f576020600c54604051908152f35b3461027f57600036600319011261027f57602060405162278d008152f35b3461027f57602036600319011261027f576001600160a01b03611f6f612798565b1660005260196020526020604060002054604051908152f35b3461027f57602036600319011261027f576001600160a01b03611fa9612798565b1660005260116020526020604060002054604051908152f35b3461027f57600036600319011261027f576020601654604051908152f35b3461027f5760208060031936011261027f5760043590611ffe612ff7565b61200661301a565b81156123e25733600052600f815260406000205482116123925733600052600e815260406000205462278d0081018091116108d65742106123585761204d82600c54612a8c565b601654116122ee5733600052600f81526040600020546019825282604060002054601a8452604060002054928382116000146122ac57629896806120b16120a8600096936116bf88976120a38998978998612a8c565b612b0b565b60155490612b0b565b046120f6828080806120c3868d612a8c565b338252600f8c528c6120da60408420918254612a8c565b90556120e88d600c54612a8c565b600c55335af161174a612a99565b81546001600160a01b03165af161210b612a99565b5015612272575b33600052600f815260406000205415612158575b7fb1cce8684b4ffa8667b4577654e61ee3480d661ee9c27522ac80e211f6bd4d25906040519283523392a26001600855005b601181526040600020546010546000199291908381019081116108d657808203612218575b5050601054918215612202577fb1cce8684b4ffa8667b4577654e61ee3480d661ee9c27522ac80e211f6bd4d2592016121b5816126ea565b81549060018060a01b039060031b1b19169055601055336000526011815260006040812055600e8152600060408120556019815260006040812055601a8152600060408120559050612126565b634e487b7160e01b600052603160045260246000fd5b612221906126ea565b905460039190911b1c6001600160a01b031661225e81612240846126ea565b90919060018060a01b038084549260031b9316831b921b1916179055565b60005260118252604060002055838061217d565b6064906040519062461bcd60e51b825260048201526013602482015272119959481d1c985b9cd9995c8819985a5b1959606a1b6044820152fd5b50505050600f815260406000206122c4838254612a8c565b90556122d282600c54612a8c565b600c556122e9600080808086335af161174a612a99565b612112565b6084906040519062461bcd60e51b82526004820152603c60248201527f5769746864726177616c20776f756c64206c6561766520696e7375666669636960448201527f656e7420636f76657261676520666f72206163746976652062657473000000006064820152fd5b6064906040519062461bcd60e51b825260048201526013602482015272131a5c5d5a591a5d1e481a5cc81b1bd8dad959606a1b6044820152fd5b6084906040519062461bcd60e51b82526004820152602360248201527f496e73756666696369656e74206c697175696469747920666f722070726f76696044820152623232b960e91b6064820152fd5b6084906040519062461bcd60e51b82526004820152602860248201527f5769746864726177616c20616d6f756e74206d75737420626520677265617465604482015267072207468616e20360c41b6064820152fd5b3461027f57604036600319011261027f57612450612798565b60243561245c81612fbc565b3315158061250b575b806124de575b6124c6576001600160a01b039283169282918491167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600080a4600090815260056020526040902080546001600160a01b0319169091179055005b60405163a9fbf51f60e01b8152336004820152602490fd5b5060018060a01b038116600052600660205260406000203360005260205260ff604060002054161561246b565b506001600160a01b038116331415612465565b3461027f57602036600319011261027f5760043561253b81612fbc565b506000526005602052602060018060a01b0360406000205416604051908152f35b3461027f57600036600319011261027f57604051600060018260015492612582846128b9565b92838352602094856001821691826000146110de5750506001146125ad575061106d92500383612947565b84915060016000527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6906000915b8583106125f257505061106d935082010185611060565b805483890185015287945086939092019181016125db565b3461027f57602036600319011261027f5760043560185481101561027f5760186000527fb13d2d76d1f4b7be834882e410b3e3a8afaf69f83600ae24db354391d2378d2e01546040516001600160a01b039091168152602090f35b3461027f57602036600319011261027f576004359063ffffffff60e01b821680920361027f57602091632483248360e11b81149081156126a7575b5015158152f35b6380ac58cd60e01b8114915081156126d9575b81156126c8575b50836126a0565b6301ffc9a760e01b149050836126c1565b635b5e139f60e01b811491506126ba565b6010548110156108aa5760106000527f1b6847dc741a1b0cd08d278845f9d819d87b734759afb55fe2de5cb82a9ae6720190600090565b6013548110156108aa5760136000527f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a0900190600090565b919082519283825260005b848110612784575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201612763565b600435906001600160a01b038216820361027f57565b602435906001600160a01b038216820361027f57565b606090600319011261027f576001600160a01b0390600435828116810361027f5791602435908116810361027f579060443590565b6020808201908083528351809252604092604081018260408560051b8401019601946000925b858410612830575050505050505090565b909192939495968580600192603f198582030187528a519061286360e08351835284840151908086850152830190612758565b9187810151888301526060808201519083015260808082015115159083015260a08082015115159083015260c080910151151591015299019401940192959493919061281f565b60243590811515820361027f57565b90600182811c921680156128e9575b60208310146128d357565b634e487b7160e01b600052602260045260246000fd5b91607f16916128c8565b60c0810190811067ffffffffffffffff8211176108c057604052565b60e0810190811067ffffffffffffffff8211176108c057604052565b6020810190811067ffffffffffffffff8211176108c057604052565b90601f8019910116810190811067ffffffffffffffff8211176108c057604052565b9060405191826000825461297c816128b9565b908184526020946001916001811690816000146129ec57506001146129ad575b5050506129ab92500383612947565b565b600090815285812095935091905b8183106129d45750506129ab935082010138808061299c565b855488840185015294850194879450918301916129bb565b925050506129ab94925060ff191682840152151560051b82010138808061299c565b67ffffffffffffffff81116108c057601f01601f191660200190565b929192612a3682612a0e565b91612a446040519384612947565b82948184528183011161027f578281602093846000960137010152565b9080601f8301121561027f57816020612a7c93359101612a2a565b90565b919082018092116108d657565b919082039182116108d657565b3d15612ac4573d90612aaa82612a0e565b91612ab86040519384612947565b82523d6000602084013e565b606090565b15612ad057565b60405162461bcd60e51b8152602060048201526013602482015272115512081d1c985b9cd9995c8819985a5b1959606a1b6044820152606490fd5b818102929181159184041417156108d657565b8115612b28570490565b634e487b7160e01b600052601260045260246000fd5b6001600160a01b039182169290918315610ba757600092828452826020956003875260409684888820541696879133151580612c2e575b509060037fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9284612bfb575b858352600481528b8320805460010190558683525289812080546001600160a01b0319168517905580a41692838303612bda5750505050565b6064945051926364283d7b60e01b8452600484015260248301526044820152fd5b600087815260056020526040902080546001600160a01b0319169055848352600481528b83208054600019019055612ba1565b91939450915080612c83575b15612c4a57859291879138612b75565b878688612c67576024915190637e27328960e01b82526004820152fd5b604491519063177e802f60e01b82523360048301526024820152fd5b503387148015612ca8575b80612c3a5750858252600581523385898420541614612c3a565b5086825260068152878220338352815260ff8883205416612c8e565b67ffffffffffffffff81116108c05760051b60200190565b90612ce682612cc4565b604090612cf66040519182612947565b8381528093612d07601f1991612cc4565b019160005b838110612d195750505050565b6020908251612d278161290f565b600081526060600084918083850152818785015283015260006080830152600060a0830152600060c0830152828601015201612d0c565b80518210156108aa5760209160051b010190565b60001981146108d65760010190565b612d8a81612f83565b90612d9482612cdc565b9115612ee757601254906000805b838110612db0575050505090565b604080516331a9108f60e11b8152600480820184905260209290918381602481305afa8091600091612ea3575b5090612df157505050506001905b01612da2565b6001600160a01b03878116911614612e0f575b505050600190612deb565b91839491612e9a93600195600052600b83528060002090805193612e328561290f565b82548552612e41888401612969565b9085015260028201549084015260038101546060840152015460ff9081811615156080840152818160081c16151560a084015260101c16151560c0820152612e898289612d5e565b52612e948188612d5e565b50612d72565b91903880612e04565b8581813d8311612ee0575b612eb88183612947565b81010312612edc5751906001600160a01b0382168203612ed9575038612ddd565b80fd5b5080fd5b503d612eae565b5090565b15612ef257565b60405162461bcd60e51b815260206004820152601760248201527f5061726c617920616c7265616479207265736f6c7665640000000000000000006044820152606490fd5b15612f3e57565b60405162461bcd60e51b815260206004820152601760248201527f5061726c617920616c72656164792063616e63656c65640000000000000000006044820152606490fd5b6001600160a01b03168015612fa357600052600460205260406000205490565b6040516322718ad960e21b815260006004820152602490fd5b6000818152600360205260409020546001600160a01b0316908115612fdf575090565b60249060405190637e27328960e01b82526004820152fd5b600260085414613008576002600855565b604051633ee5aeb560e01b8152600490fd5b60ff6009541661302657565b60405163d93c066560e01b8152600490fd5b6000546001600160a01b0316330361304c57565b60405163118cdaa760e01b8152336004820152602490fd5b6000908082526014602052604082205460135490600019918281019081116130f65761308f90612721565b90549060031b1c6130a38161079284612721565b84526014602052604084205560135480156130e2578101906130c482612721565b909182549160031b1b19169055601355815260146020526040812055565b634e487b7160e01b84526031600452602484fd5b634e487b7160e01b85526011600452602485fd5b9190803b613119575b50505050565b61315b60018060a01b0380921694604051938493630a85bd0160e11b968786523360048701521660248501526044840152608060648401526084830190612758565b03906020816000938185885af1908290826131da575b50506131a95782613180612a99565b80519190826131a257604051633250574960e11b815260048101839052602490fd5b9050602001fd5b6001600160e01b031916036131c2575038808080613113565b60249060405190633250574960e11b82526004820152fd5b909192506020813d60201161321b575b816131f760209383612947565b81010312612edc5751906001600160e01b031982168203612ed95750903880613171565b3d91506131ea56fea26469706673582212202d82d4223245eef649a404a1d802d9b8b9a69eaee962748b891fdb3e3508b16364736f6c63430008180033

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

0000000000000000000000001b16c0b69d4a30c42c92c873c4873787afcbec5c000000000000000000000000f9565242ad9a71d57940a81b11a3723d5f1d2097

-----Decoded View---------------
Arg [0] : _nftContract (address): 0x1B16c0B69D4a30c42c92C873C4873787AfCbEc5c
Arg [1] : _owner (address): 0xf9565242aD9A71D57940a81b11a3723D5f1D2097

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000001b16c0b69d4a30c42c92c873c4873787afcbec5c
Arg [1] : 000000000000000000000000f9565242ad9a71d57940a81b11a3723d5f1d2097


Deployed Bytecode Sourcemap

429:13914:25:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;-1:-1:-1;;;;;429:13914:25;;:::i;:::-;;;;1851:49;429:13914;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;:::i;:::-;1500:62:0;;:::i;:::-;-1:-1:-1;;;;;429:13914:25;;;;2627:22:0;;2623:91;;429:13914:25;;;;;;;;;;;;3052:40:0;429:13914:25;3052:40:0;;429:13914:25;2623:91:0;429:13914:25;;-1:-1:-1;;;2672:31:0;;429:13914:25;;2672:31:0;;429:13914:25;;;2672:31:0;429:13914:25;;;;;;-1:-1:-1;;429:13914:25;;;;;;;14324:10;429:13914;;;;;;;;;;14324:10;429:13914;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;429:13914:25;;;;;-1:-1:-1;429:13914:25;;;;;;;;;;;;;;;-1:-1:-1;;;;;429:13914:25;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;13070:17;429:13914;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;:::i;:::-;;;:::i;:::-;;;;;;;;;;;;4039:18:10;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;:::i;:::-;2322:103:18;;;:::i;:::-;1439:72:17;;:::i;:::-;2710:9:25;:13;429:13914;;;;2774:8;429:13914;;2832:18;429:13914;2832:22;;429:13914;;3031:41;2710:9;3054:4;3032:18;429:13914;;2710:9;3032:18;:::i;:::-;429:13914;3031:41;:::i;:::-;3144:2;429:13914;;;;;3144:2;429:13914;;;;;;3103:50;;429:13914;;3266:14;429:13914;3266:32;;;;;:::i;:::-;3330:44;429:13914;;3458:33;;;:::i;:::-;3266:14;429:13914;3520:13;429:13914;3520:13;;;:::i;:::-;;429:13914;;;;;;:::i;:::-;;;;3553:10;10022:16:10;10018:87;;429:13914:25;;;;5799:7:10;429:13914:25;;;;;;-1:-1:-1;;;;;429:13914:25;;9157:256:10;;429:13914:25;3553:10;429:13914;;;;;;;;9427:16:10;429:13914:25;;;;;;;;5799:7:10;429:13914:25;;;;;3553:10;429:13914;;;;;;;;;3553:10;;9577:27:10;;429:13914:25;9577:27:10;;10180:96;;3553:10:25;17034:14:10;17030:664;;429:13914:25;;;;;2013:10:13;429:13914:25;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9427:16:10;429:13914:25;;;;;5799:7:10;429:13914:25;;;;;;;;2059:23:13;429:13914:25;;;;;;2059:23:13;429:13914:25;;;;;:::i;:::-;;;;;3652:208;;429:13914;;;;;;3652:208;;429:13914;2710:9;429:13914;3652:208;;429:13914;;;3652:208;;429:13914;;3652:208;;;429:13914;;3652:208;;;429:13914;;;;3625:15;429:13914;;;;;;;;;;;;;;;;;;;;9427:16:10;429:13914:25;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9427:16:10;429:13914:25;;;;;5799:7:10;429:13914:25;;;;;9427:16:10;429:13914:25;;;;;3652:208;;429:13914;;;;;;3652:208;;429:13914;5799:7:10;429:13914:25;;;;3652:208;429:13914;;3652:208;;429:13914;;;;;;;;;;;;;;;;;;;;3652:208;;;429:13914;;;;;;3652:208;429:13914;;3652:208;;429:13914;;;;;;;;;;;;;;;;;;3904:17;429:13914;;;;3871:21;429:13914;;;;;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;9427:16:10;429:13914:25;;;3904:17;429:13914;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;3979:29;2710:9;3979:29;429:13914;3979:29;:::i;:::-;;429:13914;3553:10;429:13914;;4019:9;429:13914;;;;;;;;9427:16:10;429:13914:25;;;;;;;;3553:10;429:13914;;4019:9;429:13914;;9427:16:10;429:13914:25;;;4065:36;:51;2710:9;429:13914;;4065:51;:::i;:::-;429:13914;;3553:10;429:13914;;4132:9;429:13914;;;;;;;;;;4131:22;4127:122;;429:13914;;;;2710:9;;429:13914;;;;;;4264:43;429:13914;3553:10;4264:43;;9427:16:10;429:13914:25;;;4127:122;-1:-1:-1;;429:13914:25;9427:16:10;429:13914:25;;;4211:10;429:13914;;;;;;;9427:16:10;429:13914:25;;;4211:10;429:13914;;;;;;4211:10;429:13914;;;;;;-1:-1:-1;;;;;;429:13914:25;3553:10;429:13914;;;4127:122;;;;;429:13914;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;429:13914:25;;;;;9427:16:10;429:13914:25;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;;;;;;;;;9427:16:10;429:13914:25;;;;;;;;;;;;;;;9427:16:10;429:13914:25;;;;;;;;;;;;5799:7:10;429:13914:25;;;;;;;;;;;;;;;;;;;9427:16:10;429:13914:25;;;;;;;;;;;;;9427:16:10;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9427:16:10;429:13914:25;;;;-1:-1:-1;429:13914:25;;;;;;;-1:-1:-1;429:13914:25;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;;9427:16:10;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5799:7:10;429:13914:25;;;;;;;;;;;;;;;;9427:16:10;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9427:16:10;429:13914:25;;;;-1:-1:-1;429:13914:25;;;17030:664:10;429:13914:25;;;;;;;;;17072:71:10;;;;3553:10:25;429:13914;17072:71:10;;429:13914:25;;;;;;;;;;;;;;;;;;;;;:::i;:::-;17072:71:10;3553:10:25;429:13914;3553:10;17072:71:10;;429:13914:25;;17072:71:10;;;17030:664;-1:-1:-1;17068:616:10;;17331:353;;:::i;:::-;429:13914:25;;;17381:18:10;;;429:13914:25;;-1:-1:-1;;;17430:25:10;;3553:10:25;429:13914;17430:25:10;;429:13914:25;;;17430:25:10;17377:293;429:13914:25;17557:95:10;;17068:616;-1:-1:-1;;;;;;429:13914:25;17190:51:10;17186:130;;17030:664;;;17186:130;429:13914:25;;-1:-1:-1;;;17272:25:10;;3553:10:25;429:13914;17272:25:10;;429:13914:25;;;17272:25:10;17072:71;;;;429:13914:25;17072:71:10;;429:13914:25;17072:71:10;;;;;;429:13914:25;17072:71:10;;;:::i;:::-;;;429:13914:25;;;;;-1:-1:-1;;;;;;429:13914:25;;;;;;17072:71:10;;;;;;;-1:-1:-1;17072:71:10;;10180:96;429:13914:25;;-1:-1:-1;;;10234:31:10;;429:13914:25;;10234:31:10;;429:13914:25;;;10234:31:10;9157:256;429:13914:25;;;;15346:15:10;429:13914:25;;;;;;;-1:-1:-1;;;;;;429:13914:25;;;;;;;;;;;;;;;;;;;9157:256:10;;10018:87;429:13914:25;;-1:-1:-1;;;10061:33:10;;429:13914:25;;10061:33:10;;429:13914:25;;;10061:33:10;429:13914:25;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;;;;;;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;;;;;;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;-1:-1:-1;;;;;429:13914:25;;:::i;:::-;;;;1307:53;429:13914;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;586:26;429:13914;;;;;;;;-1:-1:-1;;;;;429:13914:25;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;1308:22:13;;;:::i;:::-;;429:13914:25;;1367:10:13;429:13914:25;;;;;;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;:::i;:::-;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;5181:4:10;429:13914:25;;;;;;;;;;;:::i;:::-;5121:7:10;;;;;;:::i;:::-;5181:4;:::i;:::-;429:13914:25;;;;;;;-1:-1:-1;;429:13914:25;;;;;;1366:43;429:13914;1366:43;;;;;;429:13914;1366:43;;:::i;:::-;429:13914;;;;;;;;;;-1:-1:-1;;;;;429:13914:25;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;1501:34;429:13914;1501:34;;;;;;429:13914;1501:34;;:::i;:::-;429:13914;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;:::i;:::-;;;:::i;:::-;-1:-1:-1;;;;;429:13914:25;;;;15698:22:10;;15694:91;;735:10:16;429:13914:25;;15794:18:10;429:13914:25;;;;;;;;;;15794:46:10;429:13914:25;;;;;;;;;;;;;;;;;;;15794:46:10;429:13914:25;;;;;;;15855:41:10;429:13914:25;735:10:16;15855:41:10;;429:13914:25;15694:91:10;429:13914:25;;-1:-1:-1;;;15743:31:10;;429:13914:25;15743:31:10;;429:13914:25;;;;;15743:31:10;429:13914:25;;;;;;-1:-1:-1;;429:13914:25;;;;-1:-1:-1;;;;;429:13914:25;;:::i;:::-;;;;13309:18;429:13914;;;;;;;13351:16;429:13914;;;;;;13391:14;429:13914;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;;;1541:56;429:13914;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;2597:7:10;429:13914:25;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;:::i;:::-;;;;2597:7:10;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;429:13914:25;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;;;;;;;;;;-1:-1:-1;429:13914:25;;-1:-1:-1;429:13914:25;;-1:-1:-1;429:13914:25;;;;;;;-1:-1:-1;;429:13914:25;;;;;;;;-1:-1:-1;;;;;429:13914:25;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;-1:-1:-1;;;;;429:13914:25;;:::i;:::-;;;;1017:46;429:13914;;;;;;;;1017:46;;;;429:13914;1017:46;;;;429:13914;1017:46;;;429:13914;1017:46;;429:13914;1017:46;;429:13914;1017:46;;429:13914;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;1500:62:0;;:::i;:::-;1439:72:17;;:::i;:::-;2532:4;429:13914:25;;2522:14:17;429:13914:25;;;2522:14:17;429:13914:25;2551:20:17;429:13914:25;;;735:10:16;429:13914:25;;2551:20:17;429:13914:25;;;;;;;;;;;2322:103:18;;:::i;:::-;1439:72:17;;:::i;:::-;4451:11:25;429:13914;;;-1:-1:-1;;;4451:33:25;;4473:10;429:13914;4451:33;;429:13914;;;;;;;;;;;;-1:-1:-1;;;;;429:13914:25;4451:33;;;;;;;429:13914;4451:33;;;429:13914;4451:37;;429:13914;;4578:9;:13;429:13914;;4473:10;429:13914;;4683:18;429:13914;;;;;;4683:35;4679:248;;429:13914;4683:18;429:13914;;;;;4936:46;4578:9;429:13914;;4936:46;:::i;:::-;429:13914;;4992:34;4578:9;4992:34;429:13914;4992:34;:::i;:::-;;429:13914;5042:44;429:13914;;4578:9;;429:13914;;4473:10;5042:44;;429:13914;;;;4679:248;4734:26;429:13914;-1:-1:-1;;;429:13914:25;;;;;;;;;;;4734:26;429:13914;;:::i;:::-;;;-1:-1:-1;;;;;429:13914:25;;;;;;;;;;4473:10;429:13914;;;;;;;;4473:10;429:13914;;4791:16;429:13914;;4822:15;429:13914;;;;4734:26;429:13914;;;;;;;;;;4473:10;429:13914;;4851:13;429:13914;;;;;;4679:248;;429:13914;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;429:13914:25;;;;;4451:33;;;;;;;;;;;;;;;;:::i;:::-;;;429:13914;;;;;4451:33;;;;;;;;;429:13914;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;1469:26;429:13914;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;;;1070:49;429:13914;;;;;;;1070:49;429:13914;1070:49;;;:::i;:::-;;429:13914;1070:49;;;429:13914;1070:49;429:13914;1070:49;;;429:13914;1070:49;;429:13914;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;13540:25;429:13914;;;1500:62:0;;:::i;:::-;429:13914:25;13506:19;429:13914;;;;;;13540:25;429:13914;;;;;;;-1:-1:-1;;429:13914:25;;;;;;:::i;:::-;1500:62:0;;:::i;:::-;2322:103:18;;:::i;:::-;1439:72:17;;:::i;:::-;429:13914:25;;;;;7975:15;429:13914;;;;;8018:13;8164:24;8018:13;429:13914;8018:13;;429:13914;;;8009:50;429:13914;;;;;8017:14;8009:50;:::i;:::-;8069:52;429:13914;;;;;8077:16;8069:52;:::i;:::-;429:13914;;;;;;;;;;;;;;;;;;;;;8164:24;2274:22:10;429:13914:25;;2274:22:10;:::i;:::-;429:13914:25;8306:7;429:13914;;8306:7;:::i;:::-;429:13914;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;:::i;:::-;-1:-1:-1;;429:13914:25;;;;;;;;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;8574:13;429:13914;8569:292;8589:17;;;;;;-1:-1:-1;;8871:2192:25;;;;8995:4;8965:26;8980:11;429:13914;8965:12;;429:13914;8980:11;;429:13914;8965:26;;:::i;:::-;429:13914;;9055:18;429:13914;8706:18;;429:13914;8706:18;429:13914;;;;;;8706:18;429:13914;;;;;;;9082:3;429:13914;;9038:47;;429:13914;;9313:18;9250:27;429:13914;;9203:8;9174:25;9189:10;429:13914;9174:25;;:::i;:::-;429:13914;9250:27;;;;;:::i;:::-;9313:18;;:::i;:::-;9416:13;429:13914;9453:3;429:13914;;9431:20;;;;;429:13914;;;;9541:74;429:13914;9542:27;429:13914;9542:10;429:13914;;9495:12;429:13914;;;;;;;9495:12;;:::i;:::-;429:13914;;9542:10;;:::i;:::-;429:13914;9542:27;:::i;:::-;9541:74;:::i;:::-;429:13914;;;;;;;;9633:37;429:13914;;;9633:37;:::i;:::-;429:13914;;;;9688:14;429:13914;;9688:33;429:13914;;;;;;9688:33;:::i;:::-;429:13914;;;9416:13;;9431:20;;;;;;;;10040:39;9431:20;;429:13914;9431:20;;;;;;9800:32;9431:20;;9750:36;429:13914;9055:18;429:13914;9750:36;:::i;:::-;9055:18;429:13914;9800:32;429:13914;9800:32;:::i;:::-;;429:13914;9919:36;429:13914;;;;;-1:-1:-1;;;;;429:13914:25;;9863:42;;;;:::i;:::-;;9919:36;:::i;:::-;429:13914;;-1:-1:-1;;;;;429:13914:25;9989:37;;;;:::i;10040:39::-;429:13914;;;;;;;;;10094:9;429:13914;;8980:11;429:13914;;;10094:29;429:13914;;;;;;;;;;;;10207:51;429:13914;;;;;;;;;;;;;10094:9;429:13914;;;;;;10142:30;:45;429:13914;;;10142:45;:::i;:::-;429:13914;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;429:13914:25;;10207:51;8871:2192;429:13914;;;;;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;;;;;;;;;9082:3;;429:13914;8871:2192;10345:13;;429:13914;10345:13;;;;;;;10484:12;429:13914;10484:12;;10340:325;10382:3;429:13914;;10360:20;;;;;429:13914;;-1:-1:-1;;;;;10424:12:25;429:13914;10424:12;;:::i;:::-;429:13914;;10470:72;10471:10;:25;:10;;;;:::i;:::-;429:13914;;;10471:25;;:::i;10470:72::-;429:13914;;;;8706:18;429:13914;;;;;10560:37;429:13914;;;10560:37;:::i;:::-;429:13914;;;;10615:16;429:13914;;10615:35;429:13914;;;;;;10615:35;:::i;:::-;429:13914;;;10345:13;;10360:20;;;;;;10848:33;10360:20;;10752:82;10360:20;10678:34;429:13914;;10678:34;429:13914;10678:34;:::i;:::-;;429:13914;10799:4;10753:26;10768:11;429:13914;;10768:11;;429:13914;10753:26;;:::i;10752:82::-;10848:33;429:13914;10848:33;:::i;:::-;;429:13914;;;;;;;;;;;10895:9;429:13914;;;;;;10895:30;429:13914;;;;;;;;;;;;11011:41;429:13914;;;;;;;;10895:9;429:13914;;10944:47;:31;429:13914;;;10944:31;429:13914;;;10944:47;:::i;:::-;429:13914;;;;;;;;;;;;;;;;;;11011:41;8871:2192;;8608:3;8646:29;;8818:32;429:13914;8646:29;;;;:::i;:::-;429:13914;;;;;;;;;;;;;;;;8706:18;429:13914;;;;;;8748:23;;;;;:::i;:::-;429:13914;8785:19;;;;;:::i;:::-;429:13914;8818:32;:::i;:::-;8608:3;429:13914;8574:13;;;429:13914;;;;;;-1:-1:-1;;429:13914:25;;;;1500:62:0;;:::i;:::-;429:13914:25;;;-1:-1:-1;;;;;;429:13914:25;;;;-1:-1:-1;;;;;429:13914:25;3052:40:0;429:13914:25;;3052:40:0;429:13914:25;;;;;;;-1:-1:-1;;429:13914:25;;;;;;;;:::i;:::-;;:::i;:::-;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;11887:21;429:13914;;;1500:62:0;;:::i;:::-;2322:103:18;;:::i;:::-;429:13914:25;;;11177:15;429:13914;;11156:112;429:13914;;;;;11177:33;429:13914;;;;;11156:112;:::i;:::-;429:13914;;;11177:15;429:13914;;11278:110;429:13914;;;;;11299:31;429:13914;;;;;11278:110;:::i;:::-;429:13914;;;;11177:15;429:13914;;;;;;11457:13;;429:13914;;-1:-1:-1;;429:13914:25;;;;;11795:33;;11711:74;;11754:4;11712:26;11727:11;-1:-1:-1;;;;;2274:22:10;429:13914:25;2274:22:10;:::i;:::-;429:13914:25;11598:36;429:13914;11571:12;;;;;;429:13914;;;11545:43;;;;;:::i;11598:36::-;11645:30;429:13914;;11645:30;429:13914;11645:30;:::i;:::-;;429:13914;;11727:11;;429:13914;11712:26;;:::i;11795:33::-;;429:13914;11863:7;;;:::i;:::-;429:13914;;;;;11887:21;429:13914;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;12674:17;429:13914;12738:29;;;:::i;:::-;12783:13;429:13914;12798:19;;;;;;429:13914;;;;;;;:::i;12819:3::-;12856:20;;429:13914;12856:20;;:::i;:::-;429:13914;;;;;;;;;;;;12907:15;429:13914;;;;;;;;;;;;:::i;:::-;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;12890:41;;;;:::i;:::-;;;;;;:::i;:::-;;429:13914;12783:13;;429:13914;;;;;;-1:-1:-1;;429:13914:25;;;;;2274:22:10;429:13914:25;;2274:22:10;:::i;:::-;429:13914:25;;-1:-1:-1;;;;;429:13914:25;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;1164:29;429:13914;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;1920:7:17;429:13914:25;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;14213:9;429:13914;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;-1:-1:-1;;;;;429:13914:25;;:::i;:::-;;;;1199:51;429:13914;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;;;:::i;:::-;;:::i;:::-;;;;;;;;:::i;:::-;;;;5181:4:10;429:13914:25;;;:::i;:::-;;;;;;;;:::i;:::-;;;;5121:7:10;;;;;:::i;429:13914:25:-;;;;;;-1:-1:-1;;429:13914:25;;;;1500:62:0;;:::i;:::-;1920:7:17;429:13914:25;;;;2264:9:17;2260:62;;429:13914:25;;;1920:7:17;429:13914:25;2798:22:17;429:13914:25;;;735:10:16;429:13914:25;;2798:22:17;429:13914:25;2260:62:17;429:13914:25;;-1:-1:-1;;;2296:15:17;;429:13914:25;;2296:15:17;429:13914:25;;;;;;-1:-1:-1;;429:13914:25;;;;-1:-1:-1;;;;;429:13914:25;;:::i;:::-;;;;1714:41;429:13914;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;1603:34;429:13914;;;;;;;;;;;;;;;:::i;:::-;;;:::i;:::-;;;;;;-1:-1:-1;;429:13914:25;;;;;1125:33;429:13914;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;;1294:7;429:13914;;;;;;;;;-1:-1:-1;;429:13914:25;;;;-1:-1:-1;;;;;429:13914:25;;:::i;:::-;;;;1794:51;429:13914;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;-1:-1:-1;;;;;429:13914:25;;:::i;:::-;;;;1415:48;429:13914;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;1679:29;429:13914;;;;;;;;;;;;;;;;;;;;;;2322:103:18;;;:::i;:::-;1439:72:17;;:::i;:::-;5210:10:25;;429:13914;;5325:10;429:13914;;5306:18;429:13914;;;;;;5296:40;;429:13914;;5325:10;429:13914;;5430:16;429:13914;;;;;;1294:7;429:13914;;;;;;;5490:15;:30;429:13914;;5584:27;429:13914;5584:18;429:13914;5584:27;:::i;:::-;5642:14;429:13914;5642:36;429:13914;;5325:10;429:13914;;5306:18;429:13914;;;;;;5887:16;429:13914;;;;;;;5942:14;429:13914;;;;;;6025:17;;;;6021:1056;6025:17;;;6356:8;6325:27;6217:32;429:13914;6078:17;;6218:18;6078:17;;;;;;;;;:::i;:::-;6218:18;:::i;6217:32::-;6342:10;429:13914;6325:27;;:::i;:::-;429:13914;6592:36;6395:12;;;;;;;;:::i;:::-;5325:10;429:13914;;5306:18;429:13914;;;6422:40;429:13914;;;;;;6422:40;:::i;:::-;429:13914;;6476:28;429:13914;5584:18;429:13914;6476:28;:::i;:::-;5584:18;429:13914;5325:10;6535:43;;;;:::i;6592:36::-;429:13914;;-1:-1:-1;;;;;429:13914:25;6703:37;;;;:::i;:::-;;429:13914;;;6021:1056;5325:10;429:13914;;5306:18;429:13914;;;;;;7091:35;7087:666;;6021:1056;7768:38;429:13914;;;;;;5325:10;7768:38;;429:13914;2924:21:18;429:13914:25;;7087:666;7158:13;429:13914;;;;;;7217:26;429:13914;-1:-1:-1;;429:13914:25;;;;;;;;;;;7273:18;;;7269:236;;7087:666;429:13914;;7217:26;429:13914;;;;;;7768:38;429:13914;;;;;:::i;:::-;;;;;;;;;;;;;;;;;7217:26;429:13914;5325:10;429:13914;;7158:13;429:13914;;;;;;;5430:16;429:13914;;;;;;;5887:16;429:13914;;;;;;;5942:14;429:13914;;;;;;;7087:666;;;;429:13914;;;;;;;;;;;;7269:236;7334:37;;;:::i;:::-;429:13914;;;;;;;;-1:-1:-1;;;;;429:13914:25;7389:48;429:13914;7389:33;;;:::i;:::-;:48;429:13914;;;;;;;;;;;;;;;;;;;;;;;;;7389:48;429:13914;;7158:13;429:13914;;;;;;7269:236;;;;429:13914;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;429:13914:25;;;;;6021:1056;429:13914;;;;5306:18;429:13914;;;;;6860:40;429:13914;;;6860:40;:::i;:::-;429:13914;;6914:28;429:13914;5584:18;429:13914;6914:28;:::i;:::-;5584:18;429:13914;7030:36;429:13914;5325:10;;;;;6973:43;;;;:::i;7030:36::-;6021:1056;;429:13914;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;:::i;:::-;;;14943:22:10;;;:::i;:::-;735:10:16;15093:18:10;;:35;;;429:13914:25;15093:69:10;;;429:13914:25;15089:142:10;;-1:-1:-1;;;;;429:13914:25;;;;;;;;;15283:28:10;429:13914:25;;15283:28:10;429:13914:25;;;;15346:15:10;429:13914:25;;;;;;;-1:-1:-1;;;;;;429:13914:25;;;;;;;15089:142:10;429:13914:25;;-1:-1:-1;;;15189:27:10;;735:10:16;429:13914:25;15189:27:10;;429:13914:25;;;15189:27:10;15093:69;429:13914:25;;;;;;;;;;4039:18:10;429:13914:25;;;;;735:10:16;429:13914:25;;;;;;;;;;15132:30:10;15093:69;;:35;-1:-1:-1;;;;;;429:13914:25;;735:10:16;15115:13:10;;15093:35;;429:13914:25;;;;;;-1:-1:-1;;429:13914:25;;;;;;3583:22:10;;;:::i;:::-;;429:13914:25;;6034:15:10;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;;2442:5:10;429:13914:25;2442:5:10;429:13914:25;;;;;:::i;:::-;;;;;;;;2442:5:10;429:13914:25;;2442:5:10;;429:13914:25;2442:5:10;;;429:13914:25;;;;;;;;;;;;;:::i;:::-;;;;2442:5:10;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;429:13914:25;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;1761:27;429:13914;1761:27;;;;;;429:13914;;;;;;;-1:-1:-1;;;;;429:13914:25;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;1062:35:13;;;:75;;;;429:13914:25;;;;;;;1062:75:13;-1:-1:-1;;;1698:40:10;;;-1:-1:-1;1698:104:10;;;;1062:75:13;1698:156:10;;;;1062:75:13;;;;;1698:156:10;-1:-1:-1;;;861:40:20;;-1:-1:-1;1698:156:10;;;:104;-1:-1:-1;;;1754:48:10;;;-1:-1:-1;1698:104:10;;429:13914:25;7217:26;429:13914;;;;;;7217:26;-1:-1:-1;429:13914:25;;;;-1:-1:-1;429:13914:25;:::o;:::-;12674:17;429:13914;;;;;;12674:17;-1:-1:-1;429:13914:25;;;;-1:-1:-1;429:13914:25;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;429:13914:25;;;;;;:::o;:::-;;;;-1:-1:-1;;;;;429:13914:25;;;;;;:::o;:::-;;;;;;;;;-1:-1:-1;;;;;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;-1:-1:-1;429:13914:25;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;:::o;:::-;-1:-1:-1;429:13914:25;;;;;;;;-1:-1:-1;;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;429:13914:25;;;;:::o;:::-;;;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;-1:-1:-1;429:13914:25;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;:::i;:::-;;:::o;:::-;;;;;;;;;;:::o;:::-;;;;;;;;;;:::o;:::-;;;;;;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;-1:-1:-1;429:13914:25;;;;:::o;:::-;;;:::o;:::-;;;;:::o;:::-;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;:::o;:::-;;;;;;;;;;;;4143:578:10;-1:-1:-1;;;;;429:13914:25;;;;4143:578:10;;4237:16;;4233:87;;-1:-1:-1;429:13914:25;;;;;;;5799:7:10;429:13914:25;;;;;;;;;;735:10:16;;;;9035:18:10;;9031:86;;;4143:578;9161:18;;5799:7;9577:27;9161:18;;9157:256;;4143:578;429:13914:25;;;9487:9:10;429:13914:25;;;;;;;9427:16:10;429:13914:25;;;;;;;;;;;;-1:-1:-1;;;;;;429:13914:25;;;;;;9577:27:10;429:13914:25;4610:21:10;;;;4606:109;;4143:578;;;;:::o;4606:109::-;429:13914:25;;;;4654:50:10;;;;;;9487:9;4654:50;;429:13914:25;;;;;;;;;4654:50:10;9157:256;429:13914:25;;;;15346:15:10;429:13914:25;;;;;;;-1:-1:-1;;;;;;429:13914:25;;;;;;9368:9:10;429:13914:25;;;;;;;-1:-1:-1;;429:13914:25;;;9157:256:10;;9031:86;6514:127;;;;;;;;;9031:86;7193:39;7189:255;;9031:86;;;;;;;;7189:255;7252:19;;;429:13914:25;;;;;7298:31:10;;;;;;;;;429:13914:25;7298:31:10;7248:186;429:13914:25;;;7375:44:10;;;;;;735:10:16;7375:44:10;;;429:13914:25;;;;;7375:44:10;6514:127;735:10:16;;6552:16:10;;:52;;;;6514:127;6552:88;6514:127;6552:88;429:13914:25;;;;6034:15:10;429:13914:25;;735:10:16;429:13914:25;;;;;;6608:32:10;6514:127;;6552:52;429:13914:25;;;;4039:18:10;429:13914:25;;;;;735:10:16;429:13914:25;;;;;;;;;;6552:52:10;;429:13914:25;;;;;;;;;;;:::o;:::-;;;;;:::i;:::-;;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;:::-;;;-1:-1:-1;429:13914:25;;;;;;;;;;:::o;:::-;;;;;;;;:::i;:::-;-1:-1:-1;429:13914:25;;;-1:-1:-1;429:13914:25;;;;;;;;;;;;;;;-1:-1:-1;429:13914:25;;;;-1:-1:-1;429:13914:25;;;;-1:-1:-1;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;-1:-1:-1;;429:13914:25;;;;;;;:::o;11921:639::-;12041:15;;;:::i;:::-;12092:21;;;;:::i;:::-;12128:12;;12124:32;;12225:11;429:13914;;12139:1;;12221:15;;;;;;12539:14;;;;11921:639;:::o;12238:3::-;429:13914;;;-1:-1:-1;;;12261:15:25;;;;;;429:13914;;;12261:15;;;;;429:13914;;;12261:4;:15;;;;12139:1;12261:15;;;12238:3;-1:-1:-1;12257:262:25;;;12496:8;;;;429:13914;12496:8;12206:13;429:13914;12206:13;;12257:262;-1:-1:-1;;;;;429:13914:25;;;;;12323:13;12319:138;;12257:262;;;;429:13914;12257:262;12238:3;;12319:138;429:13914;;;;12424:14;429:13914;;;12139:1;429:13914;12384:15;429:13914;;;12139:1;429:13914;;;;;;;;:::i;:::-;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;12360:42;;;;:::i;:::-;;;;;;:::i;:::-;;12424:14;:::i;:::-;12319:138;;;;;;12261:15;;;;;;;;;;;;;;:::i;:::-;;;429:13914;;;;;;-1:-1:-1;;;;;429:13914:25;;;;;;12261:15;;;;429:13914;;;;;;;12261:15;;;;;12124:32;12142:14;;:::o;429:13914::-;;;;:::o;:::-;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;-1:-1:-1;;;429:13914:25;;;;;;;;;;;;;;;;;;;;1920:208:10;-1:-1:-1;;;;;429:13914:25;2006:19:10;;2002:87;;2023:1;429:13914:25;2105:9:10;429:13914:25;;;2023:1:10;429:13914:25;;1920:208:10;:::o;2002:87::-;429:13914:25;;-1:-1:-1;;;2048:30:10;;2023:1;2048:30;;;429:13914:25;;;2048:30:10;16138:241;-1:-1:-1;429:13914:25;;;5799:7:10;429:13914:25;;;;;;-1:-1:-1;;;;;429:13914:25;;16267:19:10;;16263:88;;16360:12;16138:241;:::o;16263:88::-;429:13914:25;;;;7298:31:10;;;;16309;;;;;429:13914:25;16309:31:10;2431:307:18;1755:1;2558:7;429:13914:25;2558:18:18;2554:86;;1755:1;2558:7;429:13914:25;2431:307:18:o;2554:86::-;429:13914:25;;-1:-1:-1;;;2599:30:18;;;;;2002:128:17;429:13914:25;1920:7:17;429:13914:25;;2063:61:17;;2002:128::o;2063:61::-;429:13914:25;;-1:-1:-1;;;2098:15:17;;;;;1796:162:0;1710:6;429:13914:25;-1:-1:-1;;;;;429:13914:25;735:10:16;1855:23:0;1851:101;;1796:162::o;1851:101::-;429:13914:25;;-1:-1:-1;;;1901:40:0;;735:10:16;1901:40:0;;;429:13914:25;;;1901:40:0;13578:383:25;-1:-1:-1;429:13914:25;;;;13663:21;429:13914;;;;;;13725:17;429:13914;;;;;;;;;;;;;13725:47;;;:::i;:::-;429:13914;;;;;;13783:38;:24;;;;:::i;:38::-;429:13914;;13663:21;429:13914;;;;;;13725:17;429:13914;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;13725:17;429:13914;;;13663:21;429:13914;;;;;;13578:383::o;429:13914::-;-1:-1:-1;;;429:13914:25;;;;;;;;;-1:-1:-1;;;429:13914:25;;;;;;;;16918:782:10;;;17034:14;;17030:664;;16918:782;;;;;:::o;17030:664::-;429:13914:25;;;;;;;;;;;;;;;;;;17072:71:10;;;;735:10:16;17072:71:10;;;429:13914:25;;;;;;;;;;;;;;;;;;;;:::i;:::-;17072:71:10;17051:1;17072:71;17051:1;;17072:71;;;;;;;;;;;;17030:664;-1:-1:-1;;17068:616:10;;17331:353;;;:::i;:::-;429:13914:25;;;;17381:18:10;;;429:13914:25;;-1:-1:-1;;;17430:25:10;;17072:71;17430:25;;429:13914:25;;;;;17430:25:10;17377:293;17557:95;;17072:71;17557:95;;17068:616;-1:-1:-1;;;;;;429:13914:25;17190:51:10;17186:130;;17068:616;17030:664;;;;;;17186:130;429:13914:25;;;;10061:33:10;;;;17272:25;;17072:71;17272:25;;429:13914:25;17272:25:10;17072:71;;;;;;;;;;;;;;;;;;;:::i;:::-;;;429:13914:25;;;;;;-1:-1:-1;;;;;;429:13914:25;;;;;;17072:71:10;;;;;;;;;-1:-1:-1;17072:71:10;

Swarm Source

ipfs://2d82d4223245eef649a404a1d802d9b8b9a69eaee962748b891fdb3e3508b163

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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