ETH Price: $3,129.12 (+0.90%)

Token

AwesomeX (AWX)
 

Overview

Max Total Supply

1,844,397,059,466.033228127673262489 AWX

Holders

390

Market

Onchain Market Cap

$0.00

Circulating Supply Market Cap

-

Other Info

Token Contract (WITH 18 Decimals)

Balance
26,880,000 AWX

Value
$0.00
0x2f5d6a2207c7435d8325e3df14ae46d0106c9791
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information
# Exchange Pair Price  24H Volume % Volume

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

Contract Name:
AwesomeX

Compiler Version
v0.8.26+commit.8a97fa7a

Optimization Enabled:
Yes with 200 runs

Other Settings:
shanghai EvmVersion
File 1 of 47 : AwesomeX.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

/* === OZ === */
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {ERC20Burnable} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";

/* = SYSTEM */
import {AwesomeXMinting} from "./AwesomeXMinting.sol";
import {AwesomeXBuyAndBurn} from "./AwesomeXBuyAndBurn.sol";

/* = LIBS =  */
import {FullMath} from "@uniswap/v3-core/contracts/libraries/FullMath.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";

/* = UNIV3 = */
import {IUniswapV3Pool} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import {INonfungiblePositionManager} from "@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol";
import {IQuoter} from "@uniswap/v3-periphery/contracts/interfaces/IQuoter.sol";

/* = UNIV2 = */

import {IUniswapV2Router02} from "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import {IUniswapV2Pair} from "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";

import "../src/const/BuyAndBurnConst.sol";

/**
 * @title AwesomeX
 * @dev ERC20 token contract for AwesomeX tokens.
 * @notice It can be minted by AwesomeXMinting during cycles
 * @notice It can be minted by AwesomeXBuyAndBurn when forming an LP
 */
contract AwesomeX is ERC20Burnable {
    using FullMath for uint256;

    /* ==== IMMUTABLES ==== */

    AwesomeXMinting public immutable minting;
    AwesomeXBuyAndBurn public immutable buyAndBurn;
    address public immutable dragonXAwesomeXPool;
    address public immutable dragonXTitanXPool;

    /* ==== ERRORS ==== */

    error OnlyMinting();
    error OnlyBuyAndBurn();
    error InvalidInput();

    /* ==== CONSTRUCTOR ==== */

    /**
     * @dev Sets the minting and buy and burn contract address.
     * @param _awesomeXMintingStartTimestamp The start of the first mint cycle
     * @param _awesomeXBuyAndBurnStartTimestamp The start of the buy and burn contract
     * @param _titanX The titanX token
     * @param _dragonX The dragonX token
     * @param _owner The owner of the buyAndBurn
     * @notice Constructor is payable to save gas
     */
    constructor(
        uint32 _awesomeXMintingStartTimestamp,
        uint32 _awesomeXBuyAndBurnStartTimestamp,
        address _titanX,
        address _dragonX,
        address _owner,
        address _dragonXTitanXPool
    ) payable ERC20("AwesomeX", "AWX") {
        dragonXAwesomeXPool = _createDragonXAwesomeXPool(_dragonX, _titanX);

        dragonXTitanXPool = _dragonXTitanXPool;

        buyAndBurn = new AwesomeXBuyAndBurn(_awesomeXBuyAndBurnStartTimestamp, _titanX, _dragonX, _owner);
        minting = new AwesomeXMinting(address(buyAndBurn), _titanX, _awesomeXMintingStartTimestamp, _dragonX);
    }

    /* == MODIFIERS == */

    /// @dev Modifier to ensure the function is called only by the minting contract.
    modifier onlyMinting() {
        _onlyMinting();
        _;
    }

    /// @dev Modifier to ensure the function is called only by the buy and burn contract.
    modifier onlyBuyAndBurn() {
        _onlyBuyAndBurn();
        _;
    }

    /* == EXTERNAL == */

    /**
     * @notice Mints AwesomeX tokens to a specified address.
     * @notice This is only callable by the minting contract
     * @param _to The address to mint the tokens to.
     * @param _amount The amount of tokens to mint.
     */
    function mint(address _to, uint256 _amount) external onlyMinting {
        _mint(_to, _amount);
    }

    /// @notice Mints AwesomeX tokens for the initial LP creation
    function mintTokensForLP() external onlyBuyAndBurn {
        _mint(address(buyAndBurn), INITIAL_LP_MINT);
    }

    /* == INTERNAL == */

    /// @dev Private method is used instead of inlining into modifier because modifiers are copied into each method,
    ///     and the use of immutable means the address bytes are copied in every place the modifier is used.
    function _onlyBuyAndBurn() internal view {
        if (msg.sender != address(buyAndBurn)) revert OnlyBuyAndBurn();
    }

    /// @dev Private method is used instead of inlining into modifier because modifiers are copied into each method,
    ///     and the use of immutable means the address bytes are copied in every place the modifier is used.
    function _onlyMinting() internal view {
        if (msg.sender != address(minting)) revert OnlyMinting();
    }

    ///@notice - Creates the DragonX/AwesomeX Pool on uniswapV3
    ///@notice - Only called inside of the constructor and never again
    function _createDragonXAwesomeXPool(address _dragonX, address _titanX) internal returns (address pool) {
        address _awesomeX = address(this);

        IQuoter quoter = IQuoter(UNISWAP_V3_QUOTER);

        bytes memory path = abi.encodePacked(address(_titanX), POOL_FEE, address(_dragonX));

        uint256 dragonXAmount = quoter.quoteExactInput(path, INITIAL_TITAN_X_FOR_LIQ);

        uint256 awesomeXAmount = INITIAL_LP_MINT;

        (address token0, address token1) = _dragonX < _awesomeX ? (_dragonX, _awesomeX) : (_awesomeX, _dragonX);

        (uint256 amount0, uint256 amount1) =
            token0 == _dragonX ? (dragonXAmount, awesomeXAmount) : (awesomeXAmount, dragonXAmount);

        uint160 sqrtPriceX96 = uint160((Math.sqrt((amount1 * 1e18) / amount0) * 2 ** 96) / 1e9);

        INonfungiblePositionManager manager = INonfungiblePositionManager(UNISWAP_V3_POSITION_MANAGER);

        pool = manager.createAndInitializePoolIfNecessary(token0, token1, POOL_FEE, sqrtPriceX96);

        IUniswapV3Pool(pool).increaseObservationCardinalityNext(uint16(100));
    }
}

File 2 of 47 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";

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

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _transfer(address from, address to, uint256 value) internal {
        if (from == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        if (to == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(from, to, value);
    }

    /**
     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
     * this function.
     *
     * Emits a {Transfer} event.
     */
    function _update(address from, address to, uint256 value) internal virtual {
        if (from == address(0)) {
            // Overflow check required: The rest of the code assumes that totalSupply never overflows
            _totalSupply += value;
        } else {
            uint256 fromBalance = _balances[from];
            if (fromBalance < value) {
                revert ERC20InsufficientBalance(from, fromBalance, value);
            }
            unchecked {
                // Overflow not possible: value <= fromBalance <= totalSupply.
                _balances[from] = fromBalance - value;
            }
        }

        if (to == address(0)) {
            unchecked {
                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
                _totalSupply -= value;
            }
        } else {
            unchecked {
                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
                _balances[to] += value;
            }
        }

        emit Transfer(from, to, value);
    }

    /**
     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
     * Relies on the `_update` mechanism
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _mint(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(address(0), account, value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
     * Relies on the `_update` mechanism.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead
     */
    function _burn(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        _update(account, address(0), value);
    }

    /**
     * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address owner, address spender, uint256 value) internal {
        _approve(owner, spender, value, true);
    }

    /**
     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
     *
     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
     * `Approval` event during `transferFrom` operations.
     *
     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
     * true using the following override:
     * ```
     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
     *     super._approve(owner, spender, value, true);
     * }
     * ```
     *
     * Requirements are the same as {_approve}.
     */
    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
        if (owner == address(0)) {
            revert ERC20InvalidApprover(address(0));
        }
        if (spender == address(0)) {
            revert ERC20InvalidSpender(address(0));
        }
        _allowances[owner][spender] = value;
        if (emitEvent) {
            emit Approval(owner, spender, value);
        }
    }

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

File 3 of 47 : ERC20Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Burnable.sol)

pragma solidity ^0.8.20;

import {ERC20} from "../ERC20.sol";
import {Context} from "../../../utils/Context.sol";

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20Burnable is Context, ERC20 {
    /**
     * @dev Destroys a `value` amount of tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 value) public virtual {
        _burn(_msgSender(), value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, deducting from
     * the caller's allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `value`.
     */
    function burnFrom(address account, uint256 value) public virtual {
        _spendAllowance(account, _msgSender(), value);
        _burn(account, value);
    }
}

File 4 of 47 : AwesomeXMinting.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

/* === OZ === */
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";

/* === SYSTEM === */
import {AwesomeXBuyAndBurn} from "./AwesomeXBuyAndBurn.sol";
import {AwesomeX} from "./AwesomeX.sol";

/* === CONST === */
import "./const/BuyAndBurnConst.sol";

/* == UTILS */
import {wdiv, wmul, sub, wpow} from "@utils/Math.sol";

/* == INTERFACES == */
import {IDragonX} from "./interfaces/IDragonX.sol";

/**
 * @title AwesomeXMinting
 * @dev This contract allows users to mint AwesomeXM tokens by depositing TITANX tokens during specific minting cycles.
 */
contract AwesomeXMinting {
    using SafeERC20 for IERC20;
    using Math for uint256;

    /* == CONSTANTS ==  */

    ///@notice  The duration of 1 mint cycle
    uint32 public constant MINT_CYCLE_DURATION = 24 hours;

    ///@notice The gap between mint cycles
    uint32 public constant GAP_BETWEEN_CYCLE = 1 weeks;

    ///@notice  The final mint cycle
    uint8 public constant MAX_MINT_CYCLE = 125;

    /* == IMMUTABLES == */

    ///@notice The titanX token
    IERC20 public immutable titanX;

    IDragonX public immutable dragonX;

    uint256 public totalTitanXDeposited;
    uint256 public totalAwesomeXClaimed;
    uint256 public totalAwesomeXMinted;
    uint256 public totalTitanXSentToDragonX;

    ///@notice The buy and burn contract
    AwesomeXBuyAndBurn public immutable buyAndBurn;

    uint32 public immutable startTimestamp;

    /* == STATE == */

    ///@notice  AwesomeX token
    AwesomeX public awesomeX;

    ///@notice The start of the first minting cycle

    ///@notice Mapping of the users amount to claim in a mint cycle
    mapping(address user => mapping(uint32 cycleId => uint256 amount)) public amountToClaim;

    /* == ERRORS == */

    error InvalidInput();
    error CycleStillOngoing();
    error NotStartedYet();
    error CycleIsOver();
    error NoAwesomeXToClaim();
    error InvalidStartTime();

    /* == EVENTS === */

    ///@notice Emits when user mints for a cycle
    event MintExecuted(address indexed user, uint256 awesomeXAmount, uint32 indexed mintCycleId);

    ///@notice Emits when user claims for a cycle
    event ClaimExecuted(address indexed user, uint256 awesomeXAmount, uint32 indexed mintCycleId);

    /* == CONSTRUCTOR == */

    /**
     * @dev Sets the addresses for the TITANX and AwesomeX tokens.
     * @param _buyAndBurn Address of the buy and burn contract
     * @param _titanX Adress of the TitanX token
     * @param _startTimestamp The time stamp of the first minting cycle
     * @notice Constructor is payable to save gas
     */
    constructor(address _buyAndBurn, address _titanX, uint32 _startTimestamp, address _dragonX) payable {
        if (_buyAndBurn == address(0)) revert InvalidInput();

        startTimestamp = _startTimestamp;
        dragonX = IDragonX(_dragonX);
        awesomeX = AwesomeX(msg.sender);
        titanX = IERC20(_titanX);
        buyAndBurn = AwesomeXBuyAndBurn(_buyAndBurn);
    }

    /* == EXTERNAL == */

    /**
     * @notice Mints AwesomeX tokens by depositing TITANX tokens during an ongoing mint cycle.
     * @param _amount The amount of TITANX tokens to deposit.
     */
    function mint(uint256 _amount) external {
        if (_amount == 0) revert InvalidInput();

        if (block.timestamp < startTimestamp) revert NotStartedYet();

        (uint32 currentCycle,, uint32 endsAt) = getCurrentMintCycle();

        if (block.timestamp > endsAt) revert CycleIsOver();

        titanX.safeTransferFrom(msg.sender, address(this), _amount);

        _distribute(_amount);

        uint256 awesomeXAmount = (_amount * getRatio()) / 1e18;

        amountToClaim[msg.sender][currentCycle] += awesomeXAmount;

        emit MintExecuted(msg.sender, awesomeXAmount, currentCycle);

        totalAwesomeXMinted = totalAwesomeXMinted + awesomeXAmount;
        totalTitanXDeposited = totalTitanXDeposited + _amount;
    }

    /**
     * @notice Claims the minted AwesomeX tokens after the end of the specified mint cycle.
     * @param _cycleId The ID of the mint cycle to claim tokens from.
     */
    function claim(uint32 _cycleId) external {
        if (_getCycleEndTime(_cycleId) > block.timestamp) revert CycleStillOngoing();

        uint256 toClaim = amountToClaim[msg.sender][_cycleId];

        if (toClaim == 0) revert NoAwesomeXToClaim();

        delete amountToClaim[msg.sender][_cycleId];

        emit ClaimExecuted(msg.sender, toClaim, _cycleId);

        totalAwesomeXClaimed = totalAwesomeXClaimed + toClaim;

        awesomeX.mint(msg.sender, toClaim);
    }

    /* == INTERNAL/PRIVATE == */

    function _distribute(uint256 _amount) internal {
        uint256 titanXBalance = titanX.balanceOf(address(buyAndBurn));

        //@note - If there is no added liquidity, but the balance exceeds the initial for liquidity, we should distribute the difference
        if (!buyAndBurn.liquidityAdded()) {
            if (titanXBalance <= INITIAL_TITAN_X_FOR_LIQ) {
                titanX.approve(address(buyAndBurn), _amount);
                buyAndBurn.distributeTitanXForBurning(_amount);
                return;
            }

            _amount = uint192(titanXBalance - INITIAL_TITAN_X_FOR_LIQ);
        }

        unchecked {
            uint256 titanXForDragonX = _amount.mulDiv(DRAGON_X_VAULT_BPS, BPS_DENOM, Math.Rounding.Ceil);
            uint256 titanXForLaunchpad = _amount.mulDiv(AWESOME_X_LAUNCHPAD, BPS_DENOM, Math.Rounding.Ceil);
            uint256 titanXForTreasury = _amount.mulDiv(TREASURY, BPS_DENOM, Math.Rounding.Ceil);
            uint256 titanXForTeam = _amount.mulDiv(TEAM_BPS / 2, BPS_DENOM, Math.Rounding.Ceil);

            uint256 forBnB = _amount - (titanXForLaunchpad + titanXForDragonX + titanXForTreasury + (titanXForTeam * 2));

            titanX.safeTransfer(TREASURY_ADDRESS, titanXForTreasury);

            titanX.safeTransfer(TEAM_ADDR1, titanXForTeam);
            titanX.safeTransfer(TEAM_ADDR2, titanXForTeam);

            titanX.safeTransfer(LAUNCHPAD_ADDRESS, titanXForLaunchpad);

            totalTitanXSentToDragonX += titanXForDragonX;

            titanX.safeTransfer(address(dragonX), titanXForDragonX);
            dragonX.updateVault();

            titanX.approve(address(buyAndBurn), forBnB);
            buyAndBurn.distributeTitanXForBurning(forBnB);
        }
    }

    function getCurrentMintCycle() public view returns (uint32 currentCycle, uint32 startsAt, uint32 endsAt) {
        uint32 timeElapsedSince = uint32(block.timestamp - startTimestamp);

        currentCycle = (timeElapsedSince / GAP_BETWEEN_CYCLE) + 1;

        startsAt = startTimestamp + ((currentCycle - 1) * GAP_BETWEEN_CYCLE);

        endsAt = startsAt + MINT_CYCLE_DURATION;
    }

    function getRatio() public view returns (uint256 ratio) {
        uint32 gaps = uint32((block.timestamp - startTimestamp) / GAP_BETWEEN_CYCLE);

        if (gaps > MAX_MINT_CYCLE) gaps = MAX_MINT_CYCLE;

        ratio = uint160(wmul(INITIAL_MINTING_RATIO, wpow(sub(WAD, WEEKLY_DEDUCTION), gaps, WAD)));
    }

    function _getCycleEndTime(uint32 cycleNumber) internal view returns (uint32 endsAt) {
        uint32 cycleStartTime = startTimestamp + ((cycleNumber - 1) * GAP_BETWEEN_CYCLE);

        endsAt = cycleStartTime + MINT_CYCLE_DURATION;
    }
}

