ETH Price: $3,181.82 (+2.55%)

Contract

0x22354b70596E9638C32E8B6cc5d01716396617c4
 

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Swap And Mint200537032024-06-09 10:34:47160 days ago1717929287IN
0x22354b70...6396617c4
0 ETH0.002391443.30142182
Swap And Mint200536172024-06-09 10:17:23160 days ago1717928243IN
0x22354b70...6396617c4
0 ETH0.002328193.31112906
Swap And Mint200535022024-06-09 9:54:23160 days ago1717926863IN
0x22354b70...6396617c4
0.28 ETH0.002765433.82501711
Swap And Mint200525882024-06-09 6:49:47160 days ago1717915787IN
0x22354b70...6396617c4
5 ETH0.00329914.70817921
Swap And Mint200525702024-06-09 6:46:11160 days ago1717915571IN
0x22354b70...6396617c4
5 ETH0.002601754.7805833
Swap And Increas...200525492024-06-09 6:41:47160 days ago1717915307IN
0x22354b70...6396617c4
0 ETH0.002681233.70025516
Swap And Mint200515672024-06-09 3:25:23160 days ago1717903523IN
0x22354b70...6396617c4
0.0084 ETH0.003920824.17300171
Swap And Mint200511632024-06-09 2:03:35160 days ago1717898615IN
0x22354b70...6396617c4
0.24 ETH0.003231054.57080331
Swap And Increas...200511202024-06-09 1:54:59160 days ago1717898099IN
0x22354b70...6396617c4
0.24 ETH0.003109045.53592544
Swap And Increas...200511072024-06-09 1:52:23160 days ago1717897943IN
0x22354b70...6396617c4
0.24 ETH0.002855555.0842785
Swap And Increas...200509202024-06-09 1:14:11160 days ago1717895651IN
0x22354b70...6396617c4
0.3 ETH0.001669054.01046989
Swap And Mint200505602024-06-09 0:01:35160 days ago1717891295IN
0x22354b70...6396617c4
0.272 ETH0.00252985.21285429
Swap And Mint200503142024-06-08 23:12:11160 days ago1717888331IN
0x22354b70...6396617c4
71 ETH0.004456854.80182263
Swap And Mint200496162024-06-08 20:52:11160 days ago1717879931IN
0x22354b70...6396617c4
0.2 ETH0.005091047.4733999
Swap And Mint200491192024-06-08 19:12:47160 days ago1717873967IN
0x22354b70...6396617c4
0.65 ETH0.0095760713.74711846
Swap And Mint200491132024-06-08 19:11:35160 days ago1717873895IN
0x22354b70...6396617c4
0.24 ETH0.0097610113.60465074
Swap And Mint200489752024-06-08 18:43:47160 days ago1717872227IN
0x22354b70...6396617c4
0 ETH0.0083936510.85536596
Swap And Mint200489342024-06-08 18:35:23160 days ago1717871723IN
0x22354b70...6396617c4
0 ETH0.007319859.91692186
Swap And Mint200485702024-06-08 17:22:11160 days ago1717867331IN
0x22354b70...6396617c4
0.2 ETH0.005445568.77197063
Swap And Mint200485422024-06-08 17:16:35160 days ago1717866995IN
0x22354b70...6396617c4
0.28 ETH0.005687148.4140121
Swap And Mint200481152024-06-08 15:50:23160 days ago1717861823IN
0x22354b70...6396617c4
1.2 ETH0.004666877.04494233
Swap And Mint200476182024-06-08 14:10:11160 days ago1717855811IN
0x22354b70...6396617c4
0 ETH0.005392557.19874725
Swap And Mint200473642024-06-08 13:19:11160 days ago1717852751IN
0x22354b70...6396617c4
1 ETH0.006013917.38149533
Swap And Increas...200467442024-06-08 11:14:11161 days ago1717845251IN
0x22354b70...6396617c4
2 ETH0.002217476.02215951
Swap And Mint200464562024-06-08 10:16:23161 days ago1717841783IN
0x22354b70...6396617c4
8 ETH0.004275836.54787686
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
200536462024-06-09 10:23:23160 days ago1717928603
0x22354b70...6396617c4
0.24046272 ETH
200536462024-06-09 10:23:23160 days ago1717928603
0x22354b70...6396617c4
0.24046272 ETH
200536242024-06-09 10:18:47160 days ago1717928327
0x22354b70...6396617c4
0.00015474 ETH
200536242024-06-09 10:18:47160 days ago1717928327
0x22354b70...6396617c4
0.00015474 ETH
200535022024-06-09 9:54:23160 days ago1717926863
0x22354b70...6396617c4
0.00199877 ETH
200535022024-06-09 9:54:23160 days ago1717926863
0x22354b70...6396617c4
0.00199877 ETH
200535022024-06-09 9:54:23160 days ago1717926863
0x22354b70...6396617c4
0.28 ETH
200534622024-06-09 9:46:23160 days ago1717926383
0x22354b70...6396617c4
0.27921892 ETH
200534622024-06-09 9:46:23160 days ago1717926383
0x22354b70...6396617c4
0.27921892 ETH
200527442024-06-09 7:21:11160 days ago1717917671
0x22354b70...6396617c4
0.00001255 ETH
200527442024-06-09 7:21:11160 days ago1717917671
0x22354b70...6396617c4
0.00001255 ETH
200525882024-06-09 6:49:47160 days ago1717915787
0x22354b70...6396617c4
5 ETH
200525702024-06-09 6:46:11160 days ago1717915571
0x22354b70...6396617c4
5 ETH
200522942024-06-09 5:50:47160 days ago1717912247
0x22354b70...6396617c4
0.00000011 ETH
200522942024-06-09 5:50:47160 days ago1717912247
0x22354b70...6396617c4
0.00000011 ETH
200522942024-06-09 5:50:47160 days ago1717912247
0x22354b70...6396617c4
0.00000011 ETH
200522942024-06-09 5:50:47160 days ago1717912247
0x22354b70...6396617c4
0.00000011 ETH
200522942024-06-09 5:50:47160 days ago1717912247
0x22354b70...6396617c4
0.00000011 ETH
200522942024-06-09 5:50:47160 days ago1717912247
0x22354b70...6396617c4
0.00000011 ETH
200522942024-06-09 5:50:47160 days ago1717912247
0x22354b70...6396617c4
0.00000011 ETH
200522942024-06-09 5:50:47160 days ago1717912247
0x22354b70...6396617c4
0.00000011 ETH
200522942024-06-09 5:50:47160 days ago1717912247
0x22354b70...6396617c4
0.00000011 ETH
200522942024-06-09 5:50:47160 days ago1717912247
0x22354b70...6396617c4
0.00000011 ETH
200522912024-06-09 5:50:11160 days ago1717912211
0x22354b70...6396617c4
1 wei
200522912024-06-09 5:50:11160 days ago1717912211
0x22354b70...6396617c4
1 wei
View All Internal Transactions
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 24 : V3Utils.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "./Common.sol";

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

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

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

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

        // for creating new positions with CHANGE_RANGE
        int24 tickLower;
        int24 tickUpper;
        
        bool compoundFees;

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

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

        // protocol fees
        uint64 protocolFeeX64;
    }

    /// @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,,,,uint24 fee) = _getPosition(nfpm, instructions.protocol, tokenId);

        (uint256 amount0, uint256 amount1) = _decreaseLiquidityAndCollectFees(DecreaseAndCollectFeesParams(nfpm, instructions.recipient, IERC20(token0), IERC20(token1), tokenId, instructions.liquidity, instructions.deadline, instructions.amountRemoveMin0, instructions.amountRemoveMin1, instructions.compoundFees));
       
        // take protocol fees
        if (instructions.protocolFeeX64 > 0) {
            (amount0, amount1,,,,) = _deductFees(DeductFeesParams(amount0, amount1, 0, instructions.protocolFeeX64, FeeType.PROTOCOL_FEE, address(nfpm), tokenId, instructions.recipient, token0, token1, address(0)), true);
        }
       
        // check if enough tokens are available for swaps
        if (amount0 < instructions.amountIn0 || amount1 < instructions.amountIn1) {
            revert AmountError();
        }

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

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

            emit ChangeRange(msg.sender, tokenId, result.tokenId, result.liquidity, result.added0, result.added1);
        } 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 NotSupportedAction();
        }
        
        // return token to owner (this line guarantees that token is returned to originating owner)
        nfpm.transferFrom(address(this), from, tokenId);

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

        _prepareSwap(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 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 (SwapAndMintResult memory result) {
        if (params.token0 == params.token1) {
            revert SameToken();
        }
        IWETH9 weth = _getWeth9(params.nfpm, params.protocol);
        _prepareSwap(weth, params.token0, params.token1, params.swapSourceToken, params.amount0, params.amount1, params.amount2);
        SwapAndMintParams memory _params = params;

        DeductFeesEventData memory eventData;
        if (params.protocolFeeX64 > 0) {
            uint256 feeAmount0;
            uint256 feeAmount1;
            uint256 feeAmount2;
            // since we do not have the tokenId here, we need to emit event later
            (_params.amount0, _params.amount1, _params.amount2, feeAmount0, feeAmount1, feeAmount2) = _deductFees(DeductFeesParams(params.amount0, params.amount1, params.amount2, params.protocolFeeX64, FeeType.PROTOCOL_FEE, address(params.nfpm), 0, params.recipient, address(params.token0), address(params.token1), address(params.swapSourceToken)), false);
            // swap source token is not token 0 and token 1
            if (_params.swapSourceToken != _params.token0 && _params.swapSourceToken != _params.token1) {
                if (_params.amountIn0 + _params.amountIn1 > _params.amount2) {
                    revert AmountError();
                }
                if (_params.amountIn0 + _params.amountIn1 < _params.amount2) {
                    uint256 leftOverAmount = _params.amount2 - (_params.amountIn0 + _params.amountIn1);
                    // return un-needed tokens
                    _transferToken(weth, msg.sender, _params.swapSourceToken, leftOverAmount, msg.value != 0);
                }
            }

            eventData = DeductFeesEventData({
                token0: address(params.token0),
                token1: address(params.token1),
                token2: address(params.swapSourceToken),
                amount0: params.amount0,
                amount1: params.amount1,
                amount2: params.amount2,
                feeAmount0: feeAmount0,
                feeAmount1: feeAmount1,
                feeAmount2: feeAmount2,
                feeX64: params.protocolFeeX64,
                feeType: FeeType.PROTOCOL_FEE
            });
        }
        result = _swapAndMint(_params, msg.value != 0);
        emit DeductFees(address(params.nfpm), result.tokenId, params.recipient, eventData);
    }

    /// @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 (SwapAndIncreaseLiquidityResult memory result) {
        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);
        _prepareSwap(weth, IERC20(token0), IERC20(token1), params.swapSourceToken, params.amount0, params.amount1, params.amount2);
        SwapAndIncreaseLiquidityParams memory _params = params;
        if (params.protocolFeeX64 > 0) {
            (_params.amount0, _params.amount1, _params.amount2,,,) = _deductFees(DeductFeesParams(params.amount0, params.amount1, params.amount2, params.protocolFeeX64, FeeType.PROTOCOL_FEE, address(params.nfpm), params.tokenId, params.recipient, token0, token1, address(params.swapSourceToken)), true);
            // swap source token is not token 0 and token 1
            if (address(_params.swapSourceToken) != token0 && address(_params.swapSourceToken) != token1) {
                if (_params.amountIn0 + _params.amountIn1 > _params.amount2) {
                    revert AmountError();
                }
                if (_params.amountIn0 + _params.amountIn1 < _params.amount2) {
                    uint256 leftOverAmount = _params.amount2 - (_params.amountIn0 + _params.amountIn1);
                    // return un-needed tokens
                    _transferToken(weth, msg.sender, _params.swapSourceToken, leftOverAmount, msg.value != 0);
                }
            }
        }

        result = _swapAndIncrease(_params, IERC20(token0), IERC20(token1), msg.value != 0);
    }
    // needed for WETH unwrapping
    receive() external payable{}
}

File 2 of 24 : 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 3 of 24 : Common.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "v3-periphery/interfaces/external/IWETH9.sol";
import "v3-periphery/interfaces/INonfungiblePositionManager.sol" as univ3;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "v3-core/libraries/FullMath.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/Pausable.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);
}

