ETH Price: $2,935.97 (-0.76%)

Contract

0x4D1DeC18368B4e7c62e4EbdD8dF22BA938B6a9d4

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Token Holdings

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Toggle Merkl Ope...145128972025-05-27 15:57:13242 days ago1748361433IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000170.00199502
Sweep Token144857622025-05-27 0:52:43243 days ago1748307163IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000050.00105429
Sweep Token144857452025-05-27 0:52:09243 days ago1748307129IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000050.00105359
Remove Full Posi...144857252025-05-27 0:51:29243 days ago1748307089IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000250.00105297
Remove Full Posi...144855942025-05-27 0:47:07243 days ago1748306827IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000230.00104814
Toggle Merkl Ope...144851262025-05-27 0:31:31243 days ago1748305891IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000040.00103376
Sweep Token144849642025-05-27 0:26:07243 days ago1748305567IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000060.00102896
Remove Incentive...144849452025-05-27 0:25:29243 days ago1748305529IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000060.00102845
Compound143381592025-05-23 14:52:37246 days ago1748011957IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000310.0010027
Sweep Token143380582025-05-23 14:49:15246 days ago1748011755IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000080.00100249
Compound143379902025-05-23 14:46:59246 days ago1748011619IN
0x4D1DeC18...938B6a9d4
0 ETH0.00000030.00100235
Set Merkl Claim ...143213762025-05-23 5:33:11247 days ago1747978391IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000160.00414179
Set Fees143207832025-05-23 5:13:25247 days ago1747977205IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000180.00563633
Set Fees143206552025-05-23 5:09:09247 days ago1747976949IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000190.00598651
Set Fees143198632025-05-23 4:42:45247 days ago1747975365IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000260.00833957
Sweep Token143196862025-05-23 4:36:51247 days ago1747975011IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000340.00905451
Add Incentive143194632025-05-23 4:29:25247 days ago1747974565IN
0x4D1DeC18...938B6a9d4
0 ETH0.000001320.00940825
Set Slippage143191912025-05-23 4:20:21247 days ago1747974021IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000310.00957256
Set Fees143190662025-05-23 4:16:11247 days ago1747973771IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000290.00964486
Set Slippage143126592025-05-23 0:42:37247 days ago1747960957IN
0x4D1DeC18...938B6a9d4
0 ETH0.000000110.00328175

View more zero value Internal Transactions in Advanced View mode

Advanced mode:

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ProxyPoolJUZ

Compiler Version
v0.8.24+commit.e11b9ed9

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
// SPDX-License-Identifier: MIT
//
// ░▒▓█▓▒░      ░▒▓████████▓▒░     ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓████████▓▒░
// ░▒▓█▓▒░      ░▒▓█▓▒░            ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░      ░▒▓█▓▒░
// ░▒▓█▓▒░      ░▒▓█▓▒░            ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░    ░▒▓██▓▒░
// ░▒▓█▓▒░      ░▒▓██████▓▒░       ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░  ░▒▓██▓▒░
// ░▒▓█▓▒░      ░▒▓█▓▒░     ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓██▓▒░
// ░▒▓█▓▒░      ░▒▓█▓▒░     ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░
// ░▒▓████████▓▒░▒▓████████▓▒░▒▓██████▓▒░ ░▒▓██████▓▒░░▒▓████████▓▒░
//

pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@uniswap/v3-core/contracts/libraries/TickMath.sol";
import "./lib/LiquidityAmounts.sol";
import "./lib/FullMath.sol";

import {ISignatureTransfer} from "./interfaces/ISignatureTransfer.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IUniswapV3Pool} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import {INonfungiblePositionManager} from "@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol";

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

// We want to extract rewards from Merkl Campaings too
// So we add DEV_ADDRESS to the MerklOperator contract as an operator
interface IMerklOperatorContract {
    // @see https://github.com/AngleProtocol/merkl-contracts/blob/main/contracts/Distributor.sol#L231
    function toggleOperator(address user, address operator) external;

    // @see https://github.com/AngleProtocol/merkl-contracts/blob/main/contracts/Distributor.sol#L242
    function setClaimRecipient(address recipient, address token) external;
}

