POL Price: $0.379276 (+0.73%)
 

Overview

POL Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 POL

POL Value

$0.00

Token Holdings

Sponsored

Transaction Hash
Method
Block
From
To
Deploy Wave548427322024-03-19 14:09:05177 days ago1710857345IN
0x8e7B531E...1345Ce5e7
0 POL0.5762357177.21
Deploy Wave548427192024-03-19 14:08:37177 days ago1710857317IN
0x8e7B531E...1345Ce5e7
0 POL0.41169912126.61
Deploy Wave548427002024-03-19 14:07:57177 days ago1710857277IN
0x8e7B531E...1345Ce5e7
0 POL0.37362159114.9
Deploy Wave548425042024-03-19 14:00:29177 days ago1710856829IN
0x8e7B531E...1345Ce5e7
0 POL0.32936578102.70880974
Deploy Wave540691522024-02-28 19:09:45197 days ago1709147385IN
0x8e7B531E...1345Ce5e7
0 POL0.2928538791.32436852
Deploy Wave540602122024-02-28 13:43:56197 days ago1709127836IN
0x8e7B531E...1345Ce5e7
0 POL0.46873502145.15654909
Deploy Wave540521732024-02-28 8:55:39197 days ago1709110539IN
0x8e7B531E...1345Ce5e7
0 POL0.4620681144.09314557
Deploy Wave537902122024-02-21 16:12:58204 days ago1708531978IN
0x8e7B531E...1345Ce5e7
0 POL0.69587513216.99714841
Deploy Wave537829042024-02-21 11:50:49204 days ago1708516249IN
0x8e7B531E...1345Ce5e7
0 POL0.80551087247.72
Deploy Wave537465022024-02-20 13:16:24205 days ago1708434984IN
0x8e7B531E...1345Ce5e7
0 POL0.62546708192.3508555
Deploy Wave535434862024-02-15 8:21:54210 days ago1707985314IN
0x8e7B531E...1345Ce5e7
0 POL0.2886257290.01023143
Deploy Wave535078862024-02-14 10:13:49211 days ago1707905629IN
0x8e7B531E...1345Ce5e7
0 POL0.2307722271.9665405
Deploy Wave534333112024-02-12 13:22:13213 days ago1707744133IN
0x8e7B531E...1345Ce5e7
0 POL0.35455642110.56834757
Deploy Wave534302872024-02-12 11:34:50213 days ago1707737690IN
0x8e7B531E...1345Ce5e7
0 POL0.1433292644.07680709
Deploy Wave532320152024-02-07 12:36:03218 days ago1707309363IN
0x8e7B531E...1345Ce5e7
0 POL0.121704537.42838869
Deploy Wave529736472024-01-31 20:15:56225 days ago1706732156IN
0x8e7B531E...1345Ce5e7
0 POL0.3003835992.37265649
Deploy Wave529736402024-01-31 20:15:42225 days ago1706732142IN
0x8e7B531E...1345Ce5e7
0 POL0.3071417694.45090059
Deploy Wave529734462024-01-31 20:07:46225 days ago1706731666IN
0x8e7B531E...1345Ce5e7
0 POL0.40841219125.59221479
Deploy Wave529729692024-01-31 19:49:08225 days ago1706730548IN
0x8e7B531E...1345Ce5e7
0 POL0.243438774.8612117
Deploy Wave529729252024-01-31 19:47:34225 days ago1706730454IN
0x8e7B531E...1345Ce5e7
0 POL0.2308650770.9946254
Deploy Wave526604522024-01-23 14:07:24233 days ago1706018844IN
0x8e7B531E...1345Ce5e7
0 POL1.10862625331.49526868
Deploy Wave526599952024-01-23 13:48:32233 days ago1706017712IN
0x8e7B531E...1345Ce5e7
0 POL0.2505994375.04082562
Deploy Wave526599912024-01-23 13:48:24233 days ago1706017704IN
0x8e7B531E...1345Ce5e7
0 POL0.2494552474.59152485
Deploy Wave526207762024-01-22 13:10:24234 days ago1705929024IN
0x8e7B531E...1345Ce5e7
0 POL0.43512722129.42280036
Deploy Wave526179192024-01-22 11:21:29234 days ago1705922489IN
0x8e7B531E...1345Ce5e7
0 POL0.2349926170.36693154
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To
548427322024-03-19 14:09:05177 days ago1710857345
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
548427192024-03-19 14:08:37177 days ago1710857317
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
548427002024-03-19 14:07:57177 days ago1710857277
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
548425042024-03-19 14:00:29177 days ago1710856829
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
540691522024-02-28 19:09:45197 days ago1709147385
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
540602122024-02-28 13:43:56197 days ago1709127836
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
540521732024-02-28 8:55:39197 days ago1709110539
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
537902122024-02-21 16:12:58204 days ago1708531978
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
537829042024-02-21 11:50:49204 days ago1708516249
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
537465022024-02-20 13:16:24205 days ago1708434984
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
535434862024-02-15 8:21:54210 days ago1707985314
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
535078862024-02-14 10:13:49211 days ago1707905629
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
534333112024-02-12 13:22:13213 days ago1707744133
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
534302872024-02-12 11:34:50213 days ago1707737690
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
532320152024-02-07 12:36:03218 days ago1707309363
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
529736472024-01-31 20:15:56225 days ago1706732156
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
529736402024-01-31 20:15:42225 days ago1706732142
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
529734462024-01-31 20:07:46225 days ago1706731666
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
529729692024-01-31 19:49:08225 days ago1706730548
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
529729252024-01-31 19:47:34225 days ago1706730454
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
526604522024-01-23 14:07:24233 days ago1706018844
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
526599952024-01-23 13:48:32233 days ago1706017712
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
526599912024-01-23 13:48:24233 days ago1706017704
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
526207762024-01-22 13:10:24234 days ago1705929024
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
526179192024-01-22 11:21:29234 days ago1705922489
0x8e7B531E...1345Ce5e7
 Contract Creation0 POL
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
WaveFactory

Compiler Version
v0.8.21+commit.d9974bed

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 20 : WaveFactory.sol
// SPDX-License-Identifier: GPL-2.0
pragma solidity ^0.8.21;
pragma abicoder v2;

import {Ownable} from "lib/openzeppelin-contracts/contracts/access/Ownable.sol";
import {WaveContract} from "./WaveContract.sol";
import {IWaveFactory} from "../interfaces/IWaveFactory.sol";
import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";