abstract contract Common is AccessControl, Pausable {
    using Address for address;

    bytes32 public constant WITHDRAWER_ROLE = keccak256("WITHDRAWER_ROLE");
    bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
    uint256 internal constant Q64 = 2 ** 64;
    uint256 internal constant Q96 = 2 ** 96;
    
    // error types
    error SelfSend();
    error NotSupportedAction();
    error NotSupportedProtocol();
    error SameToken();
    error AmountError();
    error SlippageError();
    error CollectError();
    error TransferError();
    error EtherSendFailed();
    error TooMuchEtherSent();
    error NoEtherToken();
    error NotWETH();
    error TooMuchFee();
    error AlreadyInitialised();
    error GetPositionFailed();
    error NoFees();


    struct DeductFeesEventData {
        address token0;
        address token1;
        address token2;
        uint256 amount0;
        uint256 amount1;
        uint256 amount2;
        uint256 feeAmount0;
        uint256 feeAmount1;
        uint256 feeAmount2;
        uint64 feeX64;
        FeeType feeType;
    }

    // events
    event CompoundFees(address indexed nfpm, uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    event DeductFees(address indexed nfpm, uint256 indexed tokenId, address indexed userAddress, DeductFeesEventData data);
    event ChangeRange(address indexed nfpm, uint256 indexed tokenId, uint256 newTokenId, uint256 newLiquidity, uint256 token0Added, uint256 token1Added);
    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);


    address public swapRouter;
    mapping (FeeType=>uint64) _maxFeeX64;
    constructor() {
        _maxFeeX64[FeeType.GAS_FEE] = 1844674407370955264; // 10%
        _maxFeeX64[FeeType.PROTOCOL_FEE] = 1844674407370955264; // 10%
    }

    bool private _initialized = false;
    function initialize(address router, address admin, address withdrawer) public virtual {
        if (_initialized) {
            revert AlreadyInitialised();
        }
        if (withdrawer == address(0)) {
            revert();
        }
        _grantRole(ADMIN_ROLE, admin);
        _grantRole(DEFAULT_ADMIN_ROLE, admin);
        _grantRole(WITHDRAWER_ROLE, withdrawer);
        _grantRole(DEFAULT_ADMIN_ROLE, withdrawer);
        swapRouter = router;

        _initialized = true;
    }

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

    enum FeeType {
        GAS_FEE,
        PROTOCOL_FEE
        // todo: PERFORMANCE_FEE
    }

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

        IERC20 token0;
        IERC20 token1;
        uint24 fee;
        int24 tickLower;
        int24 tickUpper;
        uint64 protocolFeeX64;

        // how much is provided of token0 and token1
        uint256 amount0;
        uint256 amount1;
        uint256 amount2;
        address recipient; // recipient of 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 Params for swapAndIncreaseLiquidity() function
    struct SwapAndIncreaseLiquidityParams {
        Protocol protocol;
        INonfungiblePositionManager nfpm;
        uint256 tokenId;

        // how much is provided of token0 and token1
        uint256 amount0;
        uint256 amount1;
        uint256 amount2;
        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;

        uint64 protocolFeeX64;
    }

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

    struct DecreaseAndCollectFeesParams {
        INonfungiblePositionManager nfpm;
        address userAddress;
        IERC20 token0;
        IERC20 token1;
        uint256 tokenId; 
        uint128 liquidity;
        uint256 deadline; 
        uint256 token0Min; 
        uint256 token1Min;
        bool compoundFees;
    }

    struct DeductFeesParams {
        uint256 amount0;
        uint256 amount1;
        uint256 amount2;
        uint64 feeX64;
        FeeType feeType;

        // readonly params for emitting events
        address nfpm;
        uint256 tokenId;
        address userAddress;
        address token0;
        address token1;
        address token2;
    }

    /**
     * @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 onlyRole(WITHDRAWER_ROLE) {
        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 onlyRole(WITHDRAWER_ROLE) {
        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 onlyRole(WITHDRAWER_ROLE) {
        nfpm.transferFrom(address(this), to, tokenId);
    }

    // checks if required amounts are provided and are exact - wraps any provided ETH as WETH
    // if less or more provided reverts
    function _prepareSwap(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
            }
        }
    }

    struct SwapAndMintResult {
        uint256 tokenId;
        uint128 liquidity;
        uint256 added0;
        uint256 added1;
    }
    // swap and mint logic
    function _swapAndMint(SwapAndMintParams memory params, bool unwrap) internal returns (SwapAndMintResult memory result) {
        (uint256 total0, uint256 total1) = _swapAndPrepareAmounts(params, unwrap);
        
        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
            (result.tokenId,result.liquidity,result.added0,result.added1) = _mintUniv3(params.nfpm, 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
            ));
        } 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
            (result.tokenId,result.liquidity,result.added0,result.added1) = _mintAlgebraV1(params.nfpm, 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
            ));
        } else {
            revert NotSupportedProtocol();
        }
        params.nfpm.transferFrom(address(this), params.recipient, result.tokenId);
        emit SwapAndMint(address(params.nfpm), result.tokenId, result.liquidity, result.added0, result.added1);
                
        _returnLeftoverTokens(ReturnLeftoverTokensParams(_getWeth9(params.nfpm, params.protocol), params.recipient, params.token0, params.token1, total0, total1, result.added0, result.added1, unwrap));
    }

    function _mintUniv3(INonfungiblePositionManager nfpm, INonfungiblePositionManager.MintParams memory params) internal returns (
        uint256 tokenId,
        uint128 liquidity,
        uint256 amount0,
        uint256 amount1
    ) {
        // mint is done to address(this) because it is not a safemint and safeTransferFrom needs to be done manually afterwards
        return nfpm.mint(params);
    }

    function _mintAlgebraV1(INonfungiblePositionManager nfpm, INonfungiblePositionManager.MintParams memory params) internal returns (
        uint256 tokenId,
        uint128 liquidity,
        uint256 amount0,
        uint256 amount1
    ) {
        INonfungiblePositionManager.AlgebraV1MintParams memory mintParams = 
            INonfungiblePositionManager.AlgebraV1MintParams(
                params.token0,
                params.token1,
                params.tickLower,
                params.tickUpper,
                params.amount0Desired,
                params.amount1Desired,
                params.amount0Min,
                params.amount1Min,
                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 nfpm.mint(mintParams);
    }

    struct SwapAndIncreaseLiquidityResult {
        uint128 liquidity;
        uint256 added0;
        uint256 added1;
        uint256 feeAmount0;
        uint256 feeAmount1;
    }
    // swap and increase logic
    function _swapAndIncrease(SwapAndIncreaseLiquidityParams memory params, IERC20 token0, IERC20 token1, bool unwrap) internal returns (SwapAndIncreaseLiquidityResult memory result) {
        (uint256 total0, uint256 total1) = _swapAndPrepareAmounts(
            SwapAndMintParams(params.protocol, params.nfpm, token0, token1, 0, 0, 0, 0, params.amount0, params.amount1, 0, 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
            );

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

        emit SwapAndIncreaseLiquidity(address(params.nfpm), params.tokenId, result.liquidity, result.added0, result.added1);
        IWETH9 weth = _getWeth9(params.nfpm, params.protocol);
        _returnLeftoverTokens(ReturnLeftoverTokensParams(weth, params.recipient, token0, token1, total0, total1, result.added0, result.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) {
            _safeResetAndApprove(params.token0, address(params.nfpm), total0);
        }
        if (total1 != 0) {
            _safeResetAndApprove(params.token1, address(params.nfpm), total1);
        }
    }

    // returns leftover token balances
    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)
    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
            _safeApprove(tokenIn, swapRouter, amountIn);
            // execute swap
            (bool success,) = swapRouter.call(swapData);
            if (!success) {
                revert ("swap failed!");
            }

            // reset approval
            _safeApprove(tokenIn, 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
    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
    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 _decreaseLiquidityAndCollectFees(DecreaseAndCollectFeesParams memory params) internal returns (uint256 amount0, uint256 amount1) {
        (uint256 positionAmount0, uint256 positionAmount1) = _decreaseLiquidity(params.nfpm, params.tokenId, params.liquidity, params.deadline, params.token0Min, params.token1Min);
        (amount0, amount1) = params.nfpm.collect(
            univ3.INonfungiblePositionManager.CollectParams(
                params.tokenId,
                address(this),
                type(uint128).max,
                type(uint128).max
            )
        );
        if (!params.compoundFees) {
            {
                uint256 fees0Return = amount0 - positionAmount0;
                uint256 fees1Return = amount1 - positionAmount1;
                // return feesToken
                if (fees0Return > 0) {
                    SafeERC20.safeTransfer(params.token0, params.userAddress, fees0Return);
                }
                if (fees1Return > 0) {
                    SafeERC20.safeTransfer(params.token1, params.userAddress, fees1Return);
                }
            }
            amount0 = positionAmount0;
            amount1 = positionAmount1;
        }
    }

    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 NotSupportedProtocol();
        }
    }

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

    /**
     * @notice calculate fee
     * @param emitEvent: whether to emit event or not. Since swap and mint have not had token id yet.
     * we need to emit event latter
     */
    function _deductFees(DeductFeesParams memory params, bool emitEvent) internal returns(uint256 amount0Left, uint256 amount1Left, uint256 amount2Left, uint256 feeAmount0, uint256 feeAmount1, uint256 feeAmount2) {
        if (params.feeX64 > _maxFeeX64[params.feeType]) {
            revert TooMuchFee();
        }

        // to save gas, we always need to check if fee exists before deductFees
        if (params.feeX64 == 0) {
            revert NoFees();
        }

        if (params.amount0 > 0) {
            feeAmount0 = FullMath.mulDiv(params.amount0, params.feeX64, Q64);
            amount0Left = params.amount0 - feeAmount0;
        }
        if (params.amount1 > 0) {
            feeAmount1 = FullMath.mulDiv(params.amount1, params.feeX64, Q64);
            amount1Left = params.amount1 - feeAmount1;
        }
        if (params.amount2 > 0) {
            feeAmount2 = FullMath.mulDiv(params.amount2, params.feeX64, Q64);
            amount2Left = params.amount2 - feeAmount2;
        }
        if (emitEvent) {
            emit DeductFees(address(params.nfpm), params.tokenId, params.userAddress, DeductFeesEventData(
                params.token0, params.token1, params.token2, 
                params.amount0, params.amount1, params.amount2, 
                feeAmount0, feeAmount1, feeAmount2,
                params.feeX64,
                params.feeType
            ));
        }
    }

    function pause() public onlyRole(ADMIN_ROLE) {
        _pause();
    }

    function unpause() public onlyRole(ADMIN_ROLE) {
        _unpause();
    }

    function setMaxFeeX64(FeeType feeType, uint64 feex64) external onlyRole(ADMIN_ROLE) {
        _maxFeeX64[feeType] = feex64;
    }

    function getMaxFeeX64(FeeType feeType) public view returns (uint64) {
        return _maxFeeX64[feeType];
    }

    /// @dev some tokens require allowance == 0 to approve new amount
    /// but some tokens does not allow approve ammount = 0
    /// we try to set allowance = 0 before approve new amount. if it revert means that
    /// the token not allow to approve 0, which means the following line code will work properly
    function _safeResetAndApprove(IERC20 token, address _spender, uint256 _value) internal {
        /// @dev ommited approve(0) result because it might fail and does not break the flow
        address(token).call(abi.encodeWithSelector(token.approve.selector, _spender, 0));

        /// @dev value for approval after reset must greater than 0
        require(_value > 0);
        _safeApprove(token, _spender, _value);
    }

    function _safeApprove(IERC20 token, address _spender, uint256 _value) internal {
        bytes memory returnData = address(token).functionCall(abi.encodeWithSelector(token.approve.selector, _spender, _value));
        if (returnData.length > 0) { // Return data is optional
            require(abi.decode(returnData, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 4 of 24 : 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 5 of 24 : 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 6 of 24 : 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 7 of 24 : FullMath.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.20;

import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    mapping(bytes32 role => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual returns (bool) {
        return _roles[role].hasRole[account];
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        if (!hasRole(role, account)) {
            _roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        if (hasRole(role, account)) {
            _roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}

File 9 of 24 : 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 10 of 24 : 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 11 of 24 : 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 12 of 24 : 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 13 of 24 : 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 14 of 24 : 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 15 of 24 : IPeripheryPayments.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;

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

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

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

File 16 of 24 : 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 17 of 24 : 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 18 of 24 : 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 19 of 24 : 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 20 of 24 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}

File 21 of 24 : 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 22 of 24 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 23 of 24 : 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 24 of 24 : 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":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"AlreadyInitialised","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":"GetPositionFailed","type":"error"},{"inputs":[],"name":"NoEtherToken","type":"error"},{"inputs":[],"name":"NoFees","type":"error"},{"inputs":[],"name":"NotSupportedAction","type":"error"},{"inputs":[],"name":"NotSupportedProtocol","type":"error"},{"inputs":[],"name":"NotWETH","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":"TooMuchEtherSent","type":"error"},{"inputs":[],"name":"TooMuchFee","type":"error"},{"inputs":[],"name":"TransferError","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"},{"indexed":false,"internalType":"uint256","name":"newLiquidity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"token0Added","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"token1Added","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":"nfpm","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"components":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"address","name":"token2","type":"address"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"uint256","name":"amount2","type":"uint256"},{"internalType":"uint256","name":"feeAmount0","type":"uint256"},{"internalType":"uint256","name":"feeAmount1","type":"uint256"},{"internalType":"uint256","name":"feeAmount2","type":"uint256"},{"internalType":"uint64","name":"feeX64","type":"uint64"},{"internalType":"enum Common.FeeType","name":"feeType","type":"uint8"}],"indexed":false,"internalType":"struct Common.DeductFeesEventData","name":"data","type":"tuple"}],"name":"DeductFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","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":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WITHDRAWER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"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 Common.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":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"bool","name":"compoundFees","type":"bool"},{"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":"bool","name":"unwrap","type":"bool"},{"internalType":"uint64","name":"protocolFeeX64","type":"uint64"}],"internalType":"struct V3Utils.Instructions","name":"instructions","type":"tuple"}],"name":"execute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum Common.FeeType","name":"feeType","type":"uint8"}],"name":"getMaxFeeX64","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"router","type":"address"},{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"withdrawer","type":"address"}],"name":"initialize","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":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum Common.FeeType","name":"feeType","type":"uint8"},{"internalType":"uint64","name":"feex64","type":"uint64"}],"name":"setMaxFeeX64","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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 Common.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":"uint256","name":"amount2","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":"uint64","name":"protocolFeeX64","type":"uint64"}],"internalType":"struct Common.SwapAndIncreaseLiquidityParams","name":"params","type":"tuple"}],"name":"swapAndIncreaseLiquidity","outputs":[{"components":[{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"added0","type":"uint256"},{"internalType":"uint256","name":"added1","type":"uint256"},{"internalType":"uint256","name":"feeAmount0","type":"uint256"},{"internalType":"uint256","name":"feeAmount1","type":"uint256"}],"internalType":"struct Common.SwapAndIncreaseLiquidityResult","name":"result","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"enum Common.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":"uint64","name":"protocolFeeX64","type":"uint64"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"uint256","name":"amount2","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 Common.SwapAndMintParams","name":"params","type":"tuple"}],"name":"swapAndMint","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"added0","type":"uint256"},{"internalType":"uint256","name":"added1","type":"uint256"}],"internalType":"struct Common.SwapAndMintResult","name":"result","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"swapRouter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","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"}]