File 5 of 47 : AwesomeXBuyAndBurn.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.26;

/* === UNIV3 === */
import {IUniswapV3Pool} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import {TransferHelper} from "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol";
import {INonfungiblePositionManager} from "@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol";
import {TickMath} from "@uniswap/v3-core/contracts/libraries/TickMath.sol";
import {OracleLibrary} from "./library/OracleLibrary.sol";
import {ISwapRouter} from "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
// import {ISwapRouter} from "./mocks/ISwapRouter.sol";

/* === UNIV2 ===  */
import {IUniswapV2Pair} from "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";
import {IUniswapV2Router02} from "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";

/* === OZ === */
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {Ownable2Step, Ownable} from "@openzeppelin/contracts/access/Ownable2Step.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ERC20Burnable} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";

/* === CONST === */
import "./const/BuyAndBurnConst.sol";

/* === SYSTEM === */
import {AwesomeX} from "./AwesomeX.sol";

/**
 * @title AwesomeXBuyAndBurn
 * @notice This contract handles the buying and burning of AwesomeX tokens using Uniswap V2 and V3 pools.
 */
contract AwesomeXBuyAndBurn is ReentrancyGuard, Ownable2Step {
    using TransferHelper for IERC20;
    using Math for uint256;
    /* == STRUCTS == */

    /// @notice Struct to represent intervals for burning
    struct Interval {
        uint128 amountAllocated;
        uint128 amountBurned;
    }

    struct LP {
        uint248 tokenId;
        bool isDragonXToken0;
    }

    /* == CONTSTANTS == */

    /// @notice Uniswap V3 position manager
    INonfungiblePositionManager public constant POSITION_MANAGER =
        INonfungiblePositionManager(UNISWAP_V3_POSITION_MANAGER);

    /* == IMMUTABLE == */

    /// @notice DragonX token contract
    ERC20Burnable private immutable dragonX;

    /// @notice TitanX token contract
    IERC20 public immutable titanX;

    /// @notice AwesomeX token contract
    AwesomeX public immutable awesomeXToken;

    ///@notice The startTimestamp
    uint32 public immutable startTimeStamp;

    ///@notice - The maximum amount a swap can have for the BnB
    uint128 public swapCap;

    /* == STATE == */

    ///@notice The liquidity position after creating the AwesomeX/DRAGONX Pool
    LP lp;

    /// @notice Indicates if liquidity has been added to the pool
    bool public liquidityAdded;

    /// @notice Timestamp of the last burn call
    uint32 public lastBurnedIntervalStartTimestamp;

    uint256 public totalDragonXBurnt;

    /// @notice Total amount of AwesomeX tokens burnt
    uint256 public totalAwesomeXBurnt;
    uint256 public totalAwesomeXFeesCollected;
    uint256 public totalDragonXFeesCollected;

    /// @notice Mapping from interval number to Interval struct
    mapping(uint32 interval => Interval) public intervals;

    /// @notice Last interval number
    uint32 public lastIntervalNumber;

    /// @notice Total TitanX tokens distributed
    uint256 public totalTitanXDistributed;

    /// @notice The last burned interval
    uint256 public lastBurnedInterval;

    ///@notice The slippage for the second swap in the buy and burn in %
    uint8 dragonXToAWXSlippage = 90;
    uint8 titanXToDragonXSlippage = 90;
    uint8 lpSlippage = 90;

    /* == EVENTS == */

    /// @notice Event emitted when tokens are bought and burnt
    event BuyAndBurn(uint256 indexed titanXAmount, uint256 indexed awesomeXBurnt, address indexed caller);

    /* == ERRORS == */

    /// @notice Error when the contract has not started yet
    error NotStartedYet();

    /// @notice Error when minter is not msg.msg.sender
    error OnlyMinting();

    /// @notice Error when some user input is considered invalid
    error InvalidInput();

    /// @notice Error when we try to create liquidity pool with less than the intial amount
    error NotEnoughTitanXForLiquidity();

    /// @notice Error when liquidity has already been added
    error LiquidityAlreadyAdded();

    /// @notice Error when interval has already been burned
    error IntervalAlreadyBurned();

    ///@notice Error when caller is not the slippage admin
    error OnlySlippageAdmin();

    error AWXBuyAndBurn__OnlyEOA();

    /* == CONSTRUCTOR == */

    /// @notice Constructor initializes the contract
    /// @notice Constructor is payable to save gas
    constructor(uint32 startTimestamp, address _titanX, address _dragonX, address _owner) payable Ownable(_owner) {
        startTimeStamp = startTimestamp;
        titanX = IERC20(_titanX);
        awesomeXToken = AwesomeX(msg.sender);
        dragonX = ERC20Burnable(_dragonX);

        swapCap = type(uint128).max;
    }

    /* === MODIFIERS === */

    /// @notice Updates the contract state for intervals
    modifier intervalUpdate() {
        _intervalUpdate();
        _;
    }

    function changeSwapCap(uint128 _newSwapCap) external onlyOwner {
        swapCap = _newSwapCap;
    }

    /* == PUBLIC/EXTERNAL == */

    /**
     * @notice Swaps TitanX for AwesomeX and burns the AwesomeX tokens
     * @param _deadline The deadline for which the passes should pass
     */
    function swapTitanXForAwesomeXndBurn(uint32 _deadline) external nonReentrant intervalUpdate {
        if (msg.sender != tx.origin) revert AWXBuyAndBurn__OnlyEOA();

        if (!liquidityAdded) revert NotStartedYet();
        Interval storage currInterval = intervals[lastIntervalNumber];
        if (currInterval.amountBurned != 0) revert IntervalAlreadyBurned();

        if (currInterval.amountAllocated > swapCap) currInterval.amountAllocated = swapCap;

        currInterval.amountBurned = currInterval.amountAllocated;

        uint256 incentive = (currInterval.amountAllocated * INCENTIVE_FEE) / BPS_DENOM;

        uint256 titanXToSwapAndBurn = currInterval.amountAllocated - incentive;

        uint256 dragonXAmount = _swapTitanXForDragonX(titanXToSwapAndBurn, _deadline);

        uint256 dragonXToBurn = dragonXAmount.mulDiv(TITAN_X_BURN_BPS, BPS_DENOM, Math.Rounding.Ceil);

        totalDragonXBurnt += dragonXToBurn;

        dragonX.transfer(DEAD_ADDR, dragonXToBurn);

        uint256 awesomeXAmount = _swapDragonXForAwesomeX(dragonXAmount - dragonXToBurn, _deadline);

        burnAwesomeX();

        lastBurnedInterval = lastIntervalNumber;

        TransferHelper.safeTransfer(address(titanX), msg.sender, incentive);

        emit BuyAndBurn(titanXToSwapAndBurn, awesomeXAmount, msg.sender);
    }

    /**
     * @notice Creates a Uniswap V3 pool and adds liquidity
     * @param _deadline The deadline for the liquidity addition
     */
    function addLiquidityToAWXDragonXPool(uint32 _deadline) external onlyOwner {
        if (liquidityAdded) revert LiquidityAlreadyAdded();
        if (titanX.balanceOf(address(this)) < INITIAL_TITAN_X_FOR_LIQ) revert NotEnoughTitanXForLiquidity();

        liquidityAdded = true;

        uint256 dragonXReceived = _swapTitanXForDragonX(INITIAL_TITAN_X_FOR_LIQ, _deadline);

        awesomeXToken.mintTokensForLP();

        (uint256 amount0, uint256 amount1, uint256 amount0Min, uint256 amount1Min, address token0, address token1) =
            _sortAmounts(dragonXReceived, INITIAL_LP_MINT);

        TransferHelper.safeApprove(token0, address(POSITION_MANAGER), amount0);
        TransferHelper.safeApprove(token1, address(POSITION_MANAGER), amount1);

        // wake-disable-next-line
        INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager.MintParams({
            token0: token0,
            token1: token1,
            fee: POOL_FEE,
            tickLower: (TickMath.MIN_TICK / TICK_SPACING) * TICK_SPACING,
            tickUpper: (TickMath.MAX_TICK / TICK_SPACING) * TICK_SPACING,
            amount0Desired: amount0,
            amount1Desired: amount1,
            amount0Min: amount0Min,
            amount1Min: amount1Min,
            recipient: address(this),
            deadline: _deadline
        });

        // wake-disable-next-line
        (uint256 tokenId,,,) = POSITION_MANAGER.mint(params);

        lp = LP({tokenId: uint248(tokenId), isDragonXToken0: token0 == address(dragonX)});

        totalTitanXDistributed = titanX.balanceOf(address(this));
    }

    /// @notice Burns AwesomeX tokens held by the contract
    function burnAwesomeX() public {
        uint256 awesomeXToBurn = awesomeXToken.balanceOf(address(this));

        totalAwesomeXBurnt = totalAwesomeXBurnt + awesomeXToBurn;
        awesomeXToken.burn(awesomeXToBurn);
    }

    function setSlippageForDragonXToAWX(uint8 _newSlippage) external onlyOwner {
        if (_newSlippage > 100) revert InvalidInput();

        dragonXToAWXSlippage = _newSlippage;
    }

    function setSlippageForTitanXToDragonX(uint8 _newSlippage) external onlyOwner {
        if (_newSlippage > 100) revert InvalidInput();

        titanXToDragonXSlippage = _newSlippage;
    }

    function setLpSlippage(uint8 _newSlippage) external onlyOwner {
        if (_newSlippage > 100) revert InvalidInput();

        lpSlippage = _newSlippage;
    }

    /**
     * @notice Distributes TitanX tokens for burning
     * @param _amount The amount of TitanX tokens
     */
    function distributeTitanXForBurning(uint256 _amount) external {
        if (_amount == 0) revert InvalidInput();
        if (msg.sender != address(awesomeXToken.minting())) revert OnlyMinting();

        ///@dev - If there are some missed intervals update the accumulated allocation before depositing new titanX
        if (block.timestamp > startTimeStamp && block.timestamp - lastBurnedIntervalStartTimestamp > INTERVAL_TIME) {
            _intervalUpdate();
        }

        TransferHelper.safeTransferFrom(address(titanX), msg.sender, address(this), _amount);

        totalTitanXDistributed = titanX.balanceOf(address(this));
    }

    /**
     * @notice Burns the fees collected from the Uniswap V3 position
     *
     * @return amount0 The amount of token0 collected
     * @return amount1 The amount of token1 collected
     */
    function collectFees() external returns (uint256 amount0, uint256 amount1) {
        LP memory _lp = lp;

        INonfungiblePositionManager.CollectParams memory params = INonfungiblePositionManager.CollectParams({
            tokenId: _lp.tokenId,
            recipient: address(this),
            amount0Max: type(uint128).max,
            amount1Max: type(uint128).max
        });

        (amount0, amount1) = POSITION_MANAGER.collect(params);

        (uint256 dragonXAmount, uint256 awesomeXAmount) = _lp.isDragonXToken0 ? (amount0, amount1) : (amount1, amount0);

        dragonX.transfer(TREASURY_ADDRESS, dragonXAmount);
        awesomeXToken.transfer(TREASURY_ADDRESS, awesomeXAmount);

        totalDragonXFeesCollected += dragonXAmount;
        totalAwesomeXFeesCollected += awesomeXAmount;
    }

    /* == PUBLIC-GETTERS == */

    ///@notice Gets the current week day (0=Sunday, 1=Monday etc etc) wtih a cut-off hour at 2pm UTC
    function currWeekDay() public view returns (uint8 weekDay) {
        weekDay = weekDayByT(uint32(block.timestamp));
    }

    /**
     * @notice Gets the current week day (0=Sunday, 1=Monday etc etc) wtih a cut-off hour at 2pm UTC
     * @param t The timestamp from which to get the weekDay
     */
    function weekDayByT(uint32 t) public pure returns (uint8) {
        return uint8((((t - 14 hours) / 86400) + 4) % 7);
    }

    /**
     * @notice Get the day count for a timestamp
     * @param t The timestamp from which to get the timestamp
     */
    function dayCountByT(uint32 t) public pure returns (uint32) {
        // Adjust the timestamp to the cut-off time (2 PM UTC)
        uint32 adjustedTime = t - 14 hours;

        // Calculate the number of days since Unix epoch
        return adjustedTime / 86400;
    }

    /**
     * @notice Gets the end of the day with a cut-off hour of 2 pm UTC
     * @param t The time from where to get the day end
     */
    function getDayEnd(uint32 t) public pure returns (uint32) {
        // Adjust the timestamp to the cutoff time (2 PM UTC)
        uint32 adjustedTime = t - 14 hours;

        // Calculate the number of days since Unix epoch
        uint32 daysSinceEpoch = adjustedTime / 86400;

        // Calculate the start of the next day at 2 PM UTC
        uint32 nextDayStartAt2PM = (daysSinceEpoch + 1) * 86400 + 14 hours;

        // Return the timestamp for 14:00:00 PM UTC of the given day
        return nextDayStartAt2PM;
    }

    /**
     * @notice Gets the daily TitanX allocation
     * @return dailyBPSAllocation The daily allocation in basis points
     */
    function getDailyTitanXAllocation(uint8 weekDay) public pure returns (uint32 dailyBPSAllocation) {
        dailyBPSAllocation = 300;

        if (weekDay == 5 || weekDay == 6) {
            dailyBPSAllocation = 1200;
        } else if (weekDay == 4) {
            dailyBPSAllocation = 700;
        }
    }

    /**
     * @notice Gets a quote for AWX tokens in exchange for DragonX tokens
     * @param baseAmount The amount of DragonX tokens
     * @return quote The amount of AWX tokens received
     */
    function getAwesomeXQuoteForDragonX(uint256 baseAmount) public view returns (uint256 quote) {
        address poolAddress = awesomeXToken.dragonXAwesomeXPool();
        uint32 secondsAgo = 15 * 60;
        uint32 oldestObservation = OracleLibrary.getOldestObservationSecondsAgo(poolAddress);

        if (oldestObservation < secondsAgo) secondsAgo = oldestObservation;

        (int24 arithmeticMeanTick,) = OracleLibrary.consult(poolAddress, secondsAgo);

        uint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(arithmeticMeanTick);

        quote =
            OracleLibrary.getQuoteForSqrtRatioX96(sqrtPriceX96, baseAmount, address(dragonX), address(awesomeXToken));
    }

    /**
     * @notice Gets a quote for DragonX tokens in exchange for TitanX tokens
     * @param baseAmount The amount of TitanX tokens
     * @return quote The amount of DragonX tokens received
     */
    function getDragonXQuoteForTitanX(uint256 baseAmount) public view returns (uint256 quote) {
        address poolAddress = awesomeXToken.dragonXTitanXPool();
        uint32 secondsAgo = 15 * 60;
        uint32 oldestObservation = OracleLibrary.getOldestObservationSecondsAgo(poolAddress);

        if (oldestObservation < secondsAgo) secondsAgo = oldestObservation;

        (int24 arithmeticMeanTick,) = OracleLibrary.consult(poolAddress, secondsAgo);

        uint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(arithmeticMeanTick);

        quote = OracleLibrary.getQuoteForSqrtRatioX96(sqrtPriceX96, baseAmount, address(titanX), address(dragonX));
    }

    /* == INTERNAL/PRIVATE == */

    /**
     * @notice Swaps TitanX tokens for DragonX tokens
     * @param amountTitanX The amount of TitanX tokens
     * @return _dragonXAmount The amount of DragonX tokens received
     */
    function _swapTitanXForDragonX(uint256 amountTitanX, uint256 _deadline) private returns (uint256 _dragonXAmount) {
        TransferHelper.safeApprove(address(titanX), UNISWAP_V3_ROUTER, amountTitanX);

        bytes memory path = abi.encodePacked(address(titanX), POOL_FEE, address(dragonX));

        uint256 expectedDragonXAmount = getDragonXQuoteForTitanX(amountTitanX);

        uint256 adjustedDragonXAmount = (expectedDragonXAmount * titanXToDragonXSlippage) / 100;

        // Swap parameters
        ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({
            path: path,
            recipient: address(this),
            deadline: _deadline,
            amountIn: amountTitanX,
            amountOutMinimum: adjustedDragonXAmount
        });

        return ISwapRouter(UNISWAP_V3_ROUTER).exactInput(params);
    }

    /**
     * @notice Swaps DragonX tokens for AwesomeX tokens
     * @param amountDragonX The amount of DragonX tokens
     * @param _deadline The deadline for when the swap must be executed
     * @return _awesomeXAmount The amount of AwesomeX tokens received
     */
    function _swapDragonXForAwesomeX(uint256 amountDragonX, uint256 _deadline) private returns (uint256) {
        // wake-disable-next-line
        dragonX.approve(UNISWAP_V3_ROUTER, amountDragonX);
        // Setup the swap-path, swapp
        bytes memory path = abi.encodePacked(address(dragonX), POOL_FEE, address(awesomeXToken));

        uint256 expectedAwesomeXAmount = getAwesomeXQuoteForDragonX(amountDragonX);

        // Adjust for slippage (applied uniformly across both hops)
        uint256 adjustedAwesomeXAmount = (expectedAwesomeXAmount * dragonXToAWXSlippage) / 100;

        // Swap parameters
        ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({
            path: path,
            recipient: address(this),
            deadline: _deadline,
            amountIn: amountDragonX,
            amountOutMinimum: adjustedAwesomeXAmount
        });

        // Execute the swap
        return ISwapRouter(UNISWAP_V3_ROUTER).exactInput(params);
    }

    function _calculateIntervals(uint256 timeElapsedSince)
        internal
        view
        returns (uint32 _lastIntervalNumber, uint128 _totalAmountForInterval, uint16 missedIntervals)
    {
        missedIntervals = _calculateMissedIntervals(timeElapsedSince);

        _lastIntervalNumber = lastIntervalNumber + missedIntervals + 1;

        uint32 currentDay = dayCountByT(uint32(block.timestamp));

        uint32 dayOfLastInterval =
            lastBurnedIntervalStartTimestamp == 0 ? currentDay : dayCountByT(lastBurnedIntervalStartTimestamp);

        if (currentDay == dayOfLastInterval) {
            uint256 dailyAllcation = (totalTitanXDistributed * getDailyTitanXAllocation(currWeekDay())) / BPS_DENOM;

            uint128 _amountPerInterval = uint128(dailyAllcation / INTERVALS_PER_DAY);

            uint128 additionalAmount = _amountPerInterval * missedIntervals;

            _totalAmountForInterval = _amountPerInterval + additionalAmount;
        } else {
            uint32 _lastBurnedIntervalStartTimestamp = lastBurnedIntervalStartTimestamp;

            uint32 theEndOfTheDay = getDayEnd(_lastBurnedIntervalStartTimestamp);

            while (currentDay >= dayOfLastInterval) {
                uint32 end = uint32(block.timestamp < theEndOfTheDay ? block.timestamp : theEndOfTheDay - 1);

                uint32 accumulatedIntervalsForTheDay = (end - _lastBurnedIntervalStartTimestamp) / INTERVAL_TIME;

                uint256 dailyAllcation =
                    (totalTitanXDistributed * getDailyTitanXAllocation(weekDayByT(end))) / BPS_DENOM;

                uint128 _amountPerInterval = uint128(dailyAllcation / INTERVALS_PER_DAY);

                _totalAmountForInterval += _amountPerInterval * accumulatedIntervalsForTheDay;

                ///@notice ->  minus 30 minutes since, at the end of the day the new epoch with new allocation
                _lastBurnedIntervalStartTimestamp = theEndOfTheDay - INTERVAL_TIME;

                ///@notice ->  plus 30 minutes to flip into the next day
                theEndOfTheDay = getDayEnd(_lastBurnedIntervalStartTimestamp + INTERVAL_TIME);

                dayOfLastInterval++;
            }

            if (_totalAmountForInterval > totalTitanXDistributed) {
                _totalAmountForInterval = uint128(totalTitanXDistributed);
            }
        }

        Interval memory prevInt = intervals[lastIntervalNumber];

        //@note - If the last interval was only updated, but not burned add its allocation to the next one.
        uint128 additional = prevInt.amountBurned == 0 ? prevInt.amountAllocated : 0;

        if (_totalAmountForInterval + additional > titanX.balanceOf(address(this))) {
            _totalAmountForInterval = uint128(titanX.balanceOf(address(this)));
        } else {
            _totalAmountForInterval += additional;
        }
    }

    function _calculateMissedIntervals(uint256 timeElapsedSince) internal view returns (uint16 _missedIntervals) {
        _missedIntervals = uint16(timeElapsedSince / INTERVAL_TIME);

        if (lastBurnedIntervalStartTimestamp != 0) _missedIntervals--;
    }

    /// @notice Updates the contract state for intervals
    function _intervalUpdate() private {
        if (block.timestamp < startTimeStamp) revert NotStartedYet();

        (
            uint32 _lastInterval,
            uint128 _amountAllocated,
            uint16 _missedIntervals,
            uint32 _lastIntervalStartTimestamp,
            bool updated
        ) = getCurrentInterval();

        if (updated) {
            lastBurnedIntervalStartTimestamp = _lastIntervalStartTimestamp + (_missedIntervals * INTERVAL_TIME);
            intervals[_lastInterval] = Interval({amountAllocated: _amountAllocated, amountBurned: 0});
            lastIntervalNumber = _lastInterval;
        }
    }

    function getCurrentInterval()
        public
        view
        returns (
            uint32 _lastInterval,
            uint128 _amountAllocated,
            uint16 _missedIntervals,
            uint32 _lastIntervalStartTimestamp,
            bool updated
        )
    {
        uint32 startPoint = lastBurnedIntervalStartTimestamp == 0 ? startTimeStamp : lastBurnedIntervalStartTimestamp;
        uint32 timeElapseSinceLastBurn = uint32(block.timestamp - startPoint);

        if (lastBurnedIntervalStartTimestamp == 0 || timeElapseSinceLastBurn > INTERVAL_TIME) {
            (_lastInterval, _amountAllocated, _missedIntervals) = _calculateIntervals(timeElapseSinceLastBurn);
            _lastIntervalStartTimestamp = startPoint;
            _missedIntervals += timeElapseSinceLastBurn > INTERVAL_TIME && lastBurnedIntervalStartTimestamp != 0 ? 1 : 0;
            updated = true;
        }
    }

    /**
     * @notice Creates a Uniswap V3 pool and returns the parameters
     * @return amount0 The amount of token0
     * @return amount1 The amount of token1
     * @return amount0Min Minimum amount of token0
     * @return amount1Min Minimum amount of token1
     * @return token0 Address of token0
     * @return token1 Address of token1
     */
    function _sortAmounts(uint256 dragonXAmount, uint256 awesomeXAmount)
        internal
        view
        returns (
            uint256 amount0,
            uint256 amount1,
            uint256 amount0Min,
            uint256 amount1Min,
            address token0,
            address token1
        )
    {
        address _dragonX = address(dragonX);
        address _awesomeX = address(awesomeXToken);

        (token0, token1) = _dragonX < _awesomeX ? (_dragonX, _awesomeX) : (_awesomeX, _dragonX);
        (amount0, amount1) = token0 == _dragonX ? (dragonXAmount, awesomeXAmount) : (awesomeXAmount, dragonXAmount);
        (amount0Min, amount1Min) = (_minusLpSlippage(amount0), _minusLpSlippage(amount1));
    }

    ///@notice Helper to remove 10% of an amount
    function _minusLpSlippage(uint256 _amount) internal view returns (uint256 amount) {
        amount = (_amount * lpSlippage) / 100;
    }
}

