creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the value of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the value of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 value) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n     * caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 value) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the\n     * allowance mechanism. `value` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/utils/ReentrancyGuard.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant NOT_ENTERED = 1;\n    uint256 private constant ENTERED = 2;\n\n    uint256 private _status;\n\n    /**\n     * @dev Unauthorized reentrant call.\n     */\n    error ReentrancyGuardReentrantCall();\n\n    constructor() {\n        _status = NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        _nonReentrantBefore();\n        _;\n        _nonReentrantAfter();\n    }\n\n    function _nonReentrantBefore() private {\n        // On the first call to nonReentrant, _status will be NOT_ENTERED\n        if (_status == ENTERED) {\n            revert ReentrancyGuardReentrantCall();\n        }\n\n        // Any calls to nonReentrant after this point will fail\n        _status = ENTERED;\n    }\n\n    function _nonReentrantAfter() private {\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = NOT_ENTERED;\n    }\n\n    /**\n     * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n     * `nonReentrant` function in the call stack.\n     */\n    function _reentrancyGuardEntered() internal view returns (bool) {\n        return _status == ENTERED;\n    }\n}\n"
      },
      "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IUniswapV3PoolActions#swap\n/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface\ninterface IUniswapV3SwapCallback {\n    /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.\n    /// @dev In the implementation you must pay the pool tokens owed for the swap.\n    /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n    /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.\n    /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\n    /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\n    /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\n    /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\n    /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call\n    function uniswapV3SwapCallback(\n        int256 amount0Delta,\n        int256 amount1Delta,\n        bytes calldata data\n    ) external;\n}\n"
      },
      "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\nimport './pool/IUniswapV3PoolImmutables.sol';\nimport './pool/IUniswapV3PoolState.sol';\nimport './pool/IUniswapV3PoolDerivedState.sol';\nimport './pool/IUniswapV3PoolActions.sol';\nimport './pool/IUniswapV3PoolOwnerActions.sol';\nimport './pool/IUniswapV3PoolEvents.sol';\n\n/// @title The interface for a Uniswap V3 Pool\n/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform\n/// to the ERC20 specification\n/// @dev The pool interface is broken up into many smaller pieces\ninterface IUniswapV3Pool is\n    IUniswapV3PoolImmutables,\n    IUniswapV3PoolState,\n    IUniswapV3PoolDerivedState,\n    IUniswapV3PoolActions,\n    IUniswapV3PoolOwnerActions,\n    IUniswapV3PoolEvents\n{\n\n}\n"
      },
      "@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolActions.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Permissionless pool actions\n/// @notice Contains pool methods that can be called by anyone\ninterface IUniswapV3PoolActions {\n    /// @notice Sets the initial price for the pool\n    /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value\n    /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96\n    function initialize(uint160 sqrtPriceX96) external;\n\n    /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position\n    /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback\n    /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends\n    /// on tickLower, tickUpper, the amount of liquidity, and the current price.\n    /// @param recipient The address for which the liquidity will be created\n    /// @param tickLower The lower tick of the position in which to add liquidity\n    /// @param tickUpper The upper tick of the position in which to add liquidity\n    /// @param amount The amount of liquidity to mint\n    /// @param data Any data that should be passed through to the callback\n    /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback\n    /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback\n    function mint(\n        address recipient,\n        int24 tickLower,\n        int24 tickUpper,\n        uint128 amount,\n        bytes calldata data\n    ) external returns (uint256 amount0, uint256 amount1);\n\n    /// @notice Collects tokens owed to a position\n    /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.\n    /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or\n    /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the\n    /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.\n    /// @param recipient The address which should receive the fees collected\n    /// @param tickLower The lower tick of the position for which to collect fees\n    /// @param tickUpper The upper tick of the position for which to collect fees\n    /// @param amount0Requested How much token0 should be withdrawn from the fees owed\n    /// @param amount1Requested How much token1 should be withdrawn from the fees owed\n    /// @return amount0 The amount of fees collected in token0\n    /// @return amount1 The amount of fees collected in token1\n    function collect(\n        address recipient,\n        int24 tickLower,\n        int24 tickUpper,\n        uint128 amount0Requested,\n        uint128 amount1Requested\n    ) external returns (uint128 amount0, uint128 amount1);\n\n    /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position\n    /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0\n    /// @dev Fees must be collected separately via a call to #collect\n    /// @param tickLower The lower tick of the position for which to burn liquidity\n    /// @param tickUpper The upper tick of the position for which to burn liquidity\n    /// @param amount How much liquidity to burn\n    /// @return amount0 The amount of token0 sent to the recipient\n    /// @return amount1 The amount of token1 sent to the recipient\n    function burn(\n        int24 tickLower,\n        int24 tickUpper,\n        uint128 amount\n    ) external returns (uint256 amount0, uint256 amount1);\n\n    /// @notice Swap token0 for token1, or token1 for token0\n    /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback\n    /// @param recipient The address to receive the output of the swap\n    /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0\n    /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)\n    /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this\n    /// value after the swap. If one for zero, the price cannot be greater than this value after the swap\n    /// @param data Any data to be passed through to the callback\n    /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive\n    /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive\n    function swap(\n        address recipient,\n        bool zeroForOne,\n        int256 amountSpecified,\n        uint160 sqrtPriceLimitX96,\n        bytes calldata data\n    ) external returns (int256 amount0, int256 amount1);\n\n    /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback\n    /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback\n    /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling\n    /// with 0 amount{0,1} and sending the donation amount(s) from the callback\n    /// @param recipient The address which will receive the token0 and token1 amounts\n    /// @param amount0 The amount of token0 to send\n    /// @param amount1 The amount of token1 to send\n    /// @param data Any data to be passed through to the callback\n    function flash(\n        address recipient,\n        uint256 amount0,\n        uint256 amount1,\n        bytes calldata data\n    ) external;\n\n    /// @notice Increase the maximum number of price and liquidity observations that this pool will store\n    /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to\n    /// the input observationCardinalityNext.\n    /// @param observationCardinalityNext The desired minimum number of observations for the pool to store\n    function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;\n}\n"
      },
      "@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolDerivedState.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that is not stored\n/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the\n/// blockchain. The functions here may have variable gas costs.\ninterface IUniswapV3PoolDerivedState {\n    /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp\n    /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing\n    /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,\n    /// you must call it with secondsAgos = [3600, 0].\n    /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in\n    /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.\n    /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned\n    /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp\n    /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block\n    /// timestamp\n    function observe(uint32[] calldata secondsAgos)\n        external\n        view\n        returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);\n\n    /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range\n    /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.\n    /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first\n    /// snapshot is taken and the second snapshot is taken.\n    /// @param tickLower The lower tick of the range\n    /// @param tickUpper The upper tick of the range\n    /// @return tickCumulativeInside The snapshot of the tick accumulator for the range\n    /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range\n    /// @return secondsInside The snapshot of seconds per liquidity for the range\n    function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)\n        external\n        view\n        returns (\n            int56 tickCumulativeInside,\n            uint160 secondsPerLiquidityInsideX128,\n            uint32 secondsInside\n        );\n}\n"
      },
      "@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolEvents.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Events emitted by a pool\n/// @notice Contains all events emitted by the pool\ninterface IUniswapV3PoolEvents {\n    /// @notice Emitted exactly once by a pool when #initialize is first called on the pool\n    /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize\n    /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96\n    /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool\n    event Initialize(uint160 sqrtPriceX96, int24 tick);\n\n    /// @notice Emitted when liquidity is minted for a given position\n    /// @param sender The address that minted the liquidity\n    /// @param owner The owner of the position and recipient of any minted liquidity\n    /// @param tickLower The lower tick of the position\n    /// @param tickUpper The upper tick of the position\n    /// @param amount The amount of liquidity minted to the position range\n    /// @param amount0 How much token0 was required for the minted liquidity\n    /// @param amount1 How much token1 was required for the minted liquidity\n    event Mint(\n        address sender,\n        address indexed owner,\n        int24 indexed tickLower,\n        int24 indexed tickUpper,\n        uint128 amount,\n        uint256 amount0,\n        uint256 amount1\n    );\n\n    /// @notice Emitted when fees are collected by the owner of a position\n    /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees\n    /// @param owner The owner of the position for which fees are collected\n    /// @param tickLower The lower tick of the position\n    /// @param tickUpper The upper tick of the position\n    /// @param amount0 The amount of token0 fees collected\n    /// @param amount1 The amount of token1 fees collected\n    event Collect(\n        address indexed owner,\n        address recipient,\n        int24 indexed tickLower,\n        int24 indexed tickUpper,\n        uint128 amount0,\n        uint128 amount1\n    );\n\n    /// @notice Emitted when a position's liquidity is removed\n    /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect\n    /// @param owner The owner of the position for which liquidity is removed\n    /// @param tickLower The lower tick of the position\n    /// @param tickUpper The upper tick of the position\n    /// @param amount The amount of liquidity to remove\n    /// @param amount0 The amount of token0 withdrawn\n    /// @param amount1 The amount of token1 withdrawn\n    event Burn(\n        address indexed owner,\n        int24 indexed tickLower,\n        int24 indexed tickUpper,\n        uint128 amount,\n        uint256 amount0,\n        uint256 amount1\n    );\n\n    /// @notice Emitted by the pool for any swaps between token0 and token1\n    /// @param sender The address that initiated the swap call, and that received the callback\n    /// @param recipient The address that received the output of the swap\n    /// @param amount0 The delta of the token0 balance of the pool\n    /// @param amount1 The delta of the token1 balance of the pool\n    /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96\n    /// @param liquidity The liquidity of the pool after the swap\n    /// @param tick The log base 1.0001 of price of the pool after the swap\n    event Swap(\n        address indexed sender,\n        address indexed recipient,\n        int256 amount0,\n        int256 amount1,\n        uint160 sqrtPriceX96,\n        uint128 liquidity,\n        int24 tick\n    );\n\n    /// @notice Emitted by the pool for any flashes of token0/token1\n    /// @param sender The address that initiated the swap call, and that received the callback\n    /// @param recipient The address that received the tokens from flash\n    /// @param amount0 The amount of token0 that was flashed\n    /// @param amount1 The amount of token1 that was flashed\n    /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee\n    /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee\n    event Flash(\n        address indexed sender,\n        address indexed recipient,\n        uint256 amount0,\n        uint256 amount1,\n        uint256 paid0,\n        uint256 paid1\n    );\n\n    /// @notice Emitted by the pool for increases to the number of observations that can be stored\n    /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index\n    /// just before a mint/swap/burn.\n    /// @param observationCardinalityNextOld The previous value of the next observation cardinality\n    /// @param observationCardinalityNextNew The updated value of the next observation cardinality\n    event IncreaseObservationCardinalityNext(\n        uint16 observationCardinalityNextOld,\n        uint16 observationCardinalityNextNew\n    );\n\n    /// @notice Emitted when the protocol fee is changed by the pool\n    /// @param feeProtocol0Old The previous value of the token0 protocol fee\n    /// @param feeProtocol1Old The previous value of the token1 protocol fee\n    /// @param feeProtocol0New The updated value of the token0 protocol fee\n    /// @param feeProtocol1New The updated value of the token1 protocol fee\n    event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);\n\n    /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner\n    /// @param sender The address that collects the protocol fees\n    /// @param recipient The address that receives the collected protocol fees\n    /// @param amount0 The amount of token0 protocol fees that is withdrawn\n    /// @param amount0 The amount of token1 protocol fees that is withdrawn\n    event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);\n}\n"
      },
      "@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolImmutables.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that never changes\n/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values\ninterface IUniswapV3PoolImmutables {\n    /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface\n    /// @return The contract address\n    function factory() external view returns (address);\n\n    /// @notice The first of the two tokens of the pool, sorted by address\n    /// @return The token contract address\n    function token0() external view returns (address);\n\n    /// @notice The second of the two tokens of the pool, sorted by address\n    /// @return The token contract address\n    function token1() external view returns (address);\n\n    /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6\n    /// @return The fee\n    function fee() external view returns (uint24);\n\n    /// @notice The pool tick spacing\n    /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive\n    /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...\n    /// This value is an int24 to avoid casting even though it is always positive.\n    /// @return The tick spacing\n    function tickSpacing() external view returns (int24);\n\n    /// @notice The maximum amount of position liquidity that can use any tick in the range\n    /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and\n    /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool\n    /// @return The max amount of liquidity per tick\n    function maxLiquidityPerTick() external view returns (uint128);\n}\n"
      },
      "@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolOwnerActions.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Permissioned pool actions\n/// @notice Contains pool methods that may only be called by the factory owner\ninterface IUniswapV3PoolOwnerActions {\n    /// @notice Set the denominator of the protocol's % share of the fees\n    /// @param feeProtocol0 new protocol fee for token0 of the pool\n    /// @param feeProtocol1 new protocol fee for token1 of the pool\n    function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;\n\n    /// @notice Collect the protocol fee accrued to the pool\n    /// @param recipient The address to which collected protocol fees should be sent\n    /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1\n    /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0\n    /// @return amount0 The protocol fee collected in token0\n    /// @return amount1 The protocol fee collected in token1\n    function collectProtocol(\n        address recipient,\n        uint128 amount0Requested,\n        uint128 amount1Requested\n    ) external returns (uint128 amount0, uint128 amount1);\n}\n"
      },
      "@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolState.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that can change\n/// @notice These methods compose the pool's state, and can change with any frequency including multiple times\n/// per transaction\ninterface IUniswapV3PoolState {\n    /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas\n    /// when accessed externally.\n    /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value\n    /// tick The current tick of the pool, i.e. according to the last tick transition that was run.\n    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick\n    /// boundary.\n    /// observationIndex The index of the last oracle observation that was written,\n    /// observationCardinality The current maximum number of observations stored in the pool,\n    /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.\n    /// feeProtocol The protocol fee for both tokens of the pool.\n    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0\n    /// 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.\n    /// unlocked Whether the pool is currently locked to reentrancy\n    function slot0()\n        external\n        view\n        returns (\n            uint160 sqrtPriceX96,\n            int24 tick,\n            uint16 observationIndex,\n            uint16 observationCardinality,\n            uint16 observationCardinalityNext,\n            uint8 feeProtocol,\n            bool unlocked\n        );\n\n    /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool\n    /// @dev This value can overflow the uint256\n    function feeGrowthGlobal0X128() external view returns (uint256);\n\n    /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool\n    /// @dev This value can overflow the uint256\n    function feeGrowthGlobal1X128() external view returns (uint256);\n\n    /// @notice The amounts of token0 and token1 that are owed to the protocol\n    /// @dev Protocol fees will never exceed uint128 max in either token\n    function protocolFees() external view returns (uint128 token0, uint128 token1);\n\n    /// @notice The currently in range liquidity available to the pool\n    /// @dev This value has no relationship to the total liquidity across all ticks\n    function liquidity() external view returns (uint128);\n\n    /// @notice Look up information about a specific tick in the pool\n    /// @param tick The tick to look up\n    /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or\n    /// tick upper,\n    /// liquidityNet how much liquidity changes when the pool price crosses the tick,\n    /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,\n    /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,\n    /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick\n    /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,\n    /// secondsOutside the seconds spent on the other side of the tick from the current tick,\n    /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.\n    /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.\n    /// In addition, these values are only relative and must be used only in comparison to previous snapshots for\n    /// a specific position.\n    function ticks(int24 tick)\n        external\n        view\n        returns (\n            uint128 liquidityGross,\n            int128 liquidityNet,\n            uint256 feeGrowthOutside0X128,\n            uint256 feeGrowthOutside1X128,\n            int56 tickCumulativeOutside,\n            uint160 secondsPerLiquidityOutsideX128,\n            uint32 secondsOutside,\n            bool initialized\n        );\n\n    /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information\n    function tickBitmap(int16 wordPosition) external view returns (uint256);\n\n    /// @notice Returns the information about a position by the position's key\n    /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper\n    /// @return _liquidity The amount of liquidity in the position,\n    /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,\n    /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,\n    /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,\n    /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke\n    function positions(bytes32 key)\n        external\n        view\n        returns (\n            uint128 _liquidity,\n            uint256 feeGrowthInside0LastX128,\n            uint256 feeGrowthInside1LastX128,\n            uint128 tokensOwed0,\n            uint128 tokensOwed1\n        );\n\n    /// @notice Returns data about a specific observation index\n    /// @param index The element of the observations array to fetch\n    /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time\n    /// ago, rather than at a specific index in the array.\n    /// @return blockTimestamp The timestamp of the observation,\n    /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,\n    /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,\n    /// Returns initialized whether the observation has been initialized and the values are safe to use\n    function observations(uint256 index)\n        external\n        view\n        returns (\n            uint32 blockTimestamp,\n            int56 tickCumulative,\n            uint160 secondsPerLiquidityCumulativeX128,\n            bool initialized\n        );\n}\n"
      },
      "@uniswap/v3-core/contracts/libraries/FixedPoint96.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.4.0;\n\n/// @title FixedPoint96\n/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)\n/// @dev Used in SqrtPriceMath.sol\nlibrary FixedPoint96 {\n    uint8 internal constant RESOLUTION = 96;\n    uint256 internal constant Q96 = 0x1000000000000000000000000;\n}\n"
      },
      "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.6.0;\n\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\n\nlibrary TransferHelper {\n    /// @notice Transfers tokens from the targeted address to the given destination\n    /// @notice Errors with 'STF' if transfer fails\n    /// @param token The contract address of the token to be transferred\n    /// @param from The originating address from which the tokens will be transferred\n    /// @param to The destination address of the transfer\n    /// @param value The amount to be transferred\n    function safeTransferFrom(\n        address token,\n        address from,\n        address to,\n        uint256 value\n    ) internal {\n        (bool success, bytes memory data) =\n            token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value));\n        require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');\n    }\n\n    /// @notice Transfers tokens from msg.sender to a recipient\n    /// @dev Errors with ST if transfer fails\n    /// @param token The contract address of the token which will be transferred\n    /// @param to The recipient of the transfer\n    /// @param value The value of the transfer\n    function safeTransfer(\n        address token,\n        address to,\n        uint256 value\n    ) internal {\n        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));\n        require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');\n    }\n\n    /// @notice Approves the stipulated contract to spend the given allowance in the given token\n    /// @dev Errors with 'SA' if transfer fails\n    /// @param token The contract address of the token to be approved\n    /// @param to The target of the approval\n    /// @param value The amount of the given token the target will be allowed to spend\n    function safeApprove(\n        address token,\n        address to,\n        uint256 value\n    ) internal {\n        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));\n        require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');\n    }\n\n    /// @notice Transfers ETH to the recipient address\n    /// @dev Fails with `STE`\n    /// @param to The destination of the transfer\n    /// @param value The value to be transferred\n    function safeTransferETH(address to, uint256 value) internal {\n        (bool success, ) = to.call{value: value}(new bytes(0));\n        require(success, 'STE');\n    }\n}\n"
      },
      "contracts/GnomeFactory.sol": {
        "content": "// SPDX-License-Identifier: MIT\n/*\n\n░██████╗░███╗░░██╗░█████╗░███╗░░░███╗███████╗██╗░░░░░░█████╗░███╗░░██╗██████╗░\n██╔════╝░████╗░██║██╔══██╗████╗░████║██╔════╝██║░░░░░██╔══██╗████╗░██║██╔══██╗\n██║░░██╗░██╔██╗██║██║░░██║██╔████╔██║█████╗░░██║░░░░░███████║██╔██╗██║██║░░██║\n██║░░╚██╗██║╚████║██║░░██║██║╚██╔╝██║██╔══╝░░██║░░░░░██╔══██║██║╚████║██║░░██║\n╚██████╔╝██║░╚███║╚█████╔╝██║░╚═╝░██║███████╗███████╗██║░░██║██║░╚███║██████╔╝\n░╚═════╝░╚═╝░░╚══╝░╚════╝░╚═╝░░░░░╚═╝╚══════╝╚══════╝╚═╝░░╚═╝╚═╝░░╚══╝╚═════╝░\n\n                                   ╓╓╓▄▄▄▓▓█▓▓▓▓▀▀▀▀▀▀▓█\n                             ╓▄██▀╙╙░░░░░░░░░░░░░░░░╠╬║█\n                        ╓▄▓▀╙░░░░░░░░░░░░░░░░░░░░░░╠╠╠║▌\n                     ╓█╩░░░░░░░░░░░░░░░░░░░░░░░░░░╠╠╠╠║▌\n                   ▄█▒░░░░░░░░░░░░░▒▄██████▄▄░░░░░╠╠╠╠║▌\n                 ╓██▀▀▀╙╙╚▀░░░░░▄██╩░░░░░░░░╙▀█▄▒░╠╠╠╠╬█\n              ╓▓▀╙░░░░░░░░░░░░░╚╩░░░░░░░░░░░░░░╙▀█╠╠╠╠╬▓\n             ▄╩░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╠╠╠╠╠║▌\n            ║██▓▓▓▓▓▄▄▒░░░░░░░░░░░▄▄██▓█▄▄▒░░░░░░░╠╠╠╠╠╬█\n           ╔▀         ╙▀▀█▓▄▄▄██▀╙       └╙▀█▄▒░░░╠╠╠╠╠╠║▌\n          ║█▀▀╙╙╙▀▀▓▄╖       ▄▄▓▓▓▓╗▄▄╓      ╙╙█▄▒░╠╠╠╠╠╬█\n        ╓▀   ╓╓╓╓╓╓   ╙█▄ ▄▀╙          ╙▀▓▄      ╙▀▓▒▒╠╠╠║▌\n        ▐██████████╙╙▀█▄ ╙█▄▓████████▀▀╗▄           █▀███╬█\n        █║██████▌ ██    ╙██╓███████╙▀█   └▀╗╓       ║▒   ╙╙▓\n       ╒▌╫███████╦╫█     ║ ╫███████╓▄█▌     └█╕     ║▌    ▀█▀▀\n        █╚██████████    ╓╣ ║██████████▒    ╔▀╙      ║▒     └█\n       ┌╣█╣████████╓╓▄▓▓▒▄█▄║████████▌╓╗╗▀╙        ╓█        ╚▄\n       │█▄╗▀▀╙      ╙▀╙         ╙▀▀██▒            ▄█          ╙▄\n     █▒                               ╙▀▀▀▀╠█▌╓▄▓▀             ║\n      ╙█╓           ╓╓                   ╓██╩║▌                ║\n       ╓╣███▄▄▄▄▓██╬╬╠╬███▄▄▄▄╓╓╓╓╓▄▄▄▓█╬╬▒░░╠█             ╔ ┌█\n      ╓▌  ▀█╬╬▒╠╠╠╠░▒░░░╠╠╠╚╚╚╩╠╠╠╠╬███▀╩░░░▄█        ▓      █▀\n     ╒▌   ╘█░╚╚╚╚╚▀▀▀▀▀▀▀▀▀▀▀▀▀▀╚╚╚░░░░░░▄█▀╙         ║      ▐▌\n     ╟     └▀█▄▒▒▒░░░░░░░░░░░▒▒▒▒▒▄▄█▓╝▀╙                    ▐▌\n     ║░        ╙╙▀▀▀▀▀▀▀▀▀▀▀▀▀▀╙╙                        ╓   █\n      █                                                  ▓ ╓█\n      ║▌   ╔                                            ╔█▀\n       █   ╚▄                              ╓╩          ╔▀\n       ╚▌   ╙                             ▓▀         ╓█╙\n        ╙▌          ▐                  ╓═    ▄    ╓▄▀╙\n          ▀▄        ╙▒                      ▄██▄█▀\n            ╙▀▄╓║▄   └                    ▄╩\n                ╙▀█                   ╓▄▀▀\n                   ▀▓        ▄▄▓▀▀▀▀╙\n                     └▀╗▄╓▄▀╙\n    \n\nGnome Factory:\n    Mints Gnomes and creates UniV3 concentrated liquidity position for $GNOME/WETH.\nhttps://www.gnomeland.money/\nhttps://twitter.com/Gnome0xLand\n\n\n\n\n */\npragma solidity ^0.8.20;\nimport {TickMath} from \"./Utils/TickMath.sol\";\nimport {FullMath, LiquidityAmounts} from \"./Utils/LiquidityAmounts.sol\";\nimport \"@openzeppelin/contracts/utils/ReentrancyGuard.sol\";\nimport {IUniswapV3Pool} from \"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\";\npragma abicoder v2;\nimport \"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\";\nimport \"@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol\";\n//import \"@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol\";\nimport \"@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol\";\n\ninterface IUniswapV3Factory {\n    function owner() external view returns (address);\n\n    function feeAmountTickSpacing(uint24 fee) external view returns (int24);\n\n    function getPool(address tokenA, address tokenB, uint24 fee) external view returns (address pool);\n\n    function createPool(address tokenA, address tokenB, uint24 fee) external returns (address pool);\n    function setOwner(address _owner) external;\n    function enableFeeAmount(uint24 fee, int24 tickSpacing) external;\n}\n\ninterface IWETH {\n    function deposit() external payable;\n    function transfer(address to, uint value) external returns (bool);\n    function approve(address spender, uint value) external returns (bool);\n    function balanceOf(address) external view returns (uint256);\n    function withdraw(uint256) external;\n}\n\ninterface ISwapRouter is IUniswapV3SwapCallback {\n    struct ExactInputSingleParams {\n        address tokenIn;\n        address tokenOut;\n        uint24 fee;\n        address recipient;\n        uint256 amountIn;\n        uint256 amountOutMinimum;\n        uint160 sqrtPriceLimitX96;\n    }\n\n    /// @notice Swaps `amountIn` of one token for as much as possible of another token\n    /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n    /// @return amountOut The amount of the received token\n    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n}\n\ninterface IMinimalNonfungiblePositionManager {\n    function createAndInitializePoolIfNecessary(\n        address token0,\n        address token1,\n        uint24 fee,\n        uint160 sqrtPriceX96\n    ) external payable returns (address pool);\n    function positions(\n        uint256 tokenId\n    )\n        external\n        view\n        returns (\n            uint96 nonce,\n            address operator,\n            address token0,\n            address token1,\n            uint24 fee,\n            int24 tickLower,\n            int24 tickUpper,\n            uint128 liquidity,\n            uint256 feeGrowthInside0LastX128,\n            uint256 feeGrowthInside1LastX128,\n            uint128 tokensOwed0,\n            uint128 tokensOwed1\n        );\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n    struct DecreaseLiquidityParams {\n        uint256 tokenId;\n        uint128 liquidity;\n        uint256 amount0Min;\n        uint256 amount1Min;\n        uint256 deadline;\n    }\n    struct CollectParams {\n        uint256 tokenId;\n        address recipient;\n        uint128 amount0Max;\n        uint128 amount1Max;\n    }\n    struct MintParams {\n        address token0;\n        address token1;\n        uint24 fee;\n        int24 tickLower;\n        int24 tickUpper;\n        uint256 amount0Desired;\n        uint256 amount1Desired;\n        uint256 amount0Min;\n        uint256 amount1Min;\n        address recipient;\n        uint256 deadline;\n    }\n    struct IncreaseLiquidityParams {\n        uint256 tokenId;\n        uint256 amount0Desired;\n        uint256 amount1Desired;\n        uint256 amount0Min;\n        uint256 amount1Min;\n        uint256 deadline;\n    }\n\n    function increaseLiquidity(\n        IncreaseLiquidityParams calldata params\n    ) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1);\n    function decreaseLiquidity(\n        DecreaseLiquidityParams calldata params\n    ) external payable returns (uint256 amount0, uint256 amount1);\n\n    function mint(\n        MintParams calldata params\n    ) external returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\n    function burn(uint256 tokenId) external;\n\n    /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient\n    /// @param params tokenId The ID of the NFT for which tokens are being collected,\n    /// recipient The account that should receive the tokens,\n    /// amount0Max The maximum amount of token0 to collect,\n    /// amount1Max The maximum amount of token1 to collect\n    /// @return amount0 The amount of fees collected in token0\n    /// @return amount1 The amount of fees collected in token1\n    function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);\n}\n\ninterface IGNOME {\n    function balanceOf(address) external view returns (uint256);\n    function approve(address spender, uint value) external returns (bool);\n    function enableTrading() external returns (bool);\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n    function transfer(address to, uint256 amount) external returns (bool);\n    function initialize(uint160 sqrtPriceX96) external;\n    function getTokenId() external view returns (uint256);\n    function factoryMint(address fren) external returns (uint256);\n    function signUpReferral(string memory code, address sender, uint gnomeAmount) external;\n    function signUpFactory(uint256 _id, string memory _Xusr, uint256 baseEmotion) external;\n    function setTreasuryMintTimeStamp(address gnome, uint256 timeStamp) external;\n    function setGnomeEmotion(uint256 tokenId, uint256 _gnomeEmotion) external;\n}\n\ncontract GnomesFactory is ReentrancyGuard {\n    IMinimalNonfungiblePositionManager private positionManager;\n\n    struct StakedPosition {\n        uint256 tokenId;\n        uint128 liquidity;\n        uint256 stakedAt;\n        uint256 lastRewardTime;\n    }\n\n    IUniswapV3Pool private pool;\n    ISwapRouter private constant swapRouter = ISwapRouter(0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45);\n    address private constant WETH_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n    address private POSITION_MANAGER_ADDRESS = 0xC36442b4a4522E871399CD717aBDD847Ab11FE88;\n    mapping(address => bool) public isAuth;\n\n    mapping(address => uint256) public gnomeReward;\n    mapping(address => uint256) public gameReward;\n\n    mapping(address => StakedPosition) public stakedPositions;\n    address public GNOME_ADDRESS;\n    address public GNOME_REFERRAL;\n    address public GNOME_NFT_ADDRESS;\n    address public GNOME_GAME_ADDRESS;\n    address public GNOME_NFT_POOL;\n    address public GNOME_POOL;\n    int24 public tickSpacing = 200; // spacing of the gnome/ETH pool\n\n    uint256 private SQRT_0005_PERCENT = 223606797784075547; //\n    uint256 private SQRT_2000_PERCENT = 4472135955099137979; //\n    uint256 private positionIndex = 0; //\n    mapping(uint256 => uint256) public positionByIndex;\n    uint160 private sqrtPriceLimitX96 = type(uint160).max;\n    uint256 public treasuryDiscount = 86;\n    uint256 public referralDiscount = 66;\n    bool flip = false;\n    bool flipNFT = true;\n\n    bool private mintOpened = false;\n    bool private mintReferral = false;\n    bool private communityOwned = false;\n    uint256[] public stakedTokenIds;\n    address public owner;\n    uint32 _twapInterval = 0;\n\n    bool fullrange = true;\n    bool nftPoolWeth = false;\n    int24 MinTick = -887200; // Replace with actual min tick for the pool\n    int24 MaxTick = 887200; // Replace with actual max tick for the pool\n    uint128 public totalStakedLiquidity;\n    uint256 public dailyRewardAmount = 1 * 10 ** 18; // Daily reward amount in gnome tokens\n    uint256 private initRewardTime;\n    uint256 private mulNFT = 10000000;\n    uint256 private divNFT = 100000;\n    uint256 private finalDiv = 100000;\n    uint256 private finalMul = 100000000000;\n    uint256 private treasuryDelay = 7 days; //CHANGE THIS\n    event mintedGnomeReferral(address indexed from, string gnomeName, uint256 gnomePrice);\n    event mintedGnome(address indexed from, string gnomeName, uint256 gnomePrice);\n    event feesCollected(uint256 amount0, uint256 amount1);\n\n    constructor(address gnomeNFT, address gnome, address gnomeReferral, address gnomeGame) {\n        owner = msg.sender;\n        isAuth[owner] = true;\n        isAuth[address(this)] = true;\n        GNOME_ADDRESS = gnome;\n        GNOME_NFT_ADDRESS = gnomeNFT;\n        GNOME_REFERRAL = gnomeReferral;\n        GNOME_GAME_ADDRESS = gnomeGame;\n\n        positionManager = IMinimalNonfungiblePositionManager(POSITION_MANAGER_ADDRESS); //\n    }\n\n    modifier onlyOwner() {\n        require(msg.sender == owner, \"Caller is not the authorized\");\n        _;\n    }\n    // Modifier to restrict access to owner only\n    modifier onlyAuth() {\n        require(msg.sender == owner || isAuth[msg.sender], \"Caller is not the authorized\");\n        _;\n    }\n\n    function setSqrtPriceLimitX96(uint160 _sqrtPriceLimitX96) external onlyAuth {\n        sqrtPriceLimitX96 = _sqrtPriceLimitX96;\n    }\n\n    function setMulDiv(\n        uint256 _mulNFT,\n        uint256 _divNFT,\n        uint256 _divfinal,\n        uint256 _mulfinal,\n        bool _nftPoolWeth\n    ) external onlyAuth {\n        mulNFT = _mulNFT;\n        divNFT = _divNFT;\n        nftPoolWeth = _nftPoolWeth;\n        finalDiv = _divfinal;\n        finalMul = _mulfinal;\n    }\n\n    function setFlips(bool _flipNFT, bool _flip) external onlyAuth {\n        flipNFT = _flipNFT;\n        flip = _flip;\n    }\n\n    function setIsCommunityOwned(bool _communityOwned) external onlyAuth {\n        communityOwned = _communityOwned;\n    }\n\n    function openMint(bool _mintOpened) external onlyAuth {\n        mintOpened = _mintOpened;\n    }\n\n    function openReferral(bool _mintOpened) external onlyAuth {\n        mintReferral = _mintOpened;\n    }\n\n    function setIsAuth(address fren, bool isAuthorized) external onlyAuth {\n        isAuth[fren] = isAuthorized;\n    }\n\n    function setPool741(address _gnomePool404) external onlyAuth {\n        require(_gnomePool404 != address(0), \"Invalid Pool address\");\n\n        GNOME_NFT_POOL = _gnomePool404;\n    }\n\n    function setMiContracts(\n        address _gnome,\n        address _gnomeNFT,\n        address _gnomeReferral,\n        address _gnomeGame\n    ) external onlyAuth {\n        require(_gnome != address(0), \"Invalid GNOME address\");\n        require(_gnomeNFT != address(0), \"Invalid GNOME NFT address\");\n        require(_gnomeReferral != address(0), \"Invalid GNOME Referral address\");\n        require(_gnomeGame != address(0), \"Invalid GNOME Game address\");\n        GNOME_ADDRESS = _gnome;\n        GNOME_NFT_ADDRESS = _gnomeNFT;\n        GNOME_REFERRAL = _gnomeReferral;\n        GNOME_GAME_ADDRESS = _gnomeGame;\n    }\n\n    function setPool(address _pool) public onlyAuth {\n        GNOME_POOL = _pool;\n        pool = IUniswapV3Pool(_pool);\n    }\n\n    function getPositionValue(\n        uint256 tokenId\n    ) public view returns (uint128 liquidity, address token0, address token1, int24 tickLower, int24 tickUpper) {\n        (\n            ,\n            ,\n            // nonce\n            // operator\n            address _token0, // token0\n            address _token1, // token1 // fee\n            ,\n            int24 _tickLower, // tickLower\n            int24 _tickUpper, // tickUpper\n            uint128 _liquidity, // liquidity // feeGrowthInside0LastX128 // feeGrowthInside1LastX128 // tokensOwed0 // tokensOwed1\n            ,\n            ,\n            ,\n\n        ) = positionManager.positions(tokenId);\n\n        return (_liquidity, _token0, _token1, _tickLower, _tickUpper);\n    }\n\n    function setDailyRewardAmount(uint256 _amount) external onlyOwner {\n        dailyRewardAmount = _amount;\n    }\n\n    function pendingRewards(address user) public view returns (uint256 rewards) {\n        rewards = gnomeReward[user];\n    }\n\n    function div64x64(uint128 x, uint128 y) internal pure returns (uint128) {\n        unchecked {\n            require(y != 0);\n\n            uint256 answer = (uint256(x) << 64) / y;\n\n            require(answer <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n            return uint128(answer);\n        }\n    }\n\n    function claimRewards() public nonReentrant {\n        StakedPosition storage position = stakedPositions[msg.sender];\n        // require(isGnomeInRange(msg.sender, false), \"Rebalance your Gnome\");\n        require(communityOwned, \"Gnomes not ready yet\");\n\n        // Add pending inflationary rewards to rewards\n        uint256 rewards = gnomeReward[msg.sender];\n\n        require(rewards > 0, \"No rewards available\");\n\n        // Set gnomeReward[msg.sender] to zero\n        gnomeReward[msg.sender] = 0;\n\n        position.lastRewardTime = block.timestamp; // Update the last reward time\n\n        // Transfer gnome tokens to the user\n        // Ensure that the contract has enough gnome tokens and is authorized to distribute them\n        require(IGNOME(GNOME_ADDRESS).balanceOf(address(this)) >= rewards, \"No more $gnome to give\");\n\n        IGNOME(GNOME_ADDRESS).transfer(msg.sender, rewards);\n\n        // Emit an event if necessary\n        // emit RewardsClaimed(msg.sender, rewards);\n    }\n\n    function onERC721Received(address, address from, uint256 tokenId, bytes memory) public virtual returns (bytes4) {\n        return this.onERC721Received.selector;\n    }\n\n    function collectAllFees() external returns (uint256 totalAmount0, uint256 totalAmount1) {\n        uint256 amount0;\n        uint256 amount1;\n\n        for (uint i = 0; i < stakedTokenIds.length; i++) {\n            IMinimalNonfungiblePositionManager.CollectParams memory params = IMinimalNonfungiblePositionManager\n                .CollectParams({\n                    tokenId: stakedTokenIds[i],\n                    recipient: address(this),\n                    amount0Max: type(uint128).max,\n                    amount1Max: type(uint128).max\n                });\n\n            (amount0, amount1) = positionManager.collect(params);\n            totalAmount0 += amount0;\n            totalAmount1 += amount1;\n        }\n        emit feesCollected(amount0, amount1);\n    }\n\n    function frensFundus() public payable onlyOwner {\n        (bool success, ) = payable(msg.sender).call{value: address(this).balance}(\"\");\n        require(success);\n    }\n\n    function setDiscounts(uint256 _treasuryDiscount, uint256 _referralDiscount) external onlyAuth {\n        treasuryDiscount = _treasuryDiscount;\n        referralDiscount = _referralDiscount;\n    }\n\n    function somethingAboutTokens(address token) external onlyOwner {\n        uint256 balance = IGNOME(token).balanceOf(address(this));\n        IGNOME(token).transfer(msg.sender, balance);\n    }\n\n    function swapWETH(uint value) public payable returns (uint amountOut) {\n        // Approve the router to spend WETH\n        IWETH(WETH_ADDRESS).approve(address(swapRouter), value);\n\n        // Set up swap parameters\n        ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({\n            tokenIn: WETH_ADDRESS,\n            tokenOut: GNOME_ADDRESS,\n            fee: 10000, // Assuming a 0.1% pool fee\n            recipient: address(this),\n            amountIn: value,\n            amountOutMinimum: 0,\n            sqrtPriceLimitX96: 0\n        });\n\n        // Perform the swap\n        amountOut = swapRouter.exactInputSingle(params);\n    }\n\n    function swapETH_Half(uint value, bool isWETH) public payable returns (uint amountGnome, uint amountWeth) {\n        if (!isWETH) {\n            // Wrap ETH to WETH\n            IWETH(WETH_ADDRESS).deposit{value: msg.value}();\n            assert(IWETH(WETH_ADDRESS).transfer(address(this), value));\n        }\n\n        uint amountToSwap = msg.value / 2;\n\n        // Approve the router to spend WETH\n        IWETH(WETH_ADDRESS).approve(address(swapRouter), msg.value);\n\n        // Set up swap parameters\n        ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({\n            tokenIn: WETH_ADDRESS,\n            tokenOut: GNOME_ADDRESS,\n            fee: 10000, // Assuming a 0.1% pool fee\n            recipient: address(this),\n            amountIn: amountToSwap,\n            amountOutMinimum: 0,\n            sqrtPriceLimitX96: 0\n        });\n\n        // Perform the swap\n        amountGnome = swapRouter.exactInputSingle(params);\n    }\n\n    function mintGnome(\n        string memory userX,\n        uint256 baseEmotion\n    )\n        public\n        payable\n        returns (uint _tokenId, uint128 liquidity, uint amount0, uint amount1, uint refund0, uint refund1)\n    {\n        require(msg.value >= getGnomeNFTPrice(), \"Not Enough to mint Gnome\");\n        if (!isAuth[msg.sender]) {\n            require(mintOpened, \"Minting Not Opened to Public\");\n        }\n        // uint numberOfGnomes = msg.value / (getGnomeNFTPrice()); // 1 Gnome costs 0.0333 ETH\n        uint amountWETHBefore = IWETH(WETH_ADDRESS).balanceOf(address(this));\n        (uint amountGnome, uint amountWeth) = swapETH_Half(msg.value, false);\n        uint amountWETHAfter = IWETH(WETH_ADDRESS).balanceOf(address(this));\n        uint amountWETH = amountWETHAfter - amountWETHBefore;\n\n        // For this example, we will provide equal amounts of liquidity in both assets.\n        // Providing liquidity in both assets means liquidity will be earning fees and is considered in-range.\n        uint amount0ToMint = amountGnome;\n        uint amount1ToMint = amountWETH;\n\n        // Approve the position manager\n        TransferHelper.safeApprove(GNOME_ADDRESS, address(POSITION_MANAGER_ADDRESS), amount0ToMint);\n        TransferHelper.safeApprove(WETH_ADDRESS, address(POSITION_MANAGER_ADDRESS), amount1ToMint);\n        //  for (uint i = 0; i < numberOfGnomes; i++) {\n        uint256 id = IGNOME(GNOME_NFT_ADDRESS).factoryMint(msg.sender);\n        IGNOME(GNOME_GAME_ADDRESS).signUpFactory(id, userX, baseEmotion);\n\n        // }\n        IGNOME(GNOME_NFT_ADDRESS).setTreasuryMintTimeStamp(msg.sender, block.timestamp + treasuryDelay);\n\n        emit mintedGnome(msg.sender, userX, getGnomeNFTPrice());\n        if (isGnomeInRange(msg.sender, true)) {\n            return increasePosition(msg.sender, amountGnome, amountWETH);\n        } else {\n            return mintPosition(msg.sender, address(this), amountGnome, amountWETH);\n        }\n    }\n\n    function mintGnomeReferral(\n        string memory code,\n        string memory userX,\n        uint256 baseEmotion\n    )\n        public\n        payable\n        returns (uint _tokenId, uint128 liquidity, uint amount0, uint amount1, uint refund0, uint refund1)\n    {\n        if (!isAuth[msg.sender]) {\n            require(mintOpened, \"Minting Not Opened to Public\");\n        }\n        require(msg.value >= getGnomeNFTPriceReferral(), \"Not Enough to mint Gnome\");\n        if (!isAuth[msg.sender]) {\n            require(mintReferral, \"Minting Not Opened to Referrals\");\n        }\n        // uint numberOfGnomes = msg.value / getGnomeNFTPriceReferral(); // 1 Gnome costs 0.0111 ETH\n\n        IGNOME(GNOME_REFERRAL).signUpReferral(code, msg.sender, 1);\n        uint amountWETHBefore = IWETH(WETH_ADDRESS).balanceOf(address(this));\n        (uint amountGnome, uint amountWeth) = swapETH_Half(msg.value, false);\n        uint amountWETHAfter = IWETH(WETH_ADDRESS).balanceOf(address(this));\n        uint amountWETH = amountWETHAfter - amountWETHBefore;\n\n        // For this example, we will provide equal amounts of liquidity in both assets.\n        // Providing liquidity in both assets means liquidity will be earning fees and is considered in-range.\n        uint amount0ToMint = amountGnome;\n        uint amount1ToMint = amountWETH;\n\n        // Approve the position manager\n        TransferHelper.safeApprove(GNOME_ADDRESS, address(POSITION_MANAGER_ADDRESS), amount0ToMint);\n        TransferHelper.safeApprove(WETH_ADDRESS, address(POSITION_MANAGER_ADDRESS), amount1ToMint);\n        // for (uint i = 0; i < numberOfGnomes; i++) {\n        uint256 id = IGNOME(GNOME_NFT_ADDRESS).factoryMint(msg.sender);\n        IGNOME(GNOME_GAME_ADDRESS).signUpFactory(id, userX, baseEmotion);\n        emit mintedGnomeReferral(msg.sender, userX, getGnomeNFTPriceReferral());\n        //  }\n        IGNOME(GNOME_NFT_ADDRESS).setTreasuryMintTimeStamp(msg.sender, block.timestamp + treasuryDelay);\n        if (isGnomeInRange(msg.sender, true)) {\n            return increasePosition(msg.sender, amountGnome, amountWETH);\n        } else {\n            return mintPosition(msg.sender, address(this), amountGnome, amountWETH);\n        }\n    }\n\n    function withdrawOutOfRangePositionAuth(uint256 tokenId) public nonReentrant onlyAuth {\n        (uint128 liquidity, , , , ) = getPositionValue(tokenId);\n        // Transfer the NFT back to the user\n        positionManager.safeTransferFrom(address(this), msg.sender, tokenId, \"\");\n\n        totalStakedLiquidity -= liquidity;\n        // Clear the staked position data\n        // Remove the tokenId from the stakedTokenIds array\n        for (uint i = 0; i < stakedTokenIds.length; i++) {\n            if (stakedTokenIds[i] == tokenId) {\n                stakedTokenIds[i] = stakedTokenIds[stakedTokenIds.length - 1];\n                stakedTokenIds.pop();\n                break;\n            }\n        }\n\n        removeTokenIdFromArray(tokenId);\n    }\n\n    function getTwapX96(address uniswapV3Pool, uint32 twapInterval, bool _isNFT) public view returns (uint256 price) {\n        if (twapInterval == 0) {\n            // return the current price if twapInterval == 0\n            (uint160 sqrtPriceX96, , , , , , ) = IUniswapV3Pool(uniswapV3Pool).slot0();\n\n            uint256 amount0 = FullMath.mulDiv(\n                IUniswapV3Pool(uniswapV3Pool).liquidity(),\n                FixedPoint96.Q96,\n                sqrtPriceX96\n            );\n\n            uint256 amount1 = FullMath.mulDiv(\n                IUniswapV3Pool(uniswapV3Pool).liquidity(),\n                sqrtPriceX96,\n                FixedPoint96.Q96\n            );\n\n            if (_isNFT) {\n                price = (flipNFT) ? (amount0 * mulNFT) / (amount1 * divNFT) : (amount1 * mulNFT) / (amount0 * divNFT);\n            } else {\n                price = (flip)\n                    ? (amount0 * finalMul) / (amount1 * finalDiv)\n                    : (amount1 * finalMul) / (amount0 * finalDiv);\n            }\n        } else {\n            uint32[] memory secondsAgos = new uint32[](2);\n            secondsAgos[0] = twapInterval; // from (before)\n            secondsAgos[1] = 0; // to (now)\n\n            (int56[] memory tickCumulatives, ) = IUniswapV3Pool(uniswapV3Pool).observe(secondsAgos);\n\n            // tick(imprecise as it's an integer) to price\n            uint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(\n                int24((tickCumulatives[1] - tickCumulatives[0]) / int56(int32(twapInterval)))\n            );\n\n            uint256 amount0 = FullMath.mulDiv(\n                IUniswapV3Pool(uniswapV3Pool).liquidity(),\n                FixedPoint96.Q96,\n                sqrtPriceX96\n            );\n\n            uint256 amount1 = FullMath.mulDiv(\n                IUniswapV3Pool(uniswapV3Pool).liquidity(),\n                sqrtPriceX96,\n                FixedPoint96.Q96\n            );\n\n            if (_isNFT) {\n                price = (flipNFT) ? (amount0 * mulNFT) / (amount1 * divNFT) : (amount1 * mulNFT) / (amount0 * divNFT);\n            } else {\n                price = (flip)\n                    ? (amount0 * finalMul) / (amount1 * finalDiv)\n                    : (amount1 * finalMul) / (amount0 * finalDiv);\n            }\n        }\n    }\n\n    function getGnomeNFTPrice() public view returns (uint256 priceGnome) {\n        if (nftPoolWeth) {\n            priceGnome = (getTwapX96(GNOME_NFT_POOL, _twapInterval, true) * treasuryDiscount) / 100;\n        } else {\n            priceGnome =\n                (getTwapX96(GNOME_POOL, _twapInterval, false) *\n                    getTwapX96(GNOME_NFT_POOL, _twapInterval, true) *\n                    treasuryDiscount) /\n                100;\n        }\n\n        return priceGnome;\n    }\n\n    function getGnomeNFTPriceReferral() public view returns (uint256 priceGnome) {\n        if (nftPoolWeth) {\n            priceGnome = (getTwapX96(GNOME_NFT_POOL, _twapInterval, true) * referralDiscount) / 100;\n        } else {\n            priceGnome =\n                (getTwapX96(GNOME_POOL, _twapInterval, false) *\n                    getTwapX96(GNOME_NFT_POOL, _twapInterval, true) *\n                    referralDiscount) /\n                100;\n        }\n\n        return priceGnome;\n    }\n\n    function isGnomeInRange(address fren, bool isFactory) public view returns (bool) {\n        int24 tick = getCurrentTick();\n\n        StakedPosition memory frenposition = stakedPositions[fren];\n        uint256 position;\n        if (isFactory) {\n            position = positionByIndex[positionIndex];\n            if (position == 0) return false;\n        } else {\n            position = frenposition.tokenId;\n        }\n        (, , , int24 minTick, int24 maxTick) = getPositionValue(position);\n\n        if (minTick < tick && tick < maxTick) {\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    function getCurrentTick() public view returns (int24) {\n        (, int24 tick, , , , , ) = pool.slot0();\n        return tick;\n    }\n\n    function swapGnome_Half(uint value) public payable returns (uint amountGnome, uint amountWeth) {\n        uint amountToSwap = value / 2;\n\n        // Approve the router to spend Gnome\n        IGNOME(GNOME_ADDRESS).approve(address(swapRouter), value);\n\n        // Set up swap parameters\n        ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({\n            tokenIn: GNOME_ADDRESS,\n            tokenOut: WETH_ADDRESS,\n            fee: 10000, // Assuming a 0.3% pool fee\n            recipient: address(this),\n            amountIn: amountToSwap,\n            amountOutMinimum: 0,\n            sqrtPriceLimitX96: 0\n        });\n\n        // Perform the swap\n        amountWeth = swapRouter.exactInputSingle(params);\n    }\n\n    function mintPosition(\n        address fren,\n        address rafundAddress,\n        uint _amountGnome,\n        uint _amountWETH\n    ) internal returns (uint _tokenId, uint128 liquidity, uint amount0, uint amount1, uint refund1, uint refund0) {\n        uint256 _deadline = block.timestamp + 3360;\n        int24 lowerTick;\n        int24 upperTick;\n\n        if (fullrange) {\n            (lowerTick, upperTick) = (MinTick, MaxTick);\n        } else {\n            (lowerTick, upperTick) = _getSpreadTicks();\n        }\n        address tokenA = GNOME_ADDRESS;\n        address tokenB = WETH_ADDRESS;\n\n        address token0;\n        address token1;\n\n        if (tokenA < tokenB) {\n            token0 = tokenA;\n            token1 = tokenB;\n        } else {\n            token0 = tokenB;\n            token1 = tokenA;\n        }\n\n        IMinimalNonfungiblePositionManager.MintParams memory params = IMinimalNonfungiblePositionManager.MintParams({\n            token0: token0,\n            token1: token1,\n            fee: 10000,\n            tickLower: lowerTick,\n            tickUpper: upperTick,\n            amount0Desired: _amountGnome,\n            amount1Desired: _amountWETH,\n            amount0Min: 0,\n            amount1Min: 0,\n            recipient: address(this),\n            deadline: _deadline\n        });\n\n        // Note that the pool defined by gnome/WETH and fee tier 0.1% must\n        // already be created and initialized in order to mint\n        (_tokenId, liquidity, amount0, amount1) = positionManager.mint(params);\n\n        stakedPositions[fren] = StakedPosition(_tokenId, liquidity, block.timestamp, block.timestamp);\n        stakedTokenIds.push(_tokenId); // Add the token ID to the array\n        positionIndex++;\n        positionByIndex[positionIndex] = _tokenId;\n        totalStakedLiquidity += liquidity;\n\n        if (amount0 < _amountGnome) {\n            refund0 = _amountGnome - amount0;\n            //TransferHelper.safeTransfer(GNOME_ADDRESS, rafundAddress, refund0);\n            gnomeReward[rafundAddress] += refund0;\n        }\n\n        if (amount1 < _amountWETH) {\n            refund1 = _amountWETH - amount1;\n            TransferHelper.safeTransfer(WETH_ADDRESS, rafundAddress, refund1);\n            // uint256 amountGnome = swapWETH(refund1);\n            //TransferHelper.safeTransfer(GNOME_ADDRESS, rafundAddress, amountGnome);\n            //gnomeReward[rafundAddress] += amountGnome;\n        }\n    }\n\n    function calculateSumOfLiquidity() public view returns (uint128) {\n        uint128 totalLiq = 0;\n\n        for (uint256 i = 0; i < stakedTokenIds.length; i++) {\n            uint256 tokenId = stakedTokenIds[i];\n\n            (uint128 liquidity, , , , ) = getPositionValue(tokenId);\n\n            // Add up the liquidity\n            totalLiq += liquidity;\n        }\n\n        return totalLiq;\n    }\n\n    function increasePosition(\n        address fren,\n        uint _amountGnome,\n        uint _amountWETH\n    ) internal returns (uint tokenId, uint128 liquidity, uint amount0, uint amount1, uint refund0, uint refund1) {\n        tokenId = positionByIndex[positionIndex];\n\n        uint256 _deadline = block.timestamp + 100;\n\n        address tokenA = GNOME_ADDRESS;\n        address tokenB = WETH_ADDRESS;\n\n        uint token0;\n        uint token1;\n\n        if (tokenA < tokenB) {\n            token0 = _amountGnome;\n            token1 = _amountWETH;\n        } else {\n            token0 = _amountWETH;\n            token1 = _amountGnome;\n        }\n\n        IMinimalNonfungiblePositionManager.IncreaseLiquidityParams memory params = IMinimalNonfungiblePositionManager\n            .IncreaseLiquidityParams({\n                tokenId: tokenId,\n                amount0Desired: token0,\n                amount1Desired: token1,\n                amount0Min: 0,\n                amount1Min: 0,\n                deadline: _deadline\n            });\n\n        (liquidity, amount0, amount1) = positionManager.increaseLiquidity(params);\n        uint128 curr_liquidity = stakedPositions[fren].liquidity + liquidity;\n\n        stakedPositions[fren] = StakedPosition(tokenId, curr_liquidity, block.timestamp, block.timestamp);\n\n        totalStakedLiquidity += liquidity;\n\n        if (amount0 < _amountGnome) {\n            refund0 = _amountGnome - amount0;\n            // TransferHelper.safeTransfer(GNOME_ADDRESS, fren, refund0);\n            gnomeReward[fren] += refund0;\n        }\n    }\n\n    function removeTokenIdFromArray(uint256 tokenId) internal {\n        uint256 length = stakedTokenIds.length;\n        for (uint256 i = 0; i < length; i++) {\n            if (stakedTokenIds[i] == tokenId) {\n                // Swap with the last element\n                stakedTokenIds[i] = stakedTokenIds[length - 1];\n                // Remove the last element\n                stakedTokenIds.pop();\n                break;\n            }\n        }\n    }\n\n    function _getStakedPositionID(address fren) public view returns (uint256 tokenId) {\n        StakedPosition memory position = stakedPositions[fren];\n        return position.tokenId;\n    }\n\n    function _getSpreadTicks() public view returns (int24 _lowerTick, int24 _upperTick) {\n        (uint160 sqrtPriceX96, , , , , , ) = pool.slot0();\n        (uint160 sqrtRatioAX96, uint160 sqrtRatioBX96) = (\n            uint160(FullMath.mulDiv(sqrtPriceX96, SQRT_0005_PERCENT, 1e18)),\n            uint160(FullMath.mulDiv(sqrtPriceX96, SQRT_2000_PERCENT, 1e18))\n        );\n\n        _lowerTick = TickMath.getTickAtSqrtRatio(sqrtRatioAX96);\n        _upperTick = TickMath.getTickAtSqrtRatio(sqrtRatioBX96);\n\n        _lowerTick = _lowerTick % tickSpacing == 0\n            ? _lowerTick // accept valid tickSpacing\n            : _lowerTick > 0 // else, round up to closest valid tickSpacing\n            ? (_lowerTick / tickSpacing + 1) * tickSpacing\n            : (_lowerTick / tickSpacing) * tickSpacing;\n        _upperTick = _upperTick % tickSpacing == 0\n            ? _upperTick // accept valid tickSpacing\n            : _upperTick > 0 // else, round down to closest valid tickSpacing\n            ? (_upperTick / tickSpacing) * tickSpacing\n            : (_upperTick / tickSpacing - 1) * tickSpacing;\n    }\n\n    function setTicks(int24 _minTick, int24 _maxTick, int24 _tickSpacing) public onlyOwner {\n        MaxTick = _maxTick;\n        MinTick = _minTick;\n        tickSpacing = _tickSpacing;\n    }\n\n    function setTwap(uint32 twapInterval, bool _fullrange) public onlyOwner {\n        _twapInterval = twapInterval;\n        fullrange = _fullrange;\n    }\n\n    function setDelay(uint256 _delay) public onlyOwner {\n        treasuryDelay = _delay;\n    }\n}\n"
      },
      "contracts/Utils/FullMath.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.4;\n\n/// @title Contains 512-bit math functions\n/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision\n/// @dev Handles \"phantom overflow\" i.e., allows multiplication and division where an intermediate value overflows 256 bits\nlibrary FullMath {\n    /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n    /// @param a The multiplicand\n    /// @param b The multiplier\n    /// @param denominator The divisor\n    /// @return result The 256-bit result\n    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv\n    function mulDiv(\n        uint256 a,\n        uint256 b,\n        uint256 denominator\n    ) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = a * b\n            // Compute the product mod 2**256 and mod 2**256 - 1\n            // then use the Chinese Remainder Theorem to reconstruct\n            // the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2**256 + prod0\n            uint256 prod0; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(a, b, not(0))\n                prod0 := mul(a, b)\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division\n            if (prod1 == 0) {\n                require(denominator > 0);\n                assembly {\n                    result := div(prod0, denominator)\n                }\n                return result;\n            }\n\n            // Make sure the result is less than 2**256.\n            // Also prevents denominator == 0\n            require(denominator > prod1);\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0]\n            // Compute remainder using mulmod\n            uint256 remainder;\n            assembly {\n                remainder := mulmod(a, b, denominator)\n            }\n            // Subtract 256 bit number from 512 bit number\n            assembly {\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator\n            // Compute largest power of two divisor of denominator.\n            // Always >= 1.\n            // EDIT for 0.8 compatibility:\n            // see: https://ethereum.stackexchange.com/questions/96642/unary-operator-cannot-be-applied-to-type-uint256\n            uint256 twos = denominator & (~denominator + 1);\n\n            // Divide denominator by power of two\n            assembly {\n                denominator := div(denominator, twos)\n            }\n\n            // Divide [prod1 prod0] by the factors of two\n            assembly {\n                prod0 := div(prod0, twos)\n            }\n            // Shift in bits from prod1 into prod0. For this we need\n            // to flip `twos` such that it is 2**256 / twos.\n            // If twos is zero, then it becomes one\n            assembly {\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2**256\n            // Now that denominator is an odd number, it has an inverse\n            // modulo 2**256 such that denominator * inv = 1 mod 2**256.\n            // Compute the inverse by starting with a seed that is correct\n            // correct for four bits. That is, denominator * inv = 1 mod 2**4\n            uint256 inv = (3 * denominator) ^ 2;\n            // Now use Newton-Raphson iteration to improve the precision.\n            // Thanks to Hensel's lifting lemma, this also works in modular\n            // arithmetic, doubling the correct bits in each step.\n            inv *= 2 - denominator * inv; // inverse mod 2**8\n            inv *= 2 - denominator * inv; // inverse mod 2**16\n            inv *= 2 - denominator * inv; // inverse mod 2**32\n            inv *= 2 - denominator * inv; // inverse mod 2**64\n            inv *= 2 - denominator * inv; // inverse mod 2**128\n            inv *= 2 - denominator * inv; // inverse mod 2**256\n\n            // Because the division is now exact we can divide by multiplying\n            // with the modular inverse of denominator. This will give us the\n            // correct result modulo 2**256. Since the precoditions guarantee\n            // that the outcome is less than 2**256, this is the final result.\n            // We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inv;\n            return result;\n        }\n    }\n\n    /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n    /// @param a The multiplicand\n    /// @param b The multiplier\n    /// @param denominator The divisor\n    /// @return result The 256-bit result\n    function mulDivRoundingUp(\n        uint256 a,\n        uint256 b,\n        uint256 denominator\n    ) internal pure returns (uint256 result) {\n        result = mulDiv(a, b, denominator);\n        if (mulmod(a, b, denominator) > 0) {\n            require(result < type(uint256).max);\n            result++;\n        }\n    }\n}"
      },
      "contracts/Utils/LiquidityAmounts.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.5.0;\n\nimport { FullMath } from \"./FullMath.sol\";\nimport \"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\";\n\n/// @title Liquidity amount functions\n/// @notice Provides functions for computing liquidity amounts from token amounts and prices\nlibrary LiquidityAmounts {\n    function toUint128(uint256 x) private pure returns (uint128 y) {\n        require((y = uint128(x)) == x);\n    }\n\n    /// @notice Computes the amount of liquidity received for a given amount of token0 and price range\n    /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)).\n    /// @param sqrtRatioAX96 A sqrt price\n    /// @param sqrtRatioBX96 Another sqrt price\n    /// @param amount0 The amount0 being sent in\n    /// @return liquidity The amount of returned liquidity\n    function getLiquidityForAmount0(\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint256 amount0\n    ) internal pure returns (uint128 liquidity) {\n        if (sqrtRatioAX96 > sqrtRatioBX96)\n            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n        uint256 intermediate =\n            FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96);\n        return\n            toUint128(\n                FullMath.mulDiv(\n                    amount0,\n                    intermediate,\n                    sqrtRatioBX96 - sqrtRatioAX96\n                )\n            );\n    }\n\n    /// @notice Computes the amount of liquidity received for a given amount of token1 and price range\n    /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)).\n    /// @param sqrtRatioAX96 A sqrt price\n    /// @param sqrtRatioBX96 Another sqrt price\n    /// @param amount1 The amount1 being sent in\n    /// @return liquidity The amount of returned liquidity\n    function getLiquidityForAmount1(\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint256 amount1\n    ) internal pure returns (uint128 liquidity) {\n        if (sqrtRatioAX96 > sqrtRatioBX96)\n            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n        return\n            toUint128(\n                FullMath.mulDiv(\n                    amount1,\n                    FixedPoint96.Q96,\n                    sqrtRatioBX96 - sqrtRatioAX96\n                )\n            );\n    }\n\n    /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current\n    /// pool prices and the prices at the tick boundaries\n    function getLiquidityForAmounts(\n        uint160 sqrtRatioX96,\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint256 amount0,\n        uint256 amount1\n    ) internal pure returns (uint128 liquidity) {\n        if (sqrtRatioAX96 > sqrtRatioBX96)\n            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n        if (sqrtRatioX96 <= sqrtRatioAX96) {\n            liquidity = getLiquidityForAmount0(\n                sqrtRatioAX96,\n                sqrtRatioBX96,\n                amount0\n            );\n        } else if (sqrtRatioX96 < sqrtRatioBX96) {\n            uint128 liquidity0 =\n                getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0);\n            uint128 liquidity1 =\n                getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1);\n\n            liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1;\n        } else {\n            liquidity = getLiquidityForAmount1(\n                sqrtRatioAX96,\n                sqrtRatioBX96,\n                amount1\n            );\n        }\n    }\n\n    /// @notice Computes the amount of token0 for a given amount of liquidity and a price range\n    /// @param sqrtRatioAX96 A sqrt price\n    /// @param sqrtRatioBX96 Another sqrt price\n    /// @param liquidity The liquidity being valued\n    /// @return amount0 The amount0\n    function getAmount0ForLiquidity(\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint128 liquidity\n    ) internal pure returns (uint256 amount0) {\n        if (sqrtRatioAX96 > sqrtRatioBX96)\n            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n        return\n            FullMath.mulDiv(\n                uint256(liquidity) << FixedPoint96.RESOLUTION,\n                sqrtRatioBX96 - sqrtRatioAX96,\n                sqrtRatioBX96\n            ) / sqrtRatioAX96;\n    }\n\n    /// @notice Computes the amount of token1 for a given amount of liquidity and a price range\n    /// @param sqrtRatioAX96 A sqrt price\n    /// @param sqrtRatioBX96 Another sqrt price\n    /// @param liquidity The liquidity being valued\n    /// @return amount1 The amount1\n    function getAmount1ForLiquidity(\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint128 liquidity\n    ) internal pure returns (uint256 amount1) {\n        if (sqrtRatioAX96 > sqrtRatioBX96)\n            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n        return\n            FullMath.mulDiv(\n                liquidity,\n                sqrtRatioBX96 - sqrtRatioAX96,\n                FixedPoint96.Q96\n            );\n    }\n\n    /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current\n    /// pool prices and the prices at the tick boundaries\n    function getAmountsForLiquidity(\n        uint160 sqrtRatioX96,\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint128 liquidity\n    ) internal pure returns (uint256 amount0, uint256 amount1) {\n        if (sqrtRatioAX96 > sqrtRatioBX96)\n            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n        if (sqrtRatioX96 <= sqrtRatioAX96) {\n            amount0 = getAmount0ForLiquidity(\n                sqrtRatioAX96,\n                sqrtRatioBX96,\n                liquidity\n            );\n        } else if (sqrtRatioX96 < sqrtRatioBX96) {\n            amount0 = getAmount0ForLiquidity(\n                sqrtRatioX96,\n                sqrtRatioBX96,\n                liquidity\n            );\n            amount1 = getAmount1ForLiquidity(\n                sqrtRatioAX96,\n                sqrtRatioX96,\n                liquidity\n            );\n        } else {\n            amount1 = getAmount1ForLiquidity(\n                sqrtRatioAX96,\n                sqrtRatioBX96,\n                liquidity\n            );\n        }\n    }\n}"
      },
      "contracts/Utils/TickMath.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity 0.8.20;\n\n/// @title Math library for computing sqrt prices from ticks and vice versa\n/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports\n/// prices between 2**-128 and 2**128\nlibrary TickMath {\n    /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128\n    int24 internal constant MIN_TICK = -887272;\n    /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128\n    int24 internal constant MAX_TICK = -MIN_TICK;\n\n    /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\n    uint160 internal constant MIN_SQRT_RATIO = 4295128739;\n    /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\n    uint160 internal constant MAX_SQRT_RATIO =\n        1461446703485210103287273052203988822378723970342;\n\n    /// @notice Calculates sqrt(1.0001^tick) * 2^96\n    /// @dev Throws if |tick| > max tick\n    /// @param tick The input tick for the above formula\n    /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)\n    /// at the given tick\n    function getSqrtRatioAtTick(int24 tick)\n        internal\n        pure\n        returns (uint160 sqrtPriceX96)\n    {\n        uint256 absTick =\n            tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\n\n        // EDIT: 0.8 compatibility\n        require(absTick <= uint256(int256(MAX_TICK)), \"T\");\n\n        uint256 ratio =\n            absTick & 0x1 != 0\n                ? 0xfffcb933bd6fad37aa2d162d1a594001\n                : 0x100000000000000000000000000000000;\n        if (absTick & 0x2 != 0)\n            ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;\n        if (absTick & 0x4 != 0)\n            ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;\n        if (absTick & 0x8 != 0)\n            ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;\n        if (absTick & 0x10 != 0)\n            ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;\n        if (absTick & 0x20 != 0)\n            ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;\n        if (absTick & 0x40 != 0)\n            ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;\n        if (absTick & 0x80 != 0)\n            ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;\n        if (absTick & 0x100 != 0)\n            ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;\n        if (absTick & 0x200 != 0)\n            ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;\n        if (absTick & 0x400 != 0)\n            ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;\n        if (absTick & 0x800 != 0)\n            ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;\n        if (absTick & 0x1000 != 0)\n            ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;\n        if (absTick & 0x2000 != 0)\n            ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;\n        if (absTick & 0x4000 != 0)\n            ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;\n        if (absTick & 0x8000 != 0)\n            ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;\n        if (absTick & 0x10000 != 0)\n            ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;\n        if (absTick & 0x20000 != 0)\n            ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;\n        if (absTick & 0x40000 != 0)\n            ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;\n        if (absTick & 0x80000 != 0)\n            ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;\n\n        if (tick > 0) ratio = type(uint256).max / ratio;\n\n        // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.\n        // we then downcast because we know the result always fits within 160 bits due to our tick input constraint\n        // we round up in the division so getTickAtSqrtRatio of the output price is always consistent\n        sqrtPriceX96 = uint160(\n            (ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)\n        );\n    }\n\n    /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio\n    /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may\n    /// ever return.\n    /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96\n    /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio\n    function getTickAtSqrtRatio(uint160 sqrtPriceX96)\n        internal\n        pure\n        returns (int24 tick)\n    {\n        // second inequality must be < because the price can never reach the price at the max tick\n        require(\n            sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO,\n            \"R\"\n        );\n        uint256 ratio = uint256(sqrtPriceX96) << 32;\n\n        uint256 r = ratio;\n        uint256 msb = 0;\n\n        assembly {\n            let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n            msb := or(msb, f)\n            r := shr(f, r)\n        }\n        assembly {\n            let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))\n            msb := or(msb, f)\n            r := shr(f, r)\n        }\n        assembly {\n            let f := shl(5, gt(r, 0xFFFFFFFF))\n            msb := or(msb, f)\n            r := shr(f, r)\n        }\n        assembly {\n            let f := shl(4, gt(r, 0xFFFF))\n            msb := or(msb, f)\n            r := shr(f, r)\n        }\n        assembly {\n            let f := shl(3, gt(r, 0xFF))\n            msb := or(msb, f)\n            r := shr(f, r)\n        }\n        assembly {\n            let f := shl(2, gt(r, 0xF))\n            msb := or(msb, f)\n            r := shr(f, r)\n        }\n        assembly {\n            let f := shl(1, gt(r, 0x3))\n            msb := or(msb, f)\n            r := shr(f, r)\n        }\n        assembly {\n            let f := gt(r, 0x1)\n            msb := or(msb, f)\n        }\n\n        if (msb >= 128) r = ratio >> (msb - 127);\n        else r = ratio << (127 - msb);\n\n        int256 log_2 = (int256(msb) - 128) << 64;\n\n        assembly {\n            r := shr(127, mul(r, r))\n            let f := shr(128, r)\n            log_2 := or(log_2, shl(63, f))\n            r := shr(f, r)\n        }\n        assembly {\n            r := shr(127, mul(r, r))\n            let f := shr(128, r)\n            log_2 := or(log_2, shl(62, f))\n            r := shr(f, r)\n        }\n        assembly {\n            r := shr(127, mul(r, r))\n            let f := shr(128, r)\n            log_2 := or(log_2, shl(61, f))\n            r := shr(f, r)\n        }\n        assembly {\n            r := shr(127, mul(r, r))\n            let f := shr(128, r)\n            log_2 := or(log_2, shl(60, f))\n            r := shr(f, r)\n        }\n        assembly {\n            r := shr(127, mul(r, r))\n            let f := shr(128, r)\n            log_2 := or(log_2, shl(59, f))\n            r := shr(f, r)\n        }\n        assembly {\n            r := shr(127, mul(r, r))\n            let f := shr(128, r)\n            log_2 := or(log_2, shl(58, f))\n            r := shr(f, r)\n        }\n        assembly {\n            r := shr(127, mul(r, r))\n            let f := shr(128, r)\n            log_2 := or(log_2, shl(57, f))\n            r := shr(f, r)\n        }\n        assembly {\n            r := shr(127, mul(r, r))\n            let f := shr(128, r)\n            log_2 := or(log_2, shl(56, f))\n            r := shr(f, r)\n        }\n        assembly {\n            r := shr(127, mul(r, r))\n            let f := shr(128, r)\n            log_2 := or(log_2, shl(55, f))\n            r := shr(f, r)\n        }\n        assembly {\n            r := shr(127, mul(r, r))\n            let f := shr(128, r)\n            log_2 := or(log_2, shl(54, f))\n            r := shr(f, r)\n        }\n        assembly {\n            r := shr(127, mul(r, r))\n            let f := shr(128, r)\n            log_2 := or(log_2, shl(53, f))\n            r := shr(f, r)\n        }\n        assembly {\n            r := shr(127, mul(r, r))\n            let f := shr(128, r)\n            log_2 := or(log_2, shl(52, f))\n            r := shr(f, r)\n        }\n        assembly {\n            r := shr(127, mul(r, r))\n            let f := shr(128, r)\n            log_2 := or(log_2, shl(51, f))\n            r := shr(f, r)\n        }\n        assembly {\n            r := shr(127, mul(r, r))\n            let f := shr(128, r)\n            log_2 := or(log_2, shl(50, f))\n        }\n\n        int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number\n\n        int24 tickLow =\n            int24(\n                (log_sqrt10001 - 3402992956809132418596140100660247210) >> 128\n            );\n        int24 tickHi =\n            int24(\n                (log_sqrt10001 + 291339464771989622907027621153398088495) >> 128\n            );\n\n        tick = tickLow == tickHi\n            ? tickLow\n            : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96\n            ? tickHi\n            : tickLow;\n    }\n}"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 200,
        "details": {
          "yul": true
        }
      },
      "viaIR": true,
      "evmVersion": "paris",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "metadata": {
        "useLiteralContent": true
      },
      "libraries": {}
    }
  }}