ETH Price: $3,552.34 (-1.21%)

Contract

0xEA1C03B4DA9bb959C3eEf4E11C5b11338C157726
 

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
Swap And Mint35743812024-05-17 15:09:3731 days ago1715958577IN
0xEA1C03B4...38C157726
0 ETH0.000019520.0208856
Swap And Mint32648572024-05-10 11:12:0938 days ago1715339529IN
0xEA1C03B4...38C157726
0.32 ETH0.000009190.00998768
Swap And Increas...31790932024-05-08 11:33:2140 days ago1715168001IN
0xEA1C03B4...38C157726
0 ETH0.000016920.0212343

Latest 4 internal transactions

Advanced mode:
Parent Transaction Hash Block From To Value
35536872024-05-17 3:39:4931 days ago1715917189
0xEA1C03B4...38C157726
0.41030339 ETH
35536872024-05-17 3:39:4931 days ago1715917189
0xEA1C03B4...38C157726
0.41030339 ETH
32648572024-05-10 11:12:0938 days ago1715339529
0xEA1C03B4...38C157726
0.32 ETH
29559362024-05-03 7:34:4745 days ago1714721687  Contract Creation0 ETH

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
V3Utils

Compiler Version
v0.8.23+commit.f704f362

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 21 : V3Utils.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "v3-periphery/interfaces/INonfungiblePositionManager.sol" as univ3;
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";
import "@openzeppelin/contracts/utils/Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

interface INonfungiblePositionManager is univ3.INonfungiblePositionManager {
    /// @notice mintParams for algebra v1
    struct AlgebraV1MintParams {
        address token0;
        address token1;
        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(AlgebraV1MintParams calldata params)
        external
        payable
        returns (
            uint256 tokenId,
            uint128 liquidity,
            uint256 amount0,
            uint256 amount1
        );

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

/// @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, Pausable, Ownable {

    using SafeCast for uint256;