60806040526003805460ff1916905534801561001a57600080fd5b506001805460ff1916815560026020527fac33ff75c19e70fe83507db0d683fd3465c996598dc972688b7ace676c89077b8054671999999999999a006001600160401b031991821681179092556000929092527fe90b7bceb6e7df5418fb78d8ee546e97c83a08bbccc01a0644d599ccd2a7c2e0805490921617905561567980620000a66000396000f3fe60806040526004361061014f5760003560e01c80637b9f76b5116100b6578063c01279421161006f578063c0127942146103f5578063c0c53b8b14610444578063c31c9c0714610464578063c8bfbbbe146104a1578063d547741f146104d9578063d6ee2b42146104f957600080fd5b80637b9f76b51461030b5780638456cb591461032b57806385f438c11461034057806391d1485414610362578063a217fddf14610382578063b60739b91461039757600080fd5b8063340ed32a11610108578063340ed32a1461026957806336568abe146102895780633f4ba83a146102a95780635c975abb146102be57806371c87886146102d657806375b238fc146102e957600080fd5b806301ffc9a71461015b5780631017cd5714610190578063150b7a02146101b2578063248a9ca3146101eb5780632f2ff15d146102295780632f622e6b1461024957600080fd5b3661015657005b600080fd5b34801561016757600080fd5b5061017b6101763660046142fb565b610519565b60405190151581526020015b60405180910390f35b34801561019c57600080fd5b506101b06101ab36600461434a565b610550565b005b3480156101be57600080fd5b506101d26101cd3660046143aa565b6105e0565b6040516001600160e01b03199091168152602001610187565b3480156101f757600080fd5b5061021b610206366004614448565b60009081526020819052604090206001015490565b604051908152602001610187565b34801561023557600080fd5b506101b0610244366004614461565b611222565b34801561025557600080fd5b506101b0610264366004614491565b61124d565b34801561027557600080fd5b506101b06102843660046144ae565b6112a7565b34801561029557600080fd5b506101b06102a4366004614461565b6113a8565b3480156102b557600080fd5b506101b06113db565b3480156102ca57600080fd5b5060015460ff1661017b565b61021b6102e4366004614528565b6113fe565b3480156102f557600080fd5b5061021b60008051602061562483398151915281565b34801561031757600080fd5b506101b0610326366004614563565b6115b0565b34801561033757600080fd5b506101b0611630565b34801561034c57600080fd5b5061021b60008051602061560483398151915281565b34801561036e57600080fd5b5061017b61037d366004614461565b611650565b34801561038e57600080fd5b5061021b600081565b6103aa6103a536600461459a565b611679565b6040516101879190600060a0820190506001600160801b0383511682526020830151602083015260408301516040830152606083015160608301526080830151608083015292915050565b6104086104033660046145d5565b611a00565b6040516101879190815181526020808301516001600160801b031690820152604080830151908201526060918201519181019190915260800190565b34801561045057600080fd5b506101b061045f366004614610565b611e65565b34801561047057600080fd5b506001546104899061010090046001600160a01b031681565b6040516001600160a01b039091168152602001610187565b3480156104ad57600080fd5b506104c16104bc366004614668565b611f1d565b6040516001600160401b039091168152602001610187565b3480156104e557600080fd5b506101b06104f4366004614461565b611f66565b34801561050557600080fd5b506101b061051436600461469c565b611f8b565b60006001600160e01b03198216637965db0b60e01b148061054a57506301ffc9a760e01b6001600160e01b03198316145b92915050565b610558612002565b826001600160a01b031663b88d4fde3330858560405160200161057b91906147db565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016105a994939291906149fc565b600060405180830381600087803b1580156105c357600080fd5b505af11580156105d7573d6000803e3d6000fd5b50505050505050565b60006105ea612002565b33306001600160a01b0387160361061457604051632797715160e01b815260040160405180910390fd5b600061062284860186614b61565b905060008060006106388585602001518b612028565b9550505050925092506000806106dd604051806101400160405280896001600160a01b031681526020018861024001516001600160a01b03168152602001876001600160a01b03168152602001866001600160a01b031681526020018d8152602001886101c001516001600160801b0316815260200188610220015181526020018860600151815260200188608001518152602001886101a0015115158152506121c5565b61028088015191935091506001600160401b03161561078d57610782604051806101600160405280848152602001838152602001600081526020018861028001516001600160401b0316815260200160018081111561073e5761073e6146e0565b81526001600160a01b03808b166020830152604082018f90526102408a0151811660608301528881166080830152871660a0820152600060c0909101526001612319565b509395509193505050505b8560a001518210806107a3575085610100015181105b156107c157604051634ff64a9f60e01b815260040160405180910390fd5b6002865160028111156107d6576107d66146e0565b03610b6e576107e3614204565b856001600160a01b031687604001516001600160a01b0316036108fc576108f560405180610240016040528089602001516001811115610825576108256146e0565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001876001600160a01b031681526020018961010001518152602001896101200151815260200189610140015181526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a6102600151612580565b9050610b06565b846001600160a01b031687604001516001600160a01b031603610a0b576108f56040518061024001604052808960200151600181111561093e5761093e6146e0565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001886001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018960a0015181526020018960c0015181526020018960e001518152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a6102600151612580565b610b0360405180610240016040528089602001516001811115610a3057610a306146e0565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b03168152602001896102200151815260200160006001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a6102600151612580565b90505b805160208083015160408085015181516001600160801b039095168552928401919091528201528c906001600160a01b038a16907f4a3d983c4891bedb0622c5a26f90b626e9451fe3a832b73ed9c886f1aa489cda906060015b60405180910390a3506111a6565b600086516002811115610b8357610b836146e0565b03610fcb57610b9061423c565b856001600160a01b031687604001516001600160a01b031603610ce657610cdf604051806102c0016040528089602001516001811115610bd257610bd26146e0565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001876001600160a01b031681526020018961010001518152602001896101200151815260200189610140015181526020016000815260200160008152602001604051806020016040528060008152508152602001896101e0015181526020018961020001518152508861026001516128c4565b9050610f6a565b846001600160a01b031687604001516001600160a01b031603610e3257610cdf604051806102c0016040528089602001516001811115610d2857610d286146e0565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001886001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018960a0015181526020018960c0015181526020018960e001518152602001896101e0015181526020018961020001518152508861026001516128c4565b610f67604051806102c0016040528089602001516001811115610e5757610e576146e0565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b03168152602001896102200151815260200160006001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020016000815260200160008152602001604051806020016040528060008152508152602001896101e0015181526020018961020001518152508861026001516128c4565b90505b805160208083015160408085015160608087015183519687526001600160801b039094169486019490945290840152908201528c9033907fe878b7324da2e10eb701c2cf0474248cdf5c088bb68aaf3045a6c15d1008b12d90608001610b60565b600186516002811115610fe057610fe06146e0565b0361118d576000610ff5888860200151612c0c565b9050600087604001516001600160a01b0316876001600160a01b03161461107357600080611032898b60400151888d60c001518e60e00151612ce6565b915091508582101561106057611060848b61024001518b858a6110559190614d2c565b8e6102600151613048565b61106a8184614d3f565b92505050611080565b61107d8482614d3f565b90505b87604001516001600160a01b0316866001600160a01b0316146110f1576000806110bb888b60400151878d61012001518e6101400151612ce6565b91509150848210156110de576110de848b61024001518a85896110559190614d2c565b6110e88184614d3f565b925050506110fe565b6110fb8382614d3f565b90505b8015801590611119575060408801516001600160a01b031615155b1561113957611139828961024001518a60400151848c6102600151613048565b60408089015181516001600160a01b039182168152602081018490528f92918c16917fc082f11600156d64071ed597a7b831f56741ad4e14954598e674e1ec2b61da0c910160405180910390a350506111a6565b60405163e83deb0f60e01b815260040160405180910390fd5b866001600160a01b03166323b872dd308e8e6040518463ffffffff1660e01b81526004016111d693929190614d52565b600060405180830381600087803b1580156111f057600080fd5b505af1158015611204573d6000803e3d6000fd5b50630a85bd0160e11b9a505050505050505050505095945050505050565b60008281526020819052604090206001015461123d81613151565b611247838361315b565b50505050565b60008051602061560483398151915261126581613151565b4780156112a2576040516001600160a01b0384169082156108fc029083906000818181858888f19350505050158015611247573d6000803e3d6000fd5b505050565b6000805160206156048339815191526112bf81613151565b8260005b818110156113a05760008686838181106112df576112df614d76565b90506020020160208101906112f49190614491565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa15801561133a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061135e9190614d8c565b905080156113975761139787878481811061137b5761137b614d76565b90506020020160208101906113909190614491565b86836131ed565b506001016112c3565b505050505050565b6001600160a01b03811633146113d15760405163334bd91960e11b815260040160405180910390fd5b6112a2828261324c565b6000805160206156248339815191526113f381613151565b6113fb6132b7565b50565b6000611408612002565b6114186060830160408401614491565b6001600160a01b03166114316040840160208501614491565b6001600160a01b0316036114585760405163100dac0560e11b815260040160405180910390fd5b6114886114686020840184614491565b6114786040850160208601614491565b6000808660600135600080613309565b60006114fe61149d6040850160208601614491565b6114ad6060860160408701614491565b606086013560808701356114c460c0890189614da5565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612ce692505050565b92509050811561154f5761154f6115186020850185614491565b61152860c0860160a08701614491565b6115386060870160408801614491565b8561154a610100890160e08a01614deb565b613048565b600061155f826060860135614d2c565b905080156115a9576115a96115776020860186614491565b61158760c0870160a08801614491565b6115976040880160208901614491565b8461154a6101008a0160e08b01614deb565b5050919050565b6000805160206156048339815191526115c881613151565b6040516323b872dd60e01b81526001600160a01b038516906323b872dd906115f890309086908890600401614d52565b600060405180830381600087803b15801561161257600080fd5b505af1158015611626573d6000803e3d6000fd5b5050505050505050565b60008051602061562483398151915261164881613151565b6113fb613811565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b611681614204565b611689612002565b600061169b6040840160208501614491565b6001600160a01b0316636352211e84604001356040518263ffffffff1660e01b81526004016116cc91815260200190565b602060405180830381865afa1580156116e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170d9190614e08565b90506001600160a01b038116331461176c5760405162461bcd60e51b815260206004820152601f60248201527f73656e646572206973206e6f74206f776e6572206f6620706f736974696f6e0060448201526064015b60405180910390fd5b6000806117996117826040870160208801614491565b61178f6020880188614668565b8760400135612028565b505050509150915060006117cb8660200160208101906117b99190614491565b6117c66020890189614668565b612c0c565b90506117f98184846117e56101208b016101008c01614491565b8a606001358b608001358c60a00135613309565b600061180487614e25565b9050600061181a61024089016102208a01614f66565b6001600160401b031611156119e7576118fc60405180610160016040528089606001358152602001896080013581526020018960a0013581526020018961022001602081019061186a9190614f66565b6001600160401b03168152602001600181526020018960200160208101906118929190614491565b6001600160a01b031681526040808b01356020830152016118b960e08b0160c08c01614491565b6001600160a01b0390811682528781166020830152861660408201526060016118ea6101208b016101008c01614491565b6001600160a01b031690526001612319565b50505060a0840152608083015260608201526101008101516001600160a01b038581169116148015906119465750826001600160a01b03168161010001516001600160a01b031614155b156119e7578060a001518161018001518261012001516119669190614d3f565b111561198557604051634ff64a9f60e01b815260040160405180910390fd5b8060a001518161018001518261012001516119a09190614d3f565b10156119e75760008161018001518261012001516119be9190614d3f565b8260a001516119cd9190614d2c565b90506119e58333846101000151843460001415613048565b505b6119f5818585341515612580565b979650505050505050565b611a0861423c565b611a10612002565b611a206080830160608401614491565b6001600160a01b0316611a396060840160408501614491565b6001600160a01b031603611a605760405163100dac0560e11b815260040160405180910390fd5b6000611a82611a756040850160208601614491565b6117c66020860186614668565b9050611ad181611a986060860160408701614491565b611aa86080870160608801614491565b611aba6101c088016101a08901614491565b876101000135886101200135896101400135613309565b6000611adc84614f9d565b9050611ae661426d565b6000611af9610100870160e08801614f66565b6001600160401b03161115611dde576000806000611c0d6040518061016001604052808a610100013581526020018a610120013581526020018a610140013581526020018a60e0016020810190611b509190614f66565b6001600160401b03168152602001600181526020018a6020016020810190611b789190614491565b6001600160a01b0316815260006020820152604001611b9f6101808c016101608d01614491565b6001600160a01b03168152602001611bbd60608c0160408d01614491565b6001600160a01b03168152602001611bdb60808c0160608d01614491565b6001600160a01b03168152602001611bfb6101c08c016101a08d01614491565b6001600160a01b031690526000612319565b6101408b01939093526101208a019390935261010089019390935260408801516101a089015193965091945092506001600160a01b03918216911614801590611c71575084606001516001600160a01b0316856101a001516001600160a01b031614155b15611d1557846101400151856102200151866101c00151611c929190614d3f565b1115611cb157604051634ff64a9f60e01b815260040160405180910390fd5b846101400151856102200151866101c00151611ccd9190614d3f565b1015611d15576000856102200151866101c00151611ceb9190614d3f565b866101400151611cfb9190614d2c565b9050611d138733886101a00151843460001415613048565b505b604051806101600160405280896040016020810190611d349190614491565b6001600160a01b03168152602001611d5260808b0160608c01614491565b6001600160a01b03168152602001611d726101c08b016101a08c01614491565b6001600160a01b031681526020018961010001358152602001896101200135815260200189610140013581526020018481526020018381526020018281526020018960e0016020810190611dc69190614f66565b6001600160401b031681526020016001905293505050505b611dea823415156128c4565b9350611dfe61018086016101608701614491565b84516001600160a01b039190911690611e1d6040880160208901614491565b6001600160a01b03167f07b9ff32d43e39b450a13b642c1e93282a8ea460336f1422bddc6164b304c2da84604051611e55919061512e565b60405180910390a4505050919050565b60035460ff1615611e8957604051633c3282e760e01b815260040160405180910390fd5b6001600160a01b038116611e9c57600080fd5b611eb46000805160206156248339815191528361315b565b50611ec060008361315b565b50611ed96000805160206156048339815191528261315b565b50611ee560008261315b565b5050600180546001600160a01b0390931661010002610100600160a81b0319909316929092178255506003805460ff19169091179055565b600060026000836001811115611f3557611f356146e0565b6001811115611f4657611f466146e0565b81526020810191909152604001600020546001600160401b031692915050565b600082815260208190526040902060010154611f8181613151565b611247838361324c565b600080516020615624833981519152611fa381613151565b8160026000856001811115611fba57611fba6146e0565b6001811115611fcb57611fcb6146e0565b815260200190815260200160002060006101000a8154816001600160401b0302191690836001600160401b03160217905550505050565b60015460ff16156120265760405163d93c066560e01b815260040160405180910390fd5b565b6000806000806000806000808a6001600160a01b03168960405160240161205191815260200190565b60408051601f198184030181529181526020820180516001600160e01b031663133f757160e31b1790525161208691906151e4565b6000604051808303816000865af19150503d80600081146120c3576040519150601f19603f3d011682016040523d82523d6000602084013e6120c8565b606091505b5091509150816120eb57604051631916db6f60e21b815260040160405180910390fd5b60008a60018111156120ff576120ff6146e0565b0361215657808060200190518101906121189190615227565b909192939495969798999a50909192939495969798995090919250909150905050809b50819950829a50839850849c50859d505050505050506121b7565b60018a600181111561216a5761216a6146e0565b036121b757808060200190518101906121839190615306565b90919293949596979899509091929394959697985090919250909150905050809a50819850829950839b50849c5050505050505b505093975093979195509350565b6000806000806121f2856000015186608001518760a001518860c001518960e001518a610100015161384c565b865160408051608080820183528a0151815230602082019081526001600160801b0382840181815260608401828152945163fc6f786560e01b81529351600485015291516001600160a01b03908116602485015291518116604484015292519092166064820152939550919350169063fc6f78659060840160408051808303816000875af1158015612288573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ac91906153de565b61012087015191955093506123125760006122c78386614d2c565b905060006122d58386614d2c565b905081156122f0576122f087604001518860200151846131ed565b80156123095761230987606001518860200151836131ed565b50508193508092505b5050915091565b600080600080600080600260008960800151600181111561233c5761233c6146e0565b600181111561234d5761234d6146e0565b815260208101919091526040016000205460608901516001600160401b039182169116111561238f57604051639a33400560e01b815260040160405180910390fd5b87606001516001600160401b03166000036123bd576040516303fbecdf60e51b815260040160405180910390fd5b8751156123f7576123e4886000015189606001516001600160401b0316600160401b613929565b88519093506123f4908490614d2c565b95505b60208801511561243657612421886020015189606001516001600160401b0316600160401b613929565b91508188602001516124339190614d2c565b94505b60408801511561247557612460886040015189606001516001600160401b0316600160401b613929565b90508088604001516124729190614d2c565b93505b8615612576578760e001516001600160a01b03168860c001518960a001516001600160a01b03167f07b9ff32d43e39b450a13b642c1e93282a8ea460336f1422bddc6164b304c2da6040518061016001604052808d61010001516001600160a01b031681526020018d61012001516001600160a01b031681526020018d61014001516001600160a01b031681526020018d6000015181526020018d6020015181526020018d6040015181526020018881526020018781526020018681526020018d606001516001600160401b031681526020018d60800151600181111561255e5761255e6146e0565b905260405161256d919061512e565b60405180910390a45b9295509295509295565b612588614204565b6000806126be604051806102c00160405280896000015160018111156125b0576125b06146e0565b815260200189602001516001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b03168152602001600062ffffff168152602001600060020b8152602001600060020b815260200160006001600160401b031681526020018960600151815260200189608001518152602001600081526020018960c001516001600160a01b031681526020018960e0015181526020018961010001516001600160a01b031681526020018961012001518152602001896101400151815260200189610160015181526020018961018001518152602001896101a001518152602001896101c001518152602001896101e001518152602001896102000151815250856139dc565b9150915060006040518060c0016040528089604001518152602001848152602001838152602001896101e00151815260200189610200015181526020018960e00151815250905087602001516001600160a01b031663219f5d17826040518263ffffffff1660e01b81526004016127749190600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b6060604051808303816000875af1158015612793573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b79190615402565b604087810182905260208089018490526001600160801b03949094168089528c8201518d860151835192835295820194909452808201929092525191926001600160a01b0316917fe96b62a2783f0eb40eb1daf87ed80a62c56c56e33c3669bf7f1ce575bd5d81ac9181900360600190a3600061283c89602001518a60000151612c0c565b90506128b8604051806101200160405280836001600160a01b031681526020018b60c001516001600160a01b031681526020018a6001600160a01b03168152602001896001600160a01b031681526020018681526020018581526020018760200151815260200187604001518152602001881515815250613c72565b50505050949350505050565b6128cc61423c565b6000806128d985856139dc565b90925090506000855160018111156128f3576128f36146e0565b036129b95761299a856020015160405180610160016040528088604001516001600160a01b0316815260200188606001516001600160a01b03168152602001886080015162ffffff1681526020018860a0015160020b81526020018860c0015160020b81526020018581526020018481526020018861028001518152602001886102a001518152602001306001600160a01b03168152602001886101800151815250613cea565b606087015260408601526001600160801b031660208501528352612a8e565b6001855160018111156129ce576129ce6146e0565b03612a755761299a856020015160405180610160016040528088604001516001600160a01b0316815260200188606001516001600160a01b03168152602001886080015162ffffff1681526020018860a0015160020b81526020018860c0015160020b81526020018581526020018481526020018861028001518152602001886102a001518152602001306001600160a01b03168152602001886101800151815250613d6f565b604051630e7b96f560e41b815260040160405180910390fd5b602085015161016086015184516040516323b872dd60e01b81526001600160a01b03909316926323b872dd92612ac8923092600401614d52565b600060405180830381600087803b158015612ae257600080fd5b505af1158015612af6573d6000803e3d6000fd5b50505050826000015185602001516001600160a01b03167fa9c03b58d729c750f50b2c6854d5db412e7faa78156e5ddf9225285e19011ff7856020015186604001518760600151604051612b68939291906001600160801b039390931683526020830191909152604082015260600190565b60405180910390a3612c04604051806101200160405280612b9188602001518960000151612c0c565b6001600160a01b031681526020018761016001516001600160a01b0316815260200187604001516001600160a01b0316815260200187606001516001600160a01b031681526020018481526020018381526020018560400151815260200185606001518152602001861515815250613c72565b505092915050565b600080826001811115612c2157612c216146e0565b03612c8f57826001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c889190614e08565b905061054a565b6001826001811115612ca357612ca36146e0565b03612a7557826001600160a01b0316638af3ac856040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c64573d6000803e3d6000fd5b6000808415801590612cf85750825115155b8015612d0c57506001600160a01b03861615155b1561303e576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa158015612d58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d7c9190614d8c565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038916906370a0823190602401602060405180830381865afa158015612dc6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dea9190614d8c565b9050612e0a8960018054906101000a90046001600160a01b031689613e86565b60015460405160009161010090046001600160a01b031690612e2d9088906151e4565b6000604051808303816000865af19150503d8060008114612e6a576040519150601f19603f3d011682016040523d82523d6000602084013e612e6f565b606091505b5050905080612eaf5760405162461bcd60e51b815260206004820152600c60248201526b73776170206661696c65642160a01b6044820152606401611763565b612ece8a60018054906101000a90046001600160a01b03166000613e86565b6040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015612f15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f399190614d8c565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015612f83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fa79190614d8c565b9050612fb38286614d2c565b9650612fbf8482614d2c565b955088861015612fe257604051630d4205a160e11b815260040160405180910390fd5b8a6001600160a01b03168c6001600160a01b03167ffa2dda1cc1b86e41239702756b13effbc1a092b5c57e3ad320fbe4f3b13fe2358989604051613030929190918252602082015260400190565b60405180910390a350505050505b9550959350505050565b826001600160a01b0316856001600160a01b03161480156130665750805b1561313f57604051632e1a7d4d60e01b8152600481018390526001600160a01b03861690632e1a7d4d90602401600060405180830381600087803b1580156130ad57600080fd5b505af11580156130c1573d6000803e3d6000fd5b505050506000846001600160a01b03168360405160006040518083038185875af1925050503d8060008114613112576040519150601f19603f3d011682016040523d82523d6000602084013e613117565b606091505b505090508061313957604051637cd69c3960e11b815260040160405180910390fd5b5061314a565b61314a8385846131ed565b5050505050565b6113fb8133613f5b565b60006131678383611650565b6131e5576000838152602081815260408083206001600160a01b03861684529091529020805460ff1916600117905561319d3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161054a565b50600061054a565b6040516001600160a01b038381166024830152604482018390526112a291859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050613f98565b60006132588383611650565b156131e5576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161054a565b6132bf613ffb565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60008080341561343b57896001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561334e57600080fd5b505af1158015613362573d6000803e3d6000fd5b5050505050886001600160a01b03168a6001600160a01b0316036133a957349250858311156133a4576040516307e205e160e41b815260040160405180910390fd5b61343b565b876001600160a01b03168a6001600160a01b0316036133e657349150848211156133a4576040516307e205e160e41b815260040160405180910390fd5b866001600160a01b03168a6001600160a01b031603613422575034838111156133a4576040516307e205e160e41b815260040160405180910390fd5b6040516392b0337360e01b815260040160405180910390fd5b82861115613567576040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa15801561348a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134ae9190614d8c565b90506134c58a33306134c0888c614d2c565b61401e565b6040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa15801561350c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135309190614d8c565b905061353c8589614d2c565b6135468383614d2c565b14613564576040516313ff771f60e21b815260040160405180910390fd5b50505b8185111561368e576040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156135b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135da9190614d8c565b90506135ec8933306134c0878b614d2c565b6040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa158015613633573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136579190614d8c565b90506136638488614d2c565b61366d8383614d2c565b1461368b576040516313ff771f60e21b815260040160405180910390fd5b50505b80841180156136a557506001600160a01b03871615155b80156136c35750866001600160a01b0316896001600160a01b031614155b80156136e15750866001600160a01b0316886001600160a01b031614155b15613805576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa15801561372d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137519190614d8c565b90506137638833306134c0868a614d2c565b6040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156137aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137ce9190614d8c565b90506137da8387614d2c565b6137e48383614d2c565b14613802576040516313ff771f60e21b815260040160405180910390fd5b50505b50505050505050505050565b613819612002565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258336132ec565b6000806001600160801b0386161561391e576040805160a0810182528881526001600160801b038089166020830190815282840188815260608401888152608085018b81529551630624e65f60e11b8152945160048601529151909216602484015290516044830152516064820152905160848201526001600160a01b03891690630c49ccbe9060a40160408051808303816000875af11580156138f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061391891906153de565b90925090505b965096945050505050565b6000808060001985870985870292508281108382030391505080600003613962576000841161395757600080fd5b5082900490506139d5565b80841161396e57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b60008083604001516001600160a01b0316846101a001516001600160a01b031603613a84578361022001518461010001511015613a2c57604051634ff64a9f60e01b815260040160405180910390fd5b600080613a53866040015187606001518861022001518961024001518a6102600151612ce6565b9150915081866101000151613a689190614d2c565b935080866101200151613a7b9190614d3f565b92505050613c39565b83606001516001600160a01b0316846101a001516001600160a01b031603613b2957836101c001518461012001511015613ad157604051634ff64a9f60e01b815260040160405180910390fd5b600080613af886606001518760400151886101c00151896101e001518a6102000151612ce6565b9150915081866101200151613b0d9190614d2c565b925080866101000151613b209190614d3f565b93505050613c39565b6101a08401516001600160a01b031615613c2a57600080613b65866101a001518760400151886101c00151896101e001518a6102000151612ce6565b91509150600080613b91886101a0015189606001518a61022001518b61024001518c6102600151612ce6565b9150915082886101000151613ba69190614d3f565b955080886101200151613bb99190614d3f565b9450600082858a61022001518b6101c00151613bd59190614d3f565b613bdf9190614d2c565b613be99190614d2c565b90508015613c20576000613c058a602001518b60000151612c0c565b9050613c1e818b61016001518c6101a00151858d613048565b505b5050505050613c39565b50506101008201516101208301515b8115613c5257613c528460400151856020015184614046565b8015613c6b57613c6b8460600151856020015183614046565b9250929050565b60008160c001518260800151613c889190614d2c565b905060008260e001518360a00151613ca09190614d2c565b90508115613cc657613cc683600001518460200151856040015185876101000151613048565b80156112a2576112a283600001518460200151856060015184876101000151613048565b600080600080856001600160a01b03166388316456866040518263ffffffff1660e01b8152600401613d1c9190615439565b6080604051808303816000875af1158015613d3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d5f91906154fd565b9299919850965090945092505050565b600080600080600060405180610140016040528087600001516001600160a01b0316815260200187602001516001600160a01b03168152602001876060015160020b8152602001876080015160020b81526020018760a0015181526020018760c0015181526020018760e0015181526020018761010001518152602001306001600160a01b031681526020018761014001518152509050866001600160a01b0316639cc1a283826040518263ffffffff1660e01b8152600401613e32919061553b565b6080604051808303816000875af1158015613e51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e7591906154fd565b929a91995097509095509350505050565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092019092526020810180516001600160e01b031663095ea7b360e01b179052600091613ede91908616906140fd565b8051909150156112475780806020019051810190613efc91906155e6565b6112475760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401611763565b613f658282611650565b613f945760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401611763565b5050565b6000613fad6001600160a01b038416836140fd565b90508051600014158015613fd2575080806020019051810190613fd091906155e6565b155b156112a257604051635274afe760e01b81526001600160a01b0384166004820152602401611763565b60015460ff1661202657604051638dfc202b60e01b815260040160405180910390fd5b61124784856001600160a01b03166323b872dd86868660405160240161321a93929190614d52565b604080516001600160a01b038481166024830152600060448084019190915283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1790529151918516916140a091906151e4565b6000604051808303816000865af19150503d80600081146140dd576040519150601f19603f3d011682016040523d82523d6000602084013e6140e2565b606091505b505050600081116140f257600080fd5b6112a2838383613e86565b60606139d58383600084600080856001600160a01b0316848660405161412391906151e4565b60006040518083038185875af1925050503d8060008114614160576040519150601f19603f3d011682016040523d82523d6000602084013e614165565b606091505b509150915061417586838361417f565b9695505050505050565b6060826141945761418f826141db565b6139d5565b81511580156141ab57506001600160a01b0384163b155b156141d457604051639996b31560e01b81526001600160a01b0385166004820152602401611763565b50806139d5565b8051156141eb5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6040518060a0016040528060006001600160801b03168152602001600081526020016000815260200160008152602001600081525090565b60405180608001604052806000815260200160006001600160801b0316815260200160008152602001600081525090565b60405180610160016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160401b03168152602001600060018111156142f6576142f66146e0565b905290565b60006020828403121561430d57600080fd5b81356001600160e01b0319811681146139d557600080fd5b6001600160a01b03811681146113fb57600080fd5b803561434581614325565b919050565b60008060006060848603121561435f57600080fd5b833561436a81614325565b92506020840135915060408401356001600160401b0381111561438c57600080fd5b84016102a0818703121561439f57600080fd5b809150509250925092565b6000806000806000608086880312156143c257600080fd5b85356143cd81614325565b945060208601356143dd81614325565b93506040860135925060608601356001600160401b038082111561440057600080fd5b818801915088601f83011261441457600080fd5b81358181111561442357600080fd5b89602082850101111561443557600080fd5b9699959850939650602001949392505050565b60006020828403121561445a57600080fd5b5035919050565b6000806040838503121561447457600080fd5b82359150602083013561448681614325565b809150509250929050565b6000602082840312156144a357600080fd5b81356139d581614325565b6000806000604084860312156144c357600080fd5b83356001600160401b03808211156144da57600080fd5b818601915086601f8301126144ee57600080fd5b8135818111156144fd57600080fd5b8760208260051b850101111561451257600080fd5b6020928301955093505084013561439f81614325565b60006020828403121561453a57600080fd5b81356001600160401b0381111561455057600080fd5b820161010081850312156139d557600080fd5b60008060006060848603121561457857600080fd5b833561458381614325565b925060208401359150604084013561439f81614325565b6000602082840312156145ac57600080fd5b81356001600160401b038111156145c257600080fd5b820161024081850312156139d557600080fd5b6000602082840312156145e757600080fd5b81356001600160401b038111156145fd57600080fd5b82016102c081850312156139d557600080fd5b60008060006060848603121561462557600080fd5b833561463081614325565b9250602084013561464081614325565b9150604084013561439f81614325565b600281106113fb57600080fd5b803561434581614650565b60006020828403121561467a57600080fd5b81356139d581614650565b80356001600160401b038116811461434557600080fd5b600080604083850312156146af57600080fd5b82356146ba81614650565b91506146c860208401614685565b90509250929050565b80356003811061434557600080fd5b634e487b7160e01b600052602160045260246000fd5b60038110614706576147066146e0565b9052565b60028110614706576147066146e0565b6000808335601e1984360301811261473157600080fd5b83016020810192503590506001600160401b0381111561475057600080fd5b803603821315613c6b57600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8060020b81146113fb57600080fd5b803561434581614788565b80151581146113fb57600080fd5b8035614345816147a2565b6001600160801b03811681146113fb57600080fd5b8035614345816147bb565b602081526147f4602082016147ef846146d1565b6146f6565b60006148026020840161465d565b61480f604084018261470a565b5061481c6040840161433a565b6001600160a01b03811660608401525060608301356080830152608083013560a083015260a083013560c083015260c083013560e083015261486160e084018461471a565b6102a0610100818187015261487b6102c08701848661475f565b9350610120925080870135838701525061014082870135818701526148a28188018861471a565b93509050610160601f1987860301818801526148bf85858461475f565b94506148cc818901614797565b935050506101806148e18187018460020b9052565b6148ec818801614797565b9250506101a06149008187018460020b9052565b61490b8188016147b0565b9250506101c061491e8187018415159052565b6149298188016147d0565b9250506101e0614943818701846001600160801b03169052565b61020092508087013583870152506102208287013581870152610240925080870135838701525061497582870161433a565b915061026061498e818701846001600160a01b03169052565b6149998188016147b0565b9250506102806149ac8187018415159052565b6149b7818801614685565b9250506149ce818601836001600160401b03169052565b5090949350505050565b60005b838110156149f35781810151838201526020016149db565b50506000910152565b600060018060a01b038087168352808616602084015250836040830152608060608301528251806080840152614a398160a08501602087016149d8565b601f01601f19169190910160a00195945050505050565b634e487b7160e01b600052604160045260246000fd5b6040516102a081016001600160401b0381118282101715614a8957614a89614a50565b60405290565b60405161024081016001600160401b0381118282101715614a8957614a89614a50565b6040516102c081016001600160401b0381118282101715614a8957614a89614a50565b600082601f830112614ae657600080fd5b81356001600160401b0380821115614b0057614b00614a50565b604051601f8301601f19908116603f01168101908282118183101715614b2857614b28614a50565b81604052838152866020858801011115614b4157600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060208284031215614b7357600080fd5b81356001600160401b0380821115614b8a57600080fd5b908301906102a08286031215614b9f57600080fd5b614ba7614a66565b614bb0836146d1565b8152614bbe6020840161465d565b6020820152614bcf6040840161433a565b6040820152606083013560608201526080830135608082015260a083013560a082015260c083013560c082015260e083013582811115614c0e57600080fd5b614c1a87828601614ad5565b60e083015250610100838101359082015261012080840135908201526101408084013583811115614c4a57600080fd5b614c5688828701614ad5565b8284015250506101609150614c6c828401614797565b828201526101809150614c80828401614797565b828201526101a09150614c948284016147b0565b828201526101c09150614ca88284016147d0565b918101919091526101e082810135908201526102008083013590820152610220808301359082015261024090614cdf82840161433a565b828201526102609150614cf38284016147b0565b828201526102809150614d07828401614685565b91810191909152949350505050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561054a5761054a614d16565b8082018082111561054a5761054a614d16565b6001600160a01b039384168152919092166020820152604081019190915260600190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215614d9e57600080fd5b5051919050565b6000808335601e19843603018112614dbc57600080fd5b8301803591506001600160401b03821115614dd657600080fd5b602001915036819003821315613c6b57600080fd5b600060208284031215614dfd57600080fd5b81356139d5816147a2565b600060208284031215614e1a57600080fd5b81516139d581614325565b60006102408236031215614e3857600080fd5b614e40614a8f565b614e498361465d565b8152614e576020840161433a565b602082015260408301356040820152606083013560608201526080830135608082015260a083013560a0820152614e9060c0840161433a565b60c082015260e083013560e0820152610100614ead81850161433a565b9082015261012083810135908201526101408084013590820152610160808401356001600160401b0380821115614ee357600080fd5b614eef36838801614ad5565b928401929092525061018084810135908301526101a080850135908301526101c090818501359080821115614f2357600080fd5b50614f3036828701614ad5565b8284015250506101e0808401358183015250610200808401358183015250610220614f5c818501614685565b9082015292915050565b600060208284031215614f7857600080fd5b6139d582614685565b62ffffff811681146113fb57600080fd5b803561434581614f81565b60006102c08236031215614fb057600080fd5b614fb8614ab2565b614fc18361465d565b8152614fcf6020840161433a565b6020820152614fe06040840161433a565b6040820152614ff16060840161433a565b606082015261500260808401614f92565b608082015261501360a08401614797565b60a082015261502460c08401614797565b60c082015261503560e08401614685565b60e082015261010083810135908201526101208084013590820152610140808401359082015261016061506981850161433a565b9082015261018083810135908201526101a061508681850161433a565b908201526101c083810135908201526101e08084013590820152610200808401356001600160401b03808211156150bc57600080fd5b6150c836838801614ad5565b928401929092525061022084810135908301526102408085013590830152610260908185013590808211156150fc57600080fd5b5061510936828701614ad5565b918301919091525061028083810135908201526102a092830135928101929092525090565b81516001600160a01b031681526101608101602083015161515a60208401826001600160a01b03169052565b50604083015161517560408401826001600160a01b03169052565b50606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516151cf828501826001600160401b03169052565b505061014080840151612c048285018261470a565b600082516151f68184602087016149d8565b9190910192915050565b80516bffffffffffffffffffffffff8116811461434557600080fd5b8051614345816147bb565b6000806000806000806000806000806000806101808d8f03121561524a57600080fd5b6152538d615200565b9b5060208d015161526381614325565b60408e0151909b5061527481614325565b60608e0151909a5061528581614325565b60808e015190995061529681614f81565b60a08e01519098506152a781614788565b60c08e01519097506152b881614788565b95506152c660e08e0161521c565b94506101008d015193506101208d015192506152e56101408e0161521c565b91506152f46101608e0161521c565b90509295989b509295989b509295989b565b60008060008060008060008060008060006101608c8e03121561532857600080fd5b6153318c615200565b9a5060208c015161534181614325565b60408d0151909a5061535281614325565b60608d015190995061536381614325565b60808d015190985061537481614788565b60a08d015190975061538581614788565b60c08d0151909650615396816147bb565b8095505060e08c015193506101008c015192506101208c01516153b8816147bb565b6101408d01519092506153ca816147bb565b809150509295989b509295989b9093969950565b600080604083850312156153f157600080fd5b505080516020909101519092909150565b60008060006060848603121561541757600080fd5b8351615422816147bb565b602085015160409095015190969495509392505050565b81516001600160a01b031681526101608101602083015161546560208401826001600160a01b03169052565b50604083015161547c604084018262ffffff169052565b506060830151615491606084018260020b9052565b5060808301516154a6608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516154ec828501826001600160a01b03169052565b505061014092830151919092015290565b6000806000806080858703121561551357600080fd5b845193506020850151615525816147bb565b6040860151606090960151949790965092505050565b81516001600160a01b031681526101408101602083015161556760208401826001600160a01b03169052565b50604083015161557c604084018260020b9052565b506060830151615591606084018260020b9052565b506080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401516155d5828501826001600160a01b03169052565b505061012092830151919092015290565b6000602082840312156155f857600080fd5b81516139d5816147a256fe10dac8c06a04bec0b551627dad28bc00d6516b0caacd1c7b345fcdb5211334e4a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775a26469706673582212209ddc6cd4440fa9f4db92483d86985fee400d0d1f6acbaa3736ad54cae21997ff64736f6c63430008170033