contract ProxyPoolJUZ is Ownable, ReentrancyGuard {
    using SafeERC20 for IERC20;

    // Uniswap's Permit2 Address
    ISignatureTransfer public immutable PERMIT2;

    // Address to send fees to
    address public DEV_ADDRESS = 0xA353557ddfc96325a8ab18E6f6d9c1fC0d7C1eA6;

    // Used to manualy extract rewards from Merkl Campaigns
    // @see https://github.com/AngleProtocol/merkl-contracts/blob/main/archive/deployments/worldchain/Distributor.json#L2
    IMerklOperatorContract public constant MERKL_OPERATOR =
        IMerklOperatorContract(0x3Ef3D8bA38EBe18DB133cEc108f4D14CE00Dd9Ae);

    // Time lock for incentive claiming
    uint256 private _lastCompoundTime = 0;

    // Default BPS precision
    uint16 public immutable BPS_PRECISION = 1_000;

    //////////////////////////////////////////
    // Events
    //////////////////////////////////////////

    event NewDeposit(
        address indexed user,
        uint256 amount0,
        uint256 amount1,
        uint256 shares
    );

    event Withdrawal(
        address indexed user,
        uint256 amount0,
        uint256 amount1,
        uint256 shares
    );

    event SlippageChanged(
        uint8 minSlippage,
        uint8 maxSlippage,
        uint8 increment
    );

    event CompoundCall(address indexed user, uint256 reward0, uint256 reward1);

    event BatchedIncentivesComplete(uint256 batchIndex, uint256 batchSize);

    //////////////////////////////////////////
    // Incentive Distribution Settings
    //////////////////////////////////////////
    uint256 public INCENTIVE_BATCH_INDEX = 0;

    // Number of users to process in each batch
    uint256 public INCENTIVE_BATCH_SIZE = 300;

    //////////////////////////////////////////
    // Slippage Settings
    //////////////////////////////////////////

    uint8 public MIN_SPLIPPAGE = 3; // 0.3% slippage
    uint8 public MAX_SLIPPAGE = 15; // 1.5% slippage
    uint8 public SLIPPAGE_INCREMENT = 2; // 0.2% slippage increment
    uint8 public NEXT_CALL_SLIPPAGE = MIN_SPLIPPAGE;

    //////////////////////////////////////////
    // Initial Fee Configuration
    //////////////////////////////////////////

    uint8 public FEE_WITHDRAWAL = 30; // 3% withdrawal fee
    uint8 public FEE_FOR_COMPOUNDER = 5; // 0.5% incentive as reward
    uint8 public FEE_DEV = 10; // 1% dev fee

    //////////////////////////////////////////
    // Uniswap V3 Position Metadata
    //////////////////////////////////////////

    INonfungiblePositionManager public immutable POSITION_MANAGER;
    uint256 public POSITION_NFT_ID; // ID of the contract owned position NFT

    IERC20 public immutable TOKEN_0;
    IERC20 public immutable TOKEN_1;

    IUniswapV3Pool public immutable POOL;

    //////////////////////////////////////////
    // Accounting and Shares
    //////////////////////////////////////////

    struct Deposit {
        uint256 amount0;
        uint256 amount1;
    }

    mapping(address => Deposit) public addressDeposits;

    uint256 public totalShares;
    mapping(address => uint256) public addressShares; // Shares of each user

    // track address with shares
    address[] public addressBook;

    //////////////////////////////////////////
    // Incentives Tracking
    //////////////////////////////////////////

    struct Incentive {
        // Token to incentivize
        address token;
        // Incentive start and end time
        uint256 startTime;
        uint256 endTime;
        // Amount of incentive to distribute
        uint256 amount;
        // Accumulated amount distributed
        // to each user
        uint256 distributed;
        // Last time incentives were distributed
        uint256 lastUpdate;
    }

    Incentive[] public incentives;

    constructor(
        address _permit2,
        address _positionManager,
        address _pool
    ) Ownable(msg.sender) {
        PERMIT2 = ISignatureTransfer(_permit2);
        POSITION_MANAGER = INonfungiblePositionManager(_positionManager);
        POOL = IUniswapV3Pool(_pool);
        TOKEN_0 = IERC20(POOL.token0());
        TOKEN_1 = IERC20(POOL.token1());

        // Add DEV_ADDRESS as an operator in Merkl Operator contract
        _toggleMerklOperator(DEV_ADDRESS);

        // Approve POSITION_MANAGER to spend contract tokens
        TOKEN_0.approve(_positionManager, type(uint256).max);
        TOKEN_1.approve(_positionManager, type(uint256).max);
    }

    //////////////////////////////////////////
    // User Deposits and Withdrawals
    //////////////////////////////////////////

    function depositWithPermit(
        uint256 amount0,
        uint256 amount1,
        ISignatureTransfer.PermitTransferFrom calldata permit0,
        ISignatureTransfer.SignatureTransferDetails calldata details0,
        bytes calldata sig0,
        ISignatureTransfer.PermitTransferFrom calldata permit1,
        ISignatureTransfer.SignatureTransferDetails calldata details1,
        bytes calldata sig1
    ) external {
        require(amount0 > 0 && amount1 > 0, "ZeroAmount");

        uint256 totalValueIn0 = totalValueInToken0();

        if (totalShares > 0) {
            require(totalValueIn0 > 0, "NoLiquidity");
        }

        // Add to address book if no shares
        // Assume first user deposit
        if (addressShares[msg.sender] == 0) {
            addressBook.push(msg.sender);
        }

        // Get the total value in token0 terms
        uint256 valueIn0 = _valueInToken0(amount0, amount1);

        // Mimic ERC4626 shares calculation
        uint256 claimingShares = totalShares == 0
            ? valueIn0 // 1:1 for first user
            : (valueIn0 * totalShares) / totalValueIn0;

        addressShares[msg.sender] += claimingShares;
        totalShares += claimingShares;

        // Transfer balances to contract
        PERMIT2.permitTransferFrom(permit0, details0, msg.sender, sig0);
        addressDeposits[msg.sender].amount0 += amount0;

        PERMIT2.permitTransferFrom(permit1, details1, msg.sender, sig1);
        addressDeposits[msg.sender].amount1 += amount1;

        _compoundLiquidity(false); // false = not incentivized
        _distributeIncentives();

        // Emit event for new deposit
        emit NewDeposit(msg.sender, amount0, amount1, claimingShares);
    }

    function withdraw(uint256 shares) external nonReentrant {
        require(shares > 0, "ZeroShares");
        require(POSITION_NFT_ID != 0, "NotInitialized");

        uint256 userShare = addressShares[msg.sender];
        require(userShare >= shares, "NotEnoughShares");

        // Process the next batch of incentives
        // Thanks withdrawer : p
        _distributeIncentives();

        // Collect the fees earned to this point
        _collectFees();

        // We compound balances + fees earned BEFORE withdrawing
        _compoundLiquidity(false); // false = not incentivized

        // Process the shares withdrawal
        (
            uint256 amount0,
            uint256 amount1,
            uint256 devFee0,
            uint256 devFee1
        ) = _processWithdrawal(msg.sender, shares);

        // Claim dev fees
        if (devFee0 > 0) TOKEN_0.safeTransfer(DEV_ADDRESS, devFee0);
        if (devFee1 > 0) TOKEN_1.safeTransfer(DEV_ADDRESS, devFee1);

        // Notify offchain about the withdrawal
        emit Withdrawal(msg.sender, amount0, amount1, shares);
    }

    function _processWithdrawal(
        address user,
        uint256 shares
    )
        internal
        returns (
            uint256 amount0,
            uint256 amount1,
            uint256 feeOrContractBalance0,
            uint256 feeOrContractBalance1
        )
    {
        (uint128 liquidity, , ) = getLPMetadata();

        // Convert liquidity * userShares / totalShares
        uint256 userLiquidity = FullMath.mulDiv(
            uint256(liquidity),
            shares,
            totalShares
        );

        require(userLiquidity <= type(uint128).max, "Overflow");

        // Remove user owned liquidity
        _removeLiquidity(uint128(userLiquidity));

        // Collect all earned fees + balance for user's liquidity
        (uint256 collectedAmount0, uint256 collectedAmount1) = _collectFees();

        // Get the user's deposit
        Deposit storage deposit = addressDeposits[user];

        feeOrContractBalance0 = TOKEN_0.balanceOf(address(this));
        feeOrContractBalance1 = TOKEN_1.balanceOf(address(this));

        // Get user deposit amounts ratioed by shares
        amount0 = shares == totalShares // Take all if user is withdrawing all remaining shares
            ? feeOrContractBalance0
            : FullMath.mulDiv(deposit.amount0, shares, totalShares);

        amount1 = shares == totalShares
            ? feeOrContractBalance1
            : FullMath.mulDiv(deposit.amount1, shares, totalShares);

        // If collected amount is greater than user
        // original deposit, we charge fees on the collected amount
        if (collectedAmount0 > amount0) amount0 = collectedAmount0;
        if (collectedAmount1 > amount1) amount1 = collectedAmount1;

        // Clamp to contract balances
        if (amount0 > feeOrContractBalance0) amount0 = feeOrContractBalance0;
        if (amount1 > feeOrContractBalance1) amount1 = feeOrContractBalance1;

        // Calculate dev fees
        feeOrContractBalance0 = _parseFee(amount0, FEE_WITHDRAWAL);
        feeOrContractBalance1 = _parseFee(amount1, FEE_WITHDRAWAL);

        uint256 finalAmount0 = amount0 - feeOrContractBalance0;
        uint256 finalAmount1 = amount1 - feeOrContractBalance1;

        // Transfer final amounts to user
        if (finalAmount0 > 0) TOKEN_0.safeTransfer(user, finalAmount0);
        if (finalAmount1 > 0) TOKEN_1.safeTransfer(user, finalAmount1);

        // Updated claimed shares
        totalShares -= shares;
        addressShares[user] -= shares;

        // Remove user from addressBook when ZERO shares
        if (addressShares[user] == 0) {
            _removeAddressBook(user);
        }

        // Set to 0 if collected amount is greater than current deposit
        // Otherwise subtract the amount

        deposit.amount0 = deposit.amount0 > amount0 && shares != totalShares // We set to ZERO if the user is withdrawing all shares
            ? deposit.amount0 - amount0
            : 0;

        deposit.amount1 = deposit.amount1 > amount1 && shares != totalShares
            ? deposit.amount1 - amount1
            : 0;
    }

    //////////////////////////////////////////
    // LP Position Management
    //////////////////////////////////////////

    function getLPMetadata()
        public
        view
        returns (uint128 ownedLiquidity, int24 tickLow, int24 tickUp)
    {
        if (POSITION_NFT_ID == 0) return (0, 0, 0);
        (, , , , , tickLow, tickUp, ownedLiquidity, , , , ) = POSITION_MANAGER
            .positions(POSITION_NFT_ID);
    }

    function _removeLiquidity(uint128 _liquidity) internal {
        // Get the total assets[0,1] in the LP position
        (uint256 amount0, uint256 amount1) = getLiquidityAmounts();

        // Normalize to match slippage
        (
            uint256 slippageAmount0,
            uint256 slippageAmount1
        ) = _getSlippageAmounts(amount0, amount1);

        INonfungiblePositionManager.DecreaseLiquidityParams memory params = INonfungiblePositionManager
            .DecreaseLiquidityParams({
                tokenId: POSITION_NFT_ID,
                liquidity: _liquidity,
                amount0Min: slippageAmount0,
                amount1Min: slippageAmount1,
                deadline: block.timestamp + 15 seconds // Give some extra time
            });

        POSITION_MANAGER.decreaseLiquidity(params);
    }

    function _mintOrIncreaseLiquidity(
        uint256 amount0,
        uint256 amount1
    ) internal {
        // Early exit if any empty amount
        // This is to avoid updaating position with 0 liquidity
        if (amount0 == 0 || amount1 == 0) return;

        (
            uint256 slippageAmount0,
            uint256 slippageAmount1
        ) = _getSlippageAmounts(amount0, amount1);

        if (POSITION_NFT_ID == 0) {
            INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager
                .MintParams({
                    token0: address(TOKEN_0),
                    token1: address(TOKEN_1),
                    fee: POOL.fee(),
                    tickLower: -887220, // Min Tick Range
                    tickUpper: 887220, // Max Tick Range
                    amount0Desired: amount0,
                    amount1Desired: amount1,
                    amount0Min: slippageAmount0,
                    amount1Min: slippageAmount1,
                    recipient: address(this),
                    deadline: block.timestamp + 15 seconds // Give some extra time
                });

            (uint256 tokenId, , , ) = POSITION_MANAGER.mint(params);

            // Store the created NFT tokenId of the position
            POSITION_NFT_ID = tokenId;
        } else {
            INonfungiblePositionManager.IncreaseLiquidityParams memory params = INonfungiblePositionManager
                .IncreaseLiquidityParams({
                    tokenId: POSITION_NFT_ID,
                    amount0Desired: amount0,
                    amount1Desired: amount1,
                    amount0Min: slippageAmount0,
                    amount1Min: slippageAmount1,
                    deadline: block.timestamp + 15 seconds // Give some extra time
                });

            try POSITION_MANAGER.increaseLiquidity(params) {
                // Reset slippage to min if possible
                if (NEXT_CALL_SLIPPAGE > MIN_SPLIPPAGE) {
                    NEXT_CALL_SLIPPAGE = MIN_SPLIPPAGE;
                }
            } catch {
                // Increase slippage for next call
                // This is to avoid slippage errors
                // We reset when successful
                if (NEXT_CALL_SLIPPAGE < MAX_SLIPPAGE) {
                    NEXT_CALL_SLIPPAGE += SLIPPAGE_INCREMENT;
                }
            }
        }
    }

    //////////////////////////////////////////
    // Price helpers and Normalization
    //////////////////////////////////////////

    function totalValueInToken0() public view returns (uint256) {
        if (POSITION_NFT_ID == 0) return 0;
        (uint256 amount0, uint256 amount1) = getLiquidityAmounts();
        return _valueInToken0(amount0, amount1);
    }

    function _valueInToken0(
        uint256 amount0,
        uint256 amount1
    ) internal view returns (uint256) {
        (uint160 sqrtPriceX96, , , , , , ) = POOL.slot0();
        if (sqrtPriceX96 == 0) return amount0;

        uint256 sqrtPriceX96Squared = uint256(sqrtPriceX96) *
            uint256(sqrtPriceX96);

        // token1 in token0 terms = (2^192 * 1e18) / sqrtPriceX96^2
        uint256 price1In0 = FullMath.mulDiv(
            1 << 192,
            1e18,
            sqrtPriceX96Squared
        );

        // Convert amount1 to token0 terms
        uint256 valueOfAmount1InToken0 = FullMath.mulDiv(
            amount1,
            price1In0,
            1e18
        );

        return amount0 + valueOfAmount1InToken0;
    }

    //////////////////////////////////////////
    // Yield Extraction and Compounding
    //////////////////////////////////////////

    function recklesslyCompound()
        external
        // Used to simulate rewards earned
        // Available for owner only
        onlyOwner
        returns (
            uint256 reward0,
            uint256 reward1,
            uint256 nextClaimTime,
            bool isTimeLocked
        )
    {
        _collectFees();
        (reward0, reward1) = _compoundLiquidity(true); // incentivized = true

        // Set flags for time lock
        nextClaimTime = _lastCompoundTime + 15 seconds;
        isTimeLocked = block.timestamp <= nextClaimTime;
    }

    function compound()
        external
        nonReentrant
        returns (uint256 reward0, uint256 reward1)
    {
        require(POSITION_NFT_ID != 0, "NotInitialized");

        // Block farming rewards by waiting 15 seconds per call
        require(
            block.timestamp > _lastCompoundTime + 15 seconds,
            "Wait15Seconds"
        );

        // Distribute incentives & Collect fees
        _distributeIncentives();
        _collectFees();

        (reward0, reward1) = _compoundLiquidity(true); // incentivized = true

        // Update last compound time
        _lastCompoundTime = block.timestamp;

        // Emit event for compounder call
        emit CompoundCall(msg.sender, reward0, reward1);
    }

    function _compoundLiquidity(
        bool isIncentivized
    ) internal returns (uint256 incentive0, uint256 incentive1) {
        uint256 amount0 = TOKEN_0.balanceOf(address(this));
        uint256 amount1 = TOKEN_1.balanceOf(address(this));

        // Early exit if any empty amount
        if (amount0 == 0 || amount1 == 0) return (0, 0);

        uint256 devFee0 = 0;
        uint256 devFee1 = 0;

        if (isIncentivized) {
            // Calculate rewarding fees

            incentive0 = _parseFee(amount0, FEE_FOR_COMPOUNDER);
            incentive1 = _parseFee(amount1, FEE_FOR_COMPOUNDER);

            if (incentive0 > 0) TOKEN_0.safeTransfer(msg.sender, incentive0);
            if (incentive1 > 0) TOKEN_1.safeTransfer(msg.sender, incentive1);

            devFee0 = _parseFee(amount0, FEE_DEV);
            devFee1 = _parseFee(amount1, FEE_DEV);

            if (devFee0 > 0) TOKEN_0.safeTransfer(DEV_ADDRESS, devFee0);
            if (devFee1 > 0) TOKEN_1.safeTransfer(DEV_ADDRESS, devFee1);
        }

        // Subtract fees from the amounts
        uint256 finalAmount0 = amount0 - incentive0 - devFee0;
        uint256 finalAmount1 = amount1 - incentive1 - devFee1;

        // Compound the remaining
        _mintOrIncreaseLiquidity(finalAmount0, finalAmount1);
    }

    function _collectFees()
        internal
        returns (uint256 amount0, uint256 amount1)
    {
        if (POSITION_NFT_ID != 0) {
            (amount0, amount1) = POSITION_MANAGER.collect(
                INonfungiblePositionManager.CollectParams({
                    tokenId: POSITION_NFT_ID,
                    recipient: address(this),
                    amount0Max: type(uint128).max,
                    amount1Max: type(uint128).max
                })
            );
        }
    }

    //////////////////////////////////////////
    // Incentives Management
    //////////////////////////////////////////

    function setIncentiveBatchSize(uint256 batchSize) external onlyOwner {
        require(batchSize > 0, "ZeroBatchSize");
        INCENTIVE_BATCH_SIZE = batchSize;
    }

    function addIncentive(
        address token,
        uint256 startTime,
        uint256 endTime,
        uint256 amount
    ) external onlyOwner {
        _addIncentive(token, startTime, endTime, amount);
    }

    function getIncentiveCount() external view returns (uint256 count) {
        return incentives.length;
    }

    function _addIncentive(
        address token,
        uint256 startTime,
        uint256 endTime,
        uint256 amount
    ) internal {
        require(token != address(0), "ZeroAddress");
        require(endTime > startTime, "InvalidTime");
        require(amount > 0, "ZeroAmount");

        incentives.push(
            Incentive({
                token: token,
                startTime: startTime,
                endTime: endTime,
                amount: amount,
                distributed: 0,
                lastUpdate: 0
            })
        );
    }

    function _distributeIncentives() internal {
        uint256 nowtime = block.timestamp;

        for (uint256 i = 0; i < incentives.length; i++) {
            Incentive storage incentive = incentives[i];

            // Skip if outside the incentive time window
            if (
                nowtime <= incentive.lastUpdate ||
                nowtime < incentive.startTime ||
                incentive.lastUpdate > incentive.endTime
            ) {
                continue;
            }

            // Calculate effective time range for this distribution
            uint256 from = incentive.lastUpdate < incentive.startTime
                ? incentive.startTime
                : incentive.lastUpdate;

            uint256 to = nowtime > incentive.endTime
                ? incentive.endTime
                : nowtime;

            uint256 elapsed = to - from;
            uint256 totalDuration = incentive.endTime - incentive.startTime;

            // Calculate the amount to distribute proportional to elapsed time
            uint256 distributable = (incentive.amount * elapsed) /
                totalDuration;

            // Calculate amount to distribute this cycle (minus already distributed)
            uint256 amountToDistribute = distributable >= incentive.distributed
                ? distributable - incentive.distributed
                : 0;

            if (amountToDistribute == 0 || totalShares == 0) {
                // Early exit if no amount to distribute
                continue;
            }

            // Check contract balance to avoid over-transfer
            uint256 contractBalance = IERC20(incentive.token).balanceOf(
                address(this)
            );

            if (amountToDistribute > contractBalance) {
                // Clamp to contract balance
                amountToDistribute = contractBalance;
            }

            // Distribute the incentive to current batch of users
            _batchDistribute(amountToDistribute, incentive.token);

            // Update incentive state
            incentive.distributed += amountToDistribute;
            incentive.lastUpdate = nowtime;
        }
    }

    function _batchDistribute(uint256 incentiveAmount, address token) internal {
        uint256 batchEnd = INCENTIVE_BATCH_INDEX + INCENTIVE_BATCH_SIZE;
        if (batchEnd > addressBook.length) batchEnd = addressBook.length;

        // Distribute to each user proportionally
        for (uint256 j = INCENTIVE_BATCH_INDEX; j < batchEnd; j++) {
            address user = addressBook[j];
            uint256 userShares = addressShares[user];

            if (userShares > 0) {
                uint256 userAmount = (incentiveAmount * userShares) /
                    totalShares;
                if (userAmount > 0) {
                    IERC20(token).safeTransfer(user, userAmount);
                }
            }
        }

        // Notify the incentive distribution state
        emit BatchedIncentivesComplete(
            INCENTIVE_BATCH_INDEX,
            batchEnd - INCENTIVE_BATCH_INDEX
        );

        // Move BATCH pointer forward
        INCENTIVE_BATCH_INDEX = batchEnd;

        if (INCENTIVE_BATCH_INDEX >= addressBook.length) {
            // Reset to 0 if we reached addressBook length
            INCENTIVE_BATCH_INDEX = 0;
        }
    }

    //////////////////////////////////////////
    // Merkl Operator Management
    //////////////////////////////////////////

    function setMerklClaimRecipient(
        address recipient,
        address token
    ) external onlyOwner {
        MERKL_OPERATOR.setClaimRecipient(recipient, token);
    }

    function toggleMerklOperator(address operator) external onlyOwner {
        _toggleMerklOperator(operator);
    }

    function _toggleMerklOperator(address operator) internal {
        MERKL_OPERATOR.toggleOperator(address(this), operator);
    }

    //////////////////////////////////////////
    // Management and Configuration
    //////////////////////////////////////////

    function removeFullPosition() external onlyOwner {
        require(POSITION_NFT_ID != 0, "NotInitialized");

        // Get all available liquidity
        (uint128 liquidity, , ) = getLPMetadata();
        require(liquidity > 0, "NothingToRemove");

        // Remove it all
        _removeLiquidity(liquidity);

        // Collect fees + balances
        _collectFees();
    }

    function sweepToken(IERC20 token, address recipient) external onlyOwner {
        require(address(token) != address(0), "ZeroAddress");
        uint256 amount = token.balanceOf(address(this));
        token.safeTransfer(recipient, amount);
    }

    function setFees(
        uint8 _withdrawal,
        uint8 _compoundRewards,
        uint8 _dev
    ) external onlyOwner {
        require(_withdrawal < BPS_PRECISION, "InvalidFee");
        require(_compoundRewards < BPS_PRECISION, "InvalidFee");
        require(_dev < BPS_PRECISION, "InvalidFee");

        FEE_WITHDRAWAL = _withdrawal;
        FEE_FOR_COMPOUNDER = _compoundRewards;
        FEE_DEV = _dev;
    }

    function setDevAddress(address _dev) external onlyOwner {
        require(_dev != address(0), "ZeroAddress");
        DEV_ADDRESS = _dev;
    }

    function removeIncentiveByIndex(uint256 index) external onlyOwner {
        require(index < incentives.length, "InvalidIndex");

        // Move the last incentive to the deleted index
        if (index < incentives.length - 1) {
            incentives[index] = incentives[incentives.length - 1];
        }

        // Remove the last incentive
        incentives.pop();
    }

    //////////////////////////////////////////
    // Slippage Management
    //////////////////////////////////////////

    function setSlippage(
        uint8 _min,
        uint8 _max,
        uint8 _increment
    ) external onlyOwner {
        require(_min < BPS_PRECISION, "InvalidSlippage");
        require(_max < BPS_PRECISION, "InvalidSlippage");
        require(_increment < BPS_PRECISION, "InvalidSlippage");

        MIN_SPLIPPAGE = _min;
        MAX_SLIPPAGE = _max;
        SLIPPAGE_INCREMENT = _increment;

        emit SlippageChanged(_min, _max, _increment);
    }

    function _getSlippageAmounts(
        uint256 amount0,
        uint256 amount1
    ) internal view returns (uint256 slippageAmount0, uint256 slippageAmount1) {
        uint8 slippage = NEXT_CALL_SLIPPAGE > MAX_SLIPPAGE
            ? MAX_SLIPPAGE
            : NEXT_CALL_SLIPPAGE;

        slippageAmount0 = FullMath.mulDiv(amount0, slippage, BPS_PRECISION);
        slippageAmount1 = FullMath.mulDiv(amount1, slippage, BPS_PRECISION);

        return (slippageAmount0, slippageAmount1);
    }

    //////////////////////////////////////////
    // Utility Functions
    //////////////////////////////////////////

    function getLiquidityAmounts()
        public
        view
        returns (uint256 amount0, uint256 amount1)
    {
        // Get total assets[0,1] in the LP position
        // and convert them to token0 terms

        (uint128 liquidity, int24 tickLower, int24 tickUpper) = getLPMetadata();
        (uint160 sqrtPriceX96, , , , , , ) = POOL.slot0();

        uint160 sqrtPriceAX96 = TickMath.getSqrtRatioAtTick(tickLower);
        uint160 sqrtPriceBX96 = TickMath.getSqrtRatioAtTick(tickUpper);

        (amount0, amount1) = LiquidityAmounts.getAmountsForLiquidity(
            sqrtPriceX96,
            sqrtPriceAX96,
            sqrtPriceBX96,
            liquidity
        );
    }

    function _removeAddressBook(address user) internal {
        uint256 len = addressBook.length;
        for (uint256 i = 0; i < len; i++) {
            if (addressBook[i] == user) {
                // Move last element to the deleted index
                addressBook[i] = addressBook[len - 1];
                addressBook.pop(); // Remove last element
                break;
            }
        }
    }

    function _parseFee(
        uint256 value,
        uint8 fee
    ) internal pure returns (uint256) {
        return FullMath.mulDiv(value, fee, BPS_PRECISION);
    }
}

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)

