ETH Price: $2,926.80 (-0.89%)

Contract

0xa247CfF2a50dE0328a0A5bdD0C563Bd44b1a8af9
 

Overview

ETH Balance

0.012151 ETH

ETH Value

$35.56 (@ $2,926.80/ETH)

Token Holdings

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Create Lots112817592024-11-12 1:02:13439 days ago1731373333IN
Eesee
0 ETH0.000003230.00167793
Create Lots112409902024-11-11 2:23:15440 days ago1731291795IN
Eesee
0 ETH0.000007320.00045675
Create Lots112364792024-11-10 23:52:53440 days ago1731282773IN
Eesee
0 ETH0.000001050.00063033
Create Lots111916302024-11-09 22:57:55441 days ago1731193075IN
Eesee
0 ETH0.000000470.00188026
Create Lots111907572024-11-09 22:28:49441 days ago1731191329IN
Eesee
0 ETH0.000000320.00130181
Create Lots111906972024-11-09 22:26:49441 days ago1731191209IN
Eesee
0 ETH0.000000330.00132861
Create Lots111891722024-11-09 21:35:59441 days ago1731188159IN
Eesee
0 ETH0.000000350.00149032
Create Lots111891522024-11-09 21:35:19441 days ago1731188119IN
Eesee
0 ETH0.000000360.00150301
Create Lots111891132024-11-09 21:34:01441 days ago1731188041IN
Eesee
0 ETH0.000000440.00190656
Create Lots111890512024-11-09 21:31:57441 days ago1731187917IN
Eesee
0 ETH0.000000360.00149273
Create Lots111481972024-11-08 22:50:09442 days ago1731106209IN
Eesee
0 ETH0.000000970.00412775
Create Lots111372172024-11-08 16:44:09442 days ago1731084249IN
Eesee
0 ETH0.000001160.00476507
Create Lots111132602024-11-08 3:25:35443 days ago1731036335IN
Eesee
0 ETH0.000000920.00396451
Create Lots111131982024-11-08 3:23:31443 days ago1731036211IN
Eesee
0 ETH0.000000910.00391345
Create Lots111101562024-11-08 1:42:07443 days ago1731030127IN
Eesee
0 ETH0.000000880.00404181
Create Lots111101312024-11-08 1:41:17443 days ago1731030077IN
Eesee
0 ETH0.000000890.00407258
Create Lots111100882024-11-08 1:39:51443 days ago1731029991IN
Eesee
0 ETH0.000000910.00414094
Create Lots110626922024-11-06 23:19:59444 days ago1730935199IN
Eesee
0 ETH0.000001130.00467321
Create Lots110626542024-11-06 23:18:43444 days ago1730935123IN
Eesee
0 ETH0.000001190.00493625
Create Lots110222952024-11-06 0:53:25445 days ago1730854405IN
Eesee
0 ETH0.00000070.00263151
Create Lots110214242024-11-06 0:24:23445 days ago1730852663IN
Eesee
0 ETH0.000000380.00164069
Create Lots110037692024-11-05 14:35:53446 days ago1730817353IN
Eesee
0 ETH0.000001930.0011153
Create Lots109643852024-11-04 16:43:05446 days ago1730738585IN
Eesee
0 ETH0.000000520.00141001
Create Lots109643322024-11-04 16:41:19446 days ago1730738479IN
Eesee
0 ETH0.00000050.00130893
Create Lots109642672024-11-04 16:39:09446 days ago1730738349IN
Eesee
0 ETH0.000000480.00118228
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
102936572024-10-20 4:05:29462 days ago1729397129
Eesee
0.0012 ETH
92910382024-09-26 23:04:51485 days ago1727391891
Eesee
0.0005 ETH
82520002024-09-02 21:50:15509 days ago1725313815
Eesee
0.00031 ETH
71940512024-08-09 10:05:17534 days ago1723197917
Eesee
0.0002 ETH
66814102024-07-28 13:17:15546 days ago1722172635
Eesee
0.001 ETH
65182142024-07-24 18:37:23549 days ago1721846243
Eesee
0.00001 ETH
65181842024-07-24 18:36:23549 days ago1721846183
Eesee
0.001 ETH
63446442024-07-20 18:11:43553 days ago1721499103
Eesee
0.01 ETH
59360862024-07-11 7:13:07563 days ago1720681987
Eesee
0.00001 ETH
59359652024-07-11 7:09:05563 days ago1720681745
Eesee
0.00001 ETH
58201442024-07-08 14:48:23566 days ago1720450103
Eesee
0.0001 ETH
55950562024-07-03 9:45:27571 days ago1719999927
Eesee
0.000005 ETH
53987542024-06-28 20:42:03575 days ago1719607323
Eesee
0.0095 ETH
53816712024-06-28 11:12:37576 days ago1719573157
Eesee
0.0002 ETH
53736582024-06-28 6:45:31576 days ago1719557131
Eesee
0.001 ETH
53736532024-06-28 6:45:21576 days ago1719557121
Eesee
0.001 ETH
52547952024-06-25 12:43:25579 days ago1719319405
Eesee
0.00008 ETH
52134152024-06-24 13:44:05580 days ago1719236645
Eesee
0.001 ETH
50095372024-06-19 20:28:09584 days ago1718828889
Eesee
0.001 ETH
50095102024-06-19 20:27:15584 days ago1718828835
Eesee
0.001 ETH
50093192024-06-19 20:20:53584 days ago1718828453
Eesee
0.001 ETH
50093042024-06-19 20:20:23584 days ago1718828423
Eesee
0.001 ETH
48117842024-06-15 6:36:23589 days ago1718433383
Eesee
0.0095 ETH
48117142024-06-15 6:34:03589 days ago1718433243
Eesee
0.0095 ETH
47374262024-06-13 13:17:47591 days ago1718284667
Eesee
0.0095 ETH
View All Internal Transactions

Cross-Chain Transactions
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x2c47FC6F...3EFb6edda
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
Eesee

Compiler Version
v0.8.21+commit.d9974bed

Optimization Enabled:
Yes with 2500 runs

Other Settings:
shanghai EvmVersion

Contract Source Code (Solidity Standard Json-Input format)

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/metatx/ERC2771Context.sol";
import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import "../interfaces/IEesee.sol";
import "../libraries/AssetTransfer.sol";
import "../abstract/MulticallPayable.sol";
import "../abstract/BlastPointsReceiver.sol";
import "../abstract/roles/EeseeAdmin.sol";

contract Eesee is IEesee, ERC2771Context, ERC721Holder, ERC1155Holder, EIP712, MulticallPayable, BlastPointsReceiver, EeseeAdmin {
    using AssetTransfer for Asset;
    using SafeERC20 for IERC20;

    ///@dev An array of all existing lots.
    Lot[] public lots;

    ///@dev ESE token this contract uses.
    IERC20 public immutable ESE;
    ///@dev Eesee staking contract. Tracks volume for this contract.
    IEeseeStaking public immutable staking;
    ///@dev Contract used to call external functions in another context.
    IEeseeProxy private immutable proxy;
    ///@dev Contract that mints NFTs.
    IEeseeMinter private immutable minter;
    ///@dev Contract that provides random.
    IEeseeRandom public immutable random;
    ///@dev Address the {fee}s are sent to.
    address public feeSplitter;
    ///@dev True if lot nonce has already been used.
    mapping(address => mapping(uint256 => bool)) public nonceUsed;

    ///@dev Min and max durations for a lot.
    uint64 public minDuration = 1 days;
    uint64 public maxDuration = 30 days;
    ///@dev In case random request fails to get delivered 24 hours after the lot was closed, unlock Reclaim functions.
    uint32 public constant RETURN_INTERVAL = 24 hours;
    ///@dev Max ESE in existence.
    uint96 private constant MAX_ESE = 1_000_000_000 * (10**18);
    ///@dev Denominator for fee variables.
    uint32 private constant DENOMINATOR = 10000;
    ///@dev Fee that is collected to {feeSplitter} from each fulfilled lot. [10000 == 100%]
    uint32 public fee = 600;

    ///@dev The Royalty Engine is a contract that provides an easy way for any marketplace to look up royalties for any given token contract.
    IRoyaltyEngineV1 immutable private royaltyEngine;

    modifier isValidRecipient(address recipient){
        if(recipient == address(0)) revert InvalidRecipient();
        _;
    }

    constructor(
        IERC20 _ESE,
        IEeseeStaking _staking,
        IEeseeProxy _proxy,
        IEeseeMinter _minter,
        IEeseeRandom _random,
        address _feeSplitter,
        IRoyaltyEngineV1 _royaltyEngine,
        IEeseeAccessManager _accessManager,

        IBlastPoints _blastPoints,
        address _blastPointsOperator,

        address trustedForwarder
    ) EeseeRoleHandler(_accessManager) BlastPointsReceiver(_blastPoints, _blastPointsOperator) ERC2771Context(trustedForwarder) EIP712("Eesee", "1") {
        if(
            address(_ESE) == address(0) || 
            address(_proxy) == address(0) ||
            address(_minter) == address(0) ||
            address(_random) == address(0) ||
            _feeSplitter == address(0) ||
            address(_royaltyEngine) == address(0)
        ) revert InvalidConstructor();

        ESE = _ESE;
        staking = _staking;
        proxy = _proxy;
        minter = _minter;
        random = _random;

        feeSplitter = _feeSplitter;
        royaltyEngine = _royaltyEngine;
    }

    // ============ External Write Functions ============

    /**
     * @dev Creates lots and buys tickets in them. Emits {CreateLot} for each lot created and {BuyTicket} event for each ticket bought.
     * Note: Because of how nonPayable check in buyTickets works, users can create Native type lots with this function only by calling it with multicall.
     * @param assets - Assets to list. Note: The sender must have them approved for this contract.
     * @param params - Parameters for lots.
     * @param expectedFee - Expected fee for this lot to avoid race condition with {changeFee}. 
     * @param amounts - Amounts of tickets to buy in each lot.
     * @param recipient - Recipient of tickets.
     * @param permit - Abi-encoded ESE permit data containing approveAmount, deadline, v, r and s. Set to empty bytes to skip permit.

     * @return IDs - IDs of created lots.
     * @return tokensSpent - ESE tokens spent.
     */
    function createLotsAndBuyTickets(
        Asset[] calldata assets, 
        LotParams[] calldata params, 
        uint32 expectedFee,
        uint32[] calldata amounts, 
        address recipient,
        bytes calldata permit
    ) external payable returns(uint256[] memory IDs, uint96 tokensSpent){
        IDs = createLots(assets, params, expectedFee);
        tokensSpent = buyTickets(IDs, amounts, recipient, permit);
    }

    /**
     * @dev Receive assets the sender won from lots. Emits {ReceiveAsset} event for each of the asset received.
     * @param IDs - IDs of lots to claim assets in.
     * @param recipient - Address to send Assets to. 
     
     * @return assets - Assets received.
     */
    function receiveAssets(uint256[] calldata IDs, address recipient) external payable nonPayable isValidRecipient(recipient) returns(Asset[] memory assets){
        assets = new Asset[](IDs.length);

        address msgSender = _msgSender();
        for(uint256 i; i < IDs.length;){
            uint256 ID = IDs[i];
            _isValidID(ID);
            Lot storage lot = lots[ID];
            uint32 endTimestamp = lot.endTimestamp;
            if(endTimestamp == 0) revert LotNotExists(ID);
            if(!lot.closed) revert LotNotClosed(ID);

            if(lot.buyout){ // In case the tickets in a lot were bought out by a single address, we don't need to wait for random.
                if(msgSender != lot.recipients[0]) revert CallerNotWinner(ID); 
            } else {
                uint256 randomWord = _getRandomWordAndValidateTimestamp(ID, endTimestamp);
                _validateWinner(ID, randomWord, msgSender);
            }

            if(lot.assetClaimed) revert AssetAlreadyClaimed(ID);
            Asset memory asset = lot.asset;
            if(lot.tokensClaimed){ 
                delete lots[ID]; 
            }else{
                lot.assetClaimed = true;
            }
            assets[i] = asset.transferAssetTo(recipient, minter);

            emit ReceiveAsset(ID, msgSender, recipient, assets[i]);
            unchecked{ ++i; }
        }
    }

    /**
     * @dev Receive ESE the sender has earned from lots. Emits {ReceiveTokens} event for each of the claimed lot. 
     * Note: If the lot has expired, it takes 24 hours before {reclaimTokens} becomes available. 
     * If a random number is received in this timeframe, a winner is chosen and {receiveTokens} becomes avaliable for the winner to be called instead. 
     * In such case, a winner wins all collected ESE tokens instead of asset.
     * @param IDs - IDs of lots to claim tokens in.
     * @param recipient - Address to send tokens to.
     
     * @return amount - ESE received.
     */
    function receiveTokens(uint256[] calldata IDs, address recipient) external payable nonPayable isValidRecipient(recipient) returns(uint96 amount){
        address msgSender = _msgSender();
        uint96 feeAmount;
        for(uint256 i; i < IDs.length;){
            uint256 ID = IDs[i];
            _isValidID(ID);
            Lot storage lot = lots[ID];
            address owner = lot.owner;
            if(owner == address(0)) revert LotNotExists(ID);
            uint32 ticketsBought = lot.ticketsBought;
            if(ticketsBought == 0) revert NoTicketsBought(ID);

            bool collectRoyalties;
            AssetType assetType = lot.asset.assetType;
            if(lot.buyout){ // In case the tickets in a lot were bought out by a single address, we don't need to wait for random.
                if(assetType == AssetType.ESE){
                    if(msgSender != lot.recipients[0]) revert CallerNotWinner(ID);
                } else {
                    if(msgSender != owner) revert CallerNotOwner(ID);
                    collectRoyalties = _isEligibleForRoyalties(assetType);
                }
            } else {
                uint256 randomWord = _getRandomWordAndValidateTimestamp(ID, lot.endTimestamp);
                if(!lot.closed || assetType == AssetType.ESE){ // In case we used ESE as an asset or the listing has expired, the winner claims the tokens.
                    _validateWinner(ID, randomWord, msgSender);
                }else{
                    if(msgSender != owner) revert CallerNotOwner(ID);
                    collectRoyalties = _isEligibleForRoyalties(assetType);
                }
            }
            
            // For _amount to overflow there must be more than type.max(uint96) tokens in existence, which is not the case for ESE.
            unchecked {
                uint96 _amount = lot.ticketPrice * ticketsBought;
                if(collectRoyalties){
                    _amount -= _collectRoyalties(lot.asset.token, lot.asset.tokenID, _amount, owner);
                }
                // Project fees
                uint96 _feeAmount = uint96(uint256(_amount) * lot.fee / DENOMINATOR);
                feeAmount += _feeAmount;
                _amount -= _feeAmount;

                amount += _amount; 
                ++i;

                emit ReceiveTokens(ID, msgSender, recipient, _amount);
            }

            if(lot.tokensClaimed) revert TokensAlreadyClaimed(ID);
            if(lot.assetClaimed || assetType == AssetType.ESE) {
                delete lots[ID];
            } else {
                lot.tokensClaimed = true;
            }
        }
        // Transfer later to save gas
        if(feeAmount > 0){
            address _feeSplitter = feeSplitter;
            ESE.safeTransfer(_feeSplitter, feeAmount);
            emit CollectFee(_feeSplitter, feeAmount);
        }
        ESE.safeTransfer(recipient, amount);
    }

    /**
     * @dev Reclaim assets from expired lots. Emits {ReclaimAsset} event for each lot ID.
     * @param IDs - IDs of lots to reclaim assets in.
     * @param recipient - Address to send assets to.
     
     * @return assets - Assets reclaimed.
     */
    function reclaimAssets(uint256[] calldata IDs, address recipient) external payable nonPayable isValidRecipient(recipient) returns(Asset[] memory assets){
        assets = new Asset[](IDs.length);

        address msgSender = _msgSender();
        for(uint256 i; i < IDs.length;){
            uint256 ID = IDs[i];
            _isValidID(ID);
            Lot storage lot = lots[ID];
            address owner = lot.owner;
            if(owner == address(0)) revert LotNotExists(ID);
            if(msgSender != owner) revert CallerNotOwner(ID);
            if(lot.buyout) revert LotAlreadyFulfilled(ID);
            if(lot.assetClaimed) revert AssetAlreadyClaimed(ID);

            uint32 endTimestamp = lot.endTimestamp;
            if(lot.closed) {
                _validateLotExpired(ID, endTimestamp);
            } else if(block.timestamp <= endTimestamp) revert LotNotExpired(ID);

            Asset memory asset = lot.asset;
            if(lot.tokensClaimed || lot.ticketsBought == 0) { 
                delete lots[ID];
            }else{
                lot.assetClaimed = true;
            }
            assets[i] = asset.transferAssetTo(recipient, minter);

            emit ReclaimAsset(ID, msgSender, recipient, assets[i]);
            unchecked{ ++i; }
        }
    }

    /**
     * @dev Reclaim ESE from expired lots. Emits {ReclaimTokens} event for each lot ID.
     * @param IDs - IDs of lots to reclaim tokens in.
     * @param recipient - Address to send tokens to.
     
     * @return amount - ESE received.
     * Note: This function will only be available after 24 hours after the lot has ended/expired and if no random number was received in this 24 hour timeframe.
     */
    function reclaimTokens(uint256[] calldata IDs, address recipient) external payable nonPayable isValidRecipient(recipient) returns(uint96 amount){
        address msgSender = _msgSender();
        for(uint256 i; i < IDs.length;){
            uint256 ID = IDs[i];
            _isValidID(ID);
            Lot storage lot = lots[ID];
            uint96 ticketPrice = lot.ticketPrice;
            if(ticketPrice == 0) revert LotNotExists(ID);
            uint32 ticketsHeldByAddress = lot.ticketsHeldByAddress[msgSender];
            if(ticketsHeldByAddress == 0) revert NoTicketsHeld(ID);
            if(lot.buyout) revert LotAlreadyFulfilled(ID);
            _validateLotExpired(ID, lot.endTimestamp);

            unchecked {
                uint96 _amount = ticketPrice * ticketsHeldByAddress;
                amount += _amount;
                ++i;

                lot.ticketsBought -= ticketsHeldByAddress;
                lot.ticketsHeldByAddress[msgSender] = 0;

                emit ReclaimTokens(ID, msgSender, recipient, _amount);
            }
            if(lot.ticketsBought == 0 && (lot.assetClaimed || lot.asset.assetType == AssetType.ESE)) delete lots[ID];
        }
        // Transfer later to save some gas
        ESE.safeTransfer(recipient, amount);
    }

    /**
     * @dev Call any external contract function. Is intended to be used with multicall.
     * @param to - Address to call.
     * @param data - Data to call {to} with.
     
     * @return bytes - Return data received from a call.
     */
    function callExternal(address to, bytes calldata data) external payable returns(bytes memory){
        _checkValueLeft(0);
        return proxy.callExternal{value: msg.value}(to, data);
    }

    // ============ Admin Methods ============

    /**
     * @dev Changes minDuration. Emits {ChangeMinDuration} event.
     * @param _minDuration - New minDuration.
     * Note: This function can only be called by ADMIN_ROLE.
     */
    function changeMinDuration(uint64 _minDuration) external onlyAdmin {
        if(_minDuration >= maxDuration) revert InvalidDuration();

        emit ChangeMinDuration(minDuration, _minDuration);
        minDuration = _minDuration;
    }

    /**
     * @dev Changes maxDuration. Emits {ChangeMaxDuration} event.
     * @param _maxDuration - New maxDuration.
     * Note: This function can only be called by ADMIN_ROLE.
     */
    function changeMaxDuration(uint64 _maxDuration) external onlyAdmin {
        if(_maxDuration <= minDuration) revert InvalidDuration();

        emit ChangeMaxDuration(maxDuration, _maxDuration);
        maxDuration = _maxDuration;
    }

    /**
     * @dev Changes fee. Emits {ChangeFee} event.
     * @param _fee - New fee.
     * Note: This function can only be called by ADMIN_ROLE.
     */
    function changeFee(uint32 _fee) external onlyAdmin {
        if(_fee > 5000) revert FeeTooHigh();

        emit ChangeFee(fee, _fee);
        fee = _fee;
    }

    /**
     * @dev Changes feeSplitter. Emits {ChangeFeeSplitter} event.
     * @param _feeSplitter - New fee.
     * Note: This function can only be called by ADMIN_ROLE.
     */
    function changeFeeSplitter(address _feeSplitter) external onlyAdmin {
        if(_feeSplitter == address(0)) revert InvalidFeeSplitter();

        emit ChangeFeeSplitter(feeSplitter, _feeSplitter);
        feeSplitter = _feeSplitter;
    }

    // ============ External View Functions ============

    /**
     * @dev Get length of the lots array.
     * @return length - Length of the lots array.
     */
    function getLotsLength() external view returns(uint256 length) {
        length = lots.length;
    }

    /**
     * @dev Get the holder of the specified ticket in lot.
     * @param ID - ID of the lot.
     * @param ticket - Ticket index.
     
     * @return address - Ticket holder.
     */
    function getLotTicketHolder(uint256 ID, uint32 ticket) external view returns(address) {
        return _getLotTicketHolder(lots[ID], ticket);
    }
    
    /**
     * @dev Get amount of tickets held by address in a lot.
     * @param ID - ID of the lot.
     * @param _address - Holder address.
     
     * @return uint32 - Tickets held by {_address}.
     */
    function getLotTicketsHeldByAddress(uint256 ID, address _address) external view returns(uint32) {
        return lots[ID].ticketsHeldByAddress[_address];
    }

    /**
     * @dev Get amount of bonus tickets held by address in a lot.
     * @param ID - ID of the lot.
     * @param _address - Holder address.
     
     * @return uint32 - Tickets held by {_address}.
     */
    function getLotBonusTicketsHeldByAddress(uint256 ID, address _address) external view returns(uint32) {
        return lots[ID].bonusTicketsHeldByAddress[_address];
    }

    /**
     * @dev Get the recipient of tickets in specified {transaction}.
     * @param ID - ID of the lot.
     * @param transaction - Index of the transaction in a lot.
     
     * @return address - The sender of the tickets in {transaction}.
     */
    function getBuyTicketsRecipient(uint256 ID, uint32 transaction) external view returns(address) {
        return lots[ID].recipients[transaction];
    }

    // ============ Public Write Functions ============

    /**
     * @dev Creates lots with assets from sender's balance. Emits {CreateLot} events for each created lot.
     * @param assets - Assets to list. Note: The sender must have them approved for this contract.
     * @param params.totalTickets - Total amount of tickets that can be bought by participants.
     * @param params.ticketPrice - Prices for a single ticket.
     * @param params.duration - Durations of lots. Can be in range [minDuration, maxDuration].
     * @param params.owner - Owners of the lots. Owners can claim tokens after winning or reclaim assets if not enough people bought the tickets. 
     * @param params.signer - Signer of {signature} or msg.sender to disable {signature} check. 
     * @param params.nonce - Unique random nonce for {signer}. Can be set to any value if signer == msg.sender.
     * @param params.deadline - {signature} deadline. Can be set to any value if signer == msg.sender.
     * @param params.signature - Signature bytes data. Can be set to any value if signer == msg.sender.
     * @param expectedFee - Expected fee for this lot to avoid race condition with {changeFee}. 

     * @return IDs - IDs of lots created.
     */
    function createLots(
        Asset[] calldata assets,
        LotParams[] calldata params,
        uint32 expectedFee
    ) public payable returns(uint256[] memory IDs){
        if(expectedFee != fee) revert InvalidFee();
        if(assets.length != params.length) revert InvalidArrayLengths();
        IDs = new uint256[](assets.length);

        uint256 availableValue = msg.value;
        address msgSender = _msgSender();
        bytes32 domainSeparatorV4 = _domainSeparatorV4();
        for(uint256 i; i < assets.length;) {
            address signer; 
            uint256 nonce;
            (signer, nonce, availableValue) = assets[i].transferAssetFrom(params[i], availableValue, msgSender, domainSeparatorV4, ESE);
            IDs[i] = _createLot(assets[i], params[i], expectedFee, signer);

            if(msgSender != signer){
                if(nonceUsed[signer][nonce]) revert NonceUsed();
                nonceUsed[signer][nonce] = true;
                emit ConsumeNonce(IDs[i], signer, nonce);
            } 
            unchecked{ ++i; }
        }
        _checkValueLeft(availableValue);
    }

    /**
     * @dev Buys tickets to participate in a lot. Emits {BuyTicket} event for each ticket bought.
     * @param IDs - IDs of lots to buy tickets for.
     * @param amounts - Amounts of tickets to buy in each lot.
     * @param recipient - Recipient of tickets.
     * @param permit - Abi-encoded ESE permit data containing approveAmount, deadline, v, r and s. Set to empty bytes to skip permit.

     * @return tokensSpent - ESE tokens spent.
     */
    function buyTickets(
        uint256[] memory IDs, 
        uint32[] calldata amounts, 
        address recipient,
        bytes calldata permit
    ) public payable nonPayable isValidRecipient(recipient) returns(uint96 tokensSpent){
        if(IDs.length != amounts.length) revert InvalidArrayLengths();

        for(uint256 i; i < IDs.length;){
            tokensSpent += _buyTickets(IDs[i], amounts[i], recipient);
            unchecked{ ++i; }
        }

        address msgSender = _msgSender();
        if(permit.length != 0){
            (uint256 approveAmount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) = abi.decode(permit, (uint256, uint256, uint8, bytes32, bytes32));
            IERC20Permit(address(ESE)).permit(msgSender, address(this), approveAmount, deadline, v, r, s);
        }
        
        ESE.safeTransferFrom(msgSender, address(this), tokensSpent);
        if(address(staking) != address(0)){
            try staking.addVolume(tokensSpent, recipient) {} catch {
                emit AddVolumeReverted(tokensSpent, recipient);
            }
        }
    }

    // ============ Internal Write Functions ============

    function _createLot(Asset calldata asset, LotParams calldata params, uint32 _fee, address signer) internal returns(uint256 ID){
        if(params.duration < minDuration) revert DurationTooLow(minDuration);
        if(params.duration > maxDuration) revert DurationTooHigh(maxDuration);
        if(params.totalTickets == 0) revert TotalTicketsTooLow();
        if(params.totalTickets > 1_000_000_000) revert TotalTicketsTooHigh();
        if(params.ticketPrice == 0) revert TicketPriceTooLow();
        if(params.owner == address(0)) revert InvalidOwner();
        if(params.ticketPrice * params.totalTickets > MAX_ESE) revert ESEOverflow();

        ID = lots.length;
        Lot storage lot = lots.push();
        lot.asset = asset;
        lot.owner = params.owner;
        lot.totalTickets = params.totalTickets;
        lot.ticketPrice = params.ticketPrice;
        lot.fee = _fee; // We save fees at the time of lot's creation to not have any control over existing lots' fees

        unchecked{
            uint32 endTimestamp = uint32(block.timestamp) + params.duration;
            lot.endTimestamp = endTimestamp;

            emit CreateLot(ID, asset, signer, params.owner, params.totalTickets, params.ticketPrice, endTimestamp);
        }
    }

    function _buyTickets(uint256 ID, uint32 amount, address recipient) internal returns(uint96 tokensSpent){
        _isValidID(ID);
        if(amount == 0) revert BuyAmountTooLow();
        Lot storage lot = lots[ID];
        uint32 totalTickets = lot.totalTickets;
        if(totalTickets == 0) revert LotNotExists(ID);

        uint32 _ticketsBought = lot.ticketsBought;
        uint32 ticketsBought = amount + _ticketsBought;
        if(ticketsBought > totalTickets) revert BuyLimitExceeded();
        if(block.timestamp > lot.endTimestamp) revert LotExpired(ID);

        unchecked{
            uint32 bonus = uint32((uint256(amount) * amount) / (uint256(4) * totalTickets));
            uint32 _bonusTickets = lot.bonusTickets;
            uint32 bonusTickets = _bonusTickets + bonus;
            lot.bonusTickets = bonusTickets;
        
            uint32 ticketsHeldByAddress = amount + lot.ticketsHeldByAddress[recipient];
            lot.bonusTicketsHeldByAddress[recipient] += bonus;
            lot.ticketsHeldByAddress[recipient] = ticketsHeldByAddress;
            lot.ticketsBought = ticketsBought;

            uint32 transactions = lot.transactions;
            lot.recipients[transactions] = recipient;
            lot.intervals[transactions] = ticketsBought + bonusTickets;
            lot.transactions = ++transactions;

            if(ticketsBought == totalTickets){
                lot.endTimestamp = uint32(block.timestamp);
                lot.closed = true;

                if(ticketsHeldByAddress == totalTickets){
                    lot.buyout = true;
                }
            }
        
            tokensSpent = lot.ticketPrice * amount;
            // Lower Bound is inclusive
            emit BuyTickets(ID, recipient, _ticketsBought + _bonusTickets, amount, tokensSpent, bonus);
        }
    }

    function _collectRoyalties(
        address collection, 
        uint256 tokenID, 
        uint96 value, 
        address lotOwner
    ) internal returns(uint96 royaltyAmount) {
        (address payable[] memory recipients, uint256[] memory amounts) = royaltyEngine.getRoyalty(collection, tokenID, value);
        for(uint256 i; i < recipients.length;){
            uint96 amount = uint96(amounts[i]); // Won't overflow because otherwise there needs to be more than type(uint96).max ESE tokens in existence.
            //There is no reason to collect royalty from owner if it goes to owner
            if (recipients[i] != address(0) && recipients[i] != lotOwner && amount != 0){
                ESE.safeTransfer(recipients[i], amount);
                unchecked {
                    royaltyAmount += amount;
                }
                emit CollectRoyalty(recipients[i], amount);
            }
            unchecked{ ++i; }
        }
    }

    // ============ Internal View Functions ============

    /**
     * @dev Adapted form Openzeppelin's { _findUpperBound } function.
     */
    function _getLotTicketHolder(Lot storage lot, uint32 ticket) internal view returns (address) {
        uint32 high = lot.transactions;
        unchecked{
            if (high == 0 || ticket >= lot.intervals[high - 1]) {
                return address(0);
            }
        }

        uint32 low;
        while (low < high) {
            // (a + b) / 2 can overflow.
            uint32 mid = (low & high) + (low ^ high) / 2;

            // Note that mid will always be strictly less than high (i.e. it will be a valid array index)
            // because mid rounds down (it does integer division with truncation).
            if (lot.intervals[mid] > ticket) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }

        // At this point `low` is the exclusive upper bound.
        return lot.recipients[low];
    }

    function _validateLotExpired(uint256 ID, uint32 endTimestamp) internal view {
        (,uint256 randomTimestamp) = random.getRandomFromTimestamp(endTimestamp);
        if(randomTimestamp == 0){ // random wasn't rquested.
            unchecked{ if(block.timestamp <= endTimestamp + RETURN_INTERVAL) revert LotNotExpired(ID); }
        } else { // random was rquested.
            unchecked{ if(randomTimestamp <= endTimestamp + RETURN_INTERVAL) revert LotAlreadyFulfilled(ID); }
        }
    }

    function _isEligibleForRoyalties(AssetType assetType) internal pure returns(bool collectRoyalties){
        if(assetType == AssetType.ERC721 || assetType == AssetType.ERC1155) collectRoyalties = true;
    }

    function _getRandomWordAndValidateTimestamp(uint256 ID, uint32 endTimestamp) internal view returns(uint256 randomWord){
        uint256 randomTimestamp;
        (randomWord, randomTimestamp) = random.getRandomFromTimestamp(endTimestamp);
        if(randomTimestamp == 0) revert LotNotFulfilled(ID);
        unchecked{ if(randomTimestamp > endTimestamp + RETURN_INTERVAL) revert LotExpired(ID); }
    }

    function _validateWinner(uint256 ID, uint256 randomWord, address msgSender) internal view {
        Lot storage lot = lots[ID];
        unchecked {
            // Perform circular bit shift to add entropy to winners in the same batch.
            uint256 IDmod256 = ID % 256;
            uint256 circularShiftWord = (randomWord << IDmod256) | (randomWord >> (256 - IDmod256));
            address winner = _getLotTicketHolder(lot, uint32(circularShiftWord % (lot.ticketsBought + lot.bonusTickets)));         
            if(msgSender != winner) revert CallerNotWinner(ID);
        }
    }

    function _isValidID(uint256 ID) internal view {
        if(ID >= lots.length) revert InvalidLotID();
    }
    
    function _msgSender() internal view override(Context, ERC2771Context) returns (address) {
        return ERC2771Context._msgSender();
    }

    function _msgData() internal view override(Context, ERC2771Context) returns (bytes calldata) {
        return ERC2771Context._msgData();
    }

    function _contextSuffixLength() internal view override(Context, ERC2771Context) returns (uint256) {
        return ERC2771Context._contextSuffixLength();
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC1271 standard signature validation method for
 * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
 *
 * _Available since v4.1._
 */
interface IERC1271 {
    /**
     * @dev Should return whether the signature provided is valid for the provided data
     * @param hash      Hash of the data to be signed
     * @param signature Signature byte array associated with _data
     */
    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}

File 3 of 46 : IERC5267.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol)

pragma solidity ^0.8.0;

interface IERC5267 {
    /**
     * @dev MAY be emitted to signal that the domain could have changed.
     */
    event EIP712DomainChanged();

    /**
     * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
     * signature.
     */
    function eip712Domain()
        external
        view
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        );
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (metatx/ERC2771Context.sol)

pragma solidity ^0.8.9;

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

/**
 * @dev Context variant with ERC2771 support.
 *
 * WARNING: The usage of `delegatecall` in this contract is dangerous and may result in context corruption.
 * Any forwarded request to this contract triggering a `delegatecall` to itself will result in an invalid {_msgSender}
 * recovery.
 */
abstract contract ERC2771Context is Context {
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    address private immutable _trustedForwarder;

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor(address trustedForwarder) {
        _trustedForwarder = trustedForwarder;
    }

    function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
        return forwarder == _trustedForwarder;
    }

    function _msgSender() internal view virtual override returns (address) {
        uint256 calldataLength = msg.data.length;
        uint256 contextSuffixLength = _contextSuffixLength();
        if (isTrustedForwarder(msg.sender) && calldataLength >= contextSuffixLength) {
            return address(bytes20(msg.data[calldataLength - contextSuffixLength:]));
        } else {
            return super._msgSender();
        }
    }

    function _msgData() internal view virtual override returns (bytes calldata) {
        uint256 calldataLength = msg.data.length;
        uint256 contextSuffixLength = _contextSuffixLength();
        if (isTrustedForwarder(msg.sender) && calldataLength >= contextSuffixLength) {
            return msg.data[:calldataLength - contextSuffixLength];
        } else {
            return super._msgData();
        }
    }

    /**
     * @dev ERC-2771 specifies the context as being a single address (20 bytes).
     */
    function _contextSuffixLength() internal view virtual override returns (uint256) {
        return 20;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol)

pragma solidity ^0.8.0;

import "./ERC1155Receiver.sol";

/**
 * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
 *
 * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
 * stuck.
 *
 * @dev _Available since v3.1._
 */
contract ERC1155Holder is ERC1155Receiver {
    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] memory,
        uint256[] memory,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
}

