ETH Price: $2,498.94 (-0.69%)

Contract

0xB207b52fe740d8981A78f1714c7089B662AA6c1f
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Deploy Q Contrac...199616002024-05-27 13:47:4798 days ago1716817667IN
0xB207b52f...662AA6c1f
0 ETH0.00310849121
Deploy Q Contrac...199616002024-05-27 13:47:4798 days ago1716817667IN
0xB207b52f...662AA6c1f
0 ETH0.00410477159.78085447
Deploy Q Contrac...199615992024-05-27 13:47:3598 days ago1716817655IN
0xB207b52f...662AA6c1f
0 ETH0.00310849121
Deploy Q Contrac...199615972024-05-27 13:47:1198 days ago1716817631IN
0xB207b52f...662AA6c1f
0 ETH0.00411503160.18057788
Deploy Q Contrac...199615952024-05-27 13:46:4798 days ago1716817607IN
0xB207b52f...662AA6c1f
0 ETH0.000513820
Deploy Q Contrac...199615952024-05-27 13:46:4798 days ago1716817607IN
0xB207b52f...662AA6c1f
0 ETH0.0005156120.07051153
Deploy Q Contrac...199615952024-05-27 13:46:4798 days ago1716817607IN
0xB207b52f...662AA6c1f
0 ETH0.000541321.07051153
Deploy Q Contrac...199615952024-05-27 13:46:4798 days ago1716817607IN
0xB207b52f...662AA6c1f
0 ETH0.0006499525.3
Deploy Q Contrac...199615942024-05-27 13:46:3598 days ago1716817595IN
0xB207b52f...662AA6c1f
0 ETH0.0006499525.3
Deploy Q Contrac...199615942024-05-27 13:46:3598 days ago1716817595IN
0xB207b52f...662AA6c1f
0 ETH0.0013358852
Deploy Q Contrac...199615942024-05-27 13:46:3598 days ago1716817595IN
0xB207b52f...662AA6c1f
0 ETH0.0013615753
Deploy Q Contrac...199615942024-05-27 13:46:3598 days ago1716817595IN
0xB207b52f...662AA6c1f
0 ETH0.00310849121
Deploy Q Contrac...199615942024-05-27 13:46:3598 days ago1716817595IN
0xB207b52f...662AA6c1f
0 ETH0.00412902160.72496679
Deploy Q Contrac...199615892024-05-27 13:45:3598 days ago1716817535IN
0xB207b52f...662AA6c1f
0 ETH0.0004237318
Deploy Q Contrac...199614972024-05-27 13:26:5998 days ago1716816419IN
0xB207b52f...662AA6c1f
0 ETH0.0004505919.14081559
Deploy Q Contrac...199614972024-05-27 13:26:5998 days ago1716816419IN
0xB207b52f...662AA6c1f
0 ETH0.0004505919.14081559
Deploy Q Contrac...199606342024-05-27 10:32:4798 days ago1716805967IN
0xB207b52f...662AA6c1f
0 ETH0.0003060313
Deploy Q Contrac...199460852024-05-25 9:45:47100 days ago1716630347IN
0xB207b52f...662AA6c1f
0 ETH0.000088573.76258899
Ai Register199453962024-05-25 7:27:47101 days ago1716622067IN
0xB207b52f...662AA6c1f
5 ETH0.000328864.0737316
Ai Register199411852024-05-24 17:18:59101 days ago1716571139IN
0xB207b52f...662AA6c1f
5 ETH0.0008268310.24066227
Ai Register199409422024-05-24 16:30:11101 days ago1716568211IN
0xB207b52f...662AA6c1f
5 ETH0.0008782410.87906356
Ai Register199403502024-05-24 14:30:47101 days ago1716561047IN
0xB207b52f...662AA6c1f
5 ETH0.000926079.46051208
0x60e06040199401302024-05-24 13:46:23101 days ago1716558383IN
 Create: QPayment
0 ETH0.053302949.70122446

Latest 2 internal transactions

Advanced mode:
Parent Transaction Hash Block From To
199615942024-05-27 13:46:3598 days ago1716817595
0xB207b52f...662AA6c1f
2 ETH
199615942024-05-27 13:46:3598 days ago1716817595
0xB207b52f...662AA6c1f
 Contract Creation18 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
QPayment

Compiler Version
v0.8.25+commit.b61c2a91

Optimization Enabled:
Yes with 1 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2024-05-24
*/

// File: contracts/interfaces/ISwapRouterMinimal.sol


pragma solidity ^0.8.23;

interface ISwapRouterMinimal {
    struct ExactOutputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
        uint160 sqrtPriceLimitX96;
    }

    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }

    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
    
    function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountOut);
}
// File: contracts/interfaces/IWETH9Minimal.sol


pragma solidity ^0.8.23;

interface IWETH9Minimal {
    function approve(address guy, uint256 wad) external returns(bool);

    function deposit() external payable;
}
// File: @uniswap/v3-periphery/contracts/libraries/PoolAddress.sol


pragma solidity >=0.5.0;

/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee
library PoolAddress {
    bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;

    /// @notice The identifying key of the pool
    struct PoolKey {
        address token0;
        address token1;
        uint24 fee;
    }

    /// @notice Returns PoolKey: the ordered tokens with the matched fee levels
    /// @param tokenA The first token of a pool, unsorted
    /// @param tokenB The second token of a pool, unsorted
    /// @param fee The fee level of the pool
    /// @return Poolkey The pool details with ordered token0 and token1 assignments
    function getPoolKey(
        address tokenA,
        address tokenB,
        uint24 fee
    ) internal pure returns (PoolKey memory) {
        if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);
        return PoolKey({token0: tokenA, token1: tokenB, fee: fee});
    }

    /// @notice Deterministically computes the pool address given the factory and PoolKey
    /// @param factory The Uniswap V3 factory contract address
    /// @param key The PoolKey
    /// @return pool The contract address of the V3 pool
    function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {
        require(key.token0 < key.token1);
        pool = address(
            uint160(
                uint256(
                    keccak256(
                        abi.encodePacked(
                            hex'ff',
                            factory,
                            keccak256(abi.encode(key.token0, key.token1, key.fee)),
                            POOL_INIT_CODE_HASH
                        )
                    )
                )
            )
        );
    }
}

// File: @uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolEvents.sol


pragma solidity >=0.5.0;

/// @title Events emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolEvents {
    /// @notice Emitted exactly once by a pool when #initialize is first called on the pool
    /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
    /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
    /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
    event Initialize(uint160 sqrtPriceX96, int24 tick);

    /// @notice Emitted when liquidity is minted for a given position
    /// @param sender The address that minted the liquidity
    /// @param owner The owner of the position and recipient of any minted liquidity
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount The amount of liquidity minted to the position range
    /// @param amount0 How much token0 was required for the minted liquidity
    /// @param amount1 How much token1 was required for the minted liquidity
    event Mint(
        address sender,
        address indexed owner,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount,
        uint256 amount0,
        uint256 amount1
    );

    /// @notice Emitted when fees are collected by the owner of a position
    /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
    /// @param owner The owner of the position for which fees are collected
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount0 The amount of token0 fees collected
    /// @param amount1 The amount of token1 fees collected
    event Collect(
        address indexed owner,
        address recipient,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount0,
        uint128 amount1
    );

    /// @notice Emitted when a position's liquidity is removed
    /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
    /// @param owner The owner of the position for which liquidity is removed
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount The amount of liquidity to remove
    /// @param amount0 The amount of token0 withdrawn
    /// @param amount1 The amount of token1 withdrawn
    event Burn(
        address indexed owner,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount,
        uint256 amount0,
        uint256 amount1
    );

    /// @notice Emitted by the pool for any swaps between token0 and token1
    /// @param sender The address that initiated the swap call, and that received the callback
    /// @param recipient The address that received the output of the swap
    /// @param amount0 The delta of the token0 balance of the pool
    /// @param amount1 The delta of the token1 balance of the pool
    /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
    /// @param liquidity The liquidity of the pool after the swap
    /// @param tick The log base 1.0001 of price of the pool after the swap
    event Swap(
        address indexed sender,
        address indexed recipient,
        int256 amount0,
        int256 amount1,
        uint160 sqrtPriceX96,
        uint128 liquidity,
        int24 tick
    );

    /// @notice Emitted by the pool for any flashes of token0/token1
    /// @param sender The address that initiated the swap call, and that received the callback
    /// @param recipient The address that received the tokens from flash
    /// @param amount0 The amount of token0 that was flashed
    /// @param amount1 The amount of token1 that was flashed
    /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
    /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
    event Flash(
        address indexed sender,
        address indexed recipient,
        uint256 amount0,
        uint256 amount1,
        uint256 paid0,
        uint256 paid1
    );

    /// @notice Emitted by the pool for increases to the number of observations that can be stored
    /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index
    /// just before a mint/swap/burn.
    /// @param observationCardinalityNextOld The previous value of the next observation cardinality
    /// @param observationCardinalityNextNew The updated value of the next observation cardinality
    event IncreaseObservationCardinalityNext(
        uint16 observationCardinalityNextOld,
        uint16 observationCardinalityNextNew
    );

    /// @notice Emitted when the protocol fee is changed by the pool
    /// @param feeProtocol0Old The previous value of the token0 protocol fee
    /// @param feeProtocol1Old The previous value of the token1 protocol fee
    /// @param feeProtocol0New The updated value of the token0 protocol fee
    /// @param feeProtocol1New The updated value of the token1 protocol fee
    event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);

    /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner
    /// @param sender The address that collects the protocol fees
    /// @param recipient The address that receives the collected protocol fees
    /// @param amount0 The amount of token0 protocol fees that is withdrawn
    /// @param amount0 The amount of token1 protocol fees that is withdrawn
    event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
}

// File: @uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolErrors.sol


pragma solidity >=0.5.0;

/// @title Errors emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolErrors {
    error LOK();
    error TLU();
    error TLM();
    error TUM();
    error AI();
    error M0();
    error M1();
    error AS();
    error IIA();
    error L();
    error F0();
    error F1();
}

// File: @uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolOwnerActions.sol


pragma solidity >=0.5.0;

/// @title Permissioned pool actions
/// @notice Contains pool methods that may only be called by the factory owner
interface IUniswapV3PoolOwnerActions {
    /// @notice Set the denominator of the protocol's % share of the fees
    /// @param feeProtocol0 new protocol fee for token0 of the pool
    /// @param feeProtocol1 new protocol fee for token1 of the pool
    function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;

    /// @notice Collect the protocol fee accrued to the pool
    /// @param recipient The address to which collected protocol fees should be sent
    /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1
    /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0
    /// @return amount0 The protocol fee collected in token0
    /// @return amount1 The protocol fee collected in token1
    function collectProtocol(
        address recipient,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);
}

// File: @uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolActions.sol


pragma solidity >=0.5.0;

/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IUniswapV3PoolActions {
    /// @notice Sets the initial price for the pool
    /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
    /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
    function initialize(uint160 sqrtPriceX96) external;

    /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
    /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
    /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
    /// on tickLower, tickUpper, the amount of liquidity, and the current price.
    /// @param recipient The address for which the liquidity will be created
    /// @param tickLower The lower tick of the position in which to add liquidity
    /// @param tickUpper The upper tick of the position in which to add liquidity
    /// @param amount The amount of liquidity to mint
    /// @param data Any data that should be passed through to the callback
    /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
    /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
    function mint(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount,
        bytes calldata data
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Collects tokens owed to a position
    /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
    /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
    /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
    /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
    /// @param recipient The address which should receive the fees collected
    /// @param tickLower The lower tick of the position for which to collect fees
    /// @param tickUpper The upper tick of the position for which to collect fees
    /// @param amount0Requested How much token0 should be withdrawn from the fees owed
    /// @param amount1Requested How much token1 should be withdrawn from the fees owed
    /// @return amount0 The amount of fees collected in token0
    /// @return amount1 The amount of fees collected in token1
    function collect(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);

    /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
    /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
    /// @dev Fees must be collected separately via a call to #collect
    /// @param tickLower The lower tick of the position for which to burn liquidity
    /// @param tickUpper The upper tick of the position for which to burn liquidity
    /// @param amount How much liquidity to burn
    /// @return amount0 The amount of token0 sent to the recipient
    /// @return amount1 The amount of token1 sent to the recipient
    function burn(
        int24 tickLower,
        int24 tickUpper,
        uint128 amount
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Swap token0 for token1, or token1 for token0
    /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
    /// @param recipient The address to receive the output of the swap
    /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
    /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
    /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
    /// value after the swap. If one for zero, the price cannot be greater than this value after the swap
    /// @param data Any data to be passed through to the callback
    /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
    /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
    function swap(
        address recipient,
        bool zeroForOne,
        int256 amountSpecified,
        uint160 sqrtPriceLimitX96,
        bytes calldata data
    ) external returns (int256 amount0, int256 amount1);

    /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
    /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
    /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
    /// with 0 amount{0,1} and sending the donation amount(s) from the callback
    /// @param recipient The address which will receive the token0 and token1 amounts
    /// @param amount0 The amount of token0 to send
    /// @param amount1 The amount of token1 to send
    /// @param data Any data to be passed through to the callback
    function flash(
        address recipient,
        uint256 amount0,
        uint256 amount1,
        bytes calldata data
    ) external;

    /// @notice Increase the maximum number of price and liquidity observations that this pool will store
    /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
    /// the input observationCardinalityNext.
    /// @param observationCardinalityNext The desired minimum number of observations for the pool to store
    function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}

// File: @uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolDerivedState.sol


pragma solidity >=0.5.0;

/// @title Pool state that is not stored
/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the
/// blockchain. The functions here may have variable gas costs.
interface IUniswapV3PoolDerivedState {
    /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
    /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
    /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
    /// you must call it with secondsAgos = [3600, 0].
    /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
    /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
    /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
    /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
    /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
    /// timestamp
    function observe(uint32[] calldata secondsAgos)
        external
        view
        returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);

    /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range
    /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.
    /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first
    /// snapshot is taken and the second snapshot is taken.
    /// @param tickLower The lower tick of the range
    /// @param tickUpper The upper tick of the range
    /// @return tickCumulativeInside The snapshot of the tick accumulator for the range
    /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range
    /// @return secondsInside The snapshot of seconds per liquidity for the range
    function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
        external
        view
        returns (
            int56 tickCumulativeInside,
            uint160 secondsPerLiquidityInsideX128,
            uint32 secondsInside
        );
}

// File: @uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolState.sol


pragma solidity >=0.5.0;

/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
    /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
    /// when accessed externally.
    /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
    /// @return tick The current tick of the pool, i.e. according to the last tick transition that was run.
    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
    /// boundary.
    /// @return observationIndex The index of the last oracle observation that was written,
    /// @return observationCardinality The current maximum number of observations stored in the pool,
    /// @return observationCardinalityNext The next maximum number of observations, to be updated when the observation.
    /// @return feeProtocol The protocol fee for both tokens of the pool.
    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
    /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
    /// unlocked Whether the pool is currently locked to reentrancy
    function slot0()
        external
        view
        returns (
            uint160 sqrtPriceX96,
            int24 tick,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext,
            uint8 feeProtocol,
            bool unlocked
        );

    /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal0X128() external view returns (uint256);

    /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal1X128() external view returns (uint256);

    /// @notice The amounts of token0 and token1 that are owed to the protocol
    /// @dev Protocol fees will never exceed uint128 max in either token
    function protocolFees() external view returns (uint128 token0, uint128 token1);

    /// @notice The currently in range liquidity available to the pool
    /// @dev This value has no relationship to the total liquidity across all ticks
    /// @return The liquidity at the current price of the pool
    function liquidity() external view returns (uint128);

    /// @notice Look up information about a specific tick in the pool
    /// @param tick The tick to look up
    /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
    /// tick upper
    /// @return liquidityNet how much liquidity changes when the pool price crosses the tick,
    /// @return feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
    /// @return feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
    /// @return tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
    /// @return secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
    /// @return secondsOutside the seconds spent on the other side of the tick from the current tick,
    /// @return initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
    /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
    /// In addition, these values are only relative and must be used only in comparison to previous snapshots for
    /// a specific position.
    function ticks(int24 tick)
        external
        view
        returns (
            uint128 liquidityGross,
            int128 liquidityNet,
            uint256 feeGrowthOutside0X128,
            uint256 feeGrowthOutside1X128,
            int56 tickCumulativeOutside,
            uint160 secondsPerLiquidityOutsideX128,
            uint32 secondsOutside,
            bool initialized
        );

    /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
    function tickBitmap(int16 wordPosition) external view returns (uint256);

    /// @notice Returns the information about a position by the position's key
    /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
    /// @return liquidity The amount of liquidity in the position,
    /// @return feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
    /// @return feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
    /// @return tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
    /// @return tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
    function positions(bytes32 key)
        external
        view
        returns (
            uint128 liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

    /// @notice Returns data about a specific observation index
    /// @param index The element of the observations array to fetch
    /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
    /// ago, rather than at a specific index in the array.
    /// @return blockTimestamp The timestamp of the observation,
    /// @return tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
    /// @return secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
    /// @return initialized whether the observation has been initialized and the values are safe to use
    function observations(uint256 index)
        external
        view
        returns (
            uint32 blockTimestamp,
            int56 tickCumulative,
            uint160 secondsPerLiquidityCumulativeX128,
            bool initialized
        );
}

// File: @uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolImmutables.sol


pragma solidity >=0.5.0;

/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
    /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
    /// @return The contract address
    function factory() external view returns (address);

    /// @notice The first of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token0() external view returns (address);

    /// @notice The second of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token1() external view returns (address);

    /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
    /// @return The fee
    function fee() external view returns (uint24);

    /// @notice The pool tick spacing
    /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
    /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
    /// This value is an int24 to avoid casting even though it is always positive.
    /// @return The tick spacing
    function tickSpacing() external view returns (int24);

    /// @notice The maximum amount of position liquidity that can use any tick in the range
    /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
    /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
    /// @return The max amount of liquidity per tick
    function maxLiquidityPerTick() external view returns (uint128);
}

// File: @uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol


pragma solidity >=0.5.0;








/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is
    IUniswapV3PoolImmutables,
    IUniswapV3PoolState,
    IUniswapV3PoolDerivedState,
    IUniswapV3PoolActions,
    IUniswapV3PoolOwnerActions,
    IUniswapV3PoolErrors,
    IUniswapV3PoolEvents
{

}

// File: @uniswap/v3-core/contracts/libraries/TickMath.sol


pragma solidity ^0.8.0;