File 6 of 47 : FullMath.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

File 7 of 47 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

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

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

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

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

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

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

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

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

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

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

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

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

File 8 of 47 : IUniswapV3Pool.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import {IUniswapV3PoolImmutables} from './pool/IUniswapV3PoolImmutables.sol';
import {IUniswapV3PoolState} from './pool/IUniswapV3PoolState.sol';
import {IUniswapV3PoolDerivedState} from './pool/IUniswapV3PoolDerivedState.sol';
import {IUniswapV3PoolActions} from './pool/IUniswapV3PoolActions.sol';
import {IUniswapV3PoolOwnerActions} from './pool/IUniswapV3PoolOwnerActions.sol';
import {IUniswapV3PoolErrors} from './pool/IUniswapV3PoolErrors.sol';
import {IUniswapV3PoolEvents} from './pool/IUniswapV3PoolEvents.sol';

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

}

File 9 of 47 : INonfungiblePositionManager.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol';

import './IPoolInitializer.sol';
import './IERC721Permit.sol';
import './IPeripheryPayments.sol';
import './IPeripheryImmutableState.sol';
import '../libraries/PoolAddress.sol';

/// @title Non-fungible token for positions
/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred
/// and authorized.
interface INonfungiblePositionManager is
    IPoolInitializer,
    IPeripheryPayments,
    IPeripheryImmutableState,
    IERC721Metadata,
    IERC721Enumerable,
    IERC721Permit
{
    /// @notice Emitted when liquidity is increased for a position NFT
    /// @dev Also emitted when a token is minted
    /// @param tokenId The ID of the token for which liquidity was increased
    /// @param liquidity The amount by which liquidity for the NFT position was increased
    /// @param amount0 The amount of token0 that was paid for the increase in liquidity
    /// @param amount1 The amount of token1 that was paid for the increase in liquidity
    event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    /// @notice Emitted when liquidity is decreased for a position NFT
    /// @param tokenId The ID of the token for which liquidity was decreased
    /// @param liquidity The amount by which liquidity for the NFT position was decreased
    /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity
    /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity
    event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    /// @notice Emitted when tokens are collected for a position NFT
    /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior
    /// @param tokenId The ID of the token for which underlying tokens were collected
    /// @param recipient The address of the account that received the collected tokens
    /// @param amount0 The amount of token0 owed to the position that was collected
    /// @param amount1 The amount of token1 owed to the position that was collected
    event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);

    /// @notice Returns the position information associated with a given token ID.
    /// @dev Throws if the token ID is not valid.
    /// @param tokenId The ID of the token that represents the position
    /// @return nonce The nonce for permits
    /// @return operator The address that is approved for spending
    /// @return token0 The address of the token0 for a specific pool
    /// @return token1 The address of the token1 for a specific pool
    /// @return fee The fee associated with the pool
    /// @return tickLower The lower end of the tick range for the position
    /// @return tickUpper The higher end of the tick range for the position
    /// @return liquidity The liquidity of the position
    /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
    /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
    /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
    /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
    function positions(uint256 tokenId)
        external
        view
        returns (
            uint96 nonce,
            address operator,
            address token0,
            address token1,
            uint24 fee,
            int24 tickLower,
            int24 tickUpper,
            uint128 liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

    struct MintParams {
        address token0;
        address token1;
        uint24 fee;
        int24 tickLower;
        int24 tickUpper;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
        address recipient;
        uint256 deadline;
    }

    /// @notice Creates a new position wrapped in a NFT
    /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized
    /// a method does not exist, i.e. the pool is assumed to be initialized.
    /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata
    /// @return tokenId The ID of the token that represents the minted position
    /// @return liquidity The amount of liquidity for this position
    /// @return amount0 The amount of token0
    /// @return amount1 The amount of token1
    function mint(MintParams calldata params)
        external
        payable
        returns (
            uint256 tokenId,
            uint128 liquidity,
            uint256 amount0,
            uint256 amount1
        );

    struct IncreaseLiquidityParams {
        uint256 tokenId;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
        uint256 deadline;
    }

    /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`
    /// @param params tokenId The ID of the token for which liquidity is being increased,
    /// amount0Desired The desired amount of token0 to be spent,
    /// amount1Desired The desired amount of token1 to be spent,
    /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,
    /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,
    /// deadline The time by which the transaction must be included to effect the change
    /// @return liquidity The new liquidity amount as a result of the increase
    /// @return amount0 The amount of token0 to acheive resulting liquidity
    /// @return amount1 The amount of token1 to acheive resulting liquidity
    function increaseLiquidity(IncreaseLiquidityParams calldata params)
        external
        payable
        returns (
            uint128 liquidity,
            uint256 amount0,
            uint256 amount1
        );

    struct DecreaseLiquidityParams {
        uint256 tokenId;
        uint128 liquidity;
        uint256 amount0Min;
        uint256 amount1Min;
        uint256 deadline;
    }

    /// @notice Decreases the amount of liquidity in a position and accounts it to the position
    /// @param params tokenId The ID of the token for which liquidity is being decreased,
    /// amount The amount by which liquidity will be decreased,
    /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,
    /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,
    /// deadline The time by which the transaction must be included to effect the change
    /// @return amount0 The amount of token0 accounted to the position's tokens owed
    /// @return amount1 The amount of token1 accounted to the position's tokens owed
    function decreaseLiquidity(DecreaseLiquidityParams calldata params)
        external
        payable
        returns (uint256 amount0, uint256 amount1);

    struct CollectParams {
        uint256 tokenId;
        address recipient;
        uint128 amount0Max;
        uint128 amount1Max;
    }

    /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient
    /// @param params tokenId The ID of the NFT for which tokens are being collected,
    /// recipient The account that should receive the tokens,
    /// amount0Max The maximum amount of token0 to collect,
    /// amount1Max The maximum amount of token1 to collect
    /// @return amount0 The amount of fees collected in token0
    /// @return amount1 The amount of fees collected in token1
    function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);

    /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens
    /// must be collected first.
    /// @param tokenId The ID of the token that is being burned
    function burn(uint256 tokenId) external payable;
}

File 10 of 47 : IQuoter.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

/// @title Quoter Interface
/// @notice Supports quoting the calculated amounts from exact input or exact output swaps
/// @dev These functions are not marked view because they rely on calling non-view functions and reverting
/// to compute the result. They are also not gas efficient and should not be called on-chain.
interface IQuoter {
    /// @notice Returns the amount out received for a given exact input swap without executing the swap
    /// @param path The path of the swap, i.e. each token pair and the pool fee
    /// @param amountIn The amount of the first token to swap
    /// @return amountOut The amount of the last token that would be received
    function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut);

    /// @notice Returns the amount out received for a given exact input but for a swap of a single pool
    /// @param tokenIn The token being swapped in
    /// @param tokenOut The token being swapped out
    /// @param fee The fee of the token pool to consider for the pair
    /// @param amountIn The desired input amount
    /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap
    /// @return amountOut The amount of `tokenOut` that would be received
    function quoteExactInputSingle(
        address tokenIn,
        address tokenOut,
        uint24 fee,
        uint256 amountIn,
        uint160 sqrtPriceLimitX96
    ) external returns (uint256 amountOut);

    /// @notice Returns the amount in required for a given exact output swap without executing the swap
    /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order
    /// @param amountOut The amount of the last token to receive
    /// @return amountIn The amount of first token required to be paid
    function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn);

    /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool
    /// @param tokenIn The token being swapped in
    /// @param tokenOut The token being swapped out
    /// @param fee The fee of the token pool to consider for the pair
    /// @param amountOut The desired output amount
    /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap
    /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`
    function quoteExactOutputSingle(
        address tokenIn,
        address tokenOut,
        uint24 fee,
        uint256 amountOut,
        uint160 sqrtPriceLimitX96
    ) external returns (uint256 amountIn);
}

File 11 of 47 : IUniswapV2Router02.sol
pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

File 12 of 47 : IUniswapV2Pair.sol
pragma solidity >=0.5.0;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}

File 13 of 47 : BuyAndBurnConst.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

uint256 constant INCENTIVE_FEE = 150;

address constant TITAN_X_ADDRESS = 0xF19308F923582A6f7c465e5CE7a9Dc1BEC6665B1;
address constant DRAGON_X_ADDRESS = 0x96a5399D07896f757Bd4c6eF56461F58DB951862;

address constant OWNER = 0xb4a217e7dE12FA3B0e859Ec3F639BC2b64D57874;
address constant LAUNCHPAD_ADDRESS = 0xb4a217e7dE12FA3B0e859Ec3F639BC2b64D57874;
address constant TREASURY_ADDRESS = 0xCb1C9ab495656a9224EC9D76b97412fE0AB31f8a;
address constant TEAM_ADDR1 = 0xDA674E8998b9753c60B2a9D51a273821aE155D69;
address constant TEAM_ADDR2 = 0x92c3D43102BB3E39FCCd70C6D1933a93a395BfA4;

address constant DEAD_ADDR = 0x000000000000000000000000000000000000dEaD;

uint64 constant WEEKLY_DEDUCTION = 0.028e18;

uint64 constant WAD = 1e18;

uint32 constant DRAGON_X_VAULT_BPS = 1200; // 12%
uint32 constant TITAN_X_BURN_BPS = 476; // 4.76%
uint32 constant AWESOME_X_LAUNCHPAD = 350; // 3.5%
uint32 constant TREASURY = 300; // 3%
uint32 constant TEAM_BPS = 800; // 8%
uint32 constant BPS_DENOM = 10_000;