File 8 of 46 : ERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../IERC1155Receiver.sol";
import "../../../utils/introspection/ERC165.sol";

/**
 * @dev _Available since v3.1._
 */
abstract contract ERC1155Receiver is ERC165, IERC1155Receiver {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
    }
}

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

pragma solidity ^0.8.0;

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

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.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.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

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

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

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

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the 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 override returns (uint8) {
        return 18;
    }

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

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

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

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

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` 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 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * 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 `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

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

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

        return true;
    }

    /**
     * @dev Moves `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.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(address from, address to, uint256 amount) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
            // decrementing then incrementing.
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

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

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

        _totalSupply += amount;
        unchecked {
            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
            _balances[account] += amount;
        }
        emit Transfer(address(0), account, amount);

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

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

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

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
            // Overflow not possible: amount <= accountBalance <= totalSupply.
            _totalSupply -= amount;
        }

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

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

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

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

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== 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 v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

    /**
     * @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.encodeWithSelector(token.transfer.selector, 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.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

    /**
     * @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);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @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.encodeWithSelector(token.approve.selector, spender, value);

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

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * 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.isContract(address(token));
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

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

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

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

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

File 15 of 46 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/utils/ERC721Holder.sol)

pragma solidity ^0.8.0;

import "../IERC721Receiver.sol";

/**
 * @dev Implementation of the {IERC721Receiver} interface.
 *
 * Accepts all token transfers.
 * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
 */
contract ERC721Holder is IERC721Receiver {
    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }
}

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

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

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

pragma solidity ^0.8.0;

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

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

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

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

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

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

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

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

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

        return (signer, RecoverError.NoError);
    }

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

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

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

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, "\x19\x01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            data := keccak256(ptr, 0x42)
        }
    }

    /**
     * @dev Returns an Ethereum Signed Data with intended validator, created from a
     * `validator` and `data` according to the version 0 of EIP-191.
     *
     * See {recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x00", validator, data));
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol)

pragma solidity ^0.8.8;

import "./ECDSA.sol";
import "../ShortStrings.sol";
import "../../interfaces/IERC5267.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
 * separator of the implementation contract. This will cause the `_domainSeparatorV4` function to always rebuild the
 * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
 *
 * _Available since v3.4._
 *
 * @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
 */
abstract contract EIP712 is IERC5267 {
    using ShortStrings for *;

    bytes32 private constant _TYPE_HASH =
        keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    bytes32 private immutable _cachedDomainSeparator;
    uint256 private immutable _cachedChainId;
    address private immutable _cachedThis;

    bytes32 private immutable _hashedName;
    bytes32 private immutable _hashedVersion;

    ShortString private immutable _name;
    ShortString private immutable _version;
    string private _nameFallback;
    string private _versionFallback;

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        _name = name.toShortStringWithFallback(_nameFallback);
        _version = version.toShortStringWithFallback(_versionFallback);
        _hashedName = keccak256(bytes(name));
        _hashedVersion = keccak256(bytes(version));

        _cachedChainId = block.chainid;
        _cachedDomainSeparator = _buildDomainSeparator();
        _cachedThis = address(this);
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (address(this) == _cachedThis && block.chainid == _cachedChainId) {
            return _cachedDomainSeparator;
        } else {
            return _buildDomainSeparator();
        }
    }

    function _buildDomainSeparator() private view returns (bytes32) {
        return keccak256(abi.encode(_TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));
    }

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

    /**
     * @dev See {EIP-5267}.
     *
     * _Available since v4.9._
     */
    function eip712Domain()
        public
        view
        virtual
        override
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        )
    {
        return (
            hex"0f", // 01111
            _name.toStringWithFallback(_nameFallback),
            _version.toStringWithFallback(_versionFallback),
            block.chainid,
            address(this),
            bytes32(0),
            new uint256[](0)
        );
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/SignatureChecker.sol)

pragma solidity ^0.8.0;

import "./ECDSA.sol";
import "../../interfaces/IERC1271.sol";

/**
 * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA
 * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like
 * Argent and Gnosis Safe.
 *
 * _Available since v4.1._
 */
library SignatureChecker {
    /**
     * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the
     * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`.
     *
     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
     * change through time. It could return true at block N and false at block N+1 (or the opposite).
     */
    function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) {
        (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature);
        return
            (error == ECDSA.RecoverError.NoError && recovered == signer) ||
            isValidERC1271SignatureNow(signer, hash, signature);
    }

    /**
     * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated
     * against the signer smart contract using ERC1271.
     *
     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
     * change through time. It could return true at block N and false at block N+1 (or the opposite).
     */
    function isValidERC1271SignatureNow(
        address signer,
        bytes32 hash,
        bytes memory signature
    ) internal view returns (bool) {
        (bool success, bytes memory result) = signer.staticcall(
            abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature)
        );
        return (success &&
            result.length >= 32 &&
            abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector));
    }
}

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/ShortStrings.sol)

pragma solidity ^0.8.8;

import "./StorageSlot.sol";

// | string  | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA   |
// | length  | 0x                                                              BB |
type ShortString is bytes32;

/**
 * @dev This library provides functions to convert short memory strings
 * into a `ShortString` type that can be used as an immutable variable.
 *
 * Strings of arbitrary length can be optimized using this library if
 * they are short enough (up to 31 bytes) by packing them with their
 * length (1 byte) in a single EVM word (32 bytes). Additionally, a
 * fallback mechanism can be used for every other case.
 *
 * Usage example:
 *
 * ```solidity
 * contract Named {
 *     using ShortStrings for *;
 *
 *     ShortString private immutable _name;
 *     string private _nameFallback;
 *
 *     constructor(string memory contractName) {
 *         _name = contractName.toShortStringWithFallback(_nameFallback);
 *     }
 *
 *     function name() external view returns (string memory) {
 *         return _name.toStringWithFallback(_nameFallback);
 *     }
 * }
 * ```
 */
