HYPE Price: $21.95 (-0.85%)
 

Overview

HYPE Balance

HyperEVM LogoHyperEVM LogoHyperEVM Logo0 HYPE

HYPE Value

$0.00

More Info

Private Name Tags

Transaction Hash
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MEMELaunchpad

Compiler Version
v0.8.21+commit.d9974bed

Optimization Enabled:
Yes with 10000 runs

Other Settings:
shanghai EvmVersion
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;

import { UtilLib } from "../utils/UtilLib.sol";
import { MEMEToken } from "./MEMEToken.sol";
import { IMEMELaunchpad } from "./interfaces/IMEMELaunchpad.sol";
import { IMEMEToken } from "./interfaces/IMEMEToken.sol";
import { LaunchpadLibrary } from "./libraries/LaunchpadLibrary.sol";
import { HyperpieConstants } from "../utils/HyperpieConstants.sol";
import { IHyperpieConfig } from "../interfaces/IHyperpieConfig.sol";
import { IHyperpiePair } from "../memedex/interfaces/IHyperpiePair.sol";
import { IHyperpieRouter } from "../memedex/interfaces/IHyperpieRouter.sol";
import { IHyperpieFactory } from "../memedex/interfaces/factories/IHyperpieFactory.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { Create2 } from "@openzeppelin/contracts/utils/Create2.sol";
import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import { ICurveCalculator } from "./interfaces/ICurveCalculator.sol";
import { ILaunchpadStorage } from "./interfaces/ILaunchpadStorage.sol";
import { IWHYPE } from "./interfaces/IWHYPE.sol";
import { RoleCheckerLib } from "../libraries/RoleCheckerLib.sol";

/**
 * @title MEMELaunchpad
 * @notice Manages the bonding phase for MEME tokens and handles liquidity pool creation
 * @dev Implements anti-sniping measures to protect new token launches
 */