contract WaveFactory is Ownable, IWaveFactory {
    address[] public waves;
    address public keeper;
    address public trustedForwarder;
    address public verifier;
    address public raffleManager;
    mapping(address => bool) public isRaffleWave;

    error TooManyRewards();

    event WaveCreated(address indexed wave, address indexed owner);

    constructor(address _keeper, address _trustedForwarder, address _verifier, address _raffleManager) Ownable() {
        keeper = _keeper;
        trustedForwarder = _trustedForwarder;
        verifier = _verifier;
        raffleManager = _raffleManager;
    }

    /// @dev changes the keeper associated with the factory
    /// @param _keeper address of the new keeper
    function changeKeeper(address _keeper) public onlyOwner {
        keeper = _keeper;
    }

    /// @dev changes the trusted forwarder for EIP-2771 meta transactions
    /// @param _trustedForwarder address of the new trusted forwarder
    function changeTrustedForwarder(address _trustedForwarder) public onlyOwner {
        trustedForwarder = _trustedForwarder;
    }

    /// @dev changes the verifier for EIP-712 signatures
    /// @param _verifier address of the new verifier
    function changeVerifier(address _verifier) public onlyOwner {
        verifier = _verifier;
    }

    /// @dev changes the raffle manager for the factory
    /// @param _raffleManager address of the new raffle manager
    function changeRaffleManager(address _raffleManager) public onlyOwner {
        raffleManager = _raffleManager;
    }

    /// @inheritdoc IWaveFactory
    function deployWave(
        string memory _name,
        string memory _symbol,
        string memory _baseURI,
        uint256 _startTimestamp,
        uint256 _endTimestamp,
        bool _isSoulbound,
        IWaveFactory.TokenRewards memory _tokenRewards
    ) public {
        WaveContract wave = new WaveContract(
            _name,
            _symbol,
            _baseURI,
            _startTimestamp,
            _endTimestamp,
            _isSoulbound,
            trustedForwarder,
            _tokenRewards
        );

        waves.push(address(wave));
        wave.transferOwnership(msg.sender);

        if (_tokenRewards.isRaffle) {
            isRaffleWave[address(wave)] = true;
        }

        if (_tokenRewards.token != address(0)) {
            _initiateRewards(_tokenRewards, address(wave));
        }

        emit WaveCreated(address(wave), msg.sender);
    }

    /// @notice funds the campaign with the specified token rewards
    /// @param _tokenRewards array of token rewards
    /// @param wave address of the campaign
    function _initiateRewards(IWaveFactory.TokenRewards memory _tokenRewards, address wave) internal {
        IERC20(_tokenRewards.token).transferFrom(
            msg.sender, wave, _tokenRewards.amountPerUser * _tokenRewards.rewardsLeft
        );
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

File 3 of 20 : WaveContract.sol
// SPDX-License-Identifier: GPL-2.0
pragma solidity ^0.8.21;
pragma abicoder v2;

import {Strings} from "lib/openzeppelin-contracts/contracts/utils/Strings.sol";
import {Ownable} from "lib/openzeppelin-contracts/contracts/access/Ownable.sol";
import {ERC2771Context, Context} from "lib/openzeppelin-contracts/contracts/metatx/ERC2771Context.sol";
import {IWaveFactory} from "../interfaces/IWaveFactory.sol";
import {IWaveContract} from "../interfaces/IWaveContract.sol";
import {IRaffleManager} from "../interfaces/IRaffleManager.sol";
import {ERC721} from "lib/openzeppelin-contracts/contracts/token/ERC721/ERC721.sol";
import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {SignatureVerifier} from "../helpers/SignatureVerifier.sol";

contract WaveContract is ERC2771Context, Ownable, ERC721, SignatureVerifier, IWaveContract {
    IWaveFactory public factory;

    uint256 public lastId;
    uint256 public startTimestamp;
    uint256 public endTimestamp;
    uint256 public mintsPerClaim = 1;
    uint256 public randomNumber;

    string _metadataBaseURI;

    bool public customMetadata;
    bool public isSoulbound;
    bool public isERC20Campaign;
    bool public raffleCompleted;
    bool public shouldVerifySignature = true;

    mapping(address => bool) _claimed;
    mapping(uint256 => bool) public tokenIdToHasWon;
    mapping(uint256 => bool) public tokenIdToDisqualified;
    uint256 public disqualifiedTokenIdsCount;

    IWaveFactory.TokenRewards public tokenRewards;

    error OnlyRaffleFulfillers();
    error OnlyAuthorized();
    error OnlyGovernance();
    error InvalidTimings();
    error CampaignNotActive();
    error CampaignNotEnded();
    error RewardAlreadyClaimed();
    error PermitDeadlineExpired();
    error NotTransferrable();

    event Claimed(address indexed user, uint256 indexed tokenId);
    event FCFSAwarded(address indexed user, address indexed token, uint256 amount);
    event RaffleWon(address indexed user, address indexed token, uint256 amount);
    event RaffleStarted(address indexed user);
    event RaffleCompleted();
    event CampaignForceEnded();
    event FundsWithdrawn(address indexed token, uint256 indexed amount);

    modifier onlyGovernance() {
        if (_msgSender() != factory.keeper()) {
            revert OnlyGovernance();
        }
        _;
    }

    modifier onlyAuthorized() {
        if (_msgSender() != factory.keeper() && _msgSender() != owner()) {
            revert OnlyAuthorized();
        }
        _;
    }

    modifier onlyRaffleFulfillers() {
        if (_msgSender() != factory.raffleManager() && _msgSender() != factory.keeper() && _msgSender() != owner()) {
            revert OnlyRaffleFulfillers();
        }
        _;
    }

    modifier onlyActive() {
        if (block.timestamp < startTimestamp || block.timestamp > endTimestamp) {
            revert CampaignNotActive();
        }
        _;
    }

    modifier onlyEnded() {
        if (block.timestamp < endTimestamp) revert CampaignNotEnded();
        _;
    }

    constructor(
        string memory _name,
        string memory _symbol,
        string memory _uri,
        uint256 _startTimestamp,
        uint256 _endTimestamp,
        bool _isSoulbound,
        address _trustedForwarder,
        IWaveFactory.TokenRewards memory _tokenRewards
    ) ERC2771Context(_trustedForwarder) Ownable() ERC721(_name, _symbol) SignatureVerifier(_name) {
        if (_startTimestamp > _endTimestamp || _endTimestamp < block.timestamp) {
            revert InvalidTimings();
        }

        factory = IWaveFactory(_msgSender());
        _metadataBaseURI = _uri;
        startTimestamp = _startTimestamp;
        endTimestamp = _endTimestamp;
        isSoulbound = _isSoulbound;
        tokenRewards = _tokenRewards;

        if (_tokenRewards.token != address(0)) isERC20Campaign = true;
    }

    /// @inheritdoc IWaveContract
    function changeBaseURI(string calldata _uri, bool _customMetadata) public onlyAuthorized {
        _metadataBaseURI = _uri;
        customMetadata = _customMetadata;
    }

    /// @inheritdoc IWaveContract
    function setStartTimestamp(uint256 _startTimestamp) public onlyAuthorized {
        require(block.timestamp < _startTimestamp && _startTimestamp < endTimestamp, "Invalid start timestamp");
        startTimestamp = _startTimestamp;
    }

    /// @inheritdoc IWaveContract
    function setEndTimestamp(uint256 _endTimestamp) public onlyAuthorized {
        require(_endTimestamp > block.timestamp && _endTimestamp > startTimestamp, "Invalid end timestamp");
        endTimestamp = _endTimestamp;
    }

    /// @dev set the `shouldVerifySignature` boolean
    function setVerifySignature(bool _shouldVerifySignature) public onlyGovernance {
        shouldVerifySignature = _shouldVerifySignature;
    }

    /// @dev set the `isERC20Campaign` boolean
    function setIsERC20Campaign(bool _isERC20Campaign) public onlyGovernance {
        isERC20Campaign = _isERC20Campaign;
    }

    /// @dev change the number of mints per claim with the specified number
    function setMintsPerClaim(uint256 _mintsPerClaim) public onlyGovernance {
        mintsPerClaim = _mintsPerClaim;
    }

    /// @dev change to token rewards parameters
    function setTokenRewards(IWaveFactory.TokenRewards calldata _tokenRewards) public onlyGovernance {
        tokenRewards = _tokenRewards;
    }

    /// @inheritdoc IWaveContract
    function endCampaign() public onlyActive onlyAuthorized {
        endTimestamp = block.timestamp;
        emit CampaignForceEnded();
    }

    /// @inheritdoc IWaveContract
    function withdrawFunds() public onlyEnded {
        if (tokenRewards.isRaffle) {
            require(
                raffleCompleted || _isGovernance(),
                "Can withdraw raffle funds only if raffle is completed or governance requested it"
            );
        }
        _returnTokenToOwner(IERC20(tokenRewards.token));
    }

    /// @notice allow to disqualify or requalify the `tokenIds` to win raffle rewards
    /// @param tokenIds the token ids to disqualify or requalify
    /// @param areDisqualified whether `tokenIds` should be disqualified or requalified
    function qualifyTokenIds(uint256[] calldata tokenIds, bool areDisqualified) public onlyAuthorized {
        require(tokenRewards.isRaffle, "Can qualify token ids only if raffle wave");
        uint256 qualifiedUsersCount;

        for (uint256 i = 0; i < tokenIds.length; i++) {
            uint256 tokenId = tokenIds[i];
            require(tokenId != 0 && tokenId <= lastId, "Invalid tokenId to qualify");
            // @dev increment the counter only if
            // the tokenId is not alredy set with the right qualification
            if (!tokenIdToDisqualified[tokenId] == areDisqualified) {
                tokenIdToDisqualified[tokenId] = areDisqualified;
                qualifiedUsersCount++;
            }
        }

        disqualifiedTokenIdsCount = areDisqualified
            ? disqualifiedTokenIdsCount + qualifiedUsersCount
            : disqualifiedTokenIdsCount - qualifiedUsersCount;
    }

    /// @inheritdoc IWaveContract
    function claim(uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtual onlyActive {
        if (_claimed[_msgSender()]) {
            revert RewardAlreadyClaimed();
        }
        if (block.timestamp > deadline) revert PermitDeadlineExpired();

        if (shouldVerifySignature) {
            _verifySignature(_msgSender(), deadline, v, r, s, factory.verifier());
        }

        for (uint256 i = 0; i < mintsPerClaim; i++) {
            _mintBadge(_msgSender());
        }

        if (isERC20Campaign && !tokenRewards.isRaffle) {
            _emitERC20Rewards(_msgSender());
        }
    }

    /// @inheritdoc IWaveContract
    function startRaffle() public onlyEnded {
        require(!raffleCompleted, "Raffle already done");
        require(tokenRewards.isRaffle, "Not a raffle wave");

        emit RaffleStarted(_msgSender());
        address raffleManager = factory.raffleManager();
        IRaffleManager(raffleManager).makeRequestUint256();
    }

    /// @inheritdoc IWaveContract
    function fulfillRaffle(uint256 _randomNumber) public onlyEnded onlyRaffleFulfillers {
        require(randomNumber == 0, "Random number has already been extracted");
        randomNumber = _randomNumber;
    }

    /// @inheritdoc IWaveContract
    function executeRaffle() public onlyEnded {
        require(!raffleCompleted, "Raffle already done");
        require(randomNumber != 0, "Random number was not extracted yet");

        address tokenAddress = tokenRewards.token;
        uint256 amountPerUser = tokenRewards.amountPerUser;
        uint256 rewardsLeft = tokenRewards.rewardsLeft;

        uint256 eligibleTokenIdsCount = lastId - disqualifiedTokenIdsCount;
        uint256 rewardsToAssign = eligibleTokenIdsCount < rewardsLeft ? eligibleTokenIdsCount : rewardsLeft;

        IERC20 token = IERC20(tokenAddress);

        uint256 counter = 0;

        for (uint256 assigned = 0; assigned < rewardsToAssign; assigned++) {
            uint256 tokenId;
            do {
                tokenId = (uint256(keccak256(abi.encodePacked(randomNumber, counter))) % lastId) + 1;
                counter++;
                // @dev skip disqualified users
                if (tokenIdToDisqualified[tokenId]) continue;
            } while (tokenIdToHasWon[tokenId]);

            tokenIdToHasWon[tokenId] = true;
            address winner = ownerOf(tokenId);
            token.transfer(winner, amountPerUser);
            emit RaffleWon(winner, tokenAddress, amountPerUser);
        }

        raffleCompleted = true;
        emit RaffleCompleted();
        withdrawFunds();
    }

    /// @notice returns the URI for a given token ID
    /// @param tokenId The token ID to get the URI for
    /// @return string The URI for the given token ID
    function tokenURI(uint256 tokenId) public view override returns (string memory) {
        _requireMinted(tokenId);
        return customMetadata
            ? string(abi.encodePacked(_metadataBaseURI, "/", Strings.toString(tokenId), ".json"))
            : string(abi.encodePacked(_metadataBaseURI, "/metadata.json"));
    }

    /// @dev override the transfer function to allow transfers only if not soulbound
    /// @param from The address to transfer from
    /// @param to The address to transfer to
    /// @param tokenId The token ID to transfer
    function _transfer(address from, address to, uint256 tokenId) internal override {
        if (isSoulbound) revert NotTransferrable();
        super._transfer(from, to, tokenId);
    }

    /// @dev internal function to mint a reward for a user
    /// @param user The user to mint the reward for
    function _mintBadge(address user) internal {
        _safeMint(user, ++lastId);
        _claimed[user] = true;
        emit Claimed(user, lastId);
    }

    ///@dev use ERC2771Context to get msg data
    ///@return bytes calldata
    function _msgData() internal view override(ERC2771Context, Context) returns (bytes calldata) {
        return ERC2771Context._msgData();
    }

    ///@dev use ERC2771Context to get msg sender
    ///@return address sender
    function _msgSender() internal view override(ERC2771Context, Context) returns (address) {
        return ERC2771Context._msgSender();
    }

    /// @dev internal function to emit the first FCFS ERC20 reward available
    /// @param claimer The address to emit the rewards to
    function _emitERC20Rewards(address claimer) internal {
        IERC20 token = IERC20(tokenRewards.token);
        uint256 amountPerUser = tokenRewards.amountPerUser;
        bool enoughBalance = amountPerUser <= token.balanceOf(address(this));

        if (tokenRewards.rewardsLeft != 0 && enoughBalance) {
            token.transfer(claimer, amountPerUser);
            emit FCFSAwarded(claimer, tokenRewards.token, amountPerUser);
            tokenRewards.rewardsLeft--;
        }
    }

    /// @dev internal function to call when withdrawing funds after campaign is ended
    /// @param token the token address of which balance has to be returned to the owner
    function _returnTokenToOwner(IERC20 token) internal {
        uint256 balance = token.balanceOf(address(this));
        if (balance != 0) {
            token.transfer(owner(), balance);
        }

        emit FundsWithdrawn(address(token), balance);
    }

    function _isGovernance() internal view returns (bool) {
        return _msgSender() == factory.keeper();
    }
}

File 4 of 20 : IWaveFactory.sol
// SPDX-License-Identifier: GPL-2.0
pragma solidity ^0.8.21;
pragma abicoder v2;

interface IWaveFactory {
    struct TokenRewards {
        uint256 rewardsLeft;
        uint256 amountPerUser;
        address token;
        bool isRaffle;
    }

    /// @notice deploys a new campaign
    /// @param _name name of the campaign
    /// @param _symbol symbol of the campaign
    /// @param _baseURI base URI of the ERC-721 metadata
    /// @param _startTimestamp start timestamp of the campaign
    /// @param _endTimestamp end timestamp of the campaign
    /// @param _isSoulbound whether the wave badges will be soulbound
    /// @param _tokenRewards rewards in ERC20 tokens
    function deployWave(
        string memory _name,
        string memory _symbol,
        string memory _baseURI,
        uint256 _startTimestamp,
        uint256 _endTimestamp,
        bool _isSoulbound,
        IWaveFactory.TokenRewards memory _tokenRewards
    ) external;

    function keeper() external view returns (address);

    function verifier() external view returns (address);

    function raffleManager() external view returns (address);

    function isRaffleWave(address) external view returns (bool);
}

File 5 of 20 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 8 of 20 : ERC2771Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)

pragma solidity ^0.8.9;

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

/**
 * @dev Context variant with ERC2771 support.
 */
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 sender) {
        if (isTrustedForwarder(msg.sender)) {
            // The assembly code is more direct than the Solidity version using `abi.decode`.
            /// @solidity memory-safe-assembly
            assembly {
                sender := shr(96, calldataload(sub(calldatasize(), 20)))
            }
        } else {
            return super._msgSender();
        }
    }

    function _msgData() internal view virtual override returns (bytes calldata) {
        if (isTrustedForwarder(msg.sender)) {
            return msg.data[:msg.data.length - 20];
        } else {
            return super._msgData();
        }
    }
}