pragma solidity ^0.8.20;

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

/**
 * @title IERC1363
 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
 *
 * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
 * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
 */
interface IERC1363 is IERC20, IERC165 {
    /*
     * Note: the ERC-165 identifier for this interface is 0xb0202a11.
     * 0xb0202a11 ===
     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
     */

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @param data Additional data with no specified format, sent in call to `spender`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}

File 4 of 31 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)

pragma solidity ^0.8.20;

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

File 5 of 31 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)

pragma solidity ^0.8.20;

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

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

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
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);
}

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

pragma solidity ^0.8.20;

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

/**
 * @title SafeERC20
 * @dev Wrappers around ERC-20 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 {
    /**
     * @dev An operation with an ERC-20 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.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    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.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    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.
     *
     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
     * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
     * set here.
     */
    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 Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            safeTransfer(token, to, value);
        } else if (!token.transferAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferFromAndCallRelaxed(
        IERC1363 token,
        address from,
        address to,
        uint256 value,
        bytes memory data
    ) internal {
        if (to.code.length == 0) {
            safeTransferFrom(token, from, to, value);
        } else if (!token.transferFromAndCall(from, to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
     * once without retrying, and relies on the returned value to be true.
     *
     * Reverts if the returned value is other than `true`.
     */
    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            forceApprove(token, to, value);
        } else if (!token.approveAndCall(to, value, data)) {
            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 {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            // bubble errors
            if iszero(success) {
                let ptr := mload(0x40)
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            returnSize := returndatasize()
            returnValue := mload(0)
        }

        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
            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 silently catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0)
        }
        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
    }
}

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Required interface of an ERC-721 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 ERC-721 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 ERC-721
     * 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);
}

// 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;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * 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[ERC 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);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.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 EIP-1153 (transient storage) is available on the chain you're deploying at,
 * consider using {ReentrancyGuardTransient} instead.
 *
 * 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 14 of 31 : IUniswapV3Pool.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import './pool/IUniswapV3PoolImmutables.sol';
import './pool/IUniswapV3PoolState.sol';
import './pool/IUniswapV3PoolDerivedState.sol';
import './pool/IUniswapV3PoolActions.sol';
import './pool/IUniswapV3PoolOwnerActions.sol';
import './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,
    IUniswapV3PoolEvents
{

}

// 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;
}

// 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 17 of 31 : 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);
}

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

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

// 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
    /// 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.
    /// observationIndex The index of the last oracle observation that was written,
    /// observationCardinality The current maximum number of observations stored in the pool,
    /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.
    /// 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
    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,
    /// liquidityNet how much liquidity changes when the pool price crosses the tick,
    /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
    /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
    /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
    /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
    /// secondsOutside the seconds spent on the other side of the tick from the current tick,
    /// 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,
    /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
    /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
    /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
    /// Returns 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,
    /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
    /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
    /// Returns 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 21 of 31 : FixedPoint96.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.4.0;

/// @title FixedPoint96
/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)
/// @dev Used in SqrtPriceMath.sol
library FixedPoint96 {
    uint8 internal constant RESOLUTION = 96;
    uint256 internal constant Q96 = 0x1000000000000000000000000;
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.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 {
    /// @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) {
        uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
        require(absTick <= uint256(int256(MAX_TICK)), '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) {
        // second inequality must be < because the price can never reach the price at the max tick
        require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, '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;
    }
}

// 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;
}

// 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;
}

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

// 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;
}

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

// 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 =
        0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;

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

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

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

// SPDX-License-Identifier: MIT
// Taken from: https://worldscan.org/address/0xF0882554ee924278806d708396F1a7975b732522#code#F3#L1

pragma solidity ^0.8.0;

interface IEIP712 {
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

/// @title SignatureTransfer
/// @notice Handles ERC20 token transfers through signature based actions
/// @dev Requires user's token approval on the Permit2 contract
interface ISignatureTransfer is IEIP712 {
    /// @notice Thrown when the requested amount for a transfer is larger than the permissioned amount
    /// @param maxAmount The maximum amount a spender can request to transfer
    error InvalidAmount(uint256 maxAmount);

    /// @notice Thrown when the number of tokens permissioned to a spender does not match the number of tokens being transferred
    /// @dev If the spender does not need to transfer the number of tokens permitted, the spender can request amount 0 to be transferred
    error LengthMismatch();

    /// @notice Emits an event when the owner successfully invalidates an unordered nonce.
    event UnorderedNonceInvalidation(
        address indexed owner,
        uint256 word,
        uint256 mask
    );

    /// @notice The token and amount details for a transfer signed in the permit transfer signature
    struct TokenPermissions {
        // ERC20 token address
        address token;
        // the maximum amount that can be spent
        uint256 amount;
    }

    /// @notice The signed permit message for a single token transfer
    struct PermitTransferFrom {
        TokenPermissions permitted;
        // a unique value for every token owner's signature to prevent signature replays
        uint256 nonce;
        // deadline on the permit signature
        uint256 deadline;
    }

    /// @notice Specifies the recipient address and amount for batched transfers.
    /// @dev Recipients and amounts correspond to the index of the signed token permissions array.
    /// @dev Reverts if the requested amount is greater than the permitted signed amount.
    struct SignatureTransferDetails {
        // recipient address
        address to;
        // spender requested amount
        uint256 requestedAmount;
    }

    /// @notice Used to reconstruct the signed permit message for multiple token transfers
    /// @dev Do not need to pass in spender address as it is required that it is msg.sender
    /// @dev Note that a user still signs over a spender address
    struct PermitBatchTransferFrom {
        // the tokens and corresponding amounts permitted for a transfer
        TokenPermissions[] permitted;
        // a unique value for every token owner's signature to prevent signature replays
        uint256 nonce;
        // deadline on the permit signature
        uint256 deadline;
    }

    /// @notice A map from token owner address and a caller specified word index to a bitmap. Used to set bits in the bitmap to prevent against signature replay protection
    /// @dev Uses unordered nonces so that permit messages do not need to be spent in a certain order
    /// @dev The mapping is indexed first by the token owner, then by an index specified in the nonce
    /// @dev It returns a uint256 bitmap
    /// @dev The index, or wordPosition is capped at type(uint248).max
    function nonceBitmap(address, uint256) external view returns (uint256);

    /// @notice Transfers a token using a signed permit message
    /// @dev Reverts if the requested amount is greater than the permitted signed amount
    /// @param permit The permit data signed over by the owner
    /// @param owner The owner of the tokens to transfer
    /// @param transferDetails The spender's requested transfer details for the permitted token
    /// @param signature The signature to verify
    function permitTransferFrom(
        PermitTransferFrom memory permit,
        SignatureTransferDetails calldata transferDetails,
        address owner,
        bytes calldata signature
    ) external;

    /// @notice Transfers a token using a signed permit message
    /// @notice Includes extra data provided by the caller to verify signature over
    /// @dev The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition
    /// @dev Reverts if the requested amount is greater than the permitted signed amount
    /// @param permit The permit data signed over by the owner
    /// @param owner The owner of the tokens to transfer
    /// @param transferDetails The spender's requested transfer details for the permitted token
    /// @param witness Extra data to include when checking the user signature
    /// @param witnessTypeString The EIP-712 type definition for remaining string stub of the typehash
    /// @param signature The signature to verify
    function permitWitnessTransferFrom(
        PermitTransferFrom memory permit,
        SignatureTransferDetails calldata transferDetails,
        address owner,
        bytes32 witness,
        string calldata witnessTypeString,
        bytes calldata signature
    ) external;

    /// @notice Transfers multiple tokens using a signed permit message
    /// @param permit The permit data signed over by the owner
    /// @param owner The owner of the tokens to transfer
    /// @param transferDetails Specifies the recipient and requested amount for the token transfer
    /// @param signature The signature to verify
    function permitTransferFrom(
        PermitBatchTransferFrom memory permit,
        SignatureTransferDetails[] calldata transferDetails,
        address owner,
        bytes calldata signature
    ) external;

    /// @notice Transfers multiple tokens using a signed permit message
    /// @dev The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition
    /// @notice Includes extra data provided by the caller to verify signature over
    /// @param permit The permit data signed over by the owner
    /// @param owner The owner of the tokens to transfer
    /// @param transferDetails Specifies the recipient and requested amount for the token transfer
    /// @param witness Extra data to include when checking the user signature
    /// @param witnessTypeString The EIP-712 type definition for remaining string stub of the typehash
    /// @param signature The signature to verify
    function permitWitnessTransferFrom(
        PermitBatchTransferFrom memory permit,
        SignatureTransferDetails[] calldata transferDetails,
        address owner,
        bytes32 witness,
        string calldata witnessTypeString,
        bytes calldata signature
    ) external;

    /// @notice Invalidates the bits specified in mask for the bitmap at the word position
    /// @dev The wordPos is maxed at type(uint248).max
    /// @param wordPos A number to index the nonceBitmap at
    /// @param mask A bitmap masked against msg.sender's current bitmap at the word position
    function invalidateUnorderedNonces(uint256 wordPos, uint256 mask) external;
}

// 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 = a * b; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly ("memory-safe") {
                let mm := mulmod(a, b, not(0))
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

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

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

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

            // Make division exact by subtracting the remainder from [prod1 prod0]
            // Compute remainder using mulmod
            uint256 remainder;
            assembly ("memory-safe") {
                remainder := mulmod(a, b, denominator)
            }
            // Subtract 256 bit number from 512 bit number
            assembly ("memory-safe") {
                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 ("memory-safe") {
                denominator := div(denominator, twos)
            }

            // Divide [prod1 prod0] by the factors of two
            assembly ("memory-safe") {
                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 ("memory-safe") {
                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 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 * 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 > 0);
            }
        }
    }
}

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import "./FullMath.sol";
import "@uniswap/v3-core/contracts/libraries/FixedPoint96.sol";