uint32 constant INTERVAL_TIME = 7 minutes + 30 seconds;
uint256 constant INTERVALS_PER_DAY = 24 hours / INTERVAL_TIME;

uint64 constant INITIAL_MINTING_RATIO = 2.8e18;

///@dev  The initial titan x amount needed to create liquidity pool
uint256 constant INITIAL_TITAN_X_FOR_LIQ = 50_000_000_000e18;

///@dev The intial AwesomeX that pairs with the blaze received from the swap
uint256 constant INITIAL_LP_MINT = 50_000_000_000e18;

/* === UNIV3 === */
address constant UNISWAP_V3_ROUTER = 0xE592427A0AEce92De3Edee1F18E0157C05861564;
address constant UNISWAP_V3_POSITION_MANAGER = 0xC36442b4a4522E871399CD717aBDD847Ab11FE88;
address constant UNISWAP_V3_QUOTER = 0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6;

uint24 constant POOL_FEE = 10_000; //1%

address constant DRAGON_X_TITAN_X_POOl = 0x25215d9ba4403b3DA77ce50606b54577a71b7895;

int24 constant TICK_SPACING = 200; // Uniswap's tick spacing for 1% pools is 200

/* === SEPOLIAAA ==== */

// address constant UNISWAP_V3_ROUTER = 0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E;
// address constant UNISWAP_V3_POSITION_MANAGER = 0x1238536071E1c677A632429e3655c799b22cDA52;
// address constant UNISWAP_V3_QUOTER = 0xEd1f6473345F45b75F8179591dd5bA1888cf2FB3;

File 14 of 47 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

File 15 of 47 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

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

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

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

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

File 16 of 47 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

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

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

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

File 17 of 47 : draft-IERC6093.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

/**
 * @dev Standard ERC20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}

File 18 of 47 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";

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

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

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

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

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

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

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

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

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

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

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

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

File 19 of 47 : Math.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

/* solhint-disable func-visibility, no-inline-assembly */

error Math__toInt256_overflow();
error Math__toUint64_overflow();
error Math__add_overflow_signed();
error Math__sub_overflow_signed();
error Math__mul_overflow_signed();
error Math__mul_overflow();
error Math__div_overflow();

uint256 constant WAD = 1e18;

/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/SafeCastLib.sol#L367
function toInt256(uint256 x) pure returns (int256) {
    if (x >= 1 << 255) revert Math__toInt256_overflow();
    return int256(x);
}

/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/SafeCastLib.sol#L53
function toUint64(uint256 x) pure returns (uint64) {
    if (x >= 1 << 64) revert Math__toUint64_overflow();
    return uint64(x);
}

/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/FixedPointMathLib.sol#L602
function abs(int256 x) pure returns (uint256 z) {
    assembly ("memory-safe") {
        let mask := sub(0, shr(255, x))
        z := xor(mask, add(mask, x))
    }
}

/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/FixedPointMathLib.sol#L620
function min(uint256 x, uint256 y) pure returns (uint256 z) {
    assembly ("memory-safe") {
        z := xor(x, mul(xor(x, y), lt(y, x)))
    }
}

/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/FixedPointMathLib.sol#L628
function min(int256 x, int256 y) pure returns (int256 z) {
    assembly ("memory-safe") {
        z := xor(x, mul(xor(x, y), slt(y, x)))
    }
}

/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/FixedPointMathLib.sol#L636
function max(uint256 x, uint256 y) pure returns (uint256 z) {
    assembly ("memory-safe") {
        z := xor(x, mul(xor(x, y), gt(y, x)))
    }
}

/// @dev Taken from https://github.com/makerdao/dss/blob/fa4f6630afb0624d04a003e920b0d71a00331d98/src/vat.sol#L74
function add(uint256 x, int256 y) pure returns (uint256 z) {
    assembly ("memory-safe") {
        z := add(x, y)
    }
    if ((y > 0 && z < x) || (y < 0 && z > x)) {
        revert Math__add_overflow_signed();
    }
}

/// @dev Taken from https://github.com/makerdao/dss/blob/fa4f6630afb0624d04a003e920b0d71a00331d98/src/vat.sol#L79
function sub(uint256 x, uint256 y) pure returns (uint256 z) {
    assembly ("memory-safe") {
        z := sub(x, y)
    }
    if ((y > 0 && z > x) || (y < 0 && z < x)) {
        revert Math__sub_overflow_signed();
    }
}

/// @dev Taken from https://github.com/makerdao/dss/blob/fa4f6630afb0624d04a003e920b0d71a00331d98/src/vat.sol#L84
function mul(uint256 x, int256 y) pure returns (int256 z) {
    unchecked {
        z = int256(x) * y;
        if (int256(x) < 0 || (y != 0 && z / y != int256(x))) {
            revert Math__mul_overflow_signed();
        }
    }
}

/// @dev Equivalent to `(x * y) / WAD` rounded down.
/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/FixedPointMathLib.sol#L54
function wmul(uint256 x, uint256 y) pure returns (uint256 z) {
    assembly ("memory-safe") {
        // Equivalent to `require(y == 0 || x <= type(uint256).max / y)`.
        if mul(y, gt(x, div(not(0), y))) {
            // Store the function selector of `Math__mul_overflow()`.
            mstore(0x00, 0xc4c5d7f5)

            // Revert with (offset, size).
            revert(0x1c, 0x04)
        }
        z := div(mul(x, y), WAD)
    }
}

function wmul(uint256 x, int256 y) pure returns (int256 z) {
    unchecked {
        z = mul(x, y) / int256(WAD);
    }
}

/// @dev Equivalent to `(x * y) / WAD` rounded up.
/// @dev Taken from https://github.com/Vectorized/solady/blob/969a78905274b32cdb7907398c443f7ea212e4f4/src/utils/FixedPointMathLib.sol#L69C22-L69C22
function wmulUp(uint256 x, uint256 y) pure returns (uint256 z) {
    /// @solidity memory-safe-assembly
    assembly {
        // Equivalent to `require(y == 0 || x <= type(uint256).max / y)`.
        if mul(y, gt(x, div(not(0), y))) {
            // Store the function selector of `Math__mul_overflow()`.
            mstore(0x00, 0xc4c5d7f5)
            // Revert with (offset, size).
            revert(0x1c, 0x04)
        }
        z := add(iszero(iszero(mod(mul(x, y), WAD))), div(mul(x, y), WAD))
    }
}

/// @dev Equivalent to `(x * WAD) / y` rounded down.
/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/FixedPointMathLib.sol#L84
function wdiv(uint256 x, uint256 y) pure returns (uint256 z) {
    assembly ("memory-safe") {
        // Equivalent to `require(y != 0 && (WAD == 0 || x <= type(uint256).max / WAD))`.
        if iszero(mul(y, iszero(mul(WAD, gt(x, div(not(0), WAD)))))) {
            // Store the function selector of `Math__div_overflow()`.
            mstore(0x00, 0xbcbede65)

            // Revert with (offset, size).
            revert(0x1c, 0x04)
        }
        z := div(mul(x, WAD), y)
    }
}

/// @dev Equivalent to `(x * WAD) / y` rounded up.
/// @dev Taken from https://github.com/Vectorized/solady/blob/969a78905274b32cdb7907398c443f7ea212e4f4/src/utils/FixedPointMathLib.sol#L99
function wdivUp(uint256 x, uint256 y) pure returns (uint256 z) {
    /// @solidity memory-safe-assembly
    assembly {
        // Equivalent to `require(y != 0 && (WAD == 0 || x <= type(uint256).max / WAD))`.
        if iszero(mul(y, iszero(mul(WAD, gt(x, div(not(0), WAD)))))) {
            // Store the function selector of `Math__div_overflow()`.
            mstore(0x00, 0xbcbede65)
            // Revert with (offset, size).
            revert(0x1c, 0x04)
        }
        z := add(iszero(iszero(mod(mul(x, WAD), y))), div(mul(x, WAD), y))
    }
}

/// @dev Taken from https://github.com/makerdao/dss/blob/fa4f6630afb0624d04a003e920b0d71a00331d98/src/jug.sol#L62
function wpow(uint256 x, uint256 n, uint256 b) pure returns (uint256 z) {
    unchecked {
        assembly ("memory-safe") {
            switch n
            case 0 { z := b }
            default {
                switch x
                case 0 { z := 0 }
                default {
                    switch mod(n, 2)
                    case 0 { z := b }
                    default { z := x }
                    let half := div(b, 2) // for rounding.
                    for { n := div(n, 2) } n { n := div(n, 2) } {
                        let xx := mul(x, x)
                        if shr(128, x) { revert(0, 0) }
                        let xxRound := add(xx, half)
                        if lt(xxRound, xx) { revert(0, 0) }
                        x := div(xxRound, b)
                        if mod(n, 2) {
                            let zx := mul(z, x)
                            if and(iszero(iszero(x)), iszero(eq(div(zx, x), z))) { revert(0, 0) }
                            let zxRound := add(zx, half)
                            if lt(zxRound, zx) { revert(0, 0) }
                            z := div(zxRound, b)
                        }
                    }
                }
            }
        }
    }
}

/// @dev Taken from https://github.com/Vectorized/solady/blob/cde0a5fb594da8655ba6bfcdc2e40a7c870c0cc0/src/utils/FixedPointMathLib.sol#L110
/// @dev Equivalent to `x` to the power of `y`.
/// because `x ** y = (e ** ln(x)) ** y = e ** (ln(x) * y)`.
function wpow(int256 x, int256 y) pure returns (int256) {
    // Using `ln(x)` means `x` must be greater than 0.
    return wexp((wln(x) * y) / int256(WAD));
}

/// @dev Taken from https://github.com/Vectorized/solady/blob/cde0a5fb594da8655ba6bfcdc2e40a7c870c0cc0/src/utils/FixedPointMathLib.sol#L116
/// @dev Returns `exp(x)`, denominated in `WAD`.
function wexp(int256 x) pure returns (int256 r) {
    unchecked {
        // When the result is < 0.5 we return zero. This happens when
        // x <= floor(log(0.5e18) * 1e18) ~ -42e18
        if (x <= -42139678854452767551) return r;

        /// @solidity memory-safe-assembly
        assembly {
            // When the result is > (2**255 - 1) / 1e18 we can not represent it as an
            // int. This happens when x >= floor(log((2**255 - 1) / 1e18) * 1e18) ~ 135.
            if iszero(slt(x, 135305999368893231589)) {
                mstore(0x00, 0xa37bfec9) // `ExpOverflow()`.
                revert(0x1c, 0x04)
            }
        }

        // x is now in the range (-42, 136) * 1e18. Convert to (-42, 136) * 2**96
        // for more intermediate precision and a binary basis. This base conversion
        // is a multiplication by 1e18 / 2**96 = 5**18 / 2**78.
        x = (x << 78) / 5 ** 18;

        // Reduce range of x to (-½ ln 2, ½ ln 2) * 2**96 by factoring out powers
        // of two such that exp(x) = exp(x') * 2**k, where k is an integer.
        // Solving this gives k = round(x / log(2)) and x' = x - k * log(2).
        int256 k = ((x << 96) / 54916777467707473351141471128 + 2 ** 95) >> 96;
        x = x - k * 54916777467707473351141471128;

        // k is in the range [-61, 195].

        // Evaluate using a (6, 7)-term rational approximation.
        // p is made monic, we'll multiply by a scale factor later.
        int256 y = x + 1346386616545796478920950773328;
        y = ((y * x) >> 96) + 57155421227552351082224309758442;
        int256 p = y + x - 94201549194550492254356042504812;
        p = ((p * y) >> 96) + 28719021644029726153956944680412240;
        p = p * x + (4385272521454847904659076985693276 << 96);

        // We leave p in 2**192 basis so we don't need to scale it back up for the division.
        int256 q = x - 2855989394907223263936484059900;
        q = ((q * x) >> 96) + 50020603652535783019961831881945;
        q = ((q * x) >> 96) - 533845033583426703283633433725380;
        q = ((q * x) >> 96) + 3604857256930695427073651918091429;
        q = ((q * x) >> 96) - 14423608567350463180887372962807573;
        q = ((q * x) >> 96) + 26449188498355588339934803723976023;

        /// @solidity memory-safe-assembly
        assembly {
            // Div in assembly because solidity adds a zero check despite the unchecked.
            // The q polynomial won't have zeros in the domain as all its roots are complex.
            // No scaling is necessary because p is already 2**96 too large.
            r := sdiv(p, q)
        }

        // r should be in the range (0.09, 0.25) * 2**96.

        // We now need to multiply r by:
        // * the scale factor s = ~6.031367120.
        // * the 2**k factor from the range reduction.
        // * the 1e18 / 2**96 factor for base conversion.
        // We do this all at once, with an intermediate result in 2**213
        // basis, so the final right shift is always by a positive amount.
        r = int256((uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k));
    }
}

/// @dev Taken from https://github.com/Vectorized/solady/blob/cde0a5fb594da8655ba6bfcdc2e40a7c870c0cc0/src/utils/FixedPointMathLib.sol#L184
/// @dev Returns `ln(x)`, denominated in `WAD`.
function wln(int256 x) pure returns (int256 r) {
    unchecked {
        /// @solidity memory-safe-assembly
        assembly {
            if iszero(sgt(x, 0)) {
                mstore(0x00, 0x1615e638) // `LnWadUndefined()`.
                revert(0x1c, 0x04)
            }
        }

        // We want to convert x from 10**18 fixed point to 2**96 fixed point.
        // We do this by multiplying by 2**96 / 10**18. But since
        // ln(x * C) = ln(x) + ln(C), we can simply do nothing here
        // and add ln(2**96 / 10**18) at the end.

        // Compute k = log2(x) - 96, t = 159 - k = 255 - log2(x) = 255 ^ log2(x).
        int256 t;
        /// @solidity memory-safe-assembly
        assembly {
            t := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))
            t := or(t, shl(6, lt(0xffffffffffffffff, shr(t, x))))
            t := or(t, shl(5, lt(0xffffffff, shr(t, x))))
            t := or(t, shl(4, lt(0xffff, shr(t, x))))
            t := or(t, shl(3, lt(0xff, shr(t, x))))
            // forgefmt: disable-next-item
            t := xor(
                t,
                byte(
                    and(
                        0x1f,
                        shr(shr(t, x), 0x8421084210842108cc6318c6db6d54be)
                    ),
                    0xf8f9f9faf9fdfafbf9fdfcfdfafbfcfef9fafdfafcfcfbfefafafcfbffffffff
                )
            )
        }

        // Reduce range of x to (1, 2) * 2**96
        // ln(2^k * x) = k * ln(2) + ln(x)
        x = int256(uint256(x << uint256(t)) >> 159);

        // Evaluate using a (8, 8)-term rational approximation.
        // p is made monic, we will multiply by a scale factor later.
        int256 p = x + 3273285459638523848632254066296;
        p = ((p * x) >> 96) + 24828157081833163892658089445524;
        p = ((p * x) >> 96) + 43456485725739037958740375743393;
        p = ((p * x) >> 96) - 11111509109440967052023855526967;
        p = ((p * x) >> 96) - 45023709667254063763336534515857;
        p = ((p * x) >> 96) - 14706773417378608786704636184526;
        p = p * x - (795164235651350426258249787498 << 96);

        // We leave p in 2**192 basis so we don't need to scale it back up for the division.
        // q is monic by convention.
        int256 q = x + 5573035233440673466300451813936;
        q = ((q * x) >> 96) + 71694874799317883764090561454958;
        q = ((q * x) >> 96) + 283447036172924575727196451306956;
        q = ((q * x) >> 96) + 401686690394027663651624208769553;
        q = ((q * x) >> 96) + 204048457590392012362485061816622;
        q = ((q * x) >> 96) + 31853899698501571402653359427138;
        q = ((q * x) >> 96) + 909429971244387300277376558375;
        /// @solidity memory-safe-assembly
        assembly {
            // Div in assembly because solidity adds a zero check despite the unchecked.
            // The q polynomial is known not to have zeros in the domain.
            // No scaling required because p is already 2**96 too large.
            r := sdiv(p, q)
        }

        // r is in the range (0, 0.125) * 2**96

        // Finalization, we need to:
        // * multiply by the scale factor s = 5.549…
        // * add ln(2**96 / 10**18)
        // * add k * ln(2)
        // * multiply by 10**18 / 2**96 = 5**18 >> 78

        // mul s * 5e18 * 2**96, base is now 5**18 * 2**192
        r *= 1677202110996718588342820967067443963516166;
        // add ln(2) * k * 5e18 * 2**192
        r += 16597577552685614221487285958193947469193820559219878177908093499208371 * (159 - t);
        // add ln(2**96 / 10**18) * 5e18 * 2**192
        r += 600920179829731861736702779321621459595472258049074101567377883020018308;
        // base conversion: mul 2**18 / 2**192
        r >>= 174;
    }
}

