ETH Price: $3,483.86 (+2.82%)
Gas: 2 Gwei

Contract

0xae8999DA4D81cB81b42288b12176fE20D7EAD578
 
Transaction Hash
Method
Block
From
To
Value
Swap And Increas...202093752024-07-01 4:46:472 hrs ago1719809207IN
0xae8999DA...0D7EAD578
0 ETH0.000840461.79537524
Swap And Increas...202093402024-07-01 4:39:472 hrs ago1719808787IN
0xae8999DA...0D7EAD578
0 ETH0.000924851.90596403
Swap And Increas...202092902024-07-01 4:29:472 hrs ago1719808187IN
0xae8999DA...0D7EAD578
0 ETH0.001037112.28665768
Swap And Increas...202092772024-07-01 4:27:112 hrs ago1719808031IN
0xae8999DA...0D7EAD578
1 ETH0.000222912.14446245
Swap And Increas...202092702024-07-01 4:25:472 hrs ago1719807947IN
0xae8999DA...0D7EAD578
0 ETH0.00110992.10477244
Swap And Mint202005642024-06-29 23:16:2331 hrs ago1719702983IN
0xae8999DA...0D7EAD578
0.7 ETH0.001414311.62922461
Swap And Increas...201988642024-06-29 17:34:4737 hrs ago1719682487IN
0xae8999DA...0D7EAD578
0 ETH0.001467372.73679911
Swap And Increas...201960942024-06-29 8:16:5946 hrs ago1719649019IN
0xae8999DA...0D7EAD578
0 ETH0.001802022.68235421
Swap And Increas...201930122024-06-28 21:56:352 days ago1719611795IN
0xae8999DA...0D7EAD578
0 ETH0.00123352.52516103
Swap And Increas...201929322024-06-28 21:40:352 days ago1719610835IN
0xae8999DA...0D7EAD578
0 ETH0.001407942.7241525
Swap And Mint201888092024-06-28 7:52:112 days ago1719561131IN
0xae8999DA...0D7EAD578
0 ETH0.005633385.16994619
Swap And Increas...201886052024-06-28 7:10:593 days ago1719558659IN
0xae8999DA...0D7EAD578
0 ETH0.001849433.27879321
Swap And Increas...201879192024-06-28 4:52:593 days ago1719550379IN
0xae8999DA...0D7EAD578
0 ETH0.00118382.55339971
Swap And Increas...201823902024-06-27 10:20:473 days ago1719483647IN
0xae8999DA...0D7EAD578
0 ETH0.002587394.49693275
Swap And Mint201823322024-06-27 10:09:113 days ago1719482951IN
0xae8999DA...0D7EAD578
18 ETH0.004847694.77363014
Swap And Increas...201808622024-06-27 5:13:474 days ago1719465227IN
0xae8999DA...0D7EAD578
0 ETH0.002994076.13390081
Swap And Increas...201778512024-06-26 19:08:474 days ago1719428927IN
0xae8999DA...0D7EAD578
0 ETH0.00428828.31055832
Swap And Mint201747902024-06-26 8:52:594 days ago1719391979IN
0xae8999DA...0D7EAD578
0 ETH0.004171435.91426967
Swap And Mint201744312024-06-26 7:40:474 days ago1719387647IN
0xae8999DA...0D7EAD578
0 ETH0.001288411.71196343
Swap And Increas...201740532024-06-26 6:24:235 days ago1719383063IN
0xae8999DA...0D7EAD578
0 ETH0.001214852.69419994
Swap And Increas...201740252024-06-26 6:18:475 days ago1719382727IN
0xae8999DA...0D7EAD578
0 ETH0.001221192.75761276
Swap And Increas...201740082024-06-26 6:15:235 days ago1719382523IN
0xae8999DA...0D7EAD578
0 ETH0.000801022.51452409
Swap And Increas...201731702024-06-26 3:27:475 days ago1719372467IN
0xae8999DA...0D7EAD578
0 ETH0.000773022.6578191
Swap And Increas...201722012024-06-26 0:12:355 days ago1719360755IN
0xae8999DA...0D7EAD578
0 ETH0.002069894.40222326
Swap And Increas...201721982024-06-26 0:11:595 days ago1719360719IN
0xae8999DA...0D7EAD578
0 ETH0.002182584.02234356
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To Value
202092772024-07-01 4:27:112 hrs ago1719808031
0xae8999DA...0D7EAD578
1 ETH
202081702024-07-01 0:44:476 hrs ago1719794687
0xae8999DA...0D7EAD578
2.88840595 ETH
202081702024-07-01 0:44:476 hrs ago1719794687
0xae8999DA...0D7EAD578
2.88840595 ETH
202005642024-06-29 23:16:2331 hrs ago1719702983
0xae8999DA...0D7EAD578
0.7 ETH
201867012024-06-28 0:47:593 days ago1719535679
0xae8999DA...0D7EAD578
3.04168168 ETH
201867012024-06-28 0:47:593 days ago1719535679
0xae8999DA...0D7EAD578
3.04168168 ETH
201823322024-06-27 10:09:113 days ago1719482951
0xae8999DA...0D7EAD578
18 ETH
201671642024-06-25 7:20:115 days ago1719300011
0xae8999DA...0D7EAD578
0.62475282 ETH
201671642024-06-25 7:20:115 days ago1719300011
0xae8999DA...0D7EAD578
0.62475282 ETH
201497952024-06-22 21:02:118 days ago1719090131
0xae8999DA...0D7EAD578
0.20398072 ETH
201497952024-06-22 21:02:118 days ago1719090131
0xae8999DA...0D7EAD578
0.20398072 ETH
201475392024-06-22 13:27:238 days ago1719062843
0xae8999DA...0D7EAD578
0.13983724 ETH
201450382024-06-22 5:03:479 days ago1719032627
0xae8999DA...0D7EAD578
0.00033413 ETH
201450382024-06-22 5:03:479 days ago1719032627
0xae8999DA...0D7EAD578
0.00033413 ETH
201450382024-06-22 5:03:479 days ago1719032627
0xae8999DA...0D7EAD578
0.015 ETH
201450302024-06-22 5:02:119 days ago1719032531
0xae8999DA...0D7EAD578
0.02 ETH
201450182024-06-22 4:59:479 days ago1719032387
0xae8999DA...0D7EAD578
0.05 ETH
201418812024-06-21 18:27:359 days ago1718994455
0xae8999DA...0D7EAD578
0.33159659 ETH
201418812024-06-21 18:27:359 days ago1718994455
0xae8999DA...0D7EAD578
0.33159659 ETH
201404982024-06-21 13:48:479 days ago1718977727
0xae8999DA...0D7EAD578
1.06428162 ETH
201404982024-06-21 13:48:479 days ago1718977727
0xae8999DA...0D7EAD578
1.06428162 ETH
201360522024-06-20 22:55:2310 days ago1718924123
0xae8999DA...0D7EAD578
0.00004397 ETH
201360522024-06-20 22:55:2310 days ago1718924123
0xae8999DA...0D7EAD578
0.00004397 ETH
201360522024-06-20 22:55:2310 days ago1718924123
0xae8999DA...0D7EAD578
0.36 ETH
201360422024-06-20 22:53:2310 days ago1718924003
0xae8999DA...0D7EAD578
0.38 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
V3Utils

Compiler Version
v0.8.15+commit.e14f2714

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 18 : V3Utils.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "v3-periphery/interfaces/INonfungiblePositionManager.sol";
import "v3-periphery/interfaces/external/IWETH9.sol";

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/utils/math/SafeCast.sol";