contract MEMELaunchpad is IMEMELaunchpad, ReentrancyGuardUpgradeable, PausableUpgradeable {
    using SafeERC20 for IERC20;

    uint256 private constant NO_MINIMUM_AMOUNT = 0;

    // launchpad storage variables
    ILaunchpadStorage public launchpadStorage;

    // native token wrapper
    IWHYPE public wNative;

    IHyperpieConfig public hyperpieConfig;

    // Mapping of token address to launch info
    mapping(address => LaunchInfo) public launches;

    // Array of all tokens launched through this contract
    address[] public allLaunches;

    /*//////////////////////////////////////////////////////////////
                            CONSTRUCTOR & INITIALIZER
    //////////////////////////////////////////////////////////////*/
    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    /**
     * @notice Initializes the contract
     * @param _hyperpieConfig Address of the HyperpieConfig contract
     */
    function initialize(address _hyperpieConfig, address _launchpadStorage, address _wNative) external initializer {
        UtilLib.checkNonZeroAddress(_hyperpieConfig);

        __ReentrancyGuard_init();
        __Pausable_init();

        wNative = IWHYPE(_wNative);
        hyperpieConfig = IHyperpieConfig(_hyperpieConfig);
        launchpadStorage = ILaunchpadStorage(_launchpadStorage);

        emit UpdatedHyperpieConfig(_hyperpieConfig);
    }

    receive() external payable {
        if (msg.sender != address(wNative)) revert OnlyWETH();
    }

    /**
     * @notice Get the total number of launches
     * @return Total launch count
     */
    function getLaunchCount() external view returns (uint256) {
        return allLaunches.length;
    }

    /**
     * @notice Get launch info
     * @param _token Address of the MEME token
     * @return LaunchInfo Launch information
     */
    function getLaunchInfo(address _token) external view returns (LaunchInfo memory) {
        return launches[_token];
    }

    /**
     * @notice Quote the amount of deposit tokens needed to buy or received upon selling, _amount of MEME tokens
     * @param _memeToken Address of the MEME token
     * @param _memeTokenAmount Amount of MEME tokens to buy or sell. The step size is 10^18. so, it should be a multiple
     * of 10^18.
     * @return depositTokenAmountRecAfterFee Amount of deposit tokens received after fees
     */
    function quoteSellMemeTokenAmount(
        address _memeToken,
        uint256 _memeTokenAmount
    )
        public
        view
        returns (uint256 depositTokenAmountRecAfterFee)
    {
        LaunchInfo memory launchInfo = launches[_memeToken];

        uint256 depositTokenAmountRecBeforeFee =
            ICurveCalculator(launchInfo.curveCalculator).calculateSellQuote(launchInfo, _memeTokenAmount);
        depositTokenAmountRecAfterFee = LaunchpadLibrary.afterFee(
            depositTokenAmountRecBeforeFee, ILaunchpadStorage(launchpadStorage).totalTradingFee()
        );
    }

    /**
     * @notice Quote the amount of MEME tokens needed to buy or received upon selling, _amount of deposit tokens
     * @param _memeToken Address of the MEME token
     * @param _depositTokenAmount Amount of deposit tokens to buy or sell. The step size is 10^18. so, it should be a
     * multiple of 10^18.
     * @return memeTokenAmount Amount of MEME tokens needed to buy or received upon selling, _amount of deposit tokens
     */
    function quoteBuyMemeTokenAmount(
        address _memeToken,
        uint256 _depositTokenAmount
    )
        public
        view
        returns (uint256 memeTokenAmount)
    {
        LaunchInfo memory launchInfo = launches[_memeToken];

        return ICurveCalculator(launchInfo.curveCalculator).calculateBuyMEMETokenQuote(
            launchInfo, _depositTokenAmount, ILaunchpadStorage(launchpadStorage).totalTradingFee()
        );
    }

    /**
     * @notice Quote the maximum amount of deposit token that can be inputted into the bonding curve
     * @param _memeToken Address of the MEME token
     * @return remainingDepositTokenAmountBeforeFee Maximum amount of deposit token that can be inputted into the
     * bonding curve
     */
    function quoteMaxDepositTokenInputAmount(address _memeToken) public view returns (uint256) {
        LaunchInfo memory launchInfo = launches[_memeToken];

        uint256 remainingDepositTokenAmountAfterFee =
            launchInfo.depositTokenInfo.depositTokenAmountTarget - launchInfo.depositTokenAmountRaised;
        uint256 remainingDepositTokenAmountBeforeFee = LaunchpadLibrary.beforeFee(
            remainingDepositTokenAmountAfterFee, ILaunchpadStorage(launchpadStorage).totalTradingFee()
        );

        return remainingDepositTokenAmountBeforeFee;
    }

    /**
     * @notice Create a new token launch
     * @param _params Launch creation parameters
     * @return memeTokenAddress Address of the newly created MEME token
     */
    function createLaunch(LaunchCreationParams memory _params)
        external
        payable
        nonReentrant
        whenNotPaused
        returns (address memeTokenAddress)
    {
        address curveCalculator = ILaunchpadStorage(launchpadStorage).curveCalculators(_params.curveType);
        uint256 maxCreatorBuyAmountPercentage = ILaunchpadStorage(launchpadStorage).maxCreatorBuyAmountPercentage();

        LaunchpadLibrary.createLaunchPreChecks(
            _params,
            curveCalculator,
            ILaunchpadStorage(launchpadStorage).getDepositTokenInfo(_params.curveType, _params.depositToken),
            maxCreatorBuyAmountPercentage
        );

        memeTokenAddress = Create2.deploy(
            0,
            _params.salt,
            abi.encodePacked(type(MEMEToken).creationCode, abi.encode(_params.tokenName, _params.tokenSymbol))
        );

        LaunchInfo storage launchInfo = launches[memeTokenAddress];
        launchInfo.memeToken = memeTokenAddress;
        launchInfo.memeTokenCreator = msg.sender;
        launchInfo.curveType = _params.curveType;
        launchInfo.depositTokenAddress = _params.depositToken;
        launchInfo.launchTimestamp = _params.startTime < block.timestamp ? block.timestamp : _params.startTime;
        launchInfo.depositTokenAmountRaised = 0;
        launchInfo.soldMemeTokenAmount = 0;
        launchInfo.pair = address(0);
        launchInfo.depositTokenInfo =
            ILaunchpadStorage(launchpadStorage).getDepositTokenInfo(_params.curveType, _params.depositToken);
        launchInfo.curveCalculator = curveCalculator;
        launchInfo.tags = _params.tags;
        launchInfo.tokenURI = _params.tokenURI;

        allLaunches.push(memeTokenAddress);

        emit UserReferralSet(msg.sender, _params.referral);

        if (_params.creatorBuyAmountNative > 0) {
            LaunchpadLibrary.buyMemeTokenPreChecksNative(launchInfo, address(wNative), msg.value);

            uint256 wrappedNativeAmount = LaunchpadLibrary.wrapNative(wNative, msg.value);
            _buyMemeToken(launchInfo, wrappedNativeAmount, NO_MINIMUM_AMOUNT, true, _params.referral);
        } else if (_params.creatorBuyAmount > 0) {
            _buyMemeToken(launchInfo, _params.creatorBuyAmount, NO_MINIMUM_AMOUNT, false, _params.referral);
        }

        emit LaunchCreated(
            memeTokenAddress,
            msg.sender,
            _params.curveType,
            _params.depositToken,
            launchInfo.depositTokenInfo.depositTokenAmountTarget,
            launchInfo.depositTokenInfo.initialMemeTokenPrice,
            launchInfo.launchTimestamp,
            MEMEToken(memeTokenAddress).totalSupply(),
            _params.creatorBuyAmount,
            _params.creatorBuyAmountNative,
            launchInfo.curveCalculator,
            launchInfo.tags,
            launchInfo.tokenURI
        );
    }

    /**
     * @notice Buy MEME tokens in a token launch
     * @param _memeToken Address of the MEME token
     * @param _depositTokenAmount Amount of deposit token to contribute
     * @param _minReceivedMemeTokenAmount Minimum amount of Meme tokens to receive
     */
    function buyMemeTokenWithoutPoolCreation(
        address _memeToken,
        uint256 _depositTokenAmount,
        uint256 _minReceivedMemeTokenAmount,
        address _referral
    )
        external
        nonReentrant
        whenNotPaused
    {
        LaunchInfo storage launchInfo = launches[_memeToken];
        LaunchpadLibrary.tradePreChecks(launchInfo, _memeToken, _depositTokenAmount);

        _buyMemeToken(launchInfo, _depositTokenAmount, _minReceivedMemeTokenAmount, false, _referral);
    }

    function buyMemeTokenWithoutPoolCreationNative(
        address _memeToken,
        uint256 _minReceivedMemeTokenAmount,
        address _referral
    )
        external
        payable
        nonReentrant
        whenNotPaused
    {
        LaunchInfo storage launchInfo = launches[_memeToken];
        LaunchpadLibrary.buyMemeTokenPreChecksNative(launchInfo, address(wNative), msg.value);
        LaunchpadLibrary.tradePreChecks(launchInfo, _memeToken, msg.value);

        uint256 wrappedNativeAmount = LaunchpadLibrary.wrapNative(wNative, msg.value);
        _buyMemeToken(launchInfo, wrappedNativeAmount, _minReceivedMemeTokenAmount, true, _referral);
    }

    /**
     * @notice Buy MEME tokens in a token launch and also finalize the launch if the bonding curve is filled and the
     * extra deposit token is swapped for the meme token in pool created.
     * @param _memeToken Address of the MEME token
     * @param _depositTokenAmount Amount of deposit token to contribute before fees
     * @param _minReceivedMemeTokenAmount Minimum amount of Meme tokens to receive
     */
    function buyMemeTokenWithPoolCreationAndSwap(
        address _memeToken,
        uint256 _depositTokenAmount,
        uint256 _minReceivedMemeTokenAmount,
        address _referral
    )
        external
        nonReentrant
        whenNotPaused
    {
        LaunchInfo storage launchInfo = launches[_memeToken];
        LaunchpadLibrary.tradePreChecks(launchInfo, _memeToken, _depositTokenAmount);

        _buyMemeTokenWithPoolCreationAndSwap(launchInfo, _depositTokenAmount, _minReceivedMemeTokenAmount, false, _referral);
    }

    function buyMemeTokenWithPoolCreationAndSwapNative(
        address _memeToken,
        uint256 _minReceivedMemeTokenAmount,
        address _referral
    )
        external
        payable
        nonReentrant
        whenNotPaused
    {
        LaunchInfo storage launchInfo = launches[_memeToken];
        LaunchpadLibrary.buyMemeTokenPreChecksNative(launchInfo, address(wNative), msg.value);
        LaunchpadLibrary.tradePreChecks(launchInfo, _memeToken, msg.value);

        uint256 wrappedNativeAmount = LaunchpadLibrary.wrapNative(wNative, msg.value);
        _buyMemeTokenWithPoolCreationAndSwap(launchInfo, wrappedNativeAmount, _minReceivedMemeTokenAmount, true, _referral);
    }

    /**
     * @notice Sell MEME tokens in a token launch
     * @param _memeToken Address of the MEME token
     * @param _memeTokenAmount Amount of Meme tokens to sell
     * @param _minDepositTokenAmount Minimum amount of deposit token to receive
     */
    function sellMemeToken(
        address _memeToken,
        uint256 _memeTokenAmount,
        uint256 _minDepositTokenAmount,
        address _referral
    )
        external
        nonReentrant
        whenNotPaused
    {
        LaunchInfo storage launchInfo = launches[_memeToken];
        LaunchpadLibrary.tradePreChecks(launchInfo, _memeToken, _memeTokenAmount);
        if (_memeTokenAmount > launchInfo.soldMemeTokenAmount) {
            revert InsufficientMemeTokenBalance();
        }

        _sellMemeToken(launchInfo, _memeTokenAmount, _minDepositTokenAmount, _referral);
    }

    /**
     * @notice Internal function to finalize a launch and create liquidity pool
     * @param _memeTokens Addresses of the MEME token
     */
    function finalizeLaunch(address[] calldata _memeTokens) external nonReentrant whenNotPaused {
        RoleCheckerLib.onlyAllowedBot(address(hyperpieConfig));
        for (uint256 i = 0; i < _memeTokens.length; i++) {
            _finalizeLaunch(_memeTokens[i]);
        }
    }

    /**
     * @notice Pause the contract
     */
    function pause() external {
        RoleCheckerLib.onlyPauser(address(hyperpieConfig));
        _pause();
    }

    /**
     * @notice Unpause the contract
     */
    function unpause() external {
        RoleCheckerLib.onlyDefaultAdmin(address(hyperpieConfig));
        _unpause();
    }

    function updateConfig(address _hyperpieConfig) external {
        UtilLib.checkNonZeroAddress(_hyperpieConfig);
        RoleCheckerLib.onlyDefaultAdmin(address(hyperpieConfig));
        hyperpieConfig = IHyperpieConfig(_hyperpieConfig);
        emit UpdatedHyperpieConfig(_hyperpieConfig);
    }
    
    // This will also redeict creator fee to the new creator 
    function setCreator(address _memeToken, address _creator) external {
        RoleCheckerLib.onlyMetaConfigRole(address(hyperpieConfig));

        LaunchInfo storage launchInfo = launches[_memeToken];
        LaunchpadLibrary.setNewCreator(launchInfo, _creator);
    }

    function _buyMemeToken(
        IMEMELaunchpad.LaunchInfo storage launchInfo,
        uint256 _depositTokenAmountBeforeFee,
        uint256 _minReceivedMemeTokenAmount,
        bool _isNative,
        address _referral
    )
        internal
    {
        uint256 memeTokenAmount = LaunchpadLibrary.buyMemeToken(
            launchInfo,
            _depositTokenAmountBeforeFee,
            _minReceivedMemeTokenAmount,
            ILaunchpadStorage(launchpadStorage).totalTradingFee(),
            ILaunchpadStorage(launchpadStorage).tokenCreatorFee(),
            ILaunchpadStorage(launchpadStorage).allTradingFeeInfos(),
            _isNative,
            wNative
        );

        emit UserReferralSet(msg.sender, _referral);

        emit MemeTokenBuy(launchInfo.memeToken, msg.sender, _depositTokenAmountBeforeFee, memeTokenAmount);

        if (launchInfo.depositTokenAmountRaised >= launchInfo.depositTokenInfo.depositTokenAmountTarget) {
            MEMEToken(launchInfo.memeToken).setMode(IMEMEToken.TransferMode.Restricted); // Set token to restricted mode
            emit PreLaunchPhaseStarted(launchInfo.memeToken, launchInfo.depositTokenAmountRaised);
        }
    }

    function _buyMemeTokenWithPoolCreationAndSwap(
        IMEMELaunchpad.LaunchInfo storage launchInfo,
        uint256 _depositTokenAmount,
        uint256 _minReceivedMemeTokenAmount,
        bool _isNative,
        address _referral
    )
        internal
    {
        uint256 purchaseInBondingCurve = quoteMaxDepositTokenInputAmount(launchInfo.memeToken);
        uint256 purchaseInGraduatePool;
        if (_depositTokenAmount > purchaseInBondingCurve) {
            purchaseInGraduatePool = _depositTokenAmount - purchaseInBondingCurve;
        } else {
            purchaseInBondingCurve = _depositTokenAmount;
        }

        _buyMemeToken(launchInfo, purchaseInBondingCurve, _minReceivedMemeTokenAmount, _isNative, _referral);

        if (launchInfo.depositTokenAmountRaised >= launchInfo.depositTokenInfo.depositTokenAmountTarget) {
            _finalizeLaunch(launchInfo.memeToken);

            if (purchaseInGraduatePool > 0) {
                LaunchpadLibrary.swapExtraDepositTokenForMemeToken(
                    launchInfo,
                    hyperpieConfig.getAddress(HyperpieConstants.HYPERPIE_ROUTER),
                    hyperpieConfig.getAddress(HyperpieConstants.FACTORY),
                    purchaseInGraduatePool,
                    msg.sender,
                    _isNative
                );
            }
        }
    }

    function _sellMemeToken(
        IMEMELaunchpad.LaunchInfo storage launchInfo,
        uint256 _memeTokenAmount,
        uint256 _minDepositTokenAmount,
        address _referral
    )
        internal
    {
        uint256 depositTokenAmountRecAfterFee = LaunchpadLibrary.sellMemeToken(
            launchInfo,
            _memeTokenAmount,
            _minDepositTokenAmount,
            ILaunchpadStorage(launchpadStorage).totalTradingFee(),
            ILaunchpadStorage(launchpadStorage).tokenCreatorFee(),
            ILaunchpadStorage(launchpadStorage).allTradingFeeInfos(),
            wNative
        );

        emit UserReferralSet(msg.sender, _referral);

        emit MemeTokenSell(launchInfo.memeToken, msg.sender, _memeTokenAmount, depositTokenAmountRecAfterFee);
    }

    function _finalizeLaunch(address _memeToken) internal {
        LaunchInfo storage launchInfo = launches[_memeToken];

        LaunchpadLibrary.finalizeLaunch(
            _memeToken,
            launchInfo,
            hyperpieConfig.getAddress(HyperpieConstants.HYPERPIE_ROUTER),
            hyperpieConfig.getAddress(HyperpieConstants.FACTORY),
            ILaunchpadStorage(launchpadStorage).allPoolCreationFeeInfos(),
            hyperpieConfig
        );

        emit LaunchFinalized(_memeToken, launchInfo.pair);
    }
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;

import { HyperpieConstants } from "./HyperpieConstants.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/// @title UtilLib - Utility library
/// @notice Utility functions for Hyperpie protocol
library UtilLib {
    /*//////////////////////////////////////////////////////////////
                                ERRORS
    //////////////////////////////////////////////////////////////*/
    error ZeroAddressNotAllowed();
    error TransferHYPEFailed();

    /*//////////////////////////////////////////////////////////////
                            UTILITY FUNCTIONS
    //////////////////////////////////////////////////////////////*/
    /// @dev zero address check modifier
    /// @param address_ address to check
    function checkNonZeroAddress(address address_) internal pure {
        if (address_ == address(0)) revert ZeroAddressNotAllowed();
    }

    /// @dev Safe transfer of HYPE (native token)
    /// @param to recipient address
    /// @param value amount to transfer
    function safeTransferHYPE(address to, uint256 value) internal {
        UtilLib.checkNonZeroAddress(to);
        (bool success,) = address(to).call{ value: value }("");
        if (!success) revert TransferHYPEFailed();
    }
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;

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

/**
 * @title MEMEToken
 * @notice A customizable MEME token with bonding phase restrictions
 * @dev Extends standard ERC20 with transfer restrictions during bonding phase
 */
contract MEMEToken is ERC20, Ownable, IMEMEToken {
    using SafeERC20 for IERC20;

    uint256 public constant TOTAL_SUPPLY = 1_000_000_000 ether;

    TransferMode public mode;

    /**
     * @notice Constructor for creating a new MEME token
     * @param _name Token name
     * @param _symbol Token symbol
     */
    constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) {
        if (bytes(_name).length == 0) {
            revert InvalidTokenName();
        }
        if (bytes(_symbol).length == 0) {
            revert InvalidTokenSymbol();
        }

        mode = TransferMode.Controlled;
        _mint(msg.sender, TOTAL_SUPPLY);
    }

    /**
     * @notice Set the mode of the token
     * @param v The new mode of the token
     */
    function setMode(TransferMode v) public onlyOwner {
        if (mode != TransferMode.Normal) {
            mode = v;
        }
    }

    /**
     * @notice Hook to restrict token transfers based on the current mode
     * @param from The address of the sender
     * @param to The address of the recipient
     * @param amount The amount of tokens to transfer
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
        super._beforeTokenTransfer(from, to, amount);
        if (mode == TransferMode.Restricted) {
            revert TransfersRestrictedDuringPreLaunchPhase();
        }

        if (mode == TransferMode.Controlled) {
            if (from != owner() && to != owner()) {
                revert TransfersRestrictedDuringBondingPhase();
            }
        }
    }
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;

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

/**
 * @title IMEMELaunchpad
 * @notice Interface for the MEME token launchpad
 */
interface IMEMELaunchpad {

    /**
     * @notice Tags for the token created, MEME by default
     */
    enum Tags {
        Meme,
        AI,
        Defi,
        Games,
        Infra,
        DeSci,
        Social,
        Depin,
        Charity,
        Others
    }
    /**
     * @notice Structure to store launch creation parameters
     */
    struct LaunchCreationParams {
        string tokenName;
        string tokenSymbol;
        address depositToken;
        uint256 startTime;
        uint256 creatorBuyAmount;
        uint256 creatorBuyAmountNative;
        uint8 curveType;
        bytes32 salt;
        Tags tags;
        string tokenURI; // Token URI
        address referral;
    }

    /**
     * @notice Structure to store launch information
     */
    struct LaunchInfo {
        address memeToken; // MEME token address
        address memeTokenCreator; // Creator address
        address depositTokenAddress; // Token used for payment
        uint256 launchTimestamp; // Launch start time
        uint256 depositTokenAmountRaised; // Total amount raised so far after trading fees
        uint256 soldMemeTokenAmount; // Total tokens sold so far
        address pair; // Pair address once the meme is finalized
        uint8 curveType; // The type of curve
        ILaunchpadStorage.MemeDepositTokenInfo depositTokenInfo; // Deposit token info
        address curveCalculator; // Curve calculator address
        Tags tags; // Tags for the token created
        string tokenURI; // Token URI
    }

    /**
     * @notice Structure to store fee info
     * @param feePercent Fee percent
     * @param feeDestination Fee destination
     */
    struct FeeInfo {
        uint256 feePercent;
        address feeDestination;
    }

    /**
     * @notice Event emitted when a new launch is created
     * @param memeTokenAddress Address of the MEME token
     * @param memeTokenCreator Address of the launch creator
     * @param curveType The type of curve
     * @param depositTokenAddress Address of the deposit token
     * @param depositTokenAmountTarget Target amount to raise
     * @param initialMemeTokenPrice Initial price per token in deposit token
     * @param launchTimestamp Launch start time
     * @param totalTokens Total tokens for the launch
     * @param creatorMemeTokenBuyAmount Amount of MEME tokens from creator
     */
    event LaunchCreated(
        address indexed memeTokenAddress,
        address indexed memeTokenCreator,
        uint8 curveType,
        address indexed depositTokenAddress,
        uint256 depositTokenAmountTarget,
        uint256 initialMemeTokenPrice,
        uint256 launchTimestamp,
        uint256 totalTokens,
        uint256 creatorMemeTokenBuyAmount,
        uint256 creatorMemeTokenBuyAmountNative,
        address curveCalculator,
        Tags tags,
        string tokenURI
    );

    /**
     * @notice Event emitted when a user buys MEME tokens in a launch
     * @param memeToken Address of the MEME token
     * @param user Address of the participant
     * @param depositTokenAmount Amount of deposit token contributed
     * @param memeTokenAmountRec Amount of MEME tokens received
     */
    event MemeTokenBuy(
        address indexed memeToken, address indexed user, uint256 depositTokenAmount, uint256 memeTokenAmountRec
    );

    /**
     * @notice Event emitted when a user sells MEME tokens in a launch
     * @param memeToken Address of the MEME token
     * @param user Address of the participant
     * @param memeTokenAmount Amount of MEME tokens sold
     * @param depositTokenAmountRec Amount of deposit tokens received
     */
    event MemeTokenSell(
        address indexed memeToken, address indexed user, uint256 memeTokenAmount, uint256 depositTokenAmountRec
    );

    /**
     * @notice Event emitted when a launch is finalized
     * @param token Address of the MEME token
     * @param pair Address of the pair
     */
    event LaunchFinalized(address indexed token, address indexed pair);

    /**
     * @notice Event emitted when the pre-launch phase starts
     * @param token Address of the MEME token
     * @param totalRaised Total amount raised so far
     */
    event PreLaunchPhaseStarted(address indexed token, uint256 totalRaised);

    /**
     * @notice Event emitted when the fee percent is set
     * @param _index Index of the fee info
     * @param _feePercent Fee percent
     * @param _feeDestination Fee destination
     * @param _isTradingFee Whether the fee is for trading
     */
    event FeePercentSet(uint256 indexed _index, uint256 _feePercent, address _feeDestination, bool _isTradingFee);

    /**
     * @notice Event emitted when a new fee info is added
     * @param _feePercent Fee percent
     * @param _feeDestination Fee destination
     * @param _isTradingFee Whether the fee is for trading
     */
    event FeeInfoAdded(uint256 _feePercent, address _feeDestination, bool _isTradingFee);

    /**
     * @notice Event emitted when the token creator fee is set
     * @param _feePercent Fee percent
     */
    event TokenCreatorFeeSet(uint256 _feePercent);

    /**
     * @notice Event emitted when the max creator buy amount percentage is set
     * @param _maxCreatorBuyAmountPercentage Max creator buy amount percentage
     */
    event MaxCreatorBuyAmountPercentageSet(uint256 _maxCreatorBuyAmountPercentage);

    /**
     * @notice Event emitted when the curve calculator is set
     * @param _curveType Curve type
     * @param _curveCalculator Curve calculator address
     */
    event CurveCalculatorSet(uint256 _curveType, address _curveCalculator);

    /**
     * @notice Get the total number of launches
     * @return Total launch count
     */
    function getLaunchCount() external view returns (uint256);

    /**
     * @notice Get launch info
     * @param _token Address of the MEME token
     * @return LaunchInfo Launch information
     */
    function getLaunchInfo(address _token) external view returns (LaunchInfo memory);

    /**
     * @notice Quote the amount of deposit token received upon selling, _memeTokenAmount of MEME tokens
     * @param _memeToken Address of the MEME token
     * @param _memeTokenAmount Amount of MEME tokens to buy or sell
     * @return depositTokenAmount Amount of deposit token received upon selling, _memeTokenAmount of MEME tokens
     */
    function quoteSellMemeTokenAmount(address _memeToken, uint256 _memeTokenAmount) external view returns (uint256);

    /**
     * @notice Quote the amount of MEME tokens received upon buying _depositTokenAmount of deposit token
     * @param _memeToken Address of the MEME token
     * @param _depositTokenAmount Amount of deposit token to buy or sell
     * @return memeTokenAmount Amount of MEME tokens received upon buying _depositTokenAmount of deposit token
     */
    function quoteBuyMemeTokenAmount(address _memeToken, uint256 _depositTokenAmount) external view returns (uint256);

    /**
     * @notice Quote the maximum amount of deposit token to buy and graduate the token
     * @param _memeToken Address of the MEME token
     * @return depositTokenAmount Amount of deposit token to buy and graduate the token
     */
    function quoteMaxDepositTokenInputAmount(address _memeToken) external view returns (uint256);

    /**
     * @notice Event emitted when the hyperpie config is updated
     * @param _hyperpieConfig Address of the hyperpie config
     */
    event UpdatedHyperpieConfig(address _hyperpieConfig);

    /**
     * @notice Event emitted when the referral is set
     * @param _user User address
     * @param _referral Referral address
     */
    event UserReferralSet(address indexed _user, address indexed _referral);

    /**
     * @notice Create a new token launch
     * @param params Launch creation parameters
     * @return tokenAddress Address of the newly created MEME token
     */
    function createLaunch(LaunchCreationParams memory params) external payable returns (address tokenAddress);

    /**
     * @notice Buy MEME tokens in a token launch
     * @param _memeToken Address of the MEME token
     * @param _depositTokenAmount Amount of deposit token to contribute
     * @param _minReceivedMemeTokenAmount Minimum amount of Meme tokens to receive
     * @param _referral Address of the referral
     */
    function buyMemeTokenWithoutPoolCreation(
        address _memeToken,
        uint256 _depositTokenAmount,
        uint256 _minReceivedMemeTokenAmount,
        address _referral
    )
        external;

    /**
     * @notice Buy MEME tokens in a token launch with native token
     * @param _memeToken Address of the MEME token
     * @param _minReceivedMemeTokenAmount Minimum amount of Meme tokens to receive
     * @param _referral Address of the referral
     */
    function buyMemeTokenWithoutPoolCreationNative(
        address _memeToken,
        uint256 _minReceivedMemeTokenAmount,
        address _referral
    )
        external
        payable;

    /**
     * @notice Buy MEME tokens in a token launch and also finalize the launch if the bonding curve is filled and the
     * extra deposit token is swapped for the meme token in pool created.
     * @param _memeToken Address of the MEME token
     * @param _depositTokenAmount Amount of deposit token to contribute
     * @param _minReceivedMemeTokenAmount Minimum amount of Meme tokens to receive
     * @param _referral Address of the referral
     */
    function buyMemeTokenWithPoolCreationAndSwap(
        address _memeToken,
        uint256 _depositTokenAmount,
        uint256 _minReceivedMemeTokenAmount,
        address _referral
    )
        external;

    /**
     * @notice Buy MEME tokens in a token launch with native token and also finalize the launch if the bonding curve is
     * filled and the
     * extra deposit token is swapped for the meme token in pool created.
     * @param _memeToken Address of the MEME token
     * @param _minReceivedMemeTokenAmount Minimum amount of Meme tokens to receive
     * @param _referral Address of the referral
     */
    function buyMemeTokenWithPoolCreationAndSwapNative(
        address _memeToken,
        uint256 _minReceivedMemeTokenAmount,
        address _referral
    )
        external
        payable;

    /**
     * @notice Sell MEME tokens in a token launch
     * @param _memeToken Address of the MEME token
     * @param _memeTokenAmount Amount of MEME tokens to sell
     * @param _minDepositTokenAmount Minimum amount of deposit token to receive
     * @param _referral Address of the referral
     */
    function sellMemeToken(address _memeToken, uint256 _memeTokenAmount, uint256 _minDepositTokenAmount, address _referral) external;

    /**
     * @notice Finalize token launches
     * @param _memeTokens Array of MEME token addresses
     */
    function finalizeLaunch(address[] calldata _memeTokens) external;

    /**
     * @notice Update the hyperpie config
     * @param _hyperpieConfig Hyperpie config address
     */
    function updateConfig(address _hyperpieConfig) external;

    /**
     * @notice Set the creator for a token launch
     * @param _memeToken Address of the MEME token
     * @param _creator Address of the creator
     */
    function setCreator(address _memeToken, address _creator) external;

    // Custom error definitions
    error InsufficientMemeTokenBalance();
    error OnlyWETH();
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;

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

/**
 * @title IMEMEToken
 * @notice Interface for MEME tokens with bonding phase functionality
 */
interface IMEMEToken is IERC20 {
    /**
     * @notice Enum for token mode
     */
    enum TransferMode {
        Normal, // The pool is created and there is no restriction on this token transfer.
        Restricted, // No transfer is possible (During the phase when bonding curve graduated but the pool isn't
            // created)
        Controlled // Only transfer from/to owner is allowed. (During bonding phase)

    }

    error InvalidTokenName();
    error InvalidTokenSymbol();
    error TransfersRestrictedDuringBondingPhase();
    error TransfersRestrictedDuringPreLaunchPhase();

    function setMode(TransferMode v) external;
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;

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

import { IWHYPE } from "../interfaces/IWHYPE.sol";
import { MEMEToken } from "../MEMEToken.sol";
import { IMEMEToken } from "../interfaces/IMEMEToken.sol";
import { IMEMELaunchpad } from "../interfaces/IMEMELaunchpad.sol";
import { ICurveCalculator } from "../interfaces/ICurveCalculator.sol";
import { ILaunchpadStorage } from "../interfaces/ILaunchpadStorage.sol";

import { HyperpieConstants } from "../../utils/HyperpieConstants.sol";
import { IHyperpieFactory } from "../../memedex/interfaces/factories/IHyperpieFactory.sol";
import { IHyperpieRouter } from "../../memedex/interfaces/IHyperpieRouter.sol";
import { IHyperpiePair } from "../../memedex/interfaces/IHyperpiePair.sol";
import { IPoolFees } from "../../memedex/interfaces/IPoolFees.sol";
import { IHyperpieConfig } from "../../interfaces/IHyperpieConfig.sol";

library LaunchpadLibrary {
    using SafeERC20 for IERC20;

    uint256 private constant NO_MINIMUM_AMOUNT = 0;
    uint256 private constant ACCEPTABLE_SHORTFALL = 1 ether;

    uint8 public constant CURVE_TYPE_LINEAR = 0;
    uint8 public constant CURVE_TYPE_CUBIC = 1;
    uint8 public constant CURVE_TYPE_UNIV2 = 2;

    error InvalidLaunchStartTime();
    error UnsupportedDepositToken();
    error LaunchNotFound();
    error LaunchNotStarted();
    error AlreadyFinalized();
    error NotFulfilled();
    error AmountMustBeGreaterThanZero();
    error InvalidTokenNameOrSymbol();
    error TokenNameOrSymbolTooLong();
    error FinalizationPending();
    error LaunchAlreadyFinalized();
    error DepositTokenNotWHYPE();
    error MinReceivedMemeTokenAmountNotMet();
    error MinDepositTokenAmountNotMet();
    error RouterNotSet();
    error FactoryNotSet();
    error MaxCreatorBuyAmountExceeded();
    error CurveCalculatorNotSet();
    error NativeTransferFailed();
    error InvalidTokenURI();

    event LiquidityPoolCreated(
        address indexed token, uint256 tokenAmount, uint256 depositAmount, uint256 lpTokenAmount
    );
    event ExtraDepositTokenSwappedForMemeToken(
        address _memeToken, uint256 _depositTokenAmount, uint256 _memeTokenAmount
    );
    event CreatorUpdated(address indexed _memeToken, address indexed _creator);

    /**
     * @notice Pre-checks for creating a launch
     * @param params The launch creation parameters
     * @param curveCalculator The curve calculator address
     * @param depositTokenInfo The deposit token information
     * @param maxCreatorBuyAmountPercentage The maximum creator buy amount percentage
     */
    function createLaunchPreChecks(
        IMEMELaunchpad.LaunchCreationParams memory params,
        address curveCalculator,
        ILaunchpadStorage.MemeDepositTokenInfo memory depositTokenInfo,
        uint256 maxCreatorBuyAmountPercentage
    )
        external
        view
    {
        if (bytes(params.tokenName).length == 0 || bytes(params.tokenSymbol).length == 0) {
            revert InvalidTokenNameOrSymbol();
        }
        if (bytes(params.tokenName).length > 32 || bytes(params.tokenSymbol).length > 32) {
            revert TokenNameOrSymbolTooLong();
        }
        if (!depositTokenInfo.isSupported) {
            revert UnsupportedDepositToken();
        }
        if (params.startTime + 5 minutes < block.timestamp) {
            revert InvalidLaunchStartTime();
        }
        if (curveCalculator == address(0)) {
            revert CurveCalculatorNotSet();
        }
        if (bytes(params.tokenURI).length == 0) {
            revert InvalidTokenURI();
        }
        uint256 maxCreatorBuyAmount =
            depositTokenInfo.depositTokenAmountTarget * maxCreatorBuyAmountPercentage / HyperpieConstants.DENOMINATOR;
        if (params.creatorBuyAmount + params.creatorBuyAmountNative > maxCreatorBuyAmount) {
            revert MaxCreatorBuyAmountExceeded();
        }
    }

    /**
     * @notice Pre-checks for finalizing a launch
     * @param launchInfo The launch info
     * @param _memeToken The meme token address
     */
    function finalizeLaunchPreChecks(IMEMELaunchpad.LaunchInfo memory launchInfo, address _memeToken) internal view {
        if (launchInfo.memeToken != _memeToken) {
            revert LaunchNotFound();
        }
        if (block.timestamp < launchInfo.launchTimestamp) {
            revert LaunchNotStarted();
        }
        if (launchInfo.pair != address(0)) {
            revert AlreadyFinalized();
        }
        if (
            launchInfo.depositTokenAmountRaised + ACCEPTABLE_SHORTFALL
                < launchInfo.depositTokenInfo.depositTokenAmountTarget
        ) {
            revert NotFulfilled();
        }
    }

    /**
     * @notice Pre-checks for buy/sell meme token
     * @param launchInfo The launch info
     * @param _memeToken The meme token address
     * @param _tradeAmount The trade amount
     */
    function tradePreChecks(
        IMEMELaunchpad.LaunchInfo memory launchInfo,
        address _memeToken,
        uint256 _tradeAmount
    )
        external
        view
    {
        if (launchInfo.memeToken != _memeToken) {
            revert LaunchNotFound();
        }
        if (block.timestamp < launchInfo.launchTimestamp) {
            revert LaunchNotStarted();
        }
        if (launchInfo.pair != address(0)) {
            revert LaunchAlreadyFinalized();
        }
        if (launchInfo.depositTokenAmountRaised >= launchInfo.depositTokenInfo.depositTokenAmountTarget) {
            revert FinalizationPending();
        }
        if (_tradeAmount == 0) {
            revert AmountMustBeGreaterThanZero();
        }
    }

    /**
     * @notice Pre-checks for buying meme token with native token
     * @param launchInfo The launch info
     * @param _nativeAmount The native token amount
     */
    function buyMemeTokenPreChecksNative(
        IMEMELaunchpad.LaunchInfo memory launchInfo,
        address _wNative,
        uint256 _nativeAmount
    )
        external
        pure
    {
        if (launchInfo.depositTokenAddress != address(_wNative)) {
            revert DepositTokenNotWHYPE();
        }
        if (_nativeAmount == 0) {
            revert AmountMustBeGreaterThanZero();
        }
    }

    /**
     * @notice Transfer trading fees
     * @param launchInfo The launch info
     * @param _depositTokenAmount The deposit token amount
     * @param _tokenCreatorFeePercent The token creator fee percentage
     * @param _feeInfos The fee infos
     */
    function transferTradingFees(
        IMEMELaunchpad.LaunchInfo memory launchInfo,
        uint256 _depositTokenAmount,
        uint256 _tokenCreatorFeePercent,
        ILaunchpadStorage.FeeInfo[] memory _feeInfos,
        IWHYPE _wNative
    )
        internal
        returns (uint256 totalFeeAmount)
    {
        uint256 tokenCreatorFeeAmount = _tokenCreatorFeePercent * _depositTokenAmount / HyperpieConstants.DENOMINATOR;
        if (tokenCreatorFeeAmount > 0) {
            if (launchInfo.depositTokenAddress == address(_wNative)) {
                uint256 nativeAmount = unwrapWNative(_wNative, tokenCreatorFeeAmount);
                safeTransferNative(launchInfo.memeTokenCreator, nativeAmount);
            } else {
                IERC20(launchInfo.depositTokenAddress).safeTransfer(launchInfo.memeTokenCreator, tokenCreatorFeeAmount);
            }
            totalFeeAmount += tokenCreatorFeeAmount;
        }

        for (uint256 i = 0; i < _feeInfos.length; i++) {
            uint256 feeAmount = _feeInfos[i].feePercent * _depositTokenAmount / HyperpieConstants.DENOMINATOR;
            if (feeAmount > 0) {
                IERC20(launchInfo.depositTokenAddress).safeTransfer(_feeInfos[i].feeDestination, feeAmount);
                totalFeeAmount += feeAmount;
            }
        }
    }

    /**
     * @notice Buy meme token
     * @param launchInfo The launch info
     * @param _depositTokenAmountBeforeFee The deposit token amount before fee
     * @param _minReceivedMemeTokenAmount The minimum received meme token amount
     * @param _totalTradingFee The total trading fee
     * @param _tokenCreatorFee The token creator fee
     * @param _feeInfos The fee infos
     * @return memeTokenAmount The amount of meme token received
     */
    function buyMemeToken(
        IMEMELaunchpad.LaunchInfo storage launchInfo,
        uint256 _depositTokenAmountBeforeFee,
        uint256 _minReceivedMemeTokenAmount,
        uint256 _totalTradingFee,
        uint256 _tokenCreatorFee,
        ILaunchpadStorage.FeeInfo[] memory _feeInfos,
        bool _isNative,
        IWHYPE _wNative
    )
        external
        returns (uint256)
    {
        uint256 memeTokenAmount = ICurveCalculator(launchInfo.curveCalculator).calculateBuyMEMETokenQuote(
            launchInfo, _depositTokenAmountBeforeFee, _totalTradingFee
        );
        if (memeTokenAmount < _minReceivedMemeTokenAmount) {
            revert MinReceivedMemeTokenAmountNotMet();
        }

        launchInfo.depositTokenAmountRaised += afterFee(_depositTokenAmountBeforeFee, _totalTradingFee);
        launchInfo.soldMemeTokenAmount += memeTokenAmount;

        if (!_isNative) {
            IERC20(launchInfo.depositTokenAddress).safeTransferFrom(
                msg.sender, address(this), _depositTokenAmountBeforeFee
            );
        }
        IERC20(launchInfo.memeToken).safeTransfer(msg.sender, memeTokenAmount);

        transferTradingFees(launchInfo, _depositTokenAmountBeforeFee, _tokenCreatorFee, _feeInfos, _wNative);

        return memeTokenAmount;
    }

    /**
     * @notice Sell meme token
     * @param launchInfo The launch info
     * @param _memeTokenAmount The amount of meme token to sell
     * @param _minDepositTokenAmount The minimum received deposit token amount
     * @param _totalTradingFee The total trading fee
     * @param _tokenCreatorFee The token creator fee
     * @param _feeInfos The fee infos
     * @return depositTokenAmountRecAfterFee The amount of deposit token received after fee
     */
    function sellMemeToken(
        IMEMELaunchpad.LaunchInfo storage launchInfo,
        uint256 _memeTokenAmount,
        uint256 _minDepositTokenAmount,
        uint256 _totalTradingFee,
        uint256 _tokenCreatorFee,
        ILaunchpadStorage.FeeInfo[] memory _feeInfos,
        IWHYPE _wNative
    )
        external
        returns (uint256)
    {
        uint256 depositTokenAmountRecBeforeFee =
            ICurveCalculator(launchInfo.curveCalculator).calculateSellQuote(launchInfo, _memeTokenAmount);
        uint256 depositTokenAmountRecAfterFee = afterFee(depositTokenAmountRecBeforeFee, _totalTradingFee);

        if (depositTokenAmountRecAfterFee < _minDepositTokenAmount) {
            revert MinDepositTokenAmountNotMet();
        }
        launchInfo.depositTokenAmountRaised -= depositTokenAmountRecBeforeFee;
        launchInfo.soldMemeTokenAmount -= _memeTokenAmount;

        // We're charging the fees based on the deposit token amount before fee
        transferTradingFees(launchInfo, depositTokenAmountRecBeforeFee, _tokenCreatorFee, _feeInfos, _wNative);
        IERC20(launchInfo.memeToken).safeTransferFrom(msg.sender, address(this), _memeTokenAmount);
        if (launchInfo.depositTokenAddress == address(_wNative)) {
            uint256 nativeAmount = unwrapWNative(_wNative, depositTokenAmountRecAfterFee);
            safeTransferNative(msg.sender, nativeAmount);
        } else {
            IERC20(launchInfo.depositTokenAddress).safeTransfer(msg.sender, depositTokenAmountRecAfterFee);
        }

        return depositTokenAmountRecAfterFee;
    }

    /**
     * @notice Finalize a launch
     * @param launchInfo The launch info
     * @param _hyperpieRouter The hyperpie router address
     * @param _hyperpieFactory The hyperpie factory address
     * @param _poolCreationFeeInfos The pool creation fee infos
     */
    function finalizeLaunch(
        address _memeToken,
        IMEMELaunchpad.LaunchInfo storage launchInfo,
        address _hyperpieRouter,
        address _hyperpieFactory,
        ILaunchpadStorage.FeeInfo[] memory _poolCreationFeeInfos,
        IHyperpieConfig _hyperpieConfig
    )
        external
    {
        finalizeLaunchPreChecks(launchInfo, _memeToken);

        if (_hyperpieRouter == address(0)) {
            revert RouterNotSet();
        }
        if (_hyperpieFactory == address(0)) {
            revert FactoryNotSet();
        }

        MEMEToken(launchInfo.memeToken).setMode(IMEMEToken.TransferMode.Normal);
        MEMEToken(launchInfo.memeToken).renounceOwnership();

        createPoolAndAddLiquidity(launchInfo, _hyperpieRouter, _poolCreationFeeInfos);
        launchInfo.pair =
            IHyperpieRouter(_hyperpieRouter).pairFor(launchInfo.memeToken, launchInfo.depositTokenAddress, false);

        address veHPPFeeCollector =  _hyperpieConfig.getAddress(HyperpieConstants.FEE_VEHPP_COLLECTOR);
        if (veHPPFeeCollector != address(0)) {
            IERC20(launchInfo.pair).safeTransfer(veHPPFeeCollector, IERC20(launchInfo.pair).balanceOf(address(this)));
        }

        IPoolFees(IHyperpiePair(launchInfo.pair).poolFees()).setCreatorAndMeme(true, launchInfo.memeTokenCreator);
    }

    /**
     * @notice Swap extra deposit token for meme token
     * @param launchInfo The launch info
     * @param _hyperpieRouter The hyperpie router address
     * @param _hyperpieFactory The hyperpie factory address
     * @param _depositTokenAmount The deposit token amount
     * @param _recipient The recipient address
     */
    function swapExtraDepositTokenForMemeToken(
        IMEMELaunchpad.LaunchInfo memory launchInfo,
        address _hyperpieRouter,
        address _hyperpieFactory,
        uint256 _depositTokenAmount,
        address _recipient,
        bool _isNative
    )
        external
    {
        if (!_isNative) {
            IERC20(launchInfo.depositTokenAddress).safeTransferFrom(msg.sender, address(this), _depositTokenAmount);
        }

        IHyperpieRouter.Route[] memory routes = new IHyperpieRouter.Route[](1);
        routes[0] = IHyperpieRouter.Route({
            fromToken: launchInfo.depositTokenAddress,
            toToken: launchInfo.memeToken,
            stable: false,
            factory: _hyperpieFactory
        });

        IERC20(launchInfo.depositTokenAddress).safeApprove(_hyperpieRouter, _depositTokenAmount);
        uint256[] memory amounts = IHyperpieRouter(_hyperpieRouter).swapExactTokensForTokens(
            _depositTokenAmount, NO_MINIMUM_AMOUNT, routes, _recipient, block.timestamp + 300
        );
        emit ExtraDepositTokenSwappedForMemeToken(launchInfo.memeToken, _depositTokenAmount, amounts[1]);
    }

    /**
     * @notice Create a pool and add liquidity
     * @param launchInfo The launch info
     * @param _hyperpieRouter The hyperpie router address
     * @param _feeInfos The fee infos
     */
    function createPoolAndAddLiquidity(
        IMEMELaunchpad.LaunchInfo memory launchInfo,
        address _hyperpieRouter,
        ILaunchpadStorage.FeeInfo[] memory _feeInfos
    )
        internal
    {
        uint256 totalFeeAmount = 0;
        for (uint256 i = 0; i < _feeInfos.length; i++) {
            uint256 feeAmount =
                _feeInfos[i].feePercent * launchInfo.depositTokenAmountRaised / HyperpieConstants.DENOMINATOR;
            if (feeAmount > 0) {
                IERC20(launchInfo.depositTokenAddress).safeTransfer(_feeInfos[i].feeDestination, feeAmount);
                totalFeeAmount += feeAmount;
            }
        }
        uint256 depositTokenAmount = launchInfo.depositTokenAmountRaised - totalFeeAmount;
        IERC20(launchInfo.depositTokenAddress).safeApprove(_hyperpieRouter, depositTokenAmount);

        uint256 memeTokenAmount = IERC20(launchInfo.memeToken).balanceOf(address(this));
        IERC20(launchInfo.memeToken).safeApprove(_hyperpieRouter, memeTokenAmount);

        (uint256 amountTokenUsed, uint256 amountDepositTokenUsed, uint256 liquidityTokens) = IHyperpieRouter(
            _hyperpieRouter
        ).addLiquidity(
            launchInfo.memeToken, // tokenA
            launchInfo.depositTokenAddress, // tokenB
            false, // Volatile
            memeTokenAmount, // amountADesired
            depositTokenAmount, // amountBDesired
            memeTokenAmount * 99 / 100, // amountAMin (99% of desired)
            depositTokenAmount * 99 / 100, // amountBMin (99% of desired)
            address(this), // to (LP tokens go to this contract)
            block.timestamp + 300 // deadline (5 minutes from now)
        );

        emit LiquidityPoolCreated(launchInfo.memeToken, amountTokenUsed, amountDepositTokenUsed, liquidityTokens);
    }

    /**
     * @notice Set the new creator for a pool
     * @param launchInfo The launch info
     * @param _creator The creator address
     */
    function setNewCreator(IMEMELaunchpad.LaunchInfo storage launchInfo, address _creator) external {
        launchInfo.memeTokenCreator = _creator;
        if (launchInfo.pair != address(0)) {
            IPoolFees(IHyperpiePair(launchInfo.pair).poolFees()).setCreatorAndMeme(true, _creator);
        }

        emit CreatorUpdated(launchInfo.memeToken, _creator);
    }

    /**
     * @notice Check if the deposit token is already set
     * @param _depositToken The deposit token address
     * @param _allDepositTokens The all deposit tokens
     * @return isSet True if the deposit token is already set, false otherwise
     */
    function checkDepositTokenAlreadySet(
        address _depositToken,
        address[] memory _allDepositTokens
    )
        external
        pure
        returns (bool)
    {
        for (uint256 i = 0; i < _allDepositTokens.length; i++) {
            if (_allDepositTokens[i] == _depositToken) {
                return true;
            }
        }
        return false;
    }

    /**
     * @notice Wrap native token to wype
     * @param _nativeAmount The native token amount
     * @return whypeAmount The amount of wype token received
     */
    function wrapNative(IWHYPE _wNative, uint256 _nativeAmount) external returns (uint256) {
        uint256 currentWHYPEBalance = _wNative.balanceOf(address(this));
        _wNative.deposit{ value: _nativeAmount }();
        return _wNative.balanceOf(address(this)) - currentWHYPEBalance;
    }

    /**
     * @notice Unwrap whype token to native token
     * @param _wNative The whype token address
     * @param _nativeAmount The native token amount
     */
    function unwrapWNative(IWHYPE _wNative, uint256 _nativeAmount) public returns (uint256) {
        uint256 currentNativeBalance = address(this).balance;
        _wNative.withdraw(_nativeAmount);
        return address(this).balance - currentNativeBalance;
    }

    /**
     * @notice Calculate the amount after fee
     * @param _amount The amount before fee
     * @param _fee The fee
     * @return afterAmount The amount after fee
     */
    function afterFee(uint256 _amount, uint256 _fee) public pure returns (uint256 afterAmount) {
        uint256 feeAmount = _amount * _fee / HyperpieConstants.DENOMINATOR;
        afterAmount = _amount - feeAmount;
    }

    /**
     * @notice Calculate the amount before fee
     * @param _amount The amount after fee
     * @param _fee The fee
     * @return beforeAmount The amount before fee
     */
    function beforeFee(uint256 _amount, uint256 _fee) public pure returns (uint256 beforeAmount) {
        beforeAmount = HyperpieConstants.DENOMINATOR * _amount / (HyperpieConstants.DENOMINATOR - _fee);
    }

    /**
     * @notice Safe transfer native token
     * @param to The recipient address
     * @param value The amount of native token to transfer
     */
    function safeTransferNative(address to, uint256 value) public {
        (bool success, ) = to.call{value: value, gas: 5000}(new bytes(0));
        if (!success) revert NativeTransferFailed();
    }
}

File 7 of 33 : HyperpieConstants.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;

library HyperpieConstants {
    //contracts
    bytes32 public constant HYPERPIE_STAKING = keccak256("HYPERPIE_STAKING");
    bytes32 public constant PRICE_PROVIDER = keccak256("PRICE_PROVIDER");
    bytes32 public constant HYPERPIE_WITHDRAW_MANAGER = keccak256("HYPERPIE_WITHDRAW_MANAGER");
    bytes32 public constant MHYPE_TOKEN = keccak256("MHYPE_TOKEN");
    bytes32 public constant FACTORY = keccak256("FACTORY");
    bytes32 public constant MEME_LAUNCHPAD = keccak256("MEME_LAUNCHPAD");
    bytes32 public constant HYPERPIE_ROUTER = keccak256("HYPERPIE_ROUTER");

    //Roles
    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
    bytes32 public constant MANAGER = keccak256("MANAGER");
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
    bytes32 public constant ORACLE_ROLE = keccak256("ORACLE_ROLE");
    bytes32 public constant ORACLE_ADMIN_ROLE = keccak256("ORACLE_ADMIN_ROLE");
    bytes32 public constant PRICE_PROVIDER_ROLE = keccak256("PRICE_PROVIDER_ROLE");
    bytes32 public constant ALLOWED_BOT_ROLE = keccak256("ALLOWED_BOT_ROLE");
    bytes32 public constant FEE_MANAGER_ROLE = keccak256("FEE_MANAGER_ROLE");
    bytes32 public constant HYPERPIE_V2_META_CONFIG_ROLE = keccak256("HYPERPIE_V2_META_CONFIG_ROLE");
    bytes32 public constant ADD_MEME_PAIR_ROLE = keccak256("ADD_MEME_PAIR_ROLE");

    address public constant PLATFORM_TOKEN_ADDRESS = 0x0000000000000000000000000000000000000000; // HYPERPIE Token
    address public constant WHYPE = 0x5555555555555555555555555555555555555555; // Wrapped HYPE
    bytes32 public constant HYPE_STAKE_DESTINTATION = keccak256("HYPE_STAKE_DESTINTATION");
    bytes32 public constant HYPERPIE_DELEGATOR = keccak256("HYPERPIE_DELEGATOR");
    bytes32 public constant HYPERPIE_FEE_DESTINATION = keccak256("HYPERPIE_FEE_DESTINATION");

    // HyperEVM L1 Read Precompile Addresses
    address public constant SPOT_BALANCE_PRECOMPILE = 0x0000000000000000000000000000000000000801;
    address public constant DELEGATOR_SUMMARY_PRECOMPILE = 0x0000000000000000000000000000000000000805;

    // HYPE Token ID on Hyperliquid
    uint64 public constant HYPE_TOKEN_ID = 150;
    bytes32 public constant LAUNCHPAD_FEE_DESTINATION = keccak256("MEME_LAUNCHPAD_FEE_DESTINATION");

    // For Native Restaking
    uint256 constant GWEI_TO_WEI = 1e9;

    uint256 public constant DENOMINATOR = 10_000;
    uint256 public constant MHYPE_FEE_DENOMINATOR = 1_000_000;
    uint256 public constant MHYPE_FEE_MAX_VALUE = 5_000; // Maximum ~0.5% inflation to prevent extreme inflation
    uint256 public constant ONE_WEEK = 7 days;
    uint256 public constant DECAY_RATE = 9900;

    // For DEX
    string public constant STABLE_PREFIX = "STABLE-";
    string public constant V2_PREFIX = "V2-";
    // FOR V2, SS FEE structure
    bytes32 public constant FEE_V2_STABLE_LP = keccak256("FEE_V2_STABLE_LP");
    bytes32 public constant FEE_TEAM_COLLECTOR = keccak256("FEE_TEAM_COLLECTOR");
    bytes32 public constant FEE_VEHPP_COLLECTOR = keccak256("FEE_VEHPP_COLLECTOR");
    bytes32 public constant FEE_POOL_CREATOR = keccak256("FEE_POOL_CREATOR");
    bytes32 public constant POOL_FEES_BEACON = keccak256("POOL_FEES_BEACON");

    uint256 public constant MEME_TOKEN_DECIMAL = 18;
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;

interface IHyperpieConfig {
    /*//////////////////////////////////////////////////////////////
                                ERRORS
    //////////////////////////////////////////////////////////////*/
    error CallerNotHyperpieConfigAllowedRole(string role);
    error CallerNotHyperpieConfigPriceProvider();
    error CallerNotHyperpieConfigOracleAdmin();
    error CallerNotHyperpieConfigOracle();
    error CallerNotHyperpiePauser();
    error CallerNotHyperpieConfigAllowedBot();
    error CallerNotHyperpieConfigAdmin();
    error CallerNotHyperpieConfigManager();
    error CallerNotHyperpieConfigMinter();
    error CallerNotHyperpieConfigBurner();
    error CallerNotHyperpieFactory();
    error CallerNotHyperpieConfigFeeManager();
    error CallerNotHyperpieConfigMetaConfig();
    error EmergencyPaused();
    error InvalidFeeValue();
    error DexV2Locked();

    /*//////////////////////////////////////////////////////////////
                                EVENTS
    //////////////////////////////////////////////////////////////*/
    event SetAddress(bytes32 key, address indexed addr);
    event MHypeFeeValueUpdated(uint256 mHypeFeeValue);
    event SetUintValue(bytes32 key, uint256 value);
    event SetWhitelistedFactory(address indexed factory, bool isApproved);
    event DexV2Paused(address account);
    event DexV2Unpaused(address account);

    /*//////////////////////////////////////////////////////////////
                            VIEW FUNCTIONS
    //////////////////////////////////////////////////////////////*/
    function getAddress(bytes32 addressId) external view returns (address);
    function getMHypeFeeValue() external view returns (uint256);

    function setAddress(bytes32 key, address addr) external;
    function getUint256Value(bytes32 valueId) external view returns (uint256);
    function whitelistedFactories(address factory) external view returns (bool);
    function isDexV2Paused() external view returns (bool);
}

interface IPausable {
    function paused() external view returns (bool);
}

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

interface IHyperpiePair {
    /*//////////////////////////////////////////////////////////////
                                ERRORS
    //////////////////////////////////////////////////////////////*/
    error InsufficientLiquidityMinted();
    error InsufficientLiquidityBurned();
    error InsufficientLiquidity();
    error InvalidTo();
    error Overflow();
    error InvariantKViolated();
    error InsufficientInputAmount();
    error InsufficientOutputAmount();
    error FactoryAlreadySet();
    error IsNotFactory();       
    error DepositsNotEqual();
    error BelowMinimumK();
    error K();
    error Y();

    event Mint(address indexed sender, uint256 amount0, uint256 amount1);
    event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);
    event Swap(
        address indexed swappedFor,
        uint256 amount0In,
        uint256 amount1In,
        uint256 amount0Out,
        uint256 amount1Out
    );
    event Sync(uint256 reserve0, uint256 reserve1);
    event Claim(address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1);
    event Fees(address indexed sender, uint256 amount0, uint256 amount1);
    event SetName(string name);
    event SetSymbol(string symbol);
    event UpdatedHyperpieConfig(address indexed hyperpieConfig);

     // Struct to capture time period obervations every 30 minutes, used for local oracles
    struct Observation {
        uint256 timestamp;
        uint256 reserve0Cumulative;
        uint256 reserve1Cumulative;
    }

    function getAmountOut(uint256 amountIn, address tokenIn) external view returns (uint256);
    function getReserves() external view returns (uint256 reserve0, uint256 reserve1, uint256 blockTimestampLast);
    function mint(address to) external returns (uint256 liquidity);
    function burn(address to) external returns (uint256 amount0, uint256 amount1);
    function swap(uint256 amount0Out, uint256 amount1Out, address to) external;
    function token0() external view returns (address);
    function token1() external view returns (address);
    function initialize(address _token0, address _token1, address _hyperpieConfig, bool _stable) external;
    function claimFees() external returns (uint256, uint256);
    function tokens() external view returns (address, address);
    function poolFees() external view returns (address);
    function lpRevShareBPS() external view returns (uint256);
}

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

interface IHyperpieRouter {
  struct Route {
        address fromToken;
        address toToken;
        bool stable;
        address factory;
  }

  error Expired();
  error InsufficientAmount();
  error InsufficientOutputAmount();
  error ExcessiveInputAmount();
  error InsufficientLiquidity();
  error NativeTransferFailed();
  error InvalidPath();
  error OnlyWETH();
  error InvalidFactory();
  error InvalidConfig();
  error InvalidPair();
  error InvalidToken();
  error InvalidAmount();
  error InvalidDeadline();
  error InvalidAmountOut();
  error InvalidAmountIn();
  error InvalidAmountOutMin();
  error InvalidAmountInMin();
  error InvalidRoute();
  error ZeroAddress();
  error SameAddresses();
  error InsufficientInputAmount();
  error TransferFailed();

  event UpdatedDefaultFactory(address indexed defaultFactory);
  event UpdatedHyperpieConfig(address indexed hyperpieConfig);
  event Swapped(address indexed sender, address indexed fromToken, address indexed toToken, uint amountIn, uint amountOut, address to);
  event AddedLiquidity(address sender, address to, address indexed pair, address indexed tokenA, address indexed tokenB, uint amountA, uint amountB);
  event RemovedLiquidity(address sender, address to, address indexed pair, address indexed tokenA, address indexed tokenB, uint amountA, uint amountB);
  event UserReferralSet(address indexed _user, address indexed _referral);

  function pairFor(address tokenA, address tokenB, bool stable) external view returns (address);

  function addLiquidity(
        address tokenA,
        address tokenB,
        bool stable,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
  ) external returns (uint amountA, uint amountB, uint liquidity);

  function removeLiquidity(
        address tokenA,
        address tokenB,
        bool stable,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
  ) external returns (uint amountA, uint amountB);

  function swapExactTokensForTokens(
    uint amountIn,
    uint amountOutMin,
    Route[] calldata routes,
    address to,
    uint deadline
  ) external returns (uint[] memory amounts);

  function swapExactTokensForNative(
    uint amountIn,
    uint amountOutMin,
    Route[] calldata routes,
    address to,
    uint deadline
  ) external returns (uint[] memory amounts);

  function getAmountsOut(uint256 amountIn, Route[] calldata routes) external view returns (uint256[] memory amounts);

   function getAmountsOut(
        uint256 amountIn,
        address[] calldata path
    ) external view returns (uint256[] memory amounts);

}

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

interface IHyperpieFactory {
    error IdenticalTokenAddresses();
    error PairAlreadyExists();
    error NotAuthorized();
    error FeeTooHigh();
    error ZeroFee();
    error InvalidPair();
    error FeeInvalid();

    event PairCreated(address indexed token0, address indexed token1, bool stable, address pair, uint256 index);
    event SetCustomFee(address indexed pair, uint256 fee);
    event SetFee(bool stable, uint256 fee);
    event SetHyperpiePairImp(address indexed hyperpiePairImp);
    event UpdatedHyperpieConfig(address indexed hyperpieConfig);

    function getPair(address tokenA, address tokenB, bool stable) external view returns (address);
    function createPair(address tokenA, address tokenB, bool stable) external returns (address pair);
    function setFee(bool stable, uint256 fee) external;
    function setCustomFee(address pair, uint256 fee) external;
    function getFee(address pair, bool stable) external view returns (uint256);
    function isPair(address pair) external view returns (bool);
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

/**
 * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
 * `CREATE2` can be used to compute in advance the address where a smart
 * contract will be deployed, which allows for interesting new mechanisms known
 * as 'counterfactual interactions'.
 *
 * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
 * information.
 */
library Create2 {
    /**
     * @dev Deploys a contract using `CREATE2`. The address where the contract
     * will be deployed can be known in advance via {computeAddress}.
     *
     * The bytecode for a contract can be obtained from Solidity with
     * `type(contractName).creationCode`.
     *
     * Requirements:
     *
     * - `bytecode` must not be empty.
     * - `salt` must have not been used for `bytecode` already.
     * - the factory must have a balance of at least `amount`.
     * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.
     */
    function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) {
        require(address(this).balance >= amount, "Create2: insufficient balance");
        require(bytecode.length != 0, "Create2: bytecode length is zero");
        /// @solidity memory-safe-assembly
        assembly {
            addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
        }
        require(addr != address(0), "Create2: Failed on deploy");
    }

    /**
     * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the
     * `bytecodeHash` or `salt` will result in a new destination address.
     */
    function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
        return computeAddress(salt, bytecodeHash, address(this));
    }

    /**
     * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
     * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
     */
    function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40) // Get free memory pointer

            // |                   | ↓ ptr ...  ↓ ptr + 0x0B (start) ...  ↓ ptr + 0x20 ...  ↓ ptr + 0x40 ...   |
            // |-------------------|---------------------------------------------------------------------------|
            // | bytecodeHash      |                                                        CCCCCCCCCCCCC...CC |
            // | salt              |                                      BBBBBBBBBBBBB...BB                   |
            // | deployer          | 000000...0000AAAAAAAAAAAAAAAAAAA...AA                                     |
            // | 0xFF              |            FF                                                             |
            // |-------------------|---------------------------------------------------------------------------|
            // | memory            | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |
            // | keccak(start, 85) |            ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |

            mstore(add(ptr, 0x40), bytecodeHash)
            mstore(add(ptr, 0x20), salt)
            mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes
            let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff
            mstore8(start, 0xff)
            addr := keccak256(start, 85)
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

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

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _paused = false;
    }

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

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

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

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

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

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

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

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

    uint256 private _status;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

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

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

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

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;

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

/**
 * @title IMEMELaunchpad
 * @notice Interface for the MEME token launchpad
 */
interface ICurveCalculator {
    error AmountTooHigh();

    /**
     * @notice Calculate the amount of deposit token to receive upon selling a given amount of meme token
     * @param launchInfo The launch info
     * @param _memeTokenAmount The amount of meme token to sell
     * @return depositTokenAmountRecBeforeFee The amount of deposit token to receive upon selling the meme token before
     * fee
     */
    function calculateSellQuote(
        IMEMELaunchpad.LaunchInfo memory launchInfo,
        uint256 _memeTokenAmount
    )
        external
        view
        returns (uint256 depositTokenAmountRecBeforeFee);

    /**
     * @notice Calculate the amount of meme token that can be bought for a given amount of deposit token
     * @param launchInfo The launch info
     * @param _depositTokenAmountBeforeFee The amount of deposit token to buy
     * @param _totalTradingFee The total trading fee
     * @return memeTokenAmountRec The amount of meme token that can be bought
     */
    function calculateBuyMEMETokenQuote(
        IMEMELaunchpad.LaunchInfo memory launchInfo,
        uint256 _depositTokenAmountBeforeFee,
        uint256 _totalTradingFee
    )
        external
        view
        returns (uint256 memeTokenAmountRec);

    /**
     * @notice Calculate the amount of deposit token required to buy a given amount of meme token
     * @param launchInfo The launch info
     * @param _memeTokenAmount The amount of meme token to buy
     * @param _totalTradingFee The total trading fee
     * @return depositTokenAmountRec The amount of deposit token required to buy the meme token
     */
    function calculateBuyDepositTokenQuote(
        IMEMELaunchpad.LaunchInfo memory launchInfo,
        uint256 _memeTokenAmount,
        uint256 _totalTradingFee
    )
        external
        view
        returns (uint256 depositTokenAmountRec);
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;

interface ILaunchpadStorage {
    /**
     * @notice Structure to store fee info
     * @param feePercent Fee percent
     * @param feeDestination Fee destination
     */
    struct FeeInfo {
        uint256 feePercent;
        address feeDestination;
    }

    /**
     * @notice Struct to store deposit token information
     * @param depositTokenAmountTarget The target raise amount for the token
     * @param initialMemeTokenPrice The initial price per token in deposit token
     * @param coefficient The leading coefficient for the bonding curve
     * @param bondingCurveMemeTokenSupply The total tokens for the bonding curve
     * @param initialX The initial x value for the bonding curve
     * @param initialY The initial y value for the bonding curve
     * @param isSupported Whether the deposit token is supported
     */
    struct MemeDepositTokenInfo {
        uint256 depositTokenAmountTarget;
        uint256 initialMemeTokenPrice; // scaled by 10^36
        uint256 coefficient; // scaled by 10^36
        uint256 bondingCurveMemeTokenSupply;
        uint256 initialX;
        uint256 initialY;
        bool isSupported;
    }

    error FeeTooHigh();
    error InvalidIndex();
    error InvalidCurveType();
    error DepositTokenNotSet();
    error MaxCreatorBuyAmountTooHigh();
    error ReferralCannotBeSelf();

    /**
     * @notice Event emitted when the fee percent is set
     * @param _index Index of the fee info
     * @param _feePercent Fee percent
     * @param _feeDestination Fee destination
     * @param _isTradingFee Whether the fee is for trading
     */
    event FeePercentSet(uint256 indexed _index, uint256 _feePercent, address _feeDestination, bool _isTradingFee);

    /**
     * @notice Event emitted when a new fee info is added
     * @param _feePercent Fee percent
     * @param _feeDestination Fee destination
     * @param _isTradingFee Whether the fee is for trading
     */
    event FeeInfoAdded(uint256 _feePercent, address _feeDestination, bool _isTradingFee);

    /**
     * @notice Event emitted when the token creator fee is set
     * @param _feePercent Fee percent
     */
    event TokenCreatorFeeSet(uint256 _feePercent);

    /**
     * @notice Event emitted when the max creator buy amount percentage is set
     * @param _maxCreatorBuyAmountPercentage Max creator buy amount percentage
     */
    event MaxCreatorBuyAmountPercentageSet(uint256 _maxCreatorBuyAmountPercentage);

    /**
     * @notice Event emitted when the curve calculator is set
     * @param _curveType Curve type
     * @param _curveCalculator Curve calculator address
     */
    event CurveCalculatorSet(uint8 _curveType, address _curveCalculator);

    /**
     * @notice Event emitted when a deposit token is updated
     * @param token Address of the deposit token
     * @param isSupported Whether the token is supported
     */
    event DepositTokenUpdated(address indexed token, bool isSupported);

    /**
     * @notice Event emitted when a deposit token info is updated
     * @param token Address of the deposit token
     * @param targetRaise Target raise amount
     * @param initialPrice Initial price per token in deposit token
     * @param coefficient Coefficient for the bonding curve
     * @param totalTokensForBondingCurve Total tokens for the bonding curve
     * @param isSupported Whether the token is supported
     * @param curveType The type of curve
     */
    event DepositTokenInfoUpdated(
        address indexed token,
        uint256 targetRaise,
        uint256 initialPrice,
        uint256 coefficient,
        uint256 totalTokensForBondingCurve,
        uint256 initialX,
        uint256 initialY,
        bool isSupported,
        uint256 curveType
    );

    /**
     * @notice Event emitted when the hyperpie config is updated
     * @param _hyperpieConfig Hyperpie config address
     */
    event UpdatedHyperpieConfig(address _hyperpieConfig);

    /**
     * @notice Event emitted when the referral is set
     * @param _user User address
     * @param _referral Referral address
     */
    event UserReferralSet(address indexed _user, address indexed _referral);

    /**
     * @notice Get the total trading fee
     * @return Total trading fee
     */
    function totalTradingFee() external view returns (uint256);

    /**
     * @notice Get the total pool creation fee
     * @return Total pool creation fee
     */
    function totalPoolCreationFee() external view returns (uint256);

    /**
     * @notice Get all the trading fee infos
     * @return Trading fee infos
     */
    function allTradingFeeInfos() external view returns (FeeInfo[] memory);

    /**
     * @notice Get all the pool creation fee infos
     * @return Pool creation fee infos
     */
    function allPoolCreationFeeInfos() external view returns (FeeInfo[] memory);

    /**
     * @notice Get the curve calculator
     * @param _curveType Curve type
     * @return Curve calculator
     */
    function curveCalculators(uint8 _curveType) external view returns (address);

    /**
     * @notice Get the deposit token info
     * @param _curveType Curve type
     * @param _depositToken Deposit token address
     * @return Deposit token info
     */
    function getDepositTokenInfo(
        uint8 _curveType,
        address _depositToken
    )
        external
        view
        returns (MemeDepositTokenInfo memory);

    /**
     * @notice Get the number of deposit tokens
     * @return Number of deposit tokens
     */
    function getDepositTokensLength() external view returns (uint256);

    /**
     * @notice Get the max creator buy amount percentage
     * @return Max creator buy amount percentage
     */
    function maxCreatorBuyAmountPercentage() external view returns (uint256);

    /**
     * @notice Get the token creator fee
     * @return Token creator fee
     */
    function tokenCreatorFee() external view returns (uint256);

    /**
     * @notice Set the max creator buy amount percentage
     * @param _maxCreatorBuyAmountPercentage Max creator buy amount percentage
     */
    function setMaxCreatorBuyAmountPercentage(uint256 _maxCreatorBuyAmountPercentage) external;

    /**
     * @notice Set the token creator fee
     * @param _tokenCreatorFee Token creator fee
     */
    function setTokenCreatorFee(uint256 _tokenCreatorFee) external;

    /**
     * @notice Set the curve calculator
     * @param _curveType Curve type
     * @param _curveCalculator Curve calculator address
     */
    function setCurveCalculator(uint8 _curveType, address _curveCalculator) external;

    /**
     * @notice Set the information for a specific deposit token
     * @param token Address of the deposit token
     * @param targetRaise The target raise amount for the token
     * @param initialPrice The initial price per token in deposit token
     * @param coefficient The leading coefficient for the bonding curve
     * @param totalTokensForBondingCurve The total tokens for the bonding curve
     * @param isSupported Whether the token is supported
     * @param curveType The type of curve
     */
    function setDepositTokenInfo(
        address token,
        uint256 targetRaise,
        uint256 initialPrice,
        uint256 coefficient,
        uint256 totalTokensForBondingCurve,
        uint256 initialX,
        uint256 initialY,
        bool isSupported,
        uint8 curveType
    )
        external;

    /**
     * @notice Update the hyperpie config
     * @param _hyperpieConfig Hyperpie config address
     */
    function updateConfig(address _hyperpieConfig) external;

    /**
     * @notice Set the referral for a user
     * @param _referral Referral address
     * @dev This function emits an event that is tracked by a subgraph to maintain referral relationships
     */
    function setUserReferral(address _referral) external;

    /**
     * @notice Quote the amount of deposit token required to buy _memeTokenAmount of MEME tokens
     * @param _memeToken Address of the MEME token
     * @param _memeTokenAmount Amount of MEME tokens to buy or sell
     * @return depositTokenAmount Amount of deposit token required to buy _memeTokenAmount of MEME tokens
     */
    function quoteBuyDepositTokenAmount(address _memeToken, uint256 _memeTokenAmount) external view returns (uint256);
}

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

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IWHYPE is IERC20 {
    function deposit() external payable;

    function withdraw(uint256) external;
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;

import { IHyperpieConfig } from "../utils/HyperpieConfigRoleChecker.sol";
import { HyperpieConstants } from "../utils/HyperpieConstants.sol";
import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol";


library RoleCheckerLib {

  
    /*//////////////////////////////////////////////////////////////
                                MODIFIERS
    //////////////////////////////////////////////////////////////*/
    function onlyRole(bytes32 role, address hyperpieConfig) external view {
        if (!IAccessControl(hyperpieConfig).hasRole(role, msg.sender)) {
            string memory roleStr = string(abi.encodePacked(role));
            revert IHyperpieConfig.CallerNotHyperpieConfigAllowedRole(roleStr);
        }
    }

    function onlyPriceProvider(address hyperpieConfig) external view {
        if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.PRICE_PROVIDER_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigPriceProvider();
        }
    }

    function onlyHyperpieManager(address hyperpieConfig) external view {
        if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.MANAGER, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigManager();
        }
    }

    function onlyDefaultAdmin(address hyperpieConfig) external view {
        if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.DEFAULT_ADMIN_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigAdmin();
        }
    }

    function onlyMinter(address hyperpieConfig) external view {
        if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.MINTER_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigMinter();
        }
    }

    function onlyBurner(address hyperpieConfig) external view {
        if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.BURNER_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigBurner();
        }
    }

    function onlyOracleAdmin(address hyperpieConfig) external view {
        if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.ORACLE_ADMIN_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigOracleAdmin();
        }
    }

    function onlyOracle(address hyperpieConfig) external view {
        if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.ORACLE_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigOracle();
        }
    }

    function onlyPauser(address hyperpieConfig) external view {
        if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.PAUSER_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpiePauser();
        }
    }

    function onlyAllowedBot(address hyperpieConfig) external view {
        if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.ALLOWED_BOT_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigAllowedBot();
        }
    }

    function onlyFeeManager(address hyperpieConfig) external view {
        if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.FEE_MANAGER_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigFeeManager();
        }
    }

    function onlyMetaConfigRole(address hyperpieConfig) external view {
        if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.HYPERPIE_V2_META_CONFIG_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigMetaConfig();
        }
    }
}

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