Deployed Bytecode

0x60806040526004361061014f5760003560e01c80637b9f76b5116100b6578063c01279421161006f578063c0127942146103f5578063c0c53b8b14610444578063c31c9c0714610464578063c8bfbbbe146104a1578063d547741f146104d9578063d6ee2b42146104f957600080fd5b80637b9f76b51461030b5780638456cb591461032b57806385f438c11461034057806391d1485414610362578063a217fddf14610382578063b60739b91461039757600080fd5b8063340ed32a11610108578063340ed32a1461026957806336568abe146102895780633f4ba83a146102a95780635c975abb146102be57806371c87886146102d657806375b238fc146102e957600080fd5b806301ffc9a71461015b5780631017cd5714610190578063150b7a02146101b2578063248a9ca3146101eb5780632f2ff15d146102295780632f622e6b1461024957600080fd5b3661015657005b600080fd5b34801561016757600080fd5b5061017b6101763660046142fb565b610519565b60405190151581526020015b60405180910390f35b34801561019c57600080fd5b506101b06101ab36600461434a565b610550565b005b3480156101be57600080fd5b506101d26101cd3660046143aa565b6105e0565b6040516001600160e01b03199091168152602001610187565b3480156101f757600080fd5b5061021b610206366004614448565b60009081526020819052604090206001015490565b604051908152602001610187565b34801561023557600080fd5b506101b0610244366004614461565b611222565b34801561025557600080fd5b506101b0610264366004614491565b61124d565b34801561027557600080fd5b506101b06102843660046144ae565b6112a7565b34801561029557600080fd5b506101b06102a4366004614461565b6113a8565b3480156102b557600080fd5b506101b06113db565b3480156102ca57600080fd5b5060015460ff1661017b565b61021b6102e4366004614528565b6113fe565b3480156102f557600080fd5b5061021b60008051602061562483398151915281565b34801561031757600080fd5b506101b0610326366004614563565b6115b0565b34801561033757600080fd5b506101b0611630565b34801561034c57600080fd5b5061021b60008051602061560483398151915281565b34801561036e57600080fd5b5061017b61037d366004614461565b611650565b34801561038e57600080fd5b5061021b600081565b6103aa6103a536600461459a565b611679565b6040516101879190600060a0820190506001600160801b0383511682526020830151602083015260408301516040830152606083015160608301526080830151608083015292915050565b6104086104033660046145d5565b611a00565b6040516101879190815181526020808301516001600160801b031690820152604080830151908201526060918201519181019190915260800190565b34801561045057600080fd5b506101b061045f366004614610565b611e65565b34801561047057600080fd5b506001546104899061010090046001600160a01b031681565b6040516001600160a01b039091168152602001610187565b3480156104ad57600080fd5b506104c16104bc366004614668565b611f1d565b6040516001600160401b039091168152602001610187565b3480156104e557600080fd5b506101b06104f4366004614461565b611f66565b34801561050557600080fd5b506101b061051436600461469c565b611f8b565b60006001600160e01b03198216637965db0b60e01b148061054a57506301ffc9a760e01b6001600160e01b03198316145b92915050565b610558612002565b826001600160a01b031663b88d4fde3330858560405160200161057b91906147db565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016105a994939291906149fc565b600060405180830381600087803b1580156105c357600080fd5b505af11580156105d7573d6000803e3d6000fd5b50505050505050565b60006105ea612002565b33306001600160a01b0387160361061457604051632797715160e01b815260040160405180910390fd5b600061062284860186614b61565b905060008060006106388585602001518b612028565b9550505050925092506000806106dd604051806101400160405280896001600160a01b031681526020018861024001516001600160a01b03168152602001876001600160a01b03168152602001866001600160a01b031681526020018d8152602001886101c001516001600160801b0316815260200188610220015181526020018860600151815260200188608001518152602001886101a0015115158152506121c5565b61028088015191935091506001600160401b03161561078d57610782604051806101600160405280848152602001838152602001600081526020018861028001516001600160401b0316815260200160018081111561073e5761073e6146e0565b81526001600160a01b03808b166020830152604082018f90526102408a0151811660608301528881166080830152871660a0820152600060c0909101526001612319565b509395509193505050505b8560a001518210806107a3575085610100015181105b156107c157604051634ff64a9f60e01b815260040160405180910390fd5b6002865160028111156107d6576107d66146e0565b03610b6e576107e3614204565b856001600160a01b031687604001516001600160a01b0316036108fc576108f560405180610240016040528089602001516001811115610825576108256146e0565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001876001600160a01b031681526020018961010001518152602001896101200151815260200189610140015181526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a6102600151612580565b9050610b06565b846001600160a01b031687604001516001600160a01b031603610a0b576108f56040518061024001604052808960200151600181111561093e5761093e6146e0565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001886001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018960a0015181526020018960c0015181526020018960e001518152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a6102600151612580565b610b0360405180610240016040528089602001516001811115610a3057610a306146e0565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b03168152602001896102200151815260200160006001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a6102600151612580565b90505b805160208083015160408085015181516001600160801b039095168552928401919091528201528c906001600160a01b038a16907f4a3d983c4891bedb0622c5a26f90b626e9451fe3a832b73ed9c886f1aa489cda906060015b60405180910390a3506111a6565b600086516002811115610b8357610b836146e0565b03610fcb57610b9061423c565b856001600160a01b031687604001516001600160a01b031603610ce657610cdf604051806102c0016040528089602001516001811115610bd257610bd26146e0565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001876001600160a01b031681526020018961010001518152602001896101200151815260200189610140015181526020016000815260200160008152602001604051806020016040528060008152508152602001896101e0015181526020018961020001518152508861026001516128c4565b9050610f6a565b846001600160a01b031687604001516001600160a01b031603610e3257610cdf604051806102c0016040528089602001516001811115610d2857610d286146e0565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001886001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018960a0015181526020018960c0015181526020018960e001518152602001896101e0015181526020018961020001518152508861026001516128c4565b610f67604051806102c0016040528089602001516001811115610e5757610e576146e0565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b03168152602001896102200151815260200160006001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020016000815260200160008152602001604051806020016040528060008152508152602001896101e0015181526020018961020001518152508861026001516128c4565b90505b805160208083015160408085015160608087015183519687526001600160801b039094169486019490945290840152908201528c9033907fe878b7324da2e10eb701c2cf0474248cdf5c088bb68aaf3045a6c15d1008b12d90608001610b60565b600186516002811115610fe057610fe06146e0565b0361118d576000610ff5888860200151612c0c565b9050600087604001516001600160a01b0316876001600160a01b03161461107357600080611032898b60400151888d60c001518e60e00151612ce6565b915091508582101561106057611060848b61024001518b858a6110559190614d2c565b8e6102600151613048565b61106a8184614d3f565b92505050611080565b61107d8482614d3f565b90505b87604001516001600160a01b0316866001600160a01b0316146110f1576000806110bb888b60400151878d61012001518e6101400151612ce6565b91509150848210156110de576110de848b61024001518a85896110559190614d2c565b6110e88184614d3f565b925050506110fe565b6110fb8382614d3f565b90505b8015801590611119575060408801516001600160a01b031615155b1561113957611139828961024001518a60400151848c6102600151613048565b60408089015181516001600160a01b039182168152602081018490528f92918c16917fc082f11600156d64071ed597a7b831f56741ad4e14954598e674e1ec2b61da0c910160405180910390a350506111a6565b60405163e83deb0f60e01b815260040160405180910390fd5b866001600160a01b03166323b872dd308e8e6040518463ffffffff1660e01b81526004016111d693929190614d52565b600060405180830381600087803b1580156111f057600080fd5b505af1158015611204573d6000803e3d6000fd5b50630a85bd0160e11b9a505050505050505050505095945050505050565b60008281526020819052604090206001015461123d81613151565b611247838361315b565b50505050565b60008051602061560483398151915261126581613151565b4780156112a2576040516001600160a01b0384169082156108fc029083906000818181858888f19350505050158015611247573d6000803e3d6000fd5b505050565b6000805160206156048339815191526112bf81613151565b8260005b818110156113a05760008686838181106112df576112df614d76565b90506020020160208101906112f49190614491565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa15801561133a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061135e9190614d8c565b905080156113975761139787878481811061137b5761137b614d76565b90506020020160208101906113909190614491565b86836131ed565b506001016112c3565b505050505050565b6001600160a01b03811633146113d15760405163334bd91960e11b815260040160405180910390fd5b6112a2828261324c565b6000805160206156248339815191526113f381613151565b6113fb6132b7565b50565b6000611408612002565b6114186060830160408401614491565b6001600160a01b03166114316040840160208501614491565b6001600160a01b0316036114585760405163100dac0560e11b815260040160405180910390fd5b6114886114686020840184614491565b6114786040850160208601614491565b6000808660600135600080613309565b60006114fe61149d6040850160208601614491565b6114ad6060860160408701614491565b606086013560808701356114c460c0890189614da5565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612ce692505050565b92509050811561154f5761154f6115186020850185614491565b61152860c0860160a08701614491565b6115386060870160408801614491565b8561154a610100890160e08a01614deb565b613048565b600061155f826060860135614d2c565b905080156115a9576115a96115776020860186614491565b61158760c0870160a08801614491565b6115976040880160208901614491565b8461154a6101008a0160e08b01614deb565b5050919050565b6000805160206156048339815191526115c881613151565b6040516323b872dd60e01b81526001600160a01b038516906323b872dd906115f890309086908890600401614d52565b600060405180830381600087803b15801561161257600080fd5b505af1158015611626573d6000803e3d6000fd5b5050505050505050565b60008051602061562483398151915261164881613151565b6113fb613811565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b611681614204565b611689612002565b600061169b6040840160208501614491565b6001600160a01b0316636352211e84604001356040518263ffffffff1660e01b81526004016116cc91815260200190565b602060405180830381865afa1580156116e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170d9190614e08565b90506001600160a01b038116331461176c5760405162461bcd60e51b815260206004820152601f60248201527f73656e646572206973206e6f74206f776e6572206f6620706f736974696f6e0060448201526064015b60405180910390fd5b6000806117996117826040870160208801614491565b61178f6020880188614668565b8760400135612028565b505050509150915060006117cb8660200160208101906117b99190614491565b6117c66020890189614668565b612c0c565b90506117f98184846117e56101208b016101008c01614491565b8a606001358b608001358c60a00135613309565b600061180487614e25565b9050600061181a61024089016102208a01614f66565b6001600160401b031611156119e7576118fc60405180610160016040528089606001358152602001896080013581526020018960a0013581526020018961022001602081019061186a9190614f66565b6001600160401b03168152602001600181526020018960200160208101906118929190614491565b6001600160a01b031681526040808b01356020830152016118b960e08b0160c08c01614491565b6001600160a01b0390811682528781166020830152861660408201526060016118ea6101208b016101008c01614491565b6001600160a01b031690526001612319565b50505060a0840152608083015260608201526101008101516001600160a01b038581169116148015906119465750826001600160a01b03168161010001516001600160a01b031614155b156119e7578060a001518161018001518261012001516119669190614d3f565b111561198557604051634ff64a9f60e01b815260040160405180910390fd5b8060a001518161018001518261012001516119a09190614d3f565b10156119e75760008161018001518261012001516119be9190614d3f565b8260a001516119cd9190614d2c565b90506119e58333846101000151843460001415613048565b505b6119f5818585341515612580565b979650505050505050565b611a0861423c565b611a10612002565b611a206080830160608401614491565b6001600160a01b0316611a396060840160408501614491565b6001600160a01b031603611a605760405163100dac0560e11b815260040160405180910390fd5b6000611a82611a756040850160208601614491565b6117c66020860186614668565b9050611ad181611a986060860160408701614491565b611aa86080870160608801614491565b611aba6101c088016101a08901614491565b876101000135886101200135896101400135613309565b6000611adc84614f9d565b9050611ae661426d565b6000611af9610100870160e08801614f66565b6001600160401b03161115611dde576000806000611c0d6040518061016001604052808a610100013581526020018a610120013581526020018a610140013581526020018a60e0016020810190611b509190614f66565b6001600160401b03168152602001600181526020018a6020016020810190611b789190614491565b6001600160a01b0316815260006020820152604001611b9f6101808c016101608d01614491565b6001600160a01b03168152602001611bbd60608c0160408d01614491565b6001600160a01b03168152602001611bdb60808c0160608d01614491565b6001600160a01b03168152602001611bfb6101c08c016101a08d01614491565b6001600160a01b031690526000612319565b6101408b01939093526101208a019390935261010089019390935260408801516101a089015193965091945092506001600160a01b03918216911614801590611c71575084606001516001600160a01b0316856101a001516001600160a01b031614155b15611d1557846101400151856102200151866101c00151611c929190614d3f565b1115611cb157604051634ff64a9f60e01b815260040160405180910390fd5b846101400151856102200151866101c00151611ccd9190614d3f565b1015611d15576000856102200151866101c00151611ceb9190614d3f565b866101400151611cfb9190614d2c565b9050611d138733886101a00151843460001415613048565b505b604051806101600160405280896040016020810190611d349190614491565b6001600160a01b03168152602001611d5260808b0160608c01614491565b6001600160a01b03168152602001611d726101c08b016101a08c01614491565b6001600160a01b031681526020018961010001358152602001896101200135815260200189610140013581526020018481526020018381526020018281526020018960e0016020810190611dc69190614f66565b6001600160401b031681526020016001905293505050505b611dea823415156128c4565b9350611dfe61018086016101608701614491565b84516001600160a01b039190911690611e1d6040880160208901614491565b6001600160a01b03167f07b9ff32d43e39b450a13b642c1e93282a8ea460336f1422bddc6164b304c2da84604051611e55919061512e565b60405180910390a4505050919050565b60035460ff1615611e8957604051633c3282e760e01b815260040160405180910390fd5b6001600160a01b038116611e9c57600080fd5b611eb46000805160206156248339815191528361315b565b50611ec060008361315b565b50611ed96000805160206156048339815191528261315b565b50611ee560008261315b565b5050600180546001600160a01b0390931661010002610100600160a81b0319909316929092178255506003805460ff19169091179055565b600060026000836001811115611f3557611f356146e0565b6001811115611f4657611f466146e0565b81526020810191909152604001600020546001600160401b031692915050565b600082815260208190526040902060010154611f8181613151565b611247838361324c565b600080516020615624833981519152611fa381613151565b8160026000856001811115611fba57611fba6146e0565b6001811115611fcb57611fcb6146e0565b815260200190815260200160002060006101000a8154816001600160401b0302191690836001600160401b03160217905550505050565b60015460ff16156120265760405163d93c066560e01b815260040160405180910390fd5b565b6000806000806000806000808a6001600160a01b03168960405160240161205191815260200190565b60408051601f198184030181529181526020820180516001600160e01b031663133f757160e31b1790525161208691906151e4565b6000604051808303816000865af19150503d80600081146120c3576040519150601f19603f3d011682016040523d82523d6000602084013e6120c8565b606091505b5091509150816120eb57604051631916db6f60e21b815260040160405180910390fd5b60008a60018111156120ff576120ff6146e0565b0361215657808060200190518101906121189190615227565b909192939495969798999a50909192939495969798995090919250909150905050809b50819950829a50839850849c50859d505050505050506121b7565b60018a600181111561216a5761216a6146e0565b036121b757808060200190518101906121839190615306565b90919293949596979899509091929394959697985090919250909150905050809a50819850829950839b50849c5050505050505b505093975093979195509350565b6000806000806121f2856000015186608001518760a001518860c001518960e001518a610100015161384c565b865160408051608080820183528a0151815230602082019081526001600160801b0382840181815260608401828152945163fc6f786560e01b81529351600485015291516001600160a01b03908116602485015291518116604484015292519092166064820152939550919350169063fc6f78659060840160408051808303816000875af1158015612288573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ac91906153de565b61012087015191955093506123125760006122c78386614d2c565b905060006122d58386614d2c565b905081156122f0576122f087604001518860200151846131ed565b80156123095761230987606001518860200151836131ed565b50508193508092505b5050915091565b600080600080600080600260008960800151600181111561233c5761233c6146e0565b600181111561234d5761234d6146e0565b815260208101919091526040016000205460608901516001600160401b039182169116111561238f57604051639a33400560e01b815260040160405180910390fd5b87606001516001600160401b03166000036123bd576040516303fbecdf60e51b815260040160405180910390fd5b8751156123f7576123e4886000015189606001516001600160401b0316600160401b613929565b88519093506123f4908490614d2c565b95505b60208801511561243657612421886020015189606001516001600160401b0316600160401b613929565b91508188602001516124339190614d2c565b94505b60408801511561247557612460886040015189606001516001600160401b0316600160401b613929565b90508088604001516124729190614d2c565b93505b8615612576578760e001516001600160a01b03168860c001518960a001516001600160a01b03167f07b9ff32d43e39b450a13b642c1e93282a8ea460336f1422bddc6164b304c2da6040518061016001604052808d61010001516001600160a01b031681526020018d61012001516001600160a01b031681526020018d61014001516001600160a01b031681526020018d6000015181526020018d6020015181526020018d6040015181526020018881526020018781526020018681526020018d606001516001600160401b031681526020018d60800151600181111561255e5761255e6146e0565b905260405161256d919061512e565b60405180910390a45b9295509295509295565b612588614204565b6000806126be604051806102c00160405280896000015160018111156125b0576125b06146e0565b815260200189602001516001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b03168152602001600062ffffff168152602001600060020b8152602001600060020b815260200160006001600160401b031681526020018960600151815260200189608001518152602001600081526020018960c001516001600160a01b031681526020018960e0015181526020018961010001516001600160a01b031681526020018961012001518152602001896101400151815260200189610160015181526020018961018001518152602001896101a001518152602001896101c001518152602001896101e001518152602001896102000151815250856139dc565b9150915060006040518060c0016040528089604001518152602001848152602001838152602001896101e00151815260200189610200015181526020018960e00151815250905087602001516001600160a01b031663219f5d17826040518263ffffffff1660e01b81526004016127749190600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b6060604051808303816000875af1158015612793573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b79190615402565b604087810182905260208089018490526001600160801b03949094168089528c8201518d860151835192835295820194909452808201929092525191926001600160a01b0316917fe96b62a2783f0eb40eb1daf87ed80a62c56c56e33c3669bf7f1ce575bd5d81ac9181900360600190a3600061283c89602001518a60000151612c0c565b90506128b8604051806101200160405280836001600160a01b031681526020018b60c001516001600160a01b031681526020018a6001600160a01b03168152602001896001600160a01b031681526020018681526020018581526020018760200151815260200187604001518152602001881515815250613c72565b50505050949350505050565b6128cc61423c565b6000806128d985856139dc565b90925090506000855160018111156128f3576128f36146e0565b036129b95761299a856020015160405180610160016040528088604001516001600160a01b0316815260200188606001516001600160a01b03168152602001886080015162ffffff1681526020018860a0015160020b81526020018860c0015160020b81526020018581526020018481526020018861028001518152602001886102a001518152602001306001600160a01b03168152602001886101800151815250613cea565b606087015260408601526001600160801b031660208501528352612a8e565b6001855160018111156129ce576129ce6146e0565b03612a755761299a856020015160405180610160016040528088604001516001600160a01b0316815260200188606001516001600160a01b03168152602001886080015162ffffff1681526020018860a0015160020b81526020018860c0015160020b81526020018581526020018481526020018861028001518152602001886102a001518152602001306001600160a01b03168152602001886101800151815250613d6f565b604051630e7b96f560e41b815260040160405180910390fd5b602085015161016086015184516040516323b872dd60e01b81526001600160a01b03909316926323b872dd92612ac8923092600401614d52565b600060405180830381600087803b158015612ae257600080fd5b505af1158015612af6573d6000803e3d6000fd5b50505050826000015185602001516001600160a01b03167fa9c03b58d729c750f50b2c6854d5db412e7faa78156e5ddf9225285e19011ff7856020015186604001518760600151604051612b68939291906001600160801b039390931683526020830191909152604082015260600190565b60405180910390a3612c04604051806101200160405280612b9188602001518960000151612c0c565b6001600160a01b031681526020018761016001516001600160a01b0316815260200187604001516001600160a01b0316815260200187606001516001600160a01b031681526020018481526020018381526020018560400151815260200185606001518152602001861515815250613c72565b505092915050565b600080826001811115612c2157612c216146e0565b03612c8f57826001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c889190614e08565b905061054a565b6001826001811115612ca357612ca36146e0565b03612a7557826001600160a01b0316638af3ac856040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c64573d6000803e3d6000fd5b6000808415801590612cf85750825115155b8015612d0c57506001600160a01b03861615155b1561303e576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa158015612d58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d7c9190614d8c565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038916906370a0823190602401602060405180830381865afa158015612dc6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dea9190614d8c565b9050612e0a8960018054906101000a90046001600160a01b031689613e86565b60015460405160009161010090046001600160a01b031690612e2d9088906151e4565b6000604051808303816000865af19150503d8060008114612e6a576040519150601f19603f3d011682016040523d82523d6000602084013e612e6f565b606091505b5050905080612eaf5760405162461bcd60e51b815260206004820152600c60248201526b73776170206661696c65642160a01b6044820152606401611763565b612ece8a60018054906101000a90046001600160a01b03166000613e86565b6040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015612f15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f399190614d8c565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015612f83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fa79190614d8c565b9050612fb38286614d2c565b9650612fbf8482614d2c565b955088861015612fe257604051630d4205a160e11b815260040160405180910390fd5b8a6001600160a01b03168c6001600160a01b03167ffa2dda1cc1b86e41239702756b13effbc1a092b5c57e3ad320fbe4f3b13fe2358989604051613030929190918252602082015260400190565b60405180910390a350505050505b9550959350505050565b826001600160a01b0316856001600160a01b03161480156130665750805b1561313f57604051632e1a7d4d60e01b8152600481018390526001600160a01b03861690632e1a7d4d90602401600060405180830381600087803b1580156130ad57600080fd5b505af11580156130c1573d6000803e3d6000fd5b505050506000846001600160a01b03168360405160006040518083038185875af1925050503d8060008114613112576040519150601f19603f3d011682016040523d82523d6000602084013e613117565b606091505b505090508061313957604051637cd69c3960e11b815260040160405180910390fd5b5061314a565b61314a8385846131ed565b5050505050565b6113fb8133613f5b565b60006131678383611650565b6131e5576000838152602081815260408083206001600160a01b03861684529091529020805460ff1916600117905561319d3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161054a565b50600061054a565b6040516001600160a01b038381166024830152604482018390526112a291859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050613f98565b60006132588383611650565b156131e5576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161054a565b6132bf613ffb565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60008080341561343b57896001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561334e57600080fd5b505af1158015613362573d6000803e3d6000fd5b5050505050886001600160a01b03168a6001600160a01b0316036133a957349250858311156133a4576040516307e205e160e41b815260040160405180910390fd5b61343b565b876001600160a01b03168a6001600160a01b0316036133e657349150848211156133a4576040516307e205e160e41b815260040160405180910390fd5b866001600160a01b03168a6001600160a01b031603613422575034838111156133a4576040516307e205e160e41b815260040160405180910390fd5b6040516392b0337360e01b815260040160405180910390fd5b82861115613567576040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa15801561348a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134ae9190614d8c565b90506134c58a33306134c0888c614d2c565b61401e565b6040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa15801561350c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135309190614d8c565b905061353c8589614d2c565b6135468383614d2c565b14613564576040516313ff771f60e21b815260040160405180910390fd5b50505b8185111561368e576040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156135b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135da9190614d8c565b90506135ec8933306134c0878b614d2c565b6040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa158015613633573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136579190614d8c565b90506136638488614d2c565b61366d8383614d2c565b1461368b576040516313ff771f60e21b815260040160405180910390fd5b50505b80841180156136a557506001600160a01b03871615155b80156136c35750866001600160a01b0316896001600160a01b031614155b80156136e15750866001600160a01b0316886001600160a01b031614155b15613805576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa15801561372d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137519190614d8c565b90506137638833306134c0868a614d2c565b6040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156137aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137ce9190614d8c565b90506137da8387614d2c565b6137e48383614d2c565b14613802576040516313ff771f60e21b815260040160405180910390fd5b50505b50505050505050505050565b613819612002565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258336132ec565b6000806001600160801b0386161561391e576040805160a0810182528881526001600160801b038089166020830190815282840188815260608401888152608085018b81529551630624e65f60e11b8152945160048601529151909216602484015290516044830152516064820152905160848201526001600160a01b03891690630c49ccbe9060a40160408051808303816000875af11580156138f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061391891906153de565b90925090505b965096945050505050565b6000808060001985870985870292508281108382030391505080600003613962576000841161395757600080fd5b5082900490506139d5565b80841161396e57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b60008083604001516001600160a01b0316846101a001516001600160a01b031603613a84578361022001518461010001511015613a2c57604051634ff64a9f60e01b815260040160405180910390fd5b600080613a53866040015187606001518861022001518961024001518a6102600151612ce6565b9150915081866101000151613a689190614d2c565b935080866101200151613a7b9190614d3f565b92505050613c39565b83606001516001600160a01b0316846101a001516001600160a01b031603613b2957836101c001518461012001511015613ad157604051634ff64a9f60e01b815260040160405180910390fd5b600080613af886606001518760400151886101c00151896101e001518a6102000151612ce6565b9150915081866101200151613b0d9190614d2c565b925080866101000151613b209190614d3f565b93505050613c39565b6101a08401516001600160a01b031615613c2a57600080613b65866101a001518760400151886101c00151896101e001518a6102000151612ce6565b91509150600080613b91886101a0015189606001518a61022001518b61024001518c6102600151612ce6565b9150915082886101000151613ba69190614d3f565b955080886101200151613bb99190614d3f565b9450600082858a61022001518b6101c00151613bd59190614d3f565b613bdf9190614d2c565b613be99190614d2c565b90508015613c20576000613c058a602001518b60000151612c0c565b9050613c1e818b61016001518c6101a00151858d613048565b505b5050505050613c39565b50506101008201516101208301515b8115613c5257613c528460400151856020015184614046565b8015613c6b57613c6b8460600151856020015183614046565b9250929050565b60008160c001518260800151613c889190614d2c565b905060008260e001518360a00151613ca09190614d2c565b90508115613cc657613cc683600001518460200151856040015185876101000151613048565b80156112a2576112a283600001518460200151856060015184876101000151613048565b600080600080856001600160a01b03166388316456866040518263ffffffff1660e01b8152600401613d1c9190615439565b6080604051808303816000875af1158015613d3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d5f91906154fd565b9299919850965090945092505050565b600080600080600060405180610140016040528087600001516001600160a01b0316815260200187602001516001600160a01b03168152602001876060015160020b8152602001876080015160020b81526020018760a0015181526020018760c0015181526020018760e0015181526020018761010001518152602001306001600160a01b031681526020018761014001518152509050866001600160a01b0316639cc1a283826040518263ffffffff1660e01b8152600401613e32919061553b565b6080604051808303816000875af1158015613e51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e7591906154fd565b929a91995097509095509350505050565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092019092526020810180516001600160e01b031663095ea7b360e01b179052600091613ede91908616906140fd565b8051909150156112475780806020019051810190613efc91906155e6565b6112475760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401611763565b613f658282611650565b613f945760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401611763565b5050565b6000613fad6001600160a01b038416836140fd565b90508051600014158015613fd2575080806020019051810190613fd091906155e6565b155b156112a257604051635274afe760e01b81526001600160a01b0384166004820152602401611763565b60015460ff1661202657604051638dfc202b60e01b815260040160405180910390fd5b61124784856001600160a01b03166323b872dd86868660405160240161321a93929190614d52565b604080516001600160a01b038481166024830152600060448084019190915283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1790529151918516916140a091906151e4565b6000604051808303816000865af19150503d80600081146140dd576040519150601f19603f3d011682016040523d82523d6000602084013e6140e2565b606091505b505050600081116140f257600080fd5b6112a2838383613e86565b60606139d58383600084600080856001600160a01b0316848660405161412391906151e4565b60006040518083038185875af1925050503d8060008114614160576040519150601f19603f3d011682016040523d82523d6000602084013e614165565b606091505b509150915061417586838361417f565b9695505050505050565b6060826141945761418f826141db565b6139d5565b81511580156141ab57506001600160a01b0384163b155b156141d457604051639996b31560e01b81526001600160a01b0385166004820152602401611763565b50806139d5565b8051156141eb5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6040518060a0016040528060006001600160801b03168152602001600081526020016000815260200160008152602001600081525090565b60405180608001604052806000815260200160006001600160801b0316815260200160008152602001600081525090565b60405180610160016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160401b03168152602001600060018111156142f6576142f66146e0565b905290565b60006020828403121561430d57600080fd5b81356001600160e01b0319811681146139d557600080fd5b6001600160a01b03811681146113fb57600080fd5b803561434581614325565b919050565b60008060006060848603121561435f57600080fd5b833561436a81614325565b92506020840135915060408401356001600160401b0381111561438c57600080fd5b84016102a0818703121561439f57600080fd5b809150509250925092565b6000806000806000608086880312156143c257600080fd5b85356143cd81614325565b945060208601356143dd81614325565b93506040860135925060608601356001600160401b038082111561440057600080fd5b818801915088601f83011261441457600080fd5b81358181111561442357600080fd5b89602082850101111561443557600080fd5b9699959850939650602001949392505050565b60006020828403121561445a57600080fd5b5035919050565b6000806040838503121561447457600080fd5b82359150602083013561448681614325565b809150509250929050565b6000602082840312156144a357600080fd5b81356139d581614325565b6000806000604084860312156144c357600080fd5b83356001600160401b03808211156144da57600080fd5b818601915086601f8301126144ee57600080fd5b8135818111156144fd57600080fd5b8760208260051b850101111561451257600080fd5b6020928301955093505084013561439f81614325565b60006020828403121561453a57600080fd5b81356001600160401b0381111561455057600080fd5b820161010081850312156139d557600080fd5b60008060006060848603121561457857600080fd5b833561458381614325565b925060208401359150604084013561439f81614325565b6000602082840312156145ac57600080fd5b81356001600160401b038111156145c257600080fd5b820161024081850312156139d557600080fd5b6000602082840312156145e757600080fd5b81356001600160401b038111156145fd57600080fd5b82016102c081850312156139d557600080fd5b60008060006060848603121561462557600080fd5b833561463081614325565b9250602084013561464081614325565b9150604084013561439f81614325565b600281106113fb57600080fd5b803561434581614650565b60006020828403121561467a57600080fd5b81356139d581614650565b80356001600160401b038116811461434557600080fd5b600080604083850312156146af57600080fd5b82356146ba81614650565b91506146c860208401614685565b90509250929050565b80356003811061434557600080fd5b634e487b7160e01b600052602160045260246000fd5b60038110614706576147066146e0565b9052565b60028110614706576147066146e0565b6000808335601e1984360301811261473157600080fd5b83016020810192503590506001600160401b0381111561475057600080fd5b803603821315613c6b57600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8060020b81146113fb57600080fd5b803561434581614788565b80151581146113fb57600080fd5b8035614345816147a2565b6001600160801b03811681146113fb57600080fd5b8035614345816147bb565b602081526147f4602082016147ef846146d1565b6146f6565b60006148026020840161465d565b61480f604084018261470a565b5061481c6040840161433a565b6001600160a01b03811660608401525060608301356080830152608083013560a083015260a083013560c083015260c083013560e083015261486160e084018461471a565b6102a0610100818187015261487b6102c08701848661475f565b9350610120925080870135838701525061014082870135818701526148a28188018861471a565b93509050610160601f1987860301818801526148bf85858461475f565b94506148cc818901614797565b935050506101806148e18187018460020b9052565b6148ec818801614797565b9250506101a06149008187018460020b9052565b61490b8188016147b0565b9250506101c061491e8187018415159052565b6149298188016147d0565b9250506101e0614943818701846001600160801b03169052565b61020092508087013583870152506102208287013581870152610240925080870135838701525061497582870161433a565b915061026061498e818701846001600160a01b03169052565b6149998188016147b0565b9250506102806149ac8187018415159052565b6149b7818801614685565b9250506149ce818601836001600160401b03169052565b5090949350505050565b60005b838110156149f35781810151838201526020016149db565b50506000910152565b600060018060a01b038087168352808616602084015250836040830152608060608301528251806080840152614a398160a08501602087016149d8565b601f01601f19169190910160a00195945050505050565b634e487b7160e01b600052604160045260246000fd5b6040516102a081016001600160401b0381118282101715614a8957614a89614a50565b60405290565b60405161024081016001600160401b0381118282101715614a8957614a89614a50565b6040516102c081016001600160401b0381118282101715614a8957614a89614a50565b600082601f830112614ae657600080fd5b81356001600160401b0380821115614b0057614b00614a50565b604051601f8301601f19908116603f01168101908282118183101715614b2857614b28614a50565b81604052838152866020858801011115614b4157600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060208284031215614b7357600080fd5b81356001600160401b0380821115614b8a57600080fd5b908301906102a08286031215614b9f57600080fd5b614ba7614a66565b614bb0836146d1565b8152614bbe6020840161465d565b6020820152614bcf6040840161433a565b6040820152606083013560608201526080830135608082015260a083013560a082015260c083013560c082015260e083013582811115614c0e57600080fd5b614c1a87828601614ad5565b60e083015250610100838101359082015261012080840135908201526101408084013583811115614c4a57600080fd5b614c5688828701614ad5565b8284015250506101609150614c6c828401614797565b828201526101809150614c80828401614797565b828201526101a09150614c948284016147b0565b828201526101c09150614ca88284016147d0565b918101919091526101e082810135908201526102008083013590820152610220808301359082015261024090614cdf82840161433a565b828201526102609150614cf38284016147b0565b828201526102809150614d07828401614685565b91810191909152949350505050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561054a5761054a614d16565b8082018082111561054a5761054a614d16565b6001600160a01b039384168152919092166020820152604081019190915260600190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215614d9e57600080fd5b5051919050565b6000808335601e19843603018112614dbc57600080fd5b8301803591506001600160401b03821115614dd657600080fd5b602001915036819003821315613c6b57600080fd5b600060208284031215614dfd57600080fd5b81356139d5816147a2565b600060208284031215614e1a57600080fd5b81516139d581614325565b60006102408236031215614e3857600080fd5b614e40614a8f565b614e498361465d565b8152614e576020840161433a565b602082015260408301356040820152606083013560608201526080830135608082015260a083013560a0820152614e9060c0840161433a565b60c082015260e083013560e0820152610100614ead81850161433a565b9082015261012083810135908201526101408084013590820152610160808401356001600160401b0380821115614ee357600080fd5b614eef36838801614ad5565b928401929092525061018084810135908301526101a080850135908301526101c090818501359080821115614f2357600080fd5b50614f3036828701614ad5565b8284015250506101e0808401358183015250610200808401358183015250610220614f5c818501614685565b9082015292915050565b600060208284031215614f7857600080fd5b6139d582614685565b62ffffff811681146113fb57600080fd5b803561434581614f81565b60006102c08236031215614fb057600080fd5b614fb8614ab2565b614fc18361465d565b8152614fcf6020840161433a565b6020820152614fe06040840161433a565b6040820152614ff16060840161433a565b606082015261500260808401614f92565b608082015261501360a08401614797565b60a082015261502460c08401614797565b60c082015261503560e08401614685565b60e082015261010083810135908201526101208084013590820152610140808401359082015261016061506981850161433a565b9082015261018083810135908201526101a061508681850161433a565b908201526101c083810135908201526101e08084013590820152610200808401356001600160401b03808211156150bc57600080fd5b6150c836838801614ad5565b928401929092525061022084810135908301526102408085013590830152610260908185013590808211156150fc57600080fd5b5061510936828701614ad5565b918301919091525061028083810135908201526102a092830135928101929092525090565b81516001600160a01b031681526101608101602083015161515a60208401826001600160a01b03169052565b50604083015161517560408401826001600160a01b03169052565b50606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516151cf828501826001600160401b03169052565b505061014080840151612c048285018261470a565b600082516151f68184602087016149d8565b9190910192915050565b80516bffffffffffffffffffffffff8116811461434557600080fd5b8051614345816147bb565b6000806000806000806000806000806000806101808d8f03121561524a57600080fd5b6152538d615200565b9b5060208d015161526381614325565b60408e0151909b5061527481614325565b60608e0151909a5061528581614325565b60808e015190995061529681614f81565b60a08e01519098506152a781614788565b60c08e01519097506152b881614788565b95506152c660e08e0161521c565b94506101008d015193506101208d015192506152e56101408e0161521c565b91506152f46101608e0161521c565b90509295989b509295989b509295989b565b60008060008060008060008060008060006101608c8e03121561532857600080fd5b6153318c615200565b9a5060208c015161534181614325565b60408d0151909a5061535281614325565b60608d015190995061536381614325565b60808d015190985061537481614788565b60a08d015190975061538581614788565b60c08d0151909650615396816147bb565b8095505060e08c015193506101008c015192506101208c01516153b8816147bb565b6101408d01519092506153ca816147bb565b809150509295989b509295989b9093969950565b600080604083850312156153f157600080fd5b505080516020909101519092909150565b60008060006060848603121561541757600080fd5b8351615422816147bb565b602085015160409095015190969495509392505050565b81516001600160a01b031681526101608101602083015161546560208401826001600160a01b03169052565b50604083015161547c604084018262ffffff169052565b506060830151615491606084018260020b9052565b5060808301516154a6608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516154ec828501826001600160a01b03169052565b505061014092830151919092015290565b6000806000806080858703121561551357600080fd5b845193506020850151615525816147bb565b6040860151606090960151949790965092505050565b81516001600160a01b031681526101408101602083015161556760208401826001600160a01b03169052565b50604083015161557c604084018260020b9052565b506060830151615591606084018260020b9052565b506080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401516155d5828501826001600160a01b03169052565b505061012092830151919092015290565b6000602082840312156155f857600080fd5b81516139d5816147a256fe10dac8c06a04bec0b551627dad28bc00d6516b0caacd1c7b345fcdb5211334e4a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775a26469706673582212209ddc6cd4440fa9f4db92483d86985fee400d0d1f6acbaa3736ad54cae21997ff64736f6c63430008170033

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
Chain Token Portfolio % Price Amount Value
ETH17.44%$0.000022155,035.82$3.41
ETH17.29%$0.00008141,566.3998$3.38
ETH11.71%$0.02870679.7935$2.29
ETH11.47%$1.471.5258$2.24
ETH8.47%$0.3648984.5436$1.66
ETH5.23%$0.2605223.9287$1.02
ETH5.05%$0.5200131.9$0.988
ETH4.41%$0.1661195.1949$0.8629
ETH3.55%$0.5562191.2469$0.6935
ETH3.07%$0.0139842.9145$0.5999
ETH2.70%$2.90.1823$0.5284
ETH2.17%$14.380.0296$0.4252
ETH1.80%$0.0002611,351.6504$0.3529
ETH1.71%$0.000668501.5345$0.335
ETH1.30%$3,768.870.00006741$0.254
ETH1.09%$0.00319266.918$0.2135
ETH0.83%$0.0457693.5579$0.1628
ETH0.70%$0.0001321,030.1327$0.1363
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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