library ShortStrings {
    // Used as an identifier for strings longer than 31 bytes.
    bytes32 private constant _FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;

    error StringTooLong(string str);
    error InvalidShortString();

    /**
     * @dev Encode a string of at most 31 chars into a `ShortString`.
     *
     * This will trigger a `StringTooLong` error is the input string is too long.
     */
    function toShortString(string memory str) internal pure returns (ShortString) {
        bytes memory bstr = bytes(str);
        if (bstr.length > 31) {
            revert StringTooLong(str);
        }
        return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));
    }

    /**
     * @dev Decode a `ShortString` back to a "normal" string.
     */
    function toString(ShortString sstr) internal pure returns (string memory) {
        uint256 len = byteLength(sstr);
        // using `new string(len)` would work locally but is not memory safe.
        string memory str = new string(32);
        /// @solidity memory-safe-assembly
        assembly {
            mstore(str, len)
            mstore(add(str, 0x20), sstr)
        }
        return str;
    }

    /**
     * @dev Return the length of a `ShortString`.
     */
    function byteLength(ShortString sstr) internal pure returns (uint256) {
        uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;
        if (result > 31) {
            revert InvalidShortString();
        }
        return result;
    }

    /**
     * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.
     */
    function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {
        if (bytes(value).length < 32) {
            return toShortString(value);
        } else {
            StorageSlot.getStringSlot(store).value = value;
            return ShortString.wrap(_FALLBACK_SENTINEL);
        }
    }

    /**
     * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
     */
    function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {
        if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {
            return toString(value);
        } else {
            return store;
        }
    }

    /**
     * @dev Return the length of a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
     *
     * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
     * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
     */
    function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {
        if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {
            return byteLength(value);
        } else {
            return bytes(store).length;
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
 * _Available since v4.9 for `string`, `bytes`._
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}

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

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

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

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

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

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

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

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

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

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

interface IBlastPoints {
	function configurePointsOperator(address operator) external;
}

abstract contract BlastPointsReceiver {
    error InvalidPointsOperator();
	constructor(IBlastPoints _blastPoints, address _pointsOperator) {
        if(address(_blastPoints) != address(0)){
            if(_pointsOperator == address(0)) revert InvalidPointsOperator();
		    _blastPoints.configurePointsOperator(_pointsOperator);
        } else if(_pointsOperator != address(0)) revert InvalidPointsOperator();
	}
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

import "@openzeppelin/contracts/utils/Context.sol";

abstract contract MulticallPayable is Context {
    ///@dev Adapted from OpenZeppelin's ReentrancyGuard to add third state and to only trigger for payable multicalls.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;
    uint256 private constant VALUE_SPENT = 3;
    uint256 private _status;

    error InvalidValueCall();
    error InvalidMsgValue();
    error ReentrantCall();

    modifier nonPayable() {
        // Can only receive value if called with multicall with msg.value.
        if(msg.value != 0 && _status == NOT_ENTERED) revert InvalidMsgValue();
        _;
    }

    constructor() {
        _status = NOT_ENTERED;
    }

    // ============ External Write Functions ============

    /**
     * @dev Allows calling multiple contract functions in a single call:
     * @param data - ABI-encoded data describing the call.
     *
     * @param results - ABI-encoded return data for each function call.
     * Note: Can only call functions using msg.value once.
     */
    function multicall(bytes[] calldata data) external payable returns (bytes[] memory results) {
        if(msg.value != 0){
            if(_status != NOT_ENTERED) revert ReentrantCall();
            _status = ENTERED;
        }

        // Extract ERC2771 context from the last bytes of calldata.
        bytes memory context = msg.sender == _msgSender()
            ? new bytes(0)
            : msg.data[msg.data.length - _contextSuffixLength():];
        
        results = new bytes[](data.length);
        for (uint256 i; i < data.length;) {
            // Append extracted ERC2771 context to each delegatecall calldata.
            (bool success, bytes memory result) = address(this).delegatecall(bytes.concat(data[i], context));
            if (!success) {
                if (result.length == 0) revert();
                assembly {
                    revert(add(32, result), mload(result))
                }
            }

            results[i] = result;
            unchecked{ ++i; }
        }

        if(msg.value != 0) {
            // Cannot call payable multicall without spending value.
            if(_status != VALUE_SPENT) revert InvalidValueCall();
            _status = NOT_ENTERED;
        }
    }

    // ============ Internal Write Functions ============

    ///@dev Allows the function to be both payable and non payable depending on value left.
    function _checkValueLeft(uint256 valueLeft) internal {
        if(msg.value == 0) return;

        uint256 status = _status;
        if(status == VALUE_SPENT) revert InvalidValueCall();
        
        if(valueLeft == 0){
            if(status == ENTERED) _status = VALUE_SPENT;
        } else if(status == NOT_ENTERED || valueLeft != msg.value) revert InvalidMsgValue();
    }
}

File 31 of 46 : EeseeAdmin.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

import "./EeseeRoleHandler.sol";

abstract contract EeseeAdmin is EeseeRoleHandler {
    ///@dev Admin role in {accessManager}.
    bytes32 public immutable ADMIN_ROLE;

    constructor() {
        ADMIN_ROLE = accessManager.ADMIN_ROLE();
    }

    modifier onlyAdmin(){
        _validateRole(ADMIN_ROLE, _msgSender());
        _;
    }
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

import "@openzeppelin/contracts/utils/Context.sol";
import "../../interfaces/IEeseeAccessManager.sol";

abstract contract EeseeRoleHandler is Context {
    ///@dev Access manager for Eesee contract ecosystem.
    IEeseeAccessManager public immutable accessManager;

    error CallerNotAuthorized();
    error InvalidAccessManager();

    constructor(IEeseeAccessManager _accessManager) {
        if(address(_accessManager) == address(0)) revert InvalidAccessManager();
        accessManager = _accessManager;
    }

    modifier onlyRole(bytes32 role){
        _validateRole(role, _msgSender());
        _;
    }

    function _hasRole(bytes32 role, address _addr) internal view virtual returns (bool) {
        return accessManager.hasRole(role, _addr);
    }

    function _validateRole(bytes32 role, address _addr) internal view {
        if(!_hasRole(role, _addr)) revert CallerNotAuthorized();
    }
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

import "./IEeseeMinter.sol";
import "./IEeseeRandom.sol";
import "./IEeseeStaking.sol";
import "./IEeseeProxy.sol";
import "./IRoyaltyEngineV1.sol";
import "../types/Asset.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

interface IEesee {
    /**
     * @dev Lot:
     * {totalTickets} - Amount of tickets sold in this lot. 
     * {bonusTickets} - Bonus tickets in the lot.
     * {ticketsBought} - Amount of tickets bought (not including bonus).
     * {ticketPrice} - Price of a single ticket.

     * {transactions} - BuyTickets transactions.
     * {endTimestamp} - lot expiration timestamp. type(uint32).max = 4294967295s = 2106 years.
     * {fee} - Fee sent to {feeSplitter}.

     * {closed} - Is lot closed with a function call as opposed to expired.
     * {assetClaimed} - Is Asset claimed/reclaimed.
     * {tokensClaimed} - Are tokens claimed.
     * {buyout} - Indicationg if the lot was bought out by a single address.

     * {owner} - Lot creator.
     * {asset} - Asset sold in this lot. 

     * {intervals} - Exclusive upper bounds for amount of tickets for each BuyTickets transaction.
     * {recipients} - The address the tickets in the interval were bought for.
     * {ticketsHeldByAddress} - Total amount of tickets held by address (not including bonus).
     * {bonusTicketsHeldByAddress} - Amount of bonus tickets held by address.
     */
    struct Lot {
        uint32 totalTickets;
        uint32 bonusTickets;
        uint32 ticketsBought;
        uint96 ticketPrice;

        uint32 transactions;
        uint32 endTimestamp;
        uint32 fee;

        bool closed;
        bool buyout;
        bool assetClaimed;
        bool tokensClaimed;

        address owner;
        Asset asset;

        mapping(uint32 => uint32) intervals;
        mapping(uint32 => address) recipients;
        mapping(address => uint32) ticketsHeldByAddress;
        mapping(address => uint32) bonusTicketsHeldByAddress;
    }

    /**
     * @dev LotParams:
     * {totalTickets} - Amount of tickets sold in this lot. 
     * {ticketPrice} - Price of a single ticket.
     * {duration} - Duration of a lot (in seconds).
     * {owner} - Lot owner.
     * {signer} - Signer of signature or msg.sender to disable signature check. 
     * {signatureData} - ABI-encoded data with nonce, deadline and signature bytes. If signer == msg.sender can be set to any value.
     */
    struct LotParams{
        uint32 totalTickets;
        uint96 ticketPrice;
        uint32 duration;
        address owner;

        address signer;
        bytes signatureData;
    }

    event CreateLot(
        uint256 indexed ID,
        Asset asset,
        address indexed signer,
        address indexed owner,
        uint32 totalTickets, 
        uint96 ticketPrice,
        uint32 endTimestamp
    );

    event ConsumeNonce(
        uint256 indexed ID,
        address indexed signer,
        uint256 indexed nonce
    );

    //Note: lowerBound is inclusive
    event BuyTickets(
        uint256 indexed ID,
        address indexed recipient,
        uint32 indexed lowerBound,
        uint32 ticketAmount,
        uint96 tokensSpent,
        uint32 bonusTickets
    );

    event AddVolumeReverted(
        uint96 untrackedVolume,
        address indexed recipient
    );


    event ReceiveAsset(
        uint256 indexed ID,
        address indexed winner,
        address indexed recipient,
        Asset asset
    );

    event ReceiveTokens(
        uint256 indexed ID,
        address indexed claimer,
        address indexed recipient,
        uint96 amount
    );


    event ReclaimAsset(
        uint256 indexed ID,
        address indexed owner,
        address indexed recipient,
        Asset asset
    );

    event ReclaimTokens(
        uint256 indexed ID,
        address indexed claimer,
        address indexed recipient,
        uint96 amount
    );


    event CollectRoyalty(
        address indexed recipient,
        uint96 amount
    );

    event CollectFee(
        address indexed to,
        uint96 amount
    );


    event ChangeMinDuration(
        uint64 indexed previousMinDuration,
        uint64 indexed newMinDuration
    );

    event ChangeMaxDuration(
        uint64 indexed previousMaxDuration,
        uint64 indexed newMaxDuration
    );

    event ChangeFee(
        uint32 indexed previousFee, 
        uint32 indexed newFee
    );

    event ChangeFeeSplitter(
        address indexed previousFeeSplitter, 
        address indexed newFeeSplitter
    );

    error CallerNotOwner(uint256 ID);
    error CallerNotWinner(uint256 ID);

    error AssetAlreadyClaimed(uint256 ID);
    error TokensAlreadyClaimed(uint256 ID);

    error LotAlreadyFulfilled(uint256 ID);
    error LotNotFulfilled(uint256 ID);
    error LotExpired(uint256 ID);
    error LotNotExpired(uint256 ID);
    error LotNotExists(uint256 ID);
    error LotNotClosed(uint256 ID);

    error DurationTooLow(uint64 minDuration);
    error DurationTooHigh(uint64 maxDuration);
    error TotalTicketsTooLow();
    error TotalTicketsTooHigh();
    error TicketPriceTooLow();
    error BuyAmountTooLow();
    error FeeTooHigh();
    error ExpiredDeadline();
    error ESEOverflow();

    error BuyLimitExceeded();
    error NoTicketsHeld(uint256 ID);
    error NoTicketsBought(uint256 ID);

    error InvalidArrayLengths();
    error InvalidRecipient();
    error InvalidAmount();
    error InvalidDuration();
    error InvalidOwner();
    error InvalidAsset();
    error InvalidToken();
    error InvalidTokenID();
    error InvalidInterface();
    error InvalidSignature();
    error InvalidData();
    error InvalidFee();
    error InvalidFeeSplitter();
    error InvalidConstructor();
    error InvalidLazyMintOwner();
    error InvalidLotID();

    error NonceUsed();
    error TransferNotSuccessful();

    function lots(uint256) external view returns(
        uint32 totalTickets,
        uint32 bonusTickets,
        uint32 ticketsBought,
        uint96 ticketPrice,

        uint32 transactions,
        uint32 endTimestamp,
        uint32 fee,

        bool closed,
        bool buyout,
        bool assetClaimed,
        bool tokensClaimed,

        address owner,
        Asset memory asset
    );

    function ESE() external view returns(IERC20);
    function staking() external view returns(IEeseeStaking);
    function random() external view returns(IEeseeRandom);

    function minDuration() external view returns(uint64);
    function maxDuration() external view returns(uint64);
    function fee() external view returns(uint32);
    function feeSplitter() external view returns(address);
    function nonceUsed(address, uint256) external view returns(bool);
    function RETURN_INTERVAL() external view returns(uint32);

    function createLots(
        Asset[] calldata assets, 
        LotParams[] calldata params,
        uint32 expectedFee
    ) external payable returns(uint256[] memory IDs);

    function createLotsAndBuyTickets(
        Asset[] calldata assets, 
        LotParams[] calldata params, 
        uint32 expectedFee,
        uint32[] calldata amounts, 
        address recipient,
        bytes calldata permit
    ) external payable returns(uint256[] memory IDs, uint96 tokensSpent);

    function buyTickets(uint256[] calldata ID, uint32[] calldata amount, address recipient, bytes calldata permit) external payable returns(uint96 tokensSpent);

    function receiveAssets(uint256[] calldata IDs, address recipient) external payable returns(Asset[] memory assets);
    function receiveTokens(uint256[] calldata IDs, address recipient) external payable returns(uint96 amount);

    function reclaimAssets(uint256[] calldata IDs, address recipient) external payable returns(Asset[] memory assets);
    function reclaimTokens(uint256[] calldata IDs, address recipient) external payable returns(uint96 amount);

    function callExternal(address to, bytes calldata data) external payable returns(bytes memory);

    function getLotsLength() external view returns(uint256 length);
    function getLotTicketHolder(uint256 ID, uint32 ticket) external view returns(address);
    function getLotTicketsHeldByAddress(uint256 ID, address _address) external view returns(uint32);
    function getLotBonusTicketsHeldByAddress(uint256 ID, address _address) external view returns(uint32);
    function getBuyTicketsRecipient(uint256 ID, uint32 transaction) external view returns(address);

    function changeMinDuration(uint64 _minDuration) external;
    function changeMaxDuration(uint64 _maxDuration) external;
    function changeFee(uint32 _fee) external;
    function changeFeeSplitter(address _feeSplitter) external;
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

interface IEeseeAccessManager {
    event RoleGranted(bytes32 indexed role, address indexed account);
    event RoleRevoked(bytes32 indexed role, address indexed account);

    error CallerNotAdmin();

    function hasRole(bytes32 role, address account) external view returns (bool);
    function ADMIN_ROLE() external view returns (bytes32);

    function grantRole(bytes32 role, address account) external;
    function revokeRole(bytes32 role, address account) external;
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "../interfaces/IEeseeNFTDrop.sol";
import "../interfaces/IEeseeNFTLazyMint.sol";

interface IEeseeMinter {
    error IncorrectTokenURILength();
    error InvalidConstructor();
    error InvalidOwner();
    error InvalidRecipient();

    event DeployLazyMint(IERC721 indexed collection, address indexed sender, address indexed owner, uint256 collectionID);
    event LazyMint(IERC721 indexed collection, uint256 indexed tokenID, address indexed recipient);
    event DeployDrop(IERC721 indexed collection, address indexed sender);

    function random() external view returns(IEeseeRandom);
    function lazyMintCollections(address,address,uint256) view external returns(IEeseeNFTLazyMint);
    function lazyMint(
        uint256 collectionID, 
        address owner,
        LazyMintCollectionMetadata calldata collectionMetadata,
        LazyMintTokenMetadata calldata tokenMetadata,
        address recipient
    ) external returns (IERC721 collection, uint256 tokenID);
    function deployDropCollection(
        DropMetadata calldata metadata, 
        uint32 mintLimit,
        uint32 mintStartTimestamp, 
        IEeseeNFTDrop.StageOptions[] calldata stages
    ) external returns(IERC721 collection);
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

import "../types/DropMetadata.sol";
import "../interfaces/IEeseeRandom.sol";

interface IEeseeNFTDrop {
    /**
     * @dev SaleStage:
     * {startTimestamp} - Timestamp when this stage starts.
     * {addressMintedAmount} - Amount of nfts minted by address.
     * {stageOptions} - Additional options for this stage.
     */
    struct SaleStage {
        uint32 startTimestamp;
        mapping(address => uint32) addressMintedAmount;
        StageOptions stageOptions;
    }	 
    /**
     * @dev StageOptions:
     * {duration} - Duration of mint stage.
     * {perAddressMintLimit} - Mint limit for one address.
     * {allowListMerkleRoot} - Root of merkle tree for allowlist.
     */
    struct StageOptions {     
        uint32 duration;
        uint32 perAddressMintLimit;
        bytes32 allowListMerkleRoot;
    }

    error MintTimestampNotInFuture();
    error PresaleStageLimitExceeded();
    error MintLimitExceeded();
    error MintingNotStarted();
    error MintingEnded();
    error InvalidProof();
    error InvalidStage();
    error ZeroSaleStageDuration();

    function initialize(
        DropMetadata calldata metadata,
        uint32 _mintLimit,
        uint32 mintStartTimestamp, 
        StageOptions[] calldata salesOptions,
        IEeseeRandom _random,
        address _minter
    ) external;

    function baseURI() external view returns (string memory);
    function revealedURI() external view returns (string memory);
    function contractURI() external view returns (string memory);
    function mintLimit() external view returns (uint32);
    function random() external view returns (IEeseeRandom);

    function getSaleStage() external view returns (uint8 index);
    function stages(uint256) external view returns (uint32 startTimestamp, StageOptions memory stageOptions);
    
    function nextTokenId() external view returns (uint256);
    function verifyCanMint(uint8 saleStageIndex, address claimer, bytes32[] calldata merkleProof) external view returns (bool);

    function mint(address recipient, uint32 quantity, bytes32[] calldata merkleProof) external;
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

import "../types/LazyMintMetadata.sol";

interface IEeseeNFTLazyMint {
    function contractURI() external view returns (string memory);
    function collectionID() external view returns (uint256);
    function owner() external view returns (address);
    function minter() external view returns (address);
    
    function initialize(
        uint256 _collectionID,
        address _owner,
        address _minter,
        LazyMintCollectionMetadata calldata metadata
    ) external;

    function mintSingle(address recipient, LazyMintTokenMetadata calldata metadata) external returns(uint256 tokenId);
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

import "../interfaces/IEeseeProxy.sol";

interface IEeseeProxy  {
    function callExternal(address to, bytes calldata data) external payable returns (bytes memory);
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

import "./IEeseeAccessManager.sol";
import "../types/Random.sol";

interface IEeseeRandom {
    event FulfillRandom(uint256 indexed random);
    event RequestRandom();

    function random(uint256) external view returns(uint256 word, uint256 timestamp);
    function lastRandomRequestTimestamp() external view returns(uint64);
    function randomRequestInterval() external view returns(uint32);
    function MAX_RANDOM_REQUEST_INTERVAL() external view returns(uint48);

    function getRandomFromTimestamp(uint256 _timestamp) external view returns (uint256 word, uint256 timestamp);
    function canRequestRandom() external view returns (bool randomNeeded);
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

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

interface IEeseeStaking {
    struct _TierData{
        uint256 volumeBreakpoint;
        uint64 rewardRateFlexible;
        uint64 rewardRateLocked;
    }

    /**
     * @dev TierData:
     * {volumeBreakpoint} - Max volume to apply rewardRateFlexible/rewardRateLocked for.
     * {rewardRate} - Reward per token per second. [10^18 = 1]
     */
    struct TierData{
        uint256 volumeBreakpoint;
        mapping(bool => uint64) rewardRate;
    }

    struct UserInfo{
        uint96 amount;
        uint96 reward;
        uint32 unlockTime;
        uint32 rewardID;
        uint256 rewardDebt;
    }

    error InvalidESE();
    error InvalidRecipient();
    error InvalidDuration();
    error InvalidTiersLength();
    error InsufficientStake();
    error CallerNotVolumeUpdater();
    error AlreadyGranted();
    error VolumeUpdaterNotGranted();
    error WithdrawalNotAvailable();
    error InvalidBreakpoint();
    error InvalidRewardRate();
    error InvalidRewardID();

    event DepositFlexible(address indexed user, uint96 amount);
    event DepositLocked(address indexed user, uint96 amount, uint32 unlockTime);
    
    event WithdrawFlexible(address indexed sender, address indexed recipient, uint96 amount);
    event WithdrawLocked(address indexed sender, address indexed recipient, uint96 amount);

    event AddVolume(address indexed volumeUpdater, address indexed user, uint96 amount);

    event UpdateRewardRates(uint64[] rewardRatesFlexible, uint64[] rewardRatesLocked);
    event ChangeDuration(uint32 indexed previousDuration, uint32 indexed newDuration);
    event GrantVolumeUpdater(address indexed account);
    event RevokeVolumeUpdater(address indexed account);

    function ESE() external view returns(IERC20);
    function volumeUpdaters(address) external view returns(bool);

    function volume(address) external view returns(uint256);
    function userInfo(bool isLocked, address user) external view returns(uint96 amount, uint96 reward, uint32 unlockTime, uint32 rewardRateID, uint256 rewardDebt);

    function totalDeposits() external view returns(uint96);
    function tierInfo(uint256 _tier) external view returns(_TierData memory);
    function duration() external view returns(uint32);

    function deposit(uint96 amount, uint32 lockDuration, uint32 currentRewardID, bytes calldata permit) external;
    function withdraw(bool isLocked, uint96 amount, address recipient) external returns (uint96 ESEReceived);
    function addVolume(uint96 delta, address _address) external;
    
    function pendingReward(bool isLocked, address _user) external view returns (uint96);
    function tier(uint256 _volume) external view returns (uint256);

    function updateRewardRates(uint64[] calldata rewardRatesFlexible, uint64[] calldata rewardRatesLocked) external;
    function changeDuration(uint32 _duration) external;
    function grantVolumeUpdater(address _address) external;
    function revokeVolumeUpdater(address _address) external;
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

/// @author: manifold.xyz

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

/**
 * @dev Lookup engine interface
 */
interface IRoyaltyEngineV1 is IERC165 {
    /**
     * Get the royalty for a given token (address, id) and value amount.  Does not cache the bps/amounts.  Caches the spec for a given token address
     *
     * @param tokenAddress - The address of the token
     * @param tokenId      - The id of the token
     * @param value        - The value you wish to get the royalty of
     *
     * returns Two arrays of equal length, royalty recipients and the corresponding amount each recipient should get
     */
    function getRoyalty(address tokenAddress, uint256 tokenId, uint256 value)
        external
        returns (address payable[] memory recipients, uint256[] memory amounts);

    /**
     * View only version of getRoyalty
     *
     * @param tokenAddress - The address of the token
     * @param tokenId      - The id of the token
     * @param value        - The value you wish to get the royalty of
     *
     * returns Two arrays of equal length, royalty recipients and the corresponding amount each recipient should get
     */
    function getRoyaltyView(address tokenAddress, uint256 tokenId, uint256 value)
        external
        view
        returns (address payable[] memory recipients, uint256[] memory amounts);
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "../interfaces/IEeseeMinter.sol";
import "../interfaces/IEesee.sol";
import "../types/Asset.sol";

library AssetTransfer { 
    using SafeERC20 for IERC20;

    ///@dev Lot typehash.
    bytes32 private constant LOT_TYPEHASH = keccak256("Lot(bytes32 assetHash,uint32 totalTickets,uint96 ticketPrice,uint32 duration,address owner,uint256 nonce,uint256 deadline)");

    error TransferNotSuccessful();
    error InvalidAsset();
    error InvalidAmount();
    error InvalidToken();
    error InvalidTokenID();
    error InvalidMsgValue();
    error InvalidInterface();
    error InvalidSignature();
    error ExpiredDeadline();
    error InvalidData();
    error InvalidLazyMintOwner();

    // ============ External Write Functions ============

    function transferAssetFrom(
        Asset calldata asset,
        IEesee.LotParams calldata params,
        uint256 availableValue,
        address msgSender,
        bytes32 domainSeparatorV4,
        IERC20 ESE
    ) external returns(address signer, uint256 nonce, uint256 valueLeft) {
        valueLeft = availableValue;
        if (asset.assetType == AssetType.ERC721) {
            if(asset.amount != 1) revert InvalidAmount();
            (bool success, bytes memory res) = asset.token.staticcall(abi.encodeWithSelector(IERC165.supportsInterface.selector, type(IERC721).interfaceId));
            if(!success || abi.decode(res, (bool)) == false) revert InvalidInterface();

            IERC721(asset.token).safeTransferFrom(params.signer, address(this), asset.tokenID);
        } else if (asset.assetType == AssetType.ERC1155) {
            if(asset.amount == 0) revert InvalidAmount();
            (bool success, bytes memory res) = asset.token.staticcall(abi.encodeWithSelector(IERC165.supportsInterface.selector, type(IERC1155).interfaceId));
            if(!success || abi.decode(res, (bool)) == false) revert InvalidInterface();

            IERC1155(asset.token).safeTransferFrom(params.signer, address(this), asset.tokenID, asset.amount, "");
        } else if (asset.assetType == AssetType.ERC20) {
            if(asset.amount == 0) revert InvalidAmount();
            // Most ERC-20 tokens do not implement supportsInterface, so we check against IERC721 to ensure we are not calling ERC721 contract.
            // ERC1155 will revert anyway because of different safeTransferFrom scheme.
            (bool success, bytes memory res) = asset.token.staticcall(abi.encodeWithSelector(IERC165.supportsInterface.selector, type(IERC721).interfaceId));
            if(success && abi.decode(res, (bool)) == true) revert InvalidInterface();
            if(asset.tokenID != 0) revert InvalidTokenID();
            if(asset.data.length != 0) revert InvalidData();

            IERC20(asset.token).safeTransferFrom(params.signer, address(this), asset.amount);
        } else if (asset.assetType == AssetType.Native) {
            if(asset.amount == 0) revert InvalidAmount();
            if(availableValue < asset.amount) revert InvalidMsgValue();
            if(asset.token != address(0)) revert InvalidToken();
            if(asset.tokenID != 0) revert InvalidTokenID();
            if(asset.data.length != 0) revert InvalidData();
            unchecked{ valueLeft -= asset.amount; }
        } else if (asset.assetType == AssetType.ESE) {
            if(asset.amount != params.totalTickets * params.ticketPrice) revert InvalidAmount();
            if(asset.token != address(ESE)) revert InvalidToken();
            if(asset.tokenID != 0) revert InvalidTokenID();
            if(asset.data.length != 0) revert InvalidData();
        } else if(asset.assetType == AssetType.ERC721LazyMint){
            if(asset.amount != 1) revert InvalidAmount();
            if(asset.token != address(0)) revert InvalidToken();
            if(asset.tokenID != 0) revert InvalidTokenID();

            (,address owner,,) = abi.decode(asset.data, (uint256, address, LazyMintCollectionMetadata, LazyMintTokenMetadata));
            if(owner != params.signer) revert InvalidLazyMintOwner();
        } else revert InvalidAsset();
        
        (signer, nonce) = _checkLotSignature(asset, params, msgSender, domainSeparatorV4);
    }

    // Note: _transferAssetFrom has all sanity checks and is always called before _transferAssetTo, so we don't need to put any sanity checks here.
    function transferAssetTo(
        Asset memory asset,
        address to,
        IEeseeMinter minter
    ) external returns (Asset memory){
        if (asset.assetType == AssetType.ERC721) {
            IERC721(asset.token).safeTransferFrom(address(this), to, asset.tokenID, asset.data);
            asset.data = "";
            return asset;
        } 
        if (asset.assetType == AssetType.ERC1155) {
            IERC1155(asset.token).safeTransferFrom(address(this), to, asset.tokenID, asset.amount, asset.data);
            asset.data = "";
            return asset;
        }
        if (asset.assetType == AssetType.ERC20) {
            IERC20(asset.token).safeTransfer(to, asset.amount);
            return asset;
        }
        if (asset.assetType == AssetType.Native) {
            (bool success,) = to.call{value: asset.amount}("");
            if(!success) revert TransferNotSuccessful(); 
            return asset;
        }
        if(asset.assetType == AssetType.ERC721LazyMint) {
            (
                uint256 collectionID, 
                address owner,
                LazyMintCollectionMetadata memory collectionMetadata,
                LazyMintTokenMetadata memory tokenMetadata
            ) = abi.decode(asset.data, (uint256, address, LazyMintCollectionMetadata, LazyMintTokenMetadata));
            (IERC721 collection, uint256 tokenID) = minter.lazyMint(collectionID, owner, collectionMetadata, tokenMetadata, to);
            
            return Asset({
                token: address(collection),
                tokenID: tokenID,
                amount: 1,
                assetType: AssetType.ERC721,
                data: ""
            });
        }
        revert InvalidAsset();
    }

    // ============ Internal View Functions ============

    function _checkLotSignature(
        Asset calldata asset, 
        IEesee.LotParams calldata params, 
        address msgSender, 
        bytes32 domainSeparatorV4
    ) internal view returns(address signer, uint256 nonce){
        signer = params.signer;
        if(signer == msgSender){
            return (signer, 0);
        }
        (uint256 _nonce, uint256 deadline, bytes memory signature) = abi.decode(params.signatureData,(uint256,uint256,bytes));
        if(block.timestamp > deadline) revert ExpiredDeadline();
        
        nonce = _nonce;
        bytes32 structHash = keccak256(abi.encode(
            LOT_TYPEHASH, 
            keccak256(abi.encode(asset)),

            params.totalTickets,
            params.ticketPrice,
            params.duration,
            params.owner,

            nonce,
            deadline
        ));
        if(!SignatureChecker.isValidSignatureNow(signer, ECDSA.toTypedDataHash(domainSeparatorV4, structHash), signature)) revert InvalidSignature();
    }
}

File 43 of 46 : Asset.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

enum AssetType {
    ERC721,
    ERC1155,
    ERC20,
    Native,
    ESE,
    ERC721LazyMint
}
/**
 * @dev Asset:
 * {token} - Token contract address.
 * {tokenID} - Token ID. 
 * {amount} - Amount of tokens transfered. 
 * {assetType} - Asset interface type. 
 * {data} - Additional data included with the asset. 
 */
struct Asset {
    address token;
    uint256 tokenID;
    uint256 amount;
    AssetType assetType;
    bytes data;
}

File 44 of 46 : DropMetadata.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

struct DropMetadata {
    string name;
    string symbol;
    string baseURI;
    string revealedURI;
    string contractURI;
    address royaltyReceiver;
    uint96 royaltyFeeNumerator;
}

File 45 of 46 : LazyMintMetadata.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

struct LazyMintCollectionMetadata {
    string name;
    string symbol;
    string contractURI;
}

struct LazyMintTokenMetadata {
    string URI;
    address royaltyReceiver;
    uint96 royaltyFeeNumerator;
}

File 46 of 46 : Random.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.21;

struct Random{
    uint256 word;
    uint256 timestamp;
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 2500
  },
  "evmVersion": "shanghai",
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {
    "contracts/libraries/AssetTransfer.sol": {
      "AssetTransfer": "0x26015b335ec532b32ac6436704210d677ef35429"
    }
  }
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"contract IERC20","name":"_ESE","type":"address"},{"internalType":"contract IEeseeStaking","name":"_staking","type":"address"},{"internalType":"contract IEeseeProxy","name":"_proxy","type":"address"},{"internalType":"contract IEeseeMinter","name":"_minter","type":"address"},{"internalType":"contract IEeseeRandom","name":"_random","type":"address"},{"internalType":"address","name":"_feeSplitter","type":"address"},{"internalType":"contract IRoyaltyEngineV1","name":"_royaltyEngine","type":"address"},{"internalType":"contract IEeseeAccessManager","name":"_accessManager","type":"address"},{"internalType":"contract IBlastPoints","name":"_blastPoints","type":"address"},{"internalType":"address","name":"_blastPointsOperator","type":"address"},{"internalType":"address","name":"trustedForwarder","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"}],"name":"AssetAlreadyClaimed","type":"error"},{"inputs":[],"name":"BuyAmountTooLow","type":"error"},{"inputs":[],"name":"BuyLimitExceeded","type":"error"},{"inputs":[],"name":"CallerNotAuthorized","type":"error"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"}],"name":"CallerNotOwner","type":"error"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"}],"name":"CallerNotWinner","type":"error"},{"inputs":[{"internalType":"uint64","name":"maxDuration","type":"uint64"}],"name":"DurationTooHigh","type":"error"},{"inputs":[{"internalType":"uint64","name":"minDuration","type":"uint64"}],"name":"DurationTooLow","type":"error"},{"inputs":[],"name":"ESEOverflow","type":"error"},{"inputs":[],"name":"ExpiredDeadline","type":"error"},{"inputs":[],"name":"FeeTooHigh","type":"error"},{"inputs":[],"name":"InvalidAccessManager","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidArrayLengths","type":"error"},{"inputs":[],"name":"InvalidAsset","type":"error"},{"inputs":[],"name":"InvalidConstructor","type":"error"},{"inputs":[],"name":"InvalidData","type":"error"},{"inputs":[],"name":"InvalidDuration","type":"error"},{"inputs":[],"name":"InvalidFee","type":"error"},{"inputs":[],"name":"InvalidFeeSplitter","type":"error"},{"inputs":[],"name":"InvalidInterface","type":"error"},{"inputs":[],"name":"InvalidLazyMintOwner","type":"error"},{"inputs":[],"name":"InvalidLotID","type":"error"},{"inputs":[],"name":"InvalidMsgValue","type":"error"},{"inputs":[],"name":"InvalidOwner","type":"error"},{"inputs":[],"name":"InvalidPointsOperator","type":"error"},{"inputs":[],"name":"InvalidRecipient","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"InvalidToken","type":"error"},{"inputs":[],"name":"InvalidTokenID","type":"error"},{"inputs":[],"name":"InvalidValueCall","type":"error"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"}],"name":"LotAlreadyFulfilled","type":"error"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"}],"name":"LotExpired","type":"error"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"}],"name":"LotNotClosed","type":"error"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"}],"name":"LotNotExists","type":"error"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"}],"name":"LotNotExpired","type":"error"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"}],"name":"LotNotFulfilled","type":"error"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"}],"name":"NoTicketsBought","type":"error"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"}],"name":"NoTicketsHeld","type":"error"},{"inputs":[],"name":"NonceUsed","type":"error"},{"inputs":[],"name":"ReentrantCall","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"inputs":[],"name":"TicketPriceTooLow","type":"error"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"}],"name":"TokensAlreadyClaimed","type":"error"},{"inputs":[],"name":"TotalTicketsTooHigh","type":"error"},{"inputs":[],"name":"TotalTicketsTooLow","type":"error"},{"inputs":[],"name":"TransferNotSuccessful","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint96","name":"untrackedVolume","type":"uint96"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"}],"name":"AddVolumeReverted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"ID","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":true,"internalType":"uint32","name":"lowerBound","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"ticketAmount","type":"uint32"},{"indexed":false,"internalType":"uint96","name":"tokensSpent","type":"uint96"},{"indexed":false,"internalType":"uint32","name":"bonusTickets","type":"uint32"}],"name":"BuyTickets","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"previousFee","type":"uint32"},{"indexed":true,"internalType":"uint32","name":"newFee","type":"uint32"}],"name":"ChangeFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousFeeSplitter","type":"address"},{"indexed":true,"internalType":"address","name":"newFeeSplitter","type":"address"}],"name":"ChangeFeeSplitter","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"previousMaxDuration","type":"uint64"},{"indexed":true,"internalType":"uint64","name":"newMaxDuration","type":"uint64"}],"name":"ChangeMaxDuration","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"previousMinDuration","type":"uint64"},{"indexed":true,"internalType":"uint64","name":"newMinDuration","type":"uint64"}],"name":"ChangeMinDuration","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint96","name":"amount","type":"uint96"}],"name":"CollectFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint96","name":"amount","type":"uint96"}],"name":"CollectRoyalty","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"ID","type":"uint256"},{"indexed":true,"internalType":"address","name":"signer","type":"address"},{"indexed":true,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"ConsumeNonce","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"ID","type":"uint256"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenID","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"enum AssetType","name":"assetType","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct Asset","name":"asset","type":"tuple"},{"indexed":true,"internalType":"address","name":"signer","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint32","name":"totalTickets","type":"uint32"},{"indexed":false,"internalType":"uint96","name":"ticketPrice","type":"uint96"},{"indexed":false,"internalType":"uint32","name":"endTimestamp","type":"uint32"}],"name":"CreateLot","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"ID","type":"uint256"},{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenID","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"enum AssetType","name":"assetType","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct Asset","name":"asset","type":"tuple"}],"name":"ReceiveAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"ID","type":"uint256"},{"indexed":true,"internalType":"address","name":"claimer","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint96","name":"amount","type":"uint96"}],"name":"ReceiveTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"ID","type":"uint256"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenID","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"enum AssetType","name":"assetType","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct Asset","name":"asset","type":"tuple"}],"name":"ReclaimAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"ID","type":"uint256"},{"indexed":true,"internalType":"address","name":"claimer","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint96","name":"amount","type":"uint96"}],"name":"ReclaimTokens","type":"event"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ESE","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RETURN_INTERVAL","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accessManager","outputs":[{"internalType":"contract IEeseeAccessManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"IDs","type":"uint256[]"},{"internalType":"uint32[]","name":"amounts","type":"uint32[]"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bytes","name":"permit","type":"bytes"}],"name":"buyTickets","outputs":[{"internalType":"uint96","name":"tokensSpent","type":"uint96"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"callExternal","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_fee","type":"uint32"}],"name":"changeFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeSplitter","type":"address"}],"name":"changeFeeSplitter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"_maxDuration","type":"uint64"}],"name":"changeMaxDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"_minDuration","type":"uint64"}],"name":"changeMinDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenID","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"enum AssetType","name":"assetType","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct Asset[]","name":"assets","type":"tuple[]"},{"components":[{"internalType":"uint32","name":"totalTickets","type":"uint32"},{"internalType":"uint96","name":"ticketPrice","type":"uint96"},{"internalType":"uint32","name":"duration","type":"uint32"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"signer","type":"address"},{"internalType":"bytes","name":"signatureData","type":"bytes"}],"internalType":"struct IEesee.LotParams[]","name":"params","type":"tuple[]"},{"internalType":"uint32","name":"expectedFee","type":"uint32"}],"name":"createLots","outputs":[{"internalType":"uint256[]","name":"IDs","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenID","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"enum AssetType","name":"assetType","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct Asset[]","name":"assets","type":"tuple[]"},{"components":[{"internalType":"uint32","name":"totalTickets","type":"uint32"},{"internalType":"uint96","name":"ticketPrice","type":"uint96"},{"internalType":"uint32","name":"duration","type":"uint32"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"signer","type":"address"},{"internalType":"bytes","name":"signatureData","type":"bytes"}],"internalType":"struct IEesee.LotParams[]","name":"params","type":"tuple[]"},{"internalType":"uint32","name":"expectedFee","type":"uint32"},{"internalType":"uint32[]","name":"amounts","type":"uint32[]"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bytes","name":"permit","type":"bytes"}],"name":"createLotsAndBuyTickets","outputs":[{"internalType":"uint256[]","name":"IDs","type":"uint256[]"},{"internalType":"uint96","name":"tokensSpent","type":"uint96"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fee","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeSplitter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"},{"internalType":"uint32","name":"transaction","type":"uint32"}],"name":"getBuyTicketsRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"},{"internalType":"address","name":"_address","type":"address"}],"name":"getLotBonusTicketsHeldByAddress","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"},{"internalType":"uint32","name":"ticket","type":"uint32"}],"name":"getLotTicketHolder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ID","type":"uint256"},{"internalType":"address","name":"_address","type":"address"}],"name":"getLotTicketsHeldByAddress","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLotsLength","outputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"lots","outputs":[{"internalType":"uint32","name":"totalTickets","type":"uint32"},{"internalType":"uint32","name":"bonusTickets","type":"uint32"},{"internalType":"uint32","name":"ticketsBought","type":"uint32"},{"internalType":"uint96","name":"ticketPrice","type":"uint96"},{"internalType":"uint32","name":"transactions","type":"uint32"},{"internalType":"uint32","name":"endTimestamp","type":"uint32"},{"internalType":"uint32","name":"fee","type":"uint32"},{"internalType":"bool","name":"closed","type":"bool"},{"internalType":"bool","name":"buyout","type":"bool"},{"internalType":"bool","name":"assetClaimed","type":"bool"},{"internalType":"bool","name":"tokensClaimed","type":"bool"},{"internalType":"address","name":"owner","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenID","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"enum AssetType","name":"assetType","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct Asset","name":"asset","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxDuration","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minDuration","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"nonceUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"random","outputs":[{"internalType":"contract IEeseeRandom","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"IDs","type":"uint256[]"},{"internalType":"address","name":"recipient","type":"address"}],"name":"receiveAssets","outputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenID","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"enum AssetType","name":"assetType","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct Asset[]","name":"assets","type":"tuple[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"IDs","type":"uint256[]"},{"internalType":"address","name":"recipient","type":"address"}],"name":"receiveTokens","outputs":[{"internalType":"uint96","name":"amount","type":"uint96"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"IDs","type":"uint256[]"},{"internalType":"address","name":"recipient","type":"address"}],"name":"reclaimAssets","outputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenID","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"enum AssetType","name":"assetType","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct Asset[]","name":"assets","type":"tuple[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"IDs","type":"uint256[]"},{"internalType":"address","name":"recipient","type":"address"}],"name":"reclaimTokens","outputs":[{"internalType":"uint96","name":"amount","type":"uint96"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"staking","outputs":[{"internalType":"contract IEeseeStaking","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

0x610280604052600680546001600160a01b0319167102580000000000278d00000000000001518017905534801562000035575f80fd5b50604051620065123803806200651283398101604081905262000058916200043b565b6040805180820182526005815264456573656560d81b602080830191909152825180840190935260018352603160f81b908301526001600160a01b038316608052859185918591620000ab825f6200038e565b61014052620000bc8160016200038e565b61016052815160208084019190912061010052815190820120610120524660c0526200014b6101005161012051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b60a05250503060e05260016002556001600160a01b03821615620001ef576001600160a01b0381166200019157604051634390189560e01b815260040160405180910390fd5b6040516336b91f2b60e01b81526001600160a01b0382811660048301528316906336b91f2b906024015f604051808303815f87803b158015620001d2575f80fd5b505af1158015620001e5573d5f803e3d5ffd5b5050505062000218565b6001600160a01b038116156200021857604051634390189560e01b815260040160405180910390fd5b50506001600160a01b03811662000242576040516354c0aa7160e11b815260040160405180910390fd5b6001600160a01b031661018081905260408051631d6c8e3f60e21b815290516375b238fc916004808201926020929091908290030181865afa1580156200028b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620002b1919062000531565b6101a0526001600160a01b038b161580620002d357506001600160a01b038916155b80620002e657506001600160a01b038816155b80620002f957506001600160a01b038716155b806200030c57506001600160a01b038616155b806200031f57506001600160a01b038516155b156200033e576040516312c1701b60e01b815260040160405180910390fd5b505050506001600160a01b039687166101c0529486166101e0529285166102005290841661022052831661024052600480546001600160a01b031916918416919091179055166102605262000722565b5f602083511015620003ad57620003a583620003c6565b9050620003c0565b81620003ba8482620005e9565b5060ff90505b92915050565b5f80829050601f81511115620003fc578260405163305a27a960e01b8152600401620003f39190620006b1565b60405180910390fd5b80516200040982620006fe565b179392505050565b6001600160a01b038116811462000426575f80fd5b50565b8051620004368162000411565b919050565b5f805f805f805f805f805f6101608c8e03121562000457575f80fd5b8b51620004648162000411565b60208d0151909b50620004778162000411565b60408d0151909a506200048a8162000411565b60608d01519099506200049d8162000411565b60808d0151909850620004b08162000411565b60a08d0151909750620004c38162000411565b60c08d0151909650620004d68162000411565b60e08d0151909550620004e98162000411565b6101008d0151909450620004fd8162000411565b92506200050e6101208d0162000429565b91506200051f6101408d0162000429565b90509295989b509295989b9093969950565b5f6020828403121562000542575f80fd5b5051919050565b634e487b7160e01b5f52604160045260245ffd5b600181811c908216806200057257607f821691505b6020821081036200059157634e487b7160e01b5f52602260045260245ffd5b50919050565b601f821115620005e4575f81815260208120601f850160051c81016020861015620005bf5750805b601f850160051c820191505b81811015620005e057828155600101620005cb565b5050505b505050565b81516001600160401b0381111562000605576200060562000549565b6200061d816200061684546200055d565b8462000597565b602080601f83116001811462000653575f84156200063b5750858301515b5f19600386901b1c1916600185901b178555620005e0565b5f85815260208120601f198616915b82811015620006835788860151825594840194600190910190840162000662565b5085821015620006a157878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b5f6020808352835180828501525f5b81811015620006de57858101830151858201604001528201620006c0565b505f604082860101526040601f19601f8301168501019250505092915050565b8051602080830151919081101562000591575f1960209190910360031b1b16919050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051615cc66200084c5f395f61403b01525f818161043f015281816134d401526137ff01525f81816115930152611cd101525f61103101525f818161035c01528181610ac60152610b3a01525f818161054f01528181610a2701528181610a9301528181610fbd015281816122000152818161293c015281816129c2015261417d01525f818161050e0152818161169d015281816129f701528181612acb0152612dfc01525f818161080f01526144ca01525f6117d701525f6117ad01525f613aa601525f613a7e01525f6139d901525f613a0301525f613a2d01525f81816103fe015261433f0152615cc65ff3fe608060405260043610610243575f3560e01c806384b0196e11610131578063bc197c81116100ac578063eecd5b9c1161007c578063f23a6e6111610062578063f23a6e611461079b578063f80db741146107df578063fdcb6068146107fe575f80fd5b8063eecd5b9c14610744578063f1648e8414610763575f80fd5b8063bc197c8114610692578063d00c8c77146106d6578063d798bd8c146106f5578063ddca3f4314610714575f80fd5b8063a469d3e611610101578063ad364d25116100e7578063ad364d2514610640578063ba7b8f1314610660578063bb8bd72514610673575f80fd5b8063a469d3e6146105ff578063ac9650d814610620575f80fd5b806384b0196e14610592578063870fb262146105b95780638a5e3ea0146105cc5780639796a67d146105eb575f80fd5b80635ec01e4d116101c15780636eaccadb1161019157806375b238fc1161017757806375b238fc146104fd578063764bd0c51461053e5780638142dd5314610571575f80fd5b80636eaccadb146104c7578063727c2e96146104dd575f80fd5b80635ec01e4d1461042e5780636052970c1461046157806364629f2c146104805780636db5c8fd146104a0575f80fd5b806334fb48801161021657806356715761116101fc578063567157611461039657806356b53e2b146103cf578063572b6c05146103e2575f80fd5b806334fb4880146103175780634cf088d91461034b575f80fd5b806301ffc9a714610247578063127b3be51461027b578063150b7a02146102a65780631647795e146102de575b5f80fd5b348015610252575f80fd5b50610266610261366004614795565b610831565b60405190151581526020015b60405180910390f35b61028e61028936600461495a565b610899565b6040516001600160601b039091168152602001610272565b3480156102b1575f80fd5b506102c56102c0366004614a70565b610be4565b6040516001600160e01b03199091168152602001610272565b3480156102e9575f80fd5b506102666102f8366004614ad8565b600560209081525f928352604080842090915290825290205460ff1681565b348015610322575f80fd5b50610336610331366004614b02565b610c0e565b60405163ffffffff9091168152602001610272565b348015610356575f80fd5b5061037e7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610272565b3480156103a1575f80fd5b506006546103b69067ffffffffffffffff1681565b60405167ffffffffffffffff9091168152602001610272565b61028e6103dd366004614b30565b610c58565b3480156103ed575f80fd5b506102666103fc366004614b83565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b348015610439575f80fd5b5061037e7f000000000000000000000000000000000000000000000000000000000000000081565b34801561046c575f80fd5b5060045461037e906001600160a01b031681565b61049361048e366004614b9e565b610ff6565b6040516102729190614c3c565b3480156104ab575f80fd5b506006546103b690600160401b900467ffffffffffffffff1681565b3480156104d2575f80fd5b506103366201518081565b6104f06104eb366004614b30565b6110af565b6040516102729190614cd0565b348015610508575f80fd5b506105307f000000000000000000000000000000000000000000000000000000000000000081565b604051908152602001610272565b348015610549575f80fd5b5061037e7f000000000000000000000000000000000000000000000000000000000000000081565b34801561057c575f80fd5b5061059061058b366004614d43565b611698565b005b34801561059d575f80fd5b506105a66117a0565b6040516102729796959493929190614d95565b6104f06105c7366004614b30565b611842565b3480156105d7575f80fd5b5061037e6105e6366004614e1e565b611dcb565b3480156105f6575f80fd5b50600354610530565b61061261060d366004614e48565b611e15565b604051610272929190614f2c565b61063361062e366004614f56565b611e46565b6040516102729190614f95565b61065361064e366004614fe8565b612092565b6040516102729190615063565b61028e61066e366004614b30565b612405565b34801561067e575f80fd5b5061059061068d366004614b83565b6129f2565b34801561069d575f80fd5b506102c56106ac366004615075565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e1575f80fd5b506105906106f036600461511c565b612ac6565b348015610700575f80fd5b5061033661070f366004614b02565b612bb7565b34801561071f575f80fd5b5060065461033690700100000000000000000000000000000000900463ffffffff1681565b34801561074f575f80fd5b5061037e61075e366004614e1e565b612c01565b34801561076e575f80fd5b5061078261077d366004615143565b612c31565b6040516102729d9c9b9a9998979695949392919061515a565b3480156107a6575f80fd5b506102c56107b5366004615200565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156107ea575f80fd5b506105906107f936600461511c565b612df7565b348015610809575f80fd5b5061037e7f000000000000000000000000000000000000000000000000000000000000000081565b5f6001600160e01b031982167f4e2312e000000000000000000000000000000000000000000000000000000000148061089357507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b92915050565b5f34158015906108ab57506001600254145b156108c957604051631841b4e160e01b815260040160405180910390fd5b836001600160a01b0381166108f157604051634e46966960e11b815260040160405180910390fd5b8751861461092b576040517fa9854bc900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5b88518110156109945761098089828151811061094b5761094b615264565b602002602001015189898481811061096557610965615264565b905060200201602081019061097a9190614d43565b88612eef565b61098a908461528c565b925060010161092d565b505f61099e6133b3565b90508315610a86575f808080806109b7898b018b6152ac565b6040517fd505accf0000000000000000000000000000000000000000000000000000000081526001600160a01b038c81166004830152306024830152604482018790526064820186905260ff8516608483015260a4820184905260c48201839052959a50939850919650945092507f00000000000000000000000000000000000000000000000000000000000000009091169063d505accf9060e4015f604051808303815f87803b158015610a6a575f80fd5b505af1158015610a7c573d5f803e3d5ffd5b5050505050505050505b610ac46001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001682306001600160601b0387166133c1565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031615610bd8576040517f3f50adf10000000000000000000000000000000000000000000000000000000081526001600160601b03841660048201526001600160a01b0387811660248301527f00000000000000000000000000000000000000000000000000000000000000001690633f50adf1906044015f604051808303815f87803b158015610b7b575f80fd5b505af1925050508015610b8c575060015b610bd8576040516001600160601b03841681526001600160a01b038716907fb88061c54967fd5e9babc5708c54ec3d2e4a358223a5e32fb7d4cba2f20e39579060200160405180910390a25b50509695505050505050565b7f150b7a02000000000000000000000000000000000000000000000000000000005b949350505050565b5f60038381548110610c2257610c22615264565b5f91825260208083206001600160a01b0386168452600a600b90930201919091019052604090205463ffffffff16905092915050565b5f3415801590610c6a57506001600254145b15610c8857604051631841b4e160e01b815260040160405180910390fd5b816001600160a01b038116610cb057604051634e46966960e11b815260040160405180910390fd5b5f610cb96133b3565b90505f5b85811015610faf575f878783818110610cd857610cd8615264565b905060200201359050610cea81613460565b5f60038281548110610cfe57610cfe615264565b5f91825260208220600b9091020180549092506001600160601b036c010000000000000000000000009091041690819003610d545760405163c87c164160e01b8152600481018490526024015b60405180910390fd5b6001600160a01b0385165f90815260098301602052604081205463ffffffff1690819003610db1576040517fae267ff000000000000000000000000000000000000000000000000000000000815260048101859052602401610d4b565b600183015465010000000000900460ff1615610dfc576040517fcc1bf05800000000000000000000000000000000000000000000000000000000815260048101859052602401610d4b565b8254610e16908590600160e01b900463ffffffff1661349e565b82547fffffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffff811663ffffffff600160401b92839004811684900381169092021784556001600160a01b038781165f818152600987016020908152604091829020805463ffffffff1916905590516001600160601b03948616870294851681529b84019b60019990990198928d169288917f5f0d5e01c94f6e597b35974549cefd32ab7f862eea9e90e19105e4b9b15c6f8a910160405180910390a4508254600160401b900463ffffffff16158015610f1c575060018301546601000000000000900460ff1680610f1c5750600460058085015460ff1690811115610f1a57610f1a614c4e565b145b15610fa65760038481548110610f3457610f34615264565b5f91825260208220600b909102018181556001810180546001600160e01b031916905560028101805473ffffffffffffffffffffffffffffffffffffffff19168155600382018390556004820183905560058201805460ff1916905590919081610fa1600685018261474b565b505050505b50505050610cbd565b50610fed6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016856001600160601b0386166135e1565b50509392505050565b60606110015f61362a565b6040517f64629f2c0000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906364629f2c90349061106c9088908890889060040161531f565b5f6040518083038185885af1158015611087573d5f803e3d5ffd5b50505050506040513d5f823e601f3d908101601f19168201604052610c06919081019061538c565b606034158015906110c257506001600254145b156110e057604051631841b4e160e01b815260040160405180910390fd5b816001600160a01b03811661110857604051634e46966960e11b815260040160405180910390fd5b8367ffffffffffffffff811115611121576111216147bc565b60405190808252806020026020018201604052801561118357816020015b6111706040805160a0810182525f808252602082018190529181018290529060608201908152602001606081525090565b81526020019060019003908161113f5790505b5091505f61118f6133b3565b90505f5b8581101561168e575f8787838181106111ae576111ae615264565b9050602002013590506111c081613460565b5f600382815481106111d4576111d4615264565b5f9182526020909120600b909102016001810154909150600160401b90046001600160a01b03168061121c5760405163c87c164160e01b815260048101849052602401610d4b565b806001600160a01b0316856001600160a01b03161461126a576040517fc9cd77cf00000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b600182015465010000000000900460ff16156112b5576040517fcc1bf05800000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b60018201546601000000000000900460ff1615611301576040517fd181585f00000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b81546001830154600160e01b90910463ffffffff1690640100000000900460ff161561133657611331848261349e565b611378565b8063ffffffff164211611378576040517f128471ac00000000000000000000000000000000000000000000000000000000815260048101859052602401610d4b565b6040805160a0810182526002850180546001600160a01b03168252600386015460208301526004860154928201929092526005808601545f9391606084019160ff16908111156113ca576113ca614c4e565b60058111156113db576113db614c4e565b81526020016004820180546113ef906153be565b80601f016020809104026020016040519081016040528092919081815260200182805461141b906153be565b80156114665780601f1061143d57610100808354040283529160200191611466565b820191905f5260205f20905b81548152906001019060200180831161144957829003601f168201915b505050919092525050506001850154909150670100000000000000900460ff168061149d57508354600160401b900463ffffffff16155b1561152b57600385815481106114b5576114b5615264565b5f91825260208220600b909102018181556001810180546001600160e01b031916905560028101805473ffffffffffffffffffffffffffffffffffffffff19168155600382018390556004820183905560058201805460ff1916905590919081611522600685018261474b565b50505050611547565b60018401805466ff000000000000191666010000000000001790555b6040517fdbe6079f0000000000000000000000000000000000000000000000000000000081527326015b335ec532b32ac6436704210d677ef354299063dbe6079f906115bb9084908e907f0000000000000000000000000000000000000000000000000000000000000000906004016153f6565b5f60405180830381865af41580156115d5573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526115fc9190810190615434565b89878151811061160e5761160e615264565b6020026020010181905250896001600160a01b0316876001600160a01b0316867f12650d05f405bb47df1fbc670929e68d0b595cc452e0ed396c0dff2382ddd8b58c8a8151811061166157611661615264565b602002602001015160405161167691906154d8565b60405180910390a48560010195505050505050611193565b5050509392505050565b6116c97f00000000000000000000000000000000000000000000000000000000000000006116c46133b3565b6136d6565b6113888163ffffffff16111561170b576040517fcd4e616700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60065460405163ffffffff80841692700100000000000000000000000000000000900416907fe50fb4e9ec0119d495079e81085516243df607978f5087d4d1d0d15107e323df905f90a36006805463ffffffff909216700100000000000000000000000000000000027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff909216919091179055565b5f606080828080836117d27f000000000000000000000000000000000000000000000000000000000000000083613716565b6117fd7f00000000000000000000000000000000000000000000000000000000000000006001613716565b604080515f808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b6060341580159061185557506001600254145b1561187357604051631841b4e160e01b815260040160405180910390fd5b816001600160a01b03811661189b57604051634e46966960e11b815260040160405180910390fd5b8367ffffffffffffffff8111156118b4576118b46147bc565b60405190808252806020026020018201604052801561191657816020015b6119036040805160a0810182525f808252602082018190529181018290529060608201908152602001606081525090565b8152602001906001900390816118d25790505b5091505f6119226133b3565b90505f5b8581101561168e575f87878381811061194157611941615264565b90506020020135905061195381613460565b5f6003828154811061196757611967615264565b5f91825260208220600b90910201805490925063ffffffff600160e01b90910416908190036119ac5760405163c87c164160e01b815260048101849052602401610d4b565b6001820154640100000000900460ff166119f5576040517f3fae947600000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b600182015465010000000000900460ff1615611a67575f8080526008830160205260409020546001600160a01b03868116911614611a62576040517f1d12a9fe00000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b611a81565b5f611a7284836137bf565b9050611a7f8482886138f0565b505b60018201546601000000000000900460ff1615611acd576040517fd181585f00000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b6040805160a0810182526002840180546001600160a01b03168252600385015460208301526004850154928201929092526005808501545f9391606084019160ff1690811115611b1f57611b1f614c4e565b6005811115611b3057611b30614c4e565b8152602001600482018054611b44906153be565b80601f0160208091040260200160405190810160405280929190818152602001828054611b70906153be565b8015611bbb5780601f10611b9257610100808354040283529160200191611bbb565b820191905f5260205f20905b815481529060010190602001808311611b9e57829003601f168201915b505050919092525050506001840154909150670100000000000000900460ff1615611c695760038481548110611bf357611bf3615264565b5f91825260208220600b909102018181556001810180546001600160e01b031916905560028101805473ffffffffffffffffffffffffffffffffffffffff19168155600382018390556004820183905560058201805460ff1916905590919081611c60600685018261474b565b50505050611c85565b60018301805466ff000000000000191666010000000000001790555b6040517fdbe6079f0000000000000000000000000000000000000000000000000000000081527326015b335ec532b32ac6436704210d677ef354299063dbe6079f90611cf99084908d907f0000000000000000000000000000000000000000000000000000000000000000906004016153f6565b5f60405180830381865af4158015611d13573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052611d3a9190810190615434565b888681518110611d4c57611d4c615264565b6020026020010181905250886001600160a01b0316866001600160a01b0316857f02f768edc2c81c64ab82d5a40a06c32639e178bb3de87f04202451161e2162688b8981518110611d9f57611d9f615264565b6020026020010151604051611db491906154d8565b60405180910390a484600101945050505050611926565b5f60038381548110611ddf57611ddf615264565b5f918252602080832063ffffffff861684526008600b9093020191909101905260409020546001600160a01b0316905092915050565b60605f611e258c8c8c8c8c612092565b9150611e35828888888888610899565b90509a509a98505050505050505050565b60603415611e8f57600160025414611e8a576040517f37ed32e800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600280555b5f611e986133b3565b6001600160a01b0316336001600160a01b031614611f01575f36611ebd6014826154ea565b611ec89282906154fd565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250611f1092505050565b604080515f8152602081019091525b90508267ffffffffffffffff811115611f2b57611f2b6147bc565b604051908082528060200260200182016040528015611f5e57816020015b6060815260200190600190039081611f495790505b5091505f5b83811015612042575f8030878785818110611f8057611f80615264565b9050602002810190611f929190615524565b86604051602001611fa593929190615567565b60408051601f1981840301815290829052611fbf9161558c565b5f60405180830381855af49150503d805f8114611ff7576040519150601f19603f3d011682016040523d82523d5f602084013e611ffc565b606091505b50915091508161201a5780515f03612012575f80fd5b805181602001fd5b8085848151811061202d5761202d615264565b60209081029190910101525050600101611f63565b50341561208b57600360025414612085576040517fd5bcee7e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60016002555b5092915050565b60065460609063ffffffff83811670010000000000000000000000000000000090920416146120ed576040517f58d620b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b848314612126576040517fa9854bc900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8467ffffffffffffffff81111561213f5761213f6147bc565b604051908082528060200260200182016040528015612168578160200160208202803683370190505b509050345f6121756133b3565b90505f6121806139cd565b90505f5b888110156123ef575f808b8b848181106121a0576121a0615264565b90506020028101906121b291906155a7565b6121bb906155d9565b7326015b335ec532b32ac6436704210d677ef35429637bbdd17290918c8c878181106121e9576121e9615264565b90506020028101906121fb9190615658565b8989897f00000000000000000000000000000000000000000000000000000000000000006040518763ffffffff1660e01b8152600401612240969594939291906156e2565b606060405180830381865af415801561225b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061227f91906157cf565b975090925090506122d88c8c8581811061229b5761229b615264565b90506020028101906122ad91906155a7565b8b8b868181106122bf576122bf615264565b90506020028101906122d19190615658565b8a85613af6565b8784815181106122ea576122ea615264565b602002602001018181525050816001600160a01b0316856001600160a01b0316146123e5576001600160a01b0382165f90815260056020908152604080832084845290915290205460ff161561236c576040517f1f6d5aef00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0382165f8181526005602090815260408083208584529091529020805460ff1916600117905587518291908990869081106123b0576123b0615264565b60200260200101517fc4e3e09840282d09a125dc68ec6d3f9ddc391b467fbe53aad57c80dc183bb73b60405160405180910390a45b5050600101612184565b506123f98361362a565b50505095945050505050565b5f341580159061241757506001600254145b1561243557604051631841b4e160e01b815260040160405180910390fd5b816001600160a01b03811661245d57604051634e46966960e11b815260040160405180910390fd5b5f6124666133b3565b90505f805b86811015612917575f88888381811061248657612486615264565b90506020020135905061249881613460565b5f600382815481106124ac576124ac615264565b5f9182526020909120600b909102016001810154909150600160401b90046001600160a01b0316806124f45760405163c87c164160e01b815260048101849052602401610d4b565b8154600160401b900463ffffffff165f819003612540576040517ff27cfd4600000000000000000000000000000000000000000000000000000000815260048101859052602401610d4b565b600583015460018401545f9160ff90811691650100000000009004161561263457600481600581111561257557612575614c4e565b036125d6575f8080526008860160205260409020546001600160a01b038a81169116146125d1576040517f1d12a9fe00000000000000000000000000000000000000000000000000000000815260048101879052602401610d4b565b6126f1565b836001600160a01b0316896001600160a01b031614612624576040517fc9cd77cf00000000000000000000000000000000000000000000000000000000815260048101879052602401610d4b565b61262d81613fa8565b91506126f1565b84545f90612650908890600160e01b900463ffffffff166137bf565b6001870154909150640100000000900460ff1615806126805750600482600581111561267e5761267e614c4e565b145b156126955761269087828c6138f0565b6126ef565b846001600160a01b03168a6001600160a01b0316146126e3576040517fc9cd77cf00000000000000000000000000000000000000000000000000000000815260048101889052602401610d4b565b6126ec82613fa8565b92505b505b84546001600160601b036c010000000000000000000000009091041663ffffffff841602821561273d576002860154600387015461273a916001600160a01b0316908388613fe7565b90035b60018601545f906127109063ffffffff166001600160601b03841602049050808a0199508082039150818d019c508860010198508d6001600160a01b03168b6001600160a01b0316897ff5c3d0ba946ce1f61c398ccdceab30952250a5c3a614f566ec2fd5f1dabd17bf856040516127c491906001600160601b0391909116815260200190565b60405180910390a450506001850154670100000000000000900460ff161561281b576040517f3be20bf100000000000000000000000000000000000000000000000000000000815260048101879052602401610d4b565b60018501546601000000000000900460ff16806128495750600481600581111561284757612847614c4e565b145b156128d7576003868154811061286157612861615264565b5f91825260208220600b909102018181556001810180546001600160e01b031916905560028101805473ffffffffffffffffffffffffffffffffffffffff19168155600382018390556004820183905560058201805460ff19169055909190816128ce600685018261474b565b5050505061290c565b6001850180547fffffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffff166701000000000000001790555b50505050505061246b565b506001600160601b038116156129b5576004546001600160a01b039081169061296c907f000000000000000000000000000000000000000000000000000000000000000016826001600160601b0385166135e1565b6040516001600160601b03831681526001600160a01b038216907f194055900b5891c5b0c846e80054a4aad896f0756f69397a6eaeb7014193684a9060200160405180910390a2505b61168e6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016866001600160601b0387166135e1565b612a1e7f00000000000000000000000000000000000000000000000000000000000000006116c46133b3565b6001600160a01b038116612a5e576040517f140ecf0500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6004546040516001600160a01b038084169216907f523da6ae20ac3249365e93dcf61dffd12c54a455da42b245514301487fbfd939905f90a36004805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b612af27f00000000000000000000000000000000000000000000000000000000000000006116c46133b3565b60065467ffffffffffffffff600160401b909104811690821610612b42576040517f7616640100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60065460405167ffffffffffffffff8084169216907fc14524dbf6dcb0f48ded31a41c202c3dca437c6c5bc3cc6138e880cfed083703905f90a3600680547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001667ffffffffffffffff92909216919091179055565b5f60038381548110612bcb57612bcb615264565b5f91825260208083206001600160a01b03861684526009600b90930201919091019052604090205463ffffffff16905092915050565b5f612c2a60038481548110612c1857612c18615264565b905f5260205f2090600b020183614237565b9392505050565b60038181548110612c40575f80fd5b5f918252602091829020600b90910201805460018201546040805160a0810182526002850180546001600160a01b03908116835260038701549783019790975260048601549282019290925260058086015463ffffffff8087169950640100000000808804821699600160401b808a0484169a6001600160601b036c010000000000000000000000008c04169a7801000000000000000000000000000000000000000000000000810486169a600160e01b9091048616999581169860ff9582048616986501000000000083048716986601000000000000840488169867010000000000000085048916989690940496909616959394919360608501921690811115612d4d57612d4d614c4e565b6005811115612d5e57612d5e614c4e565b8152602001600482018054612d72906153be565b80601f0160208091040260200160405190810160405280929190818152602001828054612d9e906153be565b8015612de95780601f10612dc057610100808354040283529160200191612de9565b820191905f5260205f20905b815481529060010190602001808311612dcc57829003601f168201915b50505050508152505090508d565b612e237f00000000000000000000000000000000000000000000000000000000000000006116c46133b3565b60065467ffffffffffffffff90811690821611612e6c576040517f7616640100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60065460405167ffffffffffffffff80841692600160401b900416907f48752fb030a2abe76f2d8d8681d69fa9de4ec037bb3d50f9e6b81672a8fda7bb905f90a36006805467ffffffffffffffff909216600160401b027fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff909216919091179055565b5f612ef984613460565b8263ffffffff165f03612f38576040517fb405724900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f60038581548110612f4c57612f4c615264565b5f91825260208220600b90910201805490925063ffffffff1690819003612f895760405163c87c164160e01b815260048101879052602401610d4b565b8154600160401b900463ffffffff165f612fa38288615817565b90508263ffffffff168163ffffffff161115612feb576040517fbe601f7600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8354600160e01b900463ffffffff16421115613036576040517f6250c2b400000000000000000000000000000000000000000000000000000000815260048101899052602401610d4b565b5f8363ffffffff166004028863ffffffff168963ffffffff16028161305d5761305d615803565b0490505f855f0160049054906101000a900463ffffffff1690505f828201905080875f0160046101000a81548163ffffffff021916908363ffffffff1602179055505f876009015f8b6001600160a01b03166001600160a01b031681526020019081526020015f205f9054906101000a900463ffffffff168b0190508388600a015f8c6001600160a01b03166001600160a01b031681526020019081526020015f205f8282829054906101000a900463ffffffff160192506101000a81548163ffffffff021916908363ffffffff16021790555080886009015f8c6001600160a01b03166001600160a01b031681526020019081526020015f205f6101000a81548163ffffffff021916908363ffffffff16021790555084885f0160086101000a81548163ffffffff021916908363ffffffff1602179055505f885f0160189054906101000a900463ffffffff1690508a896008015f8363ffffffff1663ffffffff1681526020019081526020015f205f6101000a8154816001600160a01b0302191690836001600160a01b03160217905550828601896007015f8363ffffffff1663ffffffff1681526020019081526020015f205f6101000a81548163ffffffff021916908363ffffffff16021790555080600101905080895f0160186101000a81548163ffffffff021916908363ffffffff1602179055508763ffffffff168663ffffffff160361330f57885463ffffffff428116600160e01b027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff909216919091178a5560018a0180547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffff166401000000001790558881169083160361330f576001890180547fffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffffff16650100000000001790555b8b63ffffffff16895f01600c9054906101000a90046001600160601b031602995083870163ffffffff168b6001600160a01b03168e7f8772ec5268199c7b7dbfea9344db6e4dcdf075620f23f073c29aa98a7678356d8f8e8a60405161339b9392919063ffffffff93841681526001600160601b03929092166020830152909116604082015260600190565b60405180910390a45050505050505050509392505050565b5f6133bc614330565b905090565b6040516001600160a01b038085166024830152831660448201526064810182905261345a9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b0319909316929092179091526143a3565b50505050565b600354811061349b576040517fd9fd6a1c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50565b6040517ffa95b13900000000000000000000000000000000000000000000000000000000815263ffffffff821660048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063fa95b139906024016040805180830381865afa158015613520573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906135449190615834565b915050805f0361359a5762015180820163ffffffff164211613595576040517f128471ac00000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b505050565b62015180820163ffffffff168111613595576040517fcc1bf05800000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b6040516001600160a01b0383166024820152604481018290526135959084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161340e565b345f036136345750565b6002547ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd8101613690576040517fd5bcee7e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b815f036136a957600281036136a55760036002555b5050565b60018114806136b85750348214155b156136a557604051631841b4e160e01b815260040160405180910390fd5b6136e08282614489565b6136a5576040517fc183bcef00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606060ff83146137305761372983614535565b9050610893565b81805461373c906153be565b80601f0160208091040260200160405190810160405280929190818152602001828054613768906153be565b80156137b35780601f1061378a576101008083540402835291602001916137b3565b820191905f5260205f20905b81548152906001019060200180831161379657829003601f168201915b50505050509050610893565b6040517ffa95b13900000000000000000000000000000000000000000000000000000000815263ffffffff821660048201525f9081906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063fa95b139906024016040805180830381865afa158015613843573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906138679190615834565b90925090505f8190036138a8576040517e4337df00000000000000000000000000000000000000000000000000000000815260048101859052602401610d4b565b62015180830163ffffffff1681111561208b576040517f6250c2b400000000000000000000000000000000000000000000000000000000815260048101859052602401610d4b565b5f6003848154811061390457613904615264565b905f5260205f2090600b020190505f610100858161392457613924615803565b8354919006915084821b61010083900386901c17905f90613974908590600160401b810463ffffffff90811664010000000090920481169190910116848161396e5761396e615803565b06614237565b9050806001600160a01b0316856001600160a01b0316146139c4576040517f1d12a9fe00000000000000000000000000000000000000000000000000000000815260048101889052602401610d4b565b50505050505050565b5f306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015613a2557507f000000000000000000000000000000000000000000000000000000000000000046145b15613a4f57507f000000000000000000000000000000000000000000000000000000000000000090565b6133bc604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b6006545f9067ffffffffffffffff16613b156060860160408701614d43565b63ffffffff161015613b63576006546040517f0c3aad9700000000000000000000000000000000000000000000000000000000815267ffffffffffffffff9091166004820152602401610d4b565b600654600160401b900467ffffffffffffffff16613b876060860160408701614d43565b63ffffffff161115613bdb576006546040517fa78341a2000000000000000000000000000000000000000000000000000000008152600160401b90910467ffffffffffffffff166004820152602401610d4b565b613be86020850185614d43565b63ffffffff165f03613c26576040517f3cfbac5700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b633b9aca00613c386020860186614d43565b63ffffffff161115613c76576040517f09d9a0c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613c866040850160208601615856565b6001600160601b03165f03613cc7576040517f1d133e9000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f613cd86080860160608701614b83565b6001600160a01b031603613d18576040517f49e27cff00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6b033b2e3c9fd0803ce8000000613d326020860186614d43565b63ffffffff16613d486040870160208801615856565b613d52919061586f565b6001600160601b03161115613d93576040517fba7848b900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600380546001810182555f91909152600b81027fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b81019086907fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85d01613df982826159a3565b50613e0c90506080860160608701614b83565b6001820180546001600160a01b0392909216600160401b027fffffffff0000000000000000000000000000000000000000ffffffffffffffff909216919091179055613e5b6020860186614d43565b815463ffffffff191663ffffffff91909116178155613e806040860160208701615856565b81547fffffffffffffffff000000000000000000000000ffffffffffffffffffffffff166c010000000000000000000000006001600160601b03929092169190910217815560018101805463ffffffff191663ffffffff86161790555f613eed6060870160408801614d43565b825463ffffffff4292909201918216600160e01b027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff9091161783559050613f376080870160608801614b83565b6001600160a01b03908116908516847ff806f15c2cacb4703b6edc897c2cbe33990d7d191bd57bbf4a8ae9ab2315bf758a613f7560208c018c614d43565b613f8560408d0160208e01615856565b87604051613f969493929190615a43565b60405180910390a45050949350505050565b5f80826005811115613fbc57613fbc614c4e565b1480613fd957506001826005811115613fd757613fd7614c4e565b145b15613fe2575060015b919050565b6040517ff533b8020000000000000000000000000000000000000000000000000000000081526001600160a01b038581166004830152602482018590526001600160601b03841660448301525f91829182917f00000000000000000000000000000000000000000000000000000000000000009091169063f533b802906064015f604051808303815f875af1158015614082573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526140a99190810190615b3e565b915091505f5b825181101561422c575f8282815181106140cb576140cb615264565b602002602001015190505f6001600160a01b03168483815181106140f1576140f1615264565b60200260200101516001600160a01b03161415801561413b5750856001600160a01b031684838151811061412757614127615264565b60200260200101516001600160a01b031614155b801561414f57506001600160601b03811615155b15614223576141b484838151811061416957614169615264565b6020026020010151826001600160601b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166135e19092919063ffffffff16565b80850194508382815181106141cb576141cb615264565b60200260200101516001600160a01b03167fd5a02d893cdcfe3f25286206f6f6592510f6a8f56272801f6c28d347625f317e8260405161421a91906001600160601b0391909116815260200190565b60405180910390a25b506001016140af565b505050949350505050565b81545f907801000000000000000000000000000000000000000000000000900463ffffffff16801580614288575063ffffffff5f19820181165f908152600786016020526040902054811690841610155b15614296575f915050610893565b5f5b8163ffffffff168163ffffffff161015614308575f6142ba6002838518615bfd565b6142c690838516615817565b63ffffffff8082165f908152600789016020526040902054919250808716911611156142f457809250614302565b6142ff816001615817565b91505b50614298565b63ffffffff165f9081526008850160205260409020546001600160a01b031691505092915050565b5f366014336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614801561436c5750808210155b1561439b575f3661437d83856154ea565b6143889282906154fd565b61439191615c2b565b60601c9250505090565b339250505090565b5f6143f7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166145729092919063ffffffff16565b905080515f14806144175750808060200190518101906144179190615c71565b6135955760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610d4b565b6040517f91d14854000000000000000000000000000000000000000000000000000000008152600481018390526001600160a01b0382811660248301525f917f0000000000000000000000000000000000000000000000000000000000000000909116906391d1485490604401602060405180830381865afa158015614511573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c2a9190615c71565b60605f61454183614580565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b6060610c0684845f856145c0565b5f60ff8216601f811115610893576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6060824710156146385760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610d4b565b5f80866001600160a01b03168587604051614653919061558c565b5f6040518083038185875af1925050503d805f811461468d576040519150601f19603f3d011682016040523d82523d5f602084013e614692565b606091505b50915091506146a3878383876146ae565b979650505050505050565b6060831561471c5782515f03614715576001600160a01b0385163b6147155760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610d4b565b5081610c06565b610c0683838151156147315781518083602001fd5b8060405162461bcd60e51b8152600401610d4b9190614c3c565b508054614757906153be565b5f825580601f10614766575050565b601f0160209004905f5260205f209081019061349b91905b80821115614791575f815560010161477e565b5090565b5f602082840312156147a5575f80fd5b81356001600160e01b031981168114612c2a575f80fd5b634e487b7160e01b5f52604160045260245ffd5b60405160a0810167ffffffffffffffff811182821017156147f3576147f36147bc565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715614822576148226147bc565b604052919050565b5f67ffffffffffffffff821115614843576148436147bc565b5060051b60200190565b5f82601f83011261485c575f80fd5b8135602061487161486c8361482a565b6147f9565b82815260059290921b8401810191818101908684111561488f575f80fd5b8286015b848110156148aa5780358352918301918301614893565b509695505050505050565b5f8083601f8401126148c5575f80fd5b50813567ffffffffffffffff8111156148dc575f80fd5b6020830191508360208260051b85010111156148f6575f80fd5b9250929050565b6001600160a01b038116811461349b575f80fd5b8035613fe2816148fd565b5f8083601f84011261492c575f80fd5b50813567ffffffffffffffff811115614943575f80fd5b6020830191508360208285010111156148f6575f80fd5b5f805f805f806080878903121561496f575f80fd5b863567ffffffffffffffff80821115614986575f80fd5b6149928a838b0161484d565b975060208901359150808211156149a7575f80fd5b6149b38a838b016148b5565b9097509550604089013591506149c8826148fd565b909350606088013590808211156149dd575f80fd5b506149ea89828a0161491c565b979a9699509497509295939492505050565b5f67ffffffffffffffff821115614a1557614a156147bc565b50601f01601f191660200190565b5f82601f830112614a32575f80fd5b8135614a4061486c826149fc565b818152846020838601011115614a54575f80fd5b816020850160208301375f918101602001919091529392505050565b5f805f8060808587031215614a83575f80fd5b8435614a8e816148fd565b93506020850135614a9e816148fd565b925060408501359150606085013567ffffffffffffffff811115614ac0575f80fd5b614acc87828801614a23565b91505092959194509250565b5f8060408385031215614ae9575f80fd5b8235614af4816148fd565b946020939093013593505050565b5f8060408385031215614b13575f80fd5b823591506020830135614b25816148fd565b809150509250929050565b5f805f60408486031215614b42575f80fd5b833567ffffffffffffffff811115614b58575f80fd5b614b64868287016148b5565b9094509250506020840135614b78816148fd565b809150509250925092565b5f60208284031215614b93575f80fd5b8135612c2a816148fd565b5f805f60408486031215614bb0575f80fd5b8335614bbb816148fd565b9250602084013567ffffffffffffffff811115614bd6575f80fd5b614be28682870161491c565b9497909650939450505050565b5f5b83811015614c09578181015183820152602001614bf1565b50505f910152565b5f8151808452614c28816020860160208601614bef565b601f01601f19169290920160200192915050565b602081525f612c2a6020830184614c11565b634e487b7160e01b5f52602160045260245ffd5b60068110614c7e57634e487b7160e01b5f52602160045260245ffd5b9052565b6001600160a01b03815116825260208101516020830152604081015160408301525f6060820151614cb66060850182614c62565b50608082015160a06080850152610c0660a0850182614c11565b5f602080830181845280855180835260408601915060408160051b87010192508387015f5b82811015614d2357603f19888603018452614d11858351614c82565b94509285019290850190600101614cf5565b5092979650505050505050565b803563ffffffff81168114613fe2575f80fd5b5f60208284031215614d53575f80fd5b612c2a82614d30565b5f8151808452602080850194508084015f5b83811015614d8a57815187529582019590820190600101614d6e565b509495945050505050565b7fff000000000000000000000000000000000000000000000000000000000000008816815260e060208201525f614dcf60e0830189614c11565b8281036040840152614de18189614c11565b90508660608401526001600160a01b03861660808401528460a084015282810360c0840152614e108185614d5c565b9a9950505050505050505050565b5f8060408385031215614e2f575f80fd5b82359150614e3f60208401614d30565b90509250929050565b5f805f805f805f805f8060c08b8d031215614e61575f80fd5b8a3567ffffffffffffffff80821115614e78575f80fd5b614e848e838f016148b5565b909c509a5060208d0135915080821115614e9c575f80fd5b614ea88e838f016148b5565b909a509850889150614ebc60408e01614d30565b975060608d0135915080821115614ed1575f80fd5b614edd8e838f016148b5565b9097509550859150614ef160808e01614911565b945060a08d0135915080821115614f06575f80fd5b50614f138d828e0161491c565b915080935050809150509295989b9194979a5092959850565b604081525f614f3e6040830185614d5c565b90506001600160601b03831660208301529392505050565b5f8060208385031215614f67575f80fd5b823567ffffffffffffffff811115614f7d575f80fd5b614f89858286016148b5565b90969095509350505050565b5f602080830181845280855180835260408601915060408160051b87010192508387015f5b82811015614d2357603f19888603018452614fd6858351614c11565b94509285019290850190600101614fba565b5f805f805f60608688031215614ffc575f80fd5b853567ffffffffffffffff80821115615013575f80fd5b61501f89838a016148b5565b90975095506020880135915080821115615037575f80fd5b50615044888289016148b5565b9094509250615057905060408701614d30565b90509295509295909350565b602081525f612c2a6020830184614d5c565b5f805f805f60a08688031215615089575f80fd5b8535615094816148fd565b945060208601356150a4816148fd565b9350604086013567ffffffffffffffff808211156150c0575f80fd5b6150cc89838a0161484d565b945060608801359150808211156150e1575f80fd5b6150ed89838a0161484d565b93506080880135915080821115615102575f80fd5b5061510f88828901614a23565b9150509295509295909350565b5f6020828403121561512c575f80fd5b813567ffffffffffffffff81168114612c2a575f80fd5b5f60208284031215615153575f80fd5b5035919050565b63ffffffff8e811682528d811660208301528c811660408301526001600160601b038c1660608301528a16608082015263ffffffff891660a082015263ffffffff881660c082015286151560e08201528515156101008201528415156101208201528315156101408201526001600160a01b0383166101608201526101a06101808201525f6151ed6101a0830184614c82565b9f9e505050505050505050505050505050565b5f805f805f60a08688031215615214575f80fd5b853561521f816148fd565b9450602086013561522f816148fd565b93506040860135925060608601359150608086013567ffffffffffffffff811115615258575f80fd5b61510f88828901614a23565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b6001600160601b0381811683821601908082111561208b5761208b615278565b5f805f805f60a086880312156152c0575f80fd5b8535945060208601359350604086013560ff811681146152de575f80fd5b94979396509394606081013594506080013592915050565b81835281816020850137505f602082840101525f6020601f19601f840116840101905092915050565b6001600160a01b0384168152604060208201525f6153416040830184866152f6565b95945050505050565b5f82601f830112615359575f80fd5b815161536761486c826149fc565b81815284602083860101111561537b575f80fd5b610c06826020830160208701614bef565b5f6020828403121561539c575f80fd5b815167ffffffffffffffff8111156153b2575f80fd5b610c068482850161534a565b600181811c908216806153d257607f821691505b6020821081036153f057634e487b7160e01b5f52602260045260245ffd5b50919050565b606081525f6154086060830186614c82565b6001600160a01b0394851660208401529290931660409091015292915050565b6006811061349b575f80fd5b5f60208284031215615444575f80fd5b815167ffffffffffffffff8082111561545b575f80fd5b9083019060a0828603121561546e575f80fd5b6154766147d0565b8251615481816148fd565b80825250602083015160208201526040830151604082015260608301516154a781615428565b60608201526080830151828111156154bd575f80fd5b6154c98782860161534a565b60808301525095945050505050565b602081525f612c2a6020830184614c82565b8181038181111561089357610893615278565b5f808585111561550b575f80fd5b83861115615517575f80fd5b5050820193919092039150565b5f808335601e19843603018112615539575f80fd5b83018035915067ffffffffffffffff821115615553575f80fd5b6020019150368190038213156148f6575f80fd5b828482375f8382015f81528351615582818360208801614bef565b0195945050505050565b5f825161559d818460208701614bef565b9190910192915050565b5f82357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6183360301811261559d575f80fd5b5f60a082360312156155e9575f80fd5b6155f16147d0565b82356155fc816148fd565b808252506020830135602082015260408301356040820152606083013561562281615428565b6060820152608083013567ffffffffffffffff811115615640575f80fd5b61564c36828601614a23565b60808301525092915050565b5f82357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4183360301811261559d575f80fd5b80356001600160601b0381168114613fe2575f80fd5b5f808335601e198436030181126156b5575f80fd5b830160208101925035905067ffffffffffffffff8111156156d4575f80fd5b8036038213156148f6575f80fd5b60c081525f6156f460c0830189614c82565b828103602084015263ffffffff8061570b8a614d30565b1682526001600160601b0361572260208b0161568a565b1660208301528061573560408b01614d30565b16604083015250606088013561574a816148fd565b6001600160a01b0316606082015261576460808901614911565b6001600160a01b0316608082015261577f60a08901896156a0565b60c060a084015261579460c0840182846152f6565b93505050508560408301526157b460608301866001600160a01b03169052565b8360808301526146a360a08301846001600160a01b03169052565b5f805f606084860312156157e1575f80fd5b83516157ec816148fd565b602085015160409095015190969495509392505050565b634e487b7160e01b5f52601260045260245ffd5b63ffffffff81811683821601908082111561208b5761208b615278565b5f8060408385031215615845575f80fd5b505080516020909101519092909150565b5f60208284031215615866575f80fd5b612c2a8261568a565b6001600160601b0381811683821602808216919082811461589257615892615278565b505092915050565b601f821115613595575f81815260208120601f850160051c810160208610156158c05750805b601f850160051c820191505b818110156158df578281556001016158cc565b505050505050565b67ffffffffffffffff8311156158ff576158ff6147bc565b6159138361590d83546153be565b8361589a565b5f601f841160018114615944575f851561592d5750838201355b5f19600387901b1c1916600186901b17835561599c565b5f83815260209020601f19861690835b828110156159745786850135825560209485019460019092019101615954565b5086821015615990575f1960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b81356159ae816148fd565b6001600160a01b03811673ffffffffffffffffffffffffffffffffffffffff198354161782555060208201356001820155604082013560028201556003810160608301356159fb81615428565b60068110615a1757634e487b7160e01b5f52602160045260245ffd5b60ff1982541660ff821681178355505050615a356080830183615524565b61345a8183600486016158e7565b608081525f8535615a53816148fd565b6001600160a01b03166080830152602086013560a0830152604086013560c08301526060860135615a8381615428565b615a9060e0840182614c62565b50615a9e60808701876156a0565b60a0610100850152615ab5610120850182846152f6565b63ffffffff97881660208601526001600160601b039690961660408501525050509216606090920191909152919050565b5f82601f830112615af5575f80fd5b81516020615b0561486c8361482a565b82815260059290921b84018101918181019086841115615b23575f80fd5b8286015b848110156148aa5780518352918301918301615b27565b5f8060408385031215615b4f575f80fd5b825167ffffffffffffffff80821115615b66575f80fd5b818501915085601f830112615b79575f80fd5b81516020615b8961486c8361482a565b82815260059290921b84018101918181019089841115615ba7575f80fd5b948201945b83861015615bce578551615bbf816148fd565b82529482019490820190615bac565b91880151919650909350505080821115615be6575f80fd5b50615bf385828601615ae6565b9150509250929050565b5f63ffffffff80841680615c1f57634e487b7160e01b5f52601260045260245ffd5b92169190910492915050565b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000081358181169160148510156158925760149490940360031b84901b1690921692915050565b5f60208284031215615c81575f80fd5b81518015158114612c2a575f80fdfea2646970667358221220868f24ff406c482b5c91247d508a52b1ac68ef616cb913d038bed9905109519564736f6c6343000815003300000000000000000000000043000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cf12be07ea93f7edf6103ee34a33890b4d8b69b50000000000000000000000004690c5b0eb109219bb27e660b17099feb870f4bd000000000000000000000000085827915e1e1a233c7543bc30ad08fda9ad575700000000000000000000000054efe2805f42683ac533ca2d2b1704d4417a1267000000000000000000000000d388d812c1ce2ce7c46d797684ba912de65cd414000000000000000000000000b62339c4ccda62c920c75bcc5fd43f07431dfde40000000000000000000000002536fe9ab3f511540f2f9e2ec2a805005c3dd800000000000000000000000000ed97e7076611c7ead32bc739eb0e3360eba3f8300000000000000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x608060405260043610610243575f3560e01c806384b0196e11610131578063bc197c81116100ac578063eecd5b9c1161007c578063f23a6e6111610062578063f23a6e611461079b578063f80db741146107df578063fdcb6068146107fe575f80fd5b8063eecd5b9c14610744578063f1648e8414610763575f80fd5b8063bc197c8114610692578063d00c8c77146106d6578063d798bd8c146106f5578063ddca3f4314610714575f80fd5b8063a469d3e611610101578063ad364d25116100e7578063ad364d2514610640578063ba7b8f1314610660578063bb8bd72514610673575f80fd5b8063a469d3e6146105ff578063ac9650d814610620575f80fd5b806384b0196e14610592578063870fb262146105b95780638a5e3ea0146105cc5780639796a67d146105eb575f80fd5b80635ec01e4d116101c15780636eaccadb1161019157806375b238fc1161017757806375b238fc146104fd578063764bd0c51461053e5780638142dd5314610571575f80fd5b80636eaccadb146104c7578063727c2e96146104dd575f80fd5b80635ec01e4d1461042e5780636052970c1461046157806364629f2c146104805780636db5c8fd146104a0575f80fd5b806334fb48801161021657806356715761116101fc578063567157611461039657806356b53e2b146103cf578063572b6c05146103e2575f80fd5b806334fb4880146103175780634cf088d91461034b575f80fd5b806301ffc9a714610247578063127b3be51461027b578063150b7a02146102a65780631647795e146102de575b5f80fd5b348015610252575f80fd5b50610266610261366004614795565b610831565b60405190151581526020015b60405180910390f35b61028e61028936600461495a565b610899565b6040516001600160601b039091168152602001610272565b3480156102b1575f80fd5b506102c56102c0366004614a70565b610be4565b6040516001600160e01b03199091168152602001610272565b3480156102e9575f80fd5b506102666102f8366004614ad8565b600560209081525f928352604080842090915290825290205460ff1681565b348015610322575f80fd5b50610336610331366004614b02565b610c0e565b60405163ffffffff9091168152602001610272565b348015610356575f80fd5b5061037e7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610272565b3480156103a1575f80fd5b506006546103b69067ffffffffffffffff1681565b60405167ffffffffffffffff9091168152602001610272565b61028e6103dd366004614b30565b610c58565b3480156103ed575f80fd5b506102666103fc366004614b83565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b348015610439575f80fd5b5061037e7f000000000000000000000000085827915e1e1a233c7543bc30ad08fda9ad575781565b34801561046c575f80fd5b5060045461037e906001600160a01b031681565b61049361048e366004614b9e565b610ff6565b6040516102729190614c3c565b3480156104ab575f80fd5b506006546103b690600160401b900467ffffffffffffffff1681565b3480156104d2575f80fd5b506103366201518081565b6104f06104eb366004614b30565b6110af565b6040516102729190614cd0565b348015610508575f80fd5b506105307f000000000000000000000000000000000000000000000000000000000000000081565b604051908152602001610272565b348015610549575f80fd5b5061037e7f000000000000000000000000430000000000000000000000000000000000000381565b34801561057c575f80fd5b5061059061058b366004614d43565b611698565b005b34801561059d575f80fd5b506105a66117a0565b6040516102729796959493929190614d95565b6104f06105c7366004614b30565b611842565b3480156105d7575f80fd5b5061037e6105e6366004614e1e565b611dcb565b3480156105f6575f80fd5b50600354610530565b61061261060d366004614e48565b611e15565b604051610272929190614f2c565b61063361062e366004614f56565b611e46565b6040516102729190614f95565b61065361064e366004614fe8565b612092565b6040516102729190615063565b61028e61066e366004614b30565b612405565b34801561067e575f80fd5b5061059061068d366004614b83565b6129f2565b34801561069d575f80fd5b506102c56106ac366004615075565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e1575f80fd5b506105906106f036600461511c565b612ac6565b348015610700575f80fd5b5061033661070f366004614b02565b612bb7565b34801561071f575f80fd5b5060065461033690700100000000000000000000000000000000900463ffffffff1681565b34801561074f575f80fd5b5061037e61075e366004614e1e565b612c01565b34801561076e575f80fd5b5061078261077d366004615143565b612c31565b6040516102729d9c9b9a9998979695949392919061515a565b3480156107a6575f80fd5b506102c56107b5366004615200565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156107ea575f80fd5b506105906107f936600461511c565b612df7565b348015610809575f80fd5b5061037e7f000000000000000000000000b62339c4ccda62c920c75bcc5fd43f07431dfde481565b5f6001600160e01b031982167f4e2312e000000000000000000000000000000000000000000000000000000000148061089357507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b92915050565b5f34158015906108ab57506001600254145b156108c957604051631841b4e160e01b815260040160405180910390fd5b836001600160a01b0381166108f157604051634e46966960e11b815260040160405180910390fd5b8751861461092b576040517fa9854bc900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5b88518110156109945761098089828151811061094b5761094b615264565b602002602001015189898481811061096557610965615264565b905060200201602081019061097a9190614d43565b88612eef565b61098a908461528c565b925060010161092d565b505f61099e6133b3565b90508315610a86575f808080806109b7898b018b6152ac565b6040517fd505accf0000000000000000000000000000000000000000000000000000000081526001600160a01b038c81166004830152306024830152604482018790526064820186905260ff8516608483015260a4820184905260c48201839052959a50939850919650945092507f00000000000000000000000043000000000000000000000000000000000000039091169063d505accf9060e4015f604051808303815f87803b158015610a6a575f80fd5b505af1158015610a7c573d5f803e3d5ffd5b5050505050505050505b610ac46001600160a01b037f00000000000000000000000043000000000000000000000000000000000000031682306001600160601b0387166133c1565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031615610bd8576040517f3f50adf10000000000000000000000000000000000000000000000000000000081526001600160601b03841660048201526001600160a01b0387811660248301527f00000000000000000000000000000000000000000000000000000000000000001690633f50adf1906044015f604051808303815f87803b158015610b7b575f80fd5b505af1925050508015610b8c575060015b610bd8576040516001600160601b03841681526001600160a01b038716907fb88061c54967fd5e9babc5708c54ec3d2e4a358223a5e32fb7d4cba2f20e39579060200160405180910390a25b50509695505050505050565b7f150b7a02000000000000000000000000000000000000000000000000000000005b949350505050565b5f60038381548110610c2257610c22615264565b5f91825260208083206001600160a01b0386168452600a600b90930201919091019052604090205463ffffffff16905092915050565b5f3415801590610c6a57506001600254145b15610c8857604051631841b4e160e01b815260040160405180910390fd5b816001600160a01b038116610cb057604051634e46966960e11b815260040160405180910390fd5b5f610cb96133b3565b90505f5b85811015610faf575f878783818110610cd857610cd8615264565b905060200201359050610cea81613460565b5f60038281548110610cfe57610cfe615264565b5f91825260208220600b9091020180549092506001600160601b036c010000000000000000000000009091041690819003610d545760405163c87c164160e01b8152600481018490526024015b60405180910390fd5b6001600160a01b0385165f90815260098301602052604081205463ffffffff1690819003610db1576040517fae267ff000000000000000000000000000000000000000000000000000000000815260048101859052602401610d4b565b600183015465010000000000900460ff1615610dfc576040517fcc1bf05800000000000000000000000000000000000000000000000000000000815260048101859052602401610d4b565b8254610e16908590600160e01b900463ffffffff1661349e565b82547fffffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffff811663ffffffff600160401b92839004811684900381169092021784556001600160a01b038781165f818152600987016020908152604091829020805463ffffffff1916905590516001600160601b03948616870294851681529b84019b60019990990198928d169288917f5f0d5e01c94f6e597b35974549cefd32ab7f862eea9e90e19105e4b9b15c6f8a910160405180910390a4508254600160401b900463ffffffff16158015610f1c575060018301546601000000000000900460ff1680610f1c5750600460058085015460ff1690811115610f1a57610f1a614c4e565b145b15610fa65760038481548110610f3457610f34615264565b5f91825260208220600b909102018181556001810180546001600160e01b031916905560028101805473ffffffffffffffffffffffffffffffffffffffff19168155600382018390556004820183905560058201805460ff1916905590919081610fa1600685018261474b565b505050505b50505050610cbd565b50610fed6001600160a01b037f000000000000000000000000430000000000000000000000000000000000000316856001600160601b0386166135e1565b50509392505050565b60606110015f61362a565b6040517f64629f2c0000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000cf12be07ea93f7edf6103ee34a33890b4d8b69b516906364629f2c90349061106c9088908890889060040161531f565b5f6040518083038185885af1158015611087573d5f803e3d5ffd5b50505050506040513d5f823e601f3d908101601f19168201604052610c06919081019061538c565b606034158015906110c257506001600254145b156110e057604051631841b4e160e01b815260040160405180910390fd5b816001600160a01b03811661110857604051634e46966960e11b815260040160405180910390fd5b8367ffffffffffffffff811115611121576111216147bc565b60405190808252806020026020018201604052801561118357816020015b6111706040805160a0810182525f808252602082018190529181018290529060608201908152602001606081525090565b81526020019060019003908161113f5790505b5091505f61118f6133b3565b90505f5b8581101561168e575f8787838181106111ae576111ae615264565b9050602002013590506111c081613460565b5f600382815481106111d4576111d4615264565b5f9182526020909120600b909102016001810154909150600160401b90046001600160a01b03168061121c5760405163c87c164160e01b815260048101849052602401610d4b565b806001600160a01b0316856001600160a01b03161461126a576040517fc9cd77cf00000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b600182015465010000000000900460ff16156112b5576040517fcc1bf05800000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b60018201546601000000000000900460ff1615611301576040517fd181585f00000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b81546001830154600160e01b90910463ffffffff1690640100000000900460ff161561133657611331848261349e565b611378565b8063ffffffff164211611378576040517f128471ac00000000000000000000000000000000000000000000000000000000815260048101859052602401610d4b565b6040805160a0810182526002850180546001600160a01b03168252600386015460208301526004860154928201929092526005808601545f9391606084019160ff16908111156113ca576113ca614c4e565b60058111156113db576113db614c4e565b81526020016004820180546113ef906153be565b80601f016020809104026020016040519081016040528092919081815260200182805461141b906153be565b80156114665780601f1061143d57610100808354040283529160200191611466565b820191905f5260205f20905b81548152906001019060200180831161144957829003601f168201915b505050919092525050506001850154909150670100000000000000900460ff168061149d57508354600160401b900463ffffffff16155b1561152b57600385815481106114b5576114b5615264565b5f91825260208220600b909102018181556001810180546001600160e01b031916905560028101805473ffffffffffffffffffffffffffffffffffffffff19168155600382018390556004820183905560058201805460ff1916905590919081611522600685018261474b565b50505050611547565b60018401805466ff000000000000191666010000000000001790555b6040517fdbe6079f0000000000000000000000000000000000000000000000000000000081527326015b335ec532b32ac6436704210d677ef354299063dbe6079f906115bb9084908e907f0000000000000000000000004690c5b0eb109219bb27e660b17099feb870f4bd906004016153f6565b5f60405180830381865af41580156115d5573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526115fc9190810190615434565b89878151811061160e5761160e615264565b6020026020010181905250896001600160a01b0316876001600160a01b0316867f12650d05f405bb47df1fbc670929e68d0b595cc452e0ed396c0dff2382ddd8b58c8a8151811061166157611661615264565b602002602001015160405161167691906154d8565b60405180910390a48560010195505050505050611193565b5050509392505050565b6116c97f00000000000000000000000000000000000000000000000000000000000000006116c46133b3565b6136d6565b6113888163ffffffff16111561170b576040517fcd4e616700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60065460405163ffffffff80841692700100000000000000000000000000000000900416907fe50fb4e9ec0119d495079e81085516243df607978f5087d4d1d0d15107e323df905f90a36006805463ffffffff909216700100000000000000000000000000000000027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff909216919091179055565b5f606080828080836117d27f456573656500000000000000000000000000000000000000000000000000000583613716565b6117fd7f31000000000000000000000000000000000000000000000000000000000000016001613716565b604080515f808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b6060341580159061185557506001600254145b1561187357604051631841b4e160e01b815260040160405180910390fd5b816001600160a01b03811661189b57604051634e46966960e11b815260040160405180910390fd5b8367ffffffffffffffff8111156118b4576118b46147bc565b60405190808252806020026020018201604052801561191657816020015b6119036040805160a0810182525f808252602082018190529181018290529060608201908152602001606081525090565b8152602001906001900390816118d25790505b5091505f6119226133b3565b90505f5b8581101561168e575f87878381811061194157611941615264565b90506020020135905061195381613460565b5f6003828154811061196757611967615264565b5f91825260208220600b90910201805490925063ffffffff600160e01b90910416908190036119ac5760405163c87c164160e01b815260048101849052602401610d4b565b6001820154640100000000900460ff166119f5576040517f3fae947600000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b600182015465010000000000900460ff1615611a67575f8080526008830160205260409020546001600160a01b03868116911614611a62576040517f1d12a9fe00000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b611a81565b5f611a7284836137bf565b9050611a7f8482886138f0565b505b60018201546601000000000000900460ff1615611acd576040517fd181585f00000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b6040805160a0810182526002840180546001600160a01b03168252600385015460208301526004850154928201929092526005808501545f9391606084019160ff1690811115611b1f57611b1f614c4e565b6005811115611b3057611b30614c4e565b8152602001600482018054611b44906153be565b80601f0160208091040260200160405190810160405280929190818152602001828054611b70906153be565b8015611bbb5780601f10611b9257610100808354040283529160200191611bbb565b820191905f5260205f20905b815481529060010190602001808311611b9e57829003601f168201915b505050919092525050506001840154909150670100000000000000900460ff1615611c695760038481548110611bf357611bf3615264565b5f91825260208220600b909102018181556001810180546001600160e01b031916905560028101805473ffffffffffffffffffffffffffffffffffffffff19168155600382018390556004820183905560058201805460ff1916905590919081611c60600685018261474b565b50505050611c85565b60018301805466ff000000000000191666010000000000001790555b6040517fdbe6079f0000000000000000000000000000000000000000000000000000000081527326015b335ec532b32ac6436704210d677ef354299063dbe6079f90611cf99084908d907f0000000000000000000000004690c5b0eb109219bb27e660b17099feb870f4bd906004016153f6565b5f60405180830381865af4158015611d13573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052611d3a9190810190615434565b888681518110611d4c57611d4c615264565b6020026020010181905250886001600160a01b0316866001600160a01b0316857f02f768edc2c81c64ab82d5a40a06c32639e178bb3de87f04202451161e2162688b8981518110611d9f57611d9f615264565b6020026020010151604051611db491906154d8565b60405180910390a484600101945050505050611926565b5f60038381548110611ddf57611ddf615264565b5f918252602080832063ffffffff861684526008600b9093020191909101905260409020546001600160a01b0316905092915050565b60605f611e258c8c8c8c8c612092565b9150611e35828888888888610899565b90509a509a98505050505050505050565b60603415611e8f57600160025414611e8a576040517f37ed32e800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600280555b5f611e986133b3565b6001600160a01b0316336001600160a01b031614611f01575f36611ebd6014826154ea565b611ec89282906154fd565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250611f1092505050565b604080515f8152602081019091525b90508267ffffffffffffffff811115611f2b57611f2b6147bc565b604051908082528060200260200182016040528015611f5e57816020015b6060815260200190600190039081611f495790505b5091505f5b83811015612042575f8030878785818110611f8057611f80615264565b9050602002810190611f929190615524565b86604051602001611fa593929190615567565b60408051601f1981840301815290829052611fbf9161558c565b5f60405180830381855af49150503d805f8114611ff7576040519150601f19603f3d011682016040523d82523d5f602084013e611ffc565b606091505b50915091508161201a5780515f03612012575f80fd5b805181602001fd5b8085848151811061202d5761202d615264565b60209081029190910101525050600101611f63565b50341561208b57600360025414612085576040517fd5bcee7e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60016002555b5092915050565b60065460609063ffffffff83811670010000000000000000000000000000000090920416146120ed576040517f58d620b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b848314612126576040517fa9854bc900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8467ffffffffffffffff81111561213f5761213f6147bc565b604051908082528060200260200182016040528015612168578160200160208202803683370190505b509050345f6121756133b3565b90505f6121806139cd565b90505f5b888110156123ef575f808b8b848181106121a0576121a0615264565b90506020028101906121b291906155a7565b6121bb906155d9565b7326015b335ec532b32ac6436704210d677ef35429637bbdd17290918c8c878181106121e9576121e9615264565b90506020028101906121fb9190615658565b8989897f00000000000000000000000043000000000000000000000000000000000000036040518763ffffffff1660e01b8152600401612240969594939291906156e2565b606060405180830381865af415801561225b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061227f91906157cf565b975090925090506122d88c8c8581811061229b5761229b615264565b90506020028101906122ad91906155a7565b8b8b868181106122bf576122bf615264565b90506020028101906122d19190615658565b8a85613af6565b8784815181106122ea576122ea615264565b602002602001018181525050816001600160a01b0316856001600160a01b0316146123e5576001600160a01b0382165f90815260056020908152604080832084845290915290205460ff161561236c576040517f1f6d5aef00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0382165f8181526005602090815260408083208584529091529020805460ff1916600117905587518291908990869081106123b0576123b0615264565b60200260200101517fc4e3e09840282d09a125dc68ec6d3f9ddc391b467fbe53aad57c80dc183bb73b60405160405180910390a45b5050600101612184565b506123f98361362a565b50505095945050505050565b5f341580159061241757506001600254145b1561243557604051631841b4e160e01b815260040160405180910390fd5b816001600160a01b03811661245d57604051634e46966960e11b815260040160405180910390fd5b5f6124666133b3565b90505f805b86811015612917575f88888381811061248657612486615264565b90506020020135905061249881613460565b5f600382815481106124ac576124ac615264565b5f9182526020909120600b909102016001810154909150600160401b90046001600160a01b0316806124f45760405163c87c164160e01b815260048101849052602401610d4b565b8154600160401b900463ffffffff165f819003612540576040517ff27cfd4600000000000000000000000000000000000000000000000000000000815260048101859052602401610d4b565b600583015460018401545f9160ff90811691650100000000009004161561263457600481600581111561257557612575614c4e565b036125d6575f8080526008860160205260409020546001600160a01b038a81169116146125d1576040517f1d12a9fe00000000000000000000000000000000000000000000000000000000815260048101879052602401610d4b565b6126f1565b836001600160a01b0316896001600160a01b031614612624576040517fc9cd77cf00000000000000000000000000000000000000000000000000000000815260048101879052602401610d4b565b61262d81613fa8565b91506126f1565b84545f90612650908890600160e01b900463ffffffff166137bf565b6001870154909150640100000000900460ff1615806126805750600482600581111561267e5761267e614c4e565b145b156126955761269087828c6138f0565b6126ef565b846001600160a01b03168a6001600160a01b0316146126e3576040517fc9cd77cf00000000000000000000000000000000000000000000000000000000815260048101889052602401610d4b565b6126ec82613fa8565b92505b505b84546001600160601b036c010000000000000000000000009091041663ffffffff841602821561273d576002860154600387015461273a916001600160a01b0316908388613fe7565b90035b60018601545f906127109063ffffffff166001600160601b03841602049050808a0199508082039150818d019c508860010198508d6001600160a01b03168b6001600160a01b0316897ff5c3d0ba946ce1f61c398ccdceab30952250a5c3a614f566ec2fd5f1dabd17bf856040516127c491906001600160601b0391909116815260200190565b60405180910390a450506001850154670100000000000000900460ff161561281b576040517f3be20bf100000000000000000000000000000000000000000000000000000000815260048101879052602401610d4b565b60018501546601000000000000900460ff16806128495750600481600581111561284757612847614c4e565b145b156128d7576003868154811061286157612861615264565b5f91825260208220600b909102018181556001810180546001600160e01b031916905560028101805473ffffffffffffffffffffffffffffffffffffffff19168155600382018390556004820183905560058201805460ff19169055909190816128ce600685018261474b565b5050505061290c565b6001850180547fffffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffff166701000000000000001790555b50505050505061246b565b506001600160601b038116156129b5576004546001600160a01b039081169061296c907f000000000000000000000000430000000000000000000000000000000000000316826001600160601b0385166135e1565b6040516001600160601b03831681526001600160a01b038216907f194055900b5891c5b0c846e80054a4aad896f0756f69397a6eaeb7014193684a9060200160405180910390a2505b61168e6001600160a01b037f000000000000000000000000430000000000000000000000000000000000000316866001600160601b0387166135e1565b612a1e7f00000000000000000000000000000000000000000000000000000000000000006116c46133b3565b6001600160a01b038116612a5e576040517f140ecf0500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6004546040516001600160a01b038084169216907f523da6ae20ac3249365e93dcf61dffd12c54a455da42b245514301487fbfd939905f90a36004805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b612af27f00000000000000000000000000000000000000000000000000000000000000006116c46133b3565b60065467ffffffffffffffff600160401b909104811690821610612b42576040517f7616640100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60065460405167ffffffffffffffff8084169216907fc14524dbf6dcb0f48ded31a41c202c3dca437c6c5bc3cc6138e880cfed083703905f90a3600680547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001667ffffffffffffffff92909216919091179055565b5f60038381548110612bcb57612bcb615264565b5f91825260208083206001600160a01b03861684526009600b90930201919091019052604090205463ffffffff16905092915050565b5f612c2a60038481548110612c1857612c18615264565b905f5260205f2090600b020183614237565b9392505050565b60038181548110612c40575f80fd5b5f918252602091829020600b90910201805460018201546040805160a0810182526002850180546001600160a01b03908116835260038701549783019790975260048601549282019290925260058086015463ffffffff8087169950640100000000808804821699600160401b808a0484169a6001600160601b036c010000000000000000000000008c04169a7801000000000000000000000000000000000000000000000000810486169a600160e01b9091048616999581169860ff9582048616986501000000000083048716986601000000000000840488169867010000000000000085048916989690940496909616959394919360608501921690811115612d4d57612d4d614c4e565b6005811115612d5e57612d5e614c4e565b8152602001600482018054612d72906153be565b80601f0160208091040260200160405190810160405280929190818152602001828054612d9e906153be565b8015612de95780601f10612dc057610100808354040283529160200191612de9565b820191905f5260205f20905b815481529060010190602001808311612dcc57829003601f168201915b50505050508152505090508d565b612e237f00000000000000000000000000000000000000000000000000000000000000006116c46133b3565b60065467ffffffffffffffff90811690821611612e6c576040517f7616640100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60065460405167ffffffffffffffff80841692600160401b900416907f48752fb030a2abe76f2d8d8681d69fa9de4ec037bb3d50f9e6b81672a8fda7bb905f90a36006805467ffffffffffffffff909216600160401b027fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff909216919091179055565b5f612ef984613460565b8263ffffffff165f03612f38576040517fb405724900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f60038581548110612f4c57612f4c615264565b5f91825260208220600b90910201805490925063ffffffff1690819003612f895760405163c87c164160e01b815260048101879052602401610d4b565b8154600160401b900463ffffffff165f612fa38288615817565b90508263ffffffff168163ffffffff161115612feb576040517fbe601f7600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8354600160e01b900463ffffffff16421115613036576040517f6250c2b400000000000000000000000000000000000000000000000000000000815260048101899052602401610d4b565b5f8363ffffffff166004028863ffffffff168963ffffffff16028161305d5761305d615803565b0490505f855f0160049054906101000a900463ffffffff1690505f828201905080875f0160046101000a81548163ffffffff021916908363ffffffff1602179055505f876009015f8b6001600160a01b03166001600160a01b031681526020019081526020015f205f9054906101000a900463ffffffff168b0190508388600a015f8c6001600160a01b03166001600160a01b031681526020019081526020015f205f8282829054906101000a900463ffffffff160192506101000a81548163ffffffff021916908363ffffffff16021790555080886009015f8c6001600160a01b03166001600160a01b031681526020019081526020015f205f6101000a81548163ffffffff021916908363ffffffff16021790555084885f0160086101000a81548163ffffffff021916908363ffffffff1602179055505f885f0160189054906101000a900463ffffffff1690508a896008015f8363ffffffff1663ffffffff1681526020019081526020015f205f6101000a8154816001600160a01b0302191690836001600160a01b03160217905550828601896007015f8363ffffffff1663ffffffff1681526020019081526020015f205f6101000a81548163ffffffff021916908363ffffffff16021790555080600101905080895f0160186101000a81548163ffffffff021916908363ffffffff1602179055508763ffffffff168663ffffffff160361330f57885463ffffffff428116600160e01b027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff909216919091178a5560018a0180547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffff166401000000001790558881169083160361330f576001890180547fffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffffff16650100000000001790555b8b63ffffffff16895f01600c9054906101000a90046001600160601b031602995083870163ffffffff168b6001600160a01b03168e7f8772ec5268199c7b7dbfea9344db6e4dcdf075620f23f073c29aa98a7678356d8f8e8a60405161339b9392919063ffffffff93841681526001600160601b03929092166020830152909116604082015260600190565b60405180910390a45050505050505050509392505050565b5f6133bc614330565b905090565b6040516001600160a01b038085166024830152831660448201526064810182905261345a9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b0319909316929092179091526143a3565b50505050565b600354811061349b576040517fd9fd6a1c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50565b6040517ffa95b13900000000000000000000000000000000000000000000000000000000815263ffffffff821660048201525f907f000000000000000000000000085827915e1e1a233c7543bc30ad08fda9ad57576001600160a01b03169063fa95b139906024016040805180830381865afa158015613520573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906135449190615834565b915050805f0361359a5762015180820163ffffffff164211613595576040517f128471ac00000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b505050565b62015180820163ffffffff168111613595576040517fcc1bf05800000000000000000000000000000000000000000000000000000000815260048101849052602401610d4b565b6040516001600160a01b0383166024820152604481018290526135959084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161340e565b345f036136345750565b6002547ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd8101613690576040517fd5bcee7e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b815f036136a957600281036136a55760036002555b5050565b60018114806136b85750348214155b156136a557604051631841b4e160e01b815260040160405180910390fd5b6136e08282614489565b6136a5576040517fc183bcef00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606060ff83146137305761372983614535565b9050610893565b81805461373c906153be565b80601f0160208091040260200160405190810160405280929190818152602001828054613768906153be565b80156137b35780601f1061378a576101008083540402835291602001916137b3565b820191905f5260205f20905b81548152906001019060200180831161379657829003601f168201915b50505050509050610893565b6040517ffa95b13900000000000000000000000000000000000000000000000000000000815263ffffffff821660048201525f9081906001600160a01b037f000000000000000000000000085827915e1e1a233c7543bc30ad08fda9ad5757169063fa95b139906024016040805180830381865afa158015613843573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906138679190615834565b90925090505f8190036138a8576040517e4337df00000000000000000000000000000000000000000000000000000000815260048101859052602401610d4b565b62015180830163ffffffff1681111561208b576040517f6250c2b400000000000000000000000000000000000000000000000000000000815260048101859052602401610d4b565b5f6003848154811061390457613904615264565b905f5260205f2090600b020190505f610100858161392457613924615803565b8354919006915084821b61010083900386901c17905f90613974908590600160401b810463ffffffff90811664010000000090920481169190910116848161396e5761396e615803565b06614237565b9050806001600160a01b0316856001600160a01b0316146139c4576040517f1d12a9fe00000000000000000000000000000000000000000000000000000000815260048101889052602401610d4b565b50505050505050565b5f306001600160a01b037f000000000000000000000000a247cff2a50de0328a0a5bdd0c563bd44b1a8af916148015613a2557507f0000000000000000000000000000000000000000000000000000000000013e3146145b15613a4f57507fb0cdaee08ef919dd1051901b9514d28a969f6fc62e4ed64e4f0871fe2261476990565b6133bc604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f15c6d7d2e55a045b0293879a9f8198d765be1307ba96029e91ec5840f0cc6ff9918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b6006545f9067ffffffffffffffff16613b156060860160408701614d43565b63ffffffff161015613b63576006546040517f0c3aad9700000000000000000000000000000000000000000000000000000000815267ffffffffffffffff9091166004820152602401610d4b565b600654600160401b900467ffffffffffffffff16613b876060860160408701614d43565b63ffffffff161115613bdb576006546040517fa78341a2000000000000000000000000000000000000000000000000000000008152600160401b90910467ffffffffffffffff166004820152602401610d4b565b613be86020850185614d43565b63ffffffff165f03613c26576040517f3cfbac5700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b633b9aca00613c386020860186614d43565b63ffffffff161115613c76576040517f09d9a0c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613c866040850160208601615856565b6001600160601b03165f03613cc7576040517f1d133e9000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f613cd86080860160608701614b83565b6001600160a01b031603613d18576040517f49e27cff00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6b033b2e3c9fd0803ce8000000613d326020860186614d43565b63ffffffff16613d486040870160208801615856565b613d52919061586f565b6001600160601b03161115613d93576040517fba7848b900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600380546001810182555f91909152600b81027fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b81019086907fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85d01613df982826159a3565b50613e0c90506080860160608701614b83565b6001820180546001600160a01b0392909216600160401b027fffffffff0000000000000000000000000000000000000000ffffffffffffffff909216919091179055613e5b6020860186614d43565b815463ffffffff191663ffffffff91909116178155613e806040860160208701615856565b81547fffffffffffffffff000000000000000000000000ffffffffffffffffffffffff166c010000000000000000000000006001600160601b03929092169190910217815560018101805463ffffffff191663ffffffff86161790555f613eed6060870160408801614d43565b825463ffffffff4292909201918216600160e01b027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff9091161783559050613f376080870160608801614b83565b6001600160a01b03908116908516847ff806f15c2cacb4703b6edc897c2cbe33990d7d191bd57bbf4a8ae9ab2315bf758a613f7560208c018c614d43565b613f8560408d0160208e01615856565b87604051613f969493929190615a43565b60405180910390a45050949350505050565b5f80826005811115613fbc57613fbc614c4e565b1480613fd957506001826005811115613fd757613fd7614c4e565b145b15613fe2575060015b919050565b6040517ff533b8020000000000000000000000000000000000000000000000000000000081526001600160a01b038581166004830152602482018590526001600160601b03841660448301525f91829182917f000000000000000000000000d388d812c1ce2ce7c46d797684ba912de65cd4149091169063f533b802906064015f604051808303815f875af1158015614082573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526140a99190810190615b3e565b915091505f5b825181101561422c575f8282815181106140cb576140cb615264565b602002602001015190505f6001600160a01b03168483815181106140f1576140f1615264565b60200260200101516001600160a01b03161415801561413b5750856001600160a01b031684838151811061412757614127615264565b60200260200101516001600160a01b031614155b801561414f57506001600160601b03811615155b15614223576141b484838151811061416957614169615264565b6020026020010151826001600160601b03167f00000000000000000000000043000000000000000000000000000000000000036001600160a01b03166135e19092919063ffffffff16565b80850194508382815181106141cb576141cb615264565b60200260200101516001600160a01b03167fd5a02d893cdcfe3f25286206f6f6592510f6a8f56272801f6c28d347625f317e8260405161421a91906001600160601b0391909116815260200190565b60405180910390a25b506001016140af565b505050949350505050565b81545f907801000000000000000000000000000000000000000000000000900463ffffffff16801580614288575063ffffffff5f19820181165f908152600786016020526040902054811690841610155b15614296575f915050610893565b5f5b8163ffffffff168163ffffffff161015614308575f6142ba6002838518615bfd565b6142c690838516615817565b63ffffffff8082165f908152600789016020526040902054919250808716911611156142f457809250614302565b6142ff816001615817565b91505b50614298565b63ffffffff165f9081526008850160205260409020546001600160a01b031691505092915050565b5f366014336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614801561436c5750808210155b1561439b575f3661437d83856154ea565b6143889282906154fd565b61439191615c2b565b60601c9250505090565b339250505090565b5f6143f7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166145729092919063ffffffff16565b905080515f14806144175750808060200190518101906144179190615c71565b6135955760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610d4b565b6040517f91d14854000000000000000000000000000000000000000000000000000000008152600481018390526001600160a01b0382811660248301525f917f000000000000000000000000b62339c4ccda62c920c75bcc5fd43f07431dfde4909116906391d1485490604401602060405180830381865afa158015614511573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c2a9190615c71565b60605f61454183614580565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b6060610c0684845f856145c0565b5f60ff8216601f811115610893576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6060824710156146385760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610d4b565b5f80866001600160a01b03168587604051614653919061558c565b5f6040518083038185875af1925050503d805f811461468d576040519150601f19603f3d011682016040523d82523d5f602084013e614692565b606091505b50915091506146a3878383876146ae565b979650505050505050565b6060831561471c5782515f03614715576001600160a01b0385163b6147155760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610d4b565b5081610c06565b610c0683838151156147315781518083602001fd5b8060405162461bcd60e51b8152600401610d4b9190614c3c565b508054614757906153be565b5f825580601f10614766575050565b601f0160209004905f5260205f209081019061349b91905b80821115614791575f815560010161477e565b5090565b5f602082840312156147a5575f80fd5b81356001600160e01b031981168114612c2a575f80fd5b634e487b7160e01b5f52604160045260245ffd5b60405160a0810167ffffffffffffffff811182821017156147f3576147f36147bc565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715614822576148226147bc565b604052919050565b5f67ffffffffffffffff821115614843576148436147bc565b5060051b60200190565b5f82601f83011261485c575f80fd5b8135602061487161486c8361482a565b6147f9565b82815260059290921b8401810191818101908684111561488f575f80fd5b8286015b848110156148aa5780358352918301918301614893565b509695505050505050565b5f8083601f8401126148c5575f80fd5b50813567ffffffffffffffff8111156148dc575f80fd5b6020830191508360208260051b85010111156148f6575f80fd5b9250929050565b6001600160a01b038116811461349b575f80fd5b8035613fe2816148fd565b5f8083601f84011261492c575f80fd5b50813567ffffffffffffffff811115614943575f80fd5b6020830191508360208285010111156148f6575f80fd5b5f805f805f806080878903121561496f575f80fd5b863567ffffffffffffffff80821115614986575f80fd5b6149928a838b0161484d565b975060208901359150808211156149a7575f80fd5b6149b38a838b016148b5565b9097509550604089013591506149c8826148fd565b909350606088013590808211156149dd575f80fd5b506149ea89828a0161491c565b979a9699509497509295939492505050565b5f67ffffffffffffffff821115614a1557614a156147bc565b50601f01601f191660200190565b5f82601f830112614a32575f80fd5b8135614a4061486c826149fc565b818152846020838601011115614a54575f80fd5b816020850160208301375f918101602001919091529392505050565b5f805f8060808587031215614a83575f80fd5b8435614a8e816148fd565b93506020850135614a9e816148fd565b925060408501359150606085013567ffffffffffffffff811115614ac0575f80fd5b614acc87828801614a23565b91505092959194509250565b5f8060408385031215614ae9575f80fd5b8235614af4816148fd565b946020939093013593505050565b5f8060408385031215614b13575f80fd5b823591506020830135614b25816148fd565b809150509250929050565b5f805f60408486031215614b42575f80fd5b833567ffffffffffffffff811115614b58575f80fd5b614b64868287016148b5565b9094509250506020840135614b78816148fd565b809150509250925092565b5f60208284031215614b93575f80fd5b8135612c2a816148fd565b5f805f60408486031215614bb0575f80fd5b8335614bbb816148fd565b9250602084013567ffffffffffffffff811115614bd6575f80fd5b614be28682870161491c565b9497909650939450505050565b5f5b83811015614c09578181015183820152602001614bf1565b50505f910152565b5f8151808452614c28816020860160208601614bef565b601f01601f19169290920160200192915050565b602081525f612c2a6020830184614c11565b634e487b7160e01b5f52602160045260245ffd5b60068110614c7e57634e487b7160e01b5f52602160045260245ffd5b9052565b6001600160a01b03815116825260208101516020830152604081015160408301525f6060820151614cb66060850182614c62565b50608082015160a06080850152610c0660a0850182614c11565b5f602080830181845280855180835260408601915060408160051b87010192508387015f5b82811015614d2357603f19888603018452614d11858351614c82565b94509285019290850190600101614cf5565b5092979650505050505050565b803563ffffffff81168114613fe2575f80fd5b5f60208284031215614d53575f80fd5b612c2a82614d30565b5f8151808452602080850194508084015f5b83811015614d8a57815187529582019590820190600101614d6e565b509495945050505050565b7fff000000000000000000000000000000000000000000000000000000000000008816815260e060208201525f614dcf60e0830189614c11565b8281036040840152614de18189614c11565b90508660608401526001600160a01b03861660808401528460a084015282810360c0840152614e108185614d5c565b9a9950505050505050505050565b5f8060408385031215614e2f575f80fd5b82359150614e3f60208401614d30565b90509250929050565b5f805f805f805f805f8060c08b8d031215614e61575f80fd5b8a3567ffffffffffffffff80821115614e78575f80fd5b614e848e838f016148b5565b909c509a5060208d0135915080821115614e9c575f80fd5b614ea88e838f016148b5565b909a509850889150614ebc60408e01614d30565b975060608d0135915080821115614ed1575f80fd5b614edd8e838f016148b5565b9097509550859150614ef160808e01614911565b945060a08d0135915080821115614f06575f80fd5b50614f138d828e0161491c565b915080935050809150509295989b9194979a5092959850565b604081525f614f3e6040830185614d5c565b90506001600160601b03831660208301529392505050565b5f8060208385031215614f67575f80fd5b823567ffffffffffffffff811115614f7d575f80fd5b614f89858286016148b5565b90969095509350505050565b5f602080830181845280855180835260408601915060408160051b87010192508387015f5b82811015614d2357603f19888603018452614fd6858351614c11565b94509285019290850190600101614fba565b5f805f805f60608688031215614ffc575f80fd5b853567ffffffffffffffff80821115615013575f80fd5b61501f89838a016148b5565b90975095506020880135915080821115615037575f80fd5b50615044888289016148b5565b9094509250615057905060408701614d30565b90509295509295909350565b602081525f612c2a6020830184614d5c565b5f805f805f60a08688031215615089575f80fd5b8535615094816148fd565b945060208601356150a4816148fd565b9350604086013567ffffffffffffffff808211156150c0575f80fd5b6150cc89838a0161484d565b945060608801359150808211156150e1575f80fd5b6150ed89838a0161484d565b93506080880135915080821115615102575f80fd5b5061510f88828901614a23565b9150509295509295909350565b5f6020828403121561512c575f80fd5b813567ffffffffffffffff81168114612c2a575f80fd5b5f60208284031215615153575f80fd5b5035919050565b63ffffffff8e811682528d811660208301528c811660408301526001600160601b038c1660608301528a16608082015263ffffffff891660a082015263ffffffff881660c082015286151560e08201528515156101008201528415156101208201528315156101408201526001600160a01b0383166101608201526101a06101808201525f6151ed6101a0830184614c82565b9f9e505050505050505050505050505050565b5f805f805f60a08688031215615214575f80fd5b853561521f816148fd565b9450602086013561522f816148fd565b93506040860135925060608601359150608086013567ffffffffffffffff811115615258575f80fd5b61510f88828901614a23565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b6001600160601b0381811683821601908082111561208b5761208b615278565b5f805f805f60a086880312156152c0575f80fd5b8535945060208601359350604086013560ff811681146152de575f80fd5b94979396509394606081013594506080013592915050565b81835281816020850137505f602082840101525f6020601f19601f840116840101905092915050565b6001600160a01b0384168152604060208201525f6153416040830184866152f6565b95945050505050565b5f82601f830112615359575f80fd5b815161536761486c826149fc565b81815284602083860101111561537b575f80fd5b610c06826020830160208701614bef565b5f6020828403121561539c575f80fd5b815167ffffffffffffffff8111156153b2575f80fd5b610c068482850161534a565b600181811c908216806153d257607f821691505b6020821081036153f057634e487b7160e01b5f52602260045260245ffd5b50919050565b606081525f6154086060830186614c82565b6001600160a01b0394851660208401529290931660409091015292915050565b6006811061349b575f80fd5b5f60208284031215615444575f80fd5b815167ffffffffffffffff8082111561545b575f80fd5b9083019060a0828603121561546e575f80fd5b6154766147d0565b8251615481816148fd565b80825250602083015160208201526040830151604082015260608301516154a781615428565b60608201526080830151828111156154bd575f80fd5b6154c98782860161534a565b60808301525095945050505050565b602081525f612c2a6020830184614c82565b8181038181111561089357610893615278565b5f808585111561550b575f80fd5b83861115615517575f80fd5b5050820193919092039150565b5f808335601e19843603018112615539575f80fd5b83018035915067ffffffffffffffff821115615553575f80fd5b6020019150368190038213156148f6575f80fd5b828482375f8382015f81528351615582818360208801614bef565b0195945050505050565b5f825161559d818460208701614bef565b9190910192915050565b5f82357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6183360301811261559d575f80fd5b5f60a082360312156155e9575f80fd5b6155f16147d0565b82356155fc816148fd565b808252506020830135602082015260408301356040820152606083013561562281615428565b6060820152608083013567ffffffffffffffff811115615640575f80fd5b61564c36828601614a23565b60808301525092915050565b5f82357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4183360301811261559d575f80fd5b80356001600160601b0381168114613fe2575f80fd5b5f808335601e198436030181126156b5575f80fd5b830160208101925035905067ffffffffffffffff8111156156d4575f80fd5b8036038213156148f6575f80fd5b60c081525f6156f460c0830189614c82565b828103602084015263ffffffff8061570b8a614d30565b1682526001600160601b0361572260208b0161568a565b1660208301528061573560408b01614d30565b16604083015250606088013561574a816148fd565b6001600160a01b0316606082015261576460808901614911565b6001600160a01b0316608082015261577f60a08901896156a0565b60c060a084015261579460c0840182846152f6565b93505050508560408301526157b460608301866001600160a01b03169052565b8360808301526146a360a08301846001600160a01b03169052565b5f805f606084860312156157e1575f80fd5b83516157ec816148fd565b602085015160409095015190969495509392505050565b634e487b7160e01b5f52601260045260245ffd5b63ffffffff81811683821601908082111561208b5761208b615278565b5f8060408385031215615845575f80fd5b505080516020909101519092909150565b5f60208284031215615866575f80fd5b612c2a8261568a565b6001600160601b0381811683821602808216919082811461589257615892615278565b505092915050565b601f821115613595575f81815260208120601f850160051c810160208610156158c05750805b601f850160051c820191505b818110156158df578281556001016158cc565b505050505050565b67ffffffffffffffff8311156158ff576158ff6147bc565b6159138361590d83546153be565b8361589a565b5f601f841160018114615944575f851561592d5750838201355b5f19600387901b1c1916600186901b17835561599c565b5f83815260209020601f19861690835b828110156159745786850135825560209485019460019092019101615954565b5086821015615990575f1960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b81356159ae816148fd565b6001600160a01b03811673ffffffffffffffffffffffffffffffffffffffff198354161782555060208201356001820155604082013560028201556003810160608301356159fb81615428565b60068110615a1757634e487b7160e01b5f52602160045260245ffd5b60ff1982541660ff821681178355505050615a356080830183615524565b61345a8183600486016158e7565b608081525f8535615a53816148fd565b6001600160a01b03166080830152602086013560a0830152604086013560c08301526060860135615a8381615428565b615a9060e0840182614c62565b50615a9e60808701876156a0565b60a0610100850152615ab5610120850182846152f6565b63ffffffff97881660208601526001600160601b039690961660408501525050509216606090920191909152919050565b5f82601f830112615af5575f80fd5b81516020615b0561486c8361482a565b82815260059290921b84018101918181019086841115615b23575f80fd5b8286015b848110156148aa5780518352918301918301615b27565b5f8060408385031215615b4f575f80fd5b825167ffffffffffffffff80821115615b66575f80fd5b818501915085601f830112615b79575f80fd5b81516020615b8961486c8361482a565b82815260059290921b84018101918181019089841115615ba7575f80fd5b948201945b83861015615bce578551615bbf816148fd565b82529482019490820190615bac565b91880151919650909350505080821115615be6575f80fd5b50615bf385828601615ae6565b9150509250929050565b5f63ffffffff80841680615c1f57634e487b7160e01b5f52601260045260245ffd5b92169190910492915050565b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000081358181169160148510156158925760149490940360031b84901b1690921692915050565b5f60208284031215615c81575f80fd5b81518015158114612c2a575f80fdfea2646970667358221220868f24ff406c482b5c91247d508a52b1ac68ef616cb913d038bed9905109519564736f6c63430008150033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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