/// @title v3Utils v1.0
/// @notice Utility functions for Uniswap V3 positions
/// This is a completely ownerless/stateless contract - does not hold any ERC20 or NFTs.
/// It can be simply redeployed when new / better functionality is implemented
contract V3Utils is IERC721Receiver {

    using SafeCast for uint256;

    /// @notice Wrapped native token address
    IWETH9 immutable public weth;

    /// @notice Uniswap v3 position manager
    INonfungiblePositionManager immutable public nonfungiblePositionManager;

    /// @notice 0x Exchange Proxy
    address immutable public swapRouter;

    // error types
    error Unauthorized();
    error WrongContract();
    error SelfSend();
    error NotSupportedWhatToDo();
    error SameToken();
    error SwapFailed();
    error AmountError();
    error SlippageError();
    error CollectError();
    error TransferError();
    error EtherSendFailed();
    error TooMuchEtherSent();
    error NoEtherToken();
    error NotWETH();

    // events
    event CompoundFees(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    event ChangeRange(uint256 indexed tokenId, uint256 newTokenId);
    event WithdrawAndCollectAndSwap(uint256 indexed tokenId, address token, uint256 amount);
    event Swap(address indexed tokenIn, address indexed tokenOut, uint256 amountIn, uint256 amountOut);
    event SwapAndMint(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    event SwapAndIncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);

    /// @notice Constructor
    /// @param _nonfungiblePositionManager Uniswap v3 position manager
    /// @param _swapRouter 0x Exchange Proxy
    constructor(INonfungiblePositionManager _nonfungiblePositionManager, address _swapRouter) {
        weth = IWETH9(_nonfungiblePositionManager.WETH9());
        nonfungiblePositionManager = _nonfungiblePositionManager;
        swapRouter = _swapRouter;
    }

    /// @notice Action which should be executed on provided NFT
    enum WhatToDo {
        CHANGE_RANGE,
        WITHDRAW_AND_COLLECT_AND_SWAP,
        COMPOUND_FEES
    }

    /// @notice Complete description of what should be executed on provided NFT - different fields are used depending on specified WhatToDo 
    struct Instructions {
        // what action to perform on provided Uniswap v3 position
        WhatToDo whatToDo;

        // target token for swaps (if this is address(0) no swaps are executed)
        address targetToken;

        // for removing liquidity slippage
        uint256 amountRemoveMin0;
        uint256 amountRemoveMin1;

        // amountIn0 is used for swap and also as minAmount0 for decreased liquidity + collected fees
        uint256 amountIn0;
        // if token0 needs to be swapped to targetToken - set values
        uint256 amountOut0Min;
        bytes swapData0; // encoded data from 0x api call (address,bytes) - allowanceTarget,data

        // amountIn1 is used for swap and also as minAmount1 for decreased liquidity + collected fees
        uint256 amountIn1;
        // if token1 needs to be swapped to targetToken - set values
        uint256 amountOut1Min;
        bytes swapData1; // encoded data from 0x api call (address,bytes) - allowanceTarget,data

        // collect fee amount for COMPOUND_FEES / CHANGE_RANGE / WITHDRAW_AND_COLLECT_AND_SWAP (if uint256(128).max - ALL)
        uint128 feeAmount0;
        uint128 feeAmount1;

        // for creating new positions with CHANGE_RANGE
        uint24 fee;
        int24 tickLower;
        int24 tickUpper;
        
        // remove liquidity amount for COMPOUND_FEES (in this case should be probably 0) / CHANGE_RANGE / WITHDRAW_AND_COLLECT_AND_SWAP
        uint128 liquidity;

        // for adding liquidity slippage
        uint256 amountAddMin0;
        uint256 amountAddMin1;

        // for all uniswap deadlineable functions
        uint256 deadline;

        // left over tokens will be sent to this address
        address recipient;

        // recipient of newly minted nft (the incoming NFT will ALWAYS be returned to from)
        address recipientNFT;

        // if tokenIn or tokenOut is WETH - unwrap
        bool unwrap;

        // data sent with returned token to IERC721Receiver (optional) 
        bytes returnData;

        // data sent with minted token to IERC721Receiver (optional)
        bytes swapAndMintReturnData;
    }

    /// @notice Execute instruction by pulling approved NFT instead of direct safeTransferFrom call from owner
    /// @param tokenId Token to process
    /// @param instructions Instructions to execute
    function execute(uint256 tokenId, Instructions calldata instructions) external
    {
        // must be approved beforehand
        nonfungiblePositionManager.safeTransferFrom(
            msg.sender,
            address(this),
            tokenId,
            abi.encode(instructions)
        );
    }

    /// @notice ERC721 callback function. Called on safeTransferFrom and does manipulation as configured in encoded Instructions parameter. 
    /// At the end the NFT (and any newly minted NFT) is returned to sender. The leftover tokens are sent to instructions.recipient.
    function onERC721Received(address, address from, uint256 tokenId, bytes calldata data) external override returns (bytes4) {

        // only Uniswap v3 NFTs allowed
        if (msg.sender != address(nonfungiblePositionManager)) {
            revert WrongContract();
        }

        // not allowed to send to itself
        if (from == address(this)) {
            revert SelfSend();
        }

        Instructions memory instructions = abi.decode(data, (Instructions));

        (,,address token0,address token1,,,,uint128 liquidity,,,,) = nonfungiblePositionManager.positions(tokenId);

        uint256 amount0;
        uint256 amount1;
        if (instructions.liquidity != 0) {
            (amount0, amount1) = _decreaseLiquidity(tokenId, instructions.liquidity, instructions.deadline, instructions.amountRemoveMin0, instructions.amountRemoveMin1);
        }
        (amount0, amount1) = _collectFees(tokenId, IERC20(token0), IERC20(token1), instructions.feeAmount0 == type(uint128).max ? type(uint128).max : (amount0 + instructions.feeAmount0).toUint128(), instructions.feeAmount1 == type(uint128).max ? type(uint128).max : (amount1 + instructions.feeAmount1).toUint128());
        
        // check if enough tokens are available for swaps
        if (amount0 < instructions.amountIn0 || amount1 < instructions.amountIn1) {
            revert AmountError();
        }

        if (instructions.whatToDo == WhatToDo.COMPOUND_FEES) {
            if (instructions.targetToken == token0) {
                (liquidity, amount0, amount1) = _swapAndIncrease(SwapAndIncreaseLiquidityParams(tokenId, amount0, amount1, instructions.recipient, instructions.deadline, IERC20(token1), instructions.amountIn1, instructions.amountOut1Min, instructions.swapData1, 0, 0, "", instructions.amountAddMin0, instructions.amountAddMin1), IERC20(token0), IERC20(token1), instructions.unwrap);
            } else if (instructions.targetToken == token1) {
                (liquidity, amount0, amount1) = _swapAndIncrease(SwapAndIncreaseLiquidityParams(tokenId, amount0, amount1, instructions.recipient, instructions.deadline, IERC20(token0), 0, 0, "", instructions.amountIn0, instructions.amountOut0Min, instructions.swapData0, instructions.amountAddMin0, instructions.amountAddMin1), IERC20(token0), IERC20(token1), instructions.unwrap);
            } else {
                // no swap is done here
                (liquidity,amount0, amount1) = _swapAndIncrease(SwapAndIncreaseLiquidityParams(tokenId, amount0, amount1, instructions.recipient, instructions.deadline, IERC20(address(0)), 0, 0, "", 0, 0, "", instructions.amountAddMin0, instructions.amountAddMin1), IERC20(token0), IERC20(token1), instructions.unwrap);
            }
            emit CompoundFees(tokenId, liquidity, amount0, amount1);            
        } else if (instructions.whatToDo == WhatToDo.CHANGE_RANGE) {

            uint256 newTokenId;

            if (instructions.targetToken == token0) {
                (newTokenId,,,) = _swapAndMint(SwapAndMintParams(IERC20(token0), IERC20(token1), instructions.fee, instructions.tickLower, instructions.tickUpper, amount0, amount1, instructions.recipient, instructions.recipientNFT, instructions.deadline, IERC20(token1), instructions.amountIn1, instructions.amountOut1Min, instructions.swapData1, 0, 0, "", instructions.amountAddMin0, instructions.amountAddMin1, instructions.swapAndMintReturnData), instructions.unwrap);
            } else if (instructions.targetToken == token1) {
                (newTokenId,,,) = _swapAndMint(SwapAndMintParams(IERC20(token0), IERC20(token1), instructions.fee, instructions.tickLower, instructions.tickUpper, amount0, amount1, instructions.recipient, instructions.recipientNFT, instructions.deadline, IERC20(token0), 0, 0, "", instructions.amountIn0, instructions.amountOut0Min, instructions.swapData0, instructions.amountAddMin0, instructions.amountAddMin1, instructions.swapAndMintReturnData), instructions.unwrap);
            } else {
                // no swap is done here
                (newTokenId,,,) = _swapAndMint(SwapAndMintParams(IERC20(token0), IERC20(token1), instructions.fee, instructions.tickLower, instructions.tickUpper, amount0, amount1, instructions.recipient, instructions.recipientNFT, instructions.deadline, IERC20(address(0)), 0, 0, "", 0, 0, "", instructions.amountAddMin0, instructions.amountAddMin1, instructions.swapAndMintReturnData), instructions.unwrap);
            }

            emit ChangeRange(tokenId, newTokenId);
        } else if (instructions.whatToDo == WhatToDo.WITHDRAW_AND_COLLECT_AND_SWAP) {
            uint256 targetAmount;
            if (token0 != instructions.targetToken) {
                (uint256 amountInDelta, uint256 amountOutDelta) = _swap(IERC20(token0), IERC20(instructions.targetToken), amount0, instructions.amountOut0Min, instructions.swapData0);
                if (amountInDelta < amount0) {
                    _transferToken(instructions.recipient, IERC20(token0), amount0 - amountInDelta, instructions.unwrap);
                }
                targetAmount += amountOutDelta;
            } else {
                targetAmount += amount0; 
            }
            if (token1 != instructions.targetToken) {
                (uint256 amountInDelta, uint256 amountOutDelta) = _swap(IERC20(token1), IERC20(instructions.targetToken), amount1, instructions.amountOut1Min, instructions.swapData1);
                if (amountInDelta < amount1) {
                    _transferToken(instructions.recipient, IERC20(token1), amount1 - amountInDelta, instructions.unwrap);
                }
                targetAmount += amountOutDelta;
            } else {
                targetAmount += amount1; 
            }

            // send complete target amount
            if (targetAmount != 0 && instructions.targetToken != address(0)) {
                _transferToken(instructions.recipient, IERC20(instructions.targetToken), targetAmount, instructions.unwrap);
            }

            emit WithdrawAndCollectAndSwap(tokenId, instructions.targetToken, targetAmount);
        } else {
            revert NotSupportedWhatToDo();
        }
        
        // return token to owner (this line guarantees that token is returned to originating owner)
        nonfungiblePositionManager.safeTransferFrom(address(this), from, tokenId, instructions.returnData);

        return IERC721Receiver.onERC721Received.selector;
    }

    /// @notice Params for swap() function
    struct SwapParams {
        IERC20 tokenIn;
        IERC20 tokenOut;
        uint256 amountIn;
        uint256 minAmountOut;
        address recipient; // recipient of tokenOut and leftover tokenIn (if any leftover)
        bytes swapData;
        bool unwrap; // if tokenIn or tokenOut is WETH - unwrap
    }

    /// @notice Swaps amountIn of tokenIn for tokenOut - returning at least minAmountOut
    /// @param params Swap configuration
    /// If tokenIn is wrapped native token - both the token or the wrapped token can be sent (the sum of both must be equal to amountIn)
    /// Optionally unwraps any wrapped native token and returns native token instead
    function swap(SwapParams calldata params) external payable returns (uint256 amountOut) {

        if (params.tokenIn == params.tokenOut) {
            revert SameToken();
        }

        _prepareAdd(params.tokenIn, IERC20(address(0)), IERC20(address(0)), params.amountIn, 0, 0);

        uint256 amountInDelta;
        (amountInDelta, amountOut) = _swap(params.tokenIn, params.tokenOut, params.amountIn, params.minAmountOut, params.swapData);

        // send swapped amount of tokenOut
        if (amountOut != 0) {
            _transferToken(params.recipient, params.tokenOut, amountOut, params.unwrap);
        }

        // if not all was swapped - return leftovers of tokenIn
        uint256 leftOver = params.amountIn - amountInDelta;
        if (leftOver != 0) {
            _transferToken(params.recipient, params.tokenIn, leftOver, params.unwrap);
        }
    }

    /// @notice Params for swapAndMint() function
    struct SwapAndMintParams {
        IERC20 token0;
        IERC20 token1;
        uint24 fee;
        int24 tickLower;
        int24 tickUpper;

        // how much is provided of token0 and token1
        uint256 amount0;
        uint256 amount1;
        address recipient; // recipient of leftover tokens
        address recipientNFT; // recipient of nft
        uint256 deadline;

        // source token for swaps (maybe either address(0), token0, token1 or another token)
        // if swapSourceToken is another token than token0 or token1 -> amountIn0 + amountIn1 of swapSourceToken are expected to be available
        IERC20 swapSourceToken;

        // if swapSourceToken needs to be swapped to token0 - set values
        uint256 amountIn0;
        uint256 amountOut0Min;
        bytes swapData0;

        // if swapSourceToken needs to be swapped to token1 - set values
        uint256 amountIn1;
        uint256 amountOut1Min;
        bytes swapData1;

        // min amount to be added after swap
        uint256 amountAddMin0;
        uint256 amountAddMin1;

        // data to be sent along newly created NFT when transfered to recipientNFT (sent to IERC721Receiver callback)
        bytes returnData;
    }

    /// @notice Does 1 or 2 swaps from swapSourceToken to token0 and token1 and adds as much as possible liquidity to a newly minted position.
    /// @param params Swap and mint configuration
    /// Newly minted NFT and leftover tokens are returned to recipient
    function swapAndMint(SwapAndMintParams calldata params) external payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1) {
        if (params.token0 == params.token1) {
            revert SameToken();
        }
        _prepareAdd(params.token0, params.token1, params.swapSourceToken, params.amount0, params.amount1, params.amountIn0 + params.amountIn1);
        (tokenId, liquidity, amount0, amount1) = _swapAndMint(params, msg.value != 0);
    }

    /// @notice Params for swapAndIncreaseLiquidity() function
    struct SwapAndIncreaseLiquidityParams {
        uint256 tokenId;

        // how much is provided of token0 and token1
        uint256 amount0;
        uint256 amount1;
        address recipient; // recipient of leftover tokens
        uint256 deadline;
        
        // source token for swaps (maybe either address(0), token0, token1 or another token)
        // if swapSourceToken is another token than token0 or token1 -> amountIn0 + amountIn1 of swapSourceToken are expected to be available
        IERC20 swapSourceToken;

        // if swapSourceToken needs to be swapped to token0 - set values
        uint256 amountIn0;
        uint256 amountOut0Min;
        bytes swapData0;

        // if swapSourceToken needs to be swapped to token1 - set values
        uint256 amountIn1;
        uint256 amountOut1Min;
        bytes swapData1;

        // min amount to be added after swap
        uint256 amountAddMin0;
        uint256 amountAddMin1;
    }

    /// @notice Does 1 or 2 swaps from swapSourceToken to token0 and token1 and adds as much as possible liquidity to any existing position (no need to be position owner).
    /// @param params Swap and increase liquidity configuration
    // Sends any leftover tokens to recipient.
    function swapAndIncreaseLiquidity(SwapAndIncreaseLiquidityParams calldata params) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1) {
        (, , address token0, address token1, , , , , , , , ) = nonfungiblePositionManager.positions(params.tokenId);
        _prepareAdd(IERC20(token0), IERC20(token1), params.swapSourceToken, params.amount0, params.amount1, params.amountIn0 + params.amountIn1);
        (liquidity, amount0, amount1) = _swapAndIncrease(params, IERC20(token0), IERC20(token1), msg.value != 0);
    }

    // checks if required amounts are provided and are exact - wraps any provided ETH as WETH
    // if less or more provided reverts
    function _prepareAdd(IERC20 token0, IERC20 token1, IERC20 otherToken, uint256 amount0, uint256 amount1, uint256 amountOther) internal
    {
        uint256 amountAdded0;
        uint256 amountAdded1;
        uint256 amountAddedOther;

        // wrap ether sent
        if (msg.value != 0) {
            weth.deposit{ value: msg.value }();

            if (address(weth) == address(token0)) {
                amountAdded0 = msg.value;
                if (amountAdded0 > amount0) {
                    revert TooMuchEtherSent();
                }
            } else if (address(weth) == address(token1)) {
                amountAdded1 = msg.value;
                if (amountAdded1 > amount1) {
                    revert TooMuchEtherSent();
                }
            } else if (address(weth) == address(otherToken)) {
                amountAddedOther = msg.value;
                if (amountAddedOther > amountOther) {
                    revert TooMuchEtherSent();
                }
            } else {
                revert NoEtherToken();
            }
        }

        // get missing tokens (fails if not enough provided)
        if (amount0 > amountAdded0) {
            uint256 balanceBefore = token0.balanceOf(address(this));
            SafeERC20.safeTransferFrom(token0, msg.sender, address(this), amount0 - amountAdded0);
            uint256 balanceAfter = token0.balanceOf(address(this));
            if (balanceAfter - balanceBefore != amount0 - amountAdded0) {
                revert TransferError(); // reverts for fee-on-transfer tokens
            }
        }
        if (amount1 > amountAdded1) {
            uint256 balanceBefore = token1.balanceOf(address(this));
            SafeERC20.safeTransferFrom(token1, msg.sender, address(this), amount1 - amountAdded1);
            uint256 balanceAfter = token1.balanceOf(address(this));
            if (balanceAfter - balanceBefore != amount1 - amountAdded1) {
                revert TransferError(); // reverts for fee-on-transfer tokens
            }
        }
        if (amountOther > amountAddedOther && address(otherToken) != address(0) && token0 != otherToken && token1 != otherToken) {
            uint256 balanceBefore = otherToken.balanceOf(address(this));
            SafeERC20.safeTransferFrom(otherToken, msg.sender, address(this), amountOther - amountAddedOther);
            uint256 balanceAfter = otherToken.balanceOf(address(this));
            if (balanceAfter - balanceBefore != amountOther - amountAddedOther) {
                revert TransferError(); // reverts for fee-on-transfer tokens
            }
        }
    }

    // swap and mint logic
    function _swapAndMint(SwapAndMintParams memory params, bool unwrap) internal returns (uint256 tokenId, uint128 liquidity, uint256 added0, uint256 added1) {

        (uint256 total0, uint256 total1) = _swapAndPrepareAmounts(params, unwrap);

        INonfungiblePositionManager.MintParams memory mintParams = 
            INonfungiblePositionManager.MintParams(
                address(params.token0), 
                address(params.token1), 
                params.fee, 
                params.tickLower,
                params.tickUpper,
                total0,
                total1, 
                params.amountAddMin0,
                params.amountAddMin1,
                address(this), // is sent to real recipient aftwards
                params.deadline
            );

        // mint is done to address(this) because it is not a safemint and safeTransferFrom needs to be done manually afterwards
        (tokenId,liquidity,added0,added1) = nonfungiblePositionManager.mint(mintParams);
        nonfungiblePositionManager.safeTransferFrom(address(this), params.recipientNFT, tokenId, params.returnData);

        emit SwapAndMint(tokenId, liquidity, added0, added1);

        _returnLeftoverTokens(params.recipient, params.token0, params.token1, total0, total1, added0, added1, unwrap);
    }

    // swap and increase logic
    function _swapAndIncrease(SwapAndIncreaseLiquidityParams memory params, IERC20 token0, IERC20 token1, bool unwrap) internal returns (uint128 liquidity, uint256 added0, uint256 added1) {

        (uint256 total0, uint256 total1) = _swapAndPrepareAmounts(
            SwapAndMintParams(token0, token1, 0, 0, 0, params.amount0, params.amount1, params.recipient, params.recipient, params.deadline, params.swapSourceToken, params.amountIn0, params.amountOut0Min, params.swapData0, params.amountIn1, params.amountOut1Min, params.swapData1, params.amountAddMin0, params.amountAddMin1, ""), unwrap);

        INonfungiblePositionManager.IncreaseLiquidityParams memory increaseLiquidityParams = 
            INonfungiblePositionManager.IncreaseLiquidityParams(
                params.tokenId, 
                total0, 
                total1, 
                params.amountAddMin0,
                params.amountAddMin1, 
                params.deadline
            );

        (liquidity, added0, added1) = nonfungiblePositionManager.increaseLiquidity(increaseLiquidityParams);

        emit SwapAndIncreaseLiquidity(params.tokenId, liquidity, added0, added1);

        _returnLeftoverTokens(params.recipient, token0, token1, total0, total1, added0, added1, unwrap);
    }

    // swaps available tokens and prepares max amounts to be added to nonfungiblePositionManager
    function _swapAndPrepareAmounts(SwapAndMintParams memory params, bool unwrap) internal returns (uint256 total0, uint256 total1) {
        if (params.swapSourceToken == params.token0) { 
            if (params.amount0 < params.amountIn1) {
                revert AmountError();
            }
            (uint256 amountInDelta, uint256 amountOutDelta) = _swap(params.token0, params.token1, params.amountIn1, params.amountOut1Min, params.swapData1);
            total0 = params.amount0 - amountInDelta;
            total1 = params.amount1 + amountOutDelta;
        } else if (params.swapSourceToken == params.token1) { 
            if (params.amount1 < params.amountIn0) {
                revert AmountError();
            }
            (uint256 amountInDelta, uint256 amountOutDelta) = _swap(params.token1, params.token0, params.amountIn0, params.amountOut0Min, params.swapData0);
            total1 = params.amount1 - amountInDelta;
            total0 = params.amount0 + amountOutDelta;
        } else if (address(params.swapSourceToken) != address(0)) {

            (uint256 amountInDelta0, uint256 amountOutDelta0) = _swap(params.swapSourceToken, params.token0, params.amountIn0, params.amountOut0Min, params.swapData0);
            (uint256 amountInDelta1, uint256 amountOutDelta1) = _swap(params.swapSourceToken, params.token1, params.amountIn1, params.amountOut1Min, params.swapData1);
            total0 = params.amount0 + amountOutDelta0;
            total1 = params.amount1 + amountOutDelta1;

            // return third token leftover if any
            uint256 leftOver = params.amountIn0 + params.amountIn1 - amountInDelta0 - amountInDelta1;

            if (leftOver != 0) {
                _transferToken(params.recipient, params.swapSourceToken, leftOver, unwrap);
            }
        } else {
            total0 = params.amount0;
            total1 = params.amount1;
        }

        if (total0 != 0) {
            SafeERC20.safeApprove(params.token0, address(nonfungiblePositionManager), 0);
            SafeERC20.safeApprove(params.token0, address(nonfungiblePositionManager), total0);
        }
        if (total1 != 0) {
            SafeERC20.safeApprove(params.token1, address(nonfungiblePositionManager), 0);
            SafeERC20.safeApprove(params.token1, address(nonfungiblePositionManager), total1);
        }
    }

    // returns leftover token balances
    function _returnLeftoverTokens(address to, IERC20 token0, IERC20 token1, uint256 total0, uint256 total1, uint256 added0, uint256 added1, bool unwrap) internal {

        uint256 left0 = total0 - added0;
        uint256 left1 = total1 - added1;

        // return leftovers
        if (left0 != 0) {
            _transferToken(to, token0, left0, unwrap);
        }
        if (left1 != 0) {
            _transferToken(to, token1, left1, unwrap);
        }
    }

    // transfers token (or unwraps WETH and sends ETH)
    function _transferToken(address to, IERC20 token, uint256 amount, bool unwrap) internal {
        if (address(weth) == address(token) && unwrap) {
            weth.withdraw(amount);
            (bool sent, ) = to.call{value: amount}("");
            if (!sent) {
                revert EtherSendFailed();
            }
        } else {
            SafeERC20.safeTransfer(token, to, amount);
        }
    }

    // general swap function which uses external router with off-chain calculated swap instructions
    // does slippage check with amountOutMin param
    // returns token amounts deltas after swap
    function _swap(IERC20 tokenIn, IERC20 tokenOut, uint256 amountIn, uint256 amountOutMin, bytes memory swapData) internal returns (uint256 amountInDelta, uint256 amountOutDelta) {
        if (amountIn != 0 && swapData.length != 0 && address(tokenOut) != address(0)) {
            uint256 balanceInBefore = tokenIn.balanceOf(address(this));
            uint256 balanceOutBefore = tokenOut.balanceOf(address(this));

            // get router specific swap data
            (address allowanceTarget, bytes memory data) = abi.decode(swapData, (address, bytes));

            // approve needed amount
            SafeERC20.safeApprove(tokenIn, allowanceTarget, amountIn);

            // execute swap
            (bool success,) = swapRouter.call(data);
            if (!success) {
                revert SwapFailed();
            }

            // reset approval
            SafeERC20.safeApprove(tokenIn, allowanceTarget, 0);

            uint256 balanceInAfter = tokenIn.balanceOf(address(this));
            uint256 balanceOutAfter = tokenOut.balanceOf(address(this));

            amountInDelta = balanceInBefore - balanceInAfter;
            amountOutDelta = balanceOutAfter - balanceOutBefore;

            // amountMin slippage check
            if (amountOutDelta < amountOutMin) {
                revert SlippageError();
            }

            // event for any swap with exact swapped value
            emit Swap(address(tokenIn), address(tokenOut), amountInDelta, amountOutDelta);
        }
    }

    // decreases liquidity from uniswap v3 position
    function _decreaseLiquidity(uint256 tokenId, uint128 liquidity, uint256 deadline, uint256 token0Min, uint256 token1Min) internal returns (uint256 amount0, uint256 amount1) {
        if (liquidity != 0) {
            (amount0, amount1) = nonfungiblePositionManager.decreaseLiquidity(
                INonfungiblePositionManager.DecreaseLiquidityParams(
                    tokenId, 
                    liquidity, 
                    token0Min, 
                    token1Min,
                    deadline
                )
            );
        }
    }

    // collects specified amount of fees from uniswap v3 position
    function _collectFees(uint256 tokenId, IERC20 token0, IERC20 token1, uint128 collectAmount0, uint128 collectAmount1) internal returns (uint256 amount0, uint256 amount1) {
        uint256 balanceBefore0 = token0.balanceOf(address(this));
        uint256 balanceBefore1 = token1.balanceOf(address(this));
        (amount0, amount1) = nonfungiblePositionManager.collect(
            INonfungiblePositionManager.CollectParams(tokenId, address(this), collectAmount0, collectAmount1)
        );
        uint256 balanceAfter0 = token0.balanceOf(address(this));
        uint256 balanceAfter1 = token1.balanceOf(address(this));

        // reverts for fee-on-transfer tokens
        if (balanceAfter0 - balanceBefore0 != amount0) {
            revert CollectError();
        }
        if (balanceAfter1 - balanceBefore1 != amount1) {
            revert CollectError();
        }
    }

    // needed for WETH unwrapping
    receive() external payable {
        if (msg.sender != address(weth)) {
            revert NotWETH();
        }
    }
}