pragma solidity ^0.8.0;

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

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

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

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

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

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(address from, address to, uint256 amount) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

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

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (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);
    }
}

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

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

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

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

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

interface IPoolFees {

    event UpdatedHyperpieConfig(address indexed hyperpieConfig);

    error NotPool();
    error InvalidFees();
    error NotLaunchpad();
    error TransferFailed();
    error InvalidToken();

    function collectFee(address _token, uint256 _amount) external;

    /// @notice Address of Minter.sol
    function claimFeesFor(address _recipient, uint256 _amount0, uint256 _amount1) external;

    function lpRevShareBPS() external view returns (uint256 lpRevBps);
    function setCreatorAndMeme(bool _meme, address _creator) external;
}

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

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @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 ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

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

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized != type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

File 29 of 33 : HyperpieConfigRoleChecker.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;

import { UtilLib } from "./UtilLib.sol";
import { HyperpieConstants } from "./HyperpieConstants.sol";

import { IHyperpieConfig } from "../interfaces/IHyperpieConfig.sol";

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

/// @title HyperpieConfigRoleChecker - Role checker for Hyperpie Config
/// @notice Provides role checking functionality for Hyperpie Config
abstract contract HyperpieConfigRoleChecker {
    /*//////////////////////////////////////////////////////////////
                            STATE VARIABLES
    //////////////////////////////////////////////////////////////*/
    IHyperpieConfig public hyperpieConfig;
    uint256[49] private __gap; // reserve for upgrade

    /*//////////////////////////////////////////////////////////////
                                EVENTS
    //////////////////////////////////////////////////////////////*/
    event UpdatedHyperpieConfig(address indexed hyperpieConfig);

    /*//////////////////////////////////////////////////////////////
                                MODIFIERS
    //////////////////////////////////////////////////////////////*/
    modifier onlyRole(bytes32 role) {
        if (!IAccessControl(address(hyperpieConfig)).hasRole(role, msg.sender)) {
            string memory roleStr = string(abi.encodePacked(role));
            revert IHyperpieConfig.CallerNotHyperpieConfigAllowedRole(roleStr);
        }
        _;
    }

    modifier onlyPriceProvider() {
        if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.PRICE_PROVIDER_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigPriceProvider();
        }
        _;
    }

    modifier onlyHyperpieManager() {
        if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.MANAGER, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigManager();
        }
        _;
    }

    modifier onlyDefaultAdmin() {
        if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.DEFAULT_ADMIN_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigAdmin();
        }
        _;
    }

    modifier onlyMinter() {
        if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.MINTER_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigMinter();
        }
        _;
    }

    modifier onlyBurner() {
        if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.BURNER_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigBurner();
        }
        _;
    }

    modifier onlyOracleAdmin() {
        if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.ORACLE_ADMIN_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigOracleAdmin();
        }
        _;
    }

    modifier onlyOracle() {
        if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.ORACLE_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigOracle();
        }
        _;
    }

    modifier onlyPauser() {
        if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.PAUSER_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpiePauser();
        }
        _;
    }

    modifier onlyAllowedBot() {
        if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.ALLOWED_BOT_ROLE, msg.sender)) {
            revert IHyperpieConfig.CallerNotHyperpieConfigAllowedBot();
        }
        _;
    }

    modifier onlyOracleOrHyperpieStaking() {
        address hyperpieStaking = hyperpieConfig.getAddress(HyperpieConstants.HYPERPIE_STAKING);
        bool isOracle = IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.ORACLE_ROLE, msg.sender);
        bool isHyperpieStaking = msg.sender == hyperpieStaking;
        
        if (!isOracle && !isHyperpieStaking) {
            revert IHyperpieConfig.CallerNotHyperpieConfigOracle();
        }
        _;
    }

    /*//////////////////////////////////////////////////////////////
                            ADMIN FUNCTIONS
    //////////////////////////////////////////////////////////////*/
    /// @notice Updates the Hyperpie config contract
    /// @dev only callable by Hyperpie default
    /// @param hyperpieConfigAddr the new Hyperpie config contract Address
    function updateHyperpieConfig(address hyperpieConfigAddr) external virtual onlyDefaultAdmin {
        UtilLib.checkNonZeroAddress(hyperpieConfigAddr);
        hyperpieConfig = IHyperpieConfig(hyperpieConfigAddr);
        emit UpdatedHyperpieConfig(hyperpieConfigAddr);
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "../IERC20.sol";

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts 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;
    }
}

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