/// @title Liquidity amount functions
/// @notice Provides functions for computing liquidity amounts from token amounts and prices
library LiquidityAmounts {
    /// @notice Downcasts uint256 to uint128
    /// @param x The uint258 to be downcasted
    /// @return y The passed value, downcasted to uint128
    function toUint128(uint256 x) private pure returns (uint128 y) {
        require((y = uint128(x)) == x);
    }

    /// @notice Computes the amount of liquidity received for a given amount of token0 and price range
    /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower))
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param amount0 The amount0 being sent in
    /// @return liquidity The amount of returned liquidity
    function getLiquidityForAmount0(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint256 amount0
    ) internal pure returns (uint128 liquidity) {
        if (sqrtRatioAX96 > sqrtRatioBX96)
            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
        uint256 intermediate = FullMath.mulDiv(
            sqrtRatioAX96,
            sqrtRatioBX96,
            FixedPoint96.Q96
        );
        return
            toUint128(
                FullMath.mulDiv(
                    amount0,
                    intermediate,
                    sqrtRatioBX96 - sqrtRatioAX96
                )
            );
    }

    /// @notice Computes the amount of liquidity received for a given amount of token1 and price range
    /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)).
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param amount1 The amount1 being sent in
    /// @return liquidity The amount of returned liquidity
    function getLiquidityForAmount1(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint256 amount1
    ) internal pure returns (uint128 liquidity) {
        if (sqrtRatioAX96 > sqrtRatioBX96)
            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
        return
            toUint128(
                FullMath.mulDiv(
                    amount1,
                    FixedPoint96.Q96,
                    sqrtRatioBX96 - sqrtRatioAX96
                )
            );
    }

    /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current
    /// pool prices and the prices at the tick boundaries
    /// @param sqrtRatioX96 A sqrt price representing the current pool prices
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param amount0 The amount of token0 being sent in
    /// @param amount1 The amount of token1 being sent in
    /// @return liquidity The maximum amount of liquidity received
    function getLiquidityForAmounts(
        uint160 sqrtRatioX96,
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint256 amount0,
        uint256 amount1
    ) internal pure returns (uint128 liquidity) {
        if (sqrtRatioAX96 > sqrtRatioBX96)
            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

        if (sqrtRatioX96 <= sqrtRatioAX96) {
            liquidity = getLiquidityForAmount0(
                sqrtRatioAX96,
                sqrtRatioBX96,
                amount0
            );
        } else if (sqrtRatioX96 < sqrtRatioBX96) {
            uint128 liquidity0 = getLiquidityForAmount0(
                sqrtRatioX96,
                sqrtRatioBX96,
                amount0
            );
            uint128 liquidity1 = getLiquidityForAmount1(
                sqrtRatioAX96,
                sqrtRatioX96,
                amount1
            );

            liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1;
        } else {
            liquidity = getLiquidityForAmount1(
                sqrtRatioAX96,
                sqrtRatioBX96,
                amount1
            );
        }
    }

    /// @notice Computes the amount of token0 for a given amount of liquidity and a price range
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param liquidity The liquidity being valued
    /// @return amount0 The amount of token0
    function getAmount0ForLiquidity(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint128 liquidity
    ) internal pure returns (uint256 amount0) {
        if (sqrtRatioAX96 > sqrtRatioBX96)
            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

        return
            FullMath.mulDiv(
                uint256(liquidity) << FixedPoint96.RESOLUTION,
                sqrtRatioBX96 - sqrtRatioAX96,
                sqrtRatioBX96
            ) / sqrtRatioAX96;
    }

    /// @notice Computes the amount of token1 for a given amount of liquidity and a price range
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param liquidity The liquidity being valued
    /// @return amount1 The amount of token1
    function getAmount1ForLiquidity(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint128 liquidity
    ) internal pure returns (uint256 amount1) {
        if (sqrtRatioAX96 > sqrtRatioBX96)
            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

        return
            FullMath.mulDiv(
                liquidity,
                sqrtRatioBX96 - sqrtRatioAX96,
                FixedPoint96.Q96
            );
    }

    /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current
    /// pool prices and the prices at the tick boundaries
    /// @param sqrtRatioX96 A sqrt price representing the current pool prices
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param liquidity The liquidity being valued
    /// @return amount0 The amount of token0
    /// @return amount1 The amount of token1
    function getAmountsForLiquidity(
        uint160 sqrtRatioX96,
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint128 liquidity
    ) internal pure returns (uint256 amount0, uint256 amount1) {
        if (sqrtRatioAX96 > sqrtRatioBX96)
            (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

        if (sqrtRatioX96 <= sqrtRatioAX96) {
            amount0 = getAmount0ForLiquidity(
                sqrtRatioAX96,
                sqrtRatioBX96,
                liquidity
            );
        } else if (sqrtRatioX96 < sqrtRatioBX96) {
            amount0 = getAmount0ForLiquidity(
                sqrtRatioX96,
                sqrtRatioBX96,
                liquidity
            );
            amount1 = getAmount1ForLiquidity(
                sqrtRatioAX96,
                sqrtRatioX96,
                liquidity
            );
        } else {
            amount1 = getAmount1ForLiquidity(
                sqrtRatioAX96,
                sqrtRatioBX96,
                liquidity
            );
        }
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "evmVersion": "paris",
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_permit2","type":"address"},{"internalType":"address","name":"_positionManager","type":"address"},{"internalType":"address","name":"_pool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"batchIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"batchSize","type":"uint256"}],"name":"BatchedIncentivesComplete","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reward1","type":"uint256"}],"name":"CompoundCall","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"NewDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"minSlippage","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"maxSlippage","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"increment","type":"uint8"}],"name":"SlippageChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Withdrawal","type":"event"},{"inputs":[],"name":"BPS_PRECISION","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEV_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_DEV","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_FOR_COMPOUNDER","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_WITHDRAWAL","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INCENTIVE_BATCH_INDEX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INCENTIVE_BATCH_SIZE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_SLIPPAGE","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MERKL_OPERATOR","outputs":[{"internalType":"contract IMerklOperatorContract","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_SPLIPPAGE","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NEXT_CALL_SLIPPAGE","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERMIT2","outputs":[{"internalType":"contract ISignatureTransfer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"POOL","outputs":[{"internalType":"contract IUniswapV3Pool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"POSITION_MANAGER","outputs":[{"internalType":"contract INonfungiblePositionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"POSITION_NFT_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLIPPAGE_INCREMENT","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKEN_0","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKEN_1","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"addIncentive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"addressBook","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"addressDeposits","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"addressShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"compound","outputs":[{"internalType":"uint256","name":"reward0","type":"uint256"},{"internalType":"uint256","name":"reward1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ISignatureTransfer.TokenPermissions","name":"permitted","type":"tuple"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct ISignatureTransfer.PermitTransferFrom","name":"permit0","type":"tuple"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"requestedAmount","type":"uint256"}],"internalType":"struct ISignatureTransfer.SignatureTransferDetails","name":"details0","type":"tuple"},{"internalType":"bytes","name":"sig0","type":"bytes"},{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ISignatureTransfer.TokenPermissions","name":"permitted","type":"tuple"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct ISignatureTransfer.PermitTransferFrom","name":"permit1","type":"tuple"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"requestedAmount","type":"uint256"}],"internalType":"struct ISignatureTransfer.SignatureTransferDetails","name":"details1","type":"tuple"},{"internalType":"bytes","name":"sig1","type":"bytes"}],"name":"depositWithPermit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getIncentiveCount","outputs":[{"internalType":"uint256","name":"count","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLPMetadata","outputs":[{"internalType":"uint128","name":"ownedLiquidity","type":"uint128"},{"internalType":"int24","name":"tickLow","type":"int24"},{"internalType":"int24","name":"tickUp","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLiquidityAmounts","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"incentives","outputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"distributed","type":"uint256"},{"internalType":"uint256","name":"lastUpdate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"recklesslyCompound","outputs":[{"internalType":"uint256","name":"reward0","type":"uint256"},{"internalType":"uint256","name":"reward1","type":"uint256"},{"internalType":"uint256","name":"nextClaimTime","type":"uint256"},{"internalType":"bool","name":"isTimeLocked","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"removeFullPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"removeIncentiveByIndex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_dev","type":"address"}],"name":"setDevAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_withdrawal","type":"uint8"},{"internalType":"uint8","name":"_compoundRewards","type":"uint8"},{"internalType":"uint8","name":"_dev","type":"uint8"}],"name":"setFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"batchSize","type":"uint256"}],"name":"setIncentiveBatchSize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"setMerklClaimRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_min","type":"uint8"},{"internalType":"uint8","name":"_max","type":"uint8"},{"internalType":"uint8","name":"_increment","type":"uint8"}],"name":"setSlippage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"address","name":"recipient","type":"address"}],"name":"sweepToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"toggleMerklOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalValueInToken0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