File 9 of 20 : IWaveContract.sol
// SPDX-License-Identifier: GPL-2.0
pragma solidity ^0.8.21;
pragma abicoder v2;

interface IWaveContract {
    struct TokenReward {
        uint256 count;
        uint256 amount;
        address token;
        bool isRaffle;
    }

    /// @notice Allows the governance to set metadata base URI for all tokens
    /// @param _uri The base URI to set
    /// @param _customMetadata Whether the metadata is encoded with tokenId
    function changeBaseURI(string memory _uri, bool _customMetadata) external;

    /// @notice Allows the owner to set the campaign start timestamp
    function setStartTimestamp(uint256 _startTimestamp) external;

    /// @notice Allows the governance to set the campaign end timestamp
    function setEndTimestamp(uint256 _endTimestamp) external;

    /// @notice Allows the owner to end the campaign early
    function endCampaign() external;

    /// @notice Allows to withdraw funds if certain conditions are met
    function withdrawFunds() external;

    /// @notice Execute the mint with permit by verifying the off-chain verifier signature
    /// @param deadline The deadline for the permit
    /// @param v The v component of the signature
    /// @param r The r component of the signature
    /// @param s The s component of the signature
    function claim(uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;

    /// @notice sends a request for random numbers to the raffle manager
    function startRaffle() external;

    /// @notice saves the random number in the contract storage
    /// @param randomNumber the random number to use for the raffle
    function fulfillRaffle(uint256 randomNumber) external;

    /// @notice execute the raffle using the saved random number
    /// and emitting the tokens. Then, returns the remaining funds for raffle rewards
    /// to the owner
    /// @dev the set of winning token ids per reward is generated by the single
    /// random number previously provided by the raffle manager
    function executeRaffle() external;
}

File 10 of 20 : IRaffleManager.sol
//SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

interface IRaffleManager {
    /// @notice Sets parameters used in requesting QRNG services
    /// @param _airnode Airnode address
    /// @param _endpointIdUint256Array Endpoint ID used to request a `uint256[]`
    /// @param _sponsor address used to sponsor this requester
    /// @param _sponsorWallet Sponsor wallet address
    function setRequestParameters(
        address _airnode,
        bytes32 _endpointIdUint256Array,
        address _sponsor,
        address _sponsorWallet
    ) external;

    /// @notice Requests a `uint256`
    /// @return requestId the 32 bytes of the request id
    function makeRequestUint256() external returns (bytes32 requestId);

    /// @notice Called by the Airnode through the AirnodeRrp contract to
    /// fulfill the request
    /// @param requestId Request ID
    /// @param data ABI-encoded response
    function fulfillUint256(bytes32 requestId, bytes calldata data) external;
}

File 11 of 20 : ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

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

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        _approve(to, tokenId);
    }

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

        return _tokenApprovals[tokenId];
    }

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

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

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

        _transfer(from, to, tokenId);
    }

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

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

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

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

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

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

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

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

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

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

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

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

        _owners[tokenId] = to;

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

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

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

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

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

        // Clear approvals
        delete _tokenApprovals[tokenId];

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

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

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

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

        _beforeTokenTransfer(from, to, tokenId, 1);

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

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

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

        emit Transfer(from, to, tokenId);

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

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

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

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

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

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

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

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

File 12 of 20 : SignatureVerifier.sol
// SPDX-License-Identifier: GPL-2.0
pragma solidity ^0.8.21;
pragma abicoder v2;

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