/// @title Math library for computing sqrt prices from ticks and vice versa
/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
/// prices between 2**-128 and 2**128
library TickMath {
    error T();
    error R();

    /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
    int24 internal constant MIN_TICK = -887272;
    /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
    int24 internal constant MAX_TICK = -MIN_TICK;

    /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)
    uint160 internal constant MIN_SQRT_RATIO = 4295128739;
    /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)
    uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;

    /// @notice Calculates sqrt(1.0001^tick) * 2^96
    /// @dev Throws if |tick| > max tick
    /// @param tick The input tick for the above formula
    /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
    /// at the given tick
    function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
        unchecked {
            uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
            if (absTick > uint256(int256(MAX_TICK))) revert T();

            uint256 ratio = absTick & 0x1 != 0
                ? 0xfffcb933bd6fad37aa2d162d1a594001
                : 0x100000000000000000000000000000000;
            if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
            if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
            if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
            if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
            if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
            if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
            if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
            if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
            if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
            if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
            if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
            if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
            if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
            if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
            if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
            if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
            if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
            if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
            if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;

            if (tick > 0) ratio = type(uint256).max / ratio;

            // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
            // we then downcast because we know the result always fits within 160 bits due to our tick input constraint
            // we round up in the division so getTickAtSqrtRatio of the output price is always consistent
            sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
        }
    }

    /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio
    /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may
    /// ever return.
    /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96
    /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio
    function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {
        unchecked {
            // second inequality must be < because the price can never reach the price at the max tick
            if (!(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO)) revert R();
            uint256 ratio = uint256(sqrtPriceX96) << 32;

            uint256 r = ratio;
            uint256 msb = 0;

            assembly {
                let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
                msb := or(msb, f)
                r := shr(f, r)
            }
            assembly {
                let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))
                msb := or(msb, f)
                r := shr(f, r)
            }
            assembly {
                let f := shl(5, gt(r, 0xFFFFFFFF))
                msb := or(msb, f)
                r := shr(f, r)
            }
            assembly {
                let f := shl(4, gt(r, 0xFFFF))
                msb := or(msb, f)
                r := shr(f, r)
            }
            assembly {
                let f := shl(3, gt(r, 0xFF))
                msb := or(msb, f)
                r := shr(f, r)
            }
            assembly {
                let f := shl(2, gt(r, 0xF))
                msb := or(msb, f)
                r := shr(f, r)
            }
            assembly {
                let f := shl(1, gt(r, 0x3))
                msb := or(msb, f)
                r := shr(f, r)
            }
            assembly {
                let f := gt(r, 0x1)
                msb := or(msb, f)
            }

            if (msb >= 128) r = ratio >> (msb - 127);
            else r = ratio << (127 - msb);

            int256 log_2 = (int256(msb) - 128) << 64;

            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(63, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(62, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(61, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(60, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(59, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(58, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(57, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(56, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(55, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(54, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(53, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(52, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(51, f))
                r := shr(f, r)
            }
            assembly {
                r := shr(127, mul(r, r))
                let f := shr(128, r)
                log_2 := or(log_2, shl(50, f))
            }

            int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number

            int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);
            int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);

            tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;
        }
    }
}

// File: @uniswap/v3-core/contracts/libraries/FullMath.sol


pragma solidity ^0.8.0;

/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
    /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
    function mulDiv(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = a * b
            // Compute the product mod 2**256 and mod 2**256 - 1
            // then use the Chinese Remainder Theorem to reconstruct
            // the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2**256 + prod0
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(a, b, not(0))
                prod0 := mul(a, b)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division
            if (prod1 == 0) {
                require(denominator > 0);
                assembly {
                    result := div(prod0, denominator)
                }
                return result;
            }

            // Make sure the result is less than 2**256.
            // Also prevents denominator == 0
            require(denominator > prod1);

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

            // Make division exact by subtracting the remainder from [prod1 prod0]
            // Compute remainder using mulmod
            uint256 remainder;
            assembly {
                remainder := mulmod(a, b, denominator)
            }
            // Subtract 256 bit number from 512 bit number
            assembly {
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator
            // Compute largest power of two divisor of denominator.
            // Always >= 1.
            uint256 twos = (0 - denominator) & denominator;
            // Divide denominator by power of two
            assembly {
                denominator := div(denominator, twos)
            }

            // Divide [prod1 prod0] by the factors of two
            assembly {
                prod0 := div(prod0, twos)
            }
            // Shift in bits from prod1 into prod0. For this we need
            // to flip `twos` such that it is 2**256 / twos.
            // If twos is zero, then it becomes one
            assembly {
                twos := add(div(sub(0, twos), twos), 1)
            }
            prod0 |= prod1 * twos;

            // Invert denominator mod 2**256
            // Now that denominator is an odd number, it has an inverse
            // modulo 2**256 such that denominator * inv = 1 mod 2**256.
            // Compute the inverse by starting with a seed that is correct
            // correct for four bits. That is, denominator * inv = 1 mod 2**4
            uint256 inv = (3 * denominator) ^ 2;
            // Now use Newton-Raphson iteration to improve the precision.
            // Thanks to Hensel's lifting lemma, this also works in modular
            // arithmetic, doubling the correct bits in each step.
            inv *= 2 - denominator * inv; // inverse mod 2**8
            inv *= 2 - denominator * inv; // inverse mod 2**16
            inv *= 2 - denominator * inv; // inverse mod 2**32
            inv *= 2 - denominator * inv; // inverse mod 2**64
            inv *= 2 - denominator * inv; // inverse mod 2**128
            inv *= 2 - denominator * inv; // inverse mod 2**256

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

    /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    function mulDivRoundingUp(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            result = mulDiv(a, b, denominator);
            if (mulmod(a, b, denominator) > 0) {
                require(result < type(uint256).max);
                result++;
            }
        }
    }
}

// File: @uniswap/v3-periphery/contracts/libraries/OracleLibrary.sol


pragma solidity >=0.5.0 <0.9.0;




/// @title Oracle library
/// @notice Provides functions to integrate with V3 pool oracle
library OracleLibrary {
    /// @notice Calculates time-weighted means of tick and liquidity for a given Uniswap V3 pool
    /// @param pool Address of the pool that we want to observe
    /// @param secondsAgo Number of seconds in the past from which to calculate the time-weighted means
    /// @return arithmeticMeanTick The arithmetic mean tick from (block.timestamp - secondsAgo) to block.timestamp
    /// @return harmonicMeanLiquidity The harmonic mean liquidity from (block.timestamp - secondsAgo) to block.timestamp
    function consult(address pool, uint32 secondsAgo)
        internal
        view
        returns (int24 arithmeticMeanTick, uint128 harmonicMeanLiquidity)
    {
        require(secondsAgo != 0, 'BP');

        uint32[] memory secondsAgos = new uint32[](2);
        secondsAgos[0] = secondsAgo;
        secondsAgos[1] = 0;

        (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s) = IUniswapV3Pool(pool)
            .observe(secondsAgos);

        int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];
        uint160 secondsPerLiquidityCumulativesDelta = secondsPerLiquidityCumulativeX128s[1] -
            secondsPerLiquidityCumulativeX128s[0];

        arithmeticMeanTick = int24(tickCumulativesDelta / int56(uint56(secondsAgo)));
        // Always round to negative infinity
        if (tickCumulativesDelta < 0 && (tickCumulativesDelta % int56(uint56(secondsAgo)) != 0)) arithmeticMeanTick--;

        // We are multiplying here instead of shifting to ensure that harmonicMeanLiquidity doesn't overflow uint128
        uint192 secondsAgoX160 = uint192(secondsAgo) * type(uint160).max;
        harmonicMeanLiquidity = uint128(secondsAgoX160 / (uint192(secondsPerLiquidityCumulativesDelta) << 32));
    }

    /// @notice Given a tick and a token amount, calculates the amount of token received in exchange
    /// @param tick Tick value used to calculate the quote
    /// @param baseAmount Amount of token to be converted
    /// @param baseToken Address of an ERC20 token contract used as the baseAmount denomination
    /// @param quoteToken Address of an ERC20 token contract used as the quoteAmount denomination
    /// @return quoteAmount Amount of quoteToken received for baseAmount of baseToken
    function getQuoteAtTick(
        int24 tick,
        uint128 baseAmount,
        address baseToken,
        address quoteToken
    ) internal pure returns (uint256 quoteAmount) {
        uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick);

        // Calculate quoteAmount with better precision if it doesn't overflow when multiplied by itself
        if (sqrtRatioX96 <= type(uint128).max) {
            uint256 ratioX192 = uint256(sqrtRatioX96) * sqrtRatioX96;
            quoteAmount = baseToken < quoteToken
                ? FullMath.mulDiv(ratioX192, baseAmount, 1 << 192)
                : FullMath.mulDiv(1 << 192, baseAmount, ratioX192);
        } else {
            uint256 ratioX128 = FullMath.mulDiv(sqrtRatioX96, sqrtRatioX96, 1 << 64);
            quoteAmount = baseToken < quoteToken
                ? FullMath.mulDiv(ratioX128, baseAmount, 1 << 128)
                : FullMath.mulDiv(1 << 128, baseAmount, ratioX128);
        }
    }

    /// @notice Given a pool, it returns the number of seconds ago of the oldest stored observation
    /// @param pool Address of Uniswap V3 pool that we want to observe
    /// @return secondsAgo The number of seconds ago of the oldest observation stored for the pool
    function getOldestObservationSecondsAgo(address pool) internal view returns (uint32 secondsAgo) {
        (, , uint16 observationIndex, uint16 observationCardinality, , , ) = IUniswapV3Pool(pool).slot0();
        require(observationCardinality > 0, 'NI');

        (uint32 observationTimestamp, , , bool initialized) = IUniswapV3Pool(pool).observations(
            (observationIndex + 1) % observationCardinality
        );

        // The next index might not be initialized if the cardinality is in the process of increasing
        // In this case the oldest observation is always in index 0
        if (!initialized) {
            (observationTimestamp, , , ) = IUniswapV3Pool(pool).observations(0);
        }

        unchecked {
            secondsAgo = uint32(block.timestamp) - observationTimestamp;
        }
    }

    /// @notice Given a pool, it returns the tick value as of the start of the current block
    /// @param pool Address of Uniswap V3 pool
    /// @return The tick that the pool was in at the start of the current block
    function getBlockStartingTickAndLiquidity(address pool) internal view returns (int24, uint128) {
        (, int24 tick, uint16 observationIndex, uint16 observationCardinality, , , ) = IUniswapV3Pool(pool).slot0();

        // 2 observations are needed to reliably calculate the block starting tick
        require(observationCardinality > 1, 'NEO');

        // If the latest observation occurred in the past, then no tick-changing trades have happened in this block
        // therefore the tick in `slot0` is the same as at the beginning of the current block.
        // We don't need to check if this observation is initialized - it is guaranteed to be.
        (
            uint32 observationTimestamp,
            int56 tickCumulative,
            uint160 secondsPerLiquidityCumulativeX128,

        ) = IUniswapV3Pool(pool).observations(observationIndex);
        if (observationTimestamp != uint32(block.timestamp)) {
            return (tick, IUniswapV3Pool(pool).liquidity());
        }

        uint256 prevIndex = (uint256(observationIndex) + observationCardinality - 1) % observationCardinality;
        (
            uint32 prevObservationTimestamp,
            int56 prevTickCumulative,
            uint160 prevSecondsPerLiquidityCumulativeX128,
            bool prevInitialized
        ) = IUniswapV3Pool(pool).observations(prevIndex);

        require(prevInitialized, 'ONI');

        uint32 delta = observationTimestamp - prevObservationTimestamp;
        tick = int24((tickCumulative - int56(uint56(prevTickCumulative))) / int56(uint56(delta)));
        uint128 liquidity = uint128(
            (uint192(delta) * type(uint160).max) /
                (uint192(secondsPerLiquidityCumulativeX128 - prevSecondsPerLiquidityCumulativeX128) << 32)
        );
        return (tick, liquidity);
    }

    /// @notice Information for calculating a weighted arithmetic mean tick
    struct WeightedTickData {
        int24 tick;
        uint128 weight;
    }

    /// @notice Given an array of ticks and weights, calculates the weighted arithmetic mean tick
    /// @param weightedTickData An array of ticks and weights
    /// @return weightedArithmeticMeanTick The weighted arithmetic mean tick
    /// @dev Each entry of `weightedTickData` should represents ticks from pools with the same underlying pool tokens. If they do not,
    /// extreme care must be taken to ensure that ticks are comparable (including decimal differences).
    /// @dev Note that the weighted arithmetic mean tick corresponds to the weighted geometric mean price.
    function getWeightedArithmeticMeanTick(WeightedTickData[] memory weightedTickData)
        internal
        pure
        returns (int24 weightedArithmeticMeanTick)
    {
        // Accumulates the sum of products between each tick and its weight
        int256 numerator;

        // Accumulates the sum of the weights
        uint256 denominator;

        // Products fit in 152 bits, so it would take an array of length ~2**104 to overflow this logic
        for (uint256 i; i < weightedTickData.length; i++) {
            numerator += weightedTickData[i].tick * int256(uint256(weightedTickData[i].weight));
            denominator += weightedTickData[i].weight;
        }

        weightedArithmeticMeanTick = int24(numerator / int256(denominator));
        // Always round to negative infinity
        if (numerator < 0 && (numerator % int256(denominator) != 0)) weightedArithmeticMeanTick--;
    }

    /// @notice Returns the "synthetic" tick which represents the price of the first entry in `tokens` in terms of the last
    /// @dev Useful for calculating relative prices along routes.
    /// @dev There must be one tick for each pairwise set of tokens.
    /// @param tokens The token contract addresses
    /// @param ticks The ticks, representing the price of each token pair in `tokens`
    /// @return syntheticTick The synthetic tick, representing the relative price of the outermost tokens in `tokens`
    function getChainedPrice(address[] memory tokens, int24[] memory ticks)
        internal
        pure
        returns (int256 syntheticTick)
    {
        require(tokens.length - 1 == ticks.length, 'DL');
        for (uint256 i = 1; i <= ticks.length; i++) {
            // check the tokens for address sort order, then accumulate the
            // ticks into the running synthetic tick, ensuring that intermediate tokens "cancel out"
            tokens[i - 1] < tokens[i] ? syntheticTick += ticks[i - 1] : syntheticTick -= ticks[i - 1];
        }
    }
}

// File: contracts/QBuyBurn.sol


pragma solidity ^0.8.24;





contract QBuyBurn {

    uint256 public i_initialTimestamp;

    uint256 constant i_periodDuration = 1 days;

    uint256 public firstCycleReceivedEther;

    uint256 public globalCountForDays;

    uint256 public collectedAmount;

    address immutable Q; 
    
    address immutable Q_WETH9_Pool;    

    address constant UNISWAP_V3_FACTORY = 0x1F98431c8aD98523631AE4a59f267346ea31F984;

    address constant WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; 

    address constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;

    address constant SWAP_ROUTER = 0xE592427A0AEce92De3Edee1F18E0157C05861564;

    mapping(uint256 => bool) public feeAlreadyDistributed;

    uint24 constant poolFee = 10000;

    receive() external payable {
        if(block.timestamp < i_initialTimestamp + 1 days) {
            firstCycleReceivedEther += msg.value;
         } else {
            collectedAmount += msg.value;
         }
    }

    constructor(address _qAddress) {
        i_initialTimestamp = block.timestamp;
        Q_WETH9_Pool = computePoolAddress(WETH9, _qAddress, poolFee);
        Q = _qAddress;
    }

    function burnToken(uint256 amountToBurn, uint256 deadline) public {
        require(msg.sender == tx.origin, "Use EOA!");
        require(isContract(Q_WETH9_Pool), "Pool does not exist!");
        require(block.timestamp > i_initialTimestamp + 1 days, "Early burn!");
        require(amountToBurn >= 0.1 ether, "Min 0.1 ETH");

        uint256 theFiftiethPart = (firstCycleReceivedEther / 50);
        uint256 amountToCompare = collectedAmount;
        uint256 currentCycle = getCurrentCycle();

        uint256 amountETH;
        uint256 callerPercent;

        if(globalCountForDays < 50 && !feeAlreadyDistributed[currentCycle]) {
            amountToCompare = collectedAmount + theFiftiethPart;
            require(amountToCompare >= amountToBurn, "Insufficient funds!");
            
            if(collectedAmount >= amountToBurn) {
                collectedAmount -= amountToBurn;
                amountToBurn += theFiftiethPart;
            } else {
                if(amountToBurn > theFiftiethPart) {
                    if(collectedAmount >= amountToBurn - theFiftiethPart) {
                        collectedAmount -= amountToBurn - theFiftiethPart;
                    }
                } else {
                amountToBurn = theFiftiethPart;
                }
            }
            globalCountForDays ++;
            feeAlreadyDistributed[currentCycle] = true;
        } else {
            require(amountToCompare >= amountToBurn, "Insufficient funds!");
            collectedAmount -= amountToBurn;
        }
        callerPercent = amountToBurn / 100;
        amountETH = amountToBurn - callerPercent;

        uint256 amountOutExpected = _getQuote(uint128(amountETH));
        uint256 minTokenAmount = (amountOutExpected * 90) / 100;
        require(minTokenAmount > 0, "Min > 0");

        _swap(minTokenAmount, amountETH, deadline);

        (bool success,) = payable(msg.sender).call{value: callerPercent}("");
        require(success, "Transfer failed.");
    }

    function _swap(uint256 amountOutMinimum, uint256 amountIn, uint256 deadline) private {
        ISwapRouterMinimal.ExactInputSingleParams memory params =
            ISwapRouterMinimal.ExactInputSingleParams({
                tokenIn: WETH9,
                tokenOut: Q,
                fee: poolFee,
                recipient: BURN_ADDRESS,
                deadline: deadline,
                amountIn: amountIn,
                amountOutMinimum: amountOutMinimum,
                sqrtPriceLimitX96: 0
            });

        ISwapRouterMinimal(SWAP_ROUTER).exactInputSingle{value: amountIn}(params);
    }

    function _getQuote(uint128 amountIn) public view returns(uint256 amountOut) {
        (int24 tick, ) = OracleLibrary.consult(Q_WETH9_Pool, 1);
        amountOut = OracleLibrary.getQuoteAtTick(tick, amountIn, WETH9, Q);
    }

    function isContract(address _addr) private view returns (bool) {
        uint32 size;
        assembly {
            size := extcodesize(_addr)
        }
        return (size > 0);
    }

    function computePoolAddress(address tokenA, address tokenB, uint24 fee) public pure returns (address pool) {
        (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
        PoolAddress.PoolKey memory key = PoolAddress.PoolKey({token0: token0, token1: token1, fee: fee});
        pool = PoolAddress.computeAddress(UNISWAP_V3_FACTORY, key);
        return pool;
    }   

    function getCurrentCycle() public view returns (uint256) {
        return (block.timestamp - i_initialTimestamp) / i_periodDuration;
    }
}
// File: @openzeppelin/contracts/utils/Counters.sol


// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library Counters {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

// File: @openzeppelin/contracts/interfaces/IERC5267.sol


// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol)

pragma solidity ^0.8.0;

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

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

// File: @openzeppelin/contracts/utils/StorageSlot.sol


// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.0;

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

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

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

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

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

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

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

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

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

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

// File: @openzeppelin/contracts/utils/ShortStrings.sol


// OpenZeppelin Contracts (last updated v4.9.0) (utils/ShortStrings.sol)

pragma solidity ^0.8.8;


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

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

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

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

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

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

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

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

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

// File: @openzeppelin/contracts/utils/math/SignedMath.sol


// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

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

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

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

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

// File: @openzeppelin/contracts/utils/math/Math.sol


// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// File: @openzeppelin/contracts/utils/Strings.sol


// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;



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

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

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

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

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

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

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

// File: @openzeppelin/contracts/utils/cryptography/ECDSA.sol


// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;


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

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

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

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

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

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

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

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

        return (signer, RecoverError.NoError);
    }

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

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

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

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

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

// File: @openzeppelin/contracts/utils/cryptography/EIP712.sol


// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol)

pragma solidity ^0.8.8;




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

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

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

    bytes32 private immutable _hashedName;
    bytes32 private immutable _hashedVersion;

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

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

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

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

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

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

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

// File: @openzeppelin/contracts/utils/Address.sol


// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

// File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol


// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

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

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

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

// File: @openzeppelin/contracts/token/ERC20/IERC20.sol


// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

// File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol


// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;


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

// File: @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol


// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;




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

// File: @openzeppelin/contracts/utils/Context.sol


// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

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

// File: @openzeppelin/contracts/token/ERC20/ERC20.sol


// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;




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

// File: @openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol


// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/ERC20Permit.sol)

pragma solidity ^0.8.0;






/**
 * @dev Implementation 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.
 *
 * _Available since v3.4._
 */
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
    using Counters for Counters.Counter;

    mapping(address => Counters.Counter) private _nonces;

    // solhint-disable-next-line var-name-mixedcase
    bytes32 private constant _PERMIT_TYPEHASH =
        keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
    /**
     * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.
     * However, to ensure consistency with the upgradeable transpiler, we will continue
     * to reserve a slot.
     * @custom:oz-renamed-from _PERMIT_TYPEHASH
     */
    // solhint-disable-next-line var-name-mixedcase
    bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;

    /**
     * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
     *
     * It's a good idea to use the same `name` that is defined as the ERC20 token name.
     */
    constructor(string memory name) EIP712(name, "1") {}

    /**
     * @inheritdoc IERC20Permit
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual override {
        require(block.timestamp <= deadline, "ERC20Permit: expired deadline");

        bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));

        bytes32 hash = _hashTypedDataV4(structHash);

        address signer = ECDSA.recover(hash, v, r, s);
        require(signer == owner, "ERC20Permit: invalid signature");

        _approve(owner, spender, value);
    }

    /**
     * @inheritdoc IERC20Permit
     */
    function nonces(address owner) public view virtual override returns (uint256) {
        return _nonces[owner].current();
    }

    /**
     * @inheritdoc IERC20Permit
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view override returns (bytes32) {
        return _domainSeparatorV4();
    }

    /**
     * @dev "Consume a nonce": return the current value and increment.
     *
     * _Available since v4.1._
     */
    function _useNonce(address owner) internal virtual returns (uint256 current) {
        Counters.Counter storage nonce = _nonces[owner];
        current = nonce.current();
        nonce.increment();
    }
}

// File: @openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol


// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/draft-ERC20Permit.sol)

pragma solidity ^0.8.0;

// EIP-2612 is Final as of 2022-11-01. This file is deprecated.


// File: contracts/QERC20.sol


pragma solidity ^0.8.24;


contract QERC20 is ERC20Permit {

    address immutable owner;

    constructor() ERC20("Q Token", "Q")
    ERC20Permit("Q Token") {
        owner = msg.sender;
    }

    function mintReward(address account, uint256 amount) external {
        require(msg.sender == owner, "Q: Incorrect caller");
        require(super.totalSupply() < 120000000000000000000000000, "Q: Already minted");
        _mint(account, amount);
    }
}
// File: @openzeppelin/contracts/metatx/ERC2771Context.sol


// OpenZeppelin Contracts (last updated v4.9.4) (metatx/ERC2771Context.sol)

pragma solidity ^0.8.9;


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

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

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

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

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

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

// File: contracts/Q.sol


pragma solidity ^0.8.24;





contract Q is ERC2771Context {
    using SafeERC20 for QERC20;

    /**
     * Used to minimise division remainder when earned fees are calculated.
     */
    uint256 constant SCALING_FACTOR = 1e40;

    /**
     * Contract creation timestamp.
     * Initialized in constructor.
     */
    uint256 immutable i_initialTimestamp;

    /**
     * Length of a reward distribution cycle. 
     * Initialized in contstructor to 1 day.
     */
    uint256 immutable i_periodDuration;

    /**
     * Helper variable to store pending stake amount.   
     */
    uint256 public pendingStake;

    /**
     * Index (0-based) of the current cycle.
     * 
     * Updated upon cycle setup that is triggered by contract interraction 
     * (account burn tokens, claims fees, claims rewards, stakes or unstakes).
     */
    uint256 public currentCycle;

    /**
     * Helper variable to store the index of the last active cycle.
     */
    uint256 public lastStartedCycle;

    /**
     * Stores the index of the penultimate active cycle plus one.
     */
    uint256 public previousStartedCycle;

    /**
     * Helper variable to store the index of the last active cycle.
     */
    uint256 public currentStartedCycle;

    /**
     * Stores the amount of stake that will be subracted from the total
     * stake once a new cycle starts.
     */
    uint256 public pendingStakeWithdrawal;

    /**
     * Diminisher of burned ether effectivness when calculating reward.
     */
    uint256 public currentBurnDecrease;

    /**
     * Registration fee for the current started cycle.
     */
    uint256 public currentRegistrationFee;

    /**
     * Total amount of ether burned through calling {enterCycle}.
     */
    uint256 public totalNativeBurned;

    /**
     * Number of times {enterCycle} has been called during current started cycle.
     */
    uint256 public cycleInteractions;

    /**
     * 3,8% of protocol fees are added to the devFee funds.
     */
    address immutable devFee;

    /**
     * 1% of protocol fees are sent to the buy and burn of DXN contract.
     */
    address immutable dxnBuyAndBurn;

    /**
     * 25% of protocol fees are sent to the buy and burn of Q contract.
     */
    address public immutable qBuyAndBurn;

    /**
     * 0,2% of protocol fees are sent to the NXD DSV contract.
     */
    address public immutable nxdDSV;

    /**
     * Q Reward Token contract.
     * Initialized in constructor.
     */
    QERC20 public immutable qToken;
    
    /**
     * The amount of entries an account has during given cycle.
     * Resets during a new cycle when an account performs an action
     * that updates its stats.
     */
    mapping(address => uint256) public accCycleEntries;
    
    /**
     * The total amount of entries across all accounts per cycle.
     */
    mapping(uint256 => uint256) public cycleTotalEntries;

    /**
     * The last cycle in which an account has burned.
     */
    mapping(address => uint256) public lastActiveCycle;

    /**
     * Current unclaimed rewards and staked amounts per account.
     */
    mapping(address => uint256) public accRewards;

    /**
     * The fee amount the account can withdraw.
     */
    mapping(address => uint256) public accAccruedFees;

    /**
     * Total token rewards allocated per cycle.
     */
    mapping(uint256 => uint256) public rewardPerCycle;

    /**
     * Total unclaimed token reward and stake. 
     * 
     * Updated when a new cycle starts and when an account claims rewards, stakes or unstakes externally owned tokens.
     */
    mapping(uint256 => uint256) public summedCycleStakes;

    /**
     * The last cycle in which the account had its fees updated.
     */ 
    mapping(address => uint256) public lastFeeUpdateCycle;

    /**
     * The total amount of accrued fees per cycle.
     */
    mapping(uint256 => uint256) public cycleAccruedFees;

    /**
     * Sum of previous total cycle accrued fees divided by cycle stake.
     */
    mapping(uint256 => uint256) public cycleFeesPerStakeSummed;

    /**
     * Amount an account has staked and is locked during given cycle.
     */
    mapping(address => mapping(uint256 => uint256)) public accStakeCycle;

    /**
     * Stake amount an account can currently withdraw.
     */
    mapping(address => uint256) public accWithdrawableStake;

    /**
     * Cycle in which an account's stake is locked and begins generating fees.
     */
    mapping(address => uint256) public accFirstStake;

    /**
     * Same as accFirstStake, but stores the second stake seperately 
     * in case the account stakes in two consecutive active cycles.
     */
    mapping(address => uint256) public accSecondStake;

    /**
     * Returns whether an AI miner has registered or not.
     */
    mapping(address => bool) public isAIMinerRegistered;

    /**
     * Deposited ether balance for a given AI miner and cycle.
     */
    mapping(address => mapping(uint256 => uint256)) public aiMinerBalancePerCycle;

    /**
     * Lowest registered AI miner balance in a given cycle.
     */
    mapping(uint256 => uint256) public lowestCycleBalance;

    /**
     * Total amount of burned ether spent on {enterCycle} transactions.
     */
    mapping(uint256 => uint256) public nativeBurnedPerCycle;

    /**
     * @dev Emitted when `account` claims an amount of `fees` in native token
     * through {claimFees} in `cycle`.
     */
    event FeesClaimed(
        uint256 indexed cycle,
        address indexed account,
        uint256 fees
    );

    /**
     * @dev Emitted when `account` stakes `amount` Q tokens through
     * {stake} in `cycle`.
     */
    event Staked(
        uint256 indexed cycle,
        address indexed account,
        uint256 amount
    );

    /**
     * @dev Emitted when `account` unstakes `amount` Q tokens through
     * {unstake} in `cycle`.
     */
    event Unstaked(
        uint256 indexed cycle,
        address indexed account,
        uint256 amount
    );

    /**
     * @dev Emitted when `account` claims `amount` Q 
     * token rewards through {claimRewards} in `cycle`.
     */
    event RewardsClaimed(
        uint256 indexed cycle,
        address indexed account,
        uint256 reward
    );

    /**
     * @dev Emitted when calling {enterCycle} marking the new current `cycle`,
     * `calculatedCycleReward` and `summedCycleStakes`.
     */
    event NewCycleStarted(
        uint256 indexed cycle,
        uint256 summedCycleStakes
    );

    /**
     * @dev Emitted when calling {enterCycle} 
     */
    event CycleEntry(
        address indexed userAddress,
        uint256 entryMultiplier
    );

    /**
     * @dev Emitted when calling {registerAIMiner} 
     */
    event NewAIRegistered(
        address indexed aiMiner,
        string name,
        uint256 currentRegistrationFee
    );

    /**
     * @dev Emitted when calling {addFundsForAIMiner} 
     */
    event AddFundsForMiner(
        address indexed user,
        address indexed aiMiner,
        uint256 amount,
        uint256 cycle
    );
    /**
     * Minimal reentrancy lock using transient storage.
     */
    modifier nonReentrant {
        assembly {
            if tload(0) { revert(0, 0) }
            tstore(0, 1)
        }
        _;
        // Unlocks the guard, making the pattern composable.
        // After the function exits, it can be called again, even in the same transaction.
        assembly {
            tstore(0, 0)
        }
    }

    /**
     * @dev Checks that the caller has sent an amount that is equal or greater 
     * than the sum of the protocol fee 
     * The change is sent back to the caller.
     * 
     */
    modifier gasWrapper() {
        uint256 startGas = gasleft();
        _;
        uint256 gasConsumed = startGas - gasleft() + 30892;
        uint256 burnedAmount = gasConsumed * block.basefee;

        nativeBurnedPerCycle[currentCycle] += burnedAmount;
        totalNativeBurned += burnedAmount;
    }

    /**
     * @param forwarder forwarder contract address.
     */
    constructor(
        address forwarder,
        address _devFee,
        address _dxnBuyAndBurn,
        address _nxdDSV,
        address[] memory AIRegisteredAddresses
    ) ERC2771Context(forwarder) payable {
        devFee = _devFee;
        nxdDSV = _nxdDSV;

        qToken = new QERC20();
        dxnBuyAndBurn = _dxnBuyAndBurn;
        qBuyAndBurn = address(new QBuyBurn(address(qToken)));
        
        i_initialTimestamp = block.timestamp;
        i_periodDuration = 1 days;

        currentRegistrationFee = 10 ether;

        uint256 stakerRegistrationFees = msg.value * 75 / 100;

        cycleAccruedFees[0] = stakerRegistrationFees;

        setAiMintersAddresses(AIRegisteredAddresses);

        sendViaCall(payable(qBuyAndBurn), msg.value - stakerRegistrationFees);
    }

    /**
     * Initializer function for marking as registered
     * those AI miners that have done so inside the 
     * Q payment contract. 
     */
    function setAiMintersAddresses(address[] memory AIAddresses) internal {
        uint256 numberOfAIs = AIAddresses.length;
        for(uint256 i=0; i < numberOfAIs; i++) {
            isAIMinerRegistered[AIAddresses[i]] = true;
        }
    }

    /**
     * Entry point for the Q daily auction.
     *
     * @param aiMiner designated AI miner
     * @param entryMultiplier multiplies the number of entries
     */
    function enterCycle(
        address aiMiner,
        uint256 entryMultiplier
    )
        external
        payable
        nonReentrant()
        gasWrapper()
    {
        require(totalNativeBurned <= 1_200_000 ether, "Q: Endgame reached");
        require(entryMultiplier <= 100, "Q: Max 100");
        require(entryMultiplier > 0, "Q: Min 1");

        require(isAIMinerRegistered[aiMiner], "Q: Not registered");

        calculateCycle();
        uint256 currentCycleMem = currentCycle;

        endCycle(currentCycleMem);
        setUpNewCycle(currentCycleMem);

        uint256 protocolFee = calculateProtocolFee(entryMultiplier);
        require(msg.value >= protocolFee, "Q: Value < fee");

        address user = _msgSender();
        updateStats(user, currentCycleMem);
        updateStats(aiMiner, currentCycleMem);

        calculateCycleEntries(entryMultiplier, currentCycleMem, aiMiner, user);

        lastActiveCycle[user] = currentCycle;
        lastActiveCycle[aiMiner] = currentCycle;

        cycleInteractions++;

        distributeFees(protocolFee, currentCycleMem);

        if(msg.value > protocolFee) {
             sendViaCall(payable(msg.sender), msg.value - protocolFee);
        }
        emit CycleEntry(user, entryMultiplier);
    }

    /**
     * Allows anyone to register as an AI miner if the
     * corresponding registration fee is paid.
     */
    function registerAIMiner(string calldata name) external payable {
        uint256 registrationFee = currentRegistrationFee;
        require(msg.value >= registrationFee);

        address aiMiner = _msgSender();
        require(!isAIMinerRegistered[aiMiner], "Q: AI registered");

        isAIMinerRegistered[aiMiner] = true;

        if(msg.value > registrationFee) {
            sendViaCall(payable(msg.sender), msg.value - registrationFee);
        }

        distributeFees(registrationFee, currentStartedCycle);
        emit NewAIRegistered(aiMiner, name, registrationFee);
    }

    /**
     * @dev Mints newly accrued account rewards and transfers the entire 
     * allocated amount to the transaction sender address.
     */
    function claimRewards(uint256 claimAmount)
        external
        nonReentrant()
    {
        calculateCycle();
        uint256 currentCycleMem = currentCycle;

        endCycle(currentCycleMem);

        address user = _msgSender();
        updateStats(user, currentCycleMem);

        uint256 reward = accRewards[user] - accWithdrawableStake[user];
        require(reward > 0, "Q: No rewards");
        require(claimAmount <= reward, "Q: Exceeds rewards");

        accRewards[user] -= claimAmount;
        if (lastStartedCycle == currentStartedCycle) {
            pendingStakeWithdrawal += claimAmount;
        } else {
            summedCycleStakes[currentCycleMem] = summedCycleStakes[currentCycleMem] - claimAmount;
        }

        qToken.mintReward(user, claimAmount);
        emit RewardsClaimed(currentCycleMem, user, claimAmount);
    }

    /**
     * @dev Transfers newly accrued fees to sender's address.
     */
    function claimFees(uint256 claimAmount)
        external
        nonReentrant()
    {
        calculateCycle();
        uint256 currentCycleMem = currentCycle;
        address user = _msgSender();

        endCycle(currentCycleMem);
        updateStats(user, currentCycleMem);

        uint256 fees = accAccruedFees[user];
        require(fees > 0, "Q: Amount is zero");
        require(claimAmount <= fees, "Q: Claim amount exceeds fees");

        accAccruedFees[user] -= claimAmount;

        sendViaCall(payable(user), claimAmount);
        
        emit FeesClaimed(currentCycleMem, user, claimAmount);
    }

    /**
     * @dev Stakes the given amount and increases the share of the daily allocated fees.
     * The tokens are transfered from sender account to this contract.
     * To receive the tokens back, the unstake function must be called by the same account address.
     * 
     * @param amount token amount to be staked (in wei).
     */
    function stake(uint256 amount)
        external
        nonReentrant()
    {
        calculateCycle();
        uint256 currentCycleMem = currentCycle;
        address user = _msgSender();

        endCycle(currentCycleMem);
        updateStats(user, currentCycleMem);

        require(amount > 0, "Q: Amount is zero");
        require(currentCycleMem == currentStartedCycle, "Q: Only stake during active cycle");

        pendingStake += amount;

        uint256 cycleToSet = currentCycleMem + 1;
        if (lastStartedCycle == currentStartedCycle) {
            cycleToSet = lastStartedCycle + 1;
        }

        if (
            (cycleToSet != accFirstStake[user] &&
                cycleToSet != accSecondStake[user])
        ) {
            if (accFirstStake[user] == 0) {
                accFirstStake[user] = cycleToSet;
            } else if (accSecondStake[user] == 0) {
                accSecondStake[user] = cycleToSet;
            }
        }

        accStakeCycle[user][cycleToSet] += amount;

        qToken.safeTransferFrom(user, address(this), amount);
        emit Staked(cycleToSet, user, amount);
    }

    /**
     * @dev Unstakes the given amount and decreases the share of the daily allocated fees.
     * If the balance is availabe, the tokens are transfered from this contract to the sender account.
     * 
     * @param amount token amount to be unstaked (in wei).
     */
    function unstake(uint256 amount)
        external
        nonReentrant()
    {
        calculateCycle();
        uint256 currentCycleMem = currentCycle;
        address user = _msgSender();

        endCycle(currentCycleMem);
        updateStats(user, currentCycleMem);
        
        require(amount > 0, "Q: Amount is zero");
        require(
            amount <= accWithdrawableStake[user],
            "Q: Amount greater than withdrawable stake"
        );

        if (lastStartedCycle == currentStartedCycle) {
            pendingStakeWithdrawal += amount;
        } else {
            summedCycleStakes[currentCycleMem] -= amount;
        }

        accWithdrawableStake[user] -= amount;
        accRewards[user] -= amount;

        qToken.safeTransfer(user, amount);
        emit Unstaked(currentCycleMem, user, amount);
    }

    /**
     * @dev Returns the index of the cycle at the current block time.
     */
    function getCurrentCycle() public view returns (uint256) {
        return (block.timestamp - i_initialTimestamp) / i_periodDuration;
    }

    /**
     * Calculates the multiplier applied to a cycle entry
     * where "miner" is the designated AI miner.
     */
    function getAIMinerRankMultiplier(address miner, uint256 cycle) internal view returns(uint256 multiplier) {
        uint256 lastStartedCycleMem = lastStartedCycle;
        uint256 lastStartedCycleBalance = aiMinerBalancePerCycle[miner][lastStartedCycleMem];

        if(lastStartedCycleBalance != 0 && cycle != 0) {
            multiplier = lastStartedCycleBalance * 2 / lowestCycleBalance[lastStartedCycleMem];
        } else {
            multiplier = 1;
        }
    }

    /**
     * Calculates the protocol fee for entering the current cycle.
     */
    function calculateProtocolFee(uint256 entryMultiplier) internal view returns(uint256 protocolFee) {
        protocolFee = (0.01 ether * entryMultiplier * (1000  + cycleInteractions)) / 1000;
    }

    /**
     * If the current registration fee is not 5 ether,
     * the fee gets updated for the new started cycle.
     */
    function calculateRegisterFee() internal {
        if(currentRegistrationFee > 5 ether) {
            uint256 newRegistrationFee = (currentRegistrationFee * 10000) / 10020;
            if(newRegistrationFee < 5 ether) {
                currentRegistrationFee = 5 ether;
            } else {
                currentRegistrationFee = newRegistrationFee;
            }
        }
    }

    /**
     * Based on the protocol fee, the corresponding allocations are
     * sent to each of the predefined addresses.
     */
    function distributeFees(uint256 fees, uint256 cycle) internal {
        cycleAccruedFees[cycle] += fees * 70 / 100;

        sendViaCall(payable(nxdDSV), fees * 2 / 1000);
        sendViaCall(payable(devFee), fees * 38 / 1000);
        sendViaCall(payable(dxnBuyAndBurn), fees / 100);
        sendViaCall(payable(qBuyAndBurn), fees * 25 / 100);
    }

    /**
     * Increase the ether balance of a given AI miner - this action
     * counts towards ranking the AI miners and establishing
     * a multiplier when choosing a certain miner to enter the cycle with.
     */
    function addFundsForAIMiner(address aiMiner) external payable {
        uint256 cycle = currentStartedCycle;
        uint256 currentBalancePlusValue = aiMinerBalancePerCycle[aiMiner][cycle] + msg.value;

        require(currentBalancePlusValue >= 0.1 ether, "Q: Min. threshold balance not met");

        aiMinerBalancePerCycle[aiMiner][cycle] += msg.value;

        uint256 currentCycleLowestBalance = lowestCycleBalance[cycle];
        if(currentBalancePlusValue < currentCycleLowestBalance ||
            currentCycleLowestBalance == 0) {
            lowestCycleBalance[cycle] = currentBalancePlusValue;
        }

        distributeFees(msg.value, cycle);

        emit AddFundsForMiner(msg.sender, aiMiner, msg.value, cycle);
    }

    /**
     * Calculates entries to be added to the total of entries of the current cycle
     * and of the entrant.
     */
    function calculateCycleEntries(uint256 batchWeight, uint256 cycle, address aiMiner, address user) internal {
        uint256 multiplier = getAIMinerRankMultiplier(aiMiner, cycle);
        if(multiplier > 1) {
            batchWeight *= multiplier;
        }

        cycleTotalEntries[cycle] += batchWeight * 100;
        accCycleEntries[user] += batchWeight * 95;
        accCycleEntries[aiMiner] += batchWeight * 5;
    }

    /**
     * @dev Updates the index of the cycle.
     */
    function calculateCycle() internal {
        uint256 calculatedCycle = getCurrentCycle();
        
        if (calculatedCycle > currentCycle) {
            currentCycle = calculatedCycle;
        }
        
    }

    /**
     * @dev Updates the global helper variables related to fee distribution.
     */
    function endCycle(uint256 cycle) internal {
        if (cycle != currentStartedCycle) {
            previousStartedCycle = lastStartedCycle;
            lastStartedCycle = currentStartedCycle;
        }

        uint256 lastStartedCycleMem = lastStartedCycle;

        if (
            cycle > lastStartedCycleMem &&
            cycleFeesPerStakeSummed[lastStartedCycleMem + 1] == 0
        ) {
            calculateCycleReward(lastStartedCycleMem);
            
            uint256 feePerStake = (cycleAccruedFees[lastStartedCycleMem] * SCALING_FACTOR) / 
                summedCycleStakes[lastStartedCycleMem];
            
            cycleFeesPerStakeSummed[lastStartedCycleMem + 1] = cycleFeesPerStakeSummed[previousStartedCycle + 1] + feePerStake;
        }
    }

    /**
     * Calculates the Q reward amount to be distributed to
     * the entrants of the specified cycle. 
     */
    function calculateCycleReward(uint256 cycle) internal {  
        uint256 reward = nativeBurnedPerCycle[cycle] * 100 - 
            nativeBurnedPerCycle[cycle] * currentBurnDecrease / 200;

        rewardPerCycle[cycle] = reward;
        summedCycleStakes[cycle] += reward;
            
        if(currentBurnDecrease < 19999) {
            currentBurnDecrease++;
        }
    }

    /**
     * @dev Updates the global state related to starting a new cycle along 
     * with helper state variables used in computation of staking rewards.
     */
    function setUpNewCycle(uint256 cycle) internal {
        if (cycle != currentStartedCycle) {
            calculateRegisterFee();

            currentStartedCycle = cycle;

            cycleInteractions = 0;

            summedCycleStakes[cycle] += summedCycleStakes[lastStartedCycle];
            
            if (pendingStake != 0) {
                summedCycleStakes[cycle] += pendingStake;
                pendingStake = 0;
            }
            
            if (pendingStakeWithdrawal != 0) {
                summedCycleStakes[cycle] -= pendingStakeWithdrawal;
                pendingStakeWithdrawal = 0;
            }
            
            emit NewCycleStarted(
                cycle,
                summedCycleStakes[cycle]
            );
        }
    }

    /**
     * @dev Updates various helper state variables used to compute token rewards 
     * and fees distribution for a given account.
     * 
     * @param account the address of the account to make the updates for.
     */
    function updateStats(address account, uint256 cycle) internal {
         if (	
            cycle > lastActiveCycle[account] &&	
            accCycleEntries[account] != 0	
        ) {	
            uint256 lastCycleAccReward = ((accCycleEntries[account] * rewardPerCycle[lastActiveCycle[account]]) / 	
                cycleTotalEntries[lastActiveCycle[account]]);
            accRewards[account] += lastCycleAccReward;	
            accCycleEntries[account] = 0;
        }

        uint256 lastStartedCyclePlusOne = lastStartedCycle + 1;
        if (
            cycle > lastStartedCycle &&
            lastFeeUpdateCycle[account] != lastStartedCyclePlusOne
        ) {
            accAccruedFees[account] =
                accAccruedFees[account] +
                (
                    (accRewards[account] * 
                        (cycleFeesPerStakeSummed[lastStartedCyclePlusOne] - 
                            cycleFeesPerStakeSummed[lastFeeUpdateCycle[account]]
                        )
                    )
                ) /
                SCALING_FACTOR;
            lastFeeUpdateCycle[account] = lastStartedCyclePlusOne;
        }

        if (
            accFirstStake[account] != 0 &&
            cycle > accFirstStake[account]
        ) {
            uint256 unlockedFirstStake = accStakeCycle[account][accFirstStake[account]];

            accRewards[account] += unlockedFirstStake;
            accWithdrawableStake[account] += unlockedFirstStake;
            if (lastStartedCyclePlusOne > accFirstStake[account]) {
                accAccruedFees[account] = accAccruedFees[account] + 
                (
                    (accStakeCycle[account][accFirstStake[account]] * 
                        (cycleFeesPerStakeSummed[lastStartedCyclePlusOne] - 
                            cycleFeesPerStakeSummed[accFirstStake[account]]
                        )
                    )
                ) / 
                SCALING_FACTOR;
            }

            accStakeCycle[account][accFirstStake[account]] = 0;
            accFirstStake[account] = 0;

            if (accSecondStake[account] != 0) {
                if (cycle > accSecondStake[account]) {
                    uint256 unlockedSecondStake = accStakeCycle[account][accSecondStake[account]];
                    accRewards[account] += unlockedSecondStake;
                    accWithdrawableStake[account] += unlockedSecondStake;
                    
                    if (lastStartedCyclePlusOne > accSecondStake[account]) {
                        accAccruedFees[account] = accAccruedFees[account] + 
                        (
                            (accStakeCycle[account][accSecondStake[account]] * 
                                (cycleFeesPerStakeSummed[lastStartedCyclePlusOne] - 
                                    cycleFeesPerStakeSummed[accSecondStake[account]]
                                )
                            )
                        ) / 
                        SCALING_FACTOR;
                    }

                    accStakeCycle[account][accSecondStake[account]] = 0;
                    accSecondStake[account] = 0;
                } else {
                    accFirstStake[account] = accSecondStake[account];
                    accSecondStake[account] = 0;
                }
            }
        }
    }

    /**
     * Recommended method to use to send native coins.
     * 
     * @param to receiving address.
     * @param amount in wei.
     */
    function sendViaCall(address payable to, uint256 amount) internal {
        (bool sent, ) = to.call{value: amount}("");
        require(sent, "Q: Failed to send amount");
    }

    receive() external payable {}

}
// File: contracts/QPayment.sol


pragma solidity ^0.8.24;


contract QPayment {
    uint256 public startTime;
    uint256 public endTime;
    uint256 constant cycleDuration = 1 days;
    uint256[3] feePerCycle = [5 ether, 6 ether, 7 ether]; 

    address constant nxdDSV = 0xAB4549F042A27Ab278eceE098Fe9E89a8d6594E9;
    address constant forwarder = 0xB2b5841DBeF766d4b521221732F9B618fCf34A87;
    address constant dxnBuyAndBurn = 0x8ff4596Cdad4F8B1e1eFaC1592a5B7b586BC5eF3;
    address public devFee;
    address public qContractAddress;
    address[] public aiAddresses;

    mapping(address => bool) public aiRegisterStatus;

    event AIRegisterData(address indexed aiAddress, uint256 fee, string aiName);

    constructor(address _devFee) {
        startTime = block.timestamp;
        endTime = startTime + 3 days;
        devFee = _devFee;
    }

    function aiRegister(string calldata aiName) external payable {
        require(block.timestamp >= startTime, "Early");
        require(block.timestamp <= endTime, "Late");

        uint256 currentCycle = calculateCurrentCycle();
        uint256 fee = feePerCycle[currentCycle];
        
        require(msg.value >= fee, "Fee low");
        require(!aiRegisterStatus[msg.sender], "Registered");

        aiRegisterStatus[msg.sender] = true;
        aiAddresses.push(msg.sender);

        emit AIRegisterData(msg.sender, fee, aiName);

        if (msg.value > fee) {
            sendViaCall(payable(msg.sender), msg.value - fee);
        }
    }

    function calculateCurrentCycle() public view returns (uint256) {
        return (block.timestamp - startTime) / cycleDuration;
    }

    function deployQContract() external {
        require(block.timestamp > endTime, "Early deploy");
        require(qContractAddress == address(0),"Already deployed");

        uint256 balance = address(this).balance;
        uint256 userPercent = balance * 10 / 100;
        uint256 contractPercent = balance - userPercent;

        qContractAddress = address(new Q{value: contractPercent}(forwarder, devFee, dxnBuyAndBurn, nxdDSV, aiAddresses));
        sendViaCall(payable(msg.sender), userPercent);
    }

    function sendViaCall(address payable to, uint256 amount) internal {
        (bool sent, ) = to.call{value: amount}("");
        require(sent, "Transfer fail");
    }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_devFee","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"aiAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"string","name":"aiName","type":"string"}],"name":"AIRegisterData","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"aiAddresses","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"aiName","type":"string"}],"name":"aiRegister","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"aiRegisterStatus","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"calculateCurrentCycle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deployQContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"devFee","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"endTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"qContractAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

60e0604052674563918244f4000060809081526753444835ec58000060a052676124fee993bc000060c05261003890600290600361009d565b50348015610044575f80fd5b50604051616151380380616151833981016040819052610063916100fa565b425f819055610075906203f480610127565b600155600580546001600160a01b0319166001600160a01b039290921691909117905561014c565b82600381019282156100d6579160200282015b828111156100d657825182906001600160401b03169055916020019190600101906100b0565b506100e29291506100e6565b5090565b5b808211156100e2575f81556001016100e7565b5f6020828403121561010a575f80fd5b81516001600160a01b0381168114610120575f80fd5b9392505050565b8082018082111561014657634e487b7160e01b5f52601160045260245ffd5b92915050565b615ff8806101595f395ff3fe608060405260043610610075575f3560e01c80633197cbb6146100795780636827e764146100a157806368d2b77b146100d85780636b63f18c146100f757806378e9792514610116578063acbe654a1461012a578063b2c884e81461013e578063c84db92914610154578063ce24c74714610167575b5f80fd5b348015610084575f80fd5b5061008e60015481565b6040519081526020015b60405180910390f35b3480156100ac575f80fd5b506005546100c0906001600160a01b031681565b6040516001600160a01b039091168152602001610098565b3480156100e3575f80fd5b506006546100c0906001600160a01b031681565b348015610102575f80fd5b506100c06101113660046105d4565b6101a5565b348015610121575f80fd5b5061008e5f5481565b348015610135575f80fd5b5061008e6101cd565b348015610149575f80fd5b506101526101ee565b005b6101526101623660046105eb565b610363565b348015610172575f80fd5b50610195610181366004610656565b60086020525f908152604090205460ff1681565b6040519015158152602001610098565b600781815481106101b4575f80fd5b5f918252602090912001546001600160a01b0316905081565b5f620151805f54426101df9190610697565b6101e991906106b0565b905090565b60015442116102335760405162461bcd60e51b815260206004820152600c60248201526b4561726c79206465706c6f7960a01b60448201526064015b60405180910390fd5b6006546001600160a01b03161561027f5760405162461bcd60e51b815260206004820152601060248201526f105b1c9958591e4819195c1b1bde595960821b604482015260640161022a565b475f606461028e83600a6106cf565b61029891906106b0565b90505f6102a58284610697565b90508073b2b5841dbef766d4b521221732f9b618fcf34a8760055f9054906101000a90046001600160a01b0316738ff4596cdad4f8b1e1efac1592a5b7b586bc5ef373ab4549f042a27ab278ecee098fe9e89a8d6594e9600760405161030a906105c7565b6103189594939291906106e6565b6040518091039082f0905080158015610333573d5f803e3d5ffd5b50600680546001600160a01b0319166001600160a01b039290921691909117905561035e3383610538565b505050565b5f5442101561039c5760405162461bcd60e51b81526020600482015260056024820152644561726c7960d81b604482015260640161022a565b6001544211156103d75760405162461bcd60e51b815260040161022a906020808252600490820152634c61746560e01b604082015260600190565b5f6103e06101cd565b90505f600282600381106103f6576103f661075e565b01549050803410156104345760405162461bcd60e51b8152602060048201526007602482015266466565206c6f7760c81b604482015260640161022a565b335f9081526008602052604090205460ff16156104805760405162461bcd60e51b815260206004820152600a602482015269149959da5cdd195c995960b21b604482015260640161022a565b335f81815260086020526040808220805460ff191660019081179091556007805491820181559092527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68890910180546001600160a01b03191683179055517fab33ccfa0d9d1bb054440bcc605e83751e22bd200d34089bf26db58ea97c49849061050f90849088908890610772565b60405180910390a280341115610532576105323361052d8334610697565b610538565b50505050565b5f826001600160a01b0316826040515f6040518083038185875af1925050503d805f8114610581576040519150601f19603f3d011682016040523d82523d5f602084013e610586565b606091505b505090508061035e5760405162461bcd60e51b815260206004820152600d60248201526c151c985b9cd9995c8819985a5b609a1b604482015260640161022a565b61581b806107a883390190565b5f602082840312156105e4575f80fd5b5035919050565b5f80602083850312156105fc575f80fd5b82356001600160401b0380821115610612575f80fd5b818501915085601f830112610625575f80fd5b813581811115610633575f80fd5b866020828501011115610644575f80fd5b60209290920196919550909350505050565b5f60208284031215610666575f80fd5b81356001600160a01b038116811461067c575f80fd5b9392505050565b634e487b7160e01b5f52601160045260245ffd5b818103818111156106aa576106aa610683565b92915050565b5f826106ca57634e487b7160e01b5f52601260045260245ffd5b500490565b80820281158282048414176106aa576106aa610683565b5f60a0820160018060a01b038089168452602081891660208601528188166040860152818716606086015260a0608086015282865480855260c087019150875f5260205f2094505f5b8181101561074d57855485168352600195860195928401920161072f565b50909b9a5050505050505050505050565b634e487b7160e01b5f52603260045260245ffd5b83815260406020820152816040820152818360608301375f818301606090810191909152601f909201601f191601019291505056fe61018060405260405161581b38038061581b83398101604081905261002391610293565b6001600160a01b0380861660805284811660e0528216610140526040516100499061024a565b604051809103905ff080158015610062573d5f803e3d5ffd5b506001600160a01b039081166101608190529084166101005260405161008790610257565b6001600160a01b039091168152602001604051809103905ff0801580156100b0573d5f803e3d5ffd5b506001600160a01b0316610120524260a0526201518060c052678ac7230489e800006007555f60646100e334604b6103aa565b6100ed91906103c7565b5f805260126020527f7e7fa33969761a458e04f477e039a608702b4f924981d6653935a8319a08ad7b819055905061012482610146565b6101205161013b9061013683346103e6565b6101a7565b50505050505061040d565b80515f5b818110156101a257600160185f858481518110610169576101696103f9565b6020908102919091018101516001600160a01b031682528101919091526040015f20805460ff191691151591909117905560010161014a565b505050565b5f826001600160a01b0316826040515f6040518083038185875af1925050503d805f81146101f0576040519150601f19603f3d011682016040523d82523d5f602084013e6101f5565b606091505b50509050806101a25760405162461bcd60e51b815260206004820152601860248201527f513a204661696c656420746f2073656e6420616d6f756e740000000000000000604482015260640160405180910390fd5b6115e480612b3383390190565b6117048061411783390190565b80516001600160a01b038116811461027a575f80fd5b919050565b634e487b7160e01b5f52604160045260245ffd5b5f805f805f60a086880312156102a7575f80fd5b6102b086610264565b945060206102bf818801610264565b94506102cd60408801610264565b93506102db60608801610264565b60808801519093506001600160401b03808211156102f7575f80fd5b818901915089601f83011261030a575f80fd5b81518181111561031c5761031c61027f565b8060051b604051601f19603f830116810181811085821117156103415761034161027f565b60405291825284820192508381018501918c83111561035e575f80fd5b938501935b828510156103835761037485610264565b84529385019392850192610363565b8096505050505050509295509295909350565b634e487b7160e01b5f52601160045260245ffd5b80820281158282048414176103c1576103c1610396565b92915050565b5f826103e157634e487b7160e01b5f52601260045260245ffd5b500490565b818103818111156103c1576103c1610396565b634e487b7160e01b5f52603260045260245ffd5b60805160a05160c05160e051610100516101205161014051610160516126a861048b5f395f81816103510152818161090801528181610e2001526111ba01525f81816103060152611e0e01525f81816105390152611eab01525f611e7c01525f611e4a01525f61135001525f61137401525f610e9501526126a85ff3fe6080604052600436106101cd575f3560e01c80630962ef79146101d85780630ece2154146101f957806310019b3c1461023757806312ce57081461026d5780631ed6380f1461028057806328720db8146102ab5780632e17de78146102d657806337c679f7146102f55780633a5abead14610340578063436091c1146103735780634afdbdfa14610388578063572b6c051461039d5780635f5080b4146103cc578063633bf03d146103e157806368f05769146103f65780637bad72eb1461040b5780637f36ba08146104205780638796c3361461044b578063a694fc3a1461045e578063a707140b1461047d578063aabbb1bd146104a8578063ac68a748146104de578063adc0f686146104fd578063b68b5e8c14610528578063bab2f5521461055b578063bc71329014610570578063be26ed7f1461059b578063bebc9dfc146105af578063c4235ae9146105da578063ce09c18a14610605578063d4432e4e14610633578063d98de91f14610647578063db80a28c14610672578063dfcdc32f1461069d578063e3c7fa2c146106c8578063e60c90c4146106db578063ed725e8314610706578063f1b371e214610731578063f51b229414610746578063fa845ca91461075b575f80fd5b366101d457005b5f80fd5b3480156101e3575f80fd5b506101f76101f23660046123cb565b610786565b005b348015610204575f80fd5b506102246102133660046123cb565b60126020525f908152604090205481565b6040519081526020015b60405180910390f35b348015610242575f80fd5b506102246102513660046123fd565b601960209081525f928352604080842090915290825290205481565b6101f761027b3660046123fd565b6109b9565b34801561028b575f80fd5b5061022461029a366004612425565b60156020525f908152604090205481565b3480156102b6575f80fd5b506102246102c53660046123cb565b601b6020525f908152604090205481565b3480156102e1575f80fd5b506101f76102f03660046123cb565b610ca0565b348015610300575f80fd5b506103287f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161022e565b34801561034b575f80fd5b506103287f000000000000000000000000000000000000000000000000000000000000000081565b34801561037e575f80fd5b5061022460025481565b348015610393575f80fd5b5061022460075481565b3480156103a8575f80fd5b506103bc6103b7366004612425565b610e93565b604051901515815260200161022e565b3480156103d7575f80fd5b5061022460035481565b3480156103ec575f80fd5b5061022460085481565b348015610401575f80fd5b5061022460055481565b348015610416575f80fd5b5061022460065481565b34801561042b575f80fd5b5061022461043a3660046123cb565b600b6020525f908152604090205481565b6101f7610459366004612445565b610ec5565b348015610469575f80fd5b506101f76104783660046123cb565b610fca565b348015610488575f80fd5b50610224610497366004612425565b60116020525f908152604090205481565b3480156104b3575f80fd5b506102246104c23660046123fd565b601460209081525f928352604080842090915290825290205481565b3480156104e9575f80fd5b506101f76104f83660046123cb565b61121e565b348015610508575f80fd5b506102246105173660046123cb565b600f6020525f908152604090205481565b348015610533575f80fd5b506103287f000000000000000000000000000000000000000000000000000000000000000081565b348015610566575f80fd5b5061022460015481565b34801561057b575f80fd5b5061022461058a366004612425565b600e6020525f908152604090205481565b3480156105a6575f80fd5b5061022461134d565b3480156105ba575f80fd5b506102246105c93660046123cb565b60136020525f908152604090205481565b3480156105e5575f80fd5b506102246105f43660046123cb565b60106020525f908152604090205481565b348015610610575f80fd5b506103bc61061f366004612425565b60186020525f908152604090205460ff1681565b34801561063e575f80fd5b506102245f5481565b348015610652575f80fd5b506102246106613660046123cb565b601a6020525f908152604090205481565b34801561067d575f80fd5b5061022461068c366004612425565b60176020525f908152604090205481565b3480156106a8575f80fd5b506102246106b7366004612425565b600a6020525f908152604090205481565b6101f76106d6366004612425565b6113a8565b3480156106e6575f80fd5b506102246106f5366004612425565b60166020525f908152604090205481565b348015610711575f80fd5b50610224610720366004612425565b600d6020525f908152604090205481565b34801561073c575f80fd5b5061022460045481565b348015610751575f80fd5b5061022460095481565b348015610766575f80fd5b50610224610775366004612425565b600c6020525f908152604090205481565b5f5c15610791575f80fd5b60015f5d61079d6114fa565b6001546107a981611518565b5f6107b26115f6565b90506107be8183611646565b6001600160a01b0381165f90815260156020908152604080832054600d9092528220546107eb91906124c4565b90505f81116108315760405162461bcd60e51b815260206004820152600d60248201526c513a204e6f207265776172647360981b60448201526064015b60405180910390fd5b808411156108765760405162461bcd60e51b8152602060048201526012602482015271513a2045786365656473207265776172647360701b6044820152606401610828565b6001600160a01b0382165f908152600d60205260408120805486929061089d9084906124c4565b9091555050600454600254036108c9578360055f8282546108be91906124d7565b909155506108f19050565b5f838152601060205260409020546108e29085906124c4565b5f848152601060205260409020555b604051634d24848760e11b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639a49090e9061093f90859088906004016124ea565b5f604051808303815f87803b158015610956575f80fd5b505af1158015610968573d5f803e3d5ffd5b50505050816001600160a01b0316837f3300bdb359cfb956935bca32e9db727413eab1ca84341f2e36caea85bb796968866040516109a891815260200190565b60405180910390a35050505f805d50565b5f5c156109c4575f80fd5b60015f5d5f5a905069fe1c215e8f838e0000006008541115610a1d5760405162461bcd60e51b8152602060048201526012602482015271144e88115b9919d85b59481c995858da195960721b6044820152606401610828565b6064821115610a5b5760405162461bcd60e51b815260206004820152600a6024820152690513a204d6178203130360b41b6044820152606401610828565b5f8211610a955760405162461bcd60e51b8152602060048201526008602482015267513a204d696e203160c01b6044820152606401610828565b6001600160a01b0383165f9081526018602052604090205460ff16610af05760405162461bcd60e51b8152602060048201526011602482015270144e88139bdd081c9959da5cdd195c9959607a1b6044820152606401610828565b610af86114fa565b600154610b0481611518565b610b0d81611bd1565b5f610b1784611cc9565b905080341015610b5a5760405162461bcd60e51b815260206004820152600e60248201526d513a2056616c7565203c2066656560901b6044820152606401610828565b5f610b636115f6565b9050610b6f8184611646565b610b798684611646565b610b8585848884611d08565b6001546001600160a01b038083165f908152600c60205260408082208490559189168152908120919091556009805491610bbe83612503565b9190505550610bcd8284611dcf565b81341115610be857610be833610be384346124c4565b611ed7565b806001600160a01b03167ffa46cc39fc3a7bafc0f46b0272961643c81ac5016927080d397f7f0055d856fd86604051610c2391815260200190565b60405180910390a25050505f5a610c3a90836124c4565b610c46906178ac6124d7565b90505f610c53488361251b565b905080601b5f60015481526020019081526020015f205f828254610c7791906124d7565b925050819055508060085f828254610c8f91906124d7565b925050819055505050505f805d5050565b5f5c15610cab575f80fd5b60015f5d610cb76114fa565b6001545f610cc36115f6565b9050610cce82611518565b610cd88183611646565b5f8311610cf75760405162461bcd60e51b815260040161082890612532565b6001600160a01b0381165f90815260156020526040902054831115610d705760405162461bcd60e51b815260206004820152602960248201527f513a20416d6f756e742067726561746572207468616e20776974686472617761604482015268626c65207374616b6560b81b6064820152608401610828565b60045460025403610d97578260055f828254610d8c91906124d7565b90915550610dba9050565b5f8281526010602052604081208054859290610db49084906124c4565b90915550505b6001600160a01b0381165f9081526015602052604081208054859290610de19084906124c4565b90915550506001600160a01b0381165f908152600d602052604081208054859290610e0d9084906124c4565b90915550610e4790506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168285611f71565b806001600160a01b0316827f37375b03d8924bd8f076f11f8411b9962aa5c02fb489021507bc6bb6f850e36585604051610e8391815260200190565b60405180910390a350505f805d50565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b60075434811115610ed4575f80fd5b5f610edd6115f6565b6001600160a01b0381165f9081526018602052604090205490915060ff1615610f3b5760405162461bcd60e51b815260206004820152601060248201526f144e881052481c9959da5cdd195c995960821b6044820152606401610828565b6001600160a01b0381165f908152601860205260409020805460ff1916600117905534821015610f7357610f7333610be384346124c4565b610f7f82600454611dcf565b806001600160a01b03167f692d99e6f9b3cb9e93a6d75f83ec4e52e60504a0763720ab8e639060da38b932858585604051610fbc9392919061255d565b60405180910390a250505050565b5f5c15610fd5575f80fd5b60015f5d610fe16114fa565b6001545f610fed6115f6565b9050610ff882611518565b6110028183611646565b5f83116110215760405162461bcd60e51b815260040161082890612532565b600454821461107c5760405162461bcd60e51b815260206004820152602160248201527f513a204f6e6c79207374616b6520647572696e6720616374697665206379636c6044820152606560f81b6064820152608401610828565b825f8082825461108c91906124d7565b909155505f905061109e8360016124d7565b9050600454600254036110bc576002546110b99060016124d7565b90505b6001600160a01b0382165f9081526016602052604090205481148015906110fa57506001600160a01b0382165f908152601760205260409020548114155b15611175576001600160a01b0382165f90815260166020526040812054900361113c576001600160a01b0382165f908152601660205260409020819055611175565b6001600160a01b0382165f908152601760205260408120549003611175576001600160a01b0382165f9081526017602052604090208190555b6001600160a01b0382165f908152601460209081526040808320848452909152812080548692906111a79084906124d7565b909155506111e290506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016833087611fc7565b816001600160a01b0316817f18dcd430020e4d4899772fd94a8b40451dc5044dfb70bc46b532eeae431c864f866040516109a891815260200190565b5f5c15611229575f80fd5b60015f5d6112356114fa565b6001545f6112416115f6565b905061124c82611518565b6112568183611646565b6001600160a01b0381165f908152600e60205260409020548061128b5760405162461bcd60e51b815260040161082890612532565b808411156112da5760405162461bcd60e51b815260206004820152601c60248201527b513a20436c61696d20616d6f756e742065786365656473206665657360201b6044820152606401610828565b6001600160a01b0382165f908152600e6020526040812080548692906113019084906124c4565b9091555061131190508285611ed7565b816001600160a01b0316837f2227733fc4c8a9034cb58087dcf6995128b9c0233b038b03366aaf30c92b92d6866040516109a891815260200190565b5f7f00000000000000000000000000000000000000000000000000000000000000006113997f0000000000000000000000000000000000000000000000000000000000000000426124c4565b6113a39190612594565b905090565b6004546001600160a01b0382165f9081526019602090815260408083208484529091528120546113d99034906124d7565b905067016345785d8a000081101561143d5760405162461bcd60e51b815260206004820152602160248201527f513a204d696e2e207468726573686f6c642062616c616e6365206e6f74206d656044820152601d60fa1b6064820152608401610828565b6001600160a01b0383165f9081526019602090815260408083208584529091528120805434929061146f9084906124d7565b90915550505f828152601a60205260409020548082108061148e575080155b156114a4575f838152601a602052604090208290555b6114ae3484611dcf565b60408051348152602081018590526001600160a01b0386169133917f031820cb503f016de565e43728c74cb9df7177ba8789df22781cab0a4ec10dc0910160405180910390a350505050565b5f61150361134d565b90506001548111156115155760018190555b50565b600454811461152e576002805460035560045490555b600254808211801561155a575060135f6115498360016124d7565b81526020019081526020015f20545f145b156115f25761156881611fff565b5f81815260106020908152604080832054601290925282205461159b906b1d6329f1c35ca4bfabb9f56160281b9061251b565b6115a59190612594565b90508060135f60035460016115ba91906124d7565b81526020019081526020015f20546115d291906124d7565b60135f6115e08560016124d7565b815260208101919091526040015f2055505b5050565b5f36601461160333610e93565b801561160f5750808210155b1561163e575f3661162083856124c4565b61162b9282906125b3565b611634916125da565b60601c9250505090565b339250505090565b6001600160a01b0382165f908152600c60205260409020548111801561168257506001600160a01b0382165f908152600a602052604090205415155b15611722576001600160a01b0382165f818152600c60209081526040808320548352600b825280832054600f835281842054948452600a909252822054919290916116cd919061251b565b6116d79190612594565b6001600160a01b0384165f908152600d60205260408120805492935083929091906117039084906124d7565b9091555050506001600160a01b0382165f908152600a60205260408120555b5f600254600161173291906124d7565b90506002548211801561175c57506001600160a01b0383165f908152601160205260409020548114155b1561181c576001600160a01b0383165f9081526011602090815260408083205483526013909152808220548383529120546b1d6329f1c35ca4bfabb9f56160281b916117a7916124c4565b6001600160a01b0385165f908152600d60205260409020546117c9919061251b565b6117d39190612594565b6001600160a01b0384165f908152600e60205260409020546117f591906124d7565b6001600160a01b0384165f908152600e602090815260408083209390935560119052208190555b6001600160a01b0383165f908152601660205260409020541580159061185857506001600160a01b0383165f9081526016602052604090205482115b15611bcc576001600160a01b0383165f81815260146020908152604080832060168352818420548452825280832054938352600d909152812080548392906118a19084906124d7565b90915550506001600160a01b0384165f90815260156020526040812080548392906118cd9084906124d7565b90915550506001600160a01b0384165f908152601660205260409020548211156119b0576001600160a01b0384165f9081526016602090815260408083205483526013909152808220548483529120546b1d6329f1c35ca4bfabb9f56160281b91611937916124c4565b6001600160a01b0386165f9081526014602090815260408083206016835281842054845290915290205461196b919061251b565b6119759190612594565b6001600160a01b0385165f908152600e602052604090205461199791906124d7565b6001600160a01b0385165f908152600e60205260409020555b6001600160a01b0384165f81815260146020908152604080832060168352818420805485529083528184208490559383529282905560179052205415611bca576001600160a01b0384165f90815260176020526040902054831115611b9e576001600160a01b0384165f81815260146020908152604080832060178352818420548452825280832054938352600d90915281208054839290611a539084906124d7565b90915550506001600160a01b0385165f9081526015602052604081208054839290611a7f9084906124d7565b90915550506001600160a01b0385165f90815260176020526040902054831115611b62576001600160a01b0385165f9081526017602090815260408083205483526013909152808220548583529120546b1d6329f1c35ca4bfabb9f56160281b91611ae9916124c4565b6001600160a01b0387165f90815260146020908152604080832060178352818420548452909152902054611b1d919061251b565b611b279190612594565b6001600160a01b0386165f908152600e6020526040902054611b4991906124d7565b6001600160a01b0386165f908152600e60205260409020555b506001600160a01b0384165f81815260146020908152604080832060178084528285208054865291845291842084905593835290529055611bca565b6001600160a01b0384165f90815260176020818152604080842080546016845291852091909155919052555b505b505050565b600454811461151557611be26120a4565b60048190555f600981905560025481526010602052604080822054838352908220805491929091611c149084906124d7565b90915550505f5415611c49575f8054828252601060205260408220805491929091611c409084906124d7565b90915550505f80555b60055415611c7b576005545f8281526010602052604081208054909190611c719084906124c4565b90915550505f6005555b807f2ee63a65823306caa71f76a6f1fbc130f9932419aca12e4bc61488794c0fe84260105f8481526020019081526020015f2054604051611cbe91815260200190565b60405180910390a250565b5f6103e86009546103e8611cdd91906124d7565b611cee84662386f26fc1000061251b565b611cf8919061251b565b611d029190612594565b92915050565b5f611d1383856120fb565b90506001811115611d2b57611d28818661251b565b94505b611d3685606461251b565b5f858152600b602052604081208054909190611d539084906124d7565b90915550611d64905085605f61251b565b6001600160a01b0383165f908152600a602052604081208054909190611d8b9084906124d7565b90915550611d9c905085600561251b565b6001600160a01b0384165f908152600a602052604081208054909190611dc39084906124d7565b90915550505050505050565b6064611ddc83604661251b565b611de69190612594565b5f8281526012602052604081208054909190611e039084906124d7565b90915550611e4590507f00000000000000000000000000000000000000000000000000000000000000006103e8611e3b85600261251b565b610be39190612594565b611e777f00000000000000000000000000000000000000000000000000000000000000006103e8611e3b85602661251b565b611ea67f0000000000000000000000000000000000000000000000000000000000000000610be3606485612594565b6115f27f00000000000000000000000000000000000000000000000000000000000000006064611e3b85601961251b565b5f826001600160a01b0316826040515f6040518083038185875af1925050503d805f8114611f20576040519150601f19603f3d011682016040523d82523d5f602084013e611f25565b606091505b5050905080611bcc5760405162461bcd60e51b8152602060048201526018602482015277144e8811985a5b1959081d1bc81cd95b9908185b5bdd5b9d60421b6044820152606401610828565b611bcc8363a9059cbb60e01b8484604051602401611f909291906124ea565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261216e565b6040516001600160a01b0380851660248301528316604482015260648101829052611bca9085906323b872dd60e01b90608401611f90565b6006545f828152601b6020526040812054909160c89161201f919061251b565b6120299190612594565b5f838152601b602052604090205461204290606461251b565b61204c91906124c4565b5f838152600f60209081526040808320849055601090915281208054929350839290919061207b9084906124d7565b9091555050600654614e1f11156115f25760068054905f61209b83612503565b91905055505050565b674563918244f4000060075411156120f9575f6127246007546127106120ca919061251b565b6120d49190612594565b9050674563918244f400008110156120f557674563918244f4000060075550565b6007555b565b6002546001600160a01b0383165f908152601960209081526040808320848452909152812054909190801580159061213257508315155b15612161575f828152601a602052604090205461215082600261251b565b61215a9190612594565b9250612166565b600192505b505092915050565b5f6121c2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166122419092919063ffffffff16565b905080515f14806121e25750808060200190518101906121e29190612608565b611bcc5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610828565b606061224f84845f85612257565b949350505050565b6060824710156122b85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610828565b5f80866001600160a01b031685876040516122d39190612627565b5f6040518083038185875af1925050503d805f811461230d576040519150601f19603f3d011682016040523d82523d5f602084013e612312565b606091505b50915091506123238783838761232e565b979650505050505050565b6060831561239c5782515f03612395576001600160a01b0385163b6123955760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610828565b508161224f565b61224f83838151156123b15781518083602001fd5b8060405162461bcd60e51b8152600401610828919061263d565b5f602082840312156123db575f80fd5b5035919050565b80356001600160a01b03811681146123f8575f80fd5b919050565b5f806040838503121561240e575f80fd5b612417836123e2565b946020939093013593505050565b5f60208284031215612435575f80fd5b61243e826123e2565b9392505050565b5f8060208385031215612456575f80fd5b82356001600160401b038082111561246c575f80fd5b818501915085601f83011261247f575f80fd5b81358181111561248d575f80fd5b86602082850101111561249e575f80fd5b60209290920196919550909350505050565b634e487b7160e01b5f52601160045260245ffd5b81810381811115611d0257611d026124b0565b80820180821115611d0257611d026124b0565b6001600160a01b03929092168252602082015260400190565b5f60018201612514576125146124b0565b5060010190565b8082028115828204841417611d0257611d026124b0565b602080825260119082015270513a20416d6f756e74206973207a65726f60781b604082015260600190565b60408152826040820152828460608301375f606084830101525f6060601f19601f8601168301019050826020830152949350505050565b5f826125ae57634e487b7160e01b5f52601260045260245ffd5b500490565b5f80858511156125c1575f80fd5b838611156125cd575f80fd5b5050820193919092039150565b6001600160601b031981358181169160148510156121665760149490940360031b84901b1690921692915050565b5f60208284031215612618575f80fd5b8151801515811461243e575f80fd5b5f82518060208501845e5f920191825250919050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f8301168401019150509291505056fea264697066735822122085460eab68e9de9774f82431c6f4ebc1f46dc8465fa59728222a7158bd1a8d4964736f6c63430008190033610180604052348015610010575f80fd5b506040518060400160405280600781526020016628902a37b5b2b760c91b81525080604051806040016040528060018152602001603160f81b8152506040518060400160405280600781526020016628902a37b5b2b760c91b815250604051806040016040528060018152602001605160f81b81525081600390816100959190610271565b5060046100a28282610271565b506100b291508390506005610161565b610120526100c1816006610161565b61014052815160208084019190912060e052815190820120610100524660a05261014d60e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b60805250503060c052503361016052610388565b5f60208351101561017c5761017583610193565b905061018d565b816101878482610271565b5060ff90505b92915050565b5f80829050601f815111156101c6578260405163305a27a960e01b81526004016101bd9190610330565b60405180910390fd5b80516101d182610365565b179392505050565b634e487b7160e01b5f52604160045260245ffd5b600181811c9082168061020157607f821691505b60208210810361021f57634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561026c57805f5260205f20601f840160051c8101602085101561024a5750805b601f840160051c820191505b81811015610269575f8155600101610256565b50505b505050565b81516001600160401b0381111561028a5761028a6101d9565b61029e8161029884546101ed565b84610225565b602080601f8311600181146102d1575f84156102ba5750858301515b5f19600386901b1c1916600185901b178555610328565b5f85815260208120601f198616915b828110156102ff578886015182559484019460019091019084016102e0565b508582101561031c57878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b8051602080830151919081101561021f575f1960209190910360031b1b16919050565b60805160a05160c05160e051610100516101205161014051610160516112016103e35f395f6103da01525f61037101525f61034601525f610abb01525f610a9301525f6109ee01525f610a1801525f610a4201526112015ff3fe608060405234801561000f575f80fd5b50600436106100ce575f3560e01c806306fdde03146100d2578063095ea7b3146100f057806318160ddd1461011357806323b872dd14610125578063313ce567146101385780633644e51514610147578063395093511461014f57806370a08231146101625780637ecebe001461018a57806384b0196e1461019d57806395d89b41146101b85780639a49090e146101c0578063a457c2d7146101d5578063a9059cbb146101e8578063d505accf146101fb578063dd62ed3e1461020e575b5f80fd5b6100da610221565b6040516100e79190610f63565b60405180910390f35b6101036100fe366004610f97565b6102b1565b60405190151581526020016100e7565b6002545b6040519081526020016100e7565b610103610133366004610fbf565b6102ca565b604051601281526020016100e7565b6101176102ed565b61010361015d366004610f97565b6102fb565b610117610170366004610ff8565b6001600160a01b03165f9081526020819052604090205490565b610117610198366004610ff8565b61031c565b6101a5610339565b6040516100e79796959493929190611011565b6100da6103c0565b6101d36101ce366004610f97565b6103cf565b005b6101036101e3366004610f97565b6104a6565b6101036101f6366004610f97565b610520565b6101d36102093660046110a8565b61052d565b61011761021c366004611115565b61068e565b60606003805461023090611146565b80601f016020809104026020016040519081016040528092919081815260200182805461025c90611146565b80156102a75780601f1061027e576101008083540402835291602001916102a7565b820191905f5260205f20905b81548152906001019060200180831161028a57829003601f168201915b5050505050905090565b5f336102be8185856106b8565b60019150505b92915050565b5f336102d78582856107db565b6102e2858585610853565b506001949350505050565b5f6102f66109e2565b905090565b5f336102be81858561030d838361068e565b6103179190611178565b6106b8565b6001600160a01b0381165f908152600760205260408120546102c4565b5f6060808280808361036c7f00000000000000000000000000000000000000000000000000000000000000006005610b0b565b6103977f00000000000000000000000000000000000000000000000000000000000000006006610b0b565b604080515f80825260208201909252600f60f81b9b939a50919850469750309650945092509050565b60606004805461023090611146565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146104425760405162461bcd60e51b8152602060048201526013602482015272289d1024b731b7b93932b1ba1031b0b63632b960691b60448201526064015b60405180910390fd5b6a6342fd08f00f637800000061045760025490565b106104985760405162461bcd60e51b8152602060048201526011602482015270144e88105b1c9958591e481b5a5b9d1959607a1b6044820152606401610439565b6104a28282610bb4565b5050565b5f33816104b3828661068e565b9050838110156105135760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610439565b6102e282868684036106b8565b5f336102be818585610853565b8342111561057d5760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610439565b5f7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886105ab8c610c5e565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090505f61060582610c85565b90505f61061482878787610cb1565b9050896001600160a01b0316816001600160a01b0316146106775760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610439565b6106828a8a8a6106b8565b50505050505050505050565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b6001600160a01b03831661071a5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610439565b6001600160a01b03821661077b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610439565b6001600160a01b038381165f8181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b5f6107e6848461068e565b90505f19811461084d57818110156108405760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610439565b61084d84848484036106b8565b50505050565b6001600160a01b0383166108b75760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610439565b6001600160a01b0382166109195760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610439565b6001600160a01b0383165f90815260208190526040902054818110156109905760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610439565b6001600160a01b038481165f81815260208181526040808320878703905593871680835291849020805487019055925185815290925f805160206111ac833981519152910160405180910390a361084d565b5f306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015610a3a57507f000000000000000000000000000000000000000000000000000000000000000046145b15610a6457507f000000000000000000000000000000000000000000000000000000000000000090565b6102f6604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b606060ff8314610b2557610b1e83610cd7565b90506102c4565b818054610b3190611146565b80601f0160208091040260200160405190810160405280929190818152602001828054610b5d90611146565b8015610ba85780601f10610b7f57610100808354040283529160200191610ba8565b820191905f5260205f20905b815481529060010190602001808311610b8b57829003601f168201915b505050505090506102c4565b6001600160a01b038216610c0a5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610439565b8060025f828254610c1b9190611178565b90915550506001600160a01b0382165f81815260208181526040808320805486019055518481525f805160206111ac833981519152910160405180910390a35050565b6001600160a01b0381165f9081526007602052604090208054600181018255905b50919050565b5f6102c4610c916109e2565b8360405161190160f01b8152600281019290925260228201526042902090565b5f805f610cc087878787610d14565b91509150610ccd81610dc7565b5095945050505050565b60605f610ce383610f0e565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b5f806fa2a8918ca85bafe22016d0b997e4df60600160ff1b03831115610d3f57505f90506003610dbe565b604080515f8082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015610d90573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b038116610db8575f60019250925050610dbe565b91505f90505b94509492505050565b5f816004811115610dda57610dda611197565b03610de25750565b6001816004811115610df657610df6611197565b03610e3e5760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b6044820152606401610439565b6002816004811115610e5257610e52611197565b03610e9f5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610439565b6003816004811115610eb357610eb3611197565b03610f0b5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610439565b50565b5f60ff8216601f8111156102c457604051632cd44ac360e21b815260040160405180910390fd5b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f610f756020830184610f35565b9392505050565b80356001600160a01b0381168114610f92575f80fd5b919050565b5f8060408385031215610fa8575f80fd5b610fb183610f7c565b946020939093013593505050565b5f805f60608486031215610fd1575f80fd5b610fda84610f7c565b9250610fe860208501610f7c565b9150604084013590509250925092565b5f60208284031215611008575f80fd5b610f7582610f7c565b60ff60f81b881681525f602060e0602084015261103160e084018a610f35565b8381036040850152611043818a610f35565b606085018990526001600160a01b038816608086015260a0850187905284810360c0860152855180825260208088019350909101905f5b818110156110965783518352928401929184019160010161107a565b50909c9b505050505050505050505050565b5f805f805f805f60e0888a0312156110be575f80fd5b6110c788610f7c565b96506110d560208901610f7c565b95506040880135945060608801359350608088013560ff811681146110f8575f80fd5b9699959850939692959460a0840135945060c09093013592915050565b5f8060408385031215611126575f80fd5b61112f83610f7c565b915061113d60208401610f7c565b90509250929050565b600181811c9082168061115a57607f821691505b602082108103610c7f57634e487b7160e01b5f52602260045260245ffd5b808201808211156102c457634e487b7160e01b5f52601160045260245ffd5b634e487b7160e01b5f52602160045260245ffdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220c22e871721421ab8743f1837744003fc3fc896fa7d8b1c452a9c5a133c6d1f0864736f6c6343000819003360c060405234801561000f575f80fd5b5060405161170438038061170483398101604081905261002e916101e1565b425f5561005273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc282612710610069565b6001600160a01b0390811660a0521660805261020e565b5f805f846001600160a01b0316866001600160a01b03161061008c57848661008f565b85855b604080516060810182526001600160a01b0380851682528316602082015262ffffff88169181019190915291935091506100dd731f98431c8ad98523631ae4a59f267346ea31f984826100e8565b979650505050505050565b5f81602001516001600160a01b0316825f01516001600160a01b03161061010d575f80fd5b815160208084015160408086015181516001600160a01b0395861681860152949092168482015262ffffff90911660608085019190915281518085038201815260808501909252815191909201207fff0000000000000000000000000000000000000000000000000000000000000060a08401529085901b6001600160601b03191660a183015260b58201527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d582015260f50160408051601f1981840301815291905280516020909101209392505050565b5f602082840312156101f1575f80fd5b81516001600160a01b0381168114610207575f80fd5b9392505050565b60805160a0516114c761023d5f395f81816102c4015261063001525f818161067501526107c701526114c75ff3fe608060405260043610610078575f3560e01c806309c2bc96146100cc57806355ecf5a81461010f578063802c6ee5146101465780638225b247146101695780638bd95563146101885780638fe075961461019c578063b70872e6146101bb578063bdc639bc146101d0578063be26ed7f146101e5575f80fd5b366100c8575f5461008c9062015180610fe4565b4210156100af573460015f8282546100a49190610fe4565b909155506100c69050565b3460035f8282546100c09190610fe4565b90915550505b005b5f80fd5b3480156100d7575f80fd5b506100fa6100e6366004610ffd565b60046020525f908152604090205460ff1681565b60405190151581526020015b60405180910390f35b34801561011a575f80fd5b5061012e61012936600461102b565b6101f9565b6040516001600160a01b039091168152602001610106565b348015610151575f80fd5b5061015b60035481565b604051908152602001610106565b348015610174575f80fd5b506100c661018336600461107a565b610283565b348015610193575f80fd5b5061015b5f5481565b3480156101a7575f80fd5b5061015b6101b636600461109a565b610629565b3480156101c6575f80fd5b5061015b60015481565b3480156101db575f80fd5b5061015b60025481565b3480156101f0575f80fd5b5061015b610699565b5f805f846001600160a01b0316866001600160a01b03161061021c57848661021f565b85855b915091505f6040518060600160405280846001600160a01b03168152602001836001600160a01b031681526020018662ffffff168152509050610276731f98431c8ad98523631ae4a59f267346ea31f984826106ba565b93505050505b9392505050565b3332146102c25760405162461bcd60e51b815260206004820152600860248201526755736520454f412160c01b60448201526064015b60405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000003b63ffffffff1661032d5760405162461bcd60e51b8152602060048201526014602482015273506f6f6c20646f6573206e6f742065786973742160601b60448201526064016102b9565b5f5461033c9062015180610fe4565b42116103785760405162461bcd60e51b815260206004820152600b60248201526a4561726c79206275726e2160a81b60448201526064016102b9565b67016345785d8a00008210156103be5760405162461bcd60e51b815260206004820152600b60248201526a09ad2dc40605c62408aa8960ab1b60448201526064016102b9565b5f60326001546103ce91906110d4565b6003549091505f6103dd610699565b90505f80603260025410801561040157505f8381526004602052604090205460ff16155b156104db57846003546104149190610fe4565b9350868410156104365760405162461bcd60e51b81526004016102b9906110e7565b8660035410610467578660035f8282546104509190611114565b9091555061046090508588610fe4565b96506104aa565b848711156104a6576104798588611114565b600354106104a15761048b8588611114565b60035f82825461049b9190611114565b90915550505b6104aa565b8496505b60028054905f6104b983611127565b90915550505f838152600460205260409020805460ff19166001179055610512565b868410156104fb5760405162461bcd60e51b81526004016102b9906110e7565b8660035f82825461050c9190611114565b90915550505b61051d6064886110d4565b90506105298188611114565b91505f61053583610629565b90505f606461054583605a61113f565b61054f91906110d4565b90505f811161058a5760405162461bcd60e51b815260206004820152600760248201526604d696e203e20360cc1b60448201526064016102b9565b61059581858a61079b565b6040515f90339085908381818185875af1925050503d805f81146105d4576040519150601f19603f3d011682016040523d82523d5f602084013e6105d9565b606091505b505090508061061d5760405162461bcd60e51b815260206004820152601060248201526f2a3930b739b332b9103330b4b632b21760811b60448201526064016102b9565b50505050505050505050565b5f806106567f000000000000000000000000000000000000000000000000000000000000000060016108d7565b50905061027c818473c02aaa39b223fe8d0a0e5c4f27ead9083c756cc27f0000000000000000000000000000000000000000000000000000000000000000610b10565b5f620151805f54426106ab9190611114565b6106b591906110d4565b905090565b5f81602001516001600160a01b0316825f01516001600160a01b0316106106df575f80fd5b815160208084015160408086015181516001600160a01b0395861681860152949092168482015262ffffff90911660608085019190915281518085038201815260808501909252815191909201206001600160f81b031960a08401529085901b6001600160601b03191660a183015260b58201527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d582015260f50160408051601f1981840301815291905280516020909101209392505050565b604080516101008101825273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166020830190815261271083850190815261dead606085019081526080850187815260a0860189815260c087018b81525f60e08901908152985163414bf38960e01b8152885188166004820152955187166024870152935162ffffff1660448601529151851660648501525160848401525160a48301525160c482015292511660e48301529073e592427a0aece92de3edee1f18e0157c058615649063414bf3899085906101040160206040518083038185885af11580156108ab573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906108d09190611156565b5050505050565b5f808263ffffffff165f036109135760405162461bcd60e51b8152602060048201526002602482015261042560f41b60448201526064016102b9565b6040805160028082526060820183525f9260208301908036833701905050905083815f8151811061094657610946611181565b602002602001019063ffffffff16908163ffffffff16815250505f8160018151811061097457610974611181565b602002602001019063ffffffff16908163ffffffff16815250505f80866001600160a01b031663883bdbfd846040518263ffffffff1660e01b81526004016109bc9190611195565b5f60405180830381865afa1580156109d6573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526109fd91908101906112a5565b915091505f825f81518110610a1457610a14611181565b602002602001015183600181518110610a2f57610a2f611181565b6020026020010151610a419190611368565b90505f825f81518110610a5657610a56611181565b602002602001015183600181518110610a7157610a71611181565b6020026020010151610a839190611395565b9050610a9563ffffffff8916836113bc565b96505f8260060b128015610aba5750610ab463ffffffff8916836113f8565b60060b15155b15610acd5786610ac981611419565b9750505b5f610ae56001600160a01b0363ffffffff8b1661143a565b9050610b01600160201b600160c01b03602084901b168261146c565b96505050505050509250929050565b5f80610b1b86610c16565b90506001600160801b036001600160a01b03821611610ba0575f610b486001600160a01b0383168061113f565b9050836001600160a01b0316856001600160a01b031610610b8057610b7b600160c01b876001600160801b031683610f26565b610b98565b610b9881876001600160801b0316600160c01b610f26565b925050610c0d565b5f610bb96001600160a01b03831680600160401b610f26565b9050836001600160a01b0316856001600160a01b031610610bf157610bec600160801b876001600160801b031683610f26565b610c09565b610c0981876001600160801b0316600160801b610f26565b9250505b50949350505050565b5f805f8360020b12610c2b578260020b610c32565b8260020b5f035b9050620d89e8811115610c58576040516315e4079d60e11b815260040160405180910390fd5b5f816001165f03610c6d57600160801b610c7f565b6ffffcb933bd6fad37aa2d162d1a5940015b6001600160881b031690506002821615610ca9576ffff97272373d413259a46990580e213a0260801c5b6004821615610cc8576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615610ce7576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615610d06576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615610d25576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615610d44576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615610d63576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615610d83576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615610da3576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615610dc3576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615610de3576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615610e03576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615610e23576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615610e43576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615610e63576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615610e84576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615610ea4576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615610ec3576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615610ee0576b048a170391f7dc42444e8fa20260801c5b5f8460020b1315610eff57805f1981610efb57610efb6110c0565b0490505b600160201b810615610f12576001610f14565b5f5b60ff16602082901c0192505050919050565b5f80805f19858709858702925082811083820303915050805f03610f5a575f8411610f4f575f80fd5b50829004905061027c565b808411610f65575f80fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b634e487b7160e01b5f52601160045260245ffd5b80820180821115610ff757610ff7610fd0565b92915050565b5f6020828403121561100d575f80fd5b5035919050565b6001600160a01b0381168114611028575f80fd5b50565b5f805f6060848603121561103d575f80fd5b833561104881611014565b9250602084013561105881611014565b9150604084013562ffffff8116811461106f575f80fd5b809150509250925092565b5f806040838503121561108b575f80fd5b50508035926020909101359150565b5f602082840312156110aa575f80fd5b81356001600160801b038116811461027c575f80fd5b634e487b7160e01b5f52601260045260245ffd5b5f826110e2576110e26110c0565b500490565b602080825260139082015272496e73756666696369656e742066756e64732160681b604082015260600190565b81810381811115610ff757610ff7610fd0565b5f6001820161113857611138610fd0565b5060010190565b8082028115828204841417610ff757610ff7610fd0565b5f60208284031215611166575f80fd5b5051919050565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b602080825282518282018190525f9190848201906040850190845b818110156111d257835163ffffffff16835292840192918401916001016111b0565b50909695505050505050565b604051601f8201601f191681016001600160401b03811182821017156112065761120661116d565b604052919050565b5f6001600160401b038211156112265761122661116d565b5060051b60200190565b5f82601f83011261123f575f80fd5b8151602061125461124f8361120e565b6111de565b8083825260208201915060208460051b870101935086841115611275575f80fd5b602086015b8481101561129a57805161128d81611014565b835291830191830161127a565b509695505050505050565b5f80604083850312156112b6575f80fd5b82516001600160401b03808211156112cc575f80fd5b818501915085601f8301126112df575f80fd5b815160206112ef61124f8361120e565b82815260059290921b8401810191818101908984111561130d575f80fd5b948201945b838610156113395785518060060b811461132a575f80fd5b82529482019490820190611312565b91880151919650909350505080821115611351575f80fd5b5061135e85828601611230565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff82131715610ff757610ff7610fd0565b6001600160a01b038281168282160390808211156113b5576113b5610fd0565b5092915050565b5f8160060b8360060b806113d2576113d26110c0565b667fffffffffffff1982145f19821416156113ef576113ef610fd0565b90059392505050565b5f8260060b8061140a5761140a6110c0565b808360060b0791505092915050565b5f8160020b627fffff19810361143157611431610fd0565b5f190192915050565b6001600160c01b0382811682821681810283169291811582850482141761146357611463610fd0565b50505092915050565b5f6001600160c01b0383811680611485576114856110c0565b9216919091049291505056fea264697066735822122043b7cbc864d2a2bc0e7cf6b8e190075c230a223b9a7de607cd250c85d679014164736f6c63430008190033a2646970667358221220e2c5e443241009dabe9337b743e91caf880417cdcb5ec99ccc7336d90c049b6b64736f6c63430008190033000000000000000000000000783223a9851566db1a4eeba72fa1329ea3144b8d

Deployed Bytecode

0x608060405260043610610075575f3560e01c80633197cbb6146100795780636827e764146100a157806368d2b77b146100d85780636b63f18c146100f757806378e9792514610116578063acbe654a1461012a578063b2c884e81461013e578063c84db92914610154578063ce24c74714610167575b5f80fd5b348015610084575f80fd5b5061008e60015481565b6040519081526020015b60405180910390f35b3480156100ac575f80fd5b506005546100c0906001600160a01b031681565b6040516001600160a01b039091168152602001610098565b3480156100e3575f80fd5b506006546100c0906001600160a01b031681565b348015610102575f80fd5b506100c06101113660046105d4565b6101a5565b348015610121575f80fd5b5061008e5f5481565b348015610135575f80fd5b5061008e6101cd565b348015610149575f80fd5b506101526101ee565b005b6101526101623660046105eb565b610363565b348015610172575f80fd5b50610195610181366004610656565b60086020525f908152604090205460ff1681565b6040519015158152602001610098565b600781815481106101b4575f80fd5b5f918252602090912001546001600160a01b0316905081565b5f620151805f54426101df9190610697565b6101e991906106b0565b905090565b60015442116102335760405162461bcd60e51b815260206004820152600c60248201526b4561726c79206465706c6f7960a01b60448201526064015b60405180910390fd5b6006546001600160a01b03161561027f5760405162461bcd60e51b815260206004820152601060248201526f105b1c9958591e4819195c1b1bde595960821b604482015260640161022a565b475f606461028e83600a6106cf565b61029891906106b0565b90505f6102a58284610697565b90508073b2b5841dbef766d4b521221732f9b618fcf34a8760055f9054906101000a90046001600160a01b0316738ff4596cdad4f8b1e1efac1592a5b7b586bc5ef373ab4549f042a27ab278ecee098fe9e89a8d6594e9600760405161030a906105c7565b6103189594939291906106e6565b6040518091039082f0905080158015610333573d5f803e3d5ffd5b50600680546001600160a01b0319166001600160a01b039290921691909117905561035e3383610538565b505050565b5f5442101561039c5760405162461bcd60e51b81526020600482015260056024820152644561726c7960d81b604482015260640161022a565b6001544211156103d75760405162461bcd60e51b815260040161022a906020808252600490820152634c61746560e01b604082015260600190565b5f6103e06101cd565b90505f600282600381106103f6576103f661075e565b01549050803410156104345760405162461bcd60e51b8152602060048201526007602482015266466565206c6f7760c81b604482015260640161022a565b335f9081526008602052604090205460ff16156104805760405162461bcd60e51b815260206004820152600a602482015269149959da5cdd195c995960b21b604482015260640161022a565b335f81815260086020526040808220805460ff191660019081179091556007805491820181559092527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68890910180546001600160a01b03191683179055517fab33ccfa0d9d1bb054440bcc605e83751e22bd200d34089bf26db58ea97c49849061050f90849088908890610772565b60405180910390a280341115610532576105323361052d8334610697565b610538565b50505050565b5f826001600160a01b0316826040515f6040518083038185875af1925050503d805f8114610581576040519150601f19603f3d011682016040523d82523d5f602084013e610586565b606091505b505090508061035e5760405162461bcd60e51b815260206004820152600d60248201526c151c985b9cd9995c8819985a5b609a1b604482015260640161022a565b61581b806107a883390190565b5f602082840312156105e4575f80fd5b5035919050565b5f80602083850312156105fc575f80fd5b82356001600160401b0380821115610612575f80fd5b818501915085601f830112610625575f80fd5b813581811115610633575f80fd5b866020828501011115610644575f80fd5b60209290920196919550909350505050565b5f60208284031215610666575f80fd5b81356001600160a01b038116811461067c575f80fd5b9392505050565b634e487b7160e01b5f52601160045260245ffd5b818103818111156106aa576106aa610683565b92915050565b5f826106ca57634e487b7160e01b5f52601260045260245ffd5b500490565b80820281158282048414176106aa576106aa610683565b5f60a0820160018060a01b038089168452602081891660208601528188166040860152818716606086015260a0608086015282865480855260c087019150875f5260205f2094505f5b8181101561074d57855485168352600195860195928401920161072f565b50909b9a5050505050505050505050565b634e487b7160e01b5f52603260045260245ffd5b83815260406020820152816040820152818360608301375f818301606090810191909152601f909201601f191601019291505056fe61018060405260405161581b38038061581b83398101604081905261002391610293565b6001600160a01b0380861660805284811660e0528216610140526040516100499061024a565b604051809103905ff080158015610062573d5f803e3d5ffd5b506001600160a01b039081166101608190529084166101005260405161008790610257565b6001600160a01b039091168152602001604051809103905ff0801580156100b0573d5f803e3d5ffd5b506001600160a01b0316610120524260a0526201518060c052678ac7230489e800006007555f60646100e334604b6103aa565b6100ed91906103c7565b5f805260126020527f7e7fa33969761a458e04f477e039a608702b4f924981d6653935a8319a08ad7b819055905061012482610146565b6101205161013b9061013683346103e6565b6101a7565b50505050505061040d565b80515f5b818110156101a257600160185f858481518110610169576101696103f9565b6020908102919091018101516001600160a01b031682528101919091526040015f20805460ff191691151591909117905560010161014a565b505050565b5f826001600160a01b0316826040515f6040518083038185875af1925050503d805f81146101f0576040519150601f19603f3d011682016040523d82523d5f602084013e6101f5565b606091505b50509050806101a25760405162461bcd60e51b815260206004820152601860248201527f513a204661696c656420746f2073656e6420616d6f756e740000000000000000604482015260640160405180910390fd5b6115e480612b3383390190565b6117048061411783390190565b80516001600160a01b038116811461027a575f80fd5b919050565b634e487b7160e01b5f52604160045260245ffd5b5f805f805f60a086880312156102a7575f80fd5b6102b086610264565b945060206102bf818801610264565b94506102cd60408801610264565b93506102db60608801610264565b60808801519093506001600160401b03808211156102f7575f80fd5b818901915089601f83011261030a575f80fd5b81518181111561031c5761031c61027f565b8060051b604051601f19603f830116810181811085821117156103415761034161027f565b60405291825284820192508381018501918c83111561035e575f80fd5b938501935b828510156103835761037485610264565b84529385019392850192610363565b8096505050505050509295509295909350565b634e487b7160e01b5f52601160045260245ffd5b80820281158282048414176103c1576103c1610396565b92915050565b5f826103e157634e487b7160e01b5f52601260045260245ffd5b500490565b818103818111156103c1576103c1610396565b634e487b7160e01b5f52603260045260245ffd5b60805160a05160c05160e051610100516101205161014051610160516126a861048b5f395f81816103510152818161090801528181610e2001526111ba01525f81816103060152611e0e01525f81816105390152611eab01525f611e7c01525f611e4a01525f61135001525f61137401525f610e9501526126a85ff3fe6080604052600436106101cd575f3560e01c80630962ef79146101d85780630ece2154146101f957806310019b3c1461023757806312ce57081461026d5780631ed6380f1461028057806328720db8146102ab5780632e17de78146102d657806337c679f7146102f55780633a5abead14610340578063436091c1146103735780634afdbdfa14610388578063572b6c051461039d5780635f5080b4146103cc578063633bf03d146103e157806368f05769146103f65780637bad72eb1461040b5780637f36ba08146104205780638796c3361461044b578063a694fc3a1461045e578063a707140b1461047d578063aabbb1bd146104a8578063ac68a748146104de578063adc0f686146104fd578063b68b5e8c14610528578063bab2f5521461055b578063bc71329014610570578063be26ed7f1461059b578063bebc9dfc146105af578063c4235ae9146105da578063ce09c18a14610605578063d4432e4e14610633578063d98de91f14610647578063db80a28c14610672578063dfcdc32f1461069d578063e3c7fa2c146106c8578063e60c90c4146106db578063ed725e8314610706578063f1b371e214610731578063f51b229414610746578063fa845ca91461075b575f80fd5b366101d457005b5f80fd5b3480156101e3575f80fd5b506101f76101f23660046123cb565b610786565b005b348015610204575f80fd5b506102246102133660046123cb565b60126020525f908152604090205481565b6040519081526020015b60405180910390f35b348015610242575f80fd5b506102246102513660046123fd565b601960209081525f928352604080842090915290825290205481565b6101f761027b3660046123fd565b6109b9565b34801561028b575f80fd5b5061022461029a366004612425565b60156020525f908152604090205481565b3480156102b6575f80fd5b506102246102c53660046123cb565b601b6020525f908152604090205481565b3480156102e1575f80fd5b506101f76102f03660046123cb565b610ca0565b348015610300575f80fd5b506103287f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161022e565b34801561034b575f80fd5b506103287f000000000000000000000000000000000000000000000000000000000000000081565b34801561037e575f80fd5b5061022460025481565b348015610393575f80fd5b5061022460075481565b3480156103a8575f80fd5b506103bc6103b7366004612425565b610e93565b604051901515815260200161022e565b3480156103d7575f80fd5b5061022460035481565b3480156103ec575f80fd5b5061022460085481565b348015610401575f80fd5b5061022460055481565b348015610416575f80fd5b5061022460065481565b34801561042b575f80fd5b5061022461043a3660046123cb565b600b6020525f908152604090205481565b6101f7610459366004612445565b610ec5565b348015610469575f80fd5b506101f76104783660046123cb565b610fca565b348015610488575f80fd5b50610224610497366004612425565b60116020525f908152604090205481565b3480156104b3575f80fd5b506102246104c23660046123fd565b601460209081525f928352604080842090915290825290205481565b3480156104e9575f80fd5b506101f76104f83660046123cb565b61121e565b348015610508575f80fd5b506102246105173660046123cb565b600f6020525f908152604090205481565b348015610533575f80fd5b506103287f000000000000000000000000000000000000000000000000000000000000000081565b348015610566575f80fd5b5061022460015481565b34801561057b575f80fd5b5061022461058a366004612425565b600e6020525f908152604090205481565b3480156105a6575f80fd5b5061022461134d565b3480156105ba575f80fd5b506102246105c93660046123cb565b60136020525f908152604090205481565b3480156105e5575f80fd5b506102246105f43660046123cb565b60106020525f908152604090205481565b348015610610575f80fd5b506103bc61061f366004612425565b60186020525f908152604090205460ff1681565b34801561063e575f80fd5b506102245f5481565b348015610652575f80fd5b506102246106613660046123cb565b601a6020525f908152604090205481565b34801561067d575f80fd5b5061022461068c366004612425565b60176020525f908152604090205481565b3480156106a8575f80fd5b506102246106b7366004612425565b600a6020525f908152604090205481565b6101f76106d6366004612425565b6113a8565b3480156106e6575f80fd5b506102246106f5366004612425565b60166020525f908152604090205481565b348015610711575f80fd5b50610224610720366004612425565b600d6020525f908152604090205481565b34801561073c575f80fd5b5061022460045481565b348015610751575f80fd5b5061022460095481565b348015610766575f80fd5b50610224610775366004612425565b600c6020525f908152604090205481565b5f5c15610791575f80fd5b60015f5d61079d6114fa565b6001546107a981611518565b5f6107b26115f6565b90506107be8183611646565b6001600160a01b0381165f90815260156020908152604080832054600d9092528220546107eb91906124c4565b90505f81116108315760405162461bcd60e51b815260206004820152600d60248201526c513a204e6f207265776172647360981b60448201526064015b60405180910390fd5b808411156108765760405162461bcd60e51b8152602060048201526012602482015271513a2045786365656473207265776172647360701b6044820152606401610828565b6001600160a01b0382165f908152600d60205260408120805486929061089d9084906124c4565b9091555050600454600254036108c9578360055f8282546108be91906124d7565b909155506108f19050565b5f838152601060205260409020546108e29085906124c4565b5f848152601060205260409020555b604051634d24848760e11b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639a49090e9061093f90859088906004016124ea565b5f604051808303815f87803b158015610956575f80fd5b505af1158015610968573d5f803e3d5ffd5b50505050816001600160a01b0316837f3300bdb359cfb956935bca32e9db727413eab1ca84341f2e36caea85bb796968866040516109a891815260200190565b60405180910390a35050505f805d50565b5f5c156109c4575f80fd5b60015f5d5f5a905069fe1c215e8f838e0000006008541115610a1d5760405162461bcd60e51b8152602060048201526012602482015271144e88115b9919d85b59481c995858da195960721b6044820152606401610828565b6064821115610a5b5760405162461bcd60e51b815260206004820152600a6024820152690513a204d6178203130360b41b6044820152606401610828565b5f8211610a955760405162461bcd60e51b8152602060048201526008602482015267513a204d696e203160c01b6044820152606401610828565b6001600160a01b0383165f9081526018602052604090205460ff16610af05760405162461bcd60e51b8152602060048201526011602482015270144e88139bdd081c9959da5cdd195c9959607a1b6044820152606401610828565b610af86114fa565b600154610b0481611518565b610b0d81611bd1565b5f610b1784611cc9565b905080341015610b5a5760405162461bcd60e51b815260206004820152600e60248201526d513a2056616c7565203c2066656560901b6044820152606401610828565b5f610b636115f6565b9050610b6f8184611646565b610b798684611646565b610b8585848884611d08565b6001546001600160a01b038083165f908152600c60205260408082208490559189168152908120919091556009805491610bbe83612503565b9190505550610bcd8284611dcf565b81341115610be857610be833610be384346124c4565b611ed7565b806001600160a01b03167ffa46cc39fc3a7bafc0f46b0272961643c81ac5016927080d397f7f0055d856fd86604051610c2391815260200190565b60405180910390a25050505f5a610c3a90836124c4565b610c46906178ac6124d7565b90505f610c53488361251b565b905080601b5f60015481526020019081526020015f205f828254610c7791906124d7565b925050819055508060085f828254610c8f91906124d7565b925050819055505050505f805d5050565b5f5c15610cab575f80fd5b60015f5d610cb76114fa565b6001545f610cc36115f6565b9050610cce82611518565b610cd88183611646565b5f8311610cf75760405162461bcd60e51b815260040161082890612532565b6001600160a01b0381165f90815260156020526040902054831115610d705760405162461bcd60e51b815260206004820152602960248201527f513a20416d6f756e742067726561746572207468616e20776974686472617761604482015268626c65207374616b6560b81b6064820152608401610828565b60045460025403610d97578260055f828254610d8c91906124d7565b90915550610dba9050565b5f8281526010602052604081208054859290610db49084906124c4565b90915550505b6001600160a01b0381165f9081526015602052604081208054859290610de19084906124c4565b90915550506001600160a01b0381165f908152600d602052604081208054859290610e0d9084906124c4565b90915550610e4790506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168285611f71565b806001600160a01b0316827f37375b03d8924bd8f076f11f8411b9962aa5c02fb489021507bc6bb6f850e36585604051610e8391815260200190565b60405180910390a350505f805d50565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b60075434811115610ed4575f80fd5b5f610edd6115f6565b6001600160a01b0381165f9081526018602052604090205490915060ff1615610f3b5760405162461bcd60e51b815260206004820152601060248201526f144e881052481c9959da5cdd195c995960821b6044820152606401610828565b6001600160a01b0381165f908152601860205260409020805460ff1916600117905534821015610f7357610f7333610be384346124c4565b610f7f82600454611dcf565b806001600160a01b03167f692d99e6f9b3cb9e93a6d75f83ec4e52e60504a0763720ab8e639060da38b932858585604051610fbc9392919061255d565b60405180910390a250505050565b5f5c15610fd5575f80fd5b60015f5d610fe16114fa565b6001545f610fed6115f6565b9050610ff882611518565b6110028183611646565b5f83116110215760405162461bcd60e51b815260040161082890612532565b600454821461107c5760405162461bcd60e51b815260206004820152602160248201527f513a204f6e6c79207374616b6520647572696e6720616374697665206379636c6044820152606560f81b6064820152608401610828565b825f8082825461108c91906124d7565b909155505f905061109e8360016124d7565b9050600454600254036110bc576002546110b99060016124d7565b90505b6001600160a01b0382165f9081526016602052604090205481148015906110fa57506001600160a01b0382165f908152601760205260409020548114155b15611175576001600160a01b0382165f90815260166020526040812054900361113c576001600160a01b0382165f908152601660205260409020819055611175565b6001600160a01b0382165f908152601760205260408120549003611175576001600160a01b0382165f9081526017602052604090208190555b6001600160a01b0382165f908152601460209081526040808320848452909152812080548692906111a79084906124d7565b909155506111e290506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016833087611fc7565b816001600160a01b0316817f18dcd430020e4d4899772fd94a8b40451dc5044dfb70bc46b532eeae431c864f866040516109a891815260200190565b5f5c15611229575f80fd5b60015f5d6112356114fa565b6001545f6112416115f6565b905061124c82611518565b6112568183611646565b6001600160a01b0381165f908152600e60205260409020548061128b5760405162461bcd60e51b815260040161082890612532565b808411156112da5760405162461bcd60e51b815260206004820152601c60248201527b513a20436c61696d20616d6f756e742065786365656473206665657360201b6044820152606401610828565b6001600160a01b0382165f908152600e6020526040812080548692906113019084906124c4565b9091555061131190508285611ed7565b816001600160a01b0316837f2227733fc4c8a9034cb58087dcf6995128b9c0233b038b03366aaf30c92b92d6866040516109a891815260200190565b5f7f00000000000000000000000000000000000000000000000000000000000000006113997f0000000000000000000000000000000000000000000000000000000000000000426124c4565b6113a39190612594565b905090565b6004546001600160a01b0382165f9081526019602090815260408083208484529091528120546113d99034906124d7565b905067016345785d8a000081101561143d5760405162461bcd60e51b815260206004820152602160248201527f513a204d696e2e207468726573686f6c642062616c616e6365206e6f74206d656044820152601d60fa1b6064820152608401610828565b6001600160a01b0383165f9081526019602090815260408083208584529091528120805434929061146f9084906124d7565b90915550505f828152601a60205260409020548082108061148e575080155b156114a4575f838152601a602052604090208290555b6114ae3484611dcf565b60408051348152602081018590526001600160a01b0386169133917f031820cb503f016de565e43728c74cb9df7177ba8789df22781cab0a4ec10dc0910160405180910390a350505050565b5f61150361134d565b90506001548111156115155760018190555b50565b600454811461152e576002805460035560045490555b600254808211801561155a575060135f6115498360016124d7565b81526020019081526020015f20545f145b156115f25761156881611fff565b5f81815260106020908152604080832054601290925282205461159b906b1d6329f1c35ca4bfabb9f56160281b9061251b565b6115a59190612594565b90508060135f60035460016115ba91906124d7565b81526020019081526020015f20546115d291906124d7565b60135f6115e08560016124d7565b815260208101919091526040015f2055505b5050565b5f36601461160333610e93565b801561160f5750808210155b1561163e575f3661162083856124c4565b61162b9282906125b3565b611634916125da565b60601c9250505090565b339250505090565b6001600160a01b0382165f908152600c60205260409020548111801561168257506001600160a01b0382165f908152600a602052604090205415155b15611722576001600160a01b0382165f818152600c60209081526040808320548352600b825280832054600f835281842054948452600a909252822054919290916116cd919061251b565b6116d79190612594565b6001600160a01b0384165f908152600d60205260408120805492935083929091906117039084906124d7565b9091555050506001600160a01b0382165f908152600a60205260408120555b5f600254600161173291906124d7565b90506002548211801561175c57506001600160a01b0383165f908152601160205260409020548114155b1561181c576001600160a01b0383165f9081526011602090815260408083205483526013909152808220548383529120546b1d6329f1c35ca4bfabb9f56160281b916117a7916124c4565b6001600160a01b0385165f908152600d60205260409020546117c9919061251b565b6117d39190612594565b6001600160a01b0384165f908152600e60205260409020546117f591906124d7565b6001600160a01b0384165f908152600e602090815260408083209390935560119052208190555b6001600160a01b0383165f908152601660205260409020541580159061185857506001600160a01b0383165f9081526016602052604090205482115b15611bcc576001600160a01b0383165f81815260146020908152604080832060168352818420548452825280832054938352600d909152812080548392906118a19084906124d7565b90915550506001600160a01b0384165f90815260156020526040812080548392906118cd9084906124d7565b90915550506001600160a01b0384165f908152601660205260409020548211156119b0576001600160a01b0384165f9081526016602090815260408083205483526013909152808220548483529120546b1d6329f1c35ca4bfabb9f56160281b91611937916124c4565b6001600160a01b0386165f9081526014602090815260408083206016835281842054845290915290205461196b919061251b565b6119759190612594565b6001600160a01b0385165f908152600e602052604090205461199791906124d7565b6001600160a01b0385165f908152600e60205260409020555b6001600160a01b0384165f81815260146020908152604080832060168352818420805485529083528184208490559383529282905560179052205415611bca576001600160a01b0384165f90815260176020526040902054831115611b9e576001600160a01b0384165f81815260146020908152604080832060178352818420548452825280832054938352600d90915281208054839290611a539084906124d7565b90915550506001600160a01b0385165f9081526015602052604081208054839290611a7f9084906124d7565b90915550506001600160a01b0385165f90815260176020526040902054831115611b62576001600160a01b0385165f9081526017602090815260408083205483526013909152808220548583529120546b1d6329f1c35ca4bfabb9f56160281b91611ae9916124c4565b6001600160a01b0387165f90815260146020908152604080832060178352818420548452909152902054611b1d919061251b565b611b279190612594565b6001600160a01b0386165f908152600e6020526040902054611b4991906124d7565b6001600160a01b0386165f908152600e60205260409020555b506001600160a01b0384165f81815260146020908152604080832060178084528285208054865291845291842084905593835290529055611bca565b6001600160a01b0384165f90815260176020818152604080842080546016845291852091909155919052555b505b505050565b600454811461151557611be26120a4565b60048190555f600981905560025481526010602052604080822054838352908220805491929091611c149084906124d7565b90915550505f5415611c49575f8054828252601060205260408220805491929091611c409084906124d7565b90915550505f80555b60055415611c7b576005545f8281526010602052604081208054909190611c719084906124c4565b90915550505f6005555b807f2ee63a65823306caa71f76a6f1fbc130f9932419aca12e4bc61488794c0fe84260105f8481526020019081526020015f2054604051611cbe91815260200190565b60405180910390a250565b5f6103e86009546103e8611cdd91906124d7565b611cee84662386f26fc1000061251b565b611cf8919061251b565b611d029190612594565b92915050565b5f611d1383856120fb565b90506001811115611d2b57611d28818661251b565b94505b611d3685606461251b565b5f858152600b602052604081208054909190611d539084906124d7565b90915550611d64905085605f61251b565b6001600160a01b0383165f908152600a602052604081208054909190611d8b9084906124d7565b90915550611d9c905085600561251b565b6001600160a01b0384165f908152600a602052604081208054909190611dc39084906124d7565b90915550505050505050565b6064611ddc83604661251b565b611de69190612594565b5f8281526012602052604081208054909190611e039084906124d7565b90915550611e4590507f00000000000000000000000000000000000000000000000000000000000000006103e8611e3b85600261251b565b610be39190612594565b611e777f00000000000000000000000000000000000000000000000000000000000000006103e8611e3b85602661251b565b611ea67f0000000000000000000000000000000000000000000000000000000000000000610be3606485612594565b6115f27f00000000000000000000000000000000000000000000000000000000000000006064611e3b85601961251b565b5f826001600160a01b0316826040515f6040518083038185875af1925050503d805f8114611f20576040519150601f19603f3d011682016040523d82523d5f602084013e611f25565b606091505b5050905080611bcc5760405162461bcd60e51b8152602060048201526018602482015277144e8811985a5b1959081d1bc81cd95b9908185b5bdd5b9d60421b6044820152606401610828565b611bcc8363a9059cbb60e01b8484604051602401611f909291906124ea565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261216e565b6040516001600160a01b0380851660248301528316604482015260648101829052611bca9085906323b872dd60e01b90608401611f90565b6006545f828152601b6020526040812054909160c89161201f919061251b565b6120299190612594565b5f838152601b602052604090205461204290606461251b565b61204c91906124c4565b5f838152600f60209081526040808320849055601090915281208054929350839290919061207b9084906124d7565b9091555050600654614e1f11156115f25760068054905f61209b83612503565b91905055505050565b674563918244f4000060075411156120f9575f6127246007546127106120ca919061251b565b6120d49190612594565b9050674563918244f400008110156120f557674563918244f4000060075550565b6007555b565b6002546001600160a01b0383165f908152601960209081526040808320848452909152812054909190801580159061213257508315155b15612161575f828152601a602052604090205461215082600261251b565b61215a9190612594565b9250612166565b600192505b505092915050565b5f6121c2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166122419092919063ffffffff16565b905080515f14806121e25750808060200190518101906121e29190612608565b611bcc5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610828565b606061224f84845f85612257565b949350505050565b6060824710156122b85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610828565b5f80866001600160a01b031685876040516122d39190612627565b5f6040518083038185875af1925050503d805f811461230d576040519150601f19603f3d011682016040523d82523d5f602084013e612312565b606091505b50915091506123238783838761232e565b979650505050505050565b6060831561239c5782515f03612395576001600160a01b0385163b6123955760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610828565b508161224f565b61224f83838151156123b15781518083602001fd5b8060405162461bcd60e51b8152600401610828919061263d565b5f602082840312156123db575f80fd5b5035919050565b80356001600160a01b03811681146123f8575f80fd5b919050565b5f806040838503121561240e575f80fd5b612417836123e2565b946020939093013593505050565b5f60208284031215612435575f80fd5b61243e826123e2565b9392505050565b5f8060208385031215612456575f80fd5b82356001600160401b038082111561246c575f80fd5b818501915085601f83011261247f575f80fd5b81358181111561248d575f80fd5b86602082850101111561249e575f80fd5b60209290920196919550909350505050565b634e487b7160e01b5f52601160045260245ffd5b81810381811115611d0257611d026124b0565b80820180821115611d0257611d026124b0565b6001600160a01b03929092168252602082015260400190565b5f60018201612514576125146124b0565b5060010190565b8082028115828204841417611d0257611d026124b0565b602080825260119082015270513a20416d6f756e74206973207a65726f60781b604082015260600190565b60408152826040820152828460608301375f606084830101525f6060601f19601f8601168301019050826020830152949350505050565b5f826125ae57634e487b7160e01b5f52601260045260245ffd5b500490565b5f80858511156125c1575f80fd5b838611156125cd575f80fd5b5050820193919092039150565b6001600160601b031981358181169160148510156121665760149490940360031b84901b1690921692915050565b5f60208284031215612618575f80fd5b8151801515811461243e575f80fd5b5f82518060208501845e5f920191825250919050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f8301168401019150509291505056fea264697066735822122085460eab68e9de9774f82431c6f4ebc1f46dc8465fa59728222a7158bd1a8d4964736f6c63430008190033610180604052348015610010575f80fd5b506040518060400160405280600781526020016628902a37b5b2b760c91b81525080604051806040016040528060018152602001603160f81b8152506040518060400160405280600781526020016628902a37b5b2b760c91b815250604051806040016040528060018152602001605160f81b81525081600390816100959190610271565b5060046100a28282610271565b506100b291508390506005610161565b610120526100c1816006610161565b61014052815160208084019190912060e052815190820120610100524660a05261014d60e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b60805250503060c052503361016052610388565b5f60208351101561017c5761017583610193565b905061018d565b816101878482610271565b5060ff90505b92915050565b5f80829050601f815111156101c6578260405163305a27a960e01b81526004016101bd9190610330565b60405180910390fd5b80516101d182610365565b179392505050565b634e487b7160e01b5f52604160045260245ffd5b600181811c9082168061020157607f821691505b60208210810361021f57634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561026c57805f5260205f20601f840160051c8101602085101561024a5750805b601f840160051c820191505b81811015610269575f8155600101610256565b50505b505050565b81516001600160401b0381111561028a5761028a6101d9565b61029e8161029884546101ed565b84610225565b602080601f8311600181146102d1575f84156102ba5750858301515b5f19600386901b1c1916600185901b178555610328565b5f85815260208120601f198616915b828110156102ff578886015182559484019460019091019084016102e0565b508582101561031c57878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b8051602080830151919081101561021f575f1960209190910360031b1b16919050565b60805160a05160c05160e051610100516101205161014051610160516112016103e35f395f6103da01525f61037101525f61034601525f610abb01525f610a9301525f6109ee01525f610a1801525f610a4201526112015ff3fe608060405234801561000f575f80fd5b50600436106100ce575f3560e01c806306fdde03146100d2578063095ea7b3146100f057806318160ddd1461011357806323b872dd14610125578063313ce567146101385780633644e51514610147578063395093511461014f57806370a08231146101625780637ecebe001461018a57806384b0196e1461019d57806395d89b41146101b85780639a49090e146101c0578063a457c2d7146101d5578063a9059cbb146101e8578063d505accf146101fb578063dd62ed3e1461020e575b5f80fd5b6100da610221565b6040516100e79190610f63565b60405180910390f35b6101036100fe366004610f97565b6102b1565b60405190151581526020016100e7565b6002545b6040519081526020016100e7565b610103610133366004610fbf565b6102ca565b604051601281526020016100e7565b6101176102ed565b61010361015d366004610f97565b6102fb565b610117610170366004610ff8565b6001600160a01b03165f9081526020819052604090205490565b610117610198366004610ff8565b61031c565b6101a5610339565b6040516100e79796959493929190611011565b6100da6103c0565b6101d36101ce366004610f97565b6103cf565b005b6101036101e3366004610f97565b6104a6565b6101036101f6366004610f97565b610520565b6101d36102093660046110a8565b61052d565b61011761021c366004611115565b61068e565b60606003805461023090611146565b80601f016020809104026020016040519081016040528092919081815260200182805461025c90611146565b80156102a75780601f1061027e576101008083540402835291602001916102a7565b820191905f5260205f20905b81548152906001019060200180831161028a57829003601f168201915b5050505050905090565b5f336102be8185856106b8565b60019150505b92915050565b5f336102d78582856107db565b6102e2858585610853565b506001949350505050565b5f6102f66109e2565b905090565b5f336102be81858561030d838361068e565b6103179190611178565b6106b8565b6001600160a01b0381165f908152600760205260408120546102c4565b5f6060808280808361036c7f00000000000000000000000000000000000000000000000000000000000000006005610b0b565b6103977f00000000000000000000000000000000000000000000000000000000000000006006610b0b565b604080515f80825260208201909252600f60f81b9b939a50919850469750309650945092509050565b60606004805461023090611146565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146104425760405162461bcd60e51b8152602060048201526013602482015272289d1024b731b7b93932b1ba1031b0b63632b960691b60448201526064015b60405180910390fd5b6a6342fd08f00f637800000061045760025490565b106104985760405162461bcd60e51b8152602060048201526011602482015270144e88105b1c9958591e481b5a5b9d1959607a1b6044820152606401610439565b6104a28282610bb4565b5050565b5f33816104b3828661068e565b9050838110156105135760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610439565b6102e282868684036106b8565b5f336102be818585610853565b8342111561057d5760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610439565b5f7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886105ab8c610c5e565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090505f61060582610c85565b90505f61061482878787610cb1565b9050896001600160a01b0316816001600160a01b0316146106775760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610439565b6106828a8a8a6106b8565b50505050505050505050565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b6001600160a01b03831661071a5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610439565b6001600160a01b03821661077b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610439565b6001600160a01b038381165f8181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b5f6107e6848461068e565b90505f19811461084d57818110156108405760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610439565b61084d84848484036106b8565b50505050565b6001600160a01b0383166108b75760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610439565b6001600160a01b0382166109195760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610439565b6001600160a01b0383165f90815260208190526040902054818110156109905760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610439565b6001600160a01b038481165f81815260208181526040808320878703905593871680835291849020805487019055925185815290925f805160206111ac833981519152910160405180910390a361084d565b5f306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015610a3a57507f000000000000000000000000000000000000000000000000000000000000000046145b15610a6457507f000000000000000000000000000000000000000000000000000000000000000090565b6102f6604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b606060ff8314610b2557610b1e83610cd7565b90506102c4565b818054610b3190611146565b80601f0160208091040260200160405190810160405280929190818152602001828054610b5d90611146565b8015610ba85780601f10610b7f57610100808354040283529160200191610ba8565b820191905f5260205f20905b815481529060010190602001808311610b8b57829003601f168201915b505050505090506102c4565b6001600160a01b038216610c0a5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610439565b8060025f828254610c1b9190611178565b90915550506001600160a01b0382165f81815260208181526040808320805486019055518481525f805160206111ac833981519152910160405180910390a35050565b6001600160a01b0381165f9081526007602052604090208054600181018255905b50919050565b5f6102c4610c916109e2565b8360405161190160f01b8152600281019290925260228201526042902090565b5f805f610cc087878787610d14565b91509150610ccd81610dc7565b5095945050505050565b60605f610ce383610f0e565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b5f806fa2a8918ca85bafe22016d0b997e4df60600160ff1b03831115610d3f57505f90506003610dbe565b604080515f8082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015610d90573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b038116610db8575f60019250925050610dbe565b91505f90505b94509492505050565b5f816004811115610dda57610dda611197565b03610de25750565b6001816004811115610df657610df6611197565b03610e3e5760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b6044820152606401610439565b6002816004811115610e5257610e52611197565b03610e9f5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610439565b6003816004811115610eb357610eb3611197565b03610f0b5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610439565b50565b5f60ff8216601f8111156102c457604051632cd44ac360e21b815260040160405180910390fd5b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f610f756020830184610f35565b9392505050565b80356001600160a01b0381168114610f92575f80fd5b919050565b5f8060408385031215610fa8575f80fd5b610fb183610f7c565b946020939093013593505050565b5f805f60608486031215610fd1575f80fd5b610fda84610f7c565b9250610fe860208501610f7c565b9150604084013590509250925092565b5f60208284031215611008575f80fd5b610f7582610f7c565b60ff60f81b881681525f602060e0602084015261103160e084018a610f35565b8381036040850152611043818a610f35565b606085018990526001600160a01b038816608086015260a0850187905284810360c0860152855180825260208088019350909101905f5b818110156110965783518352928401929184019160010161107a565b50909c9b505050505050505050505050565b5f805f805f805f60e0888a0312156110be575f80fd5b6110c788610f7c565b96506110d560208901610f7c565b95506040880135945060608801359350608088013560ff811681146110f8575f80fd5b9699959850939692959460a0840135945060c09093013592915050565b5f8060408385031215611126575f80fd5b61112f83610f7c565b915061113d60208401610f7c565b90509250929050565b600181811c9082168061115a57607f821691505b602082108103610c7f57634e487b7160e01b5f52602260045260245ffd5b808201808211156102c457634e487b7160e01b5f52601160045260245ffd5b634e487b7160e01b5f52602160045260245ffdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220c22e871721421ab8743f1837744003fc3fc896fa7d8b1c452a9c5a133c6d1f0864736f6c6343000819003360c060405234801561000f575f80fd5b5060405161170438038061170483398101604081905261002e916101e1565b425f5561005273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc282612710610069565b6001600160a01b0390811660a0521660805261020e565b5f805f846001600160a01b0316866001600160a01b03161061008c57848661008f565b85855b604080516060810182526001600160a01b0380851682528316602082015262ffffff88169181019190915291935091506100dd731f98431c8ad98523631ae4a59f267346ea31f984826100e8565b979650505050505050565b5f81602001516001600160a01b0316825f01516001600160a01b03161061010d575f80fd5b815160208084015160408086015181516001600160a01b0395861681860152949092168482015262ffffff90911660608085019190915281518085038201815260808501909252815191909201207fff0000000000000000000000000000000000000000000000000000000000000060a08401529085901b6001600160601b03191660a183015260b58201527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d582015260f50160408051601f1981840301815291905280516020909101209392505050565b5f602082840312156101f1575f80fd5b81516001600160a01b0381168114610207575f80fd5b9392505050565b60805160a0516114c761023d5f395f81816102c4015261063001525f818161067501526107c701526114c75ff3fe608060405260043610610078575f3560e01c806309c2bc96146100cc57806355ecf5a81461010f578063802c6ee5146101465780638225b247146101695780638bd95563146101885780638fe075961461019c578063b70872e6146101bb578063bdc639bc146101d0578063be26ed7f146101e5575f80fd5b366100c8575f5461008c9062015180610fe4565b4210156100af573460015f8282546100a49190610fe4565b909155506100c69050565b3460035f8282546100c09190610fe4565b90915550505b005b5f80fd5b3480156100d7575f80fd5b506100fa6100e6366004610ffd565b60046020525f908152604090205460ff1681565b60405190151581526020015b60405180910390f35b34801561011a575f80fd5b5061012e61012936600461102b565b6101f9565b6040516001600160a01b039091168152602001610106565b348015610151575f80fd5b5061015b60035481565b604051908152602001610106565b348015610174575f80fd5b506100c661018336600461107a565b610283565b348015610193575f80fd5b5061015b5f5481565b3480156101a7575f80fd5b5061015b6101b636600461109a565b610629565b3480156101c6575f80fd5b5061015b60015481565b3480156101db575f80fd5b5061015b60025481565b3480156101f0575f80fd5b5061015b610699565b5f805f846001600160a01b0316866001600160a01b03161061021c57848661021f565b85855b915091505f6040518060600160405280846001600160a01b03168152602001836001600160a01b031681526020018662ffffff168152509050610276731f98431c8ad98523631ae4a59f267346ea31f984826106ba565b93505050505b9392505050565b3332146102c25760405162461bcd60e51b815260206004820152600860248201526755736520454f412160c01b60448201526064015b60405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000003b63ffffffff1661032d5760405162461bcd60e51b8152602060048201526014602482015273506f6f6c20646f6573206e6f742065786973742160601b60448201526064016102b9565b5f5461033c9062015180610fe4565b42116103785760405162461bcd60e51b815260206004820152600b60248201526a4561726c79206275726e2160a81b60448201526064016102b9565b67016345785d8a00008210156103be5760405162461bcd60e51b815260206004820152600b60248201526a09ad2dc40605c62408aa8960ab1b60448201526064016102b9565b5f60326001546103ce91906110d4565b6003549091505f6103dd610699565b90505f80603260025410801561040157505f8381526004602052604090205460ff16155b156104db57846003546104149190610fe4565b9350868410156104365760405162461bcd60e51b81526004016102b9906110e7565b8660035410610467578660035f8282546104509190611114565b9091555061046090508588610fe4565b96506104aa565b848711156104a6576104798588611114565b600354106104a15761048b8588611114565b60035f82825461049b9190611114565b90915550505b6104aa565b8496505b60028054905f6104b983611127565b90915550505f838152600460205260409020805460ff19166001179055610512565b868410156104fb5760405162461bcd60e51b81526004016102b9906110e7565b8660035f82825461050c9190611114565b90915550505b61051d6064886110d4565b90506105298188611114565b91505f61053583610629565b90505f606461054583605a61113f565b61054f91906110d4565b90505f811161058a5760405162461bcd60e51b815260206004820152600760248201526604d696e203e20360cc1b60448201526064016102b9565b61059581858a61079b565b6040515f90339085908381818185875af1925050503d805f81146105d4576040519150601f19603f3d011682016040523d82523d5f602084013e6105d9565b606091505b505090508061061d5760405162461bcd60e51b815260206004820152601060248201526f2a3930b739b332b9103330b4b632b21760811b60448201526064016102b9565b50505050505050505050565b5f806106567f000000000000000000000000000000000000000000000000000000000000000060016108d7565b50905061027c818473c02aaa39b223fe8d0a0e5c4f27ead9083c756cc27f0000000000000000000000000000000000000000000000000000000000000000610b10565b5f620151805f54426106ab9190611114565b6106b591906110d4565b905090565b5f81602001516001600160a01b0316825f01516001600160a01b0316106106df575f80fd5b815160208084015160408086015181516001600160a01b0395861681860152949092168482015262ffffff90911660608085019190915281518085038201815260808501909252815191909201206001600160f81b031960a08401529085901b6001600160601b03191660a183015260b58201527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d582015260f50160408051601f1981840301815291905280516020909101209392505050565b604080516101008101825273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166020830190815261271083850190815261dead606085019081526080850187815260a0860189815260c087018b81525f60e08901908152985163414bf38960e01b8152885188166004820152955187166024870152935162ffffff1660448601529151851660648501525160848401525160a48301525160c482015292511660e48301529073e592427a0aece92de3edee1f18e0157c058615649063414bf3899085906101040160206040518083038185885af11580156108ab573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906108d09190611156565b5050505050565b5f808263ffffffff165f036109135760405162461bcd60e51b8152602060048201526002602482015261042560f41b60448201526064016102b9565b6040805160028082526060820183525f9260208301908036833701905050905083815f8151811061094657610946611181565b602002602001019063ffffffff16908163ffffffff16815250505f8160018151811061097457610974611181565b602002602001019063ffffffff16908163ffffffff16815250505f80866001600160a01b031663883bdbfd846040518263ffffffff1660e01b81526004016109bc9190611195565b5f60405180830381865afa1580156109d6573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526109fd91908101906112a5565b915091505f825f81518110610a1457610a14611181565b602002602001015183600181518110610a2f57610a2f611181565b6020026020010151610a419190611368565b90505f825f81518110610a5657610a56611181565b602002602001015183600181518110610a7157610a71611181565b6020026020010151610a839190611395565b9050610a9563ffffffff8916836113bc565b96505f8260060b128015610aba5750610ab463ffffffff8916836113f8565b60060b15155b15610acd5786610ac981611419565b9750505b5f610ae56001600160a01b0363ffffffff8b1661143a565b9050610b01600160201b600160c01b03602084901b168261146c565b96505050505050509250929050565b5f80610b1b86610c16565b90506001600160801b036001600160a01b03821611610ba0575f610b486001600160a01b0383168061113f565b9050836001600160a01b0316856001600160a01b031610610b8057610b7b600160c01b876001600160801b031683610f26565b610b98565b610b9881876001600160801b0316600160c01b610f26565b925050610c0d565b5f610bb96001600160a01b03831680600160401b610f26565b9050836001600160a01b0316856001600160a01b031610610bf157610bec600160801b876001600160801b031683610f26565b610c09565b610c0981876001600160801b0316600160801b610f26565b9250505b50949350505050565b5f805f8360020b12610c2b578260020b610c32565b8260020b5f035b9050620d89e8811115610c58576040516315e4079d60e11b815260040160405180910390fd5b5f816001165f03610c6d57600160801b610c7f565b6ffffcb933bd6fad37aa2d162d1a5940015b6001600160881b031690506002821615610ca9576ffff97272373d413259a46990580e213a0260801c5b6004821615610cc8576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615610ce7576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615610d06576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615610d25576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615610d44576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615610d63576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615610d83576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615610da3576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615610dc3576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615610de3576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615610e03576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615610e23576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615610e43576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615610e63576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615610e84576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615610ea4576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615610ec3576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615610ee0576b048a170391f7dc42444e8fa20260801c5b5f8460020b1315610eff57805f1981610efb57610efb6110c0565b0490505b600160201b810615610f12576001610f14565b5f5b60ff16602082901c0192505050919050565b5f80805f19858709858702925082811083820303915050805f03610f5a575f8411610f4f575f80fd5b50829004905061027c565b808411610f65575f80fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b634e487b7160e01b5f52601160045260245ffd5b80820180821115610ff757610ff7610fd0565b92915050565b5f6020828403121561100d575f80fd5b5035919050565b6001600160a01b0381168114611028575f80fd5b50565b5f805f6060848603121561103d575f80fd5b833561104881611014565b9250602084013561105881611014565b9150604084013562ffffff8116811461106f575f80fd5b809150509250925092565b5f806040838503121561108b575f80fd5b50508035926020909101359150565b5f602082840312156110aa575f80fd5b81356001600160801b038116811461027c575f80fd5b634e487b7160e01b5f52601260045260245ffd5b5f826110e2576110e26110c0565b500490565b602080825260139082015272496e73756666696369656e742066756e64732160681b604082015260600190565b81810381811115610ff757610ff7610fd0565b5f6001820161113857611138610fd0565b5060010190565b8082028115828204841417610ff757610ff7610fd0565b5f60208284031215611166575f80fd5b5051919050565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b602080825282518282018190525f9190848201906040850190845b818110156111d257835163ffffffff16835292840192918401916001016111b0565b50909695505050505050565b604051601f8201601f191681016001600160401b03811182821017156112065761120661116d565b604052919050565b5f6001600160401b038211156112265761122661116d565b5060051b60200190565b5f82601f83011261123f575f80fd5b8151602061125461124f8361120e565b6111de565b8083825260208201915060208460051b870101935086841115611275575f80fd5b602086015b8481101561129a57805161128d81611014565b835291830191830161127a565b509695505050505050565b5f80604083850312156112b6575f80fd5b82516001600160401b03808211156112cc575f80fd5b818501915085601f8301126112df575f80fd5b815160206112ef61124f8361120e565b82815260059290921b8401810191818101908984111561130d575f80fd5b948201945b838610156113395785518060060b811461132a575f80fd5b82529482019490820190611312565b91880151919650909350505080821115611351575f80fd5b5061135e85828601611230565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff82131715610ff757610ff7610fd0565b6001600160a01b038281168282160390808211156113b5576113b5610fd0565b5092915050565b5f8160060b8360060b806113d2576113d26110c0565b667fffffffffffff1982145f19821416156113ef576113ef610fd0565b90059392505050565b5f8260060b8061140a5761140a6110c0565b808360060b0791505092915050565b5f8160020b627fffff19810361143157611431610fd0565b5f190192915050565b6001600160c01b0382811682821681810283169291811582850482141761146357611463610fd0565b50505092915050565b5f6001600160c01b0383811680611485576114856110c0565b9216919091049291505056fea264697066735822122043b7cbc864d2a2bc0e7cf6b8e190075c230a223b9a7de607cd250c85d679014164736f6c63430008190033a2646970667358221220e2c5e443241009dabe9337b743e91caf880417cdcb5ec99ccc7336d90c049b6b64736f6c63430008190033

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

000000000000000000000000783223a9851566db1a4eeba72fa1329ea3144b8d

-----Decoded View---------------
Arg [0] : _devFee (address): 0x783223a9851566db1a4EEBa72Fa1329Ea3144B8d

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000783223a9851566db1a4eeba72fa1329ea3144b8d


Deployed Bytecode Sourcemap

173702:2328:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;173758:22;;;;;;;;;;;;;;;;;;;160:25:1;;;148:2;133:18;173758:22:0;;;;;;;;174130:21;;;;;;;;;;-1:-1:-1;174130:21:0;;;;-1:-1:-1;;;;;174130:21:0;;;;;;-1:-1:-1;;;;;360:32:1;;;342:51;;330:2;315:18;174130:21:0;196:203:1;174158:31:0;;;;;;;;;;-1:-1:-1;174158:31:0;;;;-1:-1:-1;;;;;174158:31:0;;;174196:28;;;;;;;;;;-1:-1:-1;174196:28:0;;;;;:::i;:::-;;:::i;173727:24::-;;;;;;;;;;;;;;;;175193:134;;;;;;;;;;;;;:::i;175335:516::-;;;;;;;;;;;;;:::i;:::-;;174523:662;;;;;;:::i;:::-;;:::i;174233:48::-;;;;;;;;;;-1:-1:-1;174233:48:0;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;1642:14:1;;1635:22;1617:41;;1605:2;1590:18;174233:48:0;1477:187:1;174196:28:0;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;174196:28:0;;-1:-1:-1;174196:28:0;:::o;175193:134::-;175247:7;173820:6;175293:9;;175275:15;:27;;;;:::i;:::-;175274:45;;;;:::i;:::-;175267:52;;175193:134;:::o;175335:516::-;175408:7;;175390:15;:25;175382:50;;;;-1:-1:-1;;;175382:50:0;;2358:2:1;175382:50:0;;;2340:21:1;2397:2;2377:18;;;2370:30;-1:-1:-1;;;2416:18:1;;;2409:42;2468:18;;175382:50:0;;;;;;;;;175451:16;;-1:-1:-1;;;;;175451:16:0;:30;175443:58;;;;-1:-1:-1;;;175443:58:0;;2699:2:1;175443:58:0;;;2681:21:1;2738:2;2718:18;;;2711:30;-1:-1:-1;;;2757:18:1;;;2750:46;2813:18;;175443:58:0;2497:340:1;175443:58:0;175532:21;175514:15;175601:3;175586:12;175532:21;175596:2;175586:12;:::i;:::-;:18;;;;:::i;:::-;175564:40;-1:-1:-1;175615:23:0;175641:21;175564:40;175641:7;:21;:::i;:::-;175615:47;;175715:15;173999:42;175743:6;;;;;;;;;-1:-1:-1;;;;;175743:6:0;174081:42;173921;175774:11;175702:84;;;;;:::i;:::-;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;175675:16:0;:112;;-1:-1:-1;;;;;;175675:112:0;-1:-1:-1;;;;;175675:112:0;;;;;;;;;;175798:45;175818:10;175831:11;175798;:45::i;:::-;175371:480;;;175335:516::o;174523:662::-;174622:9;;174603:15;:28;;174595:46;;;;-1:-1:-1;;;174595:46:0;;4248:2:1;174595:46:0;;;4230:21:1;4287:1;4267:18;;;4260:29;-1:-1:-1;;;4305:18:1;;;4298:35;4350:18;;174595:46:0;4046:328:1;174595:46:0;174679:7;;174660:15;:26;;174652:43;;;;-1:-1:-1;;;174652:43:0;;;;;;4581:2:1;4563:21;;;4620:1;4600:18;;;4593:29;-1:-1:-1;;;4653:2:1;4638:18;;4631:34;4697:2;4682:18;;4379:327;174652:43:0;174708:20;174731:23;:21;:23::i;:::-;174708:46;;174765:11;174779;174791:12;174779:25;;;;;;;:::i;:::-;;;174765:39;;174846:3;174833:9;:16;;174825:36;;;;-1:-1:-1;;;174825:36:0;;5045:2:1;174825:36:0;;;5027:21:1;5084:1;5064:18;;;5057:29;-1:-1:-1;;;5102:18:1;;;5095:37;5149:18;;174825:36:0;4843:330:1;174825:36:0;174898:10;174881:28;;;;:16;:28;;;;;;;;174880:29;174872:52;;;;-1:-1:-1;;;174872:52:0;;5380:2:1;174872:52:0;;;5362:21:1;5419:2;5399:18;;;5392:30;-1:-1:-1;;;5438:18:1;;;5431:40;5488:18;;174872:52:0;5178:334:1;174872:52:0;174954:10;174937:28;;;;:16;:28;;;;;;:35;;-1:-1:-1;;174937:35:0;174968:4;174937:35;;;;;;174983:11;:28;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;174983:28:0;;;;;175029:39;;;;;175056:3;;175061:6;;;;175029:39;:::i;:::-;;;;;;;;175097:3;175085:9;:15;175081:97;;;175117:49;175137:10;175150:15;175162:3;175150:9;:15;:::i;:::-;175117:11;:49::i;:::-;174584:601;;174523:662;;:::o;175859:168::-;175937:9;175952:2;-1:-1:-1;;;;;175952:7:0;175967:6;175952:26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;175936:42;;;175997:4;175989:30;;;;-1:-1:-1;;;175989:30:0;;6395:2:1;175989:30:0;;;6377:21:1;6434:2;6414:18;;;6407:30;-1:-1:-1;;;6453:18:1;;;6446:43;6506:18;;175989:30:0;6193:337:1;-1:-1:-1;;;;;;;;:::o;404:180:1:-;463:6;516:2;504:9;495:7;491:23;487:32;484:52;;;532:1;529;522:12;484:52;-1:-1:-1;555:23:1;;404:180;-1:-1:-1;404:180:1:o;589:592::-;660:6;668;721:2;709:9;700:7;696:23;692:32;689:52;;;737:1;734;727:12;689:52;764:23;;-1:-1:-1;;;;;836:14:1;;;833:34;;;863:1;860;853:12;833:34;901:6;890:9;886:22;876:32;;946:7;939:4;935:2;931:13;927:27;917:55;;968:1;965;958:12;917:55;1008:2;995:16;1034:2;1026:6;1023:14;1020:34;;;1050:1;1047;1040:12;1020:34;1095:7;1090:2;1081:6;1077:2;1073:15;1069:24;1066:37;1063:57;;;1116:1;1113;1106:12;1063:57;1147:2;1139:11;;;;;1169:6;;-1:-1:-1;589:592:1;;-1:-1:-1;;;;589:592:1:o;1186:286::-;1245:6;1298:2;1286:9;1277:7;1273:23;1269:32;1266:52;;;1314:1;1311;1304:12;1266:52;1340:23;;-1:-1:-1;;;;;1392:31:1;;1382:42;;1372:70;;1438:1;1435;1428:12;1372:70;1461:5;1186:286;-1:-1:-1;;;1186:286:1:o;1669:127::-;1730:10;1725:3;1721:20;1718:1;1711:31;1761:4;1758:1;1751:15;1785:4;1782:1;1775:15;1801:128;1868:9;;;1889:11;;;1886:37;;;1903:18;;:::i;:::-;1801:128;;;;:::o;1934:217::-;1974:1;2000;1990:132;;2044:10;2039:3;2035:20;2032:1;2025:31;2079:4;2076:1;2069:15;2107:4;2104:1;2097:15;1990:132;-1:-1:-1;2136:9:1;;1934:217::o;2842:168::-;2915:9;;;2946;;2963:15;;;2957:22;;2943:37;2933:71;;2984:18;;:::i;3015:1026::-;3266:4;3314:3;3303:9;3299:19;3354:1;3350;3345:3;3341:11;3337:19;3395:2;3387:6;3383:15;3372:9;3365:34;3418:2;3468;3460:6;3456:15;3451:2;3440:9;3436:18;3429:43;3520:2;3512:6;3508:15;3503:2;3492:9;3488:18;3481:43;3572:2;3564:6;3560:15;3555:2;3544:9;3540:18;3533:43;3613:3;3607;3596:9;3592:19;3585:32;3637:6;3672;3666:13;3703:6;3695;3688:22;3741:3;3730:9;3726:19;3719:26;;3764:6;3761:1;3754:17;3807:2;3804:1;3794:16;3780:30;;3828:1;3838:177;3852:6;3849:1;3846:13;3838:177;;;3917:13;;3913:22;;3901:35;;4003:1;3991:14;;;;3956:12;;;;3867:9;3838:177;;;-1:-1:-1;4032:3:1;;3015:1026;-1:-1:-1;;;;;;;;;;;3015:1026:1:o;4711:127::-;4772:10;4767:3;4763:20;4760:1;4753:31;4803:4;4800:1;4793:15;4827:4;4824:1;4817:15;5517:461;5704:6;5693:9;5686:25;5747:2;5742;5731:9;5727:18;5720:30;5786:6;5781:2;5770:9;5766:18;5759:34;5843:6;5835;5830:2;5819:9;5815:18;5802:48;5899:1;5870:22;;;5894:2;5866:31;;;5859:42;;;;5962:2;5941:15;;;-1:-1:-1;;5937:29:1;5922:45;5918:54;;5517:461;-1:-1:-1;;5517:461:1:o

Swarm Source

ipfs://e2c5e443241009dabe9337b743e91caf880417cdcb5ec99ccc7336d90c049b6b

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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