/// @dev Returns the square root of `x`, rounded down.
function sqrt(uint256 x) pure returns (uint256 z) {
    /// @solidity memory-safe-assembly
    assembly {
        // `floor(sqrt(2**15)) = 181`. `sqrt(2**15) - 181 = 2.84`.
        z := 181 // The "correct" value is 1, but this saves a multiplication later.

        // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
        // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.

        // Let `y = x / 2**r`. We check `y >= 2**(k + 8)`
        // but shift right by `k` bits to ensure that if `x >= 256`, then `y >= 256`.
        let r := shl(7, lt(0xffffffffffffffffffffffffffffffffff, x))
        r := or(r, shl(6, lt(0xffffffffffffffffff, shr(r, x))))
        r := or(r, shl(5, lt(0xffffffffff, shr(r, x))))
        r := or(r, shl(4, lt(0xffffff, shr(r, x))))
        z := shl(shr(1, r), z)

        // Goal was to get `z*z*y` within a small factor of `x`. More iterations could
        // get y in a tighter range. Currently, we will have y in `[256, 256*(2**16))`.
        // We ensured `y >= 256` so that the relative difference between `y` and `y+1` is small.
        // That's not possible if `x < 256` but we can just verify those cases exhaustively.

        // Now, `z*z*y <= x < z*z*(y+1)`, and `y <= 2**(16+8)`, and either `y >= 256`, or `x < 256`.
        // Correctness can be checked exhaustively for `x < 256`, so we assume `y >= 256`.
        // Then `z*sqrt(y)` is within `sqrt(257)/sqrt(256)` of `sqrt(x)`, or about 20bps.

        // For `s` in the range `[1/256, 256]`, the estimate `f(s) = (181/1024) * (s+1)`
        // is in the range `(1/2.84 * sqrt(s), 2.84 * sqrt(s))`,
        // with largest error when `s = 1` and when `s = 256` or `1/256`.

        // Since `y` is in `[256, 256*(2**16))`, let `a = y/65536`, so that `a` is in `[1/256, 256)`.
        // Then we can estimate `sqrt(y)` using
        // `sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2**18`.

        // There is no overflow risk here since `y < 2**136` after the first branch above.
        z := shr(18, mul(z, add(shr(r, x), 65536))) // A `mul()` is saved from starting `z` at 181.

        // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
        z := shr(1, add(z, div(x, z)))
        z := shr(1, add(z, div(x, z)))
        z := shr(1, add(z, div(x, z)))
        z := shr(1, add(z, div(x, z)))
        z := shr(1, add(z, div(x, z)))
        z := shr(1, add(z, div(x, z)))
        z := shr(1, add(z, div(x, z)))

        // If `x+1` is a perfect square, the Babylonian method cycles between
        // `floor(sqrt(x))` and `ceil(sqrt(x))`. This statement ensures we return floor.
        // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
        z := sub(z, lt(div(x, z), z))
    }
}

File 20 of 47 : IDragonX.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

interface IDragonX {
    function updateVault() external;
}

File 21 of 47 : TransferHelper.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.0;

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

library TransferHelper {
    /// @notice Transfers tokens from the targeted address to the given destination
    /// @notice Errors with 'STF' if transfer fails
    /// @param token The contract address of the token to be transferred
    /// @param from The originating address from which the tokens will be transferred
    /// @param to The destination address of the transfer
    /// @param value The amount to be transferred
    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(
            abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value)
        );
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');
    }

    /// @notice Transfers tokens from msg.sender to a recipient
    /// @dev Errors with ST if transfer fails
    /// @param token The contract address of the token which will be transferred
    /// @param to The recipient of the transfer
    /// @param value The value of the transfer
    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');
    }

    /// @notice Approves the stipulated contract to spend the given allowance in the given token
    /// @dev Errors with 'SA' if transfer fails
    /// @param token The contract address of the token to be approved
    /// @param to The target of the approval
    /// @param value The amount of the given token the target will be allowed to spend
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');
    }

    /// @notice Transfers ETH to the recipient address
    /// @dev Fails with `STE`
    /// @param to The destination of the transfer
    /// @param value The value to be transferred
    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'STE');
    }
}

File 22 of 47 : TickMath.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

            uint256 r = ratio;
            uint256 msb = 0;

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

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

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

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

            int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number

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

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

File 23 of 47 : OracleLibrary.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.26;

// Uniswap
import {IUniswapV3Pool} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";

// OpenZeppelin
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";

/**
 * @notice Adapted Uniswap V3 OracleLibrary computation to be compliant with Solidity 0.8.x and later.
 *
 * Documentation for Auditors:
 *
 * Solidity Version: Updated the Solidity version pragma to ^0.8.0. This change ensures compatibility
 * with Solidity version 0.8.x.
 *
 * Safe Arithmetic Operations: Solidity 0.8.x automatically checks for arithmetic overflows/underflows.
 * Therefore, the code no longer needs to use SafeMath library (or similar) for basic arithmetic operations.
 * This change simplifies the code and reduces the potential for errors related to manual overflow/underflow checking.
 *
 * Overflow/Underflow: With the introduction of automatic overflow/underflow checks in Solidity 0.8.x, the code is inherently
 * safer and less prone to certain types of arithmetic errors.
 *
 * Removal of SafeMath Library: Since Solidity 0.8.x handles arithmetic operations safely, the use of SafeMath library
 * is omitted in this update.
 *
 * Git-style diff for the `consult` function:
 *
 * ```diff
 * function consult(address pool, uint32 secondsAgo)
 *     internal
 *     view
 *     returns (int24 arithmeticMeanTick, uint128 harmonicMeanLiquidity)
 * {
 *     require(secondsAgo != 0, 'BP');
 *
 *     uint32[] memory secondsAgos = new uint32[](2);
 *     secondsAgos[0] = secondsAgo;
 *     secondsAgos[1] = 0;
 *
 *     (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s) =
 *         IUniswapV3Pool(pool).observe(secondsAgos);
 *
 *     int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];
 *     uint160 secondsPerLiquidityCumulativesDelta =
 *         secondsPerLiquidityCumulativeX128s[1] - secondsPerLiquidityCumulativeX128s[0];
 *
 * -   arithmeticMeanTick = int24(tickCumulativesDelta / secondsAgo);
 * +   int56 secondsAgoInt56 = int56(uint56(secondsAgo));
 * +   arithmeticMeanTick = int24(tickCumulativesDelta / secondsAgoInt56);
 *     // Always round to negative infinity
 * -   if (tickCumulativesDelta < 0 && (tickCumulativesDelta % secondsAgo != 0)) arithmeticMeanTick--;
 * +   if (tickCumulativesDelta < 0 && (tickCumulativesDelta % secondsAgoInt56 != 0)) arithmeticMeanTick--;
 *
 * -   uint192 secondsAgoX160 = uint192(secondsAgo) * type(uint160).max;
 * +   uint192 secondsAgoUint192 = uint192(secondsAgo);
 * +   uint192 secondsAgoX160 = secondsAgoUint192 * type(uint160).max;
 *     harmonicMeanLiquidity = uint128(secondsAgoX160 / (uint192(secondsPerLiquidityCumulativesDelta) << 32));
 * }
 * ```
 */

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

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

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

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

        // Safe casting of secondsAgo to int56 for division
        int56 secondsAgoInt56 = int56(uint56(secondsAgo));
        arithmeticMeanTick = int24(tickCumulativesDelta / secondsAgoInt56);
        // Always round to negative infinity
        if (tickCumulativesDelta < 0 && (tickCumulativesDelta % secondsAgoInt56 != 0)) arithmeticMeanTick--;

        // Safe casting of secondsAgo to uint192 for multiplication
        uint192 secondsAgoUint192 = uint192(secondsAgo);
        harmonicMeanLiquidity = uint128(
            (secondsAgoUint192 * uint192(type(uint160).max)) / (uint192(secondsPerLiquidityCumulativesDelta) << 32)
        );
    }

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

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

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

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

    /// @notice Given a tick and a token amount, calculates the amount of token received in exchange
    /// a slightly modified version of the UniSwap library getQuoteAtTick to accept a sqrtRatioX96 as input parameter
    /// @param sqrtRatioX96 The sqrt ration
    /// @param baseAmount Amount of token to be converted
    /// @param baseToken Address of an ERC20 token contract used as the baseAmount denomination
    /// @param quoteToken Address of an ERC20 token contract used as the quoteAmount denomination
    /// @return quoteAmount Amount of quoteToken received for baseAmount of baseToken
    function getQuoteForSqrtRatioX96(uint160 sqrtRatioX96, uint256 baseAmount, address baseToken, address quoteToken)
        internal
        pure
        returns (uint256 quoteAmount)
    {
        // Calculate quoteAmount with better precision if it doesn't overflow when multiplied by itself
        if (sqrtRatioX96 <= type(uint128).max) {
            uint256 ratioX192 = uint256(sqrtRatioX96) * sqrtRatioX96;
            quoteAmount = baseToken < quoteToken
                ? Math.mulDiv(ratioX192, baseAmount, 1 << 192)
                : Math.mulDiv(1 << 192, baseAmount, ratioX192);
        } else {
            uint256 ratioX128 = Math.mulDiv(sqrtRatioX96, sqrtRatioX96, 1 << 64);
            quoteAmount = baseToken < quoteToken
                ? Math.mulDiv(ratioX128, baseAmount, 1 << 128)
                : Math.mulDiv(1 << 128, baseAmount, ratioX128);
        }
    }
}

File 24 of 47 : ISwapRouter.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';

/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via Uniswap V3
interface ISwapRouter is IUniswapV3SwapCallback {
    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another token
    /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);

    struct ExactInputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);

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

    /// @notice Swaps as little as possible of one token for `amountOut` of another token
    /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);

    struct ExactOutputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountOut;
        uint256 amountInMaximum;
    }

    /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);
}

File 25 of 47 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

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

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

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

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

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

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

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

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

File 26 of 47 : Ownable2Step.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

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

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

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}

File 27 of 47 : IUniswapV3PoolImmutables.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

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

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

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

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

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

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

File 28 of 47 : IUniswapV3PoolState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

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

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

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

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

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

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

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

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

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

File 29 of 47 : IUniswapV3PoolDerivedState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

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

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

File 30 of 47 : IUniswapV3PoolActions.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

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

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

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

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

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

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

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

File 31 of 47 : IUniswapV3PoolOwnerActions.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

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

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

File 32 of 47 : IUniswapV3PoolErrors.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

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

File 33 of 47 : IUniswapV3PoolEvents.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

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

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

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

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

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

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

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

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

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

File 34 of 47 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.20;

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

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

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

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

File 35 of 47 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.20;

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

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 36 of 47 : IPoolInitializer.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

/// @title Creates and initializes V3 Pools
/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that
/// require the pool to exist.
interface IPoolInitializer {
    /// @notice Creates a new pool if it does not exist, then initializes if not initialized
    /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool
    /// @param token0 The contract address of token0 of the pool
    /// @param token1 The contract address of token1 of the pool
    /// @param fee The fee amount of the v3 pool for the specified token pair
    /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value
    /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary
    function createAndInitializePoolIfNecessary(
        address token0,
        address token1,
        uint24 fee,
        uint160 sqrtPriceX96
    ) external payable returns (address pool);
}

File 37 of 47 : IERC721Permit.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;

import '@openzeppelin/contracts/token/ERC721/IERC721.sol';

/// @title ERC721 with permit
/// @notice Extension to ERC721 that includes a permit function for signature based approvals
interface IERC721Permit is IERC721 {
    /// @notice The permit typehash used in the permit signature
    /// @return The typehash for the permit
    function PERMIT_TYPEHASH() external pure returns (bytes32);

    /// @notice The domain separator used in the permit signature
    /// @return The domain seperator used in encoding of permit signature
    function DOMAIN_SEPARATOR() external view returns (bytes32);