contract SignatureVerifier {
    struct Permit {
        address spender;
        uint256 deadline;
    }

    bytes32 public immutable DOMAIN_SEPARATOR;
    bytes32 public immutable PERMIT_TYPEHASH;

    error InvalidSignature();

    constructor(string memory _name) {
        DOMAIN_SEPARATOR = _computeDomainSeparator(bytes(_name));
        PERMIT_TYPEHASH = keccak256("Permit(address spender,uint256 deadline)");
    }

    /// @dev reverts if that the message was not signed by the verifier or if the deadline is passed
    /// @param sender transaction sender
    /// @param deadline signature deadline
    /// @param v v component of the signed message
    /// @param r r component of the signed message
    /// @param s s component of the signed message
    /// @param verifier address of the verifier
    function _verifySignature(address sender, uint256 deadline, uint8 v, bytes32 r, bytes32 s, address verifier)
        internal
        view
    {
        bytes32 typedDataHash = getTypedDataHash(Permit(sender, deadline));
        address recoveredAddress = ecrecover(_prefixed(typedDataHash), v, r, s);

        if (recoveredAddress == address(0) || recoveredAddress != verifier) revert InvalidSignature();
    }

    /// @dev computes the hash of the fully encoded EIP-712 message for the domain,
    /// which can be used to recover the signer
    /// @param _permit The permit struct
    /// @return bytes32 The hash of the fully encoded EIP-712 message for the domain
    function getTypedDataHash(Permit memory _permit) public view returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, _getStructHash(_permit)));
    }

    /// @dev returns the domain separator for the contract
    /// @param _name The name of the contract
    /// @return bytes32 The domain separator for the contract
    function _computeDomainSeparator(bytes memory _name) internal view virtual returns (bytes32) {
        return keccak256(
            abi.encode(
                keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
                keccak256(_name),
                keccak256("1"),
                block.chainid,
                address(this)
            )
        );
    }

    /// @dev computes the hash of a permit struct
    /// @param _permit The permit struct
    /// @return bytes32 The hash of the permit struct
    function _getStructHash(Permit memory _permit) internal view returns (bytes32) {
        return keccak256(abi.encode(PERMIT_TYPEHASH, _permit.spender, _permit.deadline));
    }

    /// @dev Builds a prefixed hash to mimic the behavior of eth_sign.
    /// @param hash The hash to prefix
    /// @return bytes32 The prefixed hash
    function _prefixed(bytes32 hash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

pragma solidity ^0.8.0;

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_keeper","type":"address"},{"internalType":"address","name":"_trustedForwarder","type":"address"},{"internalType":"address","name":"_verifier","type":"address"},{"internalType":"address","name":"_raffleManager","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"TooManyRewards","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wave","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"WaveCreated","type":"event"},{"inputs":[{"internalType":"address","name":"_keeper","type":"address"}],"name":"changeKeeper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_raffleManager","type":"address"}],"name":"changeRaffleManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_trustedForwarder","type":"address"}],"name":"changeTrustedForwarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_verifier","type":"address"}],"name":"changeVerifier","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_baseURI","type":"string"},{"internalType":"uint256","name":"_startTimestamp","type":"uint256"},{"internalType":"uint256","name":"_endTimestamp","type":"uint256"},{"internalType":"bool","name":"_isSoulbound","type":"bool"},{"components":[{"internalType":"uint256","name":"rewardsLeft","type":"uint256"},{"internalType":"uint256","name":"amountPerUser","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"bool","name":"isRaffle","type":"bool"}],"internalType":"struct IWaveFactory.TokenRewards","name":"_tokenRewards","type":"tuple"}],"name":"deployWave","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isRaffleWave","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"keeper","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"raffleManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"trustedForwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"verifier","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"waves","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b506040516149dc3803806149dc83398101604081905261002f916100f7565b6100383361008b565b600280546001600160a01b039586166001600160a01b031991821617909155600380549486169482169490941790935560048054928516928416929092179091556005805491909316911617905561014b565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146100f257600080fd5b919050565b6000806000806080858703121561010d57600080fd5b610116856100db565b9350610124602086016100db565b9250610132604086016100db565b9150610140606086016100db565b905092959194509250565b6148828061015a6000396000f3fe60806040523480156200001157600080fd5b5060043610620000fd5760003560e01c8063aa6527d91162000097578063c781267a116200006e578063c781267a1462000209578063cf04fb941462000220578063d3f8a33a1462000237578063f2fde38b146200024e57600080fd5b8063aa6527d914620001aa578063aced166114620001be578063b553469914620001d257600080fd5b80632b7ac3f311620000d85780632b7ac3f31462000149578063715018a6146200017a5780637da0a87714620001845780638da5cb5b146200019857600080fd5b806304056c12146200010257806308c7a8dd146200011b578063097798381462000132575b600080fd5b6200011962000113366004620007a5565b62000265565b005b620001196200012c366004620008df565b620003f3565b6200011962000143366004620008df565b6200041f565b6004546200015d906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b620001196200044b565b6003546200015d906001600160a01b031681565b6000546001600160a01b03166200015d565b6005546200015d906001600160a01b031681565b6002546200015d906001600160a01b031681565b620001f8620001e3366004620008df565b60066020526000908152604090205460ff1681565b604051901515815260200162000171565b6200015d6200021a36600462000904565b62000463565b6200011962000231366004620008df565b6200048e565b6200011962000248366004620008df565b620004ba565b620001196200025f366004620008df565b620004e6565b6000878787878787600360009054906101000a90046001600160a01b0316886040516200029290620006c0565b620002a598979695949392919062000966565b604051809103906000f080158015620002c2573d6000803e3d6000fd5b506001805480820182556000919091527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf60180546001600160a01b0319166001600160a01b03831690811790915560405163f2fde38b60e01b81523360048201529192509063f2fde38b90602401600060405180830381600087803b1580156200034b57600080fd5b505af115801562000360573d6000803e3d6000fd5b5050505081606001511562000393576001600160a01b0381166000908152600660205260409020805460ff191660011790555b60408201516001600160a01b031615620003b357620003b3828262000569565b60405133906001600160a01b038316907fb49597eb6ae32b938af897f271f3c6f6448014880f91ccee242476f2db9af06c90600090a35050505050505050565b620003fd62000614565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6200042962000614565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6200045562000614565b62000461600062000670565b565b600181815481106200047457600080fd5b6000918252602090912001546001600160a01b0316905081565b6200049862000614565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b620004c462000614565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b620004f062000614565b6001600160a01b0381166200055b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b620005668162000670565b50565b81604001516001600160a01b03166323b872dd33838560000151866020015162000594919062000a0a565b6040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015620005e9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200060f919062000a36565b505050565b6000546001600160a01b03163314620004615760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640162000552565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b613df68062000a5783390190565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620006f657600080fd5b813567ffffffffffffffff80821115620007145762000714620006ce565b604051601f8301601f19908116603f011681019082821181831017156200073f576200073f620006ce565b816040528381528660208588010111156200075957600080fd5b836020870160208301376000602085830101528094505050505092915050565b80151581146200056657600080fd5b80356001600160a01b0381168114620007a057600080fd5b919050565b6000806000806000806000878903610140811215620007c357600080fd5b883567ffffffffffffffff80821115620007dc57600080fd5b620007ea8c838d01620006e4565b995060208b01359150808211156200080157600080fd5b6200080f8c838d01620006e4565b985060408b01359150808211156200082657600080fd5b620008348c838d01620006e4565b975060608b0135965060808b0135955060a08b01359150620008568262000779565b819450608060bf19840112156200086c57600080fd5b604051925060808301915082821081831117156200088e576200088e620006ce565b5060405260c0890135815260e08901356020820152620008b26101008a0162000788565b6040820152610120890135620008c88162000779565b806060830152508091505092959891949750929550565b600060208284031215620008f257600080fd5b620008fd8262000788565b9392505050565b6000602082840312156200091757600080fd5b5035919050565b6000815180845260005b81811015620009465760208185018101518683018201520162000928565b506000602082860101526020601f19601f83011685010191505092915050565b60006101608083526200097c8184018c6200091e565b9050828103602084015262000992818b6200091e565b90508281036040840152620009a8818a6200091e565b6060848101999099526080840197909752505092151560a08401526001600160a01b0391821660c0840152805160e084015260208101516101008401526040810151909116610120830152909201511515610140909201919091529392505050565b808202811582820484141762000a3057634e487b7160e01b600052601160045260246000fd5b92915050565b60006020828403121562000a4957600080fd5b8151620008fd816200077956fe60e06040526001600b55600e805460ff60201b19166401000000001790553480156200002a57600080fd5b5060405162003df638038062003df68339810160408190526200004d9162000444565b6001600160a01b038216608052878088620000716200006b620001b5565b620001c6565b60016200007f8382620005b1565b5060026200008e8282620005b1565b505050620000a2816200021660201b60201c565b60a052507f05d55ef4a8a7ca3d0b75d9ecd47170a2bf895536707a031d23b6bb013c73f73f60c05283851180620000d857504284105b15620000f75760405163c6e369f960e01b815260040160405180910390fd5b62000101620001b5565b600780546001600160a01b0319166001600160a01b0392909216919091179055600d6200012f8782620005b1565b506009859055600a849055600e80548415156101000261ff00199091161790558051601355602081015160145560408101516015805460608401511515600160a01b026001600160a81b03199091166001600160a01b0390931692831717905515620001a757600e805462ff00001916620100001790555b50505050505050506200067d565b6000620001c16200029d565b905090565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b8051602091820120604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81850152808201929092527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608301524660808301523060a0808401919091528151808403909101815260c09092019052805191012090565b6080516000906001600160a01b03163303620002c0575060131936013560601c90565b503390565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715620003065762000306620002c5565b604052919050565b600082601f8301126200032057600080fd5b81516001600160401b038111156200033c576200033c620002c5565b602062000352601f8301601f19168201620002db565b82815285828487010111156200036757600080fd5b60005b83811015620003875785810183015182820184015282016200036a565b506000928101909101919091529392505050565b80518015158114620003ac57600080fd5b919050565b80516001600160a01b0381168114620003ac57600080fd5b600060808284031215620003dc57600080fd5b604051608081016001600160401b0381118282101715620004015762000401620002c5565b806040525080915082518152602083015160208201526200042560408401620003b1565b604082015262000438606084016200039b565b60608201525092915050565b600080600080600080600080610160898b0312156200046257600080fd5b88516001600160401b03808211156200047a57600080fd5b620004888c838d016200030e565b995060208b01519150808211156200049f57600080fd5b620004ad8c838d016200030e565b985060408b0151915080821115620004c457600080fd5b50620004d38b828c016200030e565b9650506060890151945060808901519350620004f260a08a016200039b565b92506200050260c08a01620003b1565b9150620005138a60e08b01620003c9565b90509295985092959890939650565b600181811c908216806200053757607f821691505b6020821081036200055857634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620005ac57600081815260208120601f850160051c81016020861015620005875750805b601f850160051c820191505b81811015620005a85782815560010162000593565b5050505b505050565b81516001600160401b03811115620005cd57620005cd620002c5565b620005e581620005de845462000522565b846200055e565b602080601f8311600181146200061d5760008415620006045750858301515b600019600386901b1c1916600185901b178555620005a8565b600085815260208120601f198616915b828110156200064e578886015182559484019460019091019084016200062d565b50858210156200066d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c051613734620006c2600039600081816103f6015261264a01526000818161042b01526115f801526000818161048c015261282401526137346000f3fe608060405234801561001057600080fd5b50600436106102bb5760003560e01c80637eaf5dab11610182578063c87b56dd116100e9578063e262f64b116100a2578063f2fde38b1161007c578063f2fde38b146106bf578063f7eca6d0146106d2578063fb16fb72146106e4578063fdc48e31146106ec57600080fd5b8063e262f64b14610657578063e6fd48bc1461067a578063e985e9c51461068357600080fd5b8063c87b56dd146105f8578063ccbac9f51461060b578063cea3bdfd14610614578063d5c688d614610627578063d7cb69701461063b578063dfccfc701461064457600080fd5b8063a22cb4651161013b578063a22cb4651461059a578063a85adeab146105ad578063b88d4fde146105b6578063c1292cc3146105c9578063c44bef75146105d2578063c45a0155146105e557600080fd5b80637eaf5dab1461053b5780638da5cb5b1461054e578063902413d01461055f57806395d89b411461057257806398428dbf1461057a578063991784081461058757600080fd5b80633644e515116102265780636352211e116101df5780636352211e146104df57806370a08231146104f2578063715018a61461050557806371aac7f91461050d57806378ce8b40146105155780637df6a6c81461052857600080fd5b80633644e5151461042657806342842e0e1461044d578063482ddde2146104605780635576b87114610469578063572b6c051461047c57806357472ad2146104bc57600080fd5b80630ba0f2ae116102785780630ba0f2ae146103a85780631278e00a146103bb57806323b872dd146103ce578063242284f1146103e157806324600fc3146103e957806330adf81f146103f157600080fd5b806301ffc9a7146102c057806304386f52146102e857806306fdde03146102fd578063081812fc14610312578063091c76f51461033d578063095ea7b314610395575b600080fd5b6102d36102ce366004612dd1565b610701565b60405190151581526020015b60405180910390f35b6102fb6102f6366004612df5565b610753565b005b610305610807565b6040516102df9190612e5e565b610325610320366004612df5565b610899565b6040516001600160a01b0390911681526020016102df565b6013546014546015546103649291906001600160a01b03811690600160a01b900460ff1684565b6040516102df949392919093845260208401929092526001600160a01b031660408301521515606082015260800190565b6102fb6103a3366004612e86565b6108c0565b600e546102d39062010000900460ff1681565b6102fb6103c9366004612eb2565b6109ec565b6102fb6103dc366004612ef5565b610b8e565b6102fb610bc6565b6102fb610d9b565b6104187f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020016102df565b6104187f000000000000000000000000000000000000000000000000000000000000000081565b6102fb61045b366004612ef5565b610e8d565b610418600b5481565b6102fb610477366004612f44565b610ea8565b6102d361048a366004612f61565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b6102d36104ca366004612df5565b60116020526000908152604090205460ff1681565b6103256104ed366004612df5565b610f77565b610418610500366004612f61565b610fd7565b6102fb61105d565b6102fb61106f565b6102fb610523366004612f7e565b6111a5565b6102fb610536366004612df5565b6113f8565b6102fb610549366004612f44565b611529565b6000546001600160a01b0316610325565b61041861056d36600461304b565b6115f4565b61030561165c565b600e546102d39060ff1681565b6102fb6105953660046130a3565b61166b565b6102fb6105a8366004613105565b611766565b610418600a5481565b6102fb6105c436600461313e565b611778565b61041860085481565b6102fb6105e0366004612df5565b6117b1565b600754610325906001600160a01b031681565b610305610606366004612df5565b6118ea565b610418600c5481565b6102fb610622366004612df5565b611956565b600e546102d3906301000000900460ff1681565b61041860125481565b6102fb610652366004613202565b611b52565b6102d3610665366004612df5565b60106020526000908152604090205460ff1681565b61041860095481565b6102d361069136600461321a565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b6102fb6106cd366004612f61565b611c0e565b600e546102d390610100900460ff1681565b6102fb611c87565b600e546102d390640100000000900460ff1681565b60006001600160e01b031982166380ac58cd60e01b148061073257506001600160e01b03198216635b5e139f60e01b145b8061074d57506301ffc9a760e01b6001600160e01b03198316145b92915050565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ca9190613248565b6001600160a01b03166107db611f5d565b6001600160a01b031614610802576040516354348f0360e01b815260040160405180910390fd5b600b55565b60606001805461081690613265565b80601f016020809104026020016040519081016040528092919081815260200182805461084290613265565b801561088f5780601f106108645761010080835404028352916020019161088f565b820191906000526020600020905b81548152906001019060200180831161087257829003601f168201915b5050505050905090565b60006108a482611f6c565b506000908152600560205260409020546001600160a01b031690565b60006108cb82610f77565b9050806001600160a01b0316836001600160a01b03160361093d5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b806001600160a01b031661094f611f5d565b6001600160a01b0316148061096b575061096b81610691611f5d565b6109dd5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610934565b6109e78383611fcb565b505050565b6009544210806109fd5750600a5442115b15610a1b5760405163219a945b60e11b815260040160405180910390fd5b600f6000610a27611f5d565b6001600160a01b0316815260208101919091526040016000205460ff1615610a6257604051632cfe303760e21b815260040160405180910390fd5b83421115610a83576040516305787bdf60e01b815260040160405180910390fd5b600e54640100000000900460ff1615610b2157610b21610aa1611f5d565b85858585600760009054906101000a90046001600160a01b03166001600160a01b0316632b7ac3f36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610af8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b1c9190613248565b612039565b60005b600b54811015610b5057610b3e610b39611f5d565b61211b565b80610b48816132af565b915050610b24565b50600e5462010000900460ff168015610b735750601554600160a01b900460ff16155b15610b8857610b88610b83611f5d565b61218a565b50505050565b610b9f610b99611f5d565b826122eb565b610bbb5760405162461bcd60e51b8152600401610934906132c8565b6109e783838361236a565b600a54421015610be95760405163cc76115360e01b815260040160405180910390fd5b600e546301000000900460ff1615610c395760405162461bcd60e51b8152602060048201526013602482015272526166666c6520616c726561647920646f6e6560681b6044820152606401610934565b601554600160a01b900460ff16610c865760405162461bcd60e51b81526020600482015260116024820152704e6f74206120726166666c65207761766560781b6044820152606401610934565b610c8e611f5d565b6001600160a01b03167fe5ed10a2abb6a808edb6fbb7ae5cd09aad196ddaa1bd4e9295688a4d508460c860405160405180910390a26007546040805163aa6527d960e01b815290516000926001600160a01b03169163aa6527d99160048083019260209291908290030181865afa158015610d0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d319190613248565b9050806001600160a01b031663dea12bad6040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610d73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d979190613315565b5050565b600a54421015610dbe5760405163cc76115360e01b815260040160405180910390fd5b601554600160a01b900460ff1615610e7657600e546301000000900460ff1680610deb5750610deb61239e565b610e765760405162461bcd60e51b815260206004820152605060248201527f43616e20776974686472617720726166666c652066756e6473206f6e6c79206960448201527f6620726166666c6520697320636f6d706c65746564206f7220676f7665726e6160648201526f1b98d9481c995c5d595cdd1959081a5d60821b608482015260a401610934565b601554610e8b906001600160a01b031661242c565b565b6109e783838360405180602001604052806000815250611778565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa158015610efb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1f9190613248565b6001600160a01b0316610f30611f5d565b6001600160a01b031614610f57576040516354348f0360e01b815260040160405180910390fd5b600e80549115156401000000000264ff0000000019909216919091179055565b6000818152600360205260408120546001600160a01b03168061074d5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610934565b60006001600160a01b0382166110415760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610934565b506001600160a01b031660009081526004602052604090205490565b61106561256d565b610e8b60006125e6565b6009544210806110805750600a5442115b1561109e5760405163219a945b60e11b815260040160405180910390fd5b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111159190613248565b6001600160a01b0316611126611f5d565b6001600160a01b03161415801561115857506000546001600160a01b031661114c611f5d565b6001600160a01b031614155b1561117657604051637d7b71b560e01b815260040160405180910390fd5b42600a556040517f434b671a95fb0071b0127874981939c3cd42e8f1f7d602b761482102d4a5507290600090a1565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061121c9190613248565b6001600160a01b031661122d611f5d565b6001600160a01b03161415801561125f57506000546001600160a01b0316611253611f5d565b6001600160a01b031614155b1561127d57604051637d7b71b560e01b815260040160405180910390fd5b601554600160a01b900460ff166112e85760405162461bcd60e51b815260206004820152602960248201527f43616e207175616c69667920746f6b656e20696473206f6e6c7920696620726160448201526866666c65207761766560b81b6064820152608401610934565b6000805b838110156113c85760008585838181106113085761130861332e565b9050602002013590508060001415801561132457506008548111155b6113705760405162461bcd60e51b815260206004820152601a60248201527f496e76616c696420746f6b656e496420746f207175616c6966790000000000006044820152606401610934565b60008181526011602052604090205484151560ff90911615036113b5576000818152601160205260409020805460ff1916851515179055826113b1816132af565b9350505b50806113c0816132af565b9150506112ec565b50816113e157806012546113dc9190613344565b6113ef565b806012546113ef9190613357565b60125550505050565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa15801561144b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061146f9190613248565b6001600160a01b0316611480611f5d565b6001600160a01b0316141580156114b257506000546001600160a01b03166114a6611f5d565b6001600160a01b031614155b156114d057604051637d7b71b560e01b815260040160405180910390fd5b42811180156114e0575060095481115b6115245760405162461bcd60e51b81526020600482015260156024820152740496e76616c696420656e642074696d657374616d7605c1b6044820152606401610934565b600a55565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa15801561157c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a09190613248565b6001600160a01b03166115b1611f5d565b6001600160a01b0316146115d8576040516354348f0360e01b815260040160405180910390fd5b600e8054911515620100000262ff000019909216919091179055565b60007f000000000000000000000000000000000000000000000000000000000000000061162083612636565b60405161190160f01b6020820152602281019290925260428201526062015b604051602081830303815290604052805190602001209050919050565b60606002805461081690613265565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e29190613248565b6001600160a01b03166116f3611f5d565b6001600160a01b03161415801561172557506000546001600160a01b0316611719611f5d565b6001600160a01b031614155b1561174357604051637d7b71b560e01b815260040160405180910390fd5b600d6117508385836133b8565b50600e805460ff19169115159190911790555050565b610d97611771611f5d565b838361268c565b611789611783611f5d565b836122eb565b6117a55760405162461bcd60e51b8152600401610934906132c8565b610b888484848461275a565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa158015611804573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118289190613248565b6001600160a01b0316611839611f5d565b6001600160a01b03161415801561186b57506000546001600160a01b031661185f611f5d565b6001600160a01b031614155b1561188957604051637d7b71b560e01b815260040160405180910390fd5b80421080156118995750600a5481105b6118e55760405162461bcd60e51b815260206004820152601760248201527f496e76616c69642073746172742074696d657374616d700000000000000000006044820152606401610934565b600955565b60606118f582611f6c565b600e5460ff1661192557600d60405160200161191191906134ec565b60405160208183030381529060405261074d565b600d6119308361278d565b604051602001611941929190613516565b60405160208183030381529060405292915050565b600a544210156119795760405163cc76115360e01b815260040160405180910390fd5b600760009054906101000a90046001600160a01b03166001600160a01b031663aa6527d96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f09190613248565b6001600160a01b0316611a01611f5d565b6001600160a01b031614158015611aa75750600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a8a9190613248565b6001600160a01b0316611a9b611f5d565b6001600160a01b031614155b8015611ace57506000546001600160a01b0316611ac2611f5d565b6001600160a01b031614155b15611aec57604051636c94aad360e01b815260040160405180910390fd5b600c5415611b4d5760405162461bcd60e51b815260206004820152602860248201527f52616e646f6d206e756d6265722068617320616c7265616479206265656e20656044820152671e1d1c9858dd195960c21b6064820152608401610934565b600c55565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ba5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc99190613248565b6001600160a01b0316611bda611f5d565b6001600160a01b031614611c01576040516354348f0360e01b815260040160405180910390fd5b8060136109e7828261355a565b611c1661256d565b6001600160a01b038116611c7b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610934565b611c84816125e6565b50565b600a54421015611caa5760405163cc76115360e01b815260040160405180910390fd5b600e546301000000900460ff1615611cfa5760405162461bcd60e51b8152602060048201526013602482015272526166666c6520616c726561647920646f6e6560681b6044820152606401610934565b600c54600003611d585760405162461bcd60e51b815260206004820152602360248201527f52616e646f6d206e756d62657220776173206e6f7420657874726163746564206044820152621e595d60ea1b6064820152608401610934565b6015546014546013546012546008546001600160a01b0390941693600091611d7f91613344565b90506000828210611d905782611d92565b815b9050846000805b83811015611f0f5760005b600854600c5460408051602081019290925281018590526060016040516020818303038152906040528051906020012060001c611de191906135b7565b611dec906001613357565b905082611df8816132af565b60008381526010602052604090205490945060ff169050611da4576000818152601060205260408120805460ff19166001179055611e3582610f77565b60405163a9059cbb60e01b81526001600160a01b038083166004830152602482018c90529192509086169063a9059cbb906044016020604051808303816000875af1158015611e88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eac91906135d9565b50896001600160a01b0316816001600160a01b03167f80b887c8189ccc457f4b3077692f6d6d11abc05537566d3273df1747af5349548b604051611ef291815260200190565b60405180910390a350508080611f07906132af565b915050611d99565b50600e805463ff000000191663010000001790556040517f27570828a3b3d654a69144a8ca6c7e066e01acd2e5c41405c83fa9f03011831290600090a1611f54610d9b565b50505050505050565b6000611f67612820565b905090565b6000818152600360205260409020546001600160a01b0316611c845760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610934565b600081815260056020526040902080546001600160a01b0319166001600160a01b038416908117909155819061200082610f77565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006120616040518060400160405280896001600160a01b03168152602001888152506115f4565b90506000600161207083612864565b6040805160008152602081018083529290925260ff891690820152606081018790526080810186905260a0016020604051602081039080840390855afa1580156120be573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615806120f35750826001600160a01b0316816001600160a01b031614155b1561211157604051638baa579f60e01b815260040160405180910390fd5b5050505050505050565b6121388160086000815461212e906132af565b918290555061289f565b6001600160a01b0381166000818152600f6020526040808220805460ff1916600117905560085490519092917fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a91a350565b6015546014546040516370a0823160e01b81523060048201526001600160a01b039092169160009083906370a0823190602401602060405180830381865afa1580156121da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121fe9190613315565b601354908311159150158015906122125750805b15610b885760405163a9059cbb60e01b81526001600160a01b0385811660048301526024820184905284169063a9059cbb906044016020604051808303816000875af1158015612266573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061228a91906135d9565b506015546040518381526001600160a01b03918216918616907f2b5a46847b5904937aa26c09373883ac411399d3404814f716b47721af04ff4f9060200160405180910390a3601380549060006122e0836135f6565b919050555050505050565b6000806122f783610f77565b9050806001600160a01b0316846001600160a01b0316148061233e57506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b806123625750836001600160a01b031661235784610899565b6001600160a01b0316145b949350505050565b600e54610100900460ff1615612393576040516354ee515160e01b815260040160405180910390fd5b6109e78383836128b9565b6007546040805163aced166160e01b815290516000926001600160a01b03169163aced16619160048083019260209291908290030181865afa1580156123e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240c9190613248565b6001600160a01b031661241d611f5d565b6001600160a01b031614905090565b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa158015612473573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124979190613315565b9050801561253357816001600160a01b031663a9059cbb6124c06000546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303816000875af115801561250d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061253191906135d9565b505b60405181906001600160a01b038416907feaff4b37086828766ad3268786972c0cd24259d4c87a80f9d3963a3c3d999b0d90600090a35050565b612575611f5d565b6001600160a01b03166125906000546001600160a01b031690565b6001600160a01b031614610e8b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610934565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b805160208083015160405160009361163f937f0000000000000000000000000000000000000000000000000000000000000000939192019283526001600160a01b03919091166020830152604082015260600190565b816001600160a01b0316836001600160a01b0316036126ed5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610934565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b61276584848461236a565b61277184848484612a1d565b610b885760405162461bcd60e51b81526004016109349061360d565b6060600061279a83612b25565b600101905060008167ffffffffffffffff8111156127ba576127ba613004565b6040519080825280601f01601f1916602001820160405280156127e4576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846127ee57509392505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361285f575060131936013560601c90565b503390565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c0161163f565b610d97828260405180602001604052806000815250612bfd565b826001600160a01b03166128cc82610f77565b6001600160a01b0316146128f25760405162461bcd60e51b81526004016109349061365f565b6001600160a01b0382166129545760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610934565b826001600160a01b031661296782610f77565b6001600160a01b03161461298d5760405162461bcd60e51b81526004016109349061365f565b600081815260056020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260048552838620805460001901905590871680865283862080546001019055868652600390945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60006001600160a01b0384163b15612b1a57836001600160a01b031663150b7a02612a46611f5d565b8786866040518563ffffffff1660e01b8152600401612a6894939291906136a4565b6020604051808303816000875af1925050508015612aa3575060408051601f3d908101601f19168201909252612aa0918101906136e1565b60015b612b00573d808015612ad1576040519150601f19603f3d011682016040523d82523d6000602084013e612ad6565b606091505b508051600003612af85760405162461bcd60e51b81526004016109349061360d565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612362565b506001949350505050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310612b645772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310612b90576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310612bae57662386f26fc10000830492506010015b6305f5e1008310612bc6576305f5e100830492506008015b6127108310612bda57612710830492506004015b60648310612bec576064830492506002015b600a831061074d5760010192915050565b612c078383612c30565b612c146000848484612a1d565b6109e75760405162461bcd60e51b81526004016109349061360d565b6001600160a01b038216612c865760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610934565b6000818152600360205260409020546001600160a01b031615612ceb5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610934565b6000818152600360205260409020546001600160a01b031615612d505760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610934565b6001600160a01b038216600081815260046020908152604080832080546001019055848352600390915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6001600160e01b031981168114611c8457600080fd5b600060208284031215612de357600080fd5b8135612dee81612dbb565b9392505050565b600060208284031215612e0757600080fd5b5035919050565b60005b83811015612e29578181015183820152602001612e11565b50506000910152565b60008151808452612e4a816020860160208601612e0e565b601f01601f19169290920160200192915050565b602081526000612dee6020830184612e32565b6001600160a01b0381168114611c8457600080fd5b60008060408385031215612e9957600080fd5b8235612ea481612e71565b946020939093013593505050565b60008060008060808587031215612ec857600080fd5b84359350602085013560ff81168114612ee057600080fd5b93969395505050506040820135916060013590565b600080600060608486031215612f0a57600080fd5b8335612f1581612e71565b92506020840135612f2581612e71565b929592945050506040919091013590565b8015158114611c8457600080fd5b600060208284031215612f5657600080fd5b8135612dee81612f36565b600060208284031215612f7357600080fd5b8135612dee81612e71565b600080600060408486031215612f9357600080fd5b833567ffffffffffffffff80821115612fab57600080fd5b818601915086601f830112612fbf57600080fd5b813581811115612fce57600080fd5b8760208260051b8501011115612fe357600080fd5b60209283019550935050840135612ff981612f36565b809150509250925092565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561304357613043613004565b604052919050565b60006040828403121561305d57600080fd5b6040516040810181811067ffffffffffffffff8211171561308057613080613004565b604052823561308e81612e71565b81526020928301359281019290925250919050565b6000806000604084860312156130b857600080fd5b833567ffffffffffffffff808211156130d057600080fd5b818601915086601f8301126130e457600080fd5b8135818111156130f357600080fd5b876020828501011115612fe357600080fd5b6000806040838503121561311857600080fd5b823561312381612e71565b9150602083013561313381612f36565b809150509250929050565b6000806000806080858703121561315457600080fd5b843561315f81612e71565b935060208581013561317081612e71565b935060408601359250606086013567ffffffffffffffff8082111561319457600080fd5b818801915088601f8301126131a857600080fd5b8135818111156131ba576131ba613004565b6131cc601f8201601f1916850161301a565b915080825289848285010111156131e257600080fd5b808484018584013760008482840101525080935050505092959194509250565b60006080828403121561321457600080fd5b50919050565b6000806040838503121561322d57600080fd5b823561323881612e71565b9150602083013561313381612e71565b60006020828403121561325a57600080fd5b8151612dee81612e71565b600181811c9082168061327957607f821691505b60208210810361321457634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016132c1576132c1613299565b5060010190565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b60006020828403121561332757600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b8181038181111561074d5761074d613299565b8082018082111561074d5761074d613299565b601f8211156109e757600081815260208120601f850160051c810160208610156133915750805b601f850160051c820191505b818110156133b05782815560010161339d565b505050505050565b67ffffffffffffffff8311156133d0576133d0613004565b6133e4836133de8354613265565b8361336a565b6000601f84116001811461341857600085156134005750838201355b600019600387901b1c1916600186901b178355613472565b600083815260209020601f19861690835b828110156134495786850135825560209485019460019092019101613429565b50868210156134665760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b6000815461348681613265565b6001828116801561349e57600181146134b3576134e2565b60ff19841687528215158302870194506134e2565b8560005260208060002060005b858110156134d95781548a8201529084019082016134c0565b50505082870194505b5050505092915050565b60006134f88284613479565b6d17b6b2ba30b230ba30973539b7b760911b8152600e019392505050565b60006135228285613479565b602f60f81b8152835161353c816001840160208801612e0e565b64173539b7b760d91b60019290910191820152600601949350505050565b813581556020820135600182015560028101604083013561357a81612e71565b8154606085013561358a81612f36565b60ff60a01b90151560a01b166001600160a01b03929092166001600160a81b031991909116171790555050565b6000826135d457634e487b7160e01b600052601260045260246000fd5b500690565b6000602082840312156135eb57600080fd5b8151612dee81612f36565b60008161360557613605613299565b506000190190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906136d790830184612e32565b9695505050505050565b6000602082840312156136f357600080fd5b8151612dee81612dbb56fea26469706673582212203c717e2036b6f21e9a80977842633d252e91373aea8b695747d56ef9c304ddad64736f6c63430008150033a2646970667358221220b37f75e52aabb6bc8bbf8768a14adb0bd39c9f4226b508f40ea10d157aa7b18b64736f6c63430008150033000000000000000000000000607291c9b3b03d8c2dc1f5f7f8db2b6a06c911830000000000000000000000008f5b08237d9aaf212a6abef3379149765dee9c1000000000000000000000000075d14f0ae59003c0806b625b402a40340ffde634000000000000000000000000a668bdf7ac5f9a2c45f0f233708ea654993d219d