    /// @notice Krystal 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(address indexed nfpm, uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    event ChangeRange(address indexed nfpm, uint256 indexed tokenId, uint256 newTokenId);
    event WithdrawAndCollectAndSwap(address indexed nfpm, uint256 indexed tokenId, address token, uint256 amount);
    event Swap(address indexed tokenIn, address indexed tokenOut, uint256 amountIn, uint256 amountOut);
    event SwapAndMint(address indexed nfpm, uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    event SwapAndIncreaseLiquidity(address indexed nfpm, uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);

    /// @notice Constructor
    /// @param _swapRouter Krystal Exchange Proxy
    constructor(address _swapRouter, address initialOwner) Ownable(initialOwner) {
        swapRouter = _swapRouter;
    }

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

    /// @notice protocol to provide lp
    enum Protocol {
        UNI_V3,
        ALGEBRA_V1
    }

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

        // protocol to provide lp
        Protocol protocol;

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

    struct ReturnLeftoverTokensParams{
        IWETH9 weth;
        address to;
        IERC20 token0;
        IERC20 token1;
        uint256 total0;
        uint256 total1;
        uint256 added0;
        uint256 added1;
        bool unwrap;
    }

    /// @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(INonfungiblePositionManager _nfpm, uint256 tokenId, Instructions calldata instructions)  whenNotPaused() external
    {
        // must be approved beforehand
        _nfpm.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)  whenNotPaused() external override returns (bytes4) {

        INonfungiblePositionManager nfpm = INonfungiblePositionManager(msg.sender);
        // 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) = _getPosition(nfpm, instructions.protocol, tokenId);

        uint256 amount0;
        uint256 amount1;
        if (instructions.liquidity != 0) {
            (amount0, amount1) = _decreaseLiquidity(nfpm, tokenId, instructions.liquidity, instructions.deadline, instructions.amountRemoveMin0, instructions.amountRemoveMin1);
        }
        (amount0, amount1) = _collectFees(nfpm, 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(instructions.protocol, nfpm, 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(instructions.protocol, nfpm, 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(instructions.protocol, nfpm, 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(address(nfpm), tokenId, liquidity, amount0, amount1);            
        } else if (instructions.whatToDo == WhatToDo.CHANGE_RANGE) {

            uint256 newTokenId;

            if (instructions.targetToken == token0) {
                (newTokenId,,,) = _swapAndMint(SwapAndMintParams(instructions.protocol, nfpm, 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(instructions.protocol, nfpm, 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(instructions.protocol, nfpm, 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(address(nfpm), tokenId, newTokenId);
        } else if (instructions.whatToDo == WhatToDo.WITHDRAW_AND_COLLECT_AND_SWAP) {
            IWETH9 weth = _getWeth9(nfpm, instructions.protocol);
            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(weth, 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(weth, 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(weth, instructions.recipient, IERC20(instructions.targetToken), targetAmount, instructions.unwrap);
            }

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

        return IERC721Receiver.onERC721Received.selector;
    }

    /// @notice Params for swap() function
    struct SwapParams {
        IWETH9 weth;
        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)  whenNotPaused() external payable returns (uint256 amountOut) {

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

        _prepareAdd(params.weth, 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.weth, 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.weth, params.recipient, params.tokenIn, leftOver, params.unwrap);
        }
    }

    /// @notice Params for swapAndMint() function
    struct SwapAndMintParams {
        Protocol protocol;
        INonfungiblePositionManager nfpm;

        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)  whenNotPaused() external payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1) {
        if (params.token0 == params.token1) {
            revert SameToken();
        }
        IWETH9 weth = _getWeth9(params.nfpm, params.protocol);
        _prepareAdd(weth, 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 {
        Protocol protocol;
        INonfungiblePositionManager nfpm;
        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)  whenNotPaused() external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1) {
        address owner = params.nfpm.ownerOf(params.tokenId);
        require(owner == msg.sender, "sender is not owner of position");
        (address token0,address token1,) = _getPosition(params.nfpm, params.protocol, params.tokenId);
        IWETH9 weth = _getWeth9(params.nfpm, params.protocol);
        _prepareAdd(weth, 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(IWETH9 weth, 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);
        IWETH9 weth;
        if (params.protocol == Protocol.UNI_V3) {
            // mint is done to address(this) because it is not a safemint and safeTransferFrom needs to be done manually afterwards
            (tokenId,liquidity,added0,added1) = _mintUniv3(params, total0, total1);
            weth = IWETH9(params.nfpm.WETH9());
        } else if (params.protocol == Protocol.ALGEBRA_V1) {
            // mint is done to address(this) because it is not a safemint and safeTransferFrom needs to be done manually afterwards
            (tokenId,liquidity,added0,added1) = _mintAlgebraV1(params, total0, total1);
            weth = IWETH9(params.nfpm.WNativeToken());
        } else {
            revert("Invalid protocol");
        }
        params.nfpm.safeTransferFrom(address(this), params.recipientNFT, tokenId, params.returnData);
        emit SwapAndMint(address(params.nfpm), tokenId, liquidity, added0, added1);

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

    function _mintUniv3(SwapAndMintParams memory params, uint256 total0, uint256 total1) internal returns (
        uint256 tokenId,
        uint128 liquidity,
        uint256 amount0,
        uint256 amount1
    ) {
        INonfungiblePositionManager.MintParams memory mintParams = 
            univ3.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
        return params.nfpm.mint(mintParams);
    }

    function _mintAlgebraV1(SwapAndMintParams memory params, uint256 total0, uint256 total1) internal returns (
        uint256 tokenId,
        uint128 liquidity,
        uint256 amount0,
        uint256 amount1
    ) {
        INonfungiblePositionManager.AlgebraV1MintParams memory mintParams = 
            INonfungiblePositionManager.AlgebraV1MintParams(
                address(params.token0), 
                address(params.token1), 
                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
        return params.nfpm.mint(mintParams);
    }

    // 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(params.protocol, params.nfpm, 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 = 
            univ3.INonfungiblePositionManager.IncreaseLiquidityParams(
                params.tokenId, 
                total0, 
                total1, 
                params.amountAddMin0,
                params.amountAddMin1, 
                params.deadline
            );

        (liquidity, added0, added1) = params.nfpm.increaseLiquidity(increaseLiquidityParams);

        emit SwapAndIncreaseLiquidity(address(params.nfpm), params.tokenId, liquidity, added0, added1);
        IWETH9 weth = _getWeth9(params.nfpm, params.protocol);
        _returnLeftoverTokens(ReturnLeftoverTokensParams(weth, params.recipient, token0, token1, total0, total1, added0, added1, unwrap));
    }

    // swaps available tokens and prepares max amounts to be added to nfpm
    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) {
                IWETH9 weth = _getWeth9(params.nfpm, params.protocol);
                _transferToken(weth, params.recipient, params.swapSourceToken, leftOver, unwrap);
            }
        } else {
            total0 = params.amount0;
            total1 = params.amount1;
        }

        if (total0 != 0) {
            params.token0.approve(address(params.nfpm), total0);
        }
        if (total1 != 0) {
            params.token1.approve(address(params.nfpm), total1);
        }
    }

    // returns leftover token balances
    // viewed
    function _returnLeftoverTokens(ReturnLeftoverTokensParams memory params) internal {

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

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

    // transfers token (or unwraps WETH and sends ETH)
    // viewed
    function _transferToken(IWETH9 weth, 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));

            // approve needed amount
            tokenIn.approve(swapRouter, amountIn);
            // execute swap
            (bool success,) = swapRouter.call(swapData);
            if (!success) {
                revert SwapFailed();
            }

            // reset approval
            tokenIn.approve(swapRouter, 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
    // viewed
    function _decreaseLiquidity(INonfungiblePositionManager nfpm, uint256 tokenId, uint128 liquidity, uint256 deadline, uint256 token0Min, uint256 token1Min) internal returns (uint256 amount0, uint256 amount1) {
        if (liquidity != 0) {
            (amount0, amount1) = nfpm.decreaseLiquidity(
                univ3.INonfungiblePositionManager.DecreaseLiquidityParams(
                    tokenId, 
                    liquidity, 
                    token0Min, 
                    token1Min,
                    deadline
                )
            );
        }
    }

    // collects specified amount of fees from uniswap v3 position
    // viewed
    function _collectFees(INonfungiblePositionManager nfpm, 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) = nfpm.collect(
            univ3.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();
        }
    }

    function _getWeth9(INonfungiblePositionManager nfpm, Protocol protocol) view internal returns (IWETH9 weth) {
        if (protocol == Protocol.UNI_V3) {
            weth = IWETH9(nfpm.WETH9());
        } else if (protocol == Protocol.ALGEBRA_V1) {
            weth = IWETH9(nfpm.WNativeToken());
        } else {
            revert("invalid protocol");
        }
    }

    function _getPosition(INonfungiblePositionManager nfpm, Protocol protocol, uint256 tokenId) internal returns (address token0, address token1, uint128 liquidity) {
        (bool success, bytes memory data) = address(nfpm).call(abi.encodeWithSignature("positions(uint256)", tokenId));
        if (!success) {
            revert("v3utils: call get position failed");
        }
        if (protocol == Protocol.UNI_V3) {
            (,, token0, token1,,,, liquidity,,,,) = abi.decode(data, (uint96,address,address,address,uint24,int24,int24,uint128,uint256,uint256,uint128,uint128));
        } else if (protocol == Protocol.ALGEBRA_V1) {
            (,, token0, token1,,, liquidity,,,,) = abi.decode(data, (uint96,address,address,address,int24,int24,uint128,uint256,uint256,uint128,uint128));
        }
    }

    /**
     * @notice Withdraws erc20 token balance
     * @param tokens Addresses of erc20 tokens to withdraw
     * @param to Address to send to
     */
    function withdrawERC20(IERC20[] calldata tokens, address to) external onlyOwner {
        uint count = tokens.length;
        for(uint i = 0; i < count; ++i) {
            uint256 balance = tokens[i].balanceOf(address(this));
            if (balance > 0) {
                SafeERC20.safeTransfer(tokens[i], to, balance);
            }
        }
    }

    /**
     * @notice Withdraws native token balance
     * @param to Address to send to
     */
    function withdrawNative(address to) external onlyOwner {
        uint256 nativeBalance = address(this).balance;
        if (nativeBalance > 0) {
            payable(to).transfer(nativeBalance);
        }
    }

    /**
     * @notice Withdraws erc721 token balance
     * @param nfpm Addresses of erc721 tokens to withdraw
     * @param tokenId tokenId of erc721 tokens to withdraw
     * @param to Address to send to
     */
    function withdrawERC721(INonfungiblePositionManager nfpm, uint256 tokenId, address to) external onlyOwner {
        nfpm.transferFrom(address(this), to, tokenId);
    }

    function pause() public onlyOwner {
        _pause();
    }

    function unpause() public onlyOwner {
        _unpause();
    }

    // needed for WETH unwrapping
    receive() external payable{}
}

File 2 of 21 : 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 3 of 21 : 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 4 of 21 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 5 of 21 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.20;

/**
 * @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 6 of 21 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.20;

/**
 * @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.
 */
library SafeCast {
    /**
     * @dev Value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);

    /**
     * @dev An int value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedIntToUint(int256 value);

    /**
     * @dev Value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);

    /**
     * @dev An uint value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedUintToInt(uint256 value);

    /**
     * @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
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        if (value > type(uint248).max) {
            revert SafeCastOverflowedUintDowncast(248, value);
        }
        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
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        if (value > type(uint240).max) {
            revert SafeCastOverflowedUintDowncast(240, value);
        }
        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
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        if (value > type(uint232).max) {
            revert SafeCastOverflowedUintDowncast(232, value);
        }
        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
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        if (value > type(uint224).max) {
            revert SafeCastOverflowedUintDowncast(224, value);
        }
        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
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        if (value > type(uint216).max) {
            revert SafeCastOverflowedUintDowncast(216, value);
        }
        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
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        if (value > type(uint208).max) {
            revert SafeCastOverflowedUintDowncast(208, value);
        }
        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
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        if (value > type(uint200).max) {
            revert SafeCastOverflowedUintDowncast(200, value);
        }
        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
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        if (value > type(uint192).max) {
            revert SafeCastOverflowedUintDowncast(192, value);
        }
        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
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        if (value > type(uint184).max) {
            revert SafeCastOverflowedUintDowncast(184, value);
        }
        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
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        if (value > type(uint176).max) {
            revert SafeCastOverflowedUintDowncast(176, value);
        }
        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
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        if (value > type(uint168).max) {
            revert SafeCastOverflowedUintDowncast(168, value);
        }
        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
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        if (value > type(uint160).max) {
            revert SafeCastOverflowedUintDowncast(160, value);
        }
        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
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        if (value > type(uint152).max) {
            revert SafeCastOverflowedUintDowncast(152, value);
        }
        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
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        if (value > type(uint144).max) {
            revert SafeCastOverflowedUintDowncast(144, value);
        }
        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
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        if (value > type(uint136).max) {
            revert SafeCastOverflowedUintDowncast(136, value);
        }
        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
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        if (value > type(uint128).max) {
            revert SafeCastOverflowedUintDowncast(128, value);
        }
        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
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        if (value > type(uint120).max) {
            revert SafeCastOverflowedUintDowncast(120, value);
        }
        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
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        if (value > type(uint112).max) {
            revert SafeCastOverflowedUintDowncast(112, value);
        }
        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
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        if (value > type(uint104).max) {
            revert SafeCastOverflowedUintDowncast(104, value);
        }
        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
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        if (value > type(uint96).max) {
            revert SafeCastOverflowedUintDowncast(96, value);
        }
        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
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        if (value > type(uint88).max) {
            revert SafeCastOverflowedUintDowncast(88, value);
        }
        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
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        if (value > type(uint80).max) {
            revert SafeCastOverflowedUintDowncast(80, value);
        }
        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
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        if (value > type(uint72).max) {
            revert SafeCastOverflowedUintDowncast(72, value);
        }
        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
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        if (value > type(uint64).max) {
            revert SafeCastOverflowedUintDowncast(64, value);
        }
        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
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        if (value > type(uint56).max) {
            revert SafeCastOverflowedUintDowncast(56, value);
        }
        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
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        if (value > type(uint48).max) {
            revert SafeCastOverflowedUintDowncast(48, value);
        }
        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
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        if (value > type(uint40).max) {
            revert SafeCastOverflowedUintDowncast(40, value);
        }
        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
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        if (value > type(uint32).max) {
            revert SafeCastOverflowedUintDowncast(32, value);
        }
        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
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        if (value > type(uint24).max) {
            revert SafeCastOverflowedUintDowncast(24, value);
        }
        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
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        if (value > type(uint16).max) {
            revert SafeCastOverflowedUintDowncast(16, value);
        }
        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
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        if (value > type(uint8).max) {
            revert SafeCastOverflowedUintDowncast(8, value);
        }
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        if (value < 0) {
            revert SafeCastOverflowedIntToUint(value);
        }
        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
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(248, value);
        }
    }

    /**
     * @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
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(240, value);
        }
    }

    /**
     * @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
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(232, value);
        }
    }

    /**
     * @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
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(224, value);
        }
    }

    /**
     * @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
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(216, value);
        }
    }

    /**
     * @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
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(208, value);
        }
    }

    /**
     * @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
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(200, value);
        }
    }

    /**
     * @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
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(192, value);
        }
    }

    /**
     * @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
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(184, value);
        }
    }

    /**
     * @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
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(176, value);
        }
    }

    /**
     * @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
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(168, value);
        }
    }

    /**
     * @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
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(160, value);
        }
    }

    /**
     * @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
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(152, value);
        }
    }

    /**
     * @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
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(144, value);
        }
    }

    /**
     * @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
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(136, value);
        }
    }

    /**
     * @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
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(128, value);
        }
    }

    /**
     * @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
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(120, value);
        }
    }

    /**
     * @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
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(112, value);
        }
    }

    /**
     * @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
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(104, value);
        }
    }

    /**
     * @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
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(96, value);
        }
    }

    /**
     * @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
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(88, value);
        }
    }

    /**
     * @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
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(80, value);
        }
    }

    /**
     * @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
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(72, value);
        }
    }

    /**
     * @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
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(64, value);
        }
    }

    /**
     * @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
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(56, value);
        }
    }

    /**
     * @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
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(48, value);
        }
    }

    /**
     * @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
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(40, value);
        }
    }

    /**
     * @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
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(32, value);
        }
    }

    /**
     * @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
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(24, value);
        }
    }

    /**
     * @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
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(16, value);
        }
    }

    /**
     * @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
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(8, value);
        }
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        if (value > uint256(type(int256).max)) {
            revert SafeCastOverflowedUintToInt(value);
        }
        return int256(value);
    }
}

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

pragma solidity ^0.8.20;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    bool private _paused;

    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.20;

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

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

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

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

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

pragma solidity ^0.8.20;

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

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

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

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

File 11 of 21 : 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 12 of 21 : 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 21 : 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 14 of 21 : 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 21 : PoolAddress.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

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

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

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

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

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.20;

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

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

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

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.20;

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

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

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

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.20;

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_swapRouter","type":"address"},{"internalType":"address","name":"initialOwner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"AmountError","type":"error"},{"inputs":[],"name":"CollectError","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"EtherSendFailed","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"NoEtherToken","type":"error"},{"inputs":[],"name":"NotSupportedWhatToDo","type":"error"},{"inputs":[],"name":"NotWETH","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","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":"address","name":"nfpm","type":"address"},{"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":"address","name":"nfpm","type":"address"},{"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":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","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":"address","name":"nfpm","type":"address"},{"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":"address","name":"nfpm","type":"address"},{"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":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"nfpm","type":"address"},{"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":"contract INonfungiblePositionManager","name":"_nfpm","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"enum V3Utils.WhatToDo","name":"whatToDo","type":"uint8"},{"internalType":"enum V3Utils.Protocol","name":"protocol","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":[{"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":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"contract IWETH9","name":"weth","type":"address"},{"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":"enum V3Utils.Protocol","name":"protocol","type":"uint8"},{"internalType":"contract INonfungiblePositionManager","name":"nfpm","type":"address"},{"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":"enum V3Utils.Protocol","name":"protocol","type":"uint8"},{"internalType":"contract INonfungiblePositionManager","name":"nfpm","type":"address"},{"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":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20[]","name":"tokens","type":"address[]"},{"internalType":"address","name":"to","type":"address"}],"name":"withdrawERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract INonfungiblePositionManager","name":"nfpm","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"withdrawERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"withdrawNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a06040523480156200001157600080fd5b50604051620049ba380380620049ba833981016040819052620000349162000103565b6000805460ff19169055806001600160a01b0381166200006e57604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b62000079816200008d565b50506001600160a01b03166080526200013b565b600080546001600160a01b03838116610100818102610100600160a81b0319851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b80516001600160a01b0381168114620000fe57600080fd5b919050565b600080604083850312156200011757600080fd5b6200012283620000e6565b91506200013260208401620000e6565b90509250929050565b60805161484e6200016c600039600081816102f7015281816128970152818161291c01526129cd015261484e6000f3fe6080604052600436106100ec5760003560e01c8063603986f41161008a5780638456cb59116100595780638456cb59146102995780638da5cb5b146102ae578063c31c9c07146102e5578063f2fde38b1461031957600080fd5b8063603986f41461020b578063715018a61461024357806371c87886146102585780637b9f76b51461027957600080fd5b80632f622e6b116100c65780632f622e6b14610193578063340ed32a146101b35780633f4ba83a146101d35780635c975abb146101e857600080fd5b806301ccc877146100f85780630779185314610138578063150b7a021461015a57600080fd5b366100f357005b600080fd5b61010b610106366004613601565b610339565b604080519485526001600160801b0390931660208501529183015260608201526080015b60405180910390f35b34801561014457600080fd5b50610158610153366004613661565b61043e565b005b34801561016657600080fd5b5061017a6101753660046136c1565b6104ce565b6040516001600160e01b0319909116815260200161012f565b34801561019f57600080fd5b506101586101ae36600461375f565b61106a565b3480156101bf57600080fd5b506101586101ce36600461377c565b6110b5565b3480156101df57600080fd5b506101586111a5565b3480156101f457600080fd5b5060005460ff16604051901515815260200161012f565b61021e6102193660046137f6565b6111b7565b604080516001600160801b03909416845260208401929092529082015260600161012f565b34801561024f57600080fd5b5061015861135c565b61026b610266366004613831565b61136e565b60405190815260200161012f565b34801561028557600080fd5b5061015861029436600461386c565b611520565b3480156102a557600080fd5b50610158611563565b3480156102ba57600080fd5b5060005461010090046001600160a01b03165b6040516001600160a01b03909116815260200161012f565b3480156102f157600080fd5b506102cd7f000000000000000000000000000000000000000000000000000000000000000081565b34801561032557600080fd5b5061015861033436600461375f565b611573565b6000806000806103476115b1565b610357608086016060870161375f565b6001600160a01b0316610370606087016040880161375f565b6001600160a01b0316036103975760405163100dac0560e11b815260040160405180910390fd5b60006103be6103ac604088016020890161375f565b6103b960208901896138b2565b6115d5565b905061041a816103d46060890160408a0161375f565b6103e460808a0160608b0161375f565b6103f66101a08b016101808c0161375f565b60e08b01356101008c01356104156102008e01356101a08f01356138e3565b6116f0565b61042e61042687613a3d565b341515611bf8565b9299919850965090945092505050565b6104466115b1565b826001600160a01b031663b88d4fde333085856040516020016104699190613cdd565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016104979493929190613fa9565b600060405180830381600087803b1580156104b157600080fd5b505af11580156104c5573d6000803e3d6000fd5b50505050505050565b60006104d86115b1565b33306001600160a01b0387160361050257604051632797715160e01b815260040160405180910390fd5b600061051084860186613ffd565b905060008060006105268585602001518b611eb9565b9250925092506000808561020001516001600160801b031660001461056b57610565878c8861020001518961026001518a606001518b60800151612040565b90925090505b610605878c87876001600160801b0380168b61016001516001600160801b0316146105b7576105b28b61016001516001600160801b0316886105ad91906138e3565b61211d565b6105c0565b6001600160801b035b6101808c01516001600160801b03908116146105f8576105f38c61018001516001600160801b0316886105ad91906138e3565b612155565b6001600160801b03612155565b60a08801519193509150821080610620575085610100015181105b1561063e57604051634ff64a9f60e01b815260040160405180910390fd5b60028651600281111561065357610653613bfc565b0361099c57846001600160a01b031686604001516001600160a01b03160361075f576107536040518061020001604052808860200151600181111561069a5761069a613bfc565b8152602001896001600160a01b031681526020018d81526020018481526020018381526020018861028001516001600160a01b031681526020018861026001518152602001866001600160a01b03168152602001886101000151815260200188610120015181526020018861014001518152602001600081526020016000815260200160405180602001604052806000815250815260200188610220015181526020018861024001518152508686896102c0015161242c565b91945092509050610940565b836001600160a01b031686604001516001600160a01b03160361085757610753604051806102000160405280886020015160018111156107a1576107a1613bfc565b8152602001896001600160a01b031681526020018d81526020018481526020018381526020018861028001516001600160a01b031681526020018861026001518152602001876001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018860a0015181526020018860c0015181526020018860e00151815260200188610220015181526020018861024001518152508686896102c0015161242c565b6109386040518061020001604052808860200151600181111561087c5761087c613bfc565b8152602001896001600160a01b031681526020018d81526020018481526020018381526020018861028001516001600160a01b03168152602001886102600151815260200160006001600160a01b031681526020016000815260200160008152602001604051806020016040528060008152508152602001600081526020016000815260200160405180602001604052806000815250815260200188610220015181526020018861024001518152508686896102c0015161242c565b919450925090505b604080516001600160801b0385168152602081018490529081018290528b906001600160a01b038916907f4a3d983c4891bedb0622c5a26f90b626e9451fe3a832b73ed9c886f1aa489cda9060600160405180910390a3610fe7565b6000865160028111156109b1576109b1613bfc565b03610e0c576000856001600160a01b031687604001516001600160a01b031603610b2057610b14604051806102c00160405280896020015160018111156109fa576109fa613bfc565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b03168152602001896101a0015162ffffff168152602001896101c0015160020b8152602001896101e0015160020b81526020018581526020018481526020018961028001516001600160a01b03168152602001896102a001516001600160a01b031681526020018961026001518152602001876001600160a01b03168152602001896101000151815260200189610120015181526020018961014001518152602001600081526020016000815260200160405180602001604052806000815250815260200189610220015181526020018961024001518152602001896103000151815250886102c00151611bf8565b50919250610dc2915050565b846001600160a01b031687604001516001600160a01b031603610c7957610b14604051806102c0016040528089602001516001811115610b6257610b62613bfc565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b03168152602001896101a0015162ffffff168152602001896101c0015160020b8152602001896101e0015160020b81526020018581526020018481526020018961028001516001600160a01b03168152602001896102a001516001600160a01b031681526020018961026001518152602001886001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018960a0015181526020018960c0015181526020018960e00151815260200189610220015181526020018961024001518152602001896103000151815250886102c00151611bf8565b610dbb604051806102c0016040528089602001516001811115610c9e57610c9e613bfc565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b03168152602001896101a0015162ffffff168152602001896101c0015160020b8152602001896101e0015160020b81526020018581526020018481526020018961028001516001600160a01b03168152602001896102a001516001600160a01b03168152602001896102600151815260200160006001600160a01b031681526020016000815260200160008152602001604051806020016040528060008152508152602001600081526020016000815260200160405180602001604052806000815250815260200189610220015181526020018961024001518152602001896103000151815250886102c00151611bf8565b5091925050505b8b886001600160a01b03167f2ec1ca6e1389adeac5f1eb191a259a49f42071650bdd782177f7e6d988f2a3f283604051610dfe91815260200190565b60405180910390a350610fe7565b600186516002811115610e2157610e21613bfc565b03610fce576000610e368888602001516115d5565b9050600087604001516001600160a01b0316876001600160a01b031614610eb457600080610e73898b60400151888d60c001518e60e0015161277c565b9150915085821015610ea157610ea1848b61028001518b858a610e969190614212565b8e6102c00151612bc4565b610eab81846138e3565b92505050610ec1565b610ebe84826138e3565b90505b87604001516001600160a01b0316866001600160a01b031614610f3257600080610efc888b60400151878d61012001518e610140015161277c565b9150915084821015610f1f57610f1f848b61028001518a8589610e969190614212565b610f2981846138e3565b92505050610f3f565b610f3c83826138e3565b90505b8015801590610f5a575060408801516001600160a01b031615155b15610f7a57610f7a828961028001518a60400151848c6102c00151612bc4565b60408089015181516001600160a01b039182168152602081018490528f92918c16917fc082f11600156d64071ed597a7b831f56741ad4e14954598e674e1ec2b61da0c910160405180910390a35050610fe7565b60405163290db76760e01b815260040160405180910390fd5b866001600160a01b031663b88d4fde308e8e8a6102e001516040518563ffffffff1660e01b815260040161101e9493929190613fa9565b600060405180830381600087803b15801561103857600080fd5b505af115801561104c573d6000803e3d6000fd5b50630a85bd0160e11b9a505050505050505050505095945050505050565b611072612cc6565b4780156110b1576040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156110af573d6000803e3d6000fd5b505b5050565b6110bd612cc6565b8160005b8181101561119e5760008585838181106110dd576110dd614225565b90506020020160208101906110f2919061375f565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015611138573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115c919061423b565b905080156111955761119586868481811061117957611179614225565b905060200201602081019061118e919061375f565b8583612cf9565b506001016110c1565b5050505050565b6111ad612cc6565b6111b5612d58565b565b60008060006111c46115b1565b60006111d6604086016020870161375f565b6001600160a01b0316636352211e86604001356040518263ffffffff1660e01b815260040161120791815260200190565b602060405180830381865afa158015611224573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112489190614254565b90506001600160a01b03811633146112a75760405162461bcd60e51b815260206004820152601f60248201527f73656e646572206973206e6f74206f776e6572206f6620706f736974696f6e0060448201526064015b60405180910390fd5b6000806112d46112bd6040890160208a0161375f565b6112ca60208a018a6138b2565b8960400135611eb9565b50909250905060006112fc6112ef60408a0160208b0161375f565b6103b960208b018b6138b2565b90506113358184846113156101008d0160e08e0161375f565b8c606001358d608001358e61016001358f610100013561041591906138e3565b61134b61134189614271565b848434151561242c565b919a90995090975095505050505050565b611364612cc6565b6111b56000612daa565b60006113786115b1565b611388606083016040840161375f565b6001600160a01b03166113a1604084016020850161375f565b6001600160a01b0316036113c85760405163100dac0560e11b815260040160405180910390fd5b6113f86113d8602084018461375f565b6113e8604085016020860161375f565b60008086606001356000806116f0565b600061146e61140d604085016020860161375f565b61141d606086016040870161375f565b6060860135608087013561143460c0890189614396565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061277c92505050565b9250905081156114bf576114bf611488602085018561375f565b61149860c0860160a0870161375f565b6114a8606087016040880161375f565b856114ba610100890160e08a016143dc565b612bc4565b60006114cf826060860135614212565b90508015611519576115196114e7602086018661375f565b6114f760c0870160a0880161375f565b611507604088016020890161375f565b846114ba6101008a0160e08b016143dc565b5050919050565b611528612cc6565b6040516323b872dd60e01b81523060048201526001600160a01b038281166024830152604482018490528416906323b872dd90606401610497565b61156b612cc6565b6111b5612e03565b61157b612cc6565b6001600160a01b0381166115a557604051631e4fbdf760e01b81526000600482015260240161129e565b6115ae81612daa565b50565b60005460ff16156111b55760405163d93c066560e01b815260040160405180910390fd5b6000808260018111156115ea576115ea613bfc565b0361165857826001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561162d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116519190614254565b90506116ea565b600182600181111561166c5761166c613bfc565b036116af57826001600160a01b0316638af3ac856040518163ffffffff1660e01b8152600401602060405180830381865afa15801561162d573d6000803e3d6000fd5b60405162461bcd60e51b815260206004820152601060248201526f1a5b9d985b1a59081c1c9bdd1bd8dbdb60821b604482015260640161129e565b92915050565b60008080341561182257896001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561173557600080fd5b505af1158015611749573d6000803e3d6000fd5b5050505050886001600160a01b03168a6001600160a01b031603611790573492508583111561178b576040516307e205e160e41b815260040160405180910390fd5b611822565b876001600160a01b03168a6001600160a01b0316036117cd573491508482111561178b576040516307e205e160e41b815260040160405180910390fd5b866001600160a01b03168a6001600160a01b0316036118095750348381111561178b576040516307e205e160e41b815260040160405180910390fd5b6040516392b0337360e01b815260040160405180910390fd5b8286111561194e576040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa158015611871573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611895919061423b565b90506118ac8a33306118a7888c614212565b612e40565b6040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa1580156118f3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611917919061423b565b90506119238589614212565b61192d8383614212565b1461194b576040516313ff771f60e21b815260040160405180910390fd5b50505b81851115611a75576040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa15801561199d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c1919061423b565b90506119d38933306118a7878b614212565b6040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa158015611a1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3e919061423b565b9050611a4a8488614212565b611a548383614212565b14611a72576040516313ff771f60e21b815260040160405180910390fd5b50505b8084118015611a8c57506001600160a01b03871615155b8015611aaa5750866001600160a01b0316896001600160a01b031614155b8015611ac85750866001600160a01b0316886001600160a01b031614155b15611bec576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa158015611b14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b38919061423b565b9050611b4a8833306118a7868a614212565b6040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa158015611b91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bb5919061423b565b9050611bc18387614212565b611bcb8383614212565b14611be9576040516313ff771f60e21b815260040160405180910390fd5b50505b50505050505050505050565b600080600080600080611c0b8888612e7f565b909250905060008089516001811115611c2657611c26613bfc565b03611cb357611c368984846131e8565b809750819850829950839a505050505088602001516001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cac9190614254565b9050611d65565b600189516001811115611cc857611cc8613bfc565b03611d2a57611cd889848461330c565b809750819850829950839a505050505088602001516001600160a01b0316638af3ac856040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c88573d6000803e3d6000fd5b60405162461bcd60e51b815260206004820152601060248201526f125b9d985b1a59081c1c9bdd1bd8dbdb60821b604482015260640161129e565b60208901516101408a01516102a08b0151604051635c46a7ef60e11b81526001600160a01b039093169263b88d4fde92611da69230928d9190600401613fa9565b600060405180830381600087803b158015611dc057600080fd5b505af1158015611dd4573d6000803e3d6000fd5b5050506020808b0151604080516001600160801b038b16815292830189905282018790528992506001600160a01b0316907fa9c03b58d729c750f50b2c6854d5db412e7faa78156e5ddf9225285e19011ff79060600160405180910390a3611ead604051806101200160405280836001600160a01b031681526020018b61012001516001600160a01b031681526020018b604001516001600160a01b031681526020018b606001516001600160a01b031681526020018581526020018481526020018781526020018681526020018a15158152506133cc565b50505092959194509250565b6000806000806000876001600160a01b031686604051602401611ede91815260200190565b60408051601f198184030181529181526020820180516001600160e01b031663133f757160e31b17905251611f1391906143f9565b6000604051808303816000865af19150503d8060008114611f50576040519150601f19603f3d011682016040523d82523d6000602084013e611f55565b606091505b509150915081611fb15760405162461bcd60e51b815260206004820152602160248201527f76337574696c733a2063616c6c2067657420706f736974696f6e206661696c656044820152601960fa1b606482015260840161129e565b6000876001811115611fc557611fc5613bfc565b03611ff65780806020019051810190611fde919061443c565b50979e50959c50909a50612035975050505050505050565b600187600181111561200a5761200a613bfc565b036120355780806020019051810190612023919061451b565b50969d50949b50909950505050505050505b505093509350939050565b6000806001600160801b03861615612112576040805160a0810182528881526001600160801b038089166020830190815282840188815260608401888152608085018b81529551630624e65f60e11b8152945160048601529151909216602484015290516044830152516064820152905160848201526001600160a01b03891690630c49ccbe9060a40160408051808303816000875af11580156120e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210c91906145f3565b90925090505b965096945050505050565b60006001600160801b03821115612151576040516306dfcc6560e41b8152608060048201526024810183905260440161129e565b5090565b6040516370a0823160e01b8152306004820152600090819081906001600160a01b038816906370a0823190602401602060405180830381865afa1580156121a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121c4919061423b565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038816906370a0823190602401602060405180830381865afa15801561220e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612232919061423b565b604080516080810182528b815230602082019081526001600160801b038a81168385019081528a821660608501908152945163fc6f786560e01b81529351600485015291516001600160a01b039081166024850152915181166044840152925190921660648201529192508b169063fc6f78659060840160408051808303816000875af11580156122c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122eb91906145f3565b6040516370a0823160e01b815230600482015291955093506000906001600160a01b038a16906370a0823190602401602060405180830381865afa158015612337573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061235b919061423b565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156123a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123c9919061423b565b9050856123d68584614212565b146123f457604051638ad721cb60e01b815260040160405180910390fd5b846123ff8483614212565b1461241d57604051638ad721cb60e01b815260040160405180910390fd5b50505050965096945050505050565b6000806000806000612577604051806102c001604052808b60000151600181111561245957612459613bfc565b81526020018b602001516001600160a01b031681526020018a6001600160a01b03168152602001896001600160a01b03168152602001600062ffffff168152602001600060020b8152602001600060020b81526020018b6060015181526020018b6080015181526020018b60a001516001600160a01b031681526020018b60a001516001600160a01b031681526020018b60c0015181526020018b60e001516001600160a01b031681526020018b610100015181526020018b610120015181526020018b610140015181526020018b610160015181526020018b610180015181526020018b6101a0015181526020018b6101c0015181526020018b6101e0015181526020016040518060200160405280600081525081525087612e7f565b9150915060006040518060c001604052808b6040015181526020018481526020018381526020018b6101c0015181526020018b6101e0015181526020018b60c00151815250905089602001516001600160a01b031663219f5d17826040518263ffffffff1660e01b815260040161262d9190600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b6060604051808303816000875af115801561264c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126709190614617565b80965081975082985050505089604001518a602001516001600160a01b03167fe96b62a2783f0eb40eb1daf87ed80a62c56c56e33c3669bf7f1ce575bd5d81ac8888886040516126de939291906001600160801b039390931683526020830191909152604082015260600190565b60405180910390a360006126fa8b602001518c600001516115d5565b905061276e604051806101200160405280836001600160a01b031681526020018d60a001516001600160a01b031681526020018c6001600160a01b031681526020018b6001600160a01b031681526020018681526020018581526020018881526020018781526020018a15158152506133cc565b505050509450945094915050565b600080841580159061278e5750825115155b80156127a257506001600160a01b03861615155b15612bba576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa1580156127ee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612812919061423b565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038916906370a0823190602401602060405180830381865afa15801561285c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612880919061423b565b60405163095ea7b360e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018a9052919250908a169063095ea7b3906044016020604051808303816000875af11580156128f3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612917919061464e565b5060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168660405161295291906143f9565b6000604051808303816000865af19150503d806000811461298f576040519150601f19603f3d011682016040523d82523d6000602084013e612994565b606091505b50509050806129b65760405163081ceff360e41b815260040160405180910390fd5b60405163095ea7b360e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152600060248301528b169063095ea7b3906044016020604051808303816000875af1158015612a25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a49919061464e565b506040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015612a91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ab5919061423b565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015612aff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b23919061423b565b9050612b2f8286614212565b9650612b3b8482614212565b955088861015612b5e57604051630d4205a160e11b815260040160405180910390fd5b8a6001600160a01b03168c6001600160a01b03167ffa2dda1cc1b86e41239702756b13effbc1a092b5c57e3ad320fbe4f3b13fe2358989604051612bac929190918252602082015260400190565b60405180910390a350505050505b9550959350505050565b826001600160a01b0316856001600160a01b0316148015612be25750805b15612cbb57604051632e1a7d4d60e01b8152600481018390526001600160a01b03861690632e1a7d4d90602401600060405180830381600087803b158015612c2957600080fd5b505af1158015612c3d573d6000803e3d6000fd5b505050506000846001600160a01b03168360405160006040518083038185875af1925050503d8060008114612c8e576040519150601f19603f3d011682016040523d82523d6000602084013e612c93565b606091505b5050905080612cb557604051637cd69c3960e11b815260040160405180910390fd5b5061119e565b61119e838584612cf9565b6000546001600160a01b036101009091041633146111b55760405163118cdaa760e01b815233600482015260240161129e565b6040516001600160a01b038381166024830152604482018390526110af91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050613444565b612d606134a7565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600080546001600160a01b03838116610100818102610100600160a81b0319851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b612e0b6115b1565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612d8d3390565b6040516001600160a01b038481166024830152838116604483015260648201839052612e799186918216906323b872dd90608401612d26565b50505050565b60008083604001516001600160a01b03168461018001516001600160a01b031603612f25578361020001518460e001511015612ece57604051634ff64a9f60e01b815260040160405180910390fd5b600080612ef5866040015187606001518861020001518961022001518a610240015161277c565b91509150818660e00151612f099190614212565b935080866101000151612f1c91906138e3565b925050506130d7565b83606001516001600160a01b03168461018001516001600160a01b031603612fc957836101a001518461010001511015612f7257604051634ff64a9f60e01b815260040160405180910390fd5b600080612f9986606001518760400151886101a00151896101c001518a6101e0015161277c565b9150915081866101000151612fae9190614212565b9250808660e00151612fc091906138e3565b935050506130d7565b6101808401516001600160a01b0316156130c9576000806130058661018001518760400151886101a00151896101c001518a6101e0015161277c565b9150915060008061303188610180015189606001518a61020001518b61022001518c610240015161277c565b91509150828860e0015161304591906138e3565b95508088610100015161305891906138e3565b9450600082858a61020001518b6101a0015161307491906138e3565b61307e9190614212565b6130889190614212565b905080156130bf5760006130a48a602001518b600001516115d5565b90506130bd818b61012001518c6101800151858d612bc4565b505b50505050506130d7565b505060e08201516101008301515b811561315c576040808501516020860151915163095ea7b360e01b81526001600160a01b0392831660048201526024810185905291169063095ea7b3906044016020604051808303816000875af1158015613136573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061315a919061464e565b505b80156131e1576060840151602085015160405163095ea7b360e01b81526001600160a01b0391821660048201526024810184905291169063095ea7b3906044016020604051808303816000875af11580156131bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131df919061464e565b505b9250929050565b600080600080600060405180610160016040528089604001516001600160a01b0316815260200189606001516001600160a01b03168152602001896080015162ffffff1681526020018960a0015160020b81526020018960c0015160020b815260200188815260200187815260200189610260015181526020018961028001518152602001306001600160a01b03168152602001896101600151815250905087602001516001600160a01b03166388316456826040518263ffffffff1660e01b81526004016132b7919061466b565b6080604051808303816000875af11580156132d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132fa919061472f565b94509450945094505093509350935093565b600080600080600060405180610140016040528089604001516001600160a01b0316815260200189606001516001600160a01b031681526020018960a0015160020b81526020018960c0015160020b815260200188815260200187815260200189610260015181526020018961028001518152602001306001600160a01b03168152602001896101600151815250905087602001516001600160a01b0316639cc1a283826040518263ffffffff1660e01b81526004016132b7919061476d565b60008160c0015182608001516133e29190614212565b905060008260e001518360a001516133fa9190614212565b905081156134205761342083600001518460200151856040015185876101000151612bc4565b80156110af576110af83600001518460200151856060015184876101000151612bc4565b60006134596001600160a01b038416836134ca565b9050805160001415801561347e57508080602001905181019061347c919061464e565b155b156110af57604051635274afe760e01b81526001600160a01b038416600482015260240161129e565b60005460ff166111b557604051638dfc202b60e01b815260040160405180910390fd5b60606134d8838360006134df565b9392505050565b6060814710156135045760405163cd78605960e01b815230600482015260240161129e565b600080856001600160a01b0316848660405161352091906143f9565b60006040518083038185875af1925050503d806000811461355d576040519150601f19603f3d011682016040523d82523d6000602084013e613562565b606091505b509150915061357286838361357c565b9695505050505050565b6060826135915761358c826135d8565b6134d8565b81511580156135a857506001600160a01b0384163b155b156135d157604051639996b31560e01b81526001600160a01b038516600482015260240161129e565b50806134d8565b8051156135e85780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b60006020828403121561361357600080fd5b81356001600160401b0381111561362957600080fd5b82016102c081850312156134d857600080fd5b6001600160a01b03811681146115ae57600080fd5b803561365c8161363c565b919050565b60008060006060848603121561367657600080fd5b83356136818161363c565b92506020840135915060408401356001600160401b038111156136a357600080fd5b840161032081870312156136b657600080fd5b809150509250925092565b6000806000806000608086880312156136d957600080fd5b85356136e48161363c565b945060208601356136f48161363c565b93506040860135925060608601356001600160401b038082111561371757600080fd5b818801915088601f83011261372b57600080fd5b81358181111561373a57600080fd5b89602082850101111561374c57600080fd5b9699959850939650602001949392505050565b60006020828403121561377157600080fd5b81356134d88161363c565b60008060006040848603121561379157600080fd5b83356001600160401b03808211156137a857600080fd5b818601915086601f8301126137bc57600080fd5b8135818111156137cb57600080fd5b8760208260051b85010111156137e057600080fd5b602092830195509350508401356136b68161363c565b60006020828403121561380857600080fd5b81356001600160401b0381111561381e57600080fd5b820161020081850312156134d857600080fd5b60006020828403121561384357600080fd5b81356001600160401b0381111561385957600080fd5b820161010081850312156134d857600080fd5b60008060006060848603121561388157600080fd5b833561388c8161363c565b92506020840135915060408401356136b68161363c565b80356002811061365c57600080fd5b6000602082840312156138c457600080fd5b6134d8826138a3565b634e487b7160e01b600052601160045260246000fd5b808201808211156116ea576116ea6138cd565b634e487b7160e01b600052604160045260246000fd5b6040516102c081016001600160401b038111828210171561392f5761392f6138f6565b60405290565b60405161032081016001600160401b038111828210171561392f5761392f6138f6565b60405161020081016001600160401b038111828210171561392f5761392f6138f6565b62ffffff811681146115ae57600080fd5b803561365c8161397b565b8060020b81146115ae57600080fd5b803561365c81613997565b600082601f8301126139c257600080fd5b81356001600160401b03808211156139dc576139dc6138f6565b604051601f8301601f19908116603f01168101908282118183101715613a0457613a046138f6565b81604052838152866020858801011115613a1d57600080fd5b836020870160208301376000602085830101528094505050505092915050565b60006102c08236031215613a5057600080fd5b613a5861390c565b613a61836138a3565b8152613a6f60208401613651565b6020820152613a8060408401613651565b6040820152613a9160608401613651565b6060820152613aa26080840161398c565b6080820152613ab360a084016139a6565b60a0820152613ac460c084016139a6565b60c082015260e083013560e0820152610100808401358183015250610120613aed818501613651565b90820152610140613aff848201613651565b908201526101608381013590820152610180613b1c818501613651565b908201526101a083810135908201526101c080840135908201526101e0808401356001600160401b0380821115613b5257600080fd5b613b5e368388016139b1565b92840192909252506102008481013590830152610220808501359083015261024090818501359080821115613b9257600080fd5b613b9e368388016139b1565b9284019290925250610260848101359083015261028080850135908301526102a090818501359080821115613bd257600080fd5b50613bdf368287016139b1565b918301919091525092915050565b80356003811061365c57600080fd5b634e487b7160e01b600052602160045260246000fd5b60038110613c2257613c22613bfc565b9052565b60028110613c2257613c22613bfc565b6000808335601e19843603018112613c4d57600080fd5b83016020810192503590506001600160401b03811115613c6c57600080fd5b8036038213156131e157600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160801b03811681146115ae57600080fd5b803561365c81613ca4565b80151581146115ae57600080fd5b803561365c81613cc4565b60208152613cf660208201613cf184613bed565b613c12565b6000613d04602084016138a3565b613d116040840182613c26565b50613d1e60408401613651565b6001600160a01b03811660608401525060608301356080830152608083013560a083015260a083013560c083015260c083013560e0830152613d6360e0840184613c36565b6103206101008181870152613d7d61034087018486613c7b565b935061012092508087013583870152506101408287013581870152613da481880188613c36565b93509050601f19610160818887030181890152613dc2868685613c7b565b9550613dcf818a01613cb9565b9450506101809150613deb828801856001600160801b03169052565b613df6828901613cb9565b93506101a09150613e11828801856001600160801b03169052565b613e1c82890161398c565b93506101c09150613e338288018562ffffff169052565b613e3e8289016139a6565b93506101e09150613e538288018560020b9052565b613e5e8289016139a6565b93506102009150613e738288018560020b9052565b613e7e828901613cb9565b93506102209150613e99828801856001600160801b03169052565b610240935081880135848801526102609150838801358288015261028093508188013584880152613ecb848901613651565b93506102a09150613ee6828801856001600160a01b03169052565b613ef1828901613651565b93506102c09150613f0c828801856001600160a01b03169052565b613f17828901613cd2565b93506102e09150613f2b8288018515159052565b613f3782890189613c36565b94509150610300818887030181890152613f52868685613c7b565b9550613f60818a018a613c36565b955092505080878603018388015250613f7a848483613c7b565b979650505050505050565b60005b83811015613fa0578181015183820152602001613f88565b50506000910152565b600060018060a01b038087168352808616602084015250836040830152608060608301528251806080840152613fe68160a0850160208701613f85565b601f01601f19169190910160a00195945050505050565b60006020828403121561400f57600080fd5b81356001600160401b038082111561402657600080fd5b90830190610320828603121561403b57600080fd5b614043613935565b61404c83613bed565b815261405a602084016138a3565b602082015261406b60408401613651565b6040820152606083013560608201526080830135608082015260a083013560a082015260c083013560c082015260e0830135828111156140aa57600080fd5b6140b6878286016139b1565b60e0830152506101008381013590820152610120808401359082015261014080840135838111156140e657600080fd5b6140f2888287016139b1565b828401525050610160614106818501613cb9565b90820152610180614118848201613cb9565b908201526101a061412a84820161398c565b908201526101c061413c8482016139a6565b908201526101e061414e8482016139a6565b90820152610200614160848201613cb9565b90820152610220838101359082015261024080840135908201526102608084013590820152610280614193818501613651565b908201526102a06141a5848201613651565b908201526102c06141b7848201613cd2565b908201526102e083810135838111156141cf57600080fd5b6141db888287016139b1565b82840152505061030080840135838111156141f557600080fd5b614201888287016139b1565b918301919091525095945050505050565b818103818111156116ea576116ea6138cd565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561424d57600080fd5b5051919050565b60006020828403121561426657600080fd5b81516134d88161363c565b6000610200823603121561428457600080fd5b61428c613958565b614295836138a3565b81526142a360208401613651565b60208201526040830135604082015260608301356060820152608083013560808201526142d260a08401613651565b60a082015260c083013560c08201526142ed60e08401613651565b60e082015261010083810135908201526101208084013590820152610140808401356001600160401b038082111561432457600080fd5b614330368388016139b1565b9284019290925250610160848101359083015261018080850135908301526101a09081850135908082111561436457600080fd5b50614371368287016139b1565b91830191909152506101c083810135908201526101e092830135928101929092525090565b6000808335601e198436030181126143ad57600080fd5b8301803591506001600160401b038211156143c757600080fd5b6020019150368190038213156131e157600080fd5b6000602082840312156143ee57600080fd5b81356134d881613cc4565b6000825161440b818460208701613f85565b9190910192915050565b80516bffffffffffffffffffffffff8116811461365c57600080fd5b805161365c81613ca4565b6000806000806000806000806000806000806101808d8f03121561445f57600080fd5b6144688d614415565b9b5060208d01516144788161363c565b60408e0151909b506144898161363c565b60608e0151909a5061449a8161363c565b60808e01519099506144ab8161397b565b60a08e01519098506144bc81613997565b60c08e01519097506144cd81613997565b95506144db60e08e01614431565b94506101008d015193506101208d015192506144fa6101408e01614431565b91506145096101608e01614431565b90509295989b509295989b509295989b565b60008060008060008060008060008060006101608c8e03121561453d57600080fd5b6145468c614415565b9a5060208c01516145568161363c565b60408d0151909a506145678161363c565b60608d01519099506145788161363c565b60808d015190985061458981613997565b60a08d015190975061459a81613997565b60c08d01519096506145ab81613ca4565b8095505060e08c015193506101008c015192506101208c01516145cd81613ca4565b6101408d01519092506145df81613ca4565b809150509295989b509295989b9093969950565b6000806040838503121561460657600080fd5b505080516020909101519092909150565b60008060006060848603121561462c57600080fd5b835161463781613ca4565b602085015160409095015190969495509392505050565b60006020828403121561466057600080fd5b81516134d881613cc4565b81516001600160a01b031681526101608101602083015161469760208401826001600160a01b03169052565b5060408301516146ae604084018262ffffff169052565b5060608301516146c3606084018260020b9052565b5060808301516146d8608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e08301526101008084015181840152506101208084015161471e828501826001600160a01b03169052565b505061014092830151919092015290565b6000806000806080858703121561474557600080fd5b84519350602085015161475781613ca4565b6040860151606090960151949790965092505050565b81516001600160a01b031681526101408101602083015161479960208401826001600160a01b03169052565b5060408301516147ae604084018260020b9052565b5060608301516147c3606084018260020b9052565b506080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151614807828501826001600160a01b03169052565b50506101209283015191909201529056fea2646970667358221220cce4902d1ddfef4e43e5bbcf46c93b90c344f669993786428910f9d6ed8b959a64736f6c634300081700330000000000000000000000009af1b56acb3f0af84be68ce1a5284acc0615fadd000000000000000000000000320849ec0adffcd6fb0212b59a2ec936cdef5fca

Deployed Bytecode

0x6080604052600436106100ec5760003560e01c8063603986f41161008a5780638456cb59116100595780638456cb59146102995780638da5cb5b146102ae578063c31c9c07146102e5578063f2fde38b1461031957600080fd5b8063603986f41461020b578063715018a61461024357806371c87886146102585780637b9f76b51461027957600080fd5b80632f622e6b116100c65780632f622e6b14610193578063340ed32a146101b35780633f4ba83a146101d35780635c975abb146101e857600080fd5b806301ccc877146100f85780630779185314610138578063150b7a021461015a57600080fd5b366100f357005b600080fd5b61010b610106366004613601565b610339565b604080519485526001600160801b0390931660208501529183015260608201526080015b60405180910390f35b34801561014457600080fd5b50610158610153366004613661565b61043e565b005b34801561016657600080fd5b5061017a6101753660046136c1565b6104ce565b6040516001600160e01b0319909116815260200161012f565b34801561019f57600080fd5b506101586101ae36600461375f565b61106a565b3480156101bf57600080fd5b506101586101ce36600461377c565b6110b5565b3480156101df57600080fd5b506101586111a5565b3480156101f457600080fd5b5060005460ff16604051901515815260200161012f565b61021e6102193660046137f6565b6111b7565b604080516001600160801b03909416845260208401929092529082015260600161012f565b34801561024f57600080fd5b5061015861135c565b61026b610266366004613831565b61136e565b60405190815260200161012f565b34801561028557600080fd5b5061015861029436600461386c565b611520565b3480156102a557600080fd5b50610158611563565b3480156102ba57600080fd5b5060005461010090046001600160a01b03165b6040516001600160a01b03909116815260200161012f565b3480156102f157600080fd5b506102cd7f0000000000000000000000009af1b56acb3f0af84be68ce1a5284acc0615fadd81565b34801561032557600080fd5b5061015861033436600461375f565b611573565b6000806000806103476115b1565b610357608086016060870161375f565b6001600160a01b0316610370606087016040880161375f565b6001600160a01b0316036103975760405163100dac0560e11b815260040160405180910390fd5b60006103be6103ac604088016020890161375f565b6103b960208901896138b2565b6115d5565b905061041a816103d46060890160408a0161375f565b6103e460808a0160608b0161375f565b6103f66101a08b016101808c0161375f565b60e08b01356101008c01356104156102008e01356101a08f01356138e3565b6116f0565b61042e61042687613a3d565b341515611bf8565b9299919850965090945092505050565b6104466115b1565b826001600160a01b031663b88d4fde333085856040516020016104699190613cdd565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016104979493929190613fa9565b600060405180830381600087803b1580156104b157600080fd5b505af11580156104c5573d6000803e3d6000fd5b50505050505050565b60006104d86115b1565b33306001600160a01b0387160361050257604051632797715160e01b815260040160405180910390fd5b600061051084860186613ffd565b905060008060006105268585602001518b611eb9565b9250925092506000808561020001516001600160801b031660001461056b57610565878c8861020001518961026001518a606001518b60800151612040565b90925090505b610605878c87876001600160801b0380168b61016001516001600160801b0316146105b7576105b28b61016001516001600160801b0316886105ad91906138e3565b61211d565b6105c0565b6001600160801b035b6101808c01516001600160801b03908116146105f8576105f38c61018001516001600160801b0316886105ad91906138e3565b612155565b6001600160801b03612155565b60a08801519193509150821080610620575085610100015181105b1561063e57604051634ff64a9f60e01b815260040160405180910390fd5b60028651600281111561065357610653613bfc565b0361099c57846001600160a01b031686604001516001600160a01b03160361075f576107536040518061020001604052808860200151600181111561069a5761069a613bfc565b8152602001896001600160a01b031681526020018d81526020018481526020018381526020018861028001516001600160a01b031681526020018861026001518152602001866001600160a01b03168152602001886101000151815260200188610120015181526020018861014001518152602001600081526020016000815260200160405180602001604052806000815250815260200188610220015181526020018861024001518152508686896102c0015161242c565b91945092509050610940565b836001600160a01b031686604001516001600160a01b03160361085757610753604051806102000160405280886020015160018111156107a1576107a1613bfc565b8152602001896001600160a01b031681526020018d81526020018481526020018381526020018861028001516001600160a01b031681526020018861026001518152602001876001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018860a0015181526020018860c0015181526020018860e00151815260200188610220015181526020018861024001518152508686896102c0015161242c565b6109386040518061020001604052808860200151600181111561087c5761087c613bfc565b8152602001896001600160a01b031681526020018d81526020018481526020018381526020018861028001516001600160a01b03168152602001886102600151815260200160006001600160a01b031681526020016000815260200160008152602001604051806020016040528060008152508152602001600081526020016000815260200160405180602001604052806000815250815260200188610220015181526020018861024001518152508686896102c0015161242c565b919450925090505b604080516001600160801b0385168152602081018490529081018290528b906001600160a01b038916907f4a3d983c4891bedb0622c5a26f90b626e9451fe3a832b73ed9c886f1aa489cda9060600160405180910390a3610fe7565b6000865160028111156109b1576109b1613bfc565b03610e0c576000856001600160a01b031687604001516001600160a01b031603610b2057610b14604051806102c00160405280896020015160018111156109fa576109fa613bfc565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b03168152602001896101a0015162ffffff168152602001896101c0015160020b8152602001896101e0015160020b81526020018581526020018481526020018961028001516001600160a01b03168152602001896102a001516001600160a01b031681526020018961026001518152602001876001600160a01b03168152602001896101000151815260200189610120015181526020018961014001518152602001600081526020016000815260200160405180602001604052806000815250815260200189610220015181526020018961024001518152602001896103000151815250886102c00151611bf8565b50919250610dc2915050565b846001600160a01b031687604001516001600160a01b031603610c7957610b14604051806102c0016040528089602001516001811115610b6257610b62613bfc565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b03168152602001896101a0015162ffffff168152602001896101c0015160020b8152602001896101e0015160020b81526020018581526020018481526020018961028001516001600160a01b03168152602001896102a001516001600160a01b031681526020018961026001518152602001886001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018960a0015181526020018960c0015181526020018960e00151815260200189610220015181526020018961024001518152602001896103000151815250886102c00151611bf8565b610dbb604051806102c0016040528089602001516001811115610c9e57610c9e613bfc565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b03168152602001896101a0015162ffffff168152602001896101c0015160020b8152602001896101e0015160020b81526020018581526020018481526020018961028001516001600160a01b03168152602001896102a001516001600160a01b03168152602001896102600151815260200160006001600160a01b031681526020016000815260200160008152602001604051806020016040528060008152508152602001600081526020016000815260200160405180602001604052806000815250815260200189610220015181526020018961024001518152602001896103000151815250886102c00151611bf8565b5091925050505b8b886001600160a01b03167f2ec1ca6e1389adeac5f1eb191a259a49f42071650bdd782177f7e6d988f2a3f283604051610dfe91815260200190565b60405180910390a350610fe7565b600186516002811115610e2157610e21613bfc565b03610fce576000610e368888602001516115d5565b9050600087604001516001600160a01b0316876001600160a01b031614610eb457600080610e73898b60400151888d60c001518e60e0015161277c565b9150915085821015610ea157610ea1848b61028001518b858a610e969190614212565b8e6102c00151612bc4565b610eab81846138e3565b92505050610ec1565b610ebe84826138e3565b90505b87604001516001600160a01b0316866001600160a01b031614610f3257600080610efc888b60400151878d61012001518e610140015161277c565b9150915084821015610f1f57610f1f848b61028001518a8589610e969190614212565b610f2981846138e3565b92505050610f3f565b610f3c83826138e3565b90505b8015801590610f5a575060408801516001600160a01b031615155b15610f7a57610f7a828961028001518a60400151848c6102c00151612bc4565b60408089015181516001600160a01b039182168152602081018490528f92918c16917fc082f11600156d64071ed597a7b831f56741ad4e14954598e674e1ec2b61da0c910160405180910390a35050610fe7565b60405163290db76760e01b815260040160405180910390fd5b866001600160a01b031663b88d4fde308e8e8a6102e001516040518563ffffffff1660e01b815260040161101e9493929190613fa9565b600060405180830381600087803b15801561103857600080fd5b505af115801561104c573d6000803e3d6000fd5b50630a85bd0160e11b9a505050505050505050505095945050505050565b611072612cc6565b4780156110b1576040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156110af573d6000803e3d6000fd5b505b5050565b6110bd612cc6565b8160005b8181101561119e5760008585838181106110dd576110dd614225565b90506020020160208101906110f2919061375f565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015611138573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115c919061423b565b905080156111955761119586868481811061117957611179614225565b905060200201602081019061118e919061375f565b8583612cf9565b506001016110c1565b5050505050565b6111ad612cc6565b6111b5612d58565b565b60008060006111c46115b1565b60006111d6604086016020870161375f565b6001600160a01b0316636352211e86604001356040518263ffffffff1660e01b815260040161120791815260200190565b602060405180830381865afa158015611224573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112489190614254565b90506001600160a01b03811633146112a75760405162461bcd60e51b815260206004820152601f60248201527f73656e646572206973206e6f74206f776e6572206f6620706f736974696f6e0060448201526064015b60405180910390fd5b6000806112d46112bd6040890160208a0161375f565b6112ca60208a018a6138b2565b8960400135611eb9565b50909250905060006112fc6112ef60408a0160208b0161375f565b6103b960208b018b6138b2565b90506113358184846113156101008d0160e08e0161375f565b8c606001358d608001358e61016001358f610100013561041591906138e3565b61134b61134189614271565b848434151561242c565b919a90995090975095505050505050565b611364612cc6565b6111b56000612daa565b60006113786115b1565b611388606083016040840161375f565b6001600160a01b03166113a1604084016020850161375f565b6001600160a01b0316036113c85760405163100dac0560e11b815260040160405180910390fd5b6113f86113d8602084018461375f565b6113e8604085016020860161375f565b60008086606001356000806116f0565b600061146e61140d604085016020860161375f565b61141d606086016040870161375f565b6060860135608087013561143460c0890189614396565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061277c92505050565b9250905081156114bf576114bf611488602085018561375f565b61149860c0860160a0870161375f565b6114a8606087016040880161375f565b856114ba610100890160e08a016143dc565b612bc4565b60006114cf826060860135614212565b90508015611519576115196114e7602086018661375f565b6114f760c0870160a0880161375f565b611507604088016020890161375f565b846114ba6101008a0160e08b016143dc565b5050919050565b611528612cc6565b6040516323b872dd60e01b81523060048201526001600160a01b038281166024830152604482018490528416906323b872dd90606401610497565b61156b612cc6565b6111b5612e03565b61157b612cc6565b6001600160a01b0381166115a557604051631e4fbdf760e01b81526000600482015260240161129e565b6115ae81612daa565b50565b60005460ff16156111b55760405163d93c066560e01b815260040160405180910390fd5b6000808260018111156115ea576115ea613bfc565b0361165857826001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561162d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116519190614254565b90506116ea565b600182600181111561166c5761166c613bfc565b036116af57826001600160a01b0316638af3ac856040518163ffffffff1660e01b8152600401602060405180830381865afa15801561162d573d6000803e3d6000fd5b60405162461bcd60e51b815260206004820152601060248201526f1a5b9d985b1a59081c1c9bdd1bd8dbdb60821b604482015260640161129e565b92915050565b60008080341561182257896001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561173557600080fd5b505af1158015611749573d6000803e3d6000fd5b5050505050886001600160a01b03168a6001600160a01b031603611790573492508583111561178b576040516307e205e160e41b815260040160405180910390fd5b611822565b876001600160a01b03168a6001600160a01b0316036117cd573491508482111561178b576040516307e205e160e41b815260040160405180910390fd5b866001600160a01b03168a6001600160a01b0316036118095750348381111561178b576040516307e205e160e41b815260040160405180910390fd5b6040516392b0337360e01b815260040160405180910390fd5b8286111561194e576040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa158015611871573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611895919061423b565b90506118ac8a33306118a7888c614212565b612e40565b6040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa1580156118f3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611917919061423b565b90506119238589614212565b61192d8383614212565b1461194b576040516313ff771f60e21b815260040160405180910390fd5b50505b81851115611a75576040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa15801561199d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c1919061423b565b90506119d38933306118a7878b614212565b6040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa158015611a1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3e919061423b565b9050611a4a8488614212565b611a548383614212565b14611a72576040516313ff771f60e21b815260040160405180910390fd5b50505b8084118015611a8c57506001600160a01b03871615155b8015611aaa5750866001600160a01b0316896001600160a01b031614155b8015611ac85750866001600160a01b0316886001600160a01b031614155b15611bec576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa158015611b14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b38919061423b565b9050611b4a8833306118a7868a614212565b6040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa158015611b91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bb5919061423b565b9050611bc18387614212565b611bcb8383614212565b14611be9576040516313ff771f60e21b815260040160405180910390fd5b50505b50505050505050505050565b600080600080600080611c0b8888612e7f565b909250905060008089516001811115611c2657611c26613bfc565b03611cb357611c368984846131e8565b809750819850829950839a505050505088602001516001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cac9190614254565b9050611d65565b600189516001811115611cc857611cc8613bfc565b03611d2a57611cd889848461330c565b809750819850829950839a505050505088602001516001600160a01b0316638af3ac856040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c88573d6000803e3d6000fd5b60405162461bcd60e51b815260206004820152601060248201526f125b9d985b1a59081c1c9bdd1bd8dbdb60821b604482015260640161129e565b60208901516101408a01516102a08b0151604051635c46a7ef60e11b81526001600160a01b039093169263b88d4fde92611da69230928d9190600401613fa9565b600060405180830381600087803b158015611dc057600080fd5b505af1158015611dd4573d6000803e3d6000fd5b5050506020808b0151604080516001600160801b038b16815292830189905282018790528992506001600160a01b0316907fa9c03b58d729c750f50b2c6854d5db412e7faa78156e5ddf9225285e19011ff79060600160405180910390a3611ead604051806101200160405280836001600160a01b031681526020018b61012001516001600160a01b031681526020018b604001516001600160a01b031681526020018b606001516001600160a01b031681526020018581526020018481526020018781526020018681526020018a15158152506133cc565b50505092959194509250565b6000806000806000876001600160a01b031686604051602401611ede91815260200190565b60408051601f198184030181529181526020820180516001600160e01b031663133f757160e31b17905251611f1391906143f9565b6000604051808303816000865af19150503d8060008114611f50576040519150601f19603f3d011682016040523d82523d6000602084013e611f55565b606091505b509150915081611fb15760405162461bcd60e51b815260206004820152602160248201527f76337574696c733a2063616c6c2067657420706f736974696f6e206661696c656044820152601960fa1b606482015260840161129e565b6000876001811115611fc557611fc5613bfc565b03611ff65780806020019051810190611fde919061443c565b50979e50959c50909a50612035975050505050505050565b600187600181111561200a5761200a613bfc565b036120355780806020019051810190612023919061451b565b50969d50949b50909950505050505050505b505093509350939050565b6000806001600160801b03861615612112576040805160a0810182528881526001600160801b038089166020830190815282840188815260608401888152608085018b81529551630624e65f60e11b8152945160048601529151909216602484015290516044830152516064820152905160848201526001600160a01b03891690630c49ccbe9060a40160408051808303816000875af11580156120e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210c91906145f3565b90925090505b965096945050505050565b60006001600160801b03821115612151576040516306dfcc6560e41b8152608060048201526024810183905260440161129e565b5090565b6040516370a0823160e01b8152306004820152600090819081906001600160a01b038816906370a0823190602401602060405180830381865afa1580156121a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121c4919061423b565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038816906370a0823190602401602060405180830381865afa15801561220e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612232919061423b565b604080516080810182528b815230602082019081526001600160801b038a81168385019081528a821660608501908152945163fc6f786560e01b81529351600485015291516001600160a01b039081166024850152915181166044840152925190921660648201529192508b169063fc6f78659060840160408051808303816000875af11580156122c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122eb91906145f3565b6040516370a0823160e01b815230600482015291955093506000906001600160a01b038a16906370a0823190602401602060405180830381865afa158015612337573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061235b919061423b565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156123a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123c9919061423b565b9050856123d68584614212565b146123f457604051638ad721cb60e01b815260040160405180910390fd5b846123ff8483614212565b1461241d57604051638ad721cb60e01b815260040160405180910390fd5b50505050965096945050505050565b6000806000806000612577604051806102c001604052808b60000151600181111561245957612459613bfc565b81526020018b602001516001600160a01b031681526020018a6001600160a01b03168152602001896001600160a01b03168152602001600062ffffff168152602001600060020b8152602001600060020b81526020018b6060015181526020018b6080015181526020018b60a001516001600160a01b031681526020018b60a001516001600160a01b031681526020018b60c0015181526020018b60e001516001600160a01b031681526020018b610100015181526020018b610120015181526020018b610140015181526020018b610160015181526020018b610180015181526020018b6101a0015181526020018b6101c0015181526020018b6101e0015181526020016040518060200160405280600081525081525087612e7f565b9150915060006040518060c001604052808b6040015181526020018481526020018381526020018b6101c0015181526020018b6101e0015181526020018b60c00151815250905089602001516001600160a01b031663219f5d17826040518263ffffffff1660e01b815260040161262d9190600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b6060604051808303816000875af115801561264c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126709190614617565b80965081975082985050505089604001518a602001516001600160a01b03167fe96b62a2783f0eb40eb1daf87ed80a62c56c56e33c3669bf7f1ce575bd5d81ac8888886040516126de939291906001600160801b039390931683526020830191909152604082015260600190565b60405180910390a360006126fa8b602001518c600001516115d5565b905061276e604051806101200160405280836001600160a01b031681526020018d60a001516001600160a01b031681526020018c6001600160a01b031681526020018b6001600160a01b031681526020018681526020018581526020018881526020018781526020018a15158152506133cc565b505050509450945094915050565b600080841580159061278e5750825115155b80156127a257506001600160a01b03861615155b15612bba576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa1580156127ee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612812919061423b565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038916906370a0823190602401602060405180830381865afa15801561285c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612880919061423b565b60405163095ea7b360e01b81526001600160a01b037f0000000000000000000000009af1b56acb3f0af84be68ce1a5284acc0615fadd81166004830152602482018a9052919250908a169063095ea7b3906044016020604051808303816000875af11580156128f3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612917919061464e565b5060007f0000000000000000000000009af1b56acb3f0af84be68ce1a5284acc0615fadd6001600160a01b03168660405161295291906143f9565b6000604051808303816000865af19150503d806000811461298f576040519150601f19603f3d011682016040523d82523d6000602084013e612994565b606091505b50509050806129b65760405163081ceff360e41b815260040160405180910390fd5b60405163095ea7b360e01b81526001600160a01b037f0000000000000000000000009af1b56acb3f0af84be68ce1a5284acc0615fadd81166004830152600060248301528b169063095ea7b3906044016020604051808303816000875af1158015612a25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a49919061464e565b506040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015612a91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ab5919061423b565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015612aff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b23919061423b565b9050612b2f8286614212565b9650612b3b8482614212565b955088861015612b5e57604051630d4205a160e11b815260040160405180910390fd5b8a6001600160a01b03168c6001600160a01b03167ffa2dda1cc1b86e41239702756b13effbc1a092b5c57e3ad320fbe4f3b13fe2358989604051612bac929190918252602082015260400190565b60405180910390a350505050505b9550959350505050565b826001600160a01b0316856001600160a01b0316148015612be25750805b15612cbb57604051632e1a7d4d60e01b8152600481018390526001600160a01b03861690632e1a7d4d90602401600060405180830381600087803b158015612c2957600080fd5b505af1158015612c3d573d6000803e3d6000fd5b505050506000846001600160a01b03168360405160006040518083038185875af1925050503d8060008114612c8e576040519150601f19603f3d011682016040523d82523d6000602084013e612c93565b606091505b5050905080612cb557604051637cd69c3960e11b815260040160405180910390fd5b5061119e565b61119e838584612cf9565b6000546001600160a01b036101009091041633146111b55760405163118cdaa760e01b815233600482015260240161129e565b6040516001600160a01b038381166024830152604482018390526110af91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050613444565b612d606134a7565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600080546001600160a01b03838116610100818102610100600160a81b0319851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b612e0b6115b1565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612d8d3390565b6040516001600160a01b038481166024830152838116604483015260648201839052612e799186918216906323b872dd90608401612d26565b50505050565b60008083604001516001600160a01b03168461018001516001600160a01b031603612f25578361020001518460e001511015612ece57604051634ff64a9f60e01b815260040160405180910390fd5b600080612ef5866040015187606001518861020001518961022001518a610240015161277c565b91509150818660e00151612f099190614212565b935080866101000151612f1c91906138e3565b925050506130d7565b83606001516001600160a01b03168461018001516001600160a01b031603612fc957836101a001518461010001511015612f7257604051634ff64a9f60e01b815260040160405180910390fd5b600080612f9986606001518760400151886101a00151896101c001518a6101e0015161277c565b9150915081866101000151612fae9190614212565b9250808660e00151612fc091906138e3565b935050506130d7565b6101808401516001600160a01b0316156130c9576000806130058661018001518760400151886101a00151896101c001518a6101e0015161277c565b9150915060008061303188610180015189606001518a61020001518b61022001518c610240015161277c565b91509150828860e0015161304591906138e3565b95508088610100015161305891906138e3565b9450600082858a61020001518b6101a0015161307491906138e3565b61307e9190614212565b6130889190614212565b905080156130bf5760006130a48a602001518b600001516115d5565b90506130bd818b61012001518c6101800151858d612bc4565b505b50505050506130d7565b505060e08201516101008301515b811561315c576040808501516020860151915163095ea7b360e01b81526001600160a01b0392831660048201526024810185905291169063095ea7b3906044016020604051808303816000875af1158015613136573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061315a919061464e565b505b80156131e1576060840151602085015160405163095ea7b360e01b81526001600160a01b0391821660048201526024810184905291169063095ea7b3906044016020604051808303816000875af11580156131bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131df919061464e565b505b9250929050565b600080600080600060405180610160016040528089604001516001600160a01b0316815260200189606001516001600160a01b03168152602001896080015162ffffff1681526020018960a0015160020b81526020018960c0015160020b815260200188815260200187815260200189610260015181526020018961028001518152602001306001600160a01b03168152602001896101600151815250905087602001516001600160a01b03166388316456826040518263ffffffff1660e01b81526004016132b7919061466b565b6080604051808303816000875af11580156132d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132fa919061472f565b94509450945094505093509350935093565b600080600080600060405180610140016040528089604001516001600160a01b0316815260200189606001516001600160a01b031681526020018960a0015160020b81526020018960c0015160020b815260200188815260200187815260200189610260015181526020018961028001518152602001306001600160a01b03168152602001896101600151815250905087602001516001600160a01b0316639cc1a283826040518263ffffffff1660e01b81526004016132b7919061476d565b60008160c0015182608001516133e29190614212565b905060008260e001518360a001516133fa9190614212565b905081156134205761342083600001518460200151856040015185876101000151612bc4565b80156110af576110af83600001518460200151856060015184876101000151612bc4565b60006134596001600160a01b038416836134ca565b9050805160001415801561347e57508080602001905181019061347c919061464e565b155b156110af57604051635274afe760e01b81526001600160a01b038416600482015260240161129e565b60005460ff166111b557604051638dfc202b60e01b815260040160405180910390fd5b60606134d8838360006134df565b9392505050565b6060814710156135045760405163cd78605960e01b815230600482015260240161129e565b600080856001600160a01b0316848660405161352091906143f9565b60006040518083038185875af1925050503d806000811461355d576040519150601f19603f3d011682016040523d82523d6000602084013e613562565b606091505b509150915061357286838361357c565b9695505050505050565b6060826135915761358c826135d8565b6134d8565b81511580156135a857506001600160a01b0384163b155b156135d157604051639996b31560e01b81526001600160a01b038516600482015260240161129e565b50806134d8565b8051156135e85780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b60006020828403121561361357600080fd5b81356001600160401b0381111561362957600080fd5b82016102c081850312156134d857600080fd5b6001600160a01b03811681146115ae57600080fd5b803561365c8161363c565b919050565b60008060006060848603121561367657600080fd5b83356136818161363c565b92506020840135915060408401356001600160401b038111156136a357600080fd5b840161032081870312156136b657600080fd5b809150509250925092565b6000806000806000608086880312156136d957600080fd5b85356136e48161363c565b945060208601356136f48161363c565b93506040860135925060608601356001600160401b038082111561371757600080fd5b818801915088601f83011261372b57600080fd5b81358181111561373a57600080fd5b89602082850101111561374c57600080fd5b9699959850939650602001949392505050565b60006020828403121561377157600080fd5b81356134d88161363c565b60008060006040848603121561379157600080fd5b83356001600160401b03808211156137a857600080fd5b818601915086601f8301126137bc57600080fd5b8135818111156137cb57600080fd5b8760208260051b85010111156137e057600080fd5b602092830195509350508401356136b68161363c565b60006020828403121561380857600080fd5b81356001600160401b0381111561381e57600080fd5b820161020081850312156134d857600080fd5b60006020828403121561384357600080fd5b81356001600160401b0381111561385957600080fd5b820161010081850312156134d857600080fd5b60008060006060848603121561388157600080fd5b833561388c8161363c565b92506020840135915060408401356136b68161363c565b80356002811061365c57600080fd5b6000602082840312156138c457600080fd5b6134d8826138a3565b634e487b7160e01b600052601160045260246000fd5b808201808211156116ea576116ea6138cd565b634e487b7160e01b600052604160045260246000fd5b6040516102c081016001600160401b038111828210171561392f5761392f6138f6565b60405290565b60405161032081016001600160401b038111828210171561392f5761392f6138f6565b60405161020081016001600160401b038111828210171561392f5761392f6138f6565b62ffffff811681146115ae57600080fd5b803561365c8161397b565b8060020b81146115ae57600080fd5b803561365c81613997565b600082601f8301126139c257600080fd5b81356001600160401b03808211156139dc576139dc6138f6565b604051601f8301601f19908116603f01168101908282118183101715613a0457613a046138f6565b81604052838152866020858801011115613a1d57600080fd5b836020870160208301376000602085830101528094505050505092915050565b60006102c08236031215613a5057600080fd5b613a5861390c565b613a61836138a3565b8152613a6f60208401613651565b6020820152613a8060408401613651565b6040820152613a9160608401613651565b6060820152613aa26080840161398c565b6080820152613ab360a084016139a6565b60a0820152613ac460c084016139a6565b60c082015260e083013560e0820152610100808401358183015250610120613aed818501613651565b90820152610140613aff848201613651565b908201526101608381013590820152610180613b1c818501613651565b908201526101a083810135908201526101c080840135908201526101e0808401356001600160401b0380821115613b5257600080fd5b613b5e368388016139b1565b92840192909252506102008481013590830152610220808501359083015261024090818501359080821115613b9257600080fd5b613b9e368388016139b1565b9284019290925250610260848101359083015261028080850135908301526102a090818501359080821115613bd257600080fd5b50613bdf368287016139b1565b918301919091525092915050565b80356003811061365c57600080fd5b634e487b7160e01b600052602160045260246000fd5b60038110613c2257613c22613bfc565b9052565b60028110613c2257613c22613bfc565b6000808335601e19843603018112613c4d57600080fd5b83016020810192503590506001600160401b03811115613c6c57600080fd5b8036038213156131e157600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160801b03811681146115ae57600080fd5b803561365c81613ca4565b80151581146115ae57600080fd5b803561365c81613cc4565b60208152613cf660208201613cf184613bed565b613c12565b6000613d04602084016138a3565b613d116040840182613c26565b50613d1e60408401613651565b6001600160a01b03811660608401525060608301356080830152608083013560a083015260a083013560c083015260c083013560e0830152613d6360e0840184613c36565b6103206101008181870152613d7d61034087018486613c7b565b935061012092508087013583870152506101408287013581870152613da481880188613c36565b93509050601f19610160818887030181890152613dc2868685613c7b565b9550613dcf818a01613cb9565b9450506101809150613deb828801856001600160801b03169052565b613df6828901613cb9565b93506101a09150613e11828801856001600160801b03169052565b613e1c82890161398c565b93506101c09150613e338288018562ffffff169052565b613e3e8289016139a6565b93506101e09150613e538288018560020b9052565b613e5e8289016139a6565b93506102009150613e738288018560020b9052565b613e7e828901613cb9565b93506102209150613e99828801856001600160801b03169052565b610240935081880135848801526102609150838801358288015261028093508188013584880152613ecb848901613651565b93506102a09150613ee6828801856001600160a01b03169052565b613ef1828901613651565b93506102c09150613f0c828801856001600160a01b03169052565b613f17828901613cd2565b93506102e09150613f2b8288018515159052565b613f3782890189613c36565b94509150610300818887030181890152613f52868685613c7b565b9550613f60818a018a613c36565b955092505080878603018388015250613f7a848483613c7b565b979650505050505050565b60005b83811015613fa0578181015183820152602001613f88565b50506000910152565b600060018060a01b038087168352808616602084015250836040830152608060608301528251806080840152613fe68160a0850160208701613f85565b601f01601f19169190910160a00195945050505050565b60006020828403121561400f57600080fd5b81356001600160401b038082111561402657600080fd5b90830190610320828603121561403b57600080fd5b614043613935565b61404c83613bed565b815261405a602084016138a3565b602082015261406b60408401613651565b6040820152606083013560608201526080830135608082015260a083013560a082015260c083013560c082015260e0830135828111156140aa57600080fd5b6140b6878286016139b1565b60e0830152506101008381013590820152610120808401359082015261014080840135838111156140e657600080fd5b6140f2888287016139b1565b828401525050610160614106818501613cb9565b90820152610180614118848201613cb9565b908201526101a061412a84820161398c565b908201526101c061413c8482016139a6565b908201526101e061414e8482016139a6565b90820152610200614160848201613cb9565b90820152610220838101359082015261024080840135908201526102608084013590820152610280614193818501613651565b908201526102a06141a5848201613651565b908201526102c06141b7848201613cd2565b908201526102e083810135838111156141cf57600080fd5b6141db888287016139b1565b82840152505061030080840135838111156141f557600080fd5b614201888287016139b1565b918301919091525095945050505050565b818103818111156116ea576116ea6138cd565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561424d57600080fd5b5051919050565b60006020828403121561426657600080fd5b81516134d88161363c565b6000610200823603121561428457600080fd5b61428c613958565b614295836138a3565b81526142a360208401613651565b60208201526040830135604082015260608301356060820152608083013560808201526142d260a08401613651565b60a082015260c083013560c08201526142ed60e08401613651565b60e082015261010083810135908201526101208084013590820152610140808401356001600160401b038082111561432457600080fd5b614330368388016139b1565b9284019290925250610160848101359083015261018080850135908301526101a09081850135908082111561436457600080fd5b50614371368287016139b1565b91830191909152506101c083810135908201526101e092830135928101929092525090565b6000808335601e198436030181126143ad57600080fd5b8301803591506001600160401b038211156143c757600080fd5b6020019150368190038213156131e157600080fd5b6000602082840312156143ee57600080fd5b81356134d881613cc4565b6000825161440b818460208701613f85565b9190910192915050565b80516bffffffffffffffffffffffff8116811461365c57600080fd5b805161365c81613ca4565b6000806000806000806000806000806000806101808d8f03121561445f57600080fd5b6144688d614415565b9b5060208d01516144788161363c565b60408e0151909b506144898161363c565b60608e0151909a5061449a8161363c565b60808e01519099506144ab8161397b565b60a08e01519098506144bc81613997565b60c08e01519097506144cd81613997565b95506144db60e08e01614431565b94506101008d015193506101208d015192506144fa6101408e01614431565b91506145096101608e01614431565b90509295989b509295989b509295989b565b60008060008060008060008060008060006101608c8e03121561453d57600080fd5b6145468c614415565b9a5060208c01516145568161363c565b60408d0151909a506145678161363c565b60608d01519099506145788161363c565b60808d015190985061458981613997565b60a08d015190975061459a81613997565b60c08d01519096506145ab81613ca4565b8095505060e08c015193506101008c015192506101208c01516145cd81613ca4565b6101408d01519092506145df81613ca4565b809150509295989b509295989b9093969950565b6000806040838503121561460657600080fd5b505080516020909101519092909150565b60008060006060848603121561462c57600080fd5b835161463781613ca4565b602085015160409095015190969495509392505050565b60006020828403121561466057600080fd5b81516134d881613cc4565b81516001600160a01b031681526101608101602083015161469760208401826001600160a01b03169052565b5060408301516146ae604084018262ffffff169052565b5060608301516146c3606084018260020b9052565b5060808301516146d8608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e08301526101008084015181840152506101208084015161471e828501826001600160a01b03169052565b505061014092830151919092015290565b6000806000806080858703121561474557600080fd5b84519350602085015161475781613ca4565b6040860151606090960151949790965092505050565b81516001600160a01b031681526101408101602083015161479960208401826001600160a01b03169052565b5060408301516147ae604084018260020b9052565b5060608301516147c3606084018260020b9052565b506080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151614807828501826001600160a01b03169052565b50506101209283015191909201529056fea2646970667358221220cce4902d1ddfef4e43e5bbcf46c93b90c344f669993786428910f9d6ed8b959a64736f6c63430008170033

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

0000000000000000000000009af1b56acb3f0af84be68ce1a5284acc0615fadd000000000000000000000000320849ec0adffcd6fb0212b59a2ec936cdef5fca

-----Decoded View---------------
Arg [0] : _swapRouter (address): 0x9AF1B56Acb3F0Af84Be68cE1A5284ACc0615faDD
Arg [1] : initialOwner (address): 0x320849EC0aDffCd6fb0212B59a2EC936cdEF5fCa

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000009af1b56acb3f0af84be68ce1a5284acc0615fadd
Arg [1] : 000000000000000000000000320849ec0adffcd6fb0212b59a2ec936cdef5fca


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
[ 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.