Settings
{
  "remappings": [
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "Uniswap/=lib/Uniswap/",
    "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
    "eth-gas-reporter/=node_modules/eth-gas-reporter/",
    "hardhat/=node_modules/hardhat/",
    "hyperevm-project-template/=lib/hyperevm-project-template/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "solidity-code-metrics/=node_modules/solidity-code-metrics/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 10000
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "shanghai",
  "viaIR": false,
  "libraries": {
    "contracts/launchpad/MEMELaunchpad.sol": {
      "LaunchpadLibrary": "0x953d27f8dacc0516e704d52b4b24ac76e7262432",
      "RoleCheckerLib": "0x756555769a04bc926dbd7f19f29928f1405c7979"
    }
  }
}

Contract Security Audit

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InsufficientMemeTokenBalance","type":"error"},{"inputs":[],"name":"OnlyWETH","type":"error"},{"inputs":[],"name":"ZeroAddressNotAllowed","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_curveType","type":"uint256"},{"indexed":false,"internalType":"address","name":"_curveCalculator","type":"address"}],"name":"CurveCalculatorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_feePercent","type":"uint256"},{"indexed":false,"internalType":"address","name":"_feeDestination","type":"address"},{"indexed":false,"internalType":"bool","name":"_isTradingFee","type":"bool"}],"name":"FeeInfoAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_feePercent","type":"uint256"},{"indexed":false,"internalType":"address","name":"_feeDestination","type":"address"},{"indexed":false,"internalType":"bool","name":"_isTradingFee","type":"bool"}],"name":"FeePercentSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"memeTokenAddress","type":"address"},{"indexed":true,"internalType":"address","name":"memeTokenCreator","type":"address"},{"indexed":false,"internalType":"uint8","name":"curveType","type":"uint8"},{"indexed":true,"internalType":"address","name":"depositTokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositTokenAmountTarget","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"initialMemeTokenPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"launchTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalTokens","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"creatorMemeTokenBuyAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"creatorMemeTokenBuyAmountNative","type":"uint256"},{"indexed":false,"internalType":"address","name":"curveCalculator","type":"address"},{"indexed":false,"internalType":"enum IMEMELaunchpad.Tags","name":"tags","type":"uint8"},{"indexed":false,"internalType":"string","name":"tokenURI","type":"string"}],"name":"LaunchCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"pair","type":"address"}],"name":"LaunchFinalized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_maxCreatorBuyAmountPercentage","type":"uint256"}],"name":"MaxCreatorBuyAmountPercentageSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"memeToken","type":"address"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"memeTokenAmountRec","type":"uint256"}],"name":"MemeTokenBuy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"memeToken","type":"address"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"memeTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"depositTokenAmountRec","type":"uint256"}],"name":"MemeTokenSell","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"totalRaised","type":"uint256"}],"name":"PreLaunchPhaseStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_feePercent","type":"uint256"}],"name":"TokenCreatorFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_hyperpieConfig","type":"address"}],"name":"UpdatedHyperpieConfig","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"address","name":"_referral","type":"address"}],"name":"UserReferralSet","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allLaunches","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_memeToken","type":"address"},{"internalType":"uint256","name":"_depositTokenAmount","type":"uint256"},{"internalType":"uint256","name":"_minReceivedMemeTokenAmount","type":"uint256"},{"internalType":"address","name":"_referral","type":"address"}],"name":"buyMemeTokenWithPoolCreationAndSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_memeToken","type":"address"},{"internalType":"uint256","name":"_minReceivedMemeTokenAmount","type":"uint256"},{"internalType":"address","name":"_referral","type":"address"}],"name":"buyMemeTokenWithPoolCreationAndSwapNative","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_memeToken","type":"address"},{"internalType":"uint256","name":"_depositTokenAmount","type":"uint256"},{"internalType":"uint256","name":"_minReceivedMemeTokenAmount","type":"uint256"},{"internalType":"address","name":"_referral","type":"address"}],"name":"buyMemeTokenWithoutPoolCreation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_memeToken","type":"address"},{"internalType":"uint256","name":"_minReceivedMemeTokenAmount","type":"uint256"},{"internalType":"address","name":"_referral","type":"address"}],"name":"buyMemeTokenWithoutPoolCreationNative","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"tokenName","type":"string"},{"internalType":"string","name":"tokenSymbol","type":"string"},{"internalType":"address","name":"depositToken","type":"address"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"creatorBuyAmount","type":"uint256"},{"internalType":"uint256","name":"creatorBuyAmountNative","type":"uint256"},{"internalType":"uint8","name":"curveType","type":"uint8"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"enum IMEMELaunchpad.Tags","name":"tags","type":"uint8"},{"internalType":"string","name":"tokenURI","type":"string"},{"internalType":"address","name":"referral","type":"address"}],"internalType":"struct IMEMELaunchpad.LaunchCreationParams","name":"_params","type":"tuple"}],"name":"createLaunch","outputs":[{"internalType":"address","name":"memeTokenAddress","type":"address"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_memeTokens","type":"address[]"}],"name":"finalizeLaunch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getLaunchCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getLaunchInfo","outputs":[{"components":[{"internalType":"address","name":"memeToken","type":"address"},{"internalType":"address","name":"memeTokenCreator","type":"address"},{"internalType":"address","name":"depositTokenAddress","type":"address"},{"internalType":"uint256","name":"launchTimestamp","type":"uint256"},{"internalType":"uint256","name":"depositTokenAmountRaised","type":"uint256"},{"internalType":"uint256","name":"soldMemeTokenAmount","type":"uint256"},{"internalType":"address","name":"pair","type":"address"},{"internalType":"uint8","name":"curveType","type":"uint8"},{"components":[{"internalType":"uint256","name":"depositTokenAmountTarget","type":"uint256"},{"internalType":"uint256","name":"initialMemeTokenPrice","type":"uint256"},{"internalType":"uint256","name":"coefficient","type":"uint256"},{"internalType":"uint256","name":"bondingCurveMemeTokenSupply","type":"uint256"},{"internalType":"uint256","name":"initialX","type":"uint256"},{"internalType":"uint256","name":"initialY","type":"uint256"},{"internalType":"bool","name":"isSupported","type":"bool"}],"internalType":"struct ILaunchpadStorage.MemeDepositTokenInfo","name":"depositTokenInfo","type":"tuple"},{"internalType":"address","name":"curveCalculator","type":"address"},{"internalType":"enum IMEMELaunchpad.Tags","name":"tags","type":"uint8"},{"internalType":"string","name":"tokenURI","type":"string"}],"internalType":"struct IMEMELaunchpad.LaunchInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hyperpieConfig","outputs":[{"internalType":"contract IHyperpieConfig","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_hyperpieConfig","type":"address"},{"internalType":"address","name":"_launchpadStorage","type":"address"},{"internalType":"address","name":"_wNative","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"launches","outputs":[{"internalType":"address","name":"memeToken","type":"address"},{"internalType":"address","name":"memeTokenCreator","type":"address"},{"internalType":"address","name":"depositTokenAddress","type":"address"},{"internalType":"uint256","name":"launchTimestamp","type":"uint256"},{"internalType":"uint256","name":"depositTokenAmountRaised","type":"uint256"},{"internalType":"uint256","name":"soldMemeTokenAmount","type":"uint256"},{"internalType":"address","name":"pair","type":"address"},{"internalType":"uint8","name":"curveType","type":"uint8"},{"components":[{"internalType":"uint256","name":"depositTokenAmountTarget","type":"uint256"},{"internalType":"uint256","name":"initialMemeTokenPrice","type":"uint256"},{"internalType":"uint256","name":"coefficient","type":"uint256"},{"internalType":"uint256","name":"bondingCurveMemeTokenSupply","type":"uint256"},{"internalType":"uint256","name":"initialX","type":"uint256"},{"internalType":"uint256","name":"initialY","type":"uint256"},{"internalType":"bool","name":"isSupported","type":"bool"}],"internalType":"struct ILaunchpadStorage.MemeDepositTokenInfo","name":"depositTokenInfo","type":"tuple"},{"internalType":"address","name":"curveCalculator","type":"address"},{"internalType":"enum IMEMELaunchpad.Tags","name":"tags","type":"uint8"},{"internalType":"string","name":"tokenURI","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"launchpadStorage","outputs":[{"internalType":"contract ILaunchpadStorage","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_memeToken","type":"address"},{"internalType":"uint256","name":"_depositTokenAmount","type":"uint256"}],"name":"quoteBuyMemeTokenAmount","outputs":[{"internalType":"uint256","name":"memeTokenAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_memeToken","type":"address"}],"name":"quoteMaxDepositTokenInputAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_memeToken","type":"address"},{"internalType":"uint256","name":"_memeTokenAmount","type":"uint256"}],"name":"quoteSellMemeTokenAmount","outputs":[{"internalType":"uint256","name":"depositTokenAmountRecAfterFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_memeToken","type":"address"},{"internalType":"uint256","name":"_memeTokenAmount","type":"uint256"},{"internalType":"uint256","name":"_minDepositTokenAmount","type":"uint256"},{"internalType":"address","name":"_referral","type":"address"}],"name":"sellMemeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_memeToken","type":"address"},{"internalType":"address","name":"_creator","type":"address"}],"name":"setCreator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_hyperpieConfig","type":"address"}],"name":"updateConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wNative","outputs":[{"internalType":"contract IWHYPE","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

608060405234801562000010575f80fd5b506200001b62000021565b620000df565b5f54610100900460ff16156200008d5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b5f5460ff90811614620000dd575f805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b615fc980620000ed5f395ff3fe6080604052600436106200019a575f3560e01c80639e47b9c811620000e2578063d320273b1162000086578063f41440d9116200005e578063f41440d914620004ca578063fc57655414620004ee578063fcb9344a1462000505575f80fd5b8063d320273b1462000464578063db7367a41462000485578063f07f196e14620004a9575f80fd5b8063c0c53b8b11620000ba578063c0c53b8b1462000405578063c5ed423b1462000429578063cbe4abaa146200044d575f80fd5b80639e47b9c814620003a75780639ff0251f14620003cb578063b0993d0e14620003e1575f80fd5b80635c975abb116200014a57806372cb1483116200012257806372cb148314620003465780638456cb5914620003795780639a52bed01462000390575f80fd5b80635c975abb14620002cb5780636cc919c814620002ef5780636e0918251462000313575f80fd5b80633f4ba83a116200017e5780633f4ba83a146200026c57806341d6e9d3146200028357806354110b8a14620002a7575f80fd5b80631f2d855014620001eb5780632d68efc91462000232575f80fd5b36620001e7576098546001600160a01b03163314620001e5576040517f01f180c900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b005b5f80fd5b348015620001f7575f80fd5b506200020f62000209366004620038f6565b62000529565b604051620002299c9b9a99989796959493929190620039a9565b60405180910390f35b3480156200023e575f80fd5b5060985462000253906001600160a01b031681565b6040516001600160a01b03909116815260200162000229565b34801562000278575f80fd5b50620001e562000696565b3480156200028f575f80fd5b5062000253620002a136600462003a7d565b62000728565b348015620002b3575f80fd5b50620001e5620002c536600462003a95565b62000751565b348015620002d7575f80fd5b5060655460ff16604051901515815260200162000229565b348015620002fb575f80fd5b50620001e56200030d366004620038f6565b62000821565b3480156200031f575f80fd5b506200033762000331366004620038f6565b6200091f565b60405162000229919062003c16565b34801562000352575f80fd5b506200036a62000364366004620038f6565b62000b16565b60405190815260200162000229565b34801562000385575f80fd5b50620001e562000e3a565b62000253620003a136600462003d97565b62000eca565b348015620003b3575f80fd5b506200036a620003c536600462003ed0565b62001768565b348015620003d7575f80fd5b50609b546200036a565b348015620003ed575f80fd5b50620001e5620003ff36600462003a95565b62001a3b565b34801562000411575f80fd5b50620001e56200042336600462003efd565b62001afa565b34801562000435575f80fd5b506200036a6200044736600462003ed0565b62001d16565b620001e56200045e36600462003f4c565b62001ffc565b34801562000470575f80fd5b5060995462000253906001600160a01b031681565b34801562000491575f80fd5b50620001e5620004a336600462003a95565b620021fb565b348015620004b5575f80fd5b5060975462000253906001600160a01b031681565b348015620004d6575f80fd5b50620001e5620004e836600462003f85565b620022f7565b620001e5620004ff36600462003f4c565b6200241e565b34801562000511575f80fd5b50620001e56200052336600462003fc1565b6200260c565b609a60209081525f9182526040918290208054600182015460028301546003840154600485015460058601546006870154895160e081018b5260078901548152600889015499810199909952600988015499890199909952600a8701546060890152600b8701546080890152600c87015460a0890152600d87015460ff908116151560c08a0152600e880154600f890180546001600160a01b03998a169c988a169b978a169a96999598949785871697740100000000000000000000000000000000000000009687900486169791969185169591909404169291906200060f9062004035565b80601f01602080910402602001604051908101604052809291908181526020018280546200063d9062004035565b80156200068c5780601f1062000662576101008083540402835291602001916200068c565b820191905f5260205f20905b8154815290600101906020018083116200066e57829003601f168201915b505050505090508c565b6099546040517f8321d8c20000000000000000000000000000000000000000000000000000000081526001600160a01b03909116600482015273756555769a04bc926dbd7f19f29928f1405c797990638321d8c2906024015f6040518083038186803b15801562000705575f80fd5b505af415801562000718573d5f803e3d5ffd5b50505050620007266200270b565b565b609b818154811062000738575f80fd5b5f918252602090912001546001600160a01b0316905081565b6200075b6200275f565b62000765620027d4565b6001600160a01b0384165f908152609a60205260409081902090517f1e405fd600000000000000000000000000000000000000000000000000000000815273953d27f8dacc0516e704d52b4b24ac76e726243290631e405fd690620007d3908490899089906004016200421b565b5f6040518083038186803b158015620007ea575f80fd5b505af4158015620007fd573d5f803e3d5ffd5b50505050620008108185855f8662002843565b506200081b60018055565b50505050565b6200082c8162002a86565b6099546040517f8321d8c20000000000000000000000000000000000000000000000000000000081526001600160a01b03909116600482015273756555769a04bc926dbd7f19f29928f1405c797990638321d8c2906024015f6040518083038186803b1580156200089b575f80fd5b505af4158015620008ae573d5f803e3d5ffd5b5050609980547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0385169081179091556040519081527f70edc3ecaaed82c5ab4a171ac33229a3aa307576b6418dd6551b97da670cf2ad9250602001905060405180910390a150565b620009296200380f565b6001600160a01b038083165f908152609a60209081526040918290208251610180810184528154851681526001820154851681840152600282015485168185015260038201546060808301919091526004830154608080840191909152600584015460a080850191909152600685015480891660c08087019190915260ff7401000000000000000000000000000000000000000092839004811660e0808901919091528a519081018b52600789015481526008890154998101999099526009808901549a8a019a909a52600a88015495890195909552600b87015493880193909352600c86015491870191909152600d8501548316151591860191909152610100830194909452600e83015495861661012083015290949193610140860193909204169081111562000a5f5762000a5f62003914565b600981111562000a735762000a7362003914565b8152602001600f8201805462000a899062004035565b80601f016020809104026020016040519081016040528092919081815260200182805462000ab79062004035565b801562000b065780601f1062000adc5761010080835404028352916020019162000b06565b820191905f5260205f20905b81548152906001019060200180831162000ae857829003601f168201915b5050505050815250509050919050565b6001600160a01b038082165f908152609a602090815260408083208151610180810183528154861681526001820154861681850152600282015486168184015260038201546060808301919091526004830154608080840191909152600584015460a0808501919091526006850154808a1660c08087019190915260ff7401000000000000000000000000000000000000000092839004811660e08089019190915289519081018a526007890154815260088901549a81019a909a52600980890154998b0199909952600a880154958a0195909552600b87015493890193909352600c86015491880191909152600d8501548316151591870191909152610100830195909552600e83015496871661012083015294958695919492936101408601939091049091169081111562000c515762000c5162003914565b600981111562000c655762000c6562003914565b8152602001600f8201805462000c7b9062004035565b80601f016020809104026020016040519081016040528092919081815260200182805462000ca99062004035565b801562000cf85780601f1062000cce5761010080835404028352916020019162000cf8565b820191905f5260205f20905b81548152906001019060200180831162000cda57829003601f168201915b50505050508152505090505f81608001518261010001515f015162000d1e919062004277565b90505f73953d27f8dacc0516e704d52b4b24ac76e72624326395f80f538360975f9054906101000a90046001600160a01b03166001600160a01b031663d79ac0186040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000d8d573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000db391906200428d565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815260048101929092526024820152604401602060405180830381865af415801562000e0b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000e3191906200428d565b95945050505050565b6099546040517fbf4019ec0000000000000000000000000000000000000000000000000000000081526001600160a01b03909116600482015273756555769a04bc926dbd7f19f29928f1405c79799063bf4019ec906024015f6040518083038186803b15801562000ea9575f80fd5b505af415801562000ebc573d5f803e3d5ffd5b505050506200072662002aca565b5f62000ed56200275f565b62000edf620027d4565b60975460c08301516040517f66340b4900000000000000000000000000000000000000000000000000000000815260ff90911660048201525f916001600160a01b0316906366340b4990602401602060405180830381865afa15801562000f48573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000f6e9190620042a5565b90505f60975f9054906101000a90046001600160a01b03166001600160a01b03166357c46aac6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000fc2573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000fe891906200428d565b60975460c086015160408088015190517fe910094f00000000000000000000000000000000000000000000000000000000815260ff90921660048301526001600160a01b03908116602483015292935073953d27f8dacc0516e704d52b4b24ac76e726243292638466298492889287929091169063e910094f9060440160e060405180830381865afa15801562001081573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620010a79190620042c3565b856040518563ffffffff1660e01b8152600401620010c9949392919062004333565b5f6040518083038186803b158015620010e0575f80fd5b505af4158015620010f3573d5f803e3d5ffd5b50505050620011735f8560e00151604051806020016200111390620038c6565b601f1982820381018352601f909101166040819052885160208a8101516200113e93909101620044be565b60408051601f19818403018152908290526200115e9291602001620044e6565b60405160208183030381529060405262002b0a565b6001600160a01b038082165f818152609a60205260409081902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000908116909317815560018101805484163317905560c089015160068201805460ff90921674010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909216919091179055908801516002820180549190941692169190911790915560608601519194509042116200124757846060015162001249565b425b60038201555f600480830182905560058301919091556006820180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905560975460c087015160408089015190517fe910094f00000000000000000000000000000000000000000000000000000000815260ff909216938201939093526001600160a01b03928316602482015291169063e910094f9060440160e060405180830381865afa15801562001300573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620013269190620042c3565b805160078301556020810151600883015560408101516009808401919091556060820151600a8401556080820151600b84015560a0820151600c84015560c090910151600d8301805460ff1916911515919091179055600e820180547fffffffffffffffffffffffff000000000000000000000000000000000000000081166001600160a01b0387169081178355610100890151937fffffffffffffffffffffff0000000000000000000000000000000000000000009092161790740100000000000000000000000000000000000000009084908111156200140c576200140c62003914565b0217905550610120850151600f82019062001428908262004561565b50609b80546001810182555f9182527fbba9db4cdbea0a37c207bbb83e20f828cd4441c49891101dc94fd20dc8efc3490180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038781169190911790915561014087015160405191169133917fd7616e3d0bfa66cade34a2361a559668a06ba1fd1431d81e85eb2c8d73b0e0c49190a360a0850151156200161d576098546040517f55d55d9900000000000000000000000000000000000000000000000000000000815273953d27f8dacc0516e704d52b4b24ac76e7262432916355d55d99916200152f9185916001600160a01b039091169034906004016200421b565b5f6040518083038186803b15801562001546575f80fd5b505af415801562001559573d5f803e3d5ffd5b50506098546040517f916d11460000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201523460248201525f925073953d27f8dacc0516e704d52b4b24ac76e7262432915063916d114690604401602060405180830381865af4158015620015d9573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620015ff91906200428d565b90506200161682825f60018a610140015162002c67565b5062001640565b6080850151156200164057620016408186608001515f8089610140015162002c67565b84604001516001600160a01b0316336001600160a01b0316856001600160a01b03167f498edb35d804742a9759cec7bf2aef33f4b6256380d177f8e364bc0d981451708860c00151856007015f0154866007016001015487600301548b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620016d9573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620016ff91906200428d565b8d608001518e60a001518b600e015f9054906101000a90046001600160a01b03168c600e0160149054906101000a900460ff168d600f016040516200174e9a9998979695949392919062004668565b60405180910390a45050506200176360018055565b919050565b6001600160a01b038083165f908152609a602090815260408083208151610180810183528154861681526001820154861681850152600282015486168184015260038201546060808301919091526004830154608080840191909152600584015460a0808501919091526006850154808a1660c08087019190915260ff7401000000000000000000000000000000000000000092839004811660e08089019190915289519081018a526007890154815260088901549a81019a909a52600980890154998b0199909952600a880154958a0195909552600b87015493890193909352600c86015491880191909152600d8501548316151591870191909152610100830195909552600e830154968716610120830152949586959194929361014086019390910490911690811115620018a357620018a362003914565b6009811115620018b757620018b762003914565b8152602001600f82018054620018cd9062004035565b80601f0160208091040260200160405190810160405280929190818152602001828054620018fb9062004035565b80156200194a5780601f1062001920576101008083540402835291602001916200194a565b820191905f5260205f20905b8154815290600101906020018083116200192c57829003601f168201915b50505050508152505090505f8161012001516001600160a01b03166326afd81883866040518363ffffffff1660e01b81526004016200198b929190620046db565b602060405180830381865afa158015620019a7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620019cd91906200428d565b905073953d27f8dacc0516e704d52b4b24ac76e7262432634c7ae1308260975f9054906101000a90046001600160a01b03166001600160a01b031663d79ac0186040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000d8d573d5f803e3d5ffd5b62001a456200275f565b62001a4f620027d4565b6001600160a01b0384165f908152609a60205260409081902090517f1e405fd600000000000000000000000000000000000000000000000000000000815273953d27f8dacc0516e704d52b4b24ac76e726243290631e405fd69062001abd908490899089906004016200421b565b5f6040518083038186803b15801562001ad4575f80fd5b505af415801562001ae7573d5f803e3d5ffd5b50505050620008108185855f8662002c67565b5f54610100900460ff161580801562001b1957505f54600160ff909116105b8062001b345750303b15801562001b3457505f5460ff166001145b62001bc6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b5f805460ff19166001179055801562001c05575f80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b62001c108462002a86565b62001c1a62002fd7565b62001c2462003079565b609880546001600160a01b038481167fffffffffffffffffffffffff00000000000000000000000000000000000000009283161790925560998054878416908316811790915560978054938716939092169290921790556040519081527f70edc3ecaaed82c5ab4a171ac33229a3aa307576b6418dd6551b97da670cf2ad9060200160405180910390a180156200081b575f80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050565b6001600160a01b038083165f908152609a602090815260408083208151610180810183528154861681526001820154861681850152600282015486168184015260038201546060808301919091526004830154608080840191909152600584015460a0808501919091526006850154808a1660c08087019190915260ff7401000000000000000000000000000000000000000092839004811660e08089019190915289519081018a526007890154815260088901549a81019a909a52600980890154998b0199909952600a880154958a0195909552600b87015493890193909352600c86015491880191909152600d8501548316151591870191909152610100830195909552600e83015496871661012083015294958695919492936101408601939091049091169081111562001e515762001e5162003914565b600981111562001e655762001e6562003914565b8152602001600f8201805462001e7b9062004035565b80601f016020809104026020016040519081016040528092919081815260200182805462001ea99062004035565b801562001ef85780601f1062001ece5761010080835404028352916020019162001ef8565b820191905f5260205f20905b81548152906001019060200180831162001eda57829003601f168201915b50505050508152505090508061012001516001600160a01b031663d5616cc4828560975f9054906101000a90046001600160a01b03166001600160a01b031663d79ac0186040518163ffffffff1660e01b8152600401602060405180830381865afa15801562001f6a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062001f9091906200428d565b6040518463ffffffff1660e01b815260040162001fb093929190620046fe565b602060405180830381865afa15801562001fcc573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062001ff291906200428d565b9150505b92915050565b620020066200275f565b62002010620027d4565b6001600160a01b038084165f908152609a60205260409081902060985491517f55d55d99000000000000000000000000000000000000000000000000000000008152909273953d27f8dacc0516e704d52b4b24ac76e7262432926355d55d999262002084928692169034906004016200421b565b5f6040518083038186803b1580156200209b575f80fd5b505af4158015620020ae573d5f803e3d5ffd5b50506040517f1e405fd600000000000000000000000000000000000000000000000000000000815273953d27f8dacc0516e704d52b4b24ac76e72624329250631e405fd6915062002108908490889034906004016200421b565b5f6040518083038186803b1580156200211f575f80fd5b505af415801562002132573d5f803e3d5ffd5b50506098546040517f916d11460000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201523460248201525f925073953d27f8dacc0516e704d52b4b24ac76e7262432915063916d114690604401602060405180830381865af4158015620021b2573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620021d891906200428d565b9050620021ea82828660018762002843565b5050620021f660018055565b505050565b620022056200275f565b6200220f620027d4565b6001600160a01b0384165f908152609a60205260409081902090517f1e405fd600000000000000000000000000000000000000000000000000000000815273953d27f8dacc0516e704d52b4b24ac76e726243290631e405fd6906200227d908490899089906004016200421b565b5f6040518083038186803b15801562002294575f80fd5b505af4158015620022a7573d5f803e3d5ffd5b505050508060050154841115620022e9576040517e69471e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000810818585856200311b565b6099546040517ff038621a0000000000000000000000000000000000000000000000000000000081526001600160a01b03909116600482015273756555769a04bc926dbd7f19f29928f1405c79799063f038621a906024015f6040518083038186803b15801562002366575f80fd5b505af415801562002379573d5f803e3d5ffd5b505050506001600160a01b038281165f908152609a60205260409081902090517f830de9100000000000000000000000000000000000000000000000000000000081526004810182905291831660248301529073953d27f8dacc0516e704d52b4b24ac76e72624329063830de910906044015f6040518083038186803b15801562002402575f80fd5b505af415801562002415573d5f803e3d5ffd5b50505050505050565b620024286200275f565b62002432620027d4565b6001600160a01b038084165f908152609a60205260409081902060985491517f55d55d99000000000000000000000000000000000000000000000000000000008152909273953d27f8dacc0516e704d52b4b24ac76e7262432926355d55d9992620024a6928692169034906004016200421b565b5f6040518083038186803b158015620024bd575f80fd5b505af4158015620024d0573d5f803e3d5ffd5b50506040517f1e405fd600000000000000000000000000000000000000000000000000000000815273953d27f8dacc0516e704d52b4b24ac76e72624329250631e405fd691506200252a908490889034906004016200421b565b5f6040518083038186803b15801562002541575f80fd5b505af415801562002554573d5f803e3d5ffd5b50506098546040517f916d11460000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201523460248201525f925073953d27f8dacc0516e704d52b4b24ac76e7262432915063916d114690604401602060405180830381865af4158015620025d4573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620025fa91906200428d565b9050620021ea82828660018762002c67565b620026166200275f565b62002620620027d4565b6099546040517f62cf18a50000000000000000000000000000000000000000000000000000000081526001600160a01b03909116600482015273756555769a04bc926dbd7f19f29928f1405c7979906362cf18a5906024015f6040518083038186803b1580156200268f575f80fd5b505af4158015620026a2573d5f803e3d5ffd5b505050505f5b81811015620026fc57620026e7838383818110620026ca57620026ca62004724565b9050602002016020810190620026e19190620038f6565b620033b5565b80620026f38162004751565b915050620026a8565b506200270760018055565b5050565b6200271562003665565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600260015403620027cd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162001bbd565b6002600155565b60655460ff161562000726576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640162001bbd565b84545f906200285b906001600160a01b031662000b16565b90505f818611156200287b5762002873828762004277565b90506200287f565b8591505b6200288e878387878762002c67565b600787015460048801541062002415578654620028b4906001600160a01b0316620033b5565b801562002415576099546040517f21f8a7210000000000000000000000000000000000000000000000000000000081527fc0bf3125424e542a5ef242e03ca3d5281e5b3d29c7f7fa96403ead24e9f8ea29600482015273953d27f8dacc0516e704d52b4b24ac76e72624329163ba1ce0e3918a916001600160a01b0316906321f8a72190602401602060405180830381865afa15801562002957573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200297d9190620042a5565b6099546040517f21f8a7210000000000000000000000000000000000000000000000000000000081527f547b500e425d72fd0723933cceefc203cef652b4736fd04250c3369b3e1a0a7360048201526001600160a01b03909116906321f8a72190602401602060405180830381865afa158015620029fd573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062002a239190620042a5565b85338a6040518763ffffffff1660e01b815260040162002a49969594939291906200478b565b5f6040518083038186803b15801562002a60575f80fd5b505af415801562002a73573d5f803e3d5ffd5b5050505050505050505050565b60018055565b6001600160a01b03811662002ac7576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50565b62002ad4620027d4565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258620027423390565b5f8347101562002b77576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e6365000000604482015260640162001bbd565b81515f0362002be3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f604482015260640162001bbd565b8282516020840186f590506001600160a01b03811662002c60576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f7900000000000000604482015260640162001bbd565b9392505050565b5f73953d27f8dacc0516e704d52b4b24ac76e726243263c5815be187878760975f9054906101000a90046001600160a01b03166001600160a01b031663d79ac0186040518163ffffffff1660e01b8152600401602060405180830381865afa15801562002cd6573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062002cfc91906200428d565b60975f9054906101000a90046001600160a01b03166001600160a01b031663e8fe8d996040518163ffffffff1660e01b8152600401602060405180830381865afa15801562002d4d573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062002d7391906200428d565b60975f9054906101000a90046001600160a01b03166001600160a01b031663d38dff696040518163ffffffff1660e01b81526004015f60405180830381865afa15801562002dc3573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405262002dec9190810190620047d8565b6098546040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b16815262002e3d979695949392918d916001600160a01b039091169060040162004908565b602060405180830381865af415801562002e59573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062002e7f91906200428d565b6040519091506001600160a01b0383169033907fd7616e3d0bfa66cade34a2361a559668a06ba1fd1431d81e85eb2c8d73b0e0c4905f90a38554604080518781526020810184905233926001600160a01b0316917fa0a84a835300fe8ca774e5990a2da21d9e45eba2a414f052865b5bf18573135e910160405180910390a3600786015460048701541062002fcf5785546040517f21175b4a0000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906321175b4a9062002f599060019060040162004961565b5f604051808303815f87803b15801562002f71575f80fd5b505af115801562002f84573d5f803e3d5ffd5b5050875460048901546040519081526001600160a01b0390911692507f60d1cca17f5e84a32b1480a1de65214c1b61ada3393d5a80674ff8745fe9a803915060200160405180910390a25b505050505050565b5f54610100900460ff166200306f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001bbd565b62000726620036d3565b5f54610100900460ff1662003111576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001bbd565b620007266200376b565b5f73953d27f8dacc0516e704d52b4b24ac76e726243263b59cad5586868660975f9054906101000a90046001600160a01b03166001600160a01b031663d79ac0186040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200318a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620031b091906200428d565b60975f9054906101000a90046001600160a01b03166001600160a01b031663e8fe8d996040518163ffffffff1660e01b8152600401602060405180830381865afa15801562003201573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200322791906200428d565b60975f9054906101000a90046001600160a01b03166001600160a01b031663d38dff696040518163ffffffff1660e01b81526004015f60405180830381865afa15801562003277573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052620032a09190810190620047d8565b6098546040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b168152620032ed979695949392916001600160a01b0316906004016200497e565b602060405180830381865af415801562003309573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200332f91906200428d565b6040519091506001600160a01b0383169033907fd7616e3d0bfa66cade34a2361a559668a06ba1fd1431d81e85eb2c8d73b0e0c4905f90a38454604080518681526020810184905233926001600160a01b0316917faa664663fc826b7a728767a100136fe5fcae7392aac2ad3fb0c47cbdf587d3e6910160405180910390a35050505050565b6001600160a01b038181165f908152609a60205260409081902060995491517f21f8a7210000000000000000000000000000000000000000000000000000000081527fc0bf3125424e542a5ef242e03ca3d5281e5b3d29c7f7fa96403ead24e9f8ea296004820152909273953d27f8dacc0516e704d52b4b24ac76e72624329263635c3432928692869216906321f8a72190602401602060405180830381865afa15801562003466573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200348c9190620042a5565b6099546040517f21f8a7210000000000000000000000000000000000000000000000000000000081527f547b500e425d72fd0723933cceefc203cef652b4736fd04250c3369b3e1a0a7360048201526001600160a01b03909116906321f8a72190602401602060405180830381865afa1580156200350c573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620035329190620042a5565b60975f9054906101000a90046001600160a01b03166001600160a01b0316632dc6d23d6040518163ffffffff1660e01b81526004015f60405180830381865afa15801562003582573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052620035ab9190810190620047d8565b6099546040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b168152620035f79695949392916001600160a01b031690600401620049cd565b5f6040518083038186803b1580156200360e575f80fd5b505af415801562003621573d5f803e3d5ffd5b5050505060068101546040516001600160a01b03918216918416907f259e7e20bd2fa15a88aa3a8f7895503dc1cbf5845616623edd5a88b075deb5c4905f90a35050565b60655460ff1662000726576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015260640162001bbd565b5f54610100900460ff1662002a80576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001bbd565b5f54610100900460ff1662003803576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001bbd565b6065805460ff19169055565b6040518061018001604052805f6001600160a01b031681526020015f6001600160a01b031681526020015f6001600160a01b031681526020015f81526020015f81526020015f81526020015f6001600160a01b031681526020015f60ff168152602001620038ae6040518060e001604052805f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f151581525090565b81525f60208201819052604082015260609081015290565b6115768062004a1e83390190565b6001600160a01b038116811462002ac7575f80fd5b80356200176381620038d4565b5f6020828403121562003907575f80fd5b813562002c6081620038d4565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b600a811062003954576200395462003914565b9052565b5f5b83811015620039745781810151838201526020016200395a565b50505f910152565b5f81518084526200399581602086016020860162003958565b601f01601f19169290920160200192915050565b5f6001600160a01b03808f168352808e166020840152808d1660408401528b60608401528a60808401528960a084015280891660c084015260ff881660e084015262003a3a610100840188805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a083015260c0810151151560c08301525050565b85166101e083015262003a5261020083018562003941565b61024061022083015262003a6b6102408301846200397c565b9e9d5050505050505050505050505050565b5f6020828403121562003a8e575f80fd5b5035919050565b5f805f806080858703121562003aa9575f80fd5b843562003ab681620038d4565b93506020850135925060408501359150606085013562003ad681620038d4565b939692955090935050565b80516001600160a01b031682525f610240602083015162003b0d60208601826001600160a01b03169052565b50604083015162003b2960408601826001600160a01b03169052565b50606083015160608501526080830151608085015260a083015160a085015260c083015162003b6360c08601826001600160a01b03169052565b5060e083015162003b7960e086018260ff169052565b5061010083810151805186830152602081015161012087015260408101516101408701526060810151610160870152608081015161018087015260a08101516101a087015260c081015115156101c087015250506101208301516001600160a01b0381166101e08601525061014083015162003bfa61020086018262003941565b506101608301518161022086015262000e31828601826200397c565b602081525f62002c60602083018462003ae1565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b604051610160810167ffffffffffffffff8111828210171562003c7e5762003c7e62003c2a565b60405290565b60405160e0810167ffffffffffffffff8111828210171562003c7e5762003c7e62003c2a565b6040805190810167ffffffffffffffff8111828210171562003c7e5762003c7e62003c2a565b604051601f8201601f1916810167ffffffffffffffff8111828210171562003cfc5762003cfc62003c2a565b604052919050565b5f82601f83011262003d14575f80fd5b813567ffffffffffffffff81111562003d315762003d3162003c2a565b62003d466020601f19601f8401160162003cd0565b81815284602083860101111562003d5b575f80fd5b816020850160208301375f918101602001919091529392505050565b803560ff8116811462001763575f80fd5b8035600a811062001763575f80fd5b5f6020828403121562003da8575f80fd5b813567ffffffffffffffff8082111562003dc0575f80fd5b90830190610160828603121562003dd5575f80fd5b62003ddf62003c57565b82358281111562003dee575f80fd5b62003dfc8782860162003d04565b82525060208301358281111562003e11575f80fd5b62003e1f8782860162003d04565b60208301525062003e3360408401620038e9565b6040820152606083013560608201526080830135608082015260a083013560a082015262003e6460c0840162003d77565b60c082015260e083013560e082015261010062003e8381850162003d88565b90820152610120838101358381111562003e9b575f80fd5b62003ea98882870162003d04565b828401525050610140915062003ec1828401620038e9565b91810191909152949350505050565b5f806040838503121562003ee2575f80fd5b823562003eef81620038d4565b946020939093013593505050565b5f805f6060848603121562003f10575f80fd5b833562003f1d81620038d4565b9250602084013562003f2f81620038d4565b9150604084013562003f4181620038d4565b809150509250925092565b5f805f6060848603121562003f5f575f80fd5b833562003f6c81620038d4565b925060208401359150604084013562003f4181620038d4565b5f806040838503121562003f97575f80fd5b823562003fa481620038d4565b9150602083013562003fb681620038d4565b809150509250929050565b5f806020838503121562003fd3575f80fd5b823567ffffffffffffffff8082111562003feb575f80fd5b818501915085601f83011262003fff575f80fd5b8135818111156200400e575f80fd5b8660208260051b850101111562004023575f80fd5b60209290920196919550909350505050565b600181811c908216806200404a57607f821691505b60208210810362004082577f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b50919050565b5f8154620040968162004035565b808552602060018381168015620040b65760018114620040d157620040fe565b60ff198516838901528284151560051b8901019550620040fe565b865f52825f205f5b85811015620040f65781548a8201860152908301908401620040d9565b890184019650505b505050505092915050565b5f61024062004131846200412485546001600160a01b031690565b6001600160a01b03169052565b60018301546001600160a01b0390811660208601526002840154811660408601526003840154606086015260048401546080860152600584015460a080870191909152600685015480831660c088015260ff90821c811660e0880152600786015461010088015260088601546101208801526009860154610140880152600a860154610160880152600b860154610180880152600c8601546101a0880152600d860154811615156101c0880152600e8601549283166101e088015262004202916102008801919084901c1662003941565b508061022085015262001ff2818501600f850162004088565b606081525f6200422f606083018662004109565b6001600160a01b039490941660208301525060400152919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b8181038181111562001ff65762001ff66200424a565b5f602082840312156200429e575f80fd5b5051919050565b5f60208284031215620042b6575f80fd5b815162002c6081620038d4565b5f60e08284031215620042d4575f80fd5b620042de62003c84565b825181526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c0830151801515811462004327575f80fd5b60c08201529392505050565b5f61014080835286516101608083860152620043546102a08601836200397c565b915060208901517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec08087850301838801526200439184836200397c565b935060408b01519250620043b16101808801846001600160a01b03169052565b60608b01516101a088015260808b01516101c088015260a08b01516101e088015260c08b015160ff1661020088015260e08b01516102208801526101008b015192506200440361024088018462003941565b6101209250828b015191508087850301610260880152506200442683826200397c565b938a01516001600160a01b038116610280880152939250620044459050565b8193506200445e60208601896001600160a01b03169052565b620044ad6040860188805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a083015260c0810151151560c08301525050565b858186015250505095945050505050565b604081525f620044d260408301856200397c565b828103602084015262000e3181856200397c565b5f8351620044f981846020880162003958565b8351908301906200450f81836020880162003958565b01949350505050565b601f821115620021f6575f81815260208120601f850160051c81016020861015620045405750805b601f850160051c820191505b8181101562002fcf578281556001016200454c565b815167ffffffffffffffff8111156200457e576200457e62003c2a565b62004596816200458f845462004035565b8462004518565b602080601f831160018114620045eb575f8415620045b45750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b17855562002fcf565b5f85815260208120601f198616915b828110156200461b57888601518255948401946001909101908401620045fa565b50858210156200465857878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b5f61014060ff8d1683528b60208401528a60408401528960608401528860808401528760a08401528660c08401526001600160a01b03861660e0840152620046b561010084018662003941565b80610120840152620046ca8184018562004088565b9d9c50505050505050505050505050565b604081525f620046ef604083018562003ae1565b90508260208301529392505050565b606081525f62004712606083018662003ae1565b60208301949094525060400152919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036200478457620047846200424a565b5060010190565b60c081525f6200479f60c083018962004109565b6001600160a01b03978816602084015295871660408301525060608101939093529316608082015291151560a090920191909152919050565b5f6020808385031215620047ea575f80fd5b825167ffffffffffffffff8082111562004802575f80fd5b818501915085601f83011262004816575f80fd5b8151818111156200482b576200482b62003c2a565b6200483b848260051b0162003cd0565b818152848101925060069190911b8301840190878211156200485b575f80fd5b928401925b81841015620048ae57604084890312156200487a575f8081fd5b6200488462003caa565b84518152858501516200489781620038d4565b818701528352604093909301929184019162004860565b979650505050505050565b5f8151808452602080850194508084015f5b83811015620048fd578151805188528301516001600160a01b03168388015260409096019590820190600101620048cb565b509495945050505050565b5f6101008a83528960208401528860408401528760608401528660808401528060a08401526200493b81840187620048b9565b94151560c084015250506001600160a01b039190911660e0909101529695505050505050565b602081016003831062004978576200497862003914565b91905290565b87815286602082015285604082015284606082015283608082015260e060a08201525f620049b060e0830185620048b9565b90506001600160a01b03831660c083015298975050505050505050565b5f6001600160a01b0380891683528760208401528087166040840152808616606084015260c0608084015262004a0760c0840186620048b9565b915080841660a08401525097965050505050505056fe608060405234801562000010575f80fd5b506040516200157638038062001576833981016040819052620000339162000386565b8181600362000043838262000477565b50600462000052828262000477565b5050506200006f62000069620000e660201b60201c565b620000ea565b81515f0362000091576040516316c31e7760e21b815260040160405180910390fd5b80515f03620000b35760405163220839c960e01b815260040160405180910390fd5b6005805460ff60a01b1916600160a11b179055620000de336b033b2e3c9fd0803ce80000006200013b565b505062000579565b3390565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6001600160a01b038216620001965760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b620001a35f83836200020c565b8060025f828254620001b6919062000553565b90915550506001600160a01b0382165f81815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6001600554600160a01b900460ff1660028111156200022f576200022f6200053f565b036200024e576040516380cbe9f360e01b815260040160405180910390fd5b6002600554600160a01b900460ff1660028111156200027157620002716200053f565b03620002c3576005546001600160a01b03848116911614801590620002a457506005546001600160a01b03838116911614155b15620002c35760405163063f3e4d60e01b815260040160405180910390fd5b505050565b634e487b7160e01b5f52604160045260245ffd5b5f82601f830112620002ec575f80fd5b81516001600160401b0380821115620003095762000309620002c8565b604051601f8301601f19908116603f01168101908282118183101715620003345762000334620002c8565b8160405283815260209250868385880101111562000350575f80fd5b5f91505b8382101562000373578582018301518183018401529082019062000354565b5f93810190920192909252949350505050565b5f806040838503121562000398575f80fd5b82516001600160401b0380821115620003af575f80fd5b620003bd86838701620002dc565b93506020850151915080821115620003d3575f80fd5b50620003e285828601620002dc565b9150509250929050565b600181811c908216806200040157607f821691505b6020821081036200042057634e487b7160e01b5f52602260045260245ffd5b50919050565b601f821115620002c3575f81815260208120601f850160051c810160208610156200044e5750805b601f850160051c820191505b818110156200046f578281556001016200045a565b505050505050565b81516001600160401b03811115620004935762000493620002c8565b620004ab81620004a48454620003ec565b8462000426565b602080601f831160018114620004e1575f8415620004c95750858301515b5f19600386901b1c1916600185901b1785556200046f565b5f85815260208120601f198616915b828110156200051157888601518255948401946001909101908401620004f0565b50858210156200052f57878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b5f52602160045260245ffd5b808201808211156200057357634e487b7160e01b5f52601160045260245ffd5b92915050565b610fef80620005875f395ff3fe608060405234801561000f575f80fd5b5060043610610115575f3560e01c806370a08231116100ad57806395d89b411161007d578063a9059cbb11610063578063a9059cbb1461027b578063dd62ed3e1461028e578063f2fde38b146102d3575f80fd5b806395d89b4114610260578063a457c2d714610268575f80fd5b806370a08231146101e8578063715018a61461021d5780638da5cb5b14610225578063902d55a51461024d575f80fd5b806323b872dd116100e857806323b872dd14610181578063295a521214610194578063313ce567146101c657806339509351146101d5575f80fd5b806306fdde0314610119578063095ea7b31461013757806318160ddd1461015a57806321175b4a1461016c575b5f80fd5b6101216102e6565b60405161012e9190610d63565b60405180910390f35b61014a610145366004610df4565b610376565b604051901515815260200161012e565b6002545b60405190815260200161012e565b61017f61017a366004610e1c565b61038f565b005b61014a61018f366004610e41565b610426565b6005546101b99074010000000000000000000000000000000000000000900460ff1681565b60405161012e9190610ea7565b6040516012815260200161012e565b61014a6101e3366004610df4565b610449565b61015e6101f6366004610ee6565b73ffffffffffffffffffffffffffffffffffffffff165f9081526020819052604090205490565b61017f610494565b60055460405173ffffffffffffffffffffffffffffffffffffffff909116815260200161012e565b61015e6b033b2e3c9fd0803ce800000081565b6101216104a7565b61014a610276366004610df4565b6104b6565b61014a610289366004610df4565b61058b565b61015e61029c366004610eff565b73ffffffffffffffffffffffffffffffffffffffff9182165f90815260016020908152604080832093909416825291909152205490565b61017f6102e1366004610ee6565b610598565b6060600380546102f590610f30565b80601f016020809104026020016040519081016040528092919081815260200182805461032190610f30565b801561036c5780601f106103435761010080835404028352916020019161036c565b820191905f5260205f20905b81548152906001019060200180831161034f57829003601f168201915b5050505050905090565b5f3361038381858561064c565b60019150505b92915050565b6103976107fe565b5f60055474010000000000000000000000000000000000000000900460ff1660028111156103c7576103c7610e7a565b1461042357600580548291907fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000083600281111561041d5761041d610e7a565b02179055505b50565b5f3361043385828561087f565b61043e858585610955565b506001949350505050565b335f81815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152812054909190610383908290869061048f908790610f81565b61064c565b61049c6107fe565b6104a55f610bcd565b565b6060600480546102f590610f30565b335f81815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091908381101561057e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61043e828686840361064c565b5f33610383818585610955565b6105a06107fe565b73ffffffffffffffffffffffffffffffffffffffff8116610643576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610575565b61042381610bcd565b73ffffffffffffffffffffffffffffffffffffffff83166106ee576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610575565b73ffffffffffffffffffffffffffffffffffffffff8216610791576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610575565b73ffffffffffffffffffffffffffffffffffffffff8381165f8181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60055473ffffffffffffffffffffffffffffffffffffffff1633146104a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610575565b73ffffffffffffffffffffffffffffffffffffffff8381165f908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461094f5781811015610942576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610575565b61094f848484840361064c565b50505050565b73ffffffffffffffffffffffffffffffffffffffff83166109f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610575565b73ffffffffffffffffffffffffffffffffffffffff8216610a9b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610575565b610aa6838383610c43565b73ffffffffffffffffffffffffffffffffffffffff83165f9081526020819052604090205481811015610b5b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610575565b73ffffffffffffffffffffffffffffffffffffffff8481165f81815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a361094f565b6005805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b600160055474010000000000000000000000000000000000000000900460ff166002811115610c7457610c74610e7a565b03610cab576040517f80cbe9f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600260055474010000000000000000000000000000000000000000900460ff166002811115610cdc57610cdc610e7a565b03610d5e5760055473ffffffffffffffffffffffffffffffffffffffff848116911614801590610d27575060055473ffffffffffffffffffffffffffffffffffffffff838116911614155b15610d5e576040517f063f3e4d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050565b5f6020808352835180828501525f5b81811015610d8e57858101830151858201604001528201610d72565b505f6040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610def575f80fd5b919050565b5f8060408385031215610e05575f80fd5b610e0e83610dcc565b946020939093013593505050565b5f60208284031215610e2c575f80fd5b813560038110610e3a575f80fd5b9392505050565b5f805f60608486031215610e53575f80fd5b610e5c84610dcc565b9250610e6a60208501610dcc565b9150604084013590509250925092565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b6020810160038310610ee0577f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b91905290565b5f60208284031215610ef6575f80fd5b610e3a82610dcc565b5f8060408385031215610f10575f80fd5b610f1983610dcc565b9150610f2760208401610dcc565b90509250929050565b600181811c90821680610f4457607f821691505b602082108103610f7b577f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b50919050565b80820180821115610389577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffdfea264697066735822122027843b07869e97aee88cf3baa00714638d89117127d258dd5136b3cc3974d35564736f6c63430008150033a2646970667358221220dd9bda768a9609424460271a6ba3ffbd7b114aa3b1daf276e55c291b8b9ee4f464736f6c63430008150033

Deployed Bytecode

0x6080604052600436106200019a575f3560e01c80639e47b9c811620000e2578063d320273b1162000086578063f41440d9116200005e578063f41440d914620004ca578063fc57655414620004ee578063fcb9344a1462000505575f80fd5b8063d320273b1462000464578063db7367a41462000485578063f07f196e14620004a9575f80fd5b8063c0c53b8b11620000ba578063c0c53b8b1462000405578063c5ed423b1462000429578063cbe4abaa146200044d575f80fd5b80639e47b9c814620003a75780639ff0251f14620003cb578063b0993d0e14620003e1575f80fd5b80635c975abb116200014a57806372cb1483116200012257806372cb148314620003465780638456cb5914620003795780639a52bed01462000390575f80fd5b80635c975abb14620002cb5780636cc919c814620002ef5780636e0918251462000313575f80fd5b80633f4ba83a116200017e5780633f4ba83a146200026c57806341d6e9d3146200028357806354110b8a14620002a7575f80fd5b80631f2d855014620001eb5780632d68efc91462000232575f80fd5b36620001e7576098546001600160a01b03163314620001e5576040517f01f180c900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b005b5f80fd5b348015620001f7575f80fd5b506200020f62000209366004620038f6565b62000529565b604051620002299c9b9a99989796959493929190620039a9565b60405180910390f35b3480156200023e575f80fd5b5060985462000253906001600160a01b031681565b6040516001600160a01b03909116815260200162000229565b34801562000278575f80fd5b50620001e562000696565b3480156200028f575f80fd5b5062000253620002a136600462003a7d565b62000728565b348015620002b3575f80fd5b50620001e5620002c536600462003a95565b62000751565b348015620002d7575f80fd5b5060655460ff16604051901515815260200162000229565b348015620002fb575f80fd5b50620001e56200030d366004620038f6565b62000821565b3480156200031f575f80fd5b506200033762000331366004620038f6565b6200091f565b60405162000229919062003c16565b34801562000352575f80fd5b506200036a62000364366004620038f6565b62000b16565b60405190815260200162000229565b34801562000385575f80fd5b50620001e562000e3a565b62000253620003a136600462003d97565b62000eca565b348015620003b3575f80fd5b506200036a620003c536600462003ed0565b62001768565b348015620003d7575f80fd5b50609b546200036a565b348015620003ed575f80fd5b50620001e5620003ff36600462003a95565b62001a3b565b34801562000411575f80fd5b50620001e56200042336600462003efd565b62001afa565b34801562000435575f80fd5b506200036a6200044736600462003ed0565b62001d16565b620001e56200045e36600462003f4c565b62001ffc565b34801562000470575f80fd5b5060995462000253906001600160a01b031681565b34801562000491575f80fd5b50620001e5620004a336600462003a95565b620021fb565b348015620004b5575f80fd5b5060975462000253906001600160a01b031681565b348015620004d6575f80fd5b50620001e5620004e836600462003f85565b620022f7565b620001e5620004ff36600462003f4c565b6200241e565b34801562000511575f80fd5b50620001e56200052336600462003fc1565b6200260c565b609a60209081525f9182526040918290208054600182015460028301546003840154600485015460058601546006870154895160e081018b5260078901548152600889015499810199909952600988015499890199909952600a8701546060890152600b8701546080890152600c87015460a0890152600d87015460ff908116151560c08a0152600e880154600f890180546001600160a01b03998a169c988a169b978a169a96999598949785871697740100000000000000000000000000000000000000009687900486169791969185169591909404169291906200060f9062004035565b80601f01602080910402602001604051908101604052809291908181526020018280546200063d9062004035565b80156200068c5780601f1062000662576101008083540402835291602001916200068c565b820191905f5260205f20905b8154815290600101906020018083116200066e57829003601f168201915b505050505090508c565b6099546040517f8321d8c20000000000000000000000000000000000000000000000000000000081526001600160a01b03909116600482015273756555769a04bc926dbd7f19f29928f1405c797990638321d8c2906024015f6040518083038186803b15801562000705575f80fd5b505af415801562000718573d5f803e3d5ffd5b50505050620007266200270b565b565b609b818154811062000738575f80fd5b5f918252602090912001546001600160a01b0316905081565b6200075b6200275f565b62000765620027d4565b6001600160a01b0384165f908152609a60205260409081902090517f1e405fd600000000000000000000000000000000000000000000000000000000815273953d27f8dacc0516e704d52b4b24ac76e726243290631e405fd690620007d3908490899089906004016200421b565b5f6040518083038186803b158015620007ea575f80fd5b505af4158015620007fd573d5f803e3d5ffd5b50505050620008108185855f8662002843565b506200081b60018055565b50505050565b6200082c8162002a86565b6099546040517f8321d8c20000000000000000000000000000000000000000000000000000000081526001600160a01b03909116600482015273756555769a04bc926dbd7f19f29928f1405c797990638321d8c2906024015f6040518083038186803b1580156200089b575f80fd5b505af4158015620008ae573d5f803e3d5ffd5b5050609980547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0385169081179091556040519081527f70edc3ecaaed82c5ab4a171ac33229a3aa307576b6418dd6551b97da670cf2ad9250602001905060405180910390a150565b620009296200380f565b6001600160a01b038083165f908152609a60209081526040918290208251610180810184528154851681526001820154851681840152600282015485168185015260038201546060808301919091526004830154608080840191909152600584015460a080850191909152600685015480891660c08087019190915260ff7401000000000000000000000000000000000000000092839004811660e0808901919091528a519081018b52600789015481526008890154998101999099526009808901549a8a019a909a52600a88015495890195909552600b87015493880193909352600c86015491870191909152600d8501548316151591860191909152610100830194909452600e83015495861661012083015290949193610140860193909204169081111562000a5f5762000a5f62003914565b600981111562000a735762000a7362003914565b8152602001600f8201805462000a899062004035565b80601f016020809104026020016040519081016040528092919081815260200182805462000ab79062004035565b801562000b065780601f1062000adc5761010080835404028352916020019162000b06565b820191905f5260205f20905b81548152906001019060200180831162000ae857829003601f168201915b5050505050815250509050919050565b6001600160a01b038082165f908152609a602090815260408083208151610180810183528154861681526001820154861681850152600282015486168184015260038201546060808301919091526004830154608080840191909152600584015460a0808501919091526006850154808a1660c08087019190915260ff7401000000000000000000000000000000000000000092839004811660e08089019190915289519081018a526007890154815260088901549a81019a909a52600980890154998b0199909952600a880154958a0195909552600b87015493890193909352600c86015491880191909152600d8501548316151591870191909152610100830195909552600e83015496871661012083015294958695919492936101408601939091049091169081111562000c515762000c5162003914565b600981111562000c655762000c6562003914565b8152602001600f8201805462000c7b9062004035565b80601f016020809104026020016040519081016040528092919081815260200182805462000ca99062004035565b801562000cf85780601f1062000cce5761010080835404028352916020019162000cf8565b820191905f5260205f20905b81548152906001019060200180831162000cda57829003601f168201915b50505050508152505090505f81608001518261010001515f015162000d1e919062004277565b90505f73953d27f8dacc0516e704d52b4b24ac76e72624326395f80f538360975f9054906101000a90046001600160a01b03166001600160a01b031663d79ac0186040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000d8d573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000db391906200428d565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815260048101929092526024820152604401602060405180830381865af415801562000e0b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000e3191906200428d565b95945050505050565b6099546040517fbf4019ec0000000000000000000000000000000000000000000000000000000081526001600160a01b03909116600482015273756555769a04bc926dbd7f19f29928f1405c79799063bf4019ec906024015f6040518083038186803b15801562000ea9575f80fd5b505af415801562000ebc573d5f803e3d5ffd5b505050506200072662002aca565b5f62000ed56200275f565b62000edf620027d4565b60975460c08301516040517f66340b4900000000000000000000000000000000000000000000000000000000815260ff90911660048201525f916001600160a01b0316906366340b4990602401602060405180830381865afa15801562000f48573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000f6e9190620042a5565b90505f60975f9054906101000a90046001600160a01b03166001600160a01b03166357c46aac6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000fc2573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000fe891906200428d565b60975460c086015160408088015190517fe910094f00000000000000000000000000000000000000000000000000000000815260ff90921660048301526001600160a01b03908116602483015292935073953d27f8dacc0516e704d52b4b24ac76e726243292638466298492889287929091169063e910094f9060440160e060405180830381865afa15801562001081573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620010a79190620042c3565b856040518563ffffffff1660e01b8152600401620010c9949392919062004333565b5f6040518083038186803b158015620010e0575f80fd5b505af4158015620010f3573d5f803e3d5ffd5b50505050620011735f8560e00151604051806020016200111390620038c6565b601f1982820381018352601f909101166040819052885160208a8101516200113e93909101620044be565b60408051601f19818403018152908290526200115e9291602001620044e6565b60405160208183030381529060405262002b0a565b6001600160a01b038082165f818152609a60205260409081902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000908116909317815560018101805484163317905560c089015160068201805460ff90921674010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909216919091179055908801516002820180549190941692169190911790915560608601519194509042116200124757846060015162001249565b425b60038201555f600480830182905560058301919091556006820180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905560975460c087015160408089015190517fe910094f00000000000000000000000000000000000000000000000000000000815260ff909216938201939093526001600160a01b03928316602482015291169063e910094f9060440160e060405180830381865afa15801562001300573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620013269190620042c3565b805160078301556020810151600883015560408101516009808401919091556060820151600a8401556080820151600b84015560a0820151600c84015560c090910151600d8301805460ff1916911515919091179055600e820180547fffffffffffffffffffffffff000000000000000000000000000000000000000081166001600160a01b0387169081178355610100890151937fffffffffffffffffffffff0000000000000000000000000000000000000000009092161790740100000000000000000000000000000000000000009084908111156200140c576200140c62003914565b0217905550610120850151600f82019062001428908262004561565b50609b80546001810182555f9182527fbba9db4cdbea0a37c207bbb83e20f828cd4441c49891101dc94fd20dc8efc3490180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038781169190911790915561014087015160405191169133917fd7616e3d0bfa66cade34a2361a559668a06ba1fd1431d81e85eb2c8d73b0e0c49190a360a0850151156200161d576098546040517f55d55d9900000000000000000000000000000000000000000000000000000000815273953d27f8dacc0516e704d52b4b24ac76e7262432916355d55d99916200152f9185916001600160a01b039091169034906004016200421b565b5f6040518083038186803b15801562001546575f80fd5b505af415801562001559573d5f803e3d5ffd5b50506098546040517f916d11460000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201523460248201525f925073953d27f8dacc0516e704d52b4b24ac76e7262432915063916d114690604401602060405180830381865af4158015620015d9573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620015ff91906200428d565b90506200161682825f60018a610140015162002c67565b5062001640565b6080850151156200164057620016408186608001515f8089610140015162002c67565b84604001516001600160a01b0316336001600160a01b0316856001600160a01b03167f498edb35d804742a9759cec7bf2aef33f4b6256380d177f8e364bc0d981451708860c00151856007015f0154866007016001015487600301548b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620016d9573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620016ff91906200428d565b8d608001518e60a001518b600e015f9054906101000a90046001600160a01b03168c600e0160149054906101000a900460ff168d600f016040516200174e9a9998979695949392919062004668565b60405180910390a45050506200176360018055565b919050565b6001600160a01b038083165f908152609a602090815260408083208151610180810183528154861681526001820154861681850152600282015486168184015260038201546060808301919091526004830154608080840191909152600584015460a0808501919091526006850154808a1660c08087019190915260ff7401000000000000000000000000000000000000000092839004811660e08089019190915289519081018a526007890154815260088901549a81019a909a52600980890154998b0199909952600a880154958a0195909552600b87015493890193909352600c86015491880191909152600d8501548316151591870191909152610100830195909552600e830154968716610120830152949586959194929361014086019390910490911690811115620018a357620018a362003914565b6009811115620018b757620018b762003914565b8152602001600f82018054620018cd9062004035565b80601f0160208091040260200160405190810160405280929190818152602001828054620018fb9062004035565b80156200194a5780601f1062001920576101008083540402835291602001916200194a565b820191905f5260205f20905b8154815290600101906020018083116200192c57829003601f168201915b50505050508152505090505f8161012001516001600160a01b03166326afd81883866040518363ffffffff1660e01b81526004016200198b929190620046db565b602060405180830381865afa158015620019a7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620019cd91906200428d565b905073953d27f8dacc0516e704d52b4b24ac76e7262432634c7ae1308260975f9054906101000a90046001600160a01b03166001600160a01b031663d79ac0186040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000d8d573d5f803e3d5ffd5b62001a456200275f565b62001a4f620027d4565b6001600160a01b0384165f908152609a60205260409081902090517f1e405fd600000000000000000000000000000000000000000000000000000000815273953d27f8dacc0516e704d52b4b24ac76e726243290631e405fd69062001abd908490899089906004016200421b565b5f6040518083038186803b15801562001ad4575f80fd5b505af415801562001ae7573d5f803e3d5ffd5b50505050620008108185855f8662002c67565b5f54610100900460ff161580801562001b1957505f54600160ff909116105b8062001b345750303b15801562001b3457505f5460ff166001145b62001bc6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b5f805460ff19166001179055801562001c05575f80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b62001c108462002a86565b62001c1a62002fd7565b62001c2462003079565b609880546001600160a01b038481167fffffffffffffffffffffffff00000000000000000000000000000000000000009283161790925560998054878416908316811790915560978054938716939092169290921790556040519081527f70edc3ecaaed82c5ab4a171ac33229a3aa307576b6418dd6551b97da670cf2ad9060200160405180910390a180156200081b575f80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050565b6001600160a01b038083165f908152609a602090815260408083208151610180810183528154861681526001820154861681850152600282015486168184015260038201546060808301919091526004830154608080840191909152600584015460a0808501919091526006850154808a1660c08087019190915260ff7401000000000000000000000000000000000000000092839004811660e08089019190915289519081018a526007890154815260088901549a81019a909a52600980890154998b0199909952600a880154958a0195909552600b87015493890193909352600c86015491880191909152600d8501548316151591870191909152610100830195909552600e83015496871661012083015294958695919492936101408601939091049091169081111562001e515762001e5162003914565b600981111562001e655762001e6562003914565b8152602001600f8201805462001e7b9062004035565b80601f016020809104026020016040519081016040528092919081815260200182805462001ea99062004035565b801562001ef85780601f1062001ece5761010080835404028352916020019162001ef8565b820191905f5260205f20905b81548152906001019060200180831162001eda57829003601f168201915b50505050508152505090508061012001516001600160a01b031663d5616cc4828560975f9054906101000a90046001600160a01b03166001600160a01b031663d79ac0186040518163ffffffff1660e01b8152600401602060405180830381865afa15801562001f6a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062001f9091906200428d565b6040518463ffffffff1660e01b815260040162001fb093929190620046fe565b602060405180830381865afa15801562001fcc573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062001ff291906200428d565b9150505b92915050565b620020066200275f565b62002010620027d4565b6001600160a01b038084165f908152609a60205260409081902060985491517f55d55d99000000000000000000000000000000000000000000000000000000008152909273953d27f8dacc0516e704d52b4b24ac76e7262432926355d55d999262002084928692169034906004016200421b565b5f6040518083038186803b1580156200209b575f80fd5b505af4158015620020ae573d5f803e3d5ffd5b50506040517f1e405fd600000000000000000000000000000000000000000000000000000000815273953d27f8dacc0516e704d52b4b24ac76e72624329250631e405fd6915062002108908490889034906004016200421b565b5f6040518083038186803b1580156200211f575f80fd5b505af415801562002132573d5f803e3d5ffd5b50506098546040517f916d11460000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201523460248201525f925073953d27f8dacc0516e704d52b4b24ac76e7262432915063916d114690604401602060405180830381865af4158015620021b2573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620021d891906200428d565b9050620021ea82828660018762002843565b5050620021f660018055565b505050565b620022056200275f565b6200220f620027d4565b6001600160a01b0384165f908152609a60205260409081902090517f1e405fd600000000000000000000000000000000000000000000000000000000815273953d27f8dacc0516e704d52b4b24ac76e726243290631e405fd6906200227d908490899089906004016200421b565b5f6040518083038186803b15801562002294575f80fd5b505af4158015620022a7573d5f803e3d5ffd5b505050508060050154841115620022e9576040517e69471e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000810818585856200311b565b6099546040517ff038621a0000000000000000000000000000000000000000000000000000000081526001600160a01b03909116600482015273756555769a04bc926dbd7f19f29928f1405c79799063f038621a906024015f6040518083038186803b15801562002366575f80fd5b505af415801562002379573d5f803e3d5ffd5b505050506001600160a01b038281165f908152609a60205260409081902090517f830de9100000000000000000000000000000000000000000000000000000000081526004810182905291831660248301529073953d27f8dacc0516e704d52b4b24ac76e72624329063830de910906044015f6040518083038186803b15801562002402575f80fd5b505af415801562002415573d5f803e3d5ffd5b50505050505050565b620024286200275f565b62002432620027d4565b6001600160a01b038084165f908152609a60205260409081902060985491517f55d55d99000000000000000000000000000000000000000000000000000000008152909273953d27f8dacc0516e704d52b4b24ac76e7262432926355d55d9992620024a6928692169034906004016200421b565b5f6040518083038186803b158015620024bd575f80fd5b505af4158015620024d0573d5f803e3d5ffd5b50506040517f1e405fd600000000000000000000000000000000000000000000000000000000815273953d27f8dacc0516e704d52b4b24ac76e72624329250631e405fd691506200252a908490889034906004016200421b565b5f6040518083038186803b15801562002541575f80fd5b505af415801562002554573d5f803e3d5ffd5b50506098546040517f916d11460000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201523460248201525f925073953d27f8dacc0516e704d52b4b24ac76e7262432915063916d114690604401602060405180830381865af4158015620025d4573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620025fa91906200428d565b9050620021ea82828660018762002c67565b620026166200275f565b62002620620027d4565b6099546040517f62cf18a50000000000000000000000000000000000000000000000000000000081526001600160a01b03909116600482015273756555769a04bc926dbd7f19f29928f1405c7979906362cf18a5906024015f6040518083038186803b1580156200268f575f80fd5b505af4158015620026a2573d5f803e3d5ffd5b505050505f5b81811015620026fc57620026e7838383818110620026ca57620026ca62004724565b9050602002016020810190620026e19190620038f6565b620033b5565b80620026f38162004751565b915050620026a8565b506200270760018055565b5050565b6200271562003665565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600260015403620027cd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162001bbd565b6002600155565b60655460ff161562000726576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640162001bbd565b84545f906200285b906001600160a01b031662000b16565b90505f818611156200287b5762002873828762004277565b90506200287f565b8591505b6200288e878387878762002c67565b600787015460048801541062002415578654620028b4906001600160a01b0316620033b5565b801562002415576099546040517f21f8a7210000000000000000000000000000000000000000000000000000000081527fc0bf3125424e542a5ef242e03ca3d5281e5b3d29c7f7fa96403ead24e9f8ea29600482015273953d27f8dacc0516e704d52b4b24ac76e72624329163ba1ce0e3918a916001600160a01b0316906321f8a72190602401602060405180830381865afa15801562002957573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200297d9190620042a5565b6099546040517f21f8a7210000000000000000000000000000000000000000000000000000000081527f547b500e425d72fd0723933cceefc203cef652b4736fd04250c3369b3e1a0a7360048201526001600160a01b03909116906321f8a72190602401602060405180830381865afa158015620029fd573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062002a239190620042a5565b85338a6040518763ffffffff1660e01b815260040162002a49969594939291906200478b565b5f6040518083038186803b15801562002a60575f80fd5b505af415801562002a73573d5f803e3d5ffd5b5050505050505050505050565b60018055565b6001600160a01b03811662002ac7576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50565b62002ad4620027d4565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258620027423390565b5f8347101562002b77576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e6365000000604482015260640162001bbd565b81515f0362002be3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f604482015260640162001bbd565b8282516020840186f590506001600160a01b03811662002c60576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f7900000000000000604482015260640162001bbd565b9392505050565b5f73953d27f8dacc0516e704d52b4b24ac76e726243263c5815be187878760975f9054906101000a90046001600160a01b03166001600160a01b031663d79ac0186040518163ffffffff1660e01b8152600401602060405180830381865afa15801562002cd6573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062002cfc91906200428d565b60975f9054906101000a90046001600160a01b03166001600160a01b031663e8fe8d996040518163ffffffff1660e01b8152600401602060405180830381865afa15801562002d4d573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062002d7391906200428d565b60975f9054906101000a90046001600160a01b03166001600160a01b031663d38dff696040518163ffffffff1660e01b81526004015f60405180830381865afa15801562002dc3573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405262002dec9190810190620047d8565b6098546040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b16815262002e3d979695949392918d916001600160a01b039091169060040162004908565b602060405180830381865af415801562002e59573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062002e7f91906200428d565b6040519091506001600160a01b0383169033907fd7616e3d0bfa66cade34a2361a559668a06ba1fd1431d81e85eb2c8d73b0e0c4905f90a38554604080518781526020810184905233926001600160a01b0316917fa0a84a835300fe8ca774e5990a2da21d9e45eba2a414f052865b5bf18573135e910160405180910390a3600786015460048701541062002fcf5785546040517f21175b4a0000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906321175b4a9062002f599060019060040162004961565b5f604051808303815f87803b15801562002f71575f80fd5b505af115801562002f84573d5f803e3d5ffd5b5050875460048901546040519081526001600160a01b0390911692507f60d1cca17f5e84a32b1480a1de65214c1b61ada3393d5a80674ff8745fe9a803915060200160405180910390a25b505050505050565b5f54610100900460ff166200306f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001bbd565b62000726620036d3565b5f54610100900460ff1662003111576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001bbd565b620007266200376b565b5f73953d27f8dacc0516e704d52b4b24ac76e726243263b59cad5586868660975f9054906101000a90046001600160a01b03166001600160a01b031663d79ac0186040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200318a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620031b091906200428d565b60975f9054906101000a90046001600160a01b03166001600160a01b031663e8fe8d996040518163ffffffff1660e01b8152600401602060405180830381865afa15801562003201573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200322791906200428d565b60975f9054906101000a90046001600160a01b03166001600160a01b031663d38dff696040518163ffffffff1660e01b81526004015f60405180830381865afa15801562003277573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052620032a09190810190620047d8565b6098546040517fffffffff0000000000000000000000000000000000000000000000000000000060e08a901b168152620032ed979695949392916001600160a01b0316906004016200497e565b602060405180830381865af415801562003309573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200332f91906200428d565b6040519091506001600160a01b0383169033907fd7616e3d0bfa66cade34a2361a559668a06ba1fd1431d81e85eb2c8d73b0e0c4905f90a38454604080518681526020810184905233926001600160a01b0316917faa664663fc826b7a728767a100136fe5fcae7392aac2ad3fb0c47cbdf587d3e6910160405180910390a35050505050565b6001600160a01b038181165f908152609a60205260409081902060995491517f21f8a7210000000000000000000000000000000000000000000000000000000081527fc0bf3125424e542a5ef242e03ca3d5281e5b3d29c7f7fa96403ead24e9f8ea296004820152909273953d27f8dacc0516e704d52b4b24ac76e72624329263635c3432928692869216906321f8a72190602401602060405180830381865afa15801562003466573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200348c9190620042a5565b6099546040517f21f8a7210000000000000000000000000000000000000000000000000000000081527f547b500e425d72fd0723933cceefc203cef652b4736fd04250c3369b3e1a0a7360048201526001600160a01b03909116906321f8a72190602401602060405180830381865afa1580156200350c573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620035329190620042a5565b60975f9054906101000a90046001600160a01b03166001600160a01b0316632dc6d23d6040518163ffffffff1660e01b81526004015f60405180830381865afa15801562003582573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052620035ab9190810190620047d8565b6099546040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b168152620035f79695949392916001600160a01b031690600401620049cd565b5f6040518083038186803b1580156200360e575f80fd5b505af415801562003621573d5f803e3d5ffd5b5050505060068101546040516001600160a01b03918216918416907f259e7e20bd2fa15a88aa3a8f7895503dc1cbf5845616623edd5a88b075deb5c4905f90a35050565b60655460ff1662000726576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015260640162001bbd565b5f54610100900460ff1662002a80576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001bbd565b5f54610100900460ff1662003803576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001bbd565b6065805460ff19169055565b6040518061018001604052805f6001600160a01b031681526020015f6001600160a01b031681526020015f6001600160a01b031681526020015f81526020015f81526020015f81526020015f6001600160a01b031681526020015f60ff168152602001620038ae6040518060e001604052805f81526020015f81526020015f81526020015f81526020015f81526020015f81526020015f151581525090565b81525f60208201819052604082015260609081015290565b6115768062004a1e83390190565b6001600160a01b038116811462002ac7575f80fd5b80356200176381620038d4565b5f6020828403121562003907575f80fd5b813562002c6081620038d4565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b600a811062003954576200395462003914565b9052565b5f5b83811015620039745781810151838201526020016200395a565b50505f910152565b5f81518084526200399581602086016020860162003958565b601f01601f19169290920160200192915050565b5f6001600160a01b03808f168352808e166020840152808d1660408401528b60608401528a60808401528960a084015280891660c084015260ff881660e084015262003a3a610100840188805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a083015260c0810151151560c08301525050565b85166101e083015262003a5261020083018562003941565b61024061022083015262003a6b6102408301846200397c565b9e9d5050505050505050505050505050565b5f6020828403121562003a8e575f80fd5b5035919050565b5f805f806080858703121562003aa9575f80fd5b843562003ab681620038d4565b93506020850135925060408501359150606085013562003ad681620038d4565b939692955090935050565b80516001600160a01b031682525f610240602083015162003b0d60208601826001600160a01b03169052565b50604083015162003b2960408601826001600160a01b03169052565b50606083015160608501526080830151608085015260a083015160a085015260c083015162003b6360c08601826001600160a01b03169052565b5060e083015162003b7960e086018260ff169052565b5061010083810151805186830152602081015161012087015260408101516101408701526060810151610160870152608081015161018087015260a08101516101a087015260c081015115156101c087015250506101208301516001600160a01b0381166101e08601525061014083015162003bfa61020086018262003941565b506101608301518161022086015262000e31828601826200397c565b602081525f62002c60602083018462003ae1565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b604051610160810167ffffffffffffffff8111828210171562003c7e5762003c7e62003c2a565b60405290565b60405160e0810167ffffffffffffffff8111828210171562003c7e5762003c7e62003c2a565b6040805190810167ffffffffffffffff8111828210171562003c7e5762003c7e62003c2a565b604051601f8201601f1916810167ffffffffffffffff8111828210171562003cfc5762003cfc62003c2a565b604052919050565b5f82601f83011262003d14575f80fd5b813567ffffffffffffffff81111562003d315762003d3162003c2a565b62003d466020601f19601f8401160162003cd0565b81815284602083860101111562003d5b575f80fd5b816020850160208301375f918101602001919091529392505050565b803560ff8116811462001763575f80fd5b8035600a811062001763575f80fd5b5f6020828403121562003da8575f80fd5b813567ffffffffffffffff8082111562003dc0575f80fd5b90830190610160828603121562003dd5575f80fd5b62003ddf62003c57565b82358281111562003dee575f80fd5b62003dfc8782860162003d04565b82525060208301358281111562003e11575f80fd5b62003e1f8782860162003d04565b60208301525062003e3360408401620038e9565b6040820152606083013560608201526080830135608082015260a083013560a082015262003e6460c0840162003d77565b60c082015260e083013560e082015261010062003e8381850162003d88565b90820152610120838101358381111562003e9b575f80fd5b62003ea98882870162003d04565b828401525050610140915062003ec1828401620038e9565b91810191909152949350505050565b5f806040838503121562003ee2575f80fd5b823562003eef81620038d4565b946020939093013593505050565b5f805f6060848603121562003f10575f80fd5b833562003f1d81620038d4565b9250602084013562003f2f81620038d4565b9150604084013562003f4181620038d4565b809150509250925092565b5f805f6060848603121562003f5f575f80fd5b833562003f6c81620038d4565b925060208401359150604084013562003f4181620038d4565b5f806040838503121562003f97575f80fd5b823562003fa481620038d4565b9150602083013562003fb681620038d4565b809150509250929050565b5f806020838503121562003fd3575f80fd5b823567ffffffffffffffff8082111562003feb575f80fd5b818501915085601f83011262003fff575f80fd5b8135818111156200400e575f80fd5b8660208260051b850101111562004023575f80fd5b60209290920196919550909350505050565b600181811c908216806200404a57607f821691505b60208210810362004082577f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b50919050565b5f8154620040968162004035565b808552602060018381168015620040b65760018114620040d157620040fe565b60ff198516838901528284151560051b8901019550620040fe565b865f52825f205f5b85811015620040f65781548a8201860152908301908401620040d9565b890184019650505b505050505092915050565b5f61024062004131846200412485546001600160a01b031690565b6001600160a01b03169052565b60018301546001600160a01b0390811660208601526002840154811660408601526003840154606086015260048401546080860152600584015460a080870191909152600685015480831660c088015260ff90821c811660e0880152600786015461010088015260088601546101208801526009860154610140880152600a860154610160880152600b860154610180880152600c8601546101a0880152600d860154811615156101c0880152600e8601549283166101e088015262004202916102008801919084901c1662003941565b508061022085015262001ff2818501600f850162004088565b606081525f6200422f606083018662004109565b6001600160a01b039490941660208301525060400152919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b8181038181111562001ff65762001ff66200424a565b5f602082840312156200429e575f80fd5b5051919050565b5f60208284031215620042b6575f80fd5b815162002c6081620038d4565b5f60e08284031215620042d4575f80fd5b620042de62003c84565b825181526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c0830151801515811462004327575f80fd5b60c08201529392505050565b5f61014080835286516101608083860152620043546102a08601836200397c565b915060208901517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec08087850301838801526200439184836200397c565b935060408b01519250620043b16101808801846001600160a01b03169052565b60608b01516101a088015260808b01516101c088015260a08b01516101e088015260c08b015160ff1661020088015260e08b01516102208801526101008b015192506200440361024088018462003941565b6101209250828b015191508087850301610260880152506200442683826200397c565b938a01516001600160a01b038116610280880152939250620044459050565b8193506200445e60208601896001600160a01b03169052565b620044ad6040860188805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a083015260c0810151151560c08301525050565b858186015250505095945050505050565b604081525f620044d260408301856200397c565b828103602084015262000e3181856200397c565b5f8351620044f981846020880162003958565b8351908301906200450f81836020880162003958565b01949350505050565b601f821115620021f6575f81815260208120601f850160051c81016020861015620045405750805b601f850160051c820191505b8181101562002fcf578281556001016200454c565b815167ffffffffffffffff8111156200457e576200457e62003c2a565b62004596816200458f845462004035565b8462004518565b602080601f831160018114620045eb575f8415620045b45750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b17855562002fcf565b5f85815260208120601f198616915b828110156200461b57888601518255948401946001909101908401620045fa565b50858210156200465857878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b5f61014060ff8d1683528b60208401528a60408401528960608401528860808401528760a08401528660c08401526001600160a01b03861660e0840152620046b561010084018662003941565b80610120840152620046ca8184018562004088565b9d9c50505050505050505050505050565b604081525f620046ef604083018562003ae1565b90508260208301529392505050565b606081525f62004712606083018662003ae1565b60208301949094525060400152919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036200478457620047846200424a565b5060010190565b60c081525f6200479f60c083018962004109565b6001600160a01b03978816602084015295871660408301525060608101939093529316608082015291151560a090920191909152919050565b5f6020808385031215620047ea575f80fd5b825167ffffffffffffffff8082111562004802575f80fd5b818501915085601f83011262004816575f80fd5b8151818111156200482b576200482b62003c2a565b6200483b848260051b0162003cd0565b818152848101925060069190911b8301840190878211156200485b575f80fd5b928401925b81841015620048ae57604084890312156200487a575f8081fd5b6200488462003caa565b84518152858501516200489781620038d4565b818701528352604093909301929184019162004860565b979650505050505050565b5f8151808452602080850194508084015f5b83811015620048fd578151805188528301516001600160a01b03168388015260409096019590820190600101620048cb565b509495945050505050565b5f6101008a83528960208401528860408401528760608401528660808401528060a08401526200493b81840187620048b9565b94151560c084015250506001600160a01b039190911660e0909101529695505050505050565b602081016003831062004978576200497862003914565b91905290565b87815286602082015285604082015284606082015283608082015260e060a08201525f620049b060e0830185620048b9565b90506001600160a01b03831660c083015298975050505050505050565b5f6001600160a01b0380891683528760208401528087166040840152808616606084015260c0608084015262004a0760c0840186620048b9565b915080841660a08401525097965050505050505056fe608060405234801562000010575f80fd5b506040516200157638038062001576833981016040819052620000339162000386565b8181600362000043838262000477565b50600462000052828262000477565b5050506200006f62000069620000e660201b60201c565b620000ea565b81515f0362000091576040516316c31e7760e21b815260040160405180910390fd5b80515f03620000b35760405163220839c960e01b815260040160405180910390fd5b6005805460ff60a01b1916600160a11b179055620000de336b033b2e3c9fd0803ce80000006200013b565b505062000579565b3390565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6001600160a01b038216620001965760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b620001a35f83836200020c565b8060025f828254620001b6919062000553565b90915550506001600160a01b0382165f81815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6001600554600160a01b900460ff1660028111156200022f576200022f6200053f565b036200024e576040516380cbe9f360e01b815260040160405180910390fd5b6002600554600160a01b900460ff1660028111156200027157620002716200053f565b03620002c3576005546001600160a01b03848116911614801590620002a457506005546001600160a01b03838116911614155b15620002c35760405163063f3e4d60e01b815260040160405180910390fd5b505050565b634e487b7160e01b5f52604160045260245ffd5b5f82601f830112620002ec575f80fd5b81516001600160401b0380821115620003095762000309620002c8565b604051601f8301601f19908116603f01168101908282118183101715620003345762000334620002c8565b8160405283815260209250868385880101111562000350575f80fd5b5f91505b8382101562000373578582018301518183018401529082019062000354565b5f93810190920192909252949350505050565b5f806040838503121562000398575f80fd5b82516001600160401b0380821115620003af575f80fd5b620003bd86838701620002dc565b93506020850151915080821115620003d3575f80fd5b50620003e285828601620002dc565b9150509250929050565b600181811c908216806200040157607f821691505b6020821081036200042057634e487b7160e01b5f52602260045260245ffd5b50919050565b601f821115620002c3575f81815260208120601f850160051c810160208610156200044e5750805b601f850160051c820191505b818110156200046f578281556001016200045a565b505050505050565b81516001600160401b03811115620004935762000493620002c8565b620004ab81620004a48454620003ec565b8462000426565b602080601f831160018114620004e1575f8415620004c95750858301515b5f19600386901b1c1916600185901b1785556200046f565b5f85815260208120601f198616915b828110156200051157888601518255948401946001909101908401620004f0565b50858210156200052f57878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b5f52602160045260245ffd5b808201808211156200057357634e487b7160e01b5f52601160045260245ffd5b92915050565b610fef80620005875f395ff3fe608060405234801561000f575f80fd5b5060043610610115575f3560e01c806370a08231116100ad57806395d89b411161007d578063a9059cbb11610063578063a9059cbb1461027b578063dd62ed3e1461028e578063f2fde38b146102d3575f80fd5b806395d89b4114610260578063a457c2d714610268575f80fd5b806370a08231146101e8578063715018a61461021d5780638da5cb5b14610225578063902d55a51461024d575f80fd5b806323b872dd116100e857806323b872dd14610181578063295a521214610194578063313ce567146101c657806339509351146101d5575f80fd5b806306fdde0314610119578063095ea7b31461013757806318160ddd1461015a57806321175b4a1461016c575b5f80fd5b6101216102e6565b60405161012e9190610d63565b60405180910390f35b61014a610145366004610df4565b610376565b604051901515815260200161012e565b6002545b60405190815260200161012e565b61017f61017a366004610e1c565b61038f565b005b61014a61018f366004610e41565b610426565b6005546101b99074010000000000000000000000000000000000000000900460ff1681565b60405161012e9190610ea7565b6040516012815260200161012e565b61014a6101e3366004610df4565b610449565b61015e6101f6366004610ee6565b73ffffffffffffffffffffffffffffffffffffffff165f9081526020819052604090205490565b61017f610494565b60055460405173ffffffffffffffffffffffffffffffffffffffff909116815260200161012e565b61015e6b033b2e3c9fd0803ce800000081565b6101216104a7565b61014a610276366004610df4565b6104b6565b61014a610289366004610df4565b61058b565b61015e61029c366004610eff565b73ffffffffffffffffffffffffffffffffffffffff9182165f90815260016020908152604080832093909416825291909152205490565b61017f6102e1366004610ee6565b610598565b6060600380546102f590610f30565b80601f016020809104026020016040519081016040528092919081815260200182805461032190610f30565b801561036c5780601f106103435761010080835404028352916020019161036c565b820191905f5260205f20905b81548152906001019060200180831161034f57829003601f168201915b5050505050905090565b5f3361038381858561064c565b60019150505b92915050565b6103976107fe565b5f60055474010000000000000000000000000000000000000000900460ff1660028111156103c7576103c7610e7a565b1461042357600580548291907fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000083600281111561041d5761041d610e7a565b02179055505b50565b5f3361043385828561087f565b61043e858585610955565b506001949350505050565b335f81815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152812054909190610383908290869061048f908790610f81565b61064c565b61049c6107fe565b6104a55f610bcd565b565b6060600480546102f590610f30565b335f81815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091908381101561057e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61043e828686840361064c565b5f33610383818585610955565b6105a06107fe565b73ffffffffffffffffffffffffffffffffffffffff8116610643576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610575565b61042381610bcd565b73ffffffffffffffffffffffffffffffffffffffff83166106ee576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610575565b73ffffffffffffffffffffffffffffffffffffffff8216610791576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610575565b73ffffffffffffffffffffffffffffffffffffffff8381165f8181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60055473ffffffffffffffffffffffffffffffffffffffff1633146104a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610575565b73ffffffffffffffffffffffffffffffffffffffff8381165f908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461094f5781811015610942576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610575565b61094f848484840361064c565b50505050565b73ffffffffffffffffffffffffffffffffffffffff83166109f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610575565b73ffffffffffffffffffffffffffffffffffffffff8216610a9b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610575565b610aa6838383610c43565b73ffffffffffffffffffffffffffffffffffffffff83165f9081526020819052604090205481811015610b5b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610575565b73ffffffffffffffffffffffffffffffffffffffff8481165f81815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a361094f565b6005805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b600160055474010000000000000000000000000000000000000000900460ff166002811115610c7457610c74610e7a565b03610cab576040517f80cbe9f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600260055474010000000000000000000000000000000000000000900460ff166002811115610cdc57610cdc610e7a565b03610d5e5760055473ffffffffffffffffffffffffffffffffffffffff848116911614801590610d27575060055473ffffffffffffffffffffffffffffffffffffffff838116911614155b15610d5e576040517f063f3e4d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050565b5f6020808352835180828501525f5b81811015610d8e57858101830151858201604001528201610d72565b505f6040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610def575f80fd5b919050565b5f8060408385031215610e05575f80fd5b610e0e83610dcc565b946020939093013593505050565b5f60208284031215610e2c575f80fd5b813560038110610e3a575f80fd5b9392505050565b5f805f60608486031215610e53575f80fd5b610e5c84610dcc565b9250610e6a60208501610dcc565b9150604084013590509250925092565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b6020810160038310610ee0577f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b91905290565b5f60208284031215610ef6575f80fd5b610e3a82610dcc565b5f8060408385031215610f10575f80fd5b610f1983610dcc565b9150610f2760208401610dcc565b90509250929050565b600181811c90821680610f4457607f821691505b602082108103610f7b577f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b50919050565b80820180821115610389577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffdfea264697066735822122027843b07869e97aee88cf3baa00714638d89117127d258dd5136b3cc3974d35564736f6c63430008150033a2646970667358221220dd9bda768a9609424460271a6ba3ffbd7b114aa3b1daf276e55c291b8b9ee4f464736f6c63430008150033

Block Transaction Gas Used Reward
view all blocks ##produced##

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

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.