Deployed Bytecode

0x60806040523480156200001157600080fd5b5060043610620000fd5760003560e01c8063aa6527d91162000097578063c781267a116200006e578063c781267a1462000209578063cf04fb941462000220578063d3f8a33a1462000237578063f2fde38b146200024e57600080fd5b8063aa6527d914620001aa578063aced166114620001be578063b553469914620001d257600080fd5b80632b7ac3f311620000d85780632b7ac3f31462000149578063715018a6146200017a5780637da0a87714620001845780638da5cb5b146200019857600080fd5b806304056c12146200010257806308c7a8dd146200011b578063097798381462000132575b600080fd5b6200011962000113366004620007a5565b62000265565b005b620001196200012c366004620008df565b620003f3565b6200011962000143366004620008df565b6200041f565b6004546200015d906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b620001196200044b565b6003546200015d906001600160a01b031681565b6000546001600160a01b03166200015d565b6005546200015d906001600160a01b031681565b6002546200015d906001600160a01b031681565b620001f8620001e3366004620008df565b60066020526000908152604090205460ff1681565b604051901515815260200162000171565b6200015d6200021a36600462000904565b62000463565b6200011962000231366004620008df565b6200048e565b6200011962000248366004620008df565b620004ba565b620001196200025f366004620008df565b620004e6565b6000878787878787600360009054906101000a90046001600160a01b0316886040516200029290620006c0565b620002a598979695949392919062000966565b604051809103906000f080158015620002c2573d6000803e3d6000fd5b506001805480820182556000919091527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf60180546001600160a01b0319166001600160a01b03831690811790915560405163f2fde38b60e01b81523360048201529192509063f2fde38b90602401600060405180830381600087803b1580156200034b57600080fd5b505af115801562000360573d6000803e3d6000fd5b5050505081606001511562000393576001600160a01b0381166000908152600660205260409020805460ff191660011790555b60408201516001600160a01b031615620003b357620003b3828262000569565b60405133906001600160a01b038316907fb49597eb6ae32b938af897f271f3c6f6448014880f91ccee242476f2db9af06c90600090a35050505050505050565b620003fd62000614565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6200042962000614565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6200045562000614565b62000461600062000670565b565b600181815481106200047457600080fd5b6000918252602090912001546001600160a01b0316905081565b6200049862000614565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b620004c462000614565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b620004f062000614565b6001600160a01b0381166200055b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b620005668162000670565b50565b81604001516001600160a01b03166323b872dd33838560000151866020015162000594919062000a0a565b6040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015620005e9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200060f919062000a36565b505050565b6000546001600160a01b03163314620004615760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640162000552565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b613df68062000a5783390190565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620006f657600080fd5b813567ffffffffffffffff80821115620007145762000714620006ce565b604051601f8301601f19908116603f011681019082821181831017156200073f576200073f620006ce565b816040528381528660208588010111156200075957600080fd5b836020870160208301376000602085830101528094505050505092915050565b80151581146200056657600080fd5b80356001600160a01b0381168114620007a057600080fd5b919050565b6000806000806000806000878903610140811215620007c357600080fd5b883567ffffffffffffffff80821115620007dc57600080fd5b620007ea8c838d01620006e4565b995060208b01359150808211156200080157600080fd5b6200080f8c838d01620006e4565b985060408b01359150808211156200082657600080fd5b620008348c838d01620006e4565b975060608b0135965060808b0135955060a08b01359150620008568262000779565b819450608060bf19840112156200086c57600080fd5b604051925060808301915082821081831117156200088e576200088e620006ce565b5060405260c0890135815260e08901356020820152620008b26101008a0162000788565b6040820152610120890135620008c88162000779565b806060830152508091505092959891949750929550565b600060208284031215620008f257600080fd5b620008fd8262000788565b9392505050565b6000602082840312156200091757600080fd5b5035919050565b6000815180845260005b81811015620009465760208185018101518683018201520162000928565b506000602082860101526020601f19601f83011685010191505092915050565b60006101608083526200097c8184018c6200091e565b9050828103602084015262000992818b6200091e565b90508281036040840152620009a8818a6200091e565b6060848101999099526080840197909752505092151560a08401526001600160a01b0391821660c0840152805160e084015260208101516101008401526040810151909116610120830152909201511515610140909201919091529392505050565b808202811582820484141762000a3057634e487b7160e01b600052601160045260246000fd5b92915050565b60006020828403121562000a4957600080fd5b8151620008fd816200077956fe60e06040526001600b55600e805460ff60201b19166401000000001790553480156200002a57600080fd5b5060405162003df638038062003df68339810160408190526200004d9162000444565b6001600160a01b038216608052878088620000716200006b620001b5565b620001c6565b60016200007f8382620005b1565b5060026200008e8282620005b1565b505050620000a2816200021660201b60201c565b60a052507f05d55ef4a8a7ca3d0b75d9ecd47170a2bf895536707a031d23b6bb013c73f73f60c05283851180620000d857504284105b15620000f75760405163c6e369f960e01b815260040160405180910390fd5b62000101620001b5565b600780546001600160a01b0319166001600160a01b0392909216919091179055600d6200012f8782620005b1565b506009859055600a849055600e80548415156101000261ff00199091161790558051601355602081015160145560408101516015805460608401511515600160a01b026001600160a81b03199091166001600160a01b0390931692831717905515620001a757600e805462ff00001916620100001790555b50505050505050506200067d565b6000620001c16200029d565b905090565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b8051602091820120604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81850152808201929092527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608301524660808301523060a0808401919091528151808403909101815260c09092019052805191012090565b6080516000906001600160a01b03163303620002c0575060131936013560601c90565b503390565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715620003065762000306620002c5565b604052919050565b600082601f8301126200032057600080fd5b81516001600160401b038111156200033c576200033c620002c5565b602062000352601f8301601f19168201620002db565b82815285828487010111156200036757600080fd5b60005b83811015620003875785810183015182820184015282016200036a565b506000928101909101919091529392505050565b80518015158114620003ac57600080fd5b919050565b80516001600160a01b0381168114620003ac57600080fd5b600060808284031215620003dc57600080fd5b604051608081016001600160401b0381118282101715620004015762000401620002c5565b806040525080915082518152602083015160208201526200042560408401620003b1565b604082015262000438606084016200039b565b60608201525092915050565b600080600080600080600080610160898b0312156200046257600080fd5b88516001600160401b03808211156200047a57600080fd5b620004888c838d016200030e565b995060208b01519150808211156200049f57600080fd5b620004ad8c838d016200030e565b985060408b0151915080821115620004c457600080fd5b50620004d38b828c016200030e565b9650506060890151945060808901519350620004f260a08a016200039b565b92506200050260c08a01620003b1565b9150620005138a60e08b01620003c9565b90509295985092959890939650565b600181811c908216806200053757607f821691505b6020821081036200055857634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620005ac57600081815260208120601f850160051c81016020861015620005875750805b601f850160051c820191505b81811015620005a85782815560010162000593565b5050505b505050565b81516001600160401b03811115620005cd57620005cd620002c5565b620005e581620005de845462000522565b846200055e565b602080601f8311600181146200061d5760008415620006045750858301515b600019600386901b1c1916600185901b178555620005a8565b600085815260208120601f198616915b828110156200064e578886015182559484019460019091019084016200062d565b50858210156200066d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c051613734620006c2600039600081816103f6015261264a01526000818161042b01526115f801526000818161048c015261282401526137346000f3fe608060405234801561001057600080fd5b50600436106102bb5760003560e01c80637eaf5dab11610182578063c87b56dd116100e9578063e262f64b116100a2578063f2fde38b1161007c578063f2fde38b146106bf578063f7eca6d0146106d2578063fb16fb72146106e4578063fdc48e31146106ec57600080fd5b8063e262f64b14610657578063e6fd48bc1461067a578063e985e9c51461068357600080fd5b8063c87b56dd146105f8578063ccbac9f51461060b578063cea3bdfd14610614578063d5c688d614610627578063d7cb69701461063b578063dfccfc701461064457600080fd5b8063a22cb4651161013b578063a22cb4651461059a578063a85adeab146105ad578063b88d4fde146105b6578063c1292cc3146105c9578063c44bef75146105d2578063c45a0155146105e557600080fd5b80637eaf5dab1461053b5780638da5cb5b1461054e578063902413d01461055f57806395d89b411461057257806398428dbf1461057a578063991784081461058757600080fd5b80633644e515116102265780636352211e116101df5780636352211e146104df57806370a08231146104f2578063715018a61461050557806371aac7f91461050d57806378ce8b40146105155780637df6a6c81461052857600080fd5b80633644e5151461042657806342842e0e1461044d578063482ddde2146104605780635576b87114610469578063572b6c051461047c57806357472ad2146104bc57600080fd5b80630ba0f2ae116102785780630ba0f2ae146103a85780631278e00a146103bb57806323b872dd146103ce578063242284f1146103e157806324600fc3146103e957806330adf81f146103f157600080fd5b806301ffc9a7146102c057806304386f52146102e857806306fdde03146102fd578063081812fc14610312578063091c76f51461033d578063095ea7b314610395575b600080fd5b6102d36102ce366004612dd1565b610701565b60405190151581526020015b60405180910390f35b6102fb6102f6366004612df5565b610753565b005b610305610807565b6040516102df9190612e5e565b610325610320366004612df5565b610899565b6040516001600160a01b0390911681526020016102df565b6013546014546015546103649291906001600160a01b03811690600160a01b900460ff1684565b6040516102df949392919093845260208401929092526001600160a01b031660408301521515606082015260800190565b6102fb6103a3366004612e86565b6108c0565b600e546102d39062010000900460ff1681565b6102fb6103c9366004612eb2565b6109ec565b6102fb6103dc366004612ef5565b610b8e565b6102fb610bc6565b6102fb610d9b565b6104187f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020016102df565b6104187f000000000000000000000000000000000000000000000000000000000000000081565b6102fb61045b366004612ef5565b610e8d565b610418600b5481565b6102fb610477366004612f44565b610ea8565b6102d361048a366004612f61565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b6102d36104ca366004612df5565b60116020526000908152604090205460ff1681565b6103256104ed366004612df5565b610f77565b610418610500366004612f61565b610fd7565b6102fb61105d565b6102fb61106f565b6102fb610523366004612f7e565b6111a5565b6102fb610536366004612df5565b6113f8565b6102fb610549366004612f44565b611529565b6000546001600160a01b0316610325565b61041861056d36600461304b565b6115f4565b61030561165c565b600e546102d39060ff1681565b6102fb6105953660046130a3565b61166b565b6102fb6105a8366004613105565b611766565b610418600a5481565b6102fb6105c436600461313e565b611778565b61041860085481565b6102fb6105e0366004612df5565b6117b1565b600754610325906001600160a01b031681565b610305610606366004612df5565b6118ea565b610418600c5481565b6102fb610622366004612df5565b611956565b600e546102d3906301000000900460ff1681565b61041860125481565b6102fb610652366004613202565b611b52565b6102d3610665366004612df5565b60106020526000908152604090205460ff1681565b61041860095481565b6102d361069136600461321a565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b6102fb6106cd366004612f61565b611c0e565b600e546102d390610100900460ff1681565b6102fb611c87565b600e546102d390640100000000900460ff1681565b60006001600160e01b031982166380ac58cd60e01b148061073257506001600160e01b03198216635b5e139f60e01b145b8061074d57506301ffc9a760e01b6001600160e01b03198316145b92915050565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ca9190613248565b6001600160a01b03166107db611f5d565b6001600160a01b031614610802576040516354348f0360e01b815260040160405180910390fd5b600b55565b60606001805461081690613265565b80601f016020809104026020016040519081016040528092919081815260200182805461084290613265565b801561088f5780601f106108645761010080835404028352916020019161088f565b820191906000526020600020905b81548152906001019060200180831161087257829003601f168201915b5050505050905090565b60006108a482611f6c565b506000908152600560205260409020546001600160a01b031690565b60006108cb82610f77565b9050806001600160a01b0316836001600160a01b03160361093d5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b806001600160a01b031661094f611f5d565b6001600160a01b0316148061096b575061096b81610691611f5d565b6109dd5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610934565b6109e78383611fcb565b505050565b6009544210806109fd5750600a5442115b15610a1b5760405163219a945b60e11b815260040160405180910390fd5b600f6000610a27611f5d565b6001600160a01b0316815260208101919091526040016000205460ff1615610a6257604051632cfe303760e21b815260040160405180910390fd5b83421115610a83576040516305787bdf60e01b815260040160405180910390fd5b600e54640100000000900460ff1615610b2157610b21610aa1611f5d565b85858585600760009054906101000a90046001600160a01b03166001600160a01b0316632b7ac3f36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610af8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b1c9190613248565b612039565b60005b600b54811015610b5057610b3e610b39611f5d565b61211b565b80610b48816132af565b915050610b24565b50600e5462010000900460ff168015610b735750601554600160a01b900460ff16155b15610b8857610b88610b83611f5d565b61218a565b50505050565b610b9f610b99611f5d565b826122eb565b610bbb5760405162461bcd60e51b8152600401610934906132c8565b6109e783838361236a565b600a54421015610be95760405163cc76115360e01b815260040160405180910390fd5b600e546301000000900460ff1615610c395760405162461bcd60e51b8152602060048201526013602482015272526166666c6520616c726561647920646f6e6560681b6044820152606401610934565b601554600160a01b900460ff16610c865760405162461bcd60e51b81526020600482015260116024820152704e6f74206120726166666c65207761766560781b6044820152606401610934565b610c8e611f5d565b6001600160a01b03167fe5ed10a2abb6a808edb6fbb7ae5cd09aad196ddaa1bd4e9295688a4d508460c860405160405180910390a26007546040805163aa6527d960e01b815290516000926001600160a01b03169163aa6527d99160048083019260209291908290030181865afa158015610d0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d319190613248565b9050806001600160a01b031663dea12bad6040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610d73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d979190613315565b5050565b600a54421015610dbe5760405163cc76115360e01b815260040160405180910390fd5b601554600160a01b900460ff1615610e7657600e546301000000900460ff1680610deb5750610deb61239e565b610e765760405162461bcd60e51b815260206004820152605060248201527f43616e20776974686472617720726166666c652066756e6473206f6e6c79206960448201527f6620726166666c6520697320636f6d706c65746564206f7220676f7665726e6160648201526f1b98d9481c995c5d595cdd1959081a5d60821b608482015260a401610934565b601554610e8b906001600160a01b031661242c565b565b6109e783838360405180602001604052806000815250611778565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa158015610efb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1f9190613248565b6001600160a01b0316610f30611f5d565b6001600160a01b031614610f57576040516354348f0360e01b815260040160405180910390fd5b600e80549115156401000000000264ff0000000019909216919091179055565b6000818152600360205260408120546001600160a01b03168061074d5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610934565b60006001600160a01b0382166110415760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610934565b506001600160a01b031660009081526004602052604090205490565b61106561256d565b610e8b60006125e6565b6009544210806110805750600a5442115b1561109e5760405163219a945b60e11b815260040160405180910390fd5b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111159190613248565b6001600160a01b0316611126611f5d565b6001600160a01b03161415801561115857506000546001600160a01b031661114c611f5d565b6001600160a01b031614155b1561117657604051637d7b71b560e01b815260040160405180910390fd5b42600a556040517f434b671a95fb0071b0127874981939c3cd42e8f1f7d602b761482102d4a5507290600090a1565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061121c9190613248565b6001600160a01b031661122d611f5d565b6001600160a01b03161415801561125f57506000546001600160a01b0316611253611f5d565b6001600160a01b031614155b1561127d57604051637d7b71b560e01b815260040160405180910390fd5b601554600160a01b900460ff166112e85760405162461bcd60e51b815260206004820152602960248201527f43616e207175616c69667920746f6b656e20696473206f6e6c7920696620726160448201526866666c65207761766560b81b6064820152608401610934565b6000805b838110156113c85760008585838181106113085761130861332e565b9050602002013590508060001415801561132457506008548111155b6113705760405162461bcd60e51b815260206004820152601a60248201527f496e76616c696420746f6b656e496420746f207175616c6966790000000000006044820152606401610934565b60008181526011602052604090205484151560ff90911615036113b5576000818152601160205260409020805460ff1916851515179055826113b1816132af565b9350505b50806113c0816132af565b9150506112ec565b50816113e157806012546113dc9190613344565b6113ef565b806012546113ef9190613357565b60125550505050565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa15801561144b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061146f9190613248565b6001600160a01b0316611480611f5d565b6001600160a01b0316141580156114b257506000546001600160a01b03166114a6611f5d565b6001600160a01b031614155b156114d057604051637d7b71b560e01b815260040160405180910390fd5b42811180156114e0575060095481115b6115245760405162461bcd60e51b81526020600482015260156024820152740496e76616c696420656e642074696d657374616d7605c1b6044820152606401610934565b600a55565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa15801561157c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a09190613248565b6001600160a01b03166115b1611f5d565b6001600160a01b0316146115d8576040516354348f0360e01b815260040160405180910390fd5b600e8054911515620100000262ff000019909216919091179055565b60007f000000000000000000000000000000000000000000000000000000000000000061162083612636565b60405161190160f01b6020820152602281019290925260428201526062015b604051602081830303815290604052805190602001209050919050565b60606002805461081690613265565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e29190613248565b6001600160a01b03166116f3611f5d565b6001600160a01b03161415801561172557506000546001600160a01b0316611719611f5d565b6001600160a01b031614155b1561174357604051637d7b71b560e01b815260040160405180910390fd5b600d6117508385836133b8565b50600e805460ff19169115159190911790555050565b610d97611771611f5d565b838361268c565b611789611783611f5d565b836122eb565b6117a55760405162461bcd60e51b8152600401610934906132c8565b610b888484848461275a565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa158015611804573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118289190613248565b6001600160a01b0316611839611f5d565b6001600160a01b03161415801561186b57506000546001600160a01b031661185f611f5d565b6001600160a01b031614155b1561188957604051637d7b71b560e01b815260040160405180910390fd5b80421080156118995750600a5481105b6118e55760405162461bcd60e51b815260206004820152601760248201527f496e76616c69642073746172742074696d657374616d700000000000000000006044820152606401610934565b600955565b60606118f582611f6c565b600e5460ff1661192557600d60405160200161191191906134ec565b60405160208183030381529060405261074d565b600d6119308361278d565b604051602001611941929190613516565b60405160208183030381529060405292915050565b600a544210156119795760405163cc76115360e01b815260040160405180910390fd5b600760009054906101000a90046001600160a01b03166001600160a01b031663aa6527d96040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f09190613248565b6001600160a01b0316611a01611f5d565b6001600160a01b031614158015611aa75750600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a8a9190613248565b6001600160a01b0316611a9b611f5d565b6001600160a01b031614155b8015611ace57506000546001600160a01b0316611ac2611f5d565b6001600160a01b031614155b15611aec57604051636c94aad360e01b815260040160405180910390fd5b600c5415611b4d5760405162461bcd60e51b815260206004820152602860248201527f52616e646f6d206e756d6265722068617320616c7265616479206265656e20656044820152671e1d1c9858dd195960c21b6064820152608401610934565b600c55565b600760009054906101000a90046001600160a01b03166001600160a01b031663aced16616040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ba5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc99190613248565b6001600160a01b0316611bda611f5d565b6001600160a01b031614611c01576040516354348f0360e01b815260040160405180910390fd5b8060136109e7828261355a565b611c1661256d565b6001600160a01b038116611c7b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610934565b611c84816125e6565b50565b600a54421015611caa5760405163cc76115360e01b815260040160405180910390fd5b600e546301000000900460ff1615611cfa5760405162461bcd60e51b8152602060048201526013602482015272526166666c6520616c726561647920646f6e6560681b6044820152606401610934565b600c54600003611d585760405162461bcd60e51b815260206004820152602360248201527f52616e646f6d206e756d62657220776173206e6f7420657874726163746564206044820152621e595d60ea1b6064820152608401610934565b6015546014546013546012546008546001600160a01b0390941693600091611d7f91613344565b90506000828210611d905782611d92565b815b9050846000805b83811015611f0f5760005b600854600c5460408051602081019290925281018590526060016040516020818303038152906040528051906020012060001c611de191906135b7565b611dec906001613357565b905082611df8816132af565b60008381526010602052604090205490945060ff169050611da4576000818152601060205260408120805460ff19166001179055611e3582610f77565b60405163a9059cbb60e01b81526001600160a01b038083166004830152602482018c90529192509086169063a9059cbb906044016020604051808303816000875af1158015611e88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eac91906135d9565b50896001600160a01b0316816001600160a01b03167f80b887c8189ccc457f4b3077692f6d6d11abc05537566d3273df1747af5349548b604051611ef291815260200190565b60405180910390a350508080611f07906132af565b915050611d99565b50600e805463ff000000191663010000001790556040517f27570828a3b3d654a69144a8ca6c7e066e01acd2e5c41405c83fa9f03011831290600090a1611f54610d9b565b50505050505050565b6000611f67612820565b905090565b6000818152600360205260409020546001600160a01b0316611c845760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610934565b600081815260056020526040902080546001600160a01b0319166001600160a01b038416908117909155819061200082610f77565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006120616040518060400160405280896001600160a01b03168152602001888152506115f4565b90506000600161207083612864565b6040805160008152602081018083529290925260ff891690820152606081018790526080810186905260a0016020604051602081039080840390855afa1580156120be573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615806120f35750826001600160a01b0316816001600160a01b031614155b1561211157604051638baa579f60e01b815260040160405180910390fd5b5050505050505050565b6121388160086000815461212e906132af565b918290555061289f565b6001600160a01b0381166000818152600f6020526040808220805460ff1916600117905560085490519092917fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a91a350565b6015546014546040516370a0823160e01b81523060048201526001600160a01b039092169160009083906370a0823190602401602060405180830381865afa1580156121da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121fe9190613315565b601354908311159150158015906122125750805b15610b885760405163a9059cbb60e01b81526001600160a01b0385811660048301526024820184905284169063a9059cbb906044016020604051808303816000875af1158015612266573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061228a91906135d9565b506015546040518381526001600160a01b03918216918616907f2b5a46847b5904937aa26c09373883ac411399d3404814f716b47721af04ff4f9060200160405180910390a3601380549060006122e0836135f6565b919050555050505050565b6000806122f783610f77565b9050806001600160a01b0316846001600160a01b0316148061233e57506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b806123625750836001600160a01b031661235784610899565b6001600160a01b0316145b949350505050565b600e54610100900460ff1615612393576040516354ee515160e01b815260040160405180910390fd5b6109e78383836128b9565b6007546040805163aced166160e01b815290516000926001600160a01b03169163aced16619160048083019260209291908290030181865afa1580156123e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240c9190613248565b6001600160a01b031661241d611f5d565b6001600160a01b031614905090565b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa158015612473573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124979190613315565b9050801561253357816001600160a01b031663a9059cbb6124c06000546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303816000875af115801561250d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061253191906135d9565b505b60405181906001600160a01b038416907feaff4b37086828766ad3268786972c0cd24259d4c87a80f9d3963a3c3d999b0d90600090a35050565b612575611f5d565b6001600160a01b03166125906000546001600160a01b031690565b6001600160a01b031614610e8b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610934565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b805160208083015160405160009361163f937f0000000000000000000000000000000000000000000000000000000000000000939192019283526001600160a01b03919091166020830152604082015260600190565b816001600160a01b0316836001600160a01b0316036126ed5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610934565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b61276584848461236a565b61277184848484612a1d565b610b885760405162461bcd60e51b81526004016109349061360d565b6060600061279a83612b25565b600101905060008167ffffffffffffffff8111156127ba576127ba613004565b6040519080825280601f01601f1916602001820160405280156127e4576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846127ee57509392505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361285f575060131936013560601c90565b503390565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c0161163f565b610d97828260405180602001604052806000815250612bfd565b826001600160a01b03166128cc82610f77565b6001600160a01b0316146128f25760405162461bcd60e51b81526004016109349061365f565b6001600160a01b0382166129545760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610934565b826001600160a01b031661296782610f77565b6001600160a01b03161461298d5760405162461bcd60e51b81526004016109349061365f565b600081815260056020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260048552838620805460001901905590871680865283862080546001019055868652600390945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60006001600160a01b0384163b15612b1a57836001600160a01b031663150b7a02612a46611f5d565b8786866040518563ffffffff1660e01b8152600401612a6894939291906136a4565b6020604051808303816000875af1925050508015612aa3575060408051601f3d908101601f19168201909252612aa0918101906136e1565b60015b612b00573d808015612ad1576040519150601f19603f3d011682016040523d82523d6000602084013e612ad6565b606091505b508051600003612af85760405162461bcd60e51b81526004016109349061360d565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612362565b506001949350505050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310612b645772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310612b90576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310612bae57662386f26fc10000830492506010015b6305f5e1008310612bc6576305f5e100830492506008015b6127108310612bda57612710830492506004015b60648310612bec576064830492506002015b600a831061074d5760010192915050565b612c078383612c30565b612c146000848484612a1d565b6109e75760405162461bcd60e51b81526004016109349061360d565b6001600160a01b038216612c865760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610934565b6000818152600360205260409020546001600160a01b031615612ceb5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610934565b6000818152600360205260409020546001600160a01b031615612d505760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610934565b6001600160a01b038216600081815260046020908152604080832080546001019055848352600390915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6001600160e01b031981168114611c8457600080fd5b600060208284031215612de357600080fd5b8135612dee81612dbb565b9392505050565b600060208284031215612e0757600080fd5b5035919050565b60005b83811015612e29578181015183820152602001612e11565b50506000910152565b60008151808452612e4a816020860160208601612e0e565b601f01601f19169290920160200192915050565b602081526000612dee6020830184612e32565b6001600160a01b0381168114611c8457600080fd5b60008060408385031215612e9957600080fd5b8235612ea481612e71565b946020939093013593505050565b60008060008060808587031215612ec857600080fd5b84359350602085013560ff81168114612ee057600080fd5b93969395505050506040820135916060013590565b600080600060608486031215612f0a57600080fd5b8335612f1581612e71565b92506020840135612f2581612e71565b929592945050506040919091013590565b8015158114611c8457600080fd5b600060208284031215612f5657600080fd5b8135612dee81612f36565b600060208284031215612f7357600080fd5b8135612dee81612e71565b600080600060408486031215612f9357600080fd5b833567ffffffffffffffff80821115612fab57600080fd5b818601915086601f830112612fbf57600080fd5b813581811115612fce57600080fd5b8760208260051b8501011115612fe357600080fd5b60209283019550935050840135612ff981612f36565b809150509250925092565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561304357613043613004565b604052919050565b60006040828403121561305d57600080fd5b6040516040810181811067ffffffffffffffff8211171561308057613080613004565b604052823561308e81612e71565b81526020928301359281019290925250919050565b6000806000604084860312156130b857600080fd5b833567ffffffffffffffff808211156130d057600080fd5b818601915086601f8301126130e457600080fd5b8135818111156130f357600080fd5b876020828501011115612fe357600080fd5b6000806040838503121561311857600080fd5b823561312381612e71565b9150602083013561313381612f36565b809150509250929050565b6000806000806080858703121561315457600080fd5b843561315f81612e71565b935060208581013561317081612e71565b935060408601359250606086013567ffffffffffffffff8082111561319457600080fd5b818801915088601f8301126131a857600080fd5b8135818111156131ba576131ba613004565b6131cc601f8201601f1916850161301a565b915080825289848285010111156131e257600080fd5b808484018584013760008482840101525080935050505092959194509250565b60006080828403121561321457600080fd5b50919050565b6000806040838503121561322d57600080fd5b823561323881612e71565b9150602083013561313381612e71565b60006020828403121561325a57600080fd5b8151612dee81612e71565b600181811c9082168061327957607f821691505b60208210810361321457634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016132c1576132c1613299565b5060010190565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b60006020828403121561332757600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b8181038181111561074d5761074d613299565b8082018082111561074d5761074d613299565b601f8211156109e757600081815260208120601f850160051c810160208610156133915750805b601f850160051c820191505b818110156133b05782815560010161339d565b505050505050565b67ffffffffffffffff8311156133d0576133d0613004565b6133e4836133de8354613265565b8361336a565b6000601f84116001811461341857600085156134005750838201355b600019600387901b1c1916600186901b178355613472565b600083815260209020601f19861690835b828110156134495786850135825560209485019460019092019101613429565b50868210156134665760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b6000815461348681613265565b6001828116801561349e57600181146134b3576134e2565b60ff19841687528215158302870194506134e2565b8560005260208060002060005b858110156134d95781548a8201529084019082016134c0565b50505082870194505b5050505092915050565b60006134f88284613479565b6d17b6b2ba30b230ba30973539b7b760911b8152600e019392505050565b60006135228285613479565b602f60f81b8152835161353c816001840160208801612e0e565b64173539b7b760d91b60019290910191820152600601949350505050565b813581556020820135600182015560028101604083013561357a81612e71565b8154606085013561358a81612f36565b60ff60a01b90151560a01b166001600160a01b03929092166001600160a81b031991909116171790555050565b6000826135d457634e487b7160e01b600052601260045260246000fd5b500690565b6000602082840312156135eb57600080fd5b8151612dee81612f36565b60008161360557613605613299565b506000190190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906136d790830184612e32565b9695505050505050565b6000602082840312156136f357600080fd5b8151612dee81612dbb56fea26469706673582212203c717e2036b6f21e9a80977842633d252e91373aea8b695747d56ef9c304ddad64736f6c63430008150033a2646970667358221220b37f75e52aabb6bc8bbf8768a14adb0bd39c9f4226b508f40ea10d157aa7b18b64736f6c63430008150033

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