File 2 of 18 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 3 of 18 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

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

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

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

File 4 of 18 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

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

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

File 5 of 18 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

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

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

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

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

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

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

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

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

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

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

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

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

File 6 of 18 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 7 of 18 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

File 8 of 18 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

File 9 of 18 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 10 of 18 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

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

File 11 of 18 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.0;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCast {
    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.2._
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v2.5._
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.2._
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v2.5._
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v2.5._
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v2.5._
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v2.5._
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     *
     * _Available since v3.0._
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.7._
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.7._
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     *
     * _Available since v3.0._
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 17 of 18 : IWETH9.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.8.15;

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

/// @title Interface for WETH9
interface IWETH9 is IERC20 {
    /// @notice Deposit ether to get wrapped ether
    function deposit() external payable;

    /// @notice Withdraw wrapped ether to get ether
    function withdraw(uint256) external;
}

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

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

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

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

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract INonfungiblePositionManager","name":"_nonfungiblePositionManager","type":"address"},{"internalType":"address","name":"_swapRouter","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AmountError","type":"error"},{"inputs":[],"name":"CollectError","type":"error"},{"inputs":[],"name":"EtherSendFailed","type":"error"},{"inputs":[],"name":"NoEtherToken","type":"error"},{"inputs":[],"name":"NotSupportedWhatToDo","type":"error"},{"inputs":[],"name":"NotWETH","type":"error"},{"inputs":[],"name":"SameToken","type":"error"},{"inputs":[],"name":"SelfSend","type":"error"},{"inputs":[],"name":"SlippageError","type":"error"},{"inputs":[],"name":"SwapFailed","type":"error"},{"inputs":[],"name":"TooMuchEtherSent","type":"error"},{"inputs":[],"name":"TransferError","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"WrongContract","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTokenId","type":"uint256"}],"name":"ChangeRange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"liquidity","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"CompoundFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenIn","type":"address"},{"indexed":true,"internalType":"address","name":"tokenOut","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"}],"name":"Swap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"liquidity","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"SwapAndIncreaseLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"liquidity","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"SwapAndMint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawAndCollectAndSwap","type":"event"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"enum V3Utils.WhatToDo","name":"whatToDo","type":"uint8"},{"internalType":"address","name":"targetToken","type":"address"},{"internalType":"uint256","name":"amountRemoveMin0","type":"uint256"},{"internalType":"uint256","name":"amountRemoveMin1","type":"uint256"},{"internalType":"uint256","name":"amountIn0","type":"uint256"},{"internalType":"uint256","name":"amountOut0Min","type":"uint256"},{"internalType":"bytes","name":"swapData0","type":"bytes"},{"internalType":"uint256","name":"amountIn1","type":"uint256"},{"internalType":"uint256","name":"amountOut1Min","type":"uint256"},{"internalType":"bytes","name":"swapData1","type":"bytes"},{"internalType":"uint128","name":"feeAmount0","type":"uint128"},{"internalType":"uint128","name":"feeAmount1","type":"uint128"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amountAddMin0","type":"uint256"},{"internalType":"uint256","name":"amountAddMin1","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"recipientNFT","type":"address"},{"internalType":"bool","name":"unwrap","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"},{"internalType":"bytes","name":"swapAndMintReturnData","type":"bytes"}],"internalType":"struct V3Utils.Instructions","name":"instructions","type":"tuple"}],"name":"execute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nonfungiblePositionManager","outputs":[{"internalType":"contract INonfungiblePositionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"contract IERC20","name":"tokenIn","type":"address"},{"internalType":"contract IERC20","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bytes","name":"swapData","type":"bytes"},{"internalType":"bool","name":"unwrap","type":"bool"}],"internalType":"struct V3Utils.SwapParams","name":"params","type":"tuple"}],"name":"swap","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"contract IERC20","name":"swapSourceToken","type":"address"},{"internalType":"uint256","name":"amountIn0","type":"uint256"},{"internalType":"uint256","name":"amountOut0Min","type":"uint256"},{"internalType":"bytes","name":"swapData0","type":"bytes"},{"internalType":"uint256","name":"amountIn1","type":"uint256"},{"internalType":"uint256","name":"amountOut1Min","type":"uint256"},{"internalType":"bytes","name":"swapData1","type":"bytes"},{"internalType":"uint256","name":"amountAddMin0","type":"uint256"},{"internalType":"uint256","name":"amountAddMin1","type":"uint256"}],"internalType":"struct V3Utils.SwapAndIncreaseLiquidityParams","name":"params","type":"tuple"}],"name":"swapAndIncreaseLiquidity","outputs":[{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"contract IERC20","name":"token0","type":"address"},{"internalType":"contract IERC20","name":"token1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"recipientNFT","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"contract IERC20","name":"swapSourceToken","type":"address"},{"internalType":"uint256","name":"amountIn0","type":"uint256"},{"internalType":"uint256","name":"amountOut0Min","type":"uint256"},{"internalType":"bytes","name":"swapData0","type":"bytes"},{"internalType":"uint256","name":"amountIn1","type":"uint256"},{"internalType":"uint256","name":"amountOut1Min","type":"uint256"},{"internalType":"bytes","name":"swapData1","type":"bytes"},{"internalType":"uint256","name":"amountAddMin0","type":"uint256"},{"internalType":"uint256","name":"amountAddMin1","type":"uint256"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"internalType":"struct V3Utils.SwapAndMintParams","name":"params","type":"tuple"}],"name":"swapAndMint","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"swapRouter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"contract IWETH9","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60e06040523480156200001157600080fd5b5060405162003ea238038062003ea28339810160408190526200003491620000d0565b816001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000073573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200009991906200010f565b6001600160a01b0390811660805291821660a0521660c05262000136565b6001600160a01b0381168114620000cd57600080fd5b50565b60008060408385031215620000e457600080fd5b8251620000f181620000b7565b60208401519092506200010481620000b7565b809150509250929050565b6000602082840312156200012257600080fd5b81516200012f81620000b7565b9392505050565b60805160a05160c051613ca3620001ff600039600081816102380152611c2d015260008181610204015281816102870152818161030501528181610d250152818161102c01528181611102015281816112270152818161145f0152818161176f0152818161196301528181611a1e0152818161276401528181612792015281816127c701526127f7015260008181608f0152818161012401528181611e5a01528181611ea701528181611fa2015281816120200152818161208201526120df0152613ca36000f3fe60806040526004361061007f5760003560e01c8063a161848b1161004e578063a161848b146101ba578063b44a2722146101f2578063c31c9c0714610226578063dc3253a01461025a57600080fd5b8063150b7a02146100d45780633fc8cef31461011257806390d528321461015e57806392df55ac1461017f57600080fd5b366100cf57336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146100cd57604051635724f38560e01b815260040160405180910390fd5b005b600080fd5b3480156100e057600080fd5b506100f46100ef366004612cae565b61027a565b6040516001600160e01b031990911681526020015b60405180910390f35b34801561011e57600080fd5b506101467f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610109565b61017161016c366004612d4c565b610dc4565b604051908152602001610109565b61019261018d366004612d8d565b610f39565b604080519485526001600160801b039093166020850152918301526060820152608001610109565b6101cd6101c8366004612dc8565b611003565b604080516001600160801b039094168452602084019290925290820152606001610109565b3480156101fe57600080fd5b506101467f000000000000000000000000000000000000000000000000000000000000000081565b34801561023257600080fd5b506101467f000000000000000000000000000000000000000000000000000000000000000081565b34801561026657600080fd5b506100cd610275366004612e03565b611100565b6000336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146102c557604051630d348b9b60e41b815260040160405180910390fd5b306001600160a01b038616036102ee57604051632797715160e01b815260040160405180910390fd5b60006102fc83850185613001565b905060008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166399fbab88896040518263ffffffff1660e01b815260040161035191815260200190565b61018060405180830381865afa15801561036f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103939190613231565b505050509750505050945094505050600080856101e001516001600160801b03166000146103e0576103da8a876101e0015188610240015189604001518a606001516111a7565b90925090505b6104798a86866001600160801b0380168a61014001516001600160801b03161461042b576104268a61014001516001600160801b0316876104219190613328565b6112a3565b610434565b6001600160801b035b6101608b01516001600160801b039081161461046c576104678b61016001516001600160801b0316876104219190613328565b611315565b6001600160801b03611315565b6080880151919350915082108061049357508560e0015181105b156104b157604051634ff64a9f60e01b815260040160405180910390fd5b6002865160028111156104c6576104c6613340565b0361078557846001600160a01b031686602001516001600160a01b0316036105a75761059b604051806101c001604052808c81526020018481526020018381526020018861026001516001600160a01b031681526020018861024001518152602001866001600160a01b031681526020018860e00151815260200188610100015181526020018861012001518152602001600081526020016000815260200160405180602001604052806000815250815260200188610200015181526020018861022001518152508686896102a0015161160b565b91945092509050610734565b836001600160a01b031686602001516001600160a01b0316036106755761059b604051806101c001604052808c81526020018481526020018381526020018861026001516001600160a01b031681526020018861024001518152602001876001600160a01b031681526020016000815260200160008152602001604051806020016040528060008152508152602001886080015181526020018860a0015181526020018860c00151815260200188610200015181526020018861022001518152508686896102a0015161160b565b61072c604051806101c001604052808c81526020018481526020018381526020018861026001516001600160a01b03168152602001886102400151815260200160006001600160a01b031681526020016000815260200160008152602001604051806020016040528060008152508152602001600081526020016000815260200160405180602001604052806000815250815260200188610200015181526020018861022001518152508686896102a0015161160b565b919450925090505b604080516001600160801b0385168152602081018490529081018290528a907faede78842f79342b251fe687b26b9f00d35eec5b0d21d44c283dd01a5ad7c1369060600160405180910390a2610d23565b60008651600281111561079a5761079a613340565b03610b6c576000856001600160a01b031687602001516001600160a01b0316036108de576108d2604051806102800160405280886001600160a01b03168152602001876001600160a01b0316815260200189610180015162ffffff168152602001896101a0015160020b8152602001896101c0015160020b81526020018581526020018481526020018961026001516001600160a01b031681526020018961028001516001600160a01b031681526020018961024001518152602001876001600160a01b031681526020018960e00151815260200189610100015181526020018961012001518152602001600081526020016000815260200160405180602001604052806000815250815260200189610200015181526020018961022001518152602001896102e00151815250886102a001516118b1565b50919250610b2c915050565b846001600160a01b031687602001516001600160a01b031603610a0d576108d2604051806102800160405280886001600160a01b03168152602001876001600160a01b0316815260200189610180015162ffffff168152602001896101a0015160020b8152602001896101c0015160020b81526020018581526020018481526020018961026001516001600160a01b031681526020018961028001516001600160a01b031681526020018961024001518152602001886001600160a01b031681526020016000815260200160008152602001604051806020016040528060008152508152602001896080015181526020018960a0015181526020018960c00151815260200189610200015181526020018961022001518152602001896102e00151815250886102a001516118b1565b610b25604051806102800160405280886001600160a01b03168152602001876001600160a01b0316815260200189610180015162ffffff168152602001896101a0015160020b8152602001896101c0015160020b81526020018581526020018481526020018961026001516001600160a01b031681526020018961028001516001600160a01b03168152602001896102400151815260200160006001600160a01b031681526020016000815260200160008152602001604051806020016040528060008152508152602001600081526020016000815260200160405180602001604052806000815250815260200189610200015181526020018961022001518152602001896102e00151815250886102a001516118b1565b5091925050505b8a7f2d3b242342e1e892c96167e80cea1f82a3961348e1576320d5e93deaa75d368982604051610b5e91815260200190565b60405180910390a250610d23565b600186516002811115610b8157610b81613340565b03610d0a57600086602001516001600160a01b0316866001600160a01b031614610c0057600080610bc1888a60200151878c60a001518d60c00151611afd565b9150915084821015610bed57610260890151610bed9089610be28589613356565b8c6102a00151611e4e565b610bf78184613328565b92505050610c0d565b610c0a8382613328565b90505b86602001516001600160a01b0316856001600160a01b031614610c7c57600080610c48878a60200151868c61010001518d6101200151611afd565b9150915083821015610c6957610260890151610c699088610be28588613356565b610c738184613328565b92505050610c89565b610c868282613328565b90505b8015801590610ca4575060208701516001600160a01b031615155b15610cc357610cc38761026001518860200151838a6102a00151611e4e565b602080880151604080516001600160a01b0390921682529181018390528c917ff8aacb16b34d229aa53d44a7759a3741b5c098e099666e51a4ae9d66a5956c439101610b5e565b60405163290db76760e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b88d4fde308d8d8a6102c001516040518563ffffffff1660e01b8152600401610d7a94939291906133c5565b600060405180830381600087803b158015610d9457600080fd5b505af1158015610da8573d6000803e3d6000fd5b50630a85bd0160e11b9f9e505050505050505050505050505050565b6000610dd66040830160208401613402565b6001600160a01b0316610dec6020840184613402565b6001600160a01b031603610e135760405163100dac0560e11b815260040160405180910390fd5b610e33610e236020840184613402565b6000808560400135600080611f96565b6000610ea6610e456020850185613402565b610e556040860160208701613402565b60408601356060870135610e6c60a089018961341f565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611afd92505050565b925090508115610ee957610ee9610ec360a0850160808601613402565b610ed36040860160208701613402565b84610ee460e0880160c08901613465565b611e4e565b6000610ef9826040860135613356565b90508015610f3257610f32610f1460a0860160808701613402565b610f216020870187613402565b83610ee460e0890160c08a01613465565b5050919050565b6000808080610f4e6040860160208701613402565b6001600160a01b0316610f646020870187613402565b6001600160a01b031603610f8b5760405163100dac0560e11b815260040160405180910390fd5b610fe0610f9b6020870187613402565b610fab6040880160208901613402565b610fbd61016089016101408a01613402565b60a089013560c08a0135610fdb6101c08c01356101608d0135613328565b611f96565b610ff4610fec86613482565b3415156118b1565b92989197509550909350915050565b60405163133f757160e31b81528135600482015260009081908190819081906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906399fbab889060240161018060405180830381865afa158015611074573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110989190613231565b50505050505050509350935050506110db82828860a00160208101906110be9190613402565b60208a013560408b0135610fdb6101208d013560c08e0135613328565b6110f16110e78761360d565b838334151561160b565b91989097509095509350505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b88d4fde33308585604051602001611143919061379e565b6040516020818303038152906040526040518563ffffffff1660e01b815260040161117194939291906133c5565b600060405180830381600087803b15801561118b57600080fd5b505af115801561119f573d6000803e3d6000fd5b505050505050565b6000806001600160801b03861615611299576040805160a0810182528881526001600160801b038089166020830190815282840188815260608401888152608085018b81529551630624e65f60e11b8152945160048601529151909216602484015290516044830152516064820152905160848201526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690630c49ccbe9060a40160408051808303816000875af115801561126f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112939190613a1f565b90925090505b9550959350505050565b60006001600160801b038211156113115760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b60648201526084015b60405180910390fd5b5090565b6040516370a0823160e01b8152306004820152600090819081906001600160a01b038816906370a0823190602401602060405180830381865afa158015611360573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113849190613a43565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038816906370a0823190602401602060405180830381865afa1580156113ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f29190613a43565b604080516080810182528b815230602082019081526001600160801b038a81168385019081528a821660608501908152945163fc6f786560e01b81529351600485015291516001600160a01b039081166024850152915181166044840152925190921660648201529192507f0000000000000000000000000000000000000000000000000000000000000000169063fc6f78659060840160408051808303816000875af11580156114a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114cb9190613a1f565b6040516370a0823160e01b815230600482015291955093506000906001600160a01b038a16906370a0823190602401602060405180830381865afa158015611517573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061153b9190613a43565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038a16906370a0823190602401602060405180830381865afa158015611585573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a99190613a43565b9050856115b68584613356565b146115d457604051638ad721cb60e01b815260040160405180910390fd5b846115df8483613356565b146115fd57604051638ad721cb60e01b815260040160405180910390fd5b505050509550959350505050565b60008060008060006117266040518061028001604052808a6001600160a01b03168152602001896001600160a01b03168152602001600062ffffff168152602001600060020b8152602001600060020b81526020018b6020015181526020018b6040015181526020018b606001516001600160a01b031681526020018b606001516001600160a01b031681526020018b6080015181526020018b60a001516001600160a01b031681526020018b60c0015181526020018b60e0015181526020018b610100015181526020018b610120015181526020018b610140015181526020018b610160015181526020018b610180015181526020018b6101a001518152602001604051806020016040528060008152508152508761251d565b9150915060006040518060c001604052808b6000015181526020018481526020018381526020018b610180015181526020018b6101a0015181526020018b6080015181525090507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663219f5d17826040518263ffffffff1660e01b81526004016117f89190600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b6060604051808303816000875af1158015611817573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183b9190613a5c565b8c51604080516001600160801b0386168152602081018590529081018390529399509197509550907f1aa7d7662b161a8d4058004091e4c60474753d2f085db526dfb22da59838d0a79060600160405180910390a26118a48a606001518a8a86868a8a8e612823565b5050509450945094915050565b6000806000806000806118c4888861251d565b9150915060006040518061016001604052808a600001516001600160a01b031681526020018a602001516001600160a01b031681526020018a6040015162ffffff1681526020018a6060015160020b81526020018a6080015160020b81526020018481526020018381526020018a610220015181526020018a61024001518152602001306001600160a01b031681526020018a610120015181525090507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166388316456826040518263ffffffff1660e01b81526004016119ad9190613a93565b6080604051808303816000875af11580156119cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f09190613b57565b6101008d01516102608e0151604051635c46a7ef60e11b8152959c50939a5091985096506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169263b88d4fde92611a5792309290918d916004016133c5565b600060405180830381600087803b158015611a7157600080fd5b505af1158015611a85573d6000803e3d6000fd5b5050604080516001600160801b038a168152602081018990529081018790528992507fdbed0571af71402c681d3b0a1f08d80aa2245c9adb30e12d215356c7a274fcf9915060600160405180910390a2611af18960e001518a600001518b6020015186868a8a8f612823565b50505092959194509250565b6000808415801590611b0f5750825115155b8015611b2357506001600160a01b03861615155b15611299576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa158015611b6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b939190613a43565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038916906370a0823190602401602060405180830381865afa158015611bdd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c019190613a43565b905060008086806020019051810190611c1a9190613b95565b91509150611c298b838b61286f565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031682604051611c639190613c21565b6000604051808303816000865af19150503d8060008114611ca0576040519150601f19603f3d011682016040523d82523d6000602084013e611ca5565b606091505b5050905080611cc75760405163081ceff360e41b815260040160405180910390fd5b611cd38c84600061286f565b6040516370a0823160e01b81523060048201526000906001600160a01b038e16906370a0823190602401602060405180830381865afa158015611d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3e9190613a43565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038e16906370a0823190602401602060405180830381865afa158015611d88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dac9190613a43565b9050611db88288613356565b9850611dc48682613356565b97508a881015611de757604051630d4205a160e11b815260040160405180910390fd5b8c6001600160a01b03168e6001600160a01b03167ffa2dda1cc1b86e41239702756b13effbc1a092b5c57e3ad320fbe4f3b13fe2358b8b604051611e35929190918252602082015260400190565b60405180910390a3505050505050509550959350505050565b826001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316148015611e8c5750805b15611f8557604051632e1a7d4d60e01b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015611ef357600080fd5b505af1158015611f07573d6000803e3d6000fd5b505050506000846001600160a01b03168360405160006040518083038185875af1925050503d8060008114611f58576040519150601f19603f3d011682016040523d82523d6000602084013e611f5d565b606091505b5050905080611f7f57604051637cd69c3960e11b815260040160405180910390fd5b50611f90565b611f908385846129bc565b50505050565b600080803415612148577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015611ffb57600080fd5b505af115801561200f573d6000803e3d6000fd5b5050505050886001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316036120765734925085831115612071576040516307e205e160e41b815260040160405180910390fd5b612148565b876001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316036120d35734915084821115612071576040516307e205e160e41b815260040160405180910390fd5b866001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03160361212f57503483811115612071576040516307e205e160e41b815260040160405180910390fd5b6040516392b0337360e01b815260040160405180910390fd5b82861115612274576040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa158015612197573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121bb9190613a43565b90506121d28a33306121cd888c613356565b6129ec565b6040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015612219573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061223d9190613a43565b90506122498589613356565b6122538383613356565b14612271576040516313ff771f60e21b815260040160405180910390fd5b50505b8185111561239b576040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156122c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122e79190613a43565b90506122f98933306121cd878b613356565b6040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa158015612340573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123649190613a43565b90506123708488613356565b61237a8383613356565b14612398576040516313ff771f60e21b815260040160405180910390fd5b50505b80841180156123b257506001600160a01b03871615155b80156123d05750866001600160a01b0316896001600160a01b031614155b80156123ee5750866001600160a01b0316886001600160a01b031614155b15612512576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa15801561243a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061245e9190613a43565b90506124708833306121cd868a613356565b6040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156124b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124db9190613a43565b90506124e78387613356565b6124f18383613356565b1461250f576040516313ff771f60e21b815260040160405180910390fd5b50505b505050505050505050565b60008083600001516001600160a01b03168461014001516001600160a01b0316036125c257836101c001518460a00151101561256c57604051634ff64a9f60e01b815260040160405180910390fd5b60008061259386600001518760200151886101c00151896101e001518a6102000151611afd565b91509150818660a001516125a79190613356565b9350808660c001516125b99190613328565b92505050612756565b83602001516001600160a01b03168461014001516001600160a01b031603612664578361016001518460c00151101561260e57604051634ff64a9f60e01b815260040160405180910390fd5b600080612635866020015187600001518861016001518961018001518a6101a00151611afd565b91509150818660c001516126499190613356565b9250808660a0015161265b9190613328565b93505050612756565b6101408401516001600160a01b031615612749576000806126a086610140015187600001518861016001518961018001518a6101a00151611afd565b915091506000806126cc88610140015189602001518a6101c001518b6101e001518c6102000151611afd565b91509150828860a001516126e09190613328565b9550808860c001516126f29190613328565b9450600082858a6101c001518b610160015161270e9190613328565b6127189190613356565b6127229190613356565b9050801561273f5761273f8960e001518a6101400151838b611e4e565b5050505050612756565b505060a082015160c08301515b81156127b757835161278a907f0000000000000000000000000000000000000000000000000000000000000000600061286f565b83516127b7907f00000000000000000000000000000000000000000000000000000000000000008461286f565b801561281c576127ed84602001517f0000000000000000000000000000000000000000000000000000000000000000600061286f565b61281c84602001517f00000000000000000000000000000000000000000000000000000000000000008361286f565b9250929050565b600061282f8487613356565b9050600061283d8487613356565b90508115612851576128518a8a8486611e4e565b8015612863576128638a898386611e4e565b50505050505050505050565b8015806128e95750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa1580156128c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128e79190613a43565b155b6129545760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401611308565b6040516001600160a01b0383166024820152604481018290526129b790849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a24565b505050565b6040516001600160a01b0383166024820152604481018290526129b790849063a9059cbb60e01b90606401612980565b6040516001600160a01b0380851660248301528316604482015260648101829052611f909085906323b872dd60e01b90608401612980565b6000612a79826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612af69092919063ffffffff16565b8051909150156129b75780806020019051810190612a979190613c3d565b6129b75760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401611308565b6060612b058484600085612b0d565b949350505050565b606082471015612b6e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401611308565b600080866001600160a01b03168587604051612b8a9190613c21565b60006040518083038185875af1925050503d8060008114612bc7576040519150601f19603f3d011682016040523d82523d6000602084013e612bcc565b606091505b5091509150612bdd87838387612be8565b979650505050505050565b60608315612c57578251600003612c50576001600160a01b0385163b612c505760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611308565b5081612b05565b612b058383815115612c6c5781518083602001fd5b8060405162461bcd60e51b81526004016113089190613c5a565b6001600160a01b0381168114612c9b57600080fd5b50565b8035612ca981612c86565b919050565b600080600080600060808688031215612cc657600080fd5b8535612cd181612c86565b94506020860135612ce181612c86565b93506040860135925060608601356001600160401b0380821115612d0457600080fd5b818801915088601f830112612d1857600080fd5b813581811115612d2757600080fd5b896020828501011115612d3957600080fd5b9699959850939650602001949392505050565b600060208284031215612d5e57600080fd5b81356001600160401b03811115612d7457600080fd5b820160e08185031215612d8657600080fd5b9392505050565b600060208284031215612d9f57600080fd5b81356001600160401b03811115612db557600080fd5b82016102808185031215612d8657600080fd5b600060208284031215612dda57600080fd5b81356001600160401b03811115612df057600080fd5b82016101c08185031215612d8657600080fd5b60008060408385031215612e1657600080fd5b8235915060208301356001600160401b03811115612e3357600080fd5b83016103008186031215612e4657600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60405161030081016001600160401b0381118282101715612e8a57612e8a612e51565b60405290565b60405161028081016001600160401b0381118282101715612e8a57612e8a612e51565b6040516101c081016001600160401b0381118282101715612e8a57612e8a612e51565b604051601f8201601f191681016001600160401b0381118282101715612efe57612efe612e51565b604052919050565b803560038110612ca957600080fd5b60006001600160401b03821115612f2e57612f2e612e51565b50601f01601f191660200190565b600082601f830112612f4d57600080fd5b8135612f60612f5b82612f15565b612ed6565b818152846020838601011115612f7557600080fd5b816020850160208301376000918101602001919091529392505050565b6001600160801b0381168114612c9b57600080fd5b8035612ca981612f92565b62ffffff81168114612c9b57600080fd5b8035612ca981612fb2565b8060020b8114612c9b57600080fd5b8035612ca981612fce565b8015158114612c9b57600080fd5b8035612ca981612fe8565b60006020828403121561301357600080fd5b81356001600160401b038082111561302a57600080fd5b90830190610300828603121561303f57600080fd5b613047612e67565b61305083612f06565b815261305e60208401612c9e565b602082015260408301356040820152606083013560608201526080830135608082015260a083013560a082015260c08301358281111561309d57600080fd5b6130a987828601612f3c565b60c08301525060e083013560e082015261010080840135818301525061012080840135838111156130d957600080fd5b6130e588828701612f3c565b8284015250506101406130f9818501612fa7565b9082015261016061310b848201612fa7565b9082015261018061311d848201612fc3565b908201526101a061312f848201612fdd565b908201526101c0613141848201612fdd565b908201526101e0613153848201612fa7565b90820152610200838101359082015261022080840135908201526102408084013590820152610260613186818501612c9e565b90820152610280613198848201612c9e565b908201526102a06131aa848201612ff6565b908201526102c083810135838111156131c257600080fd5b6131ce88828701612f3c565b8284015250506102e080840135838111156131e857600080fd5b6131f488828701612f3c565b918301919091525095945050505050565b8051612ca981612c86565b8051612ca981612fb2565b8051612ca981612fce565b8051612ca981612f92565b6000806000806000806000806000806000806101808d8f03121561325457600080fd5b8c516bffffffffffffffffffffffff8116811461327057600080fd5b9b5061327e60208e01613205565b9a5061328c60408e01613205565b995061329a60608e01613205565b98506132a860808e01613210565b97506132b660a08e0161321b565b96506132c460c08e0161321b565b95506132d260e08e01613226565b94506101008d015193506101208d015192506132f16101408e01613226565b91506133006101608e01613226565b90509295989b509295989b509295989b565b634e487b7160e01b600052601160045260246000fd5b6000821982111561333b5761333b613312565b500190565b634e487b7160e01b600052602160045260246000fd5b60008282101561336857613368613312565b500390565b60005b83811015613388578181015183820152602001613370565b83811115611f905750506000910152565b600081518084526133b181602086016020860161336d565b601f01601f19169290920160200192915050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906133f890830184613399565b9695505050505050565b60006020828403121561341457600080fd5b8135612d8681612c86565b6000808335601e1984360301811261343657600080fd5b8301803591506001600160401b0382111561345057600080fd5b60200191503681900382131561281c57600080fd5b60006020828403121561347757600080fd5b8135612d8681612fe8565b6000610280823603121561349557600080fd5b61349d612e90565b6134a683612c9e565b81526134b460208401612c9e565b60208201526134c560408401612fc3565b60408201526134d660608401612fdd565b60608201526134e760808401612fdd565b608082015260a083013560a082015260c083013560c082015261350c60e08401612c9e565b60e082015261010061351f818501612c9e565b90820152610120838101359082015261014061353c818501612c9e565b90820152610160838101359082015261018080840135908201526101a0808401356001600160401b038082111561357257600080fd5b61357e36838801612f3c565b92840192909252506101c084810135908301526101e08085013590830152610200908185013590808211156135b257600080fd5b6135be36838801612f3c565b928401929092525061022084810135908301526102408085013590830152610260908185013590808211156135f257600080fd5b506135ff36828701612f3c565b918301919091525092915050565b60006101c0823603121561362057600080fd5b613628612eb3565b82358152602083013560208201526040830135604082015261364c60608401612c9e565b60608201526080830135608082015261366760a08401612c9e565b60a082015260c083013560c082015260e083013560e0820152610100808401356001600160401b038082111561369c57600080fd5b6136a836838801612f3c565b928401929092525061012084810135908301526101408085013590830152610160908185013590808211156136dc57600080fd5b506136e936828701612f3c565b918301919091525061018083810135908201526101a092830135928101929092525090565b6003811061372c57634e487b7160e01b600052602160045260246000fd5b9052565b6000808335601e1984360301811261374757600080fd5b83016020810192503590506001600160401b0381111561376657600080fd5b80360382131561281c57600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b602081526137b7602082016137b284612f06565b61370e565b60006137c560208401612c9e565b6001600160a01b0381166040840152506040830135606083015260608301356080830152608083013560a083015260a083013560c083015261380a60c0840184613730565b6103008060e086015261382261032086018385613775565b9250610100915060e086013582860152610120828701358187015261384981880188613730565b93509050601f19610140818887030181890152613867868685613775565b9550613874818a01612fa7565b9450506101609150613890828801856001600160801b03169052565b61389b828901612fa7565b935061018091506138b6828801856001600160801b03169052565b6138c1828901612fc3565b93506101a091506138d88288018562ffffff169052565b6138e3828901612fdd565b93506101c091506138f88288018560020b9052565b613903828901612fdd565b93506101e091506139188288018560020b9052565b613923828901612fa7565b9350610200915061393e828801856001600160801b03169052565b610220935081880135848801526102409150838801358288015261026093508188013584880152613970848901612c9e565b9350610280915061398b828801856001600160a01b03169052565b613996828901612c9e565b93506102a091506139b1828801856001600160a01b03169052565b6139bc828901612ff6565b93506102c091506139d08288018515159052565b6139dc82890189613730565b945091506102e08188870301818901526139f7868685613775565b9550613a05818a018a613730565b955092505080878603018388015250612bdd848483613775565b60008060408385031215613a3257600080fd5b505080516020909101519092909150565b600060208284031215613a5557600080fd5b5051919050565b600080600060608486031215613a7157600080fd5b8351613a7c81612f92565b602085015160409095015190969495509392505050565b81516001600160a01b0316815261016081016020830151613abf60208401826001600160a01b03169052565b506040830151613ad6604084018262ffffff169052565b506060830151613aeb606084018260020b9052565b506080830151613b00608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151613b46828501826001600160a01b03169052565b505061014092830151919092015290565b60008060008060808587031215613b6d57600080fd5b845193506020850151613b7f81612f92565b6040860151606090960151949790965092505050565b60008060408385031215613ba857600080fd5b8251613bb381612c86565b60208401519092506001600160401b03811115613bcf57600080fd5b8301601f81018513613be057600080fd5b8051613bee612f5b82612f15565b818152866020838501011115613c0357600080fd5b613c1482602083016020860161336d565b8093505050509250929050565b60008251613c3381846020870161336d565b9190910192915050565b600060208284031215613c4f57600080fd5b8151612d8681612fe8565b602081526000612d86602083018461339956fea2646970667358221220c072501aac47d4a97ed9183371fc88459c2cc11cda8d18c0d8f34622181a701664736f6c634300080f0033000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff

Deployed Bytecode

0x60806040526004361061007f5760003560e01c8063a161848b1161004e578063a161848b146101ba578063b44a2722146101f2578063c31c9c0714610226578063dc3253a01461025a57600080fd5b8063150b7a02146100d45780633fc8cef31461011257806390d528321461015e57806392df55ac1461017f57600080fd5b366100cf57336001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216146100cd57604051635724f38560e01b815260040160405180910390fd5b005b600080fd5b3480156100e057600080fd5b506100f46100ef366004612cae565b61027a565b6040516001600160e01b031990911681526020015b60405180910390f35b34801561011e57600080fd5b506101467f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6040516001600160a01b039091168152602001610109565b61017161016c366004612d4c565b610dc4565b604051908152602001610109565b61019261018d366004612d8d565b610f39565b604080519485526001600160801b039093166020850152918301526060820152608001610109565b6101cd6101c8366004612dc8565b611003565b604080516001600160801b039094168452602084019290925290820152606001610109565b3480156101fe57600080fd5b506101467f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8881565b34801561023257600080fd5b506101467f000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff81565b34801561026657600080fd5b506100cd610275366004612e03565b611100565b6000336001600160a01b037f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8816146102c557604051630d348b9b60e41b815260040160405180910390fd5b306001600160a01b038616036102ee57604051632797715160e01b815260040160405180910390fd5b60006102fc83850185613001565b905060008060007f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03166399fbab88896040518263ffffffff1660e01b815260040161035191815260200190565b61018060405180830381865afa15801561036f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103939190613231565b505050509750505050945094505050600080856101e001516001600160801b03166000146103e0576103da8a876101e0015188610240015189604001518a606001516111a7565b90925090505b6104798a86866001600160801b0380168a61014001516001600160801b03161461042b576104268a61014001516001600160801b0316876104219190613328565b6112a3565b610434565b6001600160801b035b6101608b01516001600160801b039081161461046c576104678b61016001516001600160801b0316876104219190613328565b611315565b6001600160801b03611315565b6080880151919350915082108061049357508560e0015181105b156104b157604051634ff64a9f60e01b815260040160405180910390fd5b6002865160028111156104c6576104c6613340565b0361078557846001600160a01b031686602001516001600160a01b0316036105a75761059b604051806101c001604052808c81526020018481526020018381526020018861026001516001600160a01b031681526020018861024001518152602001866001600160a01b031681526020018860e00151815260200188610100015181526020018861012001518152602001600081526020016000815260200160405180602001604052806000815250815260200188610200015181526020018861022001518152508686896102a0015161160b565b91945092509050610734565b836001600160a01b031686602001516001600160a01b0316036106755761059b604051806101c001604052808c81526020018481526020018381526020018861026001516001600160a01b031681526020018861024001518152602001876001600160a01b031681526020016000815260200160008152602001604051806020016040528060008152508152602001886080015181526020018860a0015181526020018860c00151815260200188610200015181526020018861022001518152508686896102a0015161160b565b61072c604051806101c001604052808c81526020018481526020018381526020018861026001516001600160a01b03168152602001886102400151815260200160006001600160a01b031681526020016000815260200160008152602001604051806020016040528060008152508152602001600081526020016000815260200160405180602001604052806000815250815260200188610200015181526020018861022001518152508686896102a0015161160b565b919450925090505b604080516001600160801b0385168152602081018490529081018290528a907faede78842f79342b251fe687b26b9f00d35eec5b0d21d44c283dd01a5ad7c1369060600160405180910390a2610d23565b60008651600281111561079a5761079a613340565b03610b6c576000856001600160a01b031687602001516001600160a01b0316036108de576108d2604051806102800160405280886001600160a01b03168152602001876001600160a01b0316815260200189610180015162ffffff168152602001896101a0015160020b8152602001896101c0015160020b81526020018581526020018481526020018961026001516001600160a01b031681526020018961028001516001600160a01b031681526020018961024001518152602001876001600160a01b031681526020018960e00151815260200189610100015181526020018961012001518152602001600081526020016000815260200160405180602001604052806000815250815260200189610200015181526020018961022001518152602001896102e00151815250886102a001516118b1565b50919250610b2c915050565b846001600160a01b031687602001516001600160a01b031603610a0d576108d2604051806102800160405280886001600160a01b03168152602001876001600160a01b0316815260200189610180015162ffffff168152602001896101a0015160020b8152602001896101c0015160020b81526020018581526020018481526020018961026001516001600160a01b031681526020018961028001516001600160a01b031681526020018961024001518152602001886001600160a01b031681526020016000815260200160008152602001604051806020016040528060008152508152602001896080015181526020018960a0015181526020018960c00151815260200189610200015181526020018961022001518152602001896102e00151815250886102a001516118b1565b610b25604051806102800160405280886001600160a01b03168152602001876001600160a01b0316815260200189610180015162ffffff168152602001896101a0015160020b8152602001896101c0015160020b81526020018581526020018481526020018961026001516001600160a01b031681526020018961028001516001600160a01b03168152602001896102400151815260200160006001600160a01b031681526020016000815260200160008152602001604051806020016040528060008152508152602001600081526020016000815260200160405180602001604052806000815250815260200189610200015181526020018961022001518152602001896102e00151815250886102a001516118b1565b5091925050505b8a7f2d3b242342e1e892c96167e80cea1f82a3961348e1576320d5e93deaa75d368982604051610b5e91815260200190565b60405180910390a250610d23565b600186516002811115610b8157610b81613340565b03610d0a57600086602001516001600160a01b0316866001600160a01b031614610c0057600080610bc1888a60200151878c60a001518d60c00151611afd565b9150915084821015610bed57610260890151610bed9089610be28589613356565b8c6102a00151611e4e565b610bf78184613328565b92505050610c0d565b610c0a8382613328565b90505b86602001516001600160a01b0316856001600160a01b031614610c7c57600080610c48878a60200151868c61010001518d6101200151611afd565b9150915083821015610c6957610260890151610c699088610be28588613356565b610c738184613328565b92505050610c89565b610c868282613328565b90505b8015801590610ca4575060208701516001600160a01b031615155b15610cc357610cc38761026001518860200151838a6102a00151611e4e565b602080880151604080516001600160a01b0390921682529181018390528c917ff8aacb16b34d229aa53d44a7759a3741b5c098e099666e51a4ae9d66a5956c439101610b5e565b60405163290db76760e01b815260040160405180910390fd5b7f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663b88d4fde308d8d8a6102c001516040518563ffffffff1660e01b8152600401610d7a94939291906133c5565b600060405180830381600087803b158015610d9457600080fd5b505af1158015610da8573d6000803e3d6000fd5b50630a85bd0160e11b9f9e505050505050505050505050505050565b6000610dd66040830160208401613402565b6001600160a01b0316610dec6020840184613402565b6001600160a01b031603610e135760405163100dac0560e11b815260040160405180910390fd5b610e33610e236020840184613402565b6000808560400135600080611f96565b6000610ea6610e456020850185613402565b610e556040860160208701613402565b60408601356060870135610e6c60a089018961341f565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611afd92505050565b925090508115610ee957610ee9610ec360a0850160808601613402565b610ed36040860160208701613402565b84610ee460e0880160c08901613465565b611e4e565b6000610ef9826040860135613356565b90508015610f3257610f32610f1460a0860160808701613402565b610f216020870187613402565b83610ee460e0890160c08a01613465565b5050919050565b6000808080610f4e6040860160208701613402565b6001600160a01b0316610f646020870187613402565b6001600160a01b031603610f8b5760405163100dac0560e11b815260040160405180910390fd5b610fe0610f9b6020870187613402565b610fab6040880160208901613402565b610fbd61016089016101408a01613402565b60a089013560c08a0135610fdb6101c08c01356101608d0135613328565b611f96565b610ff4610fec86613482565b3415156118b1565b92989197509550909350915050565b60405163133f757160e31b81528135600482015260009081908190819081906001600160a01b037f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8816906399fbab889060240161018060405180830381865afa158015611074573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110989190613231565b50505050505050509350935050506110db82828860a00160208101906110be9190613402565b60208a013560408b0135610fdb6101208d013560c08e0135613328565b6110f16110e78761360d565b838334151561160b565b91989097509095509350505050565b7f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663b88d4fde33308585604051602001611143919061379e565b6040516020818303038152906040526040518563ffffffff1660e01b815260040161117194939291906133c5565b600060405180830381600087803b15801561118b57600080fd5b505af115801561119f573d6000803e3d6000fd5b505050505050565b6000806001600160801b03861615611299576040805160a0810182528881526001600160801b038089166020830190815282840188815260608401888152608085018b81529551630624e65f60e11b8152945160048601529151909216602484015290516044830152516064820152905160848201526001600160a01b037f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe881690630c49ccbe9060a40160408051808303816000875af115801561126f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112939190613a1f565b90925090505b9550959350505050565b60006001600160801b038211156113115760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b60648201526084015b60405180910390fd5b5090565b6040516370a0823160e01b8152306004820152600090819081906001600160a01b038816906370a0823190602401602060405180830381865afa158015611360573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113849190613a43565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038816906370a0823190602401602060405180830381865afa1580156113ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f29190613a43565b604080516080810182528b815230602082019081526001600160801b038a81168385019081528a821660608501908152945163fc6f786560e01b81529351600485015291516001600160a01b039081166024850152915181166044840152925190921660648201529192507f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88169063fc6f78659060840160408051808303816000875af11580156114a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114cb9190613a1f565b6040516370a0823160e01b815230600482015291955093506000906001600160a01b038a16906370a0823190602401602060405180830381865afa158015611517573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061153b9190613a43565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038a16906370a0823190602401602060405180830381865afa158015611585573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a99190613a43565b9050856115b68584613356565b146115d457604051638ad721cb60e01b815260040160405180910390fd5b846115df8483613356565b146115fd57604051638ad721cb60e01b815260040160405180910390fd5b505050509550959350505050565b60008060008060006117266040518061028001604052808a6001600160a01b03168152602001896001600160a01b03168152602001600062ffffff168152602001600060020b8152602001600060020b81526020018b6020015181526020018b6040015181526020018b606001516001600160a01b031681526020018b606001516001600160a01b031681526020018b6080015181526020018b60a001516001600160a01b031681526020018b60c0015181526020018b60e0015181526020018b610100015181526020018b610120015181526020018b610140015181526020018b610160015181526020018b610180015181526020018b6101a001518152602001604051806020016040528060008152508152508761251d565b9150915060006040518060c001604052808b6000015181526020018481526020018381526020018b610180015181526020018b6101a0015181526020018b6080015181525090507f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663219f5d17826040518263ffffffff1660e01b81526004016117f89190600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b6060604051808303816000875af1158015611817573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183b9190613a5c565b8c51604080516001600160801b0386168152602081018590529081018390529399509197509550907f1aa7d7662b161a8d4058004091e4c60474753d2f085db526dfb22da59838d0a79060600160405180910390a26118a48a606001518a8a86868a8a8e612823565b5050509450945094915050565b6000806000806000806118c4888861251d565b9150915060006040518061016001604052808a600001516001600160a01b031681526020018a602001516001600160a01b031681526020018a6040015162ffffff1681526020018a6060015160020b81526020018a6080015160020b81526020018481526020018381526020018a610220015181526020018a61024001518152602001306001600160a01b031681526020018a610120015181525090507f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03166388316456826040518263ffffffff1660e01b81526004016119ad9190613a93565b6080604051808303816000875af11580156119cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f09190613b57565b6101008d01516102608e0151604051635c46a7ef60e11b8152959c50939a5091985096506001600160a01b037f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88169263b88d4fde92611a5792309290918d916004016133c5565b600060405180830381600087803b158015611a7157600080fd5b505af1158015611a85573d6000803e3d6000fd5b5050604080516001600160801b038a168152602081018990529081018790528992507fdbed0571af71402c681d3b0a1f08d80aa2245c9adb30e12d215356c7a274fcf9915060600160405180910390a2611af18960e001518a600001518b6020015186868a8a8f612823565b50505092959194509250565b6000808415801590611b0f5750825115155b8015611b2357506001600160a01b03861615155b15611299576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa158015611b6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b939190613a43565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038916906370a0823190602401602060405180830381865afa158015611bdd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c019190613a43565b905060008086806020019051810190611c1a9190613b95565b91509150611c298b838b61286f565b60007f000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff6001600160a01b031682604051611c639190613c21565b6000604051808303816000865af19150503d8060008114611ca0576040519150601f19603f3d011682016040523d82523d6000602084013e611ca5565b606091505b5050905080611cc75760405163081ceff360e41b815260040160405180910390fd5b611cd38c84600061286f565b6040516370a0823160e01b81523060048201526000906001600160a01b038e16906370a0823190602401602060405180830381865afa158015611d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3e9190613a43565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038e16906370a0823190602401602060405180830381865afa158015611d88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dac9190613a43565b9050611db88288613356565b9850611dc48682613356565b97508a881015611de757604051630d4205a160e11b815260040160405180910390fd5b8c6001600160a01b03168e6001600160a01b03167ffa2dda1cc1b86e41239702756b13effbc1a092b5c57e3ad320fbe4f3b13fe2358b8b604051611e35929190918252602082015260400190565b60405180910390a3505050505050509550959350505050565b826001600160a01b03167f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316148015611e8c5750805b15611f8557604051632e1a7d4d60e01b8152600481018390527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015611ef357600080fd5b505af1158015611f07573d6000803e3d6000fd5b505050506000846001600160a01b03168360405160006040518083038185875af1925050503d8060008114611f58576040519150601f19603f3d011682016040523d82523d6000602084013e611f5d565b606091505b5050905080611f7f57604051637cd69c3960e11b815260040160405180910390fd5b50611f90565b611f908385846129bc565b50505050565b600080803415612148577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015611ffb57600080fd5b505af115801561200f573d6000803e3d6000fd5b5050505050886001600160a01b03167f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316036120765734925085831115612071576040516307e205e160e41b815260040160405180910390fd5b612148565b876001600160a01b03167f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316036120d35734915084821115612071576040516307e205e160e41b815260040160405180910390fd5b866001600160a01b03167f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03160361212f57503483811115612071576040516307e205e160e41b815260040160405180910390fd5b6040516392b0337360e01b815260040160405180910390fd5b82861115612274576040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa158015612197573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121bb9190613a43565b90506121d28a33306121cd888c613356565b6129ec565b6040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015612219573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061223d9190613a43565b90506122498589613356565b6122538383613356565b14612271576040516313ff771f60e21b815260040160405180910390fd5b50505b8185111561239b576040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156122c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122e79190613a43565b90506122f98933306121cd878b613356565b6040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa158015612340573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123649190613a43565b90506123708488613356565b61237a8383613356565b14612398576040516313ff771f60e21b815260040160405180910390fd5b50505b80841180156123b257506001600160a01b03871615155b80156123d05750866001600160a01b0316896001600160a01b031614155b80156123ee5750866001600160a01b0316886001600160a01b031614155b15612512576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa15801561243a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061245e9190613a43565b90506124708833306121cd868a613356565b6040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156124b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124db9190613a43565b90506124e78387613356565b6124f18383613356565b1461250f576040516313ff771f60e21b815260040160405180910390fd5b50505b505050505050505050565b60008083600001516001600160a01b03168461014001516001600160a01b0316036125c257836101c001518460a00151101561256c57604051634ff64a9f60e01b815260040160405180910390fd5b60008061259386600001518760200151886101c00151896101e001518a6102000151611afd565b91509150818660a001516125a79190613356565b9350808660c001516125b99190613328565b92505050612756565b83602001516001600160a01b03168461014001516001600160a01b031603612664578361016001518460c00151101561260e57604051634ff64a9f60e01b815260040160405180910390fd5b600080612635866020015187600001518861016001518961018001518a6101a00151611afd565b91509150818660c001516126499190613356565b9250808660a0015161265b9190613328565b93505050612756565b6101408401516001600160a01b031615612749576000806126a086610140015187600001518861016001518961018001518a6101a00151611afd565b915091506000806126cc88610140015189602001518a6101c001518b6101e001518c6102000151611afd565b91509150828860a001516126e09190613328565b9550808860c001516126f29190613328565b9450600082858a6101c001518b610160015161270e9190613328565b6127189190613356565b6127229190613356565b9050801561273f5761273f8960e001518a6101400151838b611e4e565b5050505050612756565b505060a082015160c08301515b81156127b757835161278a907f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88600061286f565b83516127b7907f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe888461286f565b801561281c576127ed84602001517f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88600061286f565b61281c84602001517f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe888361286f565b9250929050565b600061282f8487613356565b9050600061283d8487613356565b90508115612851576128518a8a8486611e4e565b8015612863576128638a898386611e4e565b50505050505050505050565b8015806128e95750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa1580156128c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128e79190613a43565b155b6129545760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401611308565b6040516001600160a01b0383166024820152604481018290526129b790849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a24565b505050565b6040516001600160a01b0383166024820152604481018290526129b790849063a9059cbb60e01b90606401612980565b6040516001600160a01b0380851660248301528316604482015260648101829052611f909085906323b872dd60e01b90608401612980565b6000612a79826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612af69092919063ffffffff16565b8051909150156129b75780806020019051810190612a979190613c3d565b6129b75760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401611308565b6060612b058484600085612b0d565b949350505050565b606082471015612b6e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401611308565b600080866001600160a01b03168587604051612b8a9190613c21565b60006040518083038185875af1925050503d8060008114612bc7576040519150601f19603f3d011682016040523d82523d6000602084013e612bcc565b606091505b5091509150612bdd87838387612be8565b979650505050505050565b60608315612c57578251600003612c50576001600160a01b0385163b612c505760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611308565b5081612b05565b612b058383815115612c6c5781518083602001fd5b8060405162461bcd60e51b81526004016113089190613c5a565b6001600160a01b0381168114612c9b57600080fd5b50565b8035612ca981612c86565b919050565b600080600080600060808688031215612cc657600080fd5b8535612cd181612c86565b94506020860135612ce181612c86565b93506040860135925060608601356001600160401b0380821115612d0457600080fd5b818801915088601f830112612d1857600080fd5b813581811115612d2757600080fd5b896020828501011115612d3957600080fd5b9699959850939650602001949392505050565b600060208284031215612d5e57600080fd5b81356001600160401b03811115612d7457600080fd5b820160e08185031215612d8657600080fd5b9392505050565b600060208284031215612d9f57600080fd5b81356001600160401b03811115612db557600080fd5b82016102808185031215612d8657600080fd5b600060208284031215612dda57600080fd5b81356001600160401b03811115612df057600080fd5b82016101c08185031215612d8657600080fd5b60008060408385031215612e1657600080fd5b8235915060208301356001600160401b03811115612e3357600080fd5b83016103008186031215612e4657600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60405161030081016001600160401b0381118282101715612e8a57612e8a612e51565b60405290565b60405161028081016001600160401b0381118282101715612e8a57612e8a612e51565b6040516101c081016001600160401b0381118282101715612e8a57612e8a612e51565b604051601f8201601f191681016001600160401b0381118282101715612efe57612efe612e51565b604052919050565b803560038110612ca957600080fd5b60006001600160401b03821115612f2e57612f2e612e51565b50601f01601f191660200190565b600082601f830112612f4d57600080fd5b8135612f60612f5b82612f15565b612ed6565b818152846020838601011115612f7557600080fd5b816020850160208301376000918101602001919091529392505050565b6001600160801b0381168114612c9b57600080fd5b8035612ca981612f92565b62ffffff81168114612c9b57600080fd5b8035612ca981612fb2565b8060020b8114612c9b57600080fd5b8035612ca981612fce565b8015158114612c9b57600080fd5b8035612ca981612fe8565b60006020828403121561301357600080fd5b81356001600160401b038082111561302a57600080fd5b90830190610300828603121561303f57600080fd5b613047612e67565b61305083612f06565b815261305e60208401612c9e565b602082015260408301356040820152606083013560608201526080830135608082015260a083013560a082015260c08301358281111561309d57600080fd5b6130a987828601612f3c565b60c08301525060e083013560e082015261010080840135818301525061012080840135838111156130d957600080fd5b6130e588828701612f3c565b8284015250506101406130f9818501612fa7565b9082015261016061310b848201612fa7565b9082015261018061311d848201612fc3565b908201526101a061312f848201612fdd565b908201526101c0613141848201612fdd565b908201526101e0613153848201612fa7565b90820152610200838101359082015261022080840135908201526102408084013590820152610260613186818501612c9e565b90820152610280613198848201612c9e565b908201526102a06131aa848201612ff6565b908201526102c083810135838111156131c257600080fd5b6131ce88828701612f3c565b8284015250506102e080840135838111156131e857600080fd5b6131f488828701612f3c565b918301919091525095945050505050565b8051612ca981612c86565b8051612ca981612fb2565b8051612ca981612fce565b8051612ca981612f92565b6000806000806000806000806000806000806101808d8f03121561325457600080fd5b8c516bffffffffffffffffffffffff8116811461327057600080fd5b9b5061327e60208e01613205565b9a5061328c60408e01613205565b995061329a60608e01613205565b98506132a860808e01613210565b97506132b660a08e0161321b565b96506132c460c08e0161321b565b95506132d260e08e01613226565b94506101008d015193506101208d015192506132f16101408e01613226565b91506133006101608e01613226565b90509295989b509295989b509295989b565b634e487b7160e01b600052601160045260246000fd5b6000821982111561333b5761333b613312565b500190565b634e487b7160e01b600052602160045260246000fd5b60008282101561336857613368613312565b500390565b60005b83811015613388578181015183820152602001613370565b83811115611f905750506000910152565b600081518084526133b181602086016020860161336d565b601f01601f19169290920160200192915050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906133f890830184613399565b9695505050505050565b60006020828403121561341457600080fd5b8135612d8681612c86565b6000808335601e1984360301811261343657600080fd5b8301803591506001600160401b0382111561345057600080fd5b60200191503681900382131561281c57600080fd5b60006020828403121561347757600080fd5b8135612d8681612fe8565b6000610280823603121561349557600080fd5b61349d612e90565b6134a683612c9e565b81526134b460208401612c9e565b60208201526134c560408401612fc3565b60408201526134d660608401612fdd565b60608201526134e760808401612fdd565b608082015260a083013560a082015260c083013560c082015261350c60e08401612c9e565b60e082015261010061351f818501612c9e565b90820152610120838101359082015261014061353c818501612c9e565b90820152610160838101359082015261018080840135908201526101a0808401356001600160401b038082111561357257600080fd5b61357e36838801612f3c565b92840192909252506101c084810135908301526101e08085013590830152610200908185013590808211156135b257600080fd5b6135be36838801612f3c565b928401929092525061022084810135908301526102408085013590830152610260908185013590808211156135f257600080fd5b506135ff36828701612f3c565b918301919091525092915050565b60006101c0823603121561362057600080fd5b613628612eb3565b82358152602083013560208201526040830135604082015261364c60608401612c9e565b60608201526080830135608082015261366760a08401612c9e565b60a082015260c083013560c082015260e083013560e0820152610100808401356001600160401b038082111561369c57600080fd5b6136a836838801612f3c565b928401929092525061012084810135908301526101408085013590830152610160908185013590808211156136dc57600080fd5b506136e936828701612f3c565b918301919091525061018083810135908201526101a092830135928101929092525090565b6003811061372c57634e487b7160e01b600052602160045260246000fd5b9052565b6000808335601e1984360301811261374757600080fd5b83016020810192503590506001600160401b0381111561376657600080fd5b80360382131561281c57600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b602081526137b7602082016137b284612f06565b61370e565b60006137c560208401612c9e565b6001600160a01b0381166040840152506040830135606083015260608301356080830152608083013560a083015260a083013560c083015261380a60c0840184613730565b6103008060e086015261382261032086018385613775565b9250610100915060e086013582860152610120828701358187015261384981880188613730565b93509050601f19610140818887030181890152613867868685613775565b9550613874818a01612fa7565b9450506101609150613890828801856001600160801b03169052565b61389b828901612fa7565b935061018091506138b6828801856001600160801b03169052565b6138c1828901612fc3565b93506101a091506138d88288018562ffffff169052565b6138e3828901612fdd565b93506101c091506138f88288018560020b9052565b613903828901612fdd565b93506101e091506139188288018560020b9052565b613923828901612fa7565b9350610200915061393e828801856001600160801b03169052565b610220935081880135848801526102409150838801358288015261026093508188013584880152613970848901612c9e565b9350610280915061398b828801856001600160a01b03169052565b613996828901612c9e565b93506102a091506139b1828801856001600160a01b03169052565b6139bc828901612ff6565b93506102c091506139d08288018515159052565b6139dc82890189613730565b945091506102e08188870301818901526139f7868685613775565b9550613a05818a018a613730565b955092505080878603018388015250612bdd848483613775565b60008060408385031215613a3257600080fd5b505080516020909101519092909150565b600060208284031215613a5557600080fd5b5051919050565b600080600060608486031215613a7157600080fd5b8351613a7c81612f92565b602085015160409095015190969495509392505050565b81516001600160a01b0316815261016081016020830151613abf60208401826001600160a01b03169052565b506040830151613ad6604084018262ffffff169052565b506060830151613aeb606084018260020b9052565b506080830151613b00608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151613b46828501826001600160a01b03169052565b505061014092830151919092015290565b60008060008060808587031215613b6d57600080fd5b845193506020850151613b7f81612f92565b6040860151606090960151949790965092505050565b60008060408385031215613ba857600080fd5b8251613bb381612c86565b60208401519092506001600160401b03811115613bcf57600080fd5b8301601f81018513613be057600080fd5b8051613bee612f5b82612f15565b818152866020838501011115613c0357600080fd5b613c1482602083016020860161336d565b8093505050509250929050565b60008251613c3381846020870161336d565b9190910192915050565b600060208284031215613c4f57600080fd5b8151612d8681612fe8565b602081526000612d86602083018461339956fea2646970667358221220c072501aac47d4a97ed9183371fc88459c2cc11cda8d18c0d8f34622181a701664736f6c634300080f0033

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

000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff

-----Decoded View---------------
Arg [0] : _nonfungiblePositionManager (address): 0xC36442b4a4522E871399CD717aBDD847Ab11FE88
Arg [1] : _swapRouter (address): 0xDef1C0ded9bec7F1a1670819833240f027b25EfF

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88
Arg [1] : 000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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