610140604052600280546001600160a01b03191673a353557ddfc96325a8ab18e6f6d9c1fc0d7c1ea6179055600060038190556103e860a05260045561012c60055560068054660a051e03020f0366ffffffffffffff199091161790553480156200006957600080fd5b506040516200403d3803806200403d8339810160408190526200008c91620003c7565b3380620000b357604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b620000be81620002e2565b50600180556001600160a01b0380841660805282811660c052811661012081905260408051630dfe168160e01b81529051630dfe1681916004808201926020929091908290030181865afa1580156200011b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000141919062000411565b6001600160a01b031660e0816001600160a01b031681525050610120516001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200019c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001c2919062000411565b6001600160a01b0390811661010052600254620001e0911662000332565b60e05160405163095ea7b360e01b81526001600160a01b03848116600483015260001960248301529091169063095ea7b3906044016020604051808303816000875af115801562000235573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200025b919062000436565b506101005160405163095ea7b360e01b81526001600160a01b03848116600483015260001960248301529091169063095ea7b3906044016020604051808303816000875af1158015620002b2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002d8919062000436565b505050506200045a565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60405163bdac7ca360e01b81523060048201526001600160a01b0382166024820152733ef3d8ba38ebe18db133cec108f4d14ce00dd9ae9063bdac7ca390604401600060405180830381600087803b1580156200038e57600080fd5b505af1158015620003a3573d6000803e3d6000fd5b5050505050565b80516001600160a01b0381168114620003c257600080fd5b919050565b600080600060608486031215620003dd57600080fd5b620003e884620003aa565b9250620003f860208501620003aa565b91506200040860408501620003aa565b90509250925092565b6000602082840312156200042457600080fd5b6200042f82620003aa565b9392505050565b6000602082840312156200044957600080fd5b815180151581146200042f57600080fd5b60805160a05160c05160e0516101005161012051613aac62000591600039600081816104b9015281816111d4015281816116470152612ce40152600081816103d1015281816109a101528181611daf01528181611ec601528181611f7601528181612126015281816122b00152612cb501526000818161059e0152818161096101528181611d2101528181611e8c01528181611f36015281816120a1015281816122760152612c8601526000818161031c0152818161111c01528181611c860152818161296c01528181612dce0152612edb01526000818161061801528181610f5d01528181610fa301528181610fe90152818161140a015281816114500152818161149601528181612c1f015281816131ec015261322001526000818161045901528181610ba30152610c660152613aac6000f3fe608060405234801561001057600080fd5b50600436106102745760003560e01c8063715018a611610151578063d7c24d97116100c3578063f034bd5e11610087578063f034bd5e1461064d578063f072476e14610661578063f2fde38b14610688578063f6794fdb1461069b578063f69e2046146106ae578063f9759518146106b657600080fd5b8063d7c24d9714610591578063d99939a214610599578063dbcf91a6146105c0578063e121c102146105c9578063e41de3131461061357600080fd5b80639613b8ce116101155780639613b8ce146105085780639c6acba014610528578063b30d0aa214610535578063d0d41fe114610552578063d1c3972714610565578063d54839bf1461057a57600080fd5b8063715018a6146104ac5780637535d246146104b4578063753a0184146104db5780638da5cb5b146104ee5780638db23165146104ff57600080fd5b806338d41082116101ea5780634ff67e32116101ae5780634ff67e32146103f35780635639e8cf1461041d5780635e360784146104305780636aa37b661461044b5780636afdd85014610454578063709b12991461047b57600080fd5b806338d410821461038a5780633a98ef391461039d5780633c164924146103a6578063486190d0146103b95780634a3268e4146103cc57600080fd5b80631754c6911161023c5780631754c691146103045780631bea83fe14610317578063258836fe1461033e5780632ce9057c146103515780632e1a7d4d1461036457806334bfef041461037757600080fd5b806305f783621461027957806308f092ed1461028e57806309cdd9d0146102be5780631168d42a146102d457806316a228a5146102dc575b600080fd5b61028c610287366004613253565b6106c8565b005b6102a161029c366004613253565b61071a565b6040516001600160a01b0390911681526020015b60405180910390f35b6102c6610744565b6040519081526020016102b5565b600c546102c6565b6006546102f29065010000000000900460ff1681565b60405160ff90911681526020016102b5565b61028c610312366004613281565b610776565b6102a17f000000000000000000000000000000000000000000000000000000000000000081565b61028c61034c36600461329e565b61078a565b61028c61035f3660046132d7565b61083e565b61028c610372366004613253565b610858565b61028c61038536600461337e565b610a1b565b61028c610398366004613253565b610d79565b6102c660095481565b61028c6103b436600461329e565b610ed2565b61028c6103c7366004613461565b610f53565b6102a17f000000000000000000000000000000000000000000000000000000000000000081565b6103fb6110a4565b60408051948552602085019390935291830152151560608201526080016102b5565b6002546102a1906001600160a01b031681565b6102a1733ef3d8ba38ebe18db133cec108f4d14ce00dd9ae81565b6102c660075481565b6102a17f000000000000000000000000000000000000000000000000000000000000000081565b6104836110e7565b604080516001600160801b039094168452600292830b6020850152910b908201526060016102b5565b61028c6111a6565b6102a17f000000000000000000000000000000000000000000000000000000000000000081565b6006546102f29062010000900460ff1681565b6000546001600160a01b03166102a1565b6102c660055481565b6102c6610516366004613281565b600a6020526000908152604090205481565b6006546102f29060ff1681565b61053d6111ba565b604080519283526020830191909152016102b5565b61028c610560366004613281565b611291565b6006546102f290640100000000900460ff1681565b6006546102f2906601000000000000900460ff1681565b61028c6112e1565b6102a17f000000000000000000000000000000000000000000000000000000000000000081565b6102c660045481565b6105dc6105d7366004613253565b611375565b604080516001600160a01b0390971687526020870195909552938501929092526060840152608083015260a082015260c0016102b5565b61063a7f000000000000000000000000000000000000000000000000000000000000000081565b60405161ffff90911681526020016102b5565b6006546102f2906301000000900460ff1681565b61053d61066f366004613281565b6008602052600090815260409020805460019091015482565b61028c610696366004613281565b6113c5565b61028c6106a9366004613461565b611400565b61053d61152e565b6006546102f290610100900460ff1681565b6106d0611615565b600081116107155760405162461bcd60e51b815260206004820152600d60248201526c5a65726f426174636853697a6560981b60448201526064015b60405180910390fd5b600555565b600b818154811061072a57600080fd5b6000918252602090912001546001600160a01b0316905081565b60006007546000036107565750600090565b6000806107616111ba565b9150915061076f8282611642565b9250505090565b61077e611615565b61078781611749565b50565b610792611615565b6001600160a01b0382166107b85760405162461bcd60e51b815260040161070c906134ac565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa1580156107ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082391906134d1565b90506108396001600160a01b03841683836117bf565b505050565b610846611615565b61085284848484611811565b50505050565b6108606119f7565b6000811161089d5760405162461bcd60e51b815260206004820152600a6024820152695a65726f53686172657360b01b604482015260640161070c565b6007546000036108bf5760405162461bcd60e51b815260040161070c906134ea565b336000908152600a6020526040902054818110156109115760405162461bcd60e51b815260206004820152600f60248201526e4e6f74456e6f75676853686172657360881b604482015260640161070c565b610919611a21565b610921611c13565b505061092d6000611cfd565b505060008060008061093f3387611fe6565b9350935093509350600082111561098a5760025461098a906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081169116846117bf565b80156109ca576002546109ca906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081169116836117bf565b604080518581526020810185905290810187905233907f650fdf669e93aa6c8ff3defe2da9c12b64f1548e5e1e54e803f4c1beb6466c8e9060600160405180910390a2505050505061078760018055565b60008a118015610a2b5750600089115b610a645760405162461bcd60e51b815260206004820152600a60248201526916995c9bd05b5bdd5b9d60b21b604482015260640161070c565b6000610a6e610744565b60095490915015610ab75760008111610ab75760405162461bcd60e51b815260206004820152600b60248201526a4e6f4c697175696469747960a81b604482015260640161070c565b336000908152600a60205260408120549003610b1057600b80546001810182556000919091527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db90180546001600160a01b031916331790555b6000610b1c8c8c611642565b90506000600954600014610b48578260095483610b399190613528565b610b439190613555565b610b4a565b815b336000908152600a6020526040812080549293508392909190610b6e908490613569565b925050819055508060096000828254610b879190613569565b909155505060405163187945bd60e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906330f28b7a90610be0908e908e9033908f908f9060040161359d565b600060405180830381600087803b158015610bfa57600080fd5b505af1158015610c0e573d6000803e3d6000fd5b505050508c60086000336001600160a01b03166001600160a01b031681526020019081526020016000206000016000828254610c4a9190613569565b909155505060405163187945bd60e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906330f28b7a90610ca3908a908a9033908b908b9060040161359d565b600060405180830381600087803b158015610cbd57600080fd5b505af1158015610cd1573d6000803e3d6000fd5b505050508b60086000336001600160a01b03166001600160a01b031681526020019081526020016000206001016000828254610d0d9190613569565b90915550610d1d90506000611cfd565b5050610d27611a21565b604080518e8152602081018e905290810182905233907f632498135bdb1c11bee743dc04f2ffc8ae33cd6fb3d25fe0941ae402b068fda89060600160405180910390a250505050505050505050505050565b610d81611615565b600c548110610dc15760405162461bcd60e51b815260206004820152600c60248201526b092dcecc2d8d2c892dcc8caf60a31b604482015260640161070c565b600c54610dd090600190613611565b811015610e7957600c8054610de790600190613611565b81548110610df757610df7613624565b9060005260206000209060060201600c8281548110610e1857610e18613624565b60009182526020909120825460069092020180546001600160a01b0319166001600160a01b03909216919091178155600180830154908201556002808301549082015560038083015490820155600480830154908201556005918201549101555b600c805480610e8a57610e8a61363a565b60008281526020812060066000199093019283020180546001600160a01b03191681556001810182905560028101829055600381018290556004810182905560050155905550565b610eda611615565b604051630d0a119360e31b81526001600160a01b03808416600483015282166024820152733ef3d8ba38ebe18db133cec108f4d14ce00dd9ae906368508c9890604401600060405180830381600087803b158015610f3757600080fd5b505af1158015610f4b573d6000803e3d6000fd5b505050505050565b610f5b611615565b7f000000000000000000000000000000000000000000000000000000000000000061ffff168360ff1610610fa15760405162461bcd60e51b815260040161070c90613650565b7f000000000000000000000000000000000000000000000000000000000000000061ffff168260ff1610610fe75760405162461bcd60e51b815260040161070c90613650565b7f000000000000000000000000000000000000000000000000000000000000000061ffff168160ff161061102d5760405162461bcd60e51b815260040161070c90613650565b6006805460ff85811661ffff1990921682176101008683169081029190911762ff0000191662010000928616928302179093556040805192835260208301939093528183015290517f486f6a4d2b3c4ab974ce477a0e23b73b088fbd47b1815fb56936dc907c4616119181900360600190a1505050565b6000806000806110b2611615565b6110ba611c13565b50506110c66001611cfd565b60035491955093506110d990600f613569565b915081421115905090919293565b60008060006007546000036111025750600092839250829150565b60075460405163133f757160e31b815260048101919091527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906399fbab889060240161018060405180830381865afa15801561116c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119091906136c5565b50929d949c50929a509298505050505050505050565b6111ae611615565b6111b860006123b7565b565b60008060008060006111ca6110e7565b92509250925060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015611230573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061125491906137b8565b5050505050509050600061126784612407565b9050600061127484612407565b905061128283838389612827565b90999098509650505050505050565b611299611615565b6001600160a01b0381166112bf5760405162461bcd60e51b815260040161070c906134ac565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6112e9611615565b60075460000361130b5760405162461bcd60e51b815260040161070c906134ea565b60006113156110e7565b505090506000816001600160801b0316116113645760405162461bcd60e51b815260206004820152600f60248201526e4e6f7468696e67546f52656d6f766560881b604482015260640161070c565b61136d816128c3565b610839611c13565b600c818154811061138557600080fd5b60009182526020909120600690910201805460018201546002830154600384015460048501546005909501546001600160a01b0390941695509193909286565b6113cd611615565b6001600160a01b0381166113f757604051631e4fbdf760e01b81526000600482015260240161070c565b610787816123b7565b611408611615565b7f000000000000000000000000000000000000000000000000000000000000000061ffff168360ff161061144e5760405162461bcd60e51b815260040161070c9061384c565b7f000000000000000000000000000000000000000000000000000000000000000061ffff168260ff16106114945760405162461bcd60e51b815260040161070c9061384c565b7f000000000000000000000000000000000000000000000000000000000000000061ffff168160ff16106114da5760405162461bcd60e51b815260040161070c9061384c565b6006805465ffff00000000191664010000000060ff9586160265ff000000000019161765010000000000938516939093029290921766ff000000000000191666010000000000009190931602919091179055565b6000806115396119f7565b60075460000361155b5760405162461bcd60e51b815260040161070c906134ea565b60035461156990600f613569565b42116115a75760405162461bcd60e51b815260206004820152600d60248201526c5761697431355365636f6e647360981b604482015260640161070c565b6115af611a21565b6115b7611c13565b50506115c36001611cfd565b42600355604080518381526020810183905292945090925033917f1ed3deed70182f15bd6eede4b68462dee343e8edaff28e8c5c12a0c8f2e80704910160405180910390a261161160018055565b9091565b6000546001600160a01b031633146111b85760405163118cdaa760e01b815233600482015260240161070c565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa1580156116a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c791906137b8565b5050505050509050806001600160a01b03166000036116e95783915050611743565b60006116fe6001600160a01b03831680613528565b90506000611719600160c01b670de0b6b3a7640000846129ea565b905060006117308683670de0b6b3a76400006129ea565b905061173c8188613569565b9450505050505b92915050565b60405163bdac7ca360e01b81523060048201526001600160a01b0382166024820152733ef3d8ba38ebe18db133cec108f4d14ce00dd9ae9063bdac7ca390604401600060405180830381600087803b1580156117a457600080fd5b505af11580156117b8573d6000803e3d6000fd5b5050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610839908490612a8d565b6001600160a01b0384166118375760405162461bcd60e51b815260040161070c906134ac565b8282116118745760405162461bcd60e51b815260206004820152600b60248201526a496e76616c696454696d6560a81b604482015260640161070c565b600081116118b15760405162461bcd60e51b815260206004820152600a60248201526916995c9bd05b5bdd5b9d60b21b604482015260640161070c565b6040805160c0810182526001600160a01b039586168152602081019485529081019283526060810191825260006080820181815260a08301828152600c8054600181018255935292517fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c7600690930292830180546001600160a01b031916919098161790965593517fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c885015591517fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c9840155517fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8ca83015591517fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8cb82015590517fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8cc90910155565b600260015403611a1a57604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b4260005b600c54811015611c0f576000600c8281548110611a4457611a44613624565b90600052602060002090600602019050806005015483111580611a6a5750806001015483105b80611a7c575080600201548160050154115b15611a875750611c07565b60008160010154826005015410611aa2578160050154611aa8565b81600101545b9050600082600201548511611abd5784611ac3565b82600201545b90506000611ad18383613611565b9050600084600101548560020154611ae99190613611565b9050600081838760030154611afe9190613528565b611b089190613555565b905060008660040154821015611b1f576000611b2e565b6004870154611b2e9083613611565b9050801580611b3d5750600954155b15611b4e5750505050505050611c07565b86546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611b96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bba91906134d1565b905080821115611bc8578091505b8754611bde9083906001600160a01b0316612afe565b81886004016000828254611bf29190613569565b90915550505050600590950187905550505050505b600101611a25565b5050565b6000806007546000146116115760408051608081018252600754815230602082019081526001600160801b0382840181815260608401828152945163fc6f786560e01b81529351600485015291516001600160a01b039081166024850152915181166044840152925190921660648201527f00000000000000000000000000000000000000000000000000000000000000009091169063fc6f78659060840160408051808303816000875af1158015611cd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cf49190613870565b90925090509091565b6040516370a0823160e01b8152306004820152600090819081906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa158015611d68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8c91906134d1565b6040516370a0823160e01b81523060048201529091506000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa158015611df6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e1a91906134d1565b9050811580611e27575080155b15611e39575060009485945092505050565b6000808615611f9f57600654611e5c90859065010000000000900460ff16612c13565b9550611e7783600660059054906101000a900460ff16612c13565b94508515611eb357611eb36001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633886117bf565b8415611eed57611eed6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633876117bf565b611f048460068054906101000a900460ff16612c13565b9150611f1d8360068054906101000a900460ff16612c13565b90508115611f5f57600254611f5f906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081169116846117bf565b8015611f9f57600254611f9f906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081169116836117bf565b600082611fac8887613611565b611fb69190613611565b9050600082611fc58887613611565b611fcf9190613611565b9050611fdb8282612c47565b505050505050915091565b6000806000806000611ff66110e7565b505090506000612012826001600160801b0316886009546129ea565b90506001600160801b038111156120565760405162461bcd60e51b81526020600482015260086024820152674f766572666c6f7760c01b604482015260640161070c565b61205f816128c3565b60008061206a611c13565b6001600160a01b038c81166000908152600860205260409081902090516370a0823160e01b815230600482015293955091935090917f0000000000000000000000000000000000000000000000000000000000000000909116906370a0823190602401602060405180830381865afa1580156120ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210e91906134d1565b6040516370a0823160e01b81523060048201529097507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015612175573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219991906134d1565b95506009548a146121ba576121b581600001548b6009546129ea565b6121bc565b865b98506009548a146121dd576121d881600101548b6009546129ea565b6121df565b855b9750888311156121ed578298505b878211156121f9578197505b86891115612205578698505b85881115612211578597505b60065461222a908a90640100000000900460ff16612c13565b965061224588600660049054906101000a900460ff16612c13565b95506000612253888b613611565b90506000612261888b613611565b9050811561229d5761229d6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168e846117bf565b80156122d7576122d76001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168e836117bf565b8b600960008282546122e99190613611565b90915550506001600160a01b038d166000908152600a6020526040812080548e9290612316908490613611565b90915550506001600160a01b038d166000908152600a60205260408120549003612343576123438d612fe8565b82548b10801561235557506009548c14155b61236057600061236d565b825461236d908c90613611565b835560018301548a10801561238457506009548c14155b61238f57600061239f565b89836001015461239f9190613611565b83600101819055505050505050505092959194509250565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008060008360020b1261241e578260020b61242b565b8260020b61242b90613894565b905061243a620d89e7196138b0565b60020b8111156124705760405162461bcd60e51b81526020600482015260016024820152601560fa1b604482015260640161070c565b60008160011660000361248757600160801b612499565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156124d85760806124d3826ffff97272373d413259a46990580e213a613528565b901c90505b60048216156125025760806124fd826ffff2e50f5f656932ef12357cf3c7fdcc613528565b901c90505b600882161561252c576080612527826fffe5caca7e10e4e61c3624eaa0941cd0613528565b901c90505b6010821615612556576080612551826fffcb9843d60f6159c9db58835c926644613528565b901c90505b602082161561258057608061257b826fff973b41fa98c081472e6896dfb254c0613528565b901c90505b60408216156125aa5760806125a5826fff2ea16466c96a3843ec78b326b52861613528565b901c90505b60808216156125d45760806125cf826ffe5dee046a99a2a811c461f1969c3053613528565b901c90505b6101008216156125ff5760806125fa826ffcbe86c7900a88aedcffc83b479aa3a4613528565b901c90505b61020082161561262a576080612625826ff987a7253ac413176f2b074cf7815e54613528565b901c90505b610400821615612655576080612650826ff3392b0822b70005940c7a398e4b70f3613528565b901c90505b61080082161561268057608061267b826fe7159475a2c29b7443b29c7fa6e889d9613528565b901c90505b6110008216156126ab5760806126a6826fd097f3bdfd2022b8845ad8f792aa5825613528565b901c90505b6120008216156126d65760806126d1826fa9f746462d870fdf8a65dc1f90e061e5613528565b901c90505b6140008216156127015760806126fc826f70d869a156d2a1b890bb3df62baf32f7613528565b901c90505b61800082161561272c576080612727826f31be135f97d08fd981231505542fcfa6613528565b901c90505b62010000821615612758576080612753826f09aa508b5b7a84e1c677de54f3e99bc9613528565b901c90505b6202000082161561278357608061277e826e5d6af8dedb81196699c329225ee604613528565b901c90505b620400008216156127ad5760806127a8826d2216e584f5fa1ea926041bedfe98613528565b901c90505b620800008216156127d55760806127d0826b048a170391f7dc42444e8fa2613528565b901c90505b60008460020b13156127f0576127ed81600019613555565b90505b6127ff640100000000826138d2565b1561280b57600161280e565b60005b61281f9060ff16602083901c613569565b949350505050565b600080836001600160a01b0316856001600160a01b03161115612848579293925b846001600160a01b0316866001600160a01b0316116128735761286c8585856130e4565b91506128ba565b836001600160a01b0316866001600160a01b031610156128ac576128988685856130e4565b91506128a5858785613157565b90506128ba565b6128b7858585613157565b90505b94509492505050565b6000806128ce6111ba565b915091506000806128df84846131a1565b9150915060006040518060a001604052806007548152602001876001600160801b0316815260200184815260200183815260200142600f6129209190613569565b905260408051630624e65f60e11b81528251600482015260208301516001600160801b0316602482015290820151604482015260608201516064820152608082015160848201529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690630c49ccbe9060a40160408051808303816000875af11580156129bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e09190613870565b5050505050505050565b60008383028160001985870982811083820303915050808411612a0c57600080fd5b80600003612a1f57508290049050612a86565b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b600080602060008451602086016000885af180612ab0576040513d6000823e3d81fd5b50506000513d91508115612ac8578060011415612ad5565b6001600160a01b0384163b155b1561085257604051635274afe760e01b81526001600160a01b038516600482015260240161070c565b6000600554600454612b109190613569565b600b54909150811115612b225750600b545b6004545b81811015612bb3576000600b8281548110612b4357612b43613624565b60009182526020808320909101546001600160a01b0316808352600a9091526040909120549091508015612ba957600954600090612b818389613528565b612b8b9190613555565b90508015612ba757612ba76001600160a01b03871684836117bf565b505b5050600101612b26565b506004547fb3a10bd17078a9f771e5b624f3b69cb01fa19440fd81facb7ebaf81bdbaf54f090612be38184613611565b6040805192835260208301919091520160405180910390a16004819055600b548110610839576000600455505050565b6000612a86838360ff167f000000000000000000000000000000000000000000000000000000000000000061ffff166129ea565b811580612c52575080155b15612c5b575050565b600080612c6884846131a1565b91509150600754600003612e545760006040518061016001604052807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681526020017f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681526020017f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d6491906138e6565b62ffffff168152620d89b3196020820152620d89b46040820152606081018790526080810186905260a0810185905260c081018490523060e082015261010001612daf42600f613569565b9052604051634418b22b60e11b81529091506000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638831645690612e03908590600401613901565b6080604051808303816000875af1158015612e22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e4691906139c5565b505050600755506108529050565b60006040518060c00160405280600754815260200186815260200185815260200184815260200183815260200142600f612e8e9190613569565b90526040805163219f5d1760e01b81528251600482015260208301516024820152908201516044820152606082015160648201526080820151608482015260a082015160a48201529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063219f5d179060c4016060604051808303816000875af1925050508015612f48575060408051601f3d908101601f19168201909252612f4591810190613a01565b60015b612fac5760065460ff610100820481166301000000909204161015612fa7576006805460ff62010000820481169291600391612f8e918591630100000090910416613a36565b92506101000a81548160ff021916908360ff1602179055505b6117b8565b505060065460ff808216630100000090920416111590506117b85760068054630100000060ff82160263ff000000199091161790555050505050565b600b5460005b8181101561083957826001600160a01b0316600b828154811061301357613013613624565b6000918252602090912001546001600160a01b0316036130dc57600b61303a600184613611565b8154811061304a5761304a613624565b600091825260209091200154600b80546001600160a01b03909216918390811061307657613076613624565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600b8054806130b5576130b561363a565b600082815260209020810160001990810180546001600160a01b0319169055019055505050565b600101612fee565b6000826001600160a01b0316846001600160a01b03161115613104579192915b6001600160a01b03841661314d6fffffffffffffffffffffffffffffffff60601b606085901b166131358787613a4f565b6001600160a01b0316866001600160a01b03166129ea565b61281f9190613555565b6000826001600160a01b0316846001600160a01b03161115613177579192915b61281f6001600160801b03831661318e8686613a4f565b6001600160a01b0316600160601b6129ea565b6006546000908190819060ff61010082048116630100000090920416116131d4576006546301000000900460ff166131e0565b600654610100900460ff165b9050613214858260ff167f000000000000000000000000000000000000000000000000000000000000000061ffff166129ea565b9250613248848260ff167f000000000000000000000000000000000000000000000000000000000000000061ffff166129ea565b9150505b9250929050565b60006020828403121561326557600080fd5b5035919050565b6001600160a01b038116811461078757600080fd5b60006020828403121561329357600080fd5b8135612a868161326c565b600080604083850312156132b157600080fd5b82356132bc8161326c565b915060208301356132cc8161326c565b809150509250929050565b600080600080608085870312156132ed57600080fd5b84356132f88161326c565b966020860135965060408601359560600135945092505050565b60006080828403121561332457600080fd5b50919050565b60006040828403121561332457600080fd5b60008083601f84011261334e57600080fd5b50813567ffffffffffffffff81111561336657600080fd5b60208301915083602082850101111561324c57600080fd5b6000806000806000806000806000806102008b8d03121561339e57600080fd5b8a35995060208b013598506133b68c60408d01613312565b97506133c58c60c08d0161332a565b96506101008b013567ffffffffffffffff808211156133e357600080fd5b6133ef8e838f0161333c565b90985096508691506134058e6101208f01613312565b95506134158e6101a08f0161332a565b94506101e08d013591508082111561342c57600080fd5b506134398d828e0161333c565b915080935050809150509295989b9194979a5092959850565b60ff8116811461078757600080fd5b60008060006060848603121561347657600080fd5b833561348181613452565b9250602084013561349181613452565b915060408401356134a181613452565b809150509250925092565b6020808252600b908201526a5a65726f4164647265737360a81b604082015260600190565b6000602082840312156134e357600080fd5b5051919050565b6020808252600e908201526d139bdd125b9a5d1a585b1a5e995960921b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761174357611743613512565b634e487b7160e01b600052601260045260246000fd5b6000826135645761356461353f565b500490565b8082018082111561174357611743613512565b80356135878161326c565b6001600160a01b03168252602090810135910152565b60006101006135ac838961357c565b60408801356040840152606088013560608401526135cd608084018861357c565b6001600160a01b03861660c084015260e0830181905282018390526101208385828501376000838501820152601f909301601f191690910190910195945050505050565b8181038181111561174357611743613512565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b6020808252600f908201526e496e76616c6964536c69707061676560881b604082015260600190565b80516136848161326c565b919050565b805162ffffff8116811461368457600080fd5b8051600281900b811461368457600080fd5b80516001600160801b038116811461368457600080fd5b6000806000806000806000806000806000806101808d8f0312156136e857600080fd5b8c516bffffffffffffffffffffffff8116811461370457600080fd5b9b5061371260208e01613679565b9a5061372060408e01613679565b995061372e60608e01613679565b985061373c60808e01613689565b975061374a60a08e0161369c565b965061375860c08e0161369c565b955061376660e08e016136ae565b94506101008d015193506101208d015192506137856101408e016136ae565b91506137946101608e016136ae565b90509295989b509295989b509295989b565b805161ffff8116811461368457600080fd5b600080600080600080600060e0888a0312156137d357600080fd5b87516137de8161326c565b96506137ec6020890161369c565b95506137fa604089016137a6565b9450613808606089016137a6565b9350613816608089016137a6565b925060a088015161382681613452565b60c0890151909250801515811461383c57600080fd5b8091505092959891949750929550565b6020808252600a9082015269496e76616c696446656560b01b604082015260600190565b6000806040838503121561388357600080fd5b505080516020909101519092909150565b6000600160ff1b82016138a9576138a9613512565b5060000390565b60008160020b627fffff1981036138c9576138c9613512565b60000392915050565b6000826138e1576138e161353f565b500690565b6000602082840312156138f857600080fd5b612a8682613689565b81516001600160a01b031681526101608101602083015161392d60208401826001600160a01b03169052565b506040830151613944604084018262ffffff169052565b506060830151613959606084018260020b9052565b50608083015161396e608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516139b4828501826001600160a01b03169052565b505061014092830151919092015290565b600080600080608085870312156139db57600080fd5b845193506139eb602086016136ae565b6040860151606090960151949790965092505050565b600080600060608486031215613a1657600080fd5b613a1f846136ae565b925060208401519150604084015190509250925092565b60ff818116838216019081111561174357611743613512565b6001600160a01b03828116828216039080821115613a6f57613a6f613512565b509291505056fea2646970667358221220aeb59927bd5f6261036671b74e4322fe921c52789c4dbe11f6b818e547b894f664736f6c63430008180033000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3000000000000000000000000ec12a9f9a09f50550686363766cc153d03c27b5e000000000000000000000000494d68e3cab640fa50f4c1b3e2499698d1a173a0

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102745760003560e01c8063715018a611610151578063d7c24d97116100c3578063f034bd5e11610087578063f034bd5e1461064d578063f072476e14610661578063f2fde38b14610688578063f6794fdb1461069b578063f69e2046146106ae578063f9759518146106b657600080fd5b8063d7c24d9714610591578063d99939a214610599578063dbcf91a6146105c0578063e121c102146105c9578063e41de3131461061357600080fd5b80639613b8ce116101155780639613b8ce146105085780639c6acba014610528578063b30d0aa214610535578063d0d41fe114610552578063d1c3972714610565578063d54839bf1461057a57600080fd5b8063715018a6146104ac5780637535d246146104b4578063753a0184146104db5780638da5cb5b146104ee5780638db23165146104ff57600080fd5b806338d41082116101ea5780634ff67e32116101ae5780634ff67e32146103f35780635639e8cf1461041d5780635e360784146104305780636aa37b661461044b5780636afdd85014610454578063709b12991461047b57600080fd5b806338d410821461038a5780633a98ef391461039d5780633c164924146103a6578063486190d0146103b95780634a3268e4146103cc57600080fd5b80631754c6911161023c5780631754c691146103045780631bea83fe14610317578063258836fe1461033e5780632ce9057c146103515780632e1a7d4d1461036457806334bfef041461037757600080fd5b806305f783621461027957806308f092ed1461028e57806309cdd9d0146102be5780631168d42a146102d457806316a228a5146102dc575b600080fd5b61028c610287366004613253565b6106c8565b005b6102a161029c366004613253565b61071a565b6040516001600160a01b0390911681526020015b60405180910390f35b6102c6610744565b6040519081526020016102b5565b600c546102c6565b6006546102f29065010000000000900460ff1681565b60405160ff90911681526020016102b5565b61028c610312366004613281565b610776565b6102a17f000000000000000000000000ec12a9f9a09f50550686363766cc153d03c27b5e81565b61028c61034c36600461329e565b61078a565b61028c61035f3660046132d7565b61083e565b61028c610372366004613253565b610858565b61028c61038536600461337e565b610a1b565b61028c610398366004613253565b610d79565b6102c660095481565b61028c6103b436600461329e565b610ed2565b61028c6103c7366004613461565b610f53565b6102a17f000000000000000000000000420000000000000000000000000000000000000681565b6103fb6110a4565b60408051948552602085019390935291830152151560608201526080016102b5565b6002546102a1906001600160a01b031681565b6102a1733ef3d8ba38ebe18db133cec108f4d14ce00dd9ae81565b6102c660075481565b6102a17f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba381565b6104836110e7565b604080516001600160801b039094168452600292830b6020850152910b908201526060016102b5565b61028c6111a6565b6102a17f000000000000000000000000494d68e3cab640fa50f4c1b3e2499698d1a173a081565b6006546102f29062010000900460ff1681565b6000546001600160a01b03166102a1565b6102c660055481565b6102c6610516366004613281565b600a6020526000908152604090205481565b6006546102f29060ff1681565b61053d6111ba565b604080519283526020830191909152016102b5565b61028c610560366004613281565b611291565b6006546102f290640100000000900460ff1681565b6006546102f2906601000000000000900460ff1681565b61028c6112e1565b6102a17f0000000000000000000000002cfc85d8e48f8eab294be644d9e25c303086300381565b6102c660045481565b6105dc6105d7366004613253565b611375565b604080516001600160a01b0390971687526020870195909552938501929092526060840152608083015260a082015260c0016102b5565b61063a7f00000000000000000000000000000000000000000000000000000000000003e881565b60405161ffff90911681526020016102b5565b6006546102f2906301000000900460ff1681565b61053d61066f366004613281565b6008602052600090815260409020805460019091015482565b61028c610696366004613281565b6113c5565b61028c6106a9366004613461565b611400565b61053d61152e565b6006546102f290610100900460ff1681565b6106d0611615565b600081116107155760405162461bcd60e51b815260206004820152600d60248201526c5a65726f426174636853697a6560981b60448201526064015b60405180910390fd5b600555565b600b818154811061072a57600080fd5b6000918252602090912001546001600160a01b0316905081565b60006007546000036107565750600090565b6000806107616111ba565b9150915061076f8282611642565b9250505090565b61077e611615565b61078781611749565b50565b610792611615565b6001600160a01b0382166107b85760405162461bcd60e51b815260040161070c906134ac565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa1580156107ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082391906134d1565b90506108396001600160a01b03841683836117bf565b505050565b610846611615565b61085284848484611811565b50505050565b6108606119f7565b6000811161089d5760405162461bcd60e51b815260206004820152600a6024820152695a65726f53686172657360b01b604482015260640161070c565b6007546000036108bf5760405162461bcd60e51b815260040161070c906134ea565b336000908152600a6020526040902054818110156109115760405162461bcd60e51b815260206004820152600f60248201526e4e6f74456e6f75676853686172657360881b604482015260640161070c565b610919611a21565b610921611c13565b505061092d6000611cfd565b505060008060008061093f3387611fe6565b9350935093509350600082111561098a5760025461098a906001600160a01b037f0000000000000000000000002cfc85d8e48f8eab294be644d9e25c303086300381169116846117bf565b80156109ca576002546109ca906001600160a01b037f000000000000000000000000420000000000000000000000000000000000000681169116836117bf565b604080518581526020810185905290810187905233907f650fdf669e93aa6c8ff3defe2da9c12b64f1548e5e1e54e803f4c1beb6466c8e9060600160405180910390a2505050505061078760018055565b60008a118015610a2b5750600089115b610a645760405162461bcd60e51b815260206004820152600a60248201526916995c9bd05b5bdd5b9d60b21b604482015260640161070c565b6000610a6e610744565b60095490915015610ab75760008111610ab75760405162461bcd60e51b815260206004820152600b60248201526a4e6f4c697175696469747960a81b604482015260640161070c565b336000908152600a60205260408120549003610b1057600b80546001810182556000919091527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db90180546001600160a01b031916331790555b6000610b1c8c8c611642565b90506000600954600014610b48578260095483610b399190613528565b610b439190613555565b610b4a565b815b336000908152600a6020526040812080549293508392909190610b6e908490613569565b925050819055508060096000828254610b879190613569565b909155505060405163187945bd60e11b81526001600160a01b037f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba316906330f28b7a90610be0908e908e9033908f908f9060040161359d565b600060405180830381600087803b158015610bfa57600080fd5b505af1158015610c0e573d6000803e3d6000fd5b505050508c60086000336001600160a01b03166001600160a01b031681526020019081526020016000206000016000828254610c4a9190613569565b909155505060405163187945bd60e11b81526001600160a01b037f000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba316906330f28b7a90610ca3908a908a9033908b908b9060040161359d565b600060405180830381600087803b158015610cbd57600080fd5b505af1158015610cd1573d6000803e3d6000fd5b505050508b60086000336001600160a01b03166001600160a01b031681526020019081526020016000206001016000828254610d0d9190613569565b90915550610d1d90506000611cfd565b5050610d27611a21565b604080518e8152602081018e905290810182905233907f632498135bdb1c11bee743dc04f2ffc8ae33cd6fb3d25fe0941ae402b068fda89060600160405180910390a250505050505050505050505050565b610d81611615565b600c548110610dc15760405162461bcd60e51b815260206004820152600c60248201526b092dcecc2d8d2c892dcc8caf60a31b604482015260640161070c565b600c54610dd090600190613611565b811015610e7957600c8054610de790600190613611565b81548110610df757610df7613624565b9060005260206000209060060201600c8281548110610e1857610e18613624565b60009182526020909120825460069092020180546001600160a01b0319166001600160a01b03909216919091178155600180830154908201556002808301549082015560038083015490820155600480830154908201556005918201549101555b600c805480610e8a57610e8a61363a565b60008281526020812060066000199093019283020180546001600160a01b03191681556001810182905560028101829055600381018290556004810182905560050155905550565b610eda611615565b604051630d0a119360e31b81526001600160a01b03808416600483015282166024820152733ef3d8ba38ebe18db133cec108f4d14ce00dd9ae906368508c9890604401600060405180830381600087803b158015610f3757600080fd5b505af1158015610f4b573d6000803e3d6000fd5b505050505050565b610f5b611615565b7f00000000000000000000000000000000000000000000000000000000000003e861ffff168360ff1610610fa15760405162461bcd60e51b815260040161070c90613650565b7f00000000000000000000000000000000000000000000000000000000000003e861ffff168260ff1610610fe75760405162461bcd60e51b815260040161070c90613650565b7f00000000000000000000000000000000000000000000000000000000000003e861ffff168160ff161061102d5760405162461bcd60e51b815260040161070c90613650565b6006805460ff85811661ffff1990921682176101008683169081029190911762ff0000191662010000928616928302179093556040805192835260208301939093528183015290517f486f6a4d2b3c4ab974ce477a0e23b73b088fbd47b1815fb56936dc907c4616119181900360600190a1505050565b6000806000806110b2611615565b6110ba611c13565b50506110c66001611cfd565b60035491955093506110d990600f613569565b915081421115905090919293565b60008060006007546000036111025750600092839250829150565b60075460405163133f757160e31b815260048101919091527f000000000000000000000000ec12a9f9a09f50550686363766cc153d03c27b5e6001600160a01b0316906399fbab889060240161018060405180830381865afa15801561116c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119091906136c5565b50929d949c50929a509298505050505050505050565b6111ae611615565b6111b860006123b7565b565b60008060008060006111ca6110e7565b92509250925060007f000000000000000000000000494d68e3cab640fa50f4c1b3e2499698d1a173a06001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015611230573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061125491906137b8565b5050505050509050600061126784612407565b9050600061127484612407565b905061128283838389612827565b90999098509650505050505050565b611299611615565b6001600160a01b0381166112bf5760405162461bcd60e51b815260040161070c906134ac565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6112e9611615565b60075460000361130b5760405162461bcd60e51b815260040161070c906134ea565b60006113156110e7565b505090506000816001600160801b0316116113645760405162461bcd60e51b815260206004820152600f60248201526e4e6f7468696e67546f52656d6f766560881b604482015260640161070c565b61136d816128c3565b610839611c13565b600c818154811061138557600080fd5b60009182526020909120600690910201805460018201546002830154600384015460048501546005909501546001600160a01b0390941695509193909286565b6113cd611615565b6001600160a01b0381166113f757604051631e4fbdf760e01b81526000600482015260240161070c565b610787816123b7565b611408611615565b7f00000000000000000000000000000000000000000000000000000000000003e861ffff168360ff161061144e5760405162461bcd60e51b815260040161070c9061384c565b7f00000000000000000000000000000000000000000000000000000000000003e861ffff168260ff16106114945760405162461bcd60e51b815260040161070c9061384c565b7f00000000000000000000000000000000000000000000000000000000000003e861ffff168160ff16106114da5760405162461bcd60e51b815260040161070c9061384c565b6006805465ffff00000000191664010000000060ff9586160265ff000000000019161765010000000000938516939093029290921766ff000000000000191666010000000000009190931602919091179055565b6000806115396119f7565b60075460000361155b5760405162461bcd60e51b815260040161070c906134ea565b60035461156990600f613569565b42116115a75760405162461bcd60e51b815260206004820152600d60248201526c5761697431355365636f6e647360981b604482015260640161070c565b6115af611a21565b6115b7611c13565b50506115c36001611cfd565b42600355604080518381526020810183905292945090925033917f1ed3deed70182f15bd6eede4b68462dee343e8edaff28e8c5c12a0c8f2e80704910160405180910390a261161160018055565b9091565b6000546001600160a01b031633146111b85760405163118cdaa760e01b815233600482015260240161070c565b6000807f000000000000000000000000494d68e3cab640fa50f4c1b3e2499698d1a173a06001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa1580156116a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c791906137b8565b5050505050509050806001600160a01b03166000036116e95783915050611743565b60006116fe6001600160a01b03831680613528565b90506000611719600160c01b670de0b6b3a7640000846129ea565b905060006117308683670de0b6b3a76400006129ea565b905061173c8188613569565b9450505050505b92915050565b60405163bdac7ca360e01b81523060048201526001600160a01b0382166024820152733ef3d8ba38ebe18db133cec108f4d14ce00dd9ae9063bdac7ca390604401600060405180830381600087803b1580156117a457600080fd5b505af11580156117b8573d6000803e3d6000fd5b5050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610839908490612a8d565b6001600160a01b0384166118375760405162461bcd60e51b815260040161070c906134ac565b8282116118745760405162461bcd60e51b815260206004820152600b60248201526a496e76616c696454696d6560a81b604482015260640161070c565b600081116118b15760405162461bcd60e51b815260206004820152600a60248201526916995c9bd05b5bdd5b9d60b21b604482015260640161070c565b6040805160c0810182526001600160a01b039586168152602081019485529081019283526060810191825260006080820181815260a08301828152600c8054600181018255935292517fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c7600690930292830180546001600160a01b031916919098161790965593517fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c885015591517fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c9840155517fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8ca83015591517fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8cb82015590517fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8cc90910155565b600260015403611a1a57604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b4260005b600c54811015611c0f576000600c8281548110611a4457611a44613624565b90600052602060002090600602019050806005015483111580611a6a5750806001015483105b80611a7c575080600201548160050154115b15611a875750611c07565b60008160010154826005015410611aa2578160050154611aa8565b81600101545b9050600082600201548511611abd5784611ac3565b82600201545b90506000611ad18383613611565b9050600084600101548560020154611ae99190613611565b9050600081838760030154611afe9190613528565b611b089190613555565b905060008660040154821015611b1f576000611b2e565b6004870154611b2e9083613611565b9050801580611b3d5750600954155b15611b4e5750505050505050611c07565b86546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611b96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bba91906134d1565b905080821115611bc8578091505b8754611bde9083906001600160a01b0316612afe565b81886004016000828254611bf29190613569565b90915550505050600590950187905550505050505b600101611a25565b5050565b6000806007546000146116115760408051608081018252600754815230602082019081526001600160801b0382840181815260608401828152945163fc6f786560e01b81529351600485015291516001600160a01b039081166024850152915181166044840152925190921660648201527f000000000000000000000000ec12a9f9a09f50550686363766cc153d03c27b5e9091169063fc6f78659060840160408051808303816000875af1158015611cd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cf49190613870565b90925090509091565b6040516370a0823160e01b8152306004820152600090819081906001600160a01b037f0000000000000000000000002cfc85d8e48f8eab294be644d9e25c303086300316906370a0823190602401602060405180830381865afa158015611d68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8c91906134d1565b6040516370a0823160e01b81523060048201529091506000906001600160a01b037f000000000000000000000000420000000000000000000000000000000000000616906370a0823190602401602060405180830381865afa158015611df6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e1a91906134d1565b9050811580611e27575080155b15611e39575060009485945092505050565b6000808615611f9f57600654611e5c90859065010000000000900460ff16612c13565b9550611e7783600660059054906101000a900460ff16612c13565b94508515611eb357611eb36001600160a01b037f0000000000000000000000002cfc85d8e48f8eab294be644d9e25c30308630031633886117bf565b8415611eed57611eed6001600160a01b037f00000000000000000000000042000000000000000000000000000000000000061633876117bf565b611f048460068054906101000a900460ff16612c13565b9150611f1d8360068054906101000a900460ff16612c13565b90508115611f5f57600254611f5f906001600160a01b037f0000000000000000000000002cfc85d8e48f8eab294be644d9e25c303086300381169116846117bf565b8015611f9f57600254611f9f906001600160a01b037f000000000000000000000000420000000000000000000000000000000000000681169116836117bf565b600082611fac8887613611565b611fb69190613611565b9050600082611fc58887613611565b611fcf9190613611565b9050611fdb8282612c47565b505050505050915091565b6000806000806000611ff66110e7565b505090506000612012826001600160801b0316886009546129ea565b90506001600160801b038111156120565760405162461bcd60e51b81526020600482015260086024820152674f766572666c6f7760c01b604482015260640161070c565b61205f816128c3565b60008061206a611c13565b6001600160a01b038c81166000908152600860205260409081902090516370a0823160e01b815230600482015293955091935090917f0000000000000000000000002cfc85d8e48f8eab294be644d9e25c3030863003909116906370a0823190602401602060405180830381865afa1580156120ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210e91906134d1565b6040516370a0823160e01b81523060048201529097507f00000000000000000000000042000000000000000000000000000000000000066001600160a01b0316906370a0823190602401602060405180830381865afa158015612175573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219991906134d1565b95506009548a146121ba576121b581600001548b6009546129ea565b6121bc565b865b98506009548a146121dd576121d881600101548b6009546129ea565b6121df565b855b9750888311156121ed578298505b878211156121f9578197505b86891115612205578698505b85881115612211578597505b60065461222a908a90640100000000900460ff16612c13565b965061224588600660049054906101000a900460ff16612c13565b95506000612253888b613611565b90506000612261888b613611565b9050811561229d5761229d6001600160a01b037f0000000000000000000000002cfc85d8e48f8eab294be644d9e25c3030863003168e846117bf565b80156122d7576122d76001600160a01b037f0000000000000000000000004200000000000000000000000000000000000006168e836117bf565b8b600960008282546122e99190613611565b90915550506001600160a01b038d166000908152600a6020526040812080548e9290612316908490613611565b90915550506001600160a01b038d166000908152600a60205260408120549003612343576123438d612fe8565b82548b10801561235557506009548c14155b61236057600061236d565b825461236d908c90613611565b835560018301548a10801561238457506009548c14155b61238f57600061239f565b89836001015461239f9190613611565b83600101819055505050505050505092959194509250565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008060008360020b1261241e578260020b61242b565b8260020b61242b90613894565b905061243a620d89e7196138b0565b60020b8111156124705760405162461bcd60e51b81526020600482015260016024820152601560fa1b604482015260640161070c565b60008160011660000361248757600160801b612499565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156124d85760806124d3826ffff97272373d413259a46990580e213a613528565b901c90505b60048216156125025760806124fd826ffff2e50f5f656932ef12357cf3c7fdcc613528565b901c90505b600882161561252c576080612527826fffe5caca7e10e4e61c3624eaa0941cd0613528565b901c90505b6010821615612556576080612551826fffcb9843d60f6159c9db58835c926644613528565b901c90505b602082161561258057608061257b826fff973b41fa98c081472e6896dfb254c0613528565b901c90505b60408216156125aa5760806125a5826fff2ea16466c96a3843ec78b326b52861613528565b901c90505b60808216156125d45760806125cf826ffe5dee046a99a2a811c461f1969c3053613528565b901c90505b6101008216156125ff5760806125fa826ffcbe86c7900a88aedcffc83b479aa3a4613528565b901c90505b61020082161561262a576080612625826ff987a7253ac413176f2b074cf7815e54613528565b901c90505b610400821615612655576080612650826ff3392b0822b70005940c7a398e4b70f3613528565b901c90505b61080082161561268057608061267b826fe7159475a2c29b7443b29c7fa6e889d9613528565b901c90505b6110008216156126ab5760806126a6826fd097f3bdfd2022b8845ad8f792aa5825613528565b901c90505b6120008216156126d65760806126d1826fa9f746462d870fdf8a65dc1f90e061e5613528565b901c90505b6140008216156127015760806126fc826f70d869a156d2a1b890bb3df62baf32f7613528565b901c90505b61800082161561272c576080612727826f31be135f97d08fd981231505542fcfa6613528565b901c90505b62010000821615612758576080612753826f09aa508b5b7a84e1c677de54f3e99bc9613528565b901c90505b6202000082161561278357608061277e826e5d6af8dedb81196699c329225ee604613528565b901c90505b620400008216156127ad5760806127a8826d2216e584f5fa1ea926041bedfe98613528565b901c90505b620800008216156127d55760806127d0826b048a170391f7dc42444e8fa2613528565b901c90505b60008460020b13156127f0576127ed81600019613555565b90505b6127ff640100000000826138d2565b1561280b57600161280e565b60005b61281f9060ff16602083901c613569565b949350505050565b600080836001600160a01b0316856001600160a01b03161115612848579293925b846001600160a01b0316866001600160a01b0316116128735761286c8585856130e4565b91506128ba565b836001600160a01b0316866001600160a01b031610156128ac576128988685856130e4565b91506128a5858785613157565b90506128ba565b6128b7858585613157565b90505b94509492505050565b6000806128ce6111ba565b915091506000806128df84846131a1565b9150915060006040518060a001604052806007548152602001876001600160801b0316815260200184815260200183815260200142600f6129209190613569565b905260408051630624e65f60e11b81528251600482015260208301516001600160801b0316602482015290820151604482015260608201516064820152608082015160848201529091507f000000000000000000000000ec12a9f9a09f50550686363766cc153d03c27b5e6001600160a01b031690630c49ccbe9060a40160408051808303816000875af11580156129bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e09190613870565b5050505050505050565b60008383028160001985870982811083820303915050808411612a0c57600080fd5b80600003612a1f57508290049050612a86565b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b600080602060008451602086016000885af180612ab0576040513d6000823e3d81fd5b50506000513d91508115612ac8578060011415612ad5565b6001600160a01b0384163b155b1561085257604051635274afe760e01b81526001600160a01b038516600482015260240161070c565b6000600554600454612b109190613569565b600b54909150811115612b225750600b545b6004545b81811015612bb3576000600b8281548110612b4357612b43613624565b60009182526020808320909101546001600160a01b0316808352600a9091526040909120549091508015612ba957600954600090612b818389613528565b612b8b9190613555565b90508015612ba757612ba76001600160a01b03871684836117bf565b505b5050600101612b26565b506004547fb3a10bd17078a9f771e5b624f3b69cb01fa19440fd81facb7ebaf81bdbaf54f090612be38184613611565b6040805192835260208301919091520160405180910390a16004819055600b548110610839576000600455505050565b6000612a86838360ff167f00000000000000000000000000000000000000000000000000000000000003e861ffff166129ea565b811580612c52575080155b15612c5b575050565b600080612c6884846131a1565b91509150600754600003612e545760006040518061016001604052807f0000000000000000000000002cfc85d8e48f8eab294be644d9e25c30308630036001600160a01b031681526020017f00000000000000000000000042000000000000000000000000000000000000066001600160a01b031681526020017f000000000000000000000000494d68e3cab640fa50f4c1b3e2499698d1a173a06001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d6491906138e6565b62ffffff168152620d89b3196020820152620d89b46040820152606081018790526080810186905260a0810185905260c081018490523060e082015261010001612daf42600f613569565b9052604051634418b22b60e11b81529091506000906001600160a01b037f000000000000000000000000ec12a9f9a09f50550686363766cc153d03c27b5e1690638831645690612e03908590600401613901565b6080604051808303816000875af1158015612e22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e4691906139c5565b505050600755506108529050565b60006040518060c00160405280600754815260200186815260200185815260200184815260200183815260200142600f612e8e9190613569565b90526040805163219f5d1760e01b81528251600482015260208301516024820152908201516044820152606082015160648201526080820151608482015260a082015160a48201529091507f000000000000000000000000ec12a9f9a09f50550686363766cc153d03c27b5e6001600160a01b03169063219f5d179060c4016060604051808303816000875af1925050508015612f48575060408051601f3d908101601f19168201909252612f4591810190613a01565b60015b612fac5760065460ff610100820481166301000000909204161015612fa7576006805460ff62010000820481169291600391612f8e918591630100000090910416613a36565b92506101000a81548160ff021916908360ff1602179055505b6117b8565b505060065460ff808216630100000090920416111590506117b85760068054630100000060ff82160263ff000000199091161790555050505050565b600b5460005b8181101561083957826001600160a01b0316600b828154811061301357613013613624565b6000918252602090912001546001600160a01b0316036130dc57600b61303a600184613611565b8154811061304a5761304a613624565b600091825260209091200154600b80546001600160a01b03909216918390811061307657613076613624565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550600b8054806130b5576130b561363a565b600082815260209020810160001990810180546001600160a01b0319169055019055505050565b600101612fee565b6000826001600160a01b0316846001600160a01b03161115613104579192915b6001600160a01b03841661314d6fffffffffffffffffffffffffffffffff60601b606085901b166131358787613a4f565b6001600160a01b0316866001600160a01b03166129ea565b61281f9190613555565b6000826001600160a01b0316846001600160a01b03161115613177579192915b61281f6001600160801b03831661318e8686613a4f565b6001600160a01b0316600160601b6129ea565b6006546000908190819060ff61010082048116630100000090920416116131d4576006546301000000900460ff166131e0565b600654610100900460ff165b9050613214858260ff167f00000000000000000000000000000000000000000000000000000000000003e861ffff166129ea565b9250613248848260ff167f00000000000000000000000000000000000000000000000000000000000003e861ffff166129ea565b9150505b9250929050565b60006020828403121561326557600080fd5b5035919050565b6001600160a01b038116811461078757600080fd5b60006020828403121561329357600080fd5b8135612a868161326c565b600080604083850312156132b157600080fd5b82356132bc8161326c565b915060208301356132cc8161326c565b809150509250929050565b600080600080608085870312156132ed57600080fd5b84356132f88161326c565b966020860135965060408601359560600135945092505050565b60006080828403121561332457600080fd5b50919050565b60006040828403121561332457600080fd5b60008083601f84011261334e57600080fd5b50813567ffffffffffffffff81111561336657600080fd5b60208301915083602082850101111561324c57600080fd5b6000806000806000806000806000806102008b8d03121561339e57600080fd5b8a35995060208b013598506133b68c60408d01613312565b97506133c58c60c08d0161332a565b96506101008b013567ffffffffffffffff808211156133e357600080fd5b6133ef8e838f0161333c565b90985096508691506134058e6101208f01613312565b95506134158e6101a08f0161332a565b94506101e08d013591508082111561342c57600080fd5b506134398d828e0161333c565b915080935050809150509295989b9194979a5092959850565b60ff8116811461078757600080fd5b60008060006060848603121561347657600080fd5b833561348181613452565b9250602084013561349181613452565b915060408401356134a181613452565b809150509250925092565b6020808252600b908201526a5a65726f4164647265737360a81b604082015260600190565b6000602082840312156134e357600080fd5b5051919050565b6020808252600e908201526d139bdd125b9a5d1a585b1a5e995960921b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761174357611743613512565b634e487b7160e01b600052601260045260246000fd5b6000826135645761356461353f565b500490565b8082018082111561174357611743613512565b80356135878161326c565b6001600160a01b03168252602090810135910152565b60006101006135ac838961357c565b60408801356040840152606088013560608401526135cd608084018861357c565b6001600160a01b03861660c084015260e0830181905282018390526101208385828501376000838501820152601f909301601f191690910190910195945050505050565b8181038181111561174357611743613512565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b6020808252600f908201526e496e76616c6964536c69707061676560881b604082015260600190565b80516136848161326c565b919050565b805162ffffff8116811461368457600080fd5b8051600281900b811461368457600080fd5b80516001600160801b038116811461368457600080fd5b6000806000806000806000806000806000806101808d8f0312156136e857600080fd5b8c516bffffffffffffffffffffffff8116811461370457600080fd5b9b5061371260208e01613679565b9a5061372060408e01613679565b995061372e60608e01613679565b985061373c60808e01613689565b975061374a60a08e0161369c565b965061375860c08e0161369c565b955061376660e08e016136ae565b94506101008d015193506101208d015192506137856101408e016136ae565b91506137946101608e016136ae565b90509295989b509295989b509295989b565b805161ffff8116811461368457600080fd5b600080600080600080600060e0888a0312156137d357600080fd5b87516137de8161326c565b96506137ec6020890161369c565b95506137fa604089016137a6565b9450613808606089016137a6565b9350613816608089016137a6565b925060a088015161382681613452565b60c0890151909250801515811461383c57600080fd5b8091505092959891949750929550565b6020808252600a9082015269496e76616c696446656560b01b604082015260600190565b6000806040838503121561388357600080fd5b505080516020909101519092909150565b6000600160ff1b82016138a9576138a9613512565b5060000390565b60008160020b627fffff1981036138c9576138c9613512565b60000392915050565b6000826138e1576138e161353f565b500690565b6000602082840312156138f857600080fd5b612a8682613689565b81516001600160a01b031681526101608101602083015161392d60208401826001600160a01b03169052565b506040830151613944604084018262ffffff169052565b506060830151613959606084018260020b9052565b50608083015161396e608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516139b4828501826001600160a01b03169052565b505061014092830151919092015290565b600080600080608085870312156139db57600080fd5b845193506139eb602086016136ae565b6040860151606090960151949790965092505050565b600080600060608486031215613a1657600080fd5b613a1f846136ae565b925060208401519150604084015190509250925092565b60ff818116838216019081111561174357611743613512565b6001600160a01b03828116828216039080821115613a6f57613a6f613512565b509291505056fea2646970667358221220aeb59927bd5f6261036671b74e4322fe921c52789c4dbe11f6b818e547b894f664736f6c63430008180033

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

000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3000000000000000000000000ec12a9f9a09f50550686363766cc153d03c27b5e000000000000000000000000494d68e3cab640fa50f4c1b3e2499698d1a173a0

-----Decoded View---------------
Arg [0] : _permit2 (address): 0x000000000022D473030F116dDEE9F6B43aC78BA3
Arg [1] : _positionManager (address): 0xec12a9F9a09f50550686363766Cc153D03c27b5e
Arg [2] : _pool (address): 0x494D68e3cAb640fa50F4c1B3E2499698D1a173A0

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3
Arg [1] : 000000000000000000000000ec12a9f9a09f50550686363766cc153d03c27b5e
Arg [2] : 000000000000000000000000494d68e3cab640fa50f4c1b3e2499698d1a173a0


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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