000000000000000000000000607291c9b3b03d8c2dc1f5f7f8db2b6a06c911830000000000000000000000008f5b08237d9aaf212a6abef3379149765dee9c1000000000000000000000000075d14f0ae59003c0806b625b402a40340ffde634000000000000000000000000a668bdf7ac5f9a2c45f0f233708ea654993d219d

-----Decoded View---------------
Arg [0] : _keeper (address): 0x607291C9B3b03D8C2DC1F5f7F8db2B6A06C91183
Arg [1] : _trustedForwarder (address): 0x8f5B08237d9aaf212a6ABeF3379149765dEE9C10
Arg [2] : _verifier (address): 0x75d14F0Ae59003C0806B625B402a40340Ffde634
Arg [3] : _raffleManager (address): 0xA668BDf7AC5f9a2C45F0F233708ea654993D219d

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000607291c9b3b03d8c2dc1f5f7f8db2b6a06c91183
Arg [1] : 0000000000000000000000008f5b08237d9aaf212a6abef3379149765dee9c10
Arg [2] : 00000000000000000000000075d14f0ae59003c0806b625b402a40340ffde634
Arg [3] : 000000000000000000000000a668bdf7ac5f9a2c45f0f233708ea654993d219d


Block Transaction Gas Used Reward
view all blocks produced

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

Validator Index Block Amount
View All Withdrawals

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

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