    /// @notice Approve of a specific token ID for spending by spender via signature
    /// @param spender The account that is being approved
    /// @param tokenId The ID of the token that is being approved for spending
    /// @param deadline The deadline timestamp by which the call must be mined for the approve to work
    /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`
    /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`
    /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`
    function permit(
        address spender,
        uint256 tokenId,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external payable;
}

File 38 of 47 : IPeripheryPayments.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;

/// @title Periphery Payments
/// @notice Functions to ease deposits and withdrawals of ETH
interface IPeripheryPayments {
    /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.
    /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.
    /// @param amountMinimum The minimum amount of WETH9 to unwrap
    /// @param recipient The address receiving ETH
    function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;

    /// @notice Refunds any ETH balance held by this contract to the `msg.sender`
    /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps
    /// that use ether for the input amount
    function refundETH() external payable;

    /// @notice Transfers the full amount of a token held by this contract to recipient
    /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users
    /// @param token The contract address of the token which will be transferred to `recipient`
    /// @param amountMinimum The minimum amount of token required for a transfer
    /// @param recipient The destination address of the token
    function sweepToken(
        address token,
        uint256 amountMinimum,
        address recipient
    ) external payable;
}

File 39 of 47 : IPeripheryImmutableState.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Immutable state
/// @notice Functions that return immutable state of the router
interface IPeripheryImmutableState {
    /// @return Returns the address of the Uniswap V3 factory
    function factory() external view returns (address);

    /// @return Returns the address of WETH9
    function WETH9() external view returns (address);
}

File 40 of 47 : PoolAddress.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

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

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

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

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

File 41 of 47 : IUniswapV2Router01.sol
pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

File 42 of 47 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

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

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

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

File 43 of 47 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

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

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

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

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

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

File 44 of 47 : IUniswapV3SwapCallback.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Callback for IUniswapV3PoolActions#swap
/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface
interface IUniswapV3SwapCallback {
    /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.
    /// @dev In the implementation you must pay the pool tokens owed for the swap.
    /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
    /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
    /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
    /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
    /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
    function uniswapV3SwapCallback(
        int256 amount0Delta,
        int256 amount1Delta,
        bytes calldata data
    ) external;
}

File 45 of 47 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

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

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

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

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

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

File 46 of 47 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

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

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

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

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

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

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

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

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

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

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

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

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

File 47 of 47 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint32","name":"_awesomeXMintingStartTimestamp","type":"uint32"},{"internalType":"uint32","name":"_awesomeXBuyAndBurnStartTimestamp","type":"uint32"},{"internalType":"address","name":"_titanX","type":"address"},{"internalType":"address","name":"_dragonX","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_dragonXTitanXPool","type":"address"}],"stateMutability":"payable","type":"constructor"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[],"name":"InvalidInput","type":"error"},{"inputs":[],"name":"OnlyBuyAndBurn","type":"error"},{"inputs":[],"name":"OnlyMinting","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"burnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"buyAndBurn","outputs":[{"internalType":"contract AwesomeXBuyAndBurn","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dragonXAwesomeXPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dragonXTitanXPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintTokensForLP","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minting","outputs":[{"internalType":"contract AwesomeXMinting","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]

6101006040526040516161fa3803806161fa833981016040819052610023916105cb565b60405180604001604052806008815260200167082eecae6dedacab60c31b81525060405180604001604052806003815260200162082aeb60eb1b815250816003908161006f91906106d3565b50600461007c82826106d3565b50505061008f838561017b60201b60201c565b6001600160a01b0390811660c052811660e05260405185908590859085906100b690610583565b63ffffffff90941684526001600160a01b0392831660208501529082166040840152166060820152608001604051809103905ff0801580156100fa573d5f803e3d5ffd5b506001600160a01b031660a081905260405185908890869061011b90610590565b6001600160a01b039485168152928416602084015263ffffffff9091166040830152919091166060820152608001604051809103905ff080158015610162573d5f803e3d5ffd5b506001600160a01b031660805250610865945050505050565b604080516001600160601b0319606084811b8216602084015261027160ec1b603484015285901b1660378201528151808203602b018152604b82019283905263cdca175360e01b9092525f91309173b27308f9f90d607463bb33ea1bebb41c27ce5ab691908490839063cdca1753906102069085906ba18f07d736b90be55000000090604f0161078d565b6020604051808303815f875af1158015610222573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061024691906107df565b90506ba18f07d736b90be5500000005f806001600160a01b03808816908b161061027157868a610274565b89875b915091505f808b6001600160a01b0316846001600160a01b03161461029a57848661029d565b85855b90925090505f633b9aca006102cd846102be85670de0b6b3a76400006107f6565b6102c8919061082d565b6103ef565b6102e4906c010000000000000000000000006107f6565b6102ee919061082d565b6040516309f56ab160e11b81526001600160a01b038088166004830152808716602483015261271060448301528216606482015290915073c36442b4a4522e871399cd717abdd847ab11fe889081906313ead562906084016020604051808303815f875af1158015610362573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610386919061084c565b6040516332148f6760e01b815260646004820152909c506001600160a01b038d16906332148f67906024015f604051808303815f87803b1580156103c8575f80fd5b505af11580156103da573d5f803e3d5ffd5b50505050505050505050505050505092915050565b5f815f036103fe57505f919050565b5f600161040a846104da565b901c6001901b9050600181848161042357610423610819565b048201901c9050600181848161043b5761043b610819565b048201901c9050600181848161045357610453610819565b048201901c9050600181848161046b5761046b610819565b048201901c9050600181848161048357610483610819565b048201901c9050600181848161049b5761049b610819565b048201901c905060018184816104b3576104b3610819565b048201901c90506104d3818285816104cd576104cd610819565b0461056e565b9392505050565b5f80608083901c156104ee57608092831c92015b604083901c1561050057604092831c92015b602083901c1561051257602092831c92015b601083901c1561052457601092831c92015b600883901c1561053657600892831c92015b600483901c1561054857600492831c92015b600283901c1561055a57600292831c92015b600183901c15610568576001015b92915050565b5f81831061057c57816104d3565b5090919050565b6139878061129c83390190565b6115d780614c2383390190565b805163ffffffff811681146105b0575f80fd5b919050565b80516001600160a01b03811681146105b0575f80fd5b5f805f805f8060c087890312156105e0575f80fd5b6105e98761059d565b95506105f76020880161059d565b9450610605604088016105b5565b9350610613606088016105b5565b9250610621608088016105b5565b915061062f60a088016105b5565b90509295509295509295565b634e487b7160e01b5f52604160045260245ffd5b600181811c9082168061066357607f821691505b60208210810361068157634e487b7160e01b5f52602260045260245ffd5b50919050565b601f8211156106ce57805f5260205f20601f840160051c810160208510156106ac5750805b601f840160051c820191505b818110156106cb575f81556001016106b8565b50505b505050565b81516001600160401b038111156106ec576106ec61063b565b610700816106fa845461064f565b84610687565b6020601f821160018114610732575f831561071b5750848201515b5f19600385901b1c1916600184901b1784556106cb565b5f84815260208120601f198516915b828110156107615787850151825560209485019460019092019101610741565b508482101561077e57868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b604081525f83518060408401525f5b818110156107b9576020818701810151606086840101520161079c565b505f606082850101526060601f19601f8301168401019150508260208301529392505050565b5f602082840312156107ef575f80fd5b5051919050565b808202811582820484141761056857634e487b7160e01b5f52601160045260245ffd5b634e487b7160e01b5f52601260045260245ffd5b5f8261084757634e487b7160e01b5f52601260045260245ffd5b500490565b5f6020828403121561085c575f80fd5b6104d3826105b5565b60805160a05160c05160e0516109ef6108ad5f395f61025501525f6101ac01525f81816102970152818161041101526105fc01525f8181610226015261054b01526109ef5ff3fe608060405234801561000f575f80fd5b5060043610610106575f3560e01c806370a082311161009e578063993aec851161006e578063993aec85146102505780639bed7b6c14610277578063a9059cbb1461027f578063aa6df29914610292578063dd62ed3e146102b9575f80fd5b806370a08231146101e657806379cc67901461020e5780637dc2268c1461022157806395d89b4114610248575f80fd5b8063313ce567116100d9578063313ce5671461017057806340c10f191461017f57806342966c68146101945780635d86d62e146101a7575f80fd5b806306fdde031461010a578063095ea7b31461012857806318160ddd1461014b57806323b872dd1461015d575b5f80fd5b6101126102f1565b60405161011f9190610832565b60405180910390f35b61013b610136366004610898565b610381565b604051901515815260200161011f565b6002545b60405190815260200161011f565b61013b61016b3660046108c0565b61039a565b6040516012815260200161011f565b61019261018d366004610898565b6103bd565b005b6101926101a23660046108fa565b6103d3565b6101ce7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161011f565b61014f6101f4366004610911565b6001600160a01b03165f9081526020819052604090205490565b61019261021c366004610898565b6103e0565b6101ce7f000000000000000000000000000000000000000000000000000000000000000081565b6101126103f5565b6101ce7f000000000000000000000000000000000000000000000000000000000000000081565b610192610404565b61013b61028d366004610898565b610444565b6101ce7f000000000000000000000000000000000000000000000000000000000000000081565b61014f6102c7366004610931565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b60606003805461030090610962565b80601f016020809104026020016040519081016040528092919081815260200182805461032c90610962565b80156103775780601f1061034e57610100808354040283529160200191610377565b820191905f5260205f20905b81548152906001019060200180831161035a57829003601f168201915b5050505050905090565b5f3361038e818585610451565b60019150505b92915050565b5f336103a7858285610463565b6103b28585856104e3565b506001949350505050565b6103c5610540565b6103cf8282610589565b5050565b6103dd33826105bd565b50565b6103eb823383610463565b6103cf82826105bd565b60606004805461030090610962565b61040c6105f1565b6104427f00000000000000000000000000000000000000000000000000000000000000006ba18f07d736b90be550000000610589565b565b5f3361038e8185856104e3565b61045e838383600161063a565b505050565b6001600160a01b038381165f908152600160209081526040808320938616835292905220545f1981146104dd57818110156104cf57604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064015b60405180910390fd5b6104dd84848484035f61063a565b50505050565b6001600160a01b03831661050c57604051634b637e8f60e11b81525f60048201526024016104c6565b6001600160a01b0382166105355760405163ec442f0560e01b81525f60048201526024016104c6565b61045e83838361070c565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146104425760405163c004a90b60e01b815260040160405180910390fd5b6001600160a01b0382166105b25760405163ec442f0560e01b81525f60048201526024016104c6565b6103cf5f838361070c565b6001600160a01b0382166105e657604051634b637e8f60e11b81525f60048201526024016104c6565b6103cf825f8361070c565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461044257604051633579266f60e11b815260040160405180910390fd5b6001600160a01b0384166106635760405163e602df0560e01b81525f60048201526024016104c6565b6001600160a01b03831661068c57604051634a1406b160e11b81525f60048201526024016104c6565b6001600160a01b038085165f90815260016020908152604080832093871683529290522082905580156104dd57826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516106fe91815260200190565b60405180910390a350505050565b6001600160a01b038316610736578060025f82825461072b919061099a565b909155506107a69050565b6001600160a01b0383165f90815260208190526040902054818110156107885760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016104c6565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b0382166107c2576002805482900390556107e0565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161082591815260200190565b60405180910390a3505050565b602081525f82518060208401525f5b8181101561085e5760208186018101516040868401015201610841565b505f604082850101526040601f19601f83011684010191505092915050565b80356001600160a01b0381168114610893575f80fd5b919050565b5f80604083850312156108a9575f80fd5b6108b28361087d565b946020939093013593505050565b5f805f606084860312156108d2575f80fd5b6108db8461087d565b92506108e96020850161087d565b929592945050506040919091013590565b5f6020828403121561090a575f80fd5b5035919050565b5f60208284031215610921575f80fd5b61092a8261087d565b9392505050565b5f8060408385031215610942575f80fd5b61094b8361087d565b91506109596020840161087d565b90509250929050565b600181811c9082168061097657607f821691505b60208210810361099457634e487b7160e01b5f52602260045260245ffd5b50919050565b8082018082111561039457634e487b7160e01b5f52601160045260245ffdfea26469706673582212204404d4c38dde25ed2fdf59d1a34e59a8b6653d009df4ad9e5120297361616d1d64736f6c634300081a00336101006040819052600e805462ffffff1916625a5a5a1790556139873881900390819083398101604081905261003491610138565b60015f55806001600160a01b03811661006657604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b61006f816100b0565b505063ffffffff90921660e0526001600160a01b0390811660a0523360c05216608052600380546001600160801b0319166001600160801b03179055610193565b600280546001600160a01b03191690556100c9816100cc565b50565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b80516001600160a01b0381168114610133575f80fd5b919050565b5f805f806080858703121561014b575f80fd5b845163ffffffff8116811461015e575f80fd5b935061016c6020860161011d565b925061017a6040860161011d565b91506101886060860161011d565b905092959194509250565b60805160a05160c05160e0516136e861029f5f395f81816105680152818161099101528181610adc01526117e901525f818161037f015281816108e001528181610ba401528181610cc001528181610da901528181610f33015281816114eb015281816115ad0152818161164701528181611b7301526129d601525f818161058f01528181610834015281816109ef01528181610a2b01528181610c6c01528181610e75015281816111b7015281816118e10152818161191e01528181612062015261210101525f818161078c01528181610c8d01528181610d8801528181611166015281816114480152818161194201528181611ad901528181611b4f01526129b501526136e85ff3fe608060405234801561000f575f80fd5b506004361061021e575f3560e01c806379ba50971161012a578063c8796572116100b4578063e30c397811610079578063e30c39781461052c578063efcdf9261461053d578063f2fde38b14610550578063f38d00f014610563578063f9119bbd1461058a575f80fd5b8063c8796572146104c4578063ce0db54e146104e1578063d9443923146104e9578063df49d31514610506578063e1a2831a14610519575f80fd5b80639c5bf874116100fa5780639c5bf8741461042f5780639f0e946014610442578063ad1b63f414610455578063bc6f782b146104a8578063c0cec367146104b1575f80fd5b806379ba5097146103fa5780637f74638314610402578063867dcd51146104155780638da5cb5b1461041e575f80fd5b80634636a702116101ab578063609cc9961161017b578063609cc996146103bd5780636aadede7146103c657806371076ff6146103cf578063715018a6146103e2578063782ee170146103ea575f80fd5b80634636a70214610363578063477b453e1461037a57806348adec01146103a1578063500d55b6146103b4575f80fd5b8063225a4699116101f1578063225a4699146102c2578063253c8b39146102dc5780632ec9c3b4146102f157806330dc71ac1461030457806344e43c9814610317575f80fd5b806302df9df114610222578063090f8ad414610252578063158a3b121461027c5780631bea83fe1461028f575b5f80fd5b600354610235906001600160801b031681565b6040516001600160801b0390911681526020015b60405180910390f35b60055461026790610100900463ffffffff1681565b60405163ffffffff9091168152602001610249565b61026761028a366004612cf1565b6105b1565b6102aa73c36442b4a4522e871399cd717abdd847ab11fe8881565b6040516001600160a01b039091168152602001610249565b6102ca6105ff565b60405160ff9091168152602001610249565b6102ef6102ea366004612cf1565b61060e565b005b6102676102ff366004612cf1565b61089a565b6102ef610312366004612d0c565b6108be565b61031f610aa2565b6040805163ffffffff96871681526001600160801b03909516602086015261ffff90931692840192909252929092166060820152901515608082015260a001610249565b61036c60085481565b604051908152602001610249565b6102aa7f000000000000000000000000000000000000000000000000000000000000000081565b61036c6103af366004612d0c565b610ba0565b61036c60095481565b61036c60075481565b61036c600c5481565b61036c6103dd366004612d0c565b610cbc565b6102ef610dcd565b600b546102679063ffffffff1681565b6102ef610de0565b6102ef610410366004612cf1565b610e26565b61036c600d5481565b6001546001600160a01b03166102aa565b6102ef61043d366004612d31565b611232565b610267610450366004612d31565b61127d565b610488610463366004612cf1565b600a6020525f90815260409020546001600160801b0380821691600160801b90041682565b604080516001600160801b03938416815292909116602083015201610249565b61036c60065481565b6102ef6104bf366004612d31565b6112b8565b6104cc611301565b60408051928352602083019190915201610249565b6102ef611596565b6005546104f69060ff1681565b6040519015158152602001610249565b6102ca610514366004612cf1565b6116a9565b6102ef610527366004612d31565b6116e1565b6002546001600160a01b03166102aa565b6102ef61054b366004612d60565b611724565b6102ef61055e366004612d8f565b61174e565b6102677f000000000000000000000000000000000000000000000000000000000000000081565b6102aa7f000000000000000000000000000000000000000000000000000000000000000081565b5f806105bf61c4e084612dbe565b90505f6105cf6201518083612dee565b90505f6105dd826001612e15565b6105ea9062015180612e31565b6105f69061c4e0612e15565b95945050505050565b5f610609426116a9565b905090565b6106166117bf565b61061e6117e7565b33321461063e57604051638f87599f60e01b815260040160405180910390fd5b60055460ff1661066157604051631864d7ab60e21b815260040160405180910390fd5b600b5463ffffffff165f908152600a602052604090208054600160801b90046001600160801b0316156106a7576040516331bbcb2160e11b815260040160405180910390fd5b60035481546001600160801b03918216911611156106dd5760035481546001600160801b0319166001600160801b039091161781555b80546001600160801b03908116600160801b810280821784555f926127109261070a926096921617612e57565b6107149190612e6e565b82549091505f9061072f9083906001600160801b0316612e81565b90505f610742828663ffffffff166118db565b90505f610756826101dc6127106001611a56565b90508060065f8282546107699190612e94565b909155505060405163a9059cbb60e01b815261dead6004820152602481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a9059cbb906044016020604051808303815f875af11580156107da573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107fe9190612eb6565b505f61081961080d8385612e81565b8863ffffffff16611aa7565b9050610823611596565b600b5463ffffffff16600d5561085a7f00000000000000000000000000000000000000000000000000000000000000003387611bd7565b6040513390829086907f1b3ed074dce570943c9d4e66776a060e8ac73af4f6b002482b09e561d90f038c905f90a450505050505061089760015f55565b50565b5f806108a861c4e084612dbe565b90506108b76201518082612dee565b9392505050565b805f036108de5760405163b4fa3fb360e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637dc2268c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561093a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061095e9190612ecf565b6001600160a01b0316336001600160a01b03161461098f5760405163c004a90b60e01b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000063ffffffff16421180156109dd57506005546101c2906109db90610100900463ffffffff1642612e81565b115b156109ea576109ea6117e7565b610a167f0000000000000000000000000000000000000000000000000000000000000000333084611ccb565b6040516370a0823160e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610a78573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a9c9190612eea565b600c5550565b5f805f805f80600560019054906101000a900463ffffffff1663ffffffff165f14610ada57600554610100900463ffffffff16610afc565b7f00000000000000000000000000000000000000000000000000000000000000005b90505f610b0f63ffffffff831642612e81565b600554909150610100900463ffffffff161580610b3357506101c263ffffffff8216115b15610b9757610b478163ffffffff16611dd0565b9198509650945090925082906101c263ffffffff8216118015610b765750600554610100900463ffffffff1615155b610b80575f610b83565b60015b610b909060ff1686612f01565b9450600192505b50509091929394565b5f807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663993aec856040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bfe573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c229190612ecf565b90506103845f610c3183612191565b90508163ffffffff168163ffffffff161015610c4b578091505b5f610c568484612349565b5090505f610c638261257e565b9050610cb181887f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000612899565b979650505050505050565b5f807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635d86d62e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d1a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d3e9190612ecf565b90506103845f610d4d83612191565b90508163ffffffff168163ffffffff161015610d67578091505b5f610d728484612349565b5090505f610d7f8261257e565b9050610cb181887f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000612899565b610dd5612967565b610dde5f612994565b565b60025433906001600160a01b03168114610e1d5760405163118cdaa760e01b81526001600160a01b03821660048201526024015b60405180910390fd5b61089781612994565b610e2e612967565b60055460ff1615610e5257604051630fd02b6d60e41b815260040160405180910390fd5b6040516370a0823160e01b81523060048201526ba18f07d736b90be550000000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610ec2573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ee69190612eea565b1015610f0557604051631bbc2d7d60e21b815260040160405180910390fd5b6005805460ff191660011790555f610f2f6ba18f07d736b90be55000000063ffffffff84166118db565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639bed7b6c6040518163ffffffff1660e01b81526004015f604051808303815f87803b158015610f89575f80fd5b505af1158015610f9b573d5f803e3d5ffd5b505050505f805f805f80610fbb876ba18f07d736b90be5500000006129ad565b955095509550955095509550610fe68273c36442b4a4522e871399cd717abdd847ab11fe8888612a5e565b6110058173c36442b4a4522e871399cd717abdd847ab11fe8887612a5e565b5f604051806101600160405280846001600160a01b03168152602001836001600160a01b0316815260200161271062ffffff16815260200160c880620d89e71961104f9190612f1b565b6110599190612f53565b60020b815260200160c880611071620d89e719612f72565b61107b9190612f1b565b6110859190612f53565b60020b8152602001888152602001878152602001868152602001858152602001306001600160a01b031681526020018a63ffffffff1681525090505f73c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03166388316456836040518263ffffffff1660e01b81526004016111019190612f92565b6080604051808303815f875af115801561111d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111419190613056565b50506040805180820182526001600160f81b0384168082526001600160a01b038981167f00000000000000000000000000000000000000000000000000000000000000008216146020909301839052600160f81b90920217600490815591516370a0823160e01b815230928101929092529293507f0000000000000000000000000000000000000000000000000000000000000000909216916370a082319150602401602060405180830381865afa1580156111ff573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112239190612eea565b600c5550505050505050505050565b61123a612967565b60648160ff16111561125f5760405163b4fa3fb360e01b815260040160405180910390fd5b600e805460ff909216620100000262ff000019909216919091179055565b61012c600560ff8316148061129557508160ff166006145b156112a357506104b0919050565b8160ff166004036112b357506102bc5b919050565b6112c0612967565b60648160ff1611156112e55760405163b4fa3fb360e01b815260040160405180910390fd5b600e805460ff9092166101000261ff0019909216919091179055565b604080518082018252600480546001600160f81b038082168452600160f81b90910460ff161515602080850191909152845160808101865284519092168252309082019081526001600160801b0382860181815260608401828152965163fc6f786560e01b815284519581019590955291516001600160a01b03166024850152905181166044840152935190931660648201525f9283929173c36442b4a4522e871399cd717abdd847ab11fe889063fc6f78659060840160408051808303815f875af11580156113d3573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113f79190613092565b602084015191955093505f908190611410578486611413565b85855b60405163a9059cbb60e01b815273cb1c9ab495656a9224ec9d76b97412fe0ab31f8a60048201526024810183905291935091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a9059cbb906044016020604051808303815f875af1158015611496573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114ba9190612eb6565b5060405163a9059cbb60e01b815273cb1c9ab495656a9224ec9d76b97412fe0ab31f8a6004820152602481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a9059cbb906044016020604051808303815f875af1158015611539573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061155d9190612eb6565b508160095f82825461156f9190612e94565b925050819055508060085f8282546115879190612e94565b92505081905550505050509091565b6040516370a0823160e01b81523060048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa1580156115fa573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061161e9190612eea565b90508060075461162e9190612e94565b600755604051630852cd8d60e31b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342966c68906024015f604051808303815f87803b158015611690575f80fd5b505af11580156116a2573d5f803e3d5ffd5b5050505050565b5f6007620151806116bc61c4e085612dbe565b6116c69190612dee565b6116d1906004612e15565b6116db91906130b4565b92915050565b6116e9612967565b60648160ff16111561170e5760405163b4fa3fb360e01b815260040160405180910390fd5b600e805460ff191660ff92909216919091179055565b61172c612967565b600380546001600160801b0319166001600160801b0392909216919091179055565b611756612967565b600280546001600160a01b0383166001600160a01b031990911681179091556117876001546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b60025f54036117e157604051633ee5aeb560e01b815260040160405180910390fd5b60025f55565b7f000000000000000000000000000000000000000000000000000000000000000063ffffffff1642101561182e57604051631864d7ab60e21b815260040160405180910390fd5b5f805f805f61183b610aa2565b9450945094509450945080156116a25761185b6101c261ffff8516612e31565b6118659083612e15565b6005805463ffffffff9283166101000264ffffffff00199091161790556040805180820182526001600160801b0380881682525f6020808401828152958b16808352600a909152939020915193518116600160801b02931692909217909155600b805463ffffffff191690911790555050505050565b5f61191b7f000000000000000000000000000000000000000000000000000000000000000073e592427a0aece92de3edee1f18e0157c0586156485612a5e565b5f7f00000000000000000000000000000000000000000000000000000000000000006127107f0000000000000000000000000000000000000000000000000000000000000000604051602001611973939291906130db565b60405160208183030381529060405290505f61198e85610ba0565b600e549091505f906064906119ab90610100900460ff1684612e57565b6119b59190612e6e565b6040805160a0810182528581523060208201528082018890526060810189905260808101839052905163c04b8d5960e01b81529192509073e592427a0aece92de3edee1f18e0157c058615649063c04b8d5990611a16908490600401613138565b6020604051808303815f875af1158015611a32573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cb19190612eea565b5f80611a63868686612b52565b9050611a6e83612c11565b8015611a8957505f8480611a8457611a84612dda565b868809115b15611a9c57611a99600182612e94565b90505b90505b949350505050565b60405163095ea7b360e01b815273e592427a0aece92de3edee1f18e0157c058615646004820152602481018390525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063095ea7b3906044016020604051808303815f875af1158015611b27573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611b4b9190612eb6565b505f7f00000000000000000000000000000000000000000000000000000000000000006127107f0000000000000000000000000000000000000000000000000000000000000000604051602001611ba4939291906130db565b60405160208183030381529060405290505f611bbf85610cbc565b600e549091505f906064906119ab9060ff1684612e57565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291515f92839290871691611c3291906131a6565b5f604051808303815f865af19150503d805f8114611c6b576040519150601f19603f3d011682016040523d82523d5f602084013e611c70565b606091505b5091509150818015611c9a575080511580611c9a575080806020019051810190611c9a9190612eb6565b6116a25760405162461bcd60e51b815260206004820152600260248201526114d560f21b6044820152606401610e14565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291515f92839290881691611d2e91906131a6565b5f604051808303815f865af19150503d805f8114611d67576040519150601f19603f3d011682016040523d82523d5f602084013e611d6c565b606091505b5091509150818015611d96575080511580611d96575080806020019051810190611d969190612eb6565b611dc85760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b6044820152606401610e14565b505050505050565b5f805f611ddc84612c3d565b600b54909150611df79061ffff83169063ffffffff16612e15565b611e02906001612e15565b92505f611e0e4261089a565b6005549091505f90610100900463ffffffff1615611e4257600554611e3d90610100900463ffffffff1661089a565b611e44565b815b90508063ffffffff168263ffffffff1603611ece575f612710611e686104506105ff565b63ffffffff16600c54611e7b9190612e57565b611e859190612e6e565b90505f611e976101c262015180612dee565b611ea79063ffffffff1683612e6e565b90505f611eb861ffff8716836131c1565b9050611ec481836131e3565b9650505050611ffc565b600554610100900463ffffffff165f611ee6826105b1565b90505b8263ffffffff168463ffffffff1610611fe0575f8163ffffffff164210611f2057611f15600183612dbe565b63ffffffff16611f22565b425b90505f6101c2611f328584612dbe565b611f3c9190612dee565b90505f612710611f4e610450856116a9565b63ffffffff16600c54611f619190612e57565b611f6b9190612e6e565b90505f611f7d6101c262015180612dee565b611f8d9063ffffffff1683612e6e565b9050611f9f63ffffffff8416826131c1565b611fa9908b6131e3565b9950611fb76101c286612dbe565b9550611fc861028a6101c288612e15565b945086611fd481613202565b97505050505050611ee9565b600c54866001600160801b03161115611ff957600c5495505b50505b600b5463ffffffff165f908152600a602090815260408083208151808301909252546001600160801b038082168352600160801b90910416918101829052919015612047575f61204a565b81515b6040516370a0823160e01b81523060048201529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa1580156120af573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120d39190612eea565b6120dd82886131e3565b6001600160801b03161115612179576040516370a0823160e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa15801561214e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121729190612eea565b9550612186565b61218381876131e3565b95505b505050509193909250565b5f805f836001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa1580156121d0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121f49190613237565b5050509350935050505f8161ffff16116122355760405162461bcd60e51b81526020600482015260026024820152614e4960f01b6044820152606401610e14565b5f806001600160a01b03861663252c09d784612252876001612f01565b61225c91906132c5565b6040516001600160e01b031960e084901b16815261ffff9091166004820152602401608060405180830381865afa158015612299573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906122bd91906132f9565b935050509150806123355760405163252c09d760e01b81525f60048201526001600160a01b0387169063252c09d790602401608060405180830381865afa15801561230a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061232e91906132f9565b5091935050505b61233f8242612dbe565b9695505050505050565b5f808263ffffffff165f036123855760405162461bcd60e51b8152602060048201526002602482015261042560f41b6044820152606401610e14565b6040805160028082526060820183525f9260208301908036833701905050905083815f815181106123b8576123b8613362565b602002602001019063ffffffff16908163ffffffff16815250505f816001815181106123e6576123e6613362565b602002602001019063ffffffff16908163ffffffff16815250505f80866001600160a01b031663883bdbfd846040518263ffffffff1660e01b815260040161242e9190613376565b5f60405180830381865afa158015612448573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261246f9190810190613485565b915091505f825f8151811061248657612486613362565b6020026020010151836001815181106124a1576124a1613362565b60200260200101516124b3919061354a565b90505f825f815181106124c8576124c8613362565b6020026020010151836001815181106124e3576124e3613362565b60200260200101516124f59190613577565b905063ffffffff88166125088184613596565b97505f8360060b128015612527575061252181846135c9565b60060b15155b1561253a5787612536816135ea565b9850505b63ffffffff8916640100000000600160c01b03602084901b166125646001600160a01b038361360b565b61256e919061363c565b9750505050505050509250929050565b5f805f8360020b12612593578260020b61259a565b8260020b5f035b9050620d89e88111156125c0576040516315e4079d60e11b815260040160405180910390fd5b5f816001165f036125d557600160801b6125e7565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561261b576ffff97272373d413259a46990580e213a0260801c5b600482161561263a576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615612659576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615612678576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615612697576fff973b41fa98c081472e6896dfb254c00260801c5b60408216156126b6576fff2ea16466c96a3843ec78b326b528610260801c5b60808216156126d5576ffe5dee046a99a2a811c461f1969c30530260801c5b6101008216156126f5576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615612715576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615612735576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615612755576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615612775576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615612795576fa9f746462d870fdf8a65dc1f90e061e50260801c5b6140008216156127b5576f70d869a156d2a1b890bb3df62baf32f70260801c5b6180008216156127d5576f31be135f97d08fd981231505542fcfa60260801c5b620100008216156127f6576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615612816576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615612835576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615612852576b048a170391f7dc42444e8fa20260801c5b5f8460020b131561287157805f198161286d5761286d612dda565b0490505b640100000000810615612885576001612887565b5f5b60ff16602082901c0192505050919050565b5f6001600160801b036001600160a01b0386161161290b575f6128c56001600160a01b03871680612e57565b9050826001600160a01b0316846001600160a01b0316106128f4576128ef600160c01b8683612b52565b612903565b6129038186600160c01b612b52565b915050611a9f565b5f6129296001600160a01b0387168068010000000000000000612b52565b9050826001600160a01b0316846001600160a01b03161061295857612953600160801b8683612b52565b61233f565b61233f8186600160801b612b52565b6001546001600160a01b03163314610dde5760405163118cdaa760e01b8152336004820152602401610e14565b600280546001600160a01b031916905561089781612c6a565b5f80808080807f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0380821690831610612a0f578082612a12565b81815b90945092506001600160a01b0380851690831614612a3157888a612a34565b89895b9098509650612a4288612cbb565b612a4b88612cbb565b989b979a50985092959194509092505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b17905291515f92839290871691612ab991906131a6565b5f604051808303815f865af19150503d805f8114612af2576040519150601f19603f3d011682016040523d82523d5f602084013e612af7565b606091505b5091509150818015612b21575080511580612b21575080806020019051810190612b219190612eb6565b6116a25760405162461bcd60e51b8152602060048201526002602482015261534160f01b6044820152606401610e14565b5f838302815f1985870982811083820303915050805f03612b8657838281612b7c57612b7c612dda565b04925050506108b7565b808411612ba65760405163227bc15360e01b815260040160405180910390fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b5f6002826003811115612c2657612c2661366a565b612c30919061367e565b60ff166001149050919050565b5f612c4a6101c283612e6e565b600554909150610100900463ffffffff16156112b357806108b78161369f565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b600e545f90606490612cd69062010000900460ff1684612e57565b6116db9190612e6e565b63ffffffff81168114610897575f80fd5b5f60208284031215612d01575f80fd5b81356108b781612ce0565b5f60208284031215612d1c575f80fd5b5035919050565b60ff81168114610897575f80fd5b5f60208284031215612d41575f80fd5b81356108b781612d23565b6001600160801b0381168114610897575f80fd5b5f60208284031215612d70575f80fd5b81356108b781612d4c565b6001600160a01b0381168114610897575f80fd5b5f60208284031215612d9f575f80fd5b81356108b781612d7b565b634e487b7160e01b5f52601160045260245ffd5b63ffffffff82811682821603908111156116db576116db612daa565b634e487b7160e01b5f52601260045260245ffd5b5f63ffffffff831680612e0357612e03612dda565b8063ffffffff84160491505092915050565b63ffffffff81811683821601908111156116db576116db612daa565b63ffffffff8181168382160290811690818114612e5057612e50612daa565b5092915050565b80820281158282048414176116db576116db612daa565b5f82612e7c57612e7c612dda565b500490565b818103818111156116db576116db612daa565b808201808211156116db576116db612daa565b805180151581146112b3575f80fd5b5f60208284031215612ec6575f80fd5b6108b782612ea7565b5f60208284031215612edf575f80fd5b81516108b781612d7b565b5f60208284031215612efa575f80fd5b5051919050565b61ffff81811683821601908111156116db576116db612daa565b5f8160020b8360020b80612f3157612f31612dda565b627fffff1982145f1982141615612f4a57612f4a612daa565b90059392505050565b5f8260020b8260020b028060020b9150808214612e5057612e50612daa565b5f8160020b627fffff198103612f8a57612f8a612daa565b5f0392915050565b81516001600160a01b0316815261016081016020830151612fbe60208401826001600160a01b03169052565b506040830151612fd5604084018262ffffff169052565b506060830151612fea606084018260020b9052565b506080830151612fff608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e08301526101008301516101008301526101208301516130466101208401826001600160a01b03169052565b5061014092830151919092015290565b5f805f8060808587031215613069575f80fd5b8451602086015190945061307c81612d4c565b6040860151606090960151949790965092505050565b5f80604083850312156130a3575f80fd5b505080516020909101519092909150565b5f63ffffffff8316806130c9576130c9612dda565b8063ffffffff84160691505092915050565b606093841b6bffffffffffffffffffffffff19908116825260e89390931b6001600160e81b0319166014820152921b166017820152602b0190565b5f5b83811015613130578181015183820152602001613118565b50505f910152565b602081525f825160a0602084015280518060c085015261315f8160e0860160208501613116565b60018060a01b0360208601511660408501526040850151606085015260608501516080850152608085015160a085015260e0601f19601f8301168501019250505092915050565b5f82516131b7818460208701613116565b9190910192915050565b6001600160801b038181168382160290811690818114612e5057612e50612daa565b6001600160801b0381811683821601908111156116db576116db612daa565b5f63ffffffff821663ffffffff810361321d5761321d612daa565b60010192915050565b805161ffff811681146112b3575f80fd5b5f805f805f805f60e0888a03121561324d575f80fd5b875161325881612d7b565b8097505060208801518060020b811461326f575f80fd5b955061327d60408901613226565b945061328b60608901613226565b935061329960808901613226565b925060a08801516132a981612d23565b91506132b760c08901612ea7565b905092959891949750929550565b5f61ffff8316806132d8576132d8612dda565b8061ffff84160691505092915050565b8051600681900b81146112b3575f80fd5b5f805f806080858703121561330c575f80fd5b845161331781612ce0565b9350613325602086016132e8565b9250604085015161333581612d7b565b915061334360608601612ea7565b905092959194509250565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b602080825282518282018190525f918401906040840190835b818110156133b357835163ffffffff1683526020938401939092019160010161338f565b509095945050505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156133e7576133e761334e565b604052919050565b5f67ffffffffffffffff8211156134085761340861334e565b5060051b60200190565b5f82601f830112613421575f80fd5b815161343461342f826133ef565b6133be565b8082825260208201915060208360051b860101925085831115613455575f80fd5b602085015b8381101561347b57805161346d81612d7b565b83526020928301920161345a565b5095945050505050565b5f8060408385031215613496575f80fd5b825167ffffffffffffffff8111156134ac575f80fd5b8301601f810185136134bc575f80fd5b80516134ca61342f826133ef565b8082825260208201915060208360051b8501019250878311156134eb575f80fd5b6020840193505b8284101561351457613503846132e8565b8252602093840193909101906134f2565b80955050505050602083015167ffffffffffffffff811115613534575f80fd5b61354085828601613412565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff821317156116db576116db612daa565b6001600160a01b0382811682821603908111156116db576116db612daa565b5f8160060b8360060b806135ac576135ac612dda565b667fffffffffffff1982145f1982141615612f4a57612f4a612daa565b5f8260060b806135db576135db612dda565b808360060b0791505092915050565b5f8160020b627fffff19810361360257613602612daa565b5f190192915050565b6001600160c01b0381811683821681810290921691818304811482151761363457613634612daa565b505092915050565b5f6001600160c01b0383168061365457613654612dda565b6001600160c01b03929092169190910492915050565b634e487b7160e01b5f52602160045260245ffd5b5f60ff83168061369057613690612dda565b8060ff84160691505092915050565b5f61ffff82168061360257613602612daa56fea2646970667358221220df341d2be521691d49500679e3fa60720812e01190fc712ace8c2ba8c7b66c0a64736f6c634300081a00336101006040526040516115d73803806115d78339810160408190526100239161009f565b6001600160a01b03841661004a5760405163b4fa3fb360e01b815260040160405180910390fd5b63ffffffff90911660e0526001600160a01b0390811660a052600480546001600160a01b031916331790559081166080521660c0526100fa565b80516001600160a01b038116811461009a575f80fd5b919050565b5f805f80608085870312156100b2575f80fd5b6100bb85610084565b93506100c960208601610084565b9250604085015163ffffffff811681146100e1575f80fd5b91506100ef60608601610084565b905092959194509250565b60805160a05160c05160e0516114106101c75f395f81816102820152818161041e0152818161047f015281816104dc01528181610662015261071e01525f818161020e015281816107dc0152818161087501528181610921015281816109d101528181610c850152610d3701525f818161016b01528181610bdd0152610c0401525f81816102b101528181610564015281816108060152818161095001528181610a9301528181610adb01528181610b2301528181610b6b01528181610bbb0152610cb401526114105ff3fe608060405234801561000f575f80fd5b5060043610610106575f3560e01c80638d9f98101161009e578063c8581e2a1161006e578063c8581e2a14610239578063d09d197714610253578063e6fd48bc1461027d578063ec1ebd7a146102a4578063f9119bbd146102ac575f80fd5b80638d9f9810146101c7578063a0712d68146101f6578063aa6df29914610209578063b13a444314610230575f80fd5b80636e3f5dae116100d95780636e3f5dae1461018d57806377c18c73146101965780638041950b1461019e5780638d50a3d9146101bd575f80fd5b8063049518911461010a5780631865e6231461011f5780632f8d70991461013b57806367e25ab014610166575b5f80fd5b61011d6101183660046111d8565b6102d3565b005b61012860015481565b6040519081526020015b60405180910390f35b60045461014e906001600160a01b031681565b6040516001600160a01b039091168152602001610132565b61014e7f000000000000000000000000000000000000000000000000000000000000000081565b61012860035481565b6101285f5481565b6101a862093a8081565b60405163ffffffff9091168152602001610132565b6101a86201518081565b6101cf610410565b6040805163ffffffff94851681529284166020840152921691810191909152606001610132565b61011d6102043660046111f1565b6104ba565b61014e7f000000000000000000000000000000000000000000000000000000000000000081565b61012860025481565b610241607d81565b60405160ff9091168152602001610132565b610128610261366004611208565b600560209081525f928352604080842090915290825290205481565b6101a87f000000000000000000000000000000000000000000000000000000000000000081565b610128610657565b61014e7f000000000000000000000000000000000000000000000000000000000000000081565b426102dd826106fd565b63ffffffff16111561030257604051632db8551b60e11b815260040160405180910390fd5b335f90815260056020908152604080832063ffffffff85168452909152812054908190036103435760405163d9025c8360e01b815260040160405180910390fd5b335f81815260056020908152604080832063ffffffff871680855290835281842093909355518481529192917fc10afd795c51bb27d049606b7853725991bf7a2fcfb451615b4fd7af6f7b5b81910160405180910390a3806001546103a8919061125a565b600155600480546040516340c10f1960e01b81523392810192909252602482018390526001600160a01b0316906340c10f19906044015b5f604051808303815f87803b1580156103f6575f80fd5b505af1158015610408573d5f803e3d5ffd5b505050505050565b5f80808061044463ffffffff7f0000000000000000000000000000000000000000000000000000000000000000164261126d565b905061045362093a8082611294565b61045e9060016112bb565b935062093a8061046f6001866112d7565b61047991906112f3565b6104a3907f00000000000000000000000000000000000000000000000000000000000000006112bb565b92506104b262015180846112bb565b915050909192565b805f036104da5760405163b4fa3fb360e01b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000063ffffffff1642101561052157604051631864d7ab60e21b815260040160405180910390fd5b5f8061052b610410565b92505091508063ffffffff16421115610557576040516354913e1960e01b815260040160405180910390fd5b61058c6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333086610758565b610595836107c5565b5f670de0b6b3a76400006105a7610657565b6105b19086611319565b6105bb9190611330565b335f90815260056020908152604080832063ffffffff881684529091528120805492935083929091906105ef90849061125a565b909155505060405181815263ffffffff84169033907f35e338cd1c45f4d09abab571f5559403d556df8920b83a5e2710f6f6657d44019060200160405180910390a38060025461063f919061125a565b6002555f5461064f90859061125a565b5f5550505050565b5f8062093a8061068d7f000000000000000000000000000000000000000000000000000000000000000063ffffffff164261126d565b6106979190611330565b9050607d63ffffffff821611156106ac5750607d5b6106ee6726db992a3b1800006106e96106d4670de0b6b3a7640000666379da05b60000610d9f565b63ffffffff8516670de0b6b3a7640000610ddc565b610e94565b6001600160a01b031691505090565b5f8062093a8061070e6001856112d7565b61071891906112f3565b610742907f00000000000000000000000000000000000000000000000000000000000000006112bb565b905061075162015180826112bb565b9392505050565b6040516001600160a01b0384811660248301528381166044830152606482018390526107bf9186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050610ebf565b50505050565b6040516370a0823160e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301525f917f0000000000000000000000000000000000000000000000000000000000000000909116906370a0823190602401602060405180830381865afa15801561084d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108719190611343565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d94439236040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108cf573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108f3919061135a565b610a2a576ba18f07d736b90be5500000008111610a085760405163095ea7b360e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018490527f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b3906044016020604051808303815f875af1158015610996573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109ba919061135a565b50604051630c371c6b60e21b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906330dc71ac906024016103df565b610a1e6ba18f07d736b90be5500000008261126d565b6001600160c01b031691505b5f610a3c836104b06127106001610f2a565b90505f610a508461015e6127106001610f2a565b90505f610a648561012c6127106001610f2a565b90505f610a78866101906127106001610f2a565b9050828401820160028202018603610ace6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001673cb1c9ab495656a9224ec9d76b97412fe0ab31f8a85610f79565b610b166001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001673da674e8998b9753c60b2a9d51a273821ae155d6984610f79565b610b5e6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167392c3d43102bb3e39fccd70c6d1933a93a395bfa484610f79565b610ba66001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001673b4a217e7de12fa3b0e859ec3f639bc2b64d5787486610f79565b6003805486019055610c026001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000087610f79565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637196e8416040518163ffffffff1660e01b81526004015f604051808303815f87803b158015610c5a575f80fd5b505af1158015610c6c573d5f803e3d5ffd5b505060405163095ea7b360e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018590527f000000000000000000000000000000000000000000000000000000000000000016925063095ea7b391506044016020604051808303815f875af1158015610cfc573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d20919061135a565b50604051630c371c6b60e21b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906330dc71ac906024015f604051808303815f87803b158015610d80575f80fd5b505af1158015610d92573d5f803e3d5ffd5b5050505050505050505050565b8082038115801590610db057508281115b80610db857505f5b15610dd65760405163e942b9ed60e01b815260040160405180910390fd5b92915050565b5f828015610e8857848015610e7e57600185168015610dfd57869350610e01565b8493505b50600284046002860495505b8515610e78578687028760801c15610e23575f80fd5b81810181811015610e32575f80fd5b8690049750506001861615610e6d578684028488820414158815151615610e57575f80fd5b81810181811015610e66575f80fd5b8690049450505b600286049550610e0d565b50610e82565b5f92505b50610e8c565b8291505b509392505050565b5f815f19048311820215610eaf5763c4c5d7f55f526004601cfd5b50670de0b6b3a764000091020490565b5f610ed36001600160a01b03841683610faa565b905080515f14158015610ef7575080806020019051810190610ef5919061135a565b155b15610f2557604051635274afe760e01b81526001600160a01b03841660048201526024015b60405180910390fd5b505050565b5f80610f37868686610fb7565b9050610f4283611076565b8015610f5d57505f8480610f5857610f58611280565b868809115b15610f7057610f6d60018261125a565b90505b95945050505050565b6040516001600160a01b03838116602483015260448201839052610f2591859182169063a9059cbb9060640161078d565b606061075183835f6110a2565b5f838302815f1985870982811083820303915050805f03610feb57838281610fe157610fe1611280565b0492505050610751565b80841161100b5760405163227bc15360e01b815260040160405180910390fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b5f600282600381111561108b5761108b611379565b611095919061138d565b60ff166001149050919050565b6060814710156110c75760405163cd78605960e01b8152306004820152602401610f1c565b5f80856001600160a01b031684866040516110e291906113ae565b5f6040518083038185875af1925050503d805f811461111c576040519150601f19603f3d011682016040523d82523d5f602084013e611121565b606091505b509150915061113186838361113b565b9695505050505050565b6060826111505761114b82611197565b610751565b815115801561116757506001600160a01b0384163b155b1561119057604051639996b31560e01b81526001600160a01b0385166004820152602401610f1c565b5080610751565b8051156111a75780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b803563ffffffff811681146111d3575f80fd5b919050565b5f602082840312156111e8575f80fd5b610751826111c0565b5f60208284031215611201575f80fd5b5035919050565b5f8060408385031215611219575f80fd5b82356001600160a01b038116811461122f575f80fd5b915061123d602084016111c0565b90509250929050565b634e487b7160e01b5f52601160045260245ffd5b80820180821115610dd657610dd6611246565b81810381811115610dd657610dd6611246565b634e487b7160e01b5f52601260045260245ffd5b5f63ffffffff8316806112a9576112a9611280565b8063ffffffff84160491505092915050565b63ffffffff8181168382160190811115610dd657610dd6611246565b63ffffffff8281168282160390811115610dd657610dd6611246565b63ffffffff818116838216029081169081811461131257611312611246565b5092915050565b8082028115828204841417610dd657610dd6611246565b5f8261133e5761133e611280565b500490565b5f60208284031215611353575f80fd5b5051919050565b5f6020828403121561136a575f80fd5b81518015158114610751575f80fd5b634e487b7160e01b5f52602160045260245ffd5b5f60ff83168061139f5761139f611280565b8060ff84160691505092915050565b5f82515f5b818110156113cd57602081860181015185830152016113b3565b505f92019182525091905056fea26469706673582212206b04dab62c0beb098c4111dde129386076ec934d6498de98651bc0dec36f57af64736f6c634300081a00330000000000000000000000000000000000000000000000000000000066fec8a30000000000000000000000000000000000000000000000000000000066ff1d030000000000000000000000008627582d31b3dcffb8b44b20f158d5fcb6a1584e0000000000000000000000007d0ac226b2fe1310ab871950a4c08c4419e05b1f0000000000000000000000006a425f00269b13239d18be64784804044088e083000000000000000000000000f38d1e94e7f9fb8c1316ecfabc2653121a7e6680

Deployed Bytecode

0x608060405234801561000f575f80fd5b5060043610610106575f3560e01c806370a082311161009e578063993aec851161006e578063993aec85146102505780639bed7b6c14610277578063a9059cbb1461027f578063aa6df29914610292578063dd62ed3e146102b9575f80fd5b806370a08231146101e657806379cc67901461020e5780637dc2268c1461022157806395d89b4114610248575f80fd5b8063313ce567116100d9578063313ce5671461017057806340c10f191461017f57806342966c68146101945780635d86d62e146101a7575f80fd5b806306fdde031461010a578063095ea7b31461012857806318160ddd1461014b57806323b872dd1461015d575b5f80fd5b6101126102f1565b60405161011f9190610832565b60405180910390f35b61013b610136366004610898565b610381565b604051901515815260200161011f565b6002545b60405190815260200161011f565b61013b61016b3660046108c0565b61039a565b6040516012815260200161011f565b61019261018d366004610898565b6103bd565b005b6101926101a23660046108fa565b6103d3565b6101ce7f000000000000000000000000049c2e0e979527997d1cd8487319e9cfbd18838781565b6040516001600160a01b03909116815260200161011f565b61014f6101f4366004610911565b6001600160a01b03165f9081526020819052604090205490565b61019261021c366004610898565b6103e0565b6101ce7f0000000000000000000000004578c9e0151f074ffdd26ac65433004152546c2281565b6101126103f5565b6101ce7f000000000000000000000000f38d1e94e7f9fb8c1316ecfabc2653121a7e668081565b610192610404565b61013b61028d366004610898565b610444565b6101ce7f00000000000000000000000068a12a3d37bacacce1a82f0702270b1bf9138d4d81565b61014f6102c7366004610931565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b60606003805461030090610962565b80601f016020809104026020016040519081016040528092919081815260200182805461032c90610962565b80156103775780601f1061034e57610100808354040283529160200191610377565b820191905f5260205f20905b81548152906001019060200180831161035a57829003601f168201915b5050505050905090565b5f3361038e818585610451565b60019150505b92915050565b5f336103a7858285610463565b6103b28585856104e3565b506001949350505050565b6103c5610540565b6103cf8282610589565b5050565b6103dd33826105bd565b50565b6103eb823383610463565b6103cf82826105bd565b60606004805461030090610962565b61040c6105f1565b6104427f00000000000000000000000068a12a3d37bacacce1a82f0702270b1bf9138d4d6ba18f07d736b90be550000000610589565b565b5f3361038e8185856104e3565b61045e838383600161063a565b505050565b6001600160a01b038381165f908152600160209081526040808320938616835292905220545f1981146104dd57818110156104cf57604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064015b60405180910390fd5b6104dd84848484035f61063a565b50505050565b6001600160a01b03831661050c57604051634b637e8f60e11b81525f60048201526024016104c6565b6001600160a01b0382166105355760405163ec442f0560e01b81525f60048201526024016104c6565b61045e83838361070c565b336001600160a01b037f0000000000000000000000004578c9e0151f074ffdd26ac65433004152546c2216146104425760405163c004a90b60e01b815260040160405180910390fd5b6001600160a01b0382166105b25760405163ec442f0560e01b81525f60048201526024016104c6565b6103cf5f838361070c565b6001600160a01b0382166105e657604051634b637e8f60e11b81525f60048201526024016104c6565b6103cf825f8361070c565b336001600160a01b037f00000000000000000000000068a12a3d37bacacce1a82f0702270b1bf9138d4d161461044257604051633579266f60e11b815260040160405180910390fd5b6001600160a01b0384166106635760405163e602df0560e01b81525f60048201526024016104c6565b6001600160a01b03831661068c57604051634a1406b160e11b81525f60048201526024016104c6565b6001600160a01b038085165f90815260016020908152604080832093871683529290522082905580156104dd57826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516106fe91815260200190565b60405180910390a350505050565b6001600160a01b038316610736578060025f82825461072b919061099a565b909155506107a69050565b6001600160a01b0383165f90815260208190526040902054818110156107885760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016104c6565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b0382166107c2576002805482900390556107e0565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161082591815260200190565b60405180910390a3505050565b602081525f82518060208401525f5b8181101561085e5760208186018101516040868401015201610841565b505f604082850101526040601f19601f83011684010191505092915050565b80356001600160a01b0381168114610893575f80fd5b919050565b5f80604083850312156108a9575f80fd5b6108b28361087d565b946020939093013593505050565b5f805f606084860312156108d2575f80fd5b6108db8461087d565b92506108e96020850161087d565b929592945050506040919091013590565b5f6020828403121561090a575f80fd5b5035919050565b5f60208284031215610921575f80fd5b61092a8261087d565b9392505050565b5f8060408385031215610942575f80fd5b61094b8361087d565b91506109596020840161087d565b90509250929050565b600181811c9082168061097657607f821691505b60208210810361099457634e487b7160e01b5f52602260045260245ffd5b50919050565b8082018082111561039457634e487b7160e01b5f52601160045260245ffdfea26469706673582212204404d4c38dde25ed2fdf59d1a34e59a8b6653d009df4ad9e5120297361616d1d64736f6c634300081a0033

Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.