ETH Price: $3,526.65 (-2.00%)

Contract

0xE2b9626620223106786BAa744d92492E06537205
 

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
Initialize29161692024-05-02 9:29:1346 days ago1714642153IN
0xE2b96266...E06537205
0 ETH00.00000084

Latest 1 internal transaction

Advanced mode:
Parent Transaction Hash Block From To Value
29161562024-05-02 9:28:4746 days ago1714642127  Contract Creation0 ETH

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
V3Utils

Compiler Version
v0.8.23+commit.f704f362

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 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, 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;
        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), 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);
                }
            }
        }
        result = _swapAndMint(_params, msg.value != 0);
    }

    /// @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 {
    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;
        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) {
            params.token0.approve(address(params.nfpm), total0);
        }
        if (total1 != 0) {
            params.token1.approve(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
            tokenIn.approve(swapRouter, amountIn);
            // execute swap
            (bool success,) = swapRouter.call(swapData);
            if (!success) {
                revert ("swap failed!");
            }

            // reset approval
            tokenIn.approve(swapRouter, 0);

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

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

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

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

    // decreases liquidity from uniswap v3 position
    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) {
                    params.token0.transfer(msg.sender, fees0Return);
                }
                if (fees1Return > 0) {
                    params.token1.transfer(msg.sender, 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];
    }
}

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"}]

60806040526003805460ff1916905534801561001a57600080fd5b506001805460ff1916815560026020527fac33ff75c19e70fe83507db0d683fd3465c996598dc972688b7ace676c89077b8054671999999999999a006001600160401b031991821681179092556000929092527fe90b7bceb6e7df5418fb78d8ee546e97c83a08bbccc01a0644d599ccd2a7c2e08054909216179055615555806100a56000396000f3fe60806040526004361061014f5760003560e01c80637b9f76b5116100b6578063c01279421161006f578063c0127942146103f5578063c0c53b8b14610444578063c31c9c0714610464578063c8bfbbbe146104a1578063d547741f146104d9578063d6ee2b42146104f957600080fd5b80637b9f76b51461030b5780638456cb591461032b57806385f438c11461034057806391d1485414610362578063a217fddf14610382578063b60739b91461039757600080fd5b8063340ed32a11610108578063340ed32a1461026957806336568abe146102895780633f4ba83a146102a95780635c975abb146102be57806371c87886146102d657806375b238fc146102e957600080fd5b806301ffc9a71461015b5780631017cd5714610190578063150b7a02146101b2578063248a9ca3146101eb5780632f2ff15d146102295780632f622e6b1461024957600080fd5b3661015657005b600080fd5b34801561016757600080fd5b5061017b6101763660046141d7565b610519565b60405190151581526020015b60405180910390f35b34801561019c57600080fd5b506101b06101ab366004614226565b610550565b005b3480156101be57600080fd5b506101d26101cd366004614286565b6105e0565b6040516001600160e01b03199091168152602001610187565b3480156101f757600080fd5b5061021b610206366004614324565b60009081526020819052604090206001015490565b604051908152602001610187565b34801561023557600080fd5b506101b061024436600461433d565b61120e565b34801561025557600080fd5b506101b061026436600461436d565b611239565b34801561027557600080fd5b506101b061028436600461438a565b611293565b34801561029557600080fd5b506101b06102a436600461433d565b611394565b3480156102b557600080fd5b506101b06113c7565b3480156102ca57600080fd5b5060015460ff1661017b565b61021b6102e4366004614404565b6113ea565b3480156102f557600080fd5b5061021b60008051602061550083398151915281565b34801561031757600080fd5b506101b061032636600461443f565b61159c565b34801561033757600080fd5b506101b061161c565b34801561034c57600080fd5b5061021b6000805160206154e083398151915281565b34801561036e57600080fd5b5061017b61037d36600461433d565b61163c565b34801561038e57600080fd5b5061021b600081565b6103aa6103a5366004614476565b611665565b6040516101879190600060a0820190506001600160801b0383511682526020830151602083015260408301516040830152606083015160608301526080830151608083015292915050565b6104086104033660046144b1565b6119ec565b6040516101879190815181526020808301516001600160801b031690820152604080830151908201526060918201519181019190915260800190565b34801561045057600080fd5b506101b061045f3660046144ec565b611cfa565b34801561047057600080fd5b506001546104899061010090046001600160a01b031681565b6040516001600160a01b039091168152602001610187565b3480156104ad57600080fd5b506104c16104bc366004614544565b611db2565b6040516001600160401b039091168152602001610187565b3480156104e557600080fd5b506101b06104f436600461433d565b611dfb565b34801561050557600080fd5b506101b0610514366004614578565b611e20565b60006001600160e01b03198216637965db0b60e01b148061054a57506301ffc9a760e01b6001600160e01b03198316145b92915050565b610558611e97565b826001600160a01b031663b88d4fde3330858560405160200161057b91906146b7565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016105a994939291906148d8565b600060405180830381600087803b1580156105c357600080fd5b505af11580156105d7573d6000803e3d6000fd5b50505050505050565b60006105ea611e97565b33306001600160a01b0387160361061457604051632797715160e01b815260040160405180910390fd5b600061062284860186614a3d565b905060008060006106388585602001518b611ebd565b9550505050925092506000806106c9604051806101200160405280896001600160a01b03168152602001876001600160a01b03168152602001866001600160a01b031681526020018d8152602001886101c001516001600160801b0316815260200188610220015181526020018860600151815260200188608001518152602001886101a00151151581525061205a565b61028088015191935091506001600160401b0316156107795761076e604051806101600160405280848152602001838152602001600081526020018861028001516001600160401b0316815260200160018081111561072a5761072a6145bc565b81526001600160a01b03808b166020830152604082018f90526102408a0151811660608301528881166080830152871660a0820152600060c090910152600161227a565b509395509193505050505b8560a0015182108061078f575085610100015181105b156107ad57604051634ff64a9f60e01b815260040160405180910390fd5b6002865160028111156107c2576107c26145bc565b03610b5a576107cf61416e565b856001600160a01b031687604001516001600160a01b0316036108e8576108e160405180610240016040528089602001516001811115610811576108116145bc565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001876001600160a01b031681526020018961010001518152602001896101200151815260200189610140015181526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a61026001516124e1565b9050610af2565b846001600160a01b031687604001516001600160a01b0316036109f7576108e16040518061024001604052808960200151600181111561092a5761092a6145bc565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001886001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018960a0015181526020018960c0015181526020018960e001518152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a61026001516124e1565b610aef60405180610240016040528089602001516001811115610a1c57610a1c6145bc565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b03168152602001896102200151815260200160006001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a61026001516124e1565b90505b805160208083015160408085015181516001600160801b039095168552928401919091528201528c906001600160a01b038a16907f4a3d983c4891bedb0622c5a26f90b626e9451fe3a832b73ed9c886f1aa489cda906060015b60405180910390a350611192565b600086516002811115610b6f57610b6f6145bc565b03610fb757610b7c6141a6565b856001600160a01b031687604001516001600160a01b031603610cd257610ccb604051806102c0016040528089602001516001811115610bbe57610bbe6145bc565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001876001600160a01b031681526020018961010001518152602001896101200151815260200189610140015181526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815250886102600151612825565b9050610f56565b846001600160a01b031687604001516001600160a01b031603610e1e57610ccb604051806102c0016040528089602001516001811115610d1457610d146145bc565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001886001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018960a0015181526020018960c0015181526020018960e001518152602001896101e001518152602001896102000151815250886102600151612825565b610f53604051806102c0016040528089602001516001811115610e4357610e436145bc565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b03168152602001896102200151815260200160006001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815250886102600151612825565b90505b805160208083015160408085015160608087015183519687526001600160801b039094169486019490945290840152908201528c9033907fe878b7324da2e10eb701c2cf0474248cdf5c088bb68aaf3045a6c15d1008b12d90608001610b4c565b600186516002811115610fcc57610fcc6145bc565b03611179576000610fe1888860200151612b6d565b9050600087604001516001600160a01b0316876001600160a01b03161461105f5760008061101e898b60400151888d60c001518e60e00151612c47565b915091508582101561104c5761104c848b61024001518b858a6110419190614c08565b8e6102600151613066565b6110568184614c1b565b9250505061106c565b6110698482614c1b565b90505b87604001516001600160a01b0316866001600160a01b0316146110dd576000806110a7888b60400151878d61012001518e6101400151612c47565b91509150848210156110ca576110ca848b61024001518a85896110419190614c08565b6110d48184614c1b565b925050506110ea565b6110e78382614c1b565b90505b8015801590611105575060408801516001600160a01b031615155b1561112557611125828961024001518a60400151848c6102600151613066565b60408089015181516001600160a01b039182168152602081018490528f92918c16917fc082f11600156d64071ed597a7b831f56741ad4e14954598e674e1ec2b61da0c910160405180910390a35050611192565b60405163e83deb0f60e01b815260040160405180910390fd5b866001600160a01b03166323b872dd308e8e6040518463ffffffff1660e01b81526004016111c293929190614c2e565b600060405180830381600087803b1580156111dc57600080fd5b505af11580156111f0573d6000803e3d6000fd5b50630a85bd0160e11b9a505050505050505050505095945050505050565b6000828152602081905260409020600101546112298161316f565b6112338383613179565b50505050565b6000805160206154e08339815191526112518161316f565b47801561128e576040516001600160a01b0384169082156108fc029083906000818181858888f19350505050158015611233573d6000803e3d6000fd5b505050565b6000805160206154e08339815191526112ab8161316f565b8260005b8181101561138c5760008686838181106112cb576112cb614c52565b90506020020160208101906112e0919061436d565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015611326573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061134a9190614c68565b905080156113835761138387878481811061136757611367614c52565b905060200201602081019061137c919061436d565b868361320b565b506001016112af565b505050505050565b6001600160a01b03811633146113bd5760405163334bd91960e11b815260040160405180910390fd5b61128e828261326a565b6000805160206155008339815191526113df8161316f565b6113e76132d5565b50565b60006113f4611e97565b611404606083016040840161436d565b6001600160a01b031661141d604084016020850161436d565b6001600160a01b0316036114445760405163100dac0560e11b815260040160405180910390fd5b611474611454602084018461436d565b611464604085016020860161436d565b6000808660600135600080613327565b60006114ea611489604085016020860161436d565b611499606086016040870161436d565b606086013560808701356114b060c0890189614c81565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612c4792505050565b92509050811561153b5761153b611504602085018561436d565b61151460c0860160a0870161436d565b611524606087016040880161436d565b85611536610100890160e08a01614cc7565b613066565b600061154b826060860135614c08565b9050801561159557611595611563602086018661436d565b61157360c0870160a0880161436d565b611583604088016020890161436d565b846115366101008a0160e08b01614cc7565b5050919050565b6000805160206154e08339815191526115b48161316f565b6040516323b872dd60e01b81526001600160a01b038516906323b872dd906115e490309086908890600401614c2e565b600060405180830381600087803b1580156115fe57600080fd5b505af1158015611612573d6000803e3d6000fd5b5050505050505050565b6000805160206155008339815191526116348161316f565b6113e761382f565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b61166d61416e565b611675611e97565b6000611687604084016020850161436d565b6001600160a01b0316636352211e84604001356040518263ffffffff1660e01b81526004016116b891815260200190565b602060405180830381865afa1580156116d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116f99190614ce4565b90506001600160a01b03811633146117585760405162461bcd60e51b815260206004820152601f60248201527f73656e646572206973206e6f74206f776e6572206f6620706f736974696f6e0060448201526064015b60405180910390fd5b60008061178561176e604087016020880161436d565b61177b6020880188614544565b8760400135611ebd565b505050509150915060006117b78660200160208101906117a5919061436d565b6117b26020890189614544565b612b6d565b90506117e58184846117d16101208b016101008c0161436d565b8a606001358b608001358c60a00135613327565b60006117f087614d01565b9050600061180661024089016102208a01614e42565b6001600160401b031611156119d3576118e860405180610160016040528089606001358152602001896080013581526020018960a001358152602001896102200160208101906118569190614e42565b6001600160401b031681526020016001815260200189602001602081019061187e919061436d565b6001600160a01b031681526040808b01356020830152016118a560e08b0160c08c0161436d565b6001600160a01b0390811682528781166020830152861660408201526060016118d66101208b016101008c0161436d565b6001600160a01b03169052600161227a565b50505060a0840152608083015260608201526101008101516001600160a01b038581169116148015906119325750826001600160a01b03168161010001516001600160a01b031614155b156119d3578060a001518161018001518261012001516119529190614c1b565b111561197157604051634ff64a9f60e01b815260040160405180910390fd5b8060a0015181610180015182610120015161198c9190614c1b565b10156119d35760008161018001518261012001516119aa9190614c1b565b8260a001516119b99190614c08565b90506119d18333846101000151843460001415613066565b505b6119e18185853415156124e1565b979650505050505050565b6119f46141a6565b6119fc611e97565b611a0c608083016060840161436d565b6001600160a01b0316611a25606084016040850161436d565b6001600160a01b031603611a4c5760405163100dac0560e11b815260040160405180910390fd5b6000611a6e611a61604085016020860161436d565b6117b26020860186614544565b9050611abd81611a84606086016040870161436d565b611a94608087016060880161436d565b611aa66101c088016101a0890161436d565b876101000135886101200135896101400135613327565b6000611ac884614e79565b90506000611add610100860160e08701614e42565b6001600160401b03161115611ce657611bec6040518061016001604052808661010001358152602001866101200135815260200186610140013581526020018660e0016020810190611b2f9190614e42565b6001600160401b0316815260200160018152602001866020016020810190611b57919061436d565b6001600160a01b0316815260006020820152604001611b7e6101808801610160890161436d565b6001600160a01b03168152602001611b9c606088016040890161436d565b6001600160a01b03168152602001611bba608088016060890161436d565b6001600160a01b03168152602001611bda6101c088016101a0890161436d565b6001600160a01b03169052600061227a565b50505061014084015261012083015261010082015260408101516101a08201516001600160a01b03908116911614801590611c42575080606001516001600160a01b0316816101a001516001600160a01b031614155b15611ce657806101400151816102200151826101c00151611c639190614c1b565b1115611c8257604051634ff64a9f60e01b815260040160405180910390fd5b806101400151816102200151826101c00151611c9e9190614c1b565b1015611ce6576000816102200151826101c00151611cbc9190614c1b565b826101400151611ccc9190614c08565b9050611ce48333846101a00151843460001415613066565b505b611cf281341515612825565b949350505050565b60035460ff1615611d1e57604051633c3282e760e01b815260040160405180910390fd5b6001600160a01b038116611d3157600080fd5b611d4960008051602061550083398151915283613179565b50611d55600083613179565b50611d6e6000805160206154e083398151915282613179565b50611d7a600082613179565b5050600180546001600160a01b0390931661010002610100600160a81b0319909316929092178255506003805460ff19169091179055565b600060026000836001811115611dca57611dca6145bc565b6001811115611ddb57611ddb6145bc565b81526020810191909152604001600020546001600160401b031692915050565b600082815260208190526040902060010154611e168161316f565b611233838361326a565b600080516020615500833981519152611e388161316f565b8160026000856001811115611e4f57611e4f6145bc565b6001811115611e6057611e606145bc565b815260200190815260200160002060006101000a8154816001600160401b0302191690836001600160401b03160217905550505050565b60015460ff1615611ebb5760405163d93c066560e01b815260040160405180910390fd5b565b6000806000806000806000808a6001600160a01b031689604051602401611ee691815260200190565b60408051601f198184030181529181526020820180516001600160e01b031663133f757160e31b17905251611f1b919061500a565b6000604051808303816000865af19150503d8060008114611f58576040519150601f19603f3d011682016040523d82523d6000602084013e611f5d565b606091505b509150915081611f8057604051631916db6f60e21b815260040160405180910390fd5b60008a6001811115611f9457611f946145bc565b03611feb5780806020019051810190611fad919061504d565b909192939495969798999a50909192939495969798995090919250909150905050809b50819950829a50839850849c50859d5050505050505061204c565b60018a6001811115611fff57611fff6145bc565b0361204c5780806020019051810190612018919061512c565b90919293949596979899509091929394959697985090919250909150905050809a50819850829950839b50849c5050505050505b505093975093979195509350565b6000806000806120868560000151866060015187608001518860a001518960c001518a60e0015161386a565b8651604080516080810182526060808b0151825230602083019081526001600160801b03838501818152928401818152945163fc6f786560e01b81529351600485015290516001600160a01b03908116602485015291518116604484015292519092166064820152939550919350169063fc6f78659060840160408051808303816000875af115801561211d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121419190615204565b610100870151919550935061227357600061215c8386614c08565b9050600061216a8386614c08565b905081156121eb57602087015160405163a9059cbb60e01b8152336004820152602481018490526001600160a01b039091169063a9059cbb906044016020604051808303816000875af11580156121c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e99190615228565b505b801561226a57604080880151905163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb906044016020604051808303816000875af1158015612244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122689190615228565b505b50508193508092505b5050915091565b600080600080600080600260008960800151600181111561229d5761229d6145bc565b60018111156122ae576122ae6145bc565b815260208101919091526040016000205460608901516001600160401b03918216911611156122f057604051639a33400560e01b815260040160405180910390fd5b87606001516001600160401b031660000361231e576040516303fbecdf60e51b815260040160405180910390fd5b87511561235857612345886000015189606001516001600160401b0316600160401b613947565b8851909350612355908490614c08565b95505b60208801511561239757612382886020015189606001516001600160401b0316600160401b613947565b91508188602001516123949190614c08565b94505b6040880151156123d6576123c1886040015189606001516001600160401b0316600160401b613947565b90508088604001516123d39190614c08565b93505b86156124d7578760e001516001600160a01b03168860c001518960a001516001600160a01b03167f07b9ff32d43e39b450a13b642c1e93282a8ea460336f1422bddc6164b304c2da6040518061016001604052808d61010001516001600160a01b031681526020018d61012001516001600160a01b031681526020018d61014001516001600160a01b031681526020018d6000015181526020018d6020015181526020018d6040015181526020018881526020018781526020018681526020018d606001516001600160401b031681526020018d6080015160018111156124bf576124bf6145bc565b90526040516124ce9190615245565b60405180910390a45b9295509295509295565b6124e961416e565b60008061261f604051806102c0016040528089600001516001811115612511576125116145bc565b815260200189602001516001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b03168152602001600062ffffff168152602001600060020b8152602001600060020b815260200160006001600160401b031681526020018960600151815260200189608001518152602001600081526020018960c001516001600160a01b031681526020018960e0015181526020018961010001516001600160a01b031681526020018961012001518152602001896101400151815260200189610160015181526020018961018001518152602001896101a001518152602001896101c001518152602001896101e001518152602001896102000151815250856139fa565b9150915060006040518060c0016040528089604001518152602001848152602001838152602001896101e00151815260200189610200015181526020018960e00151815250905087602001516001600160a01b031663219f5d17826040518263ffffffff1660e01b81526004016126d59190600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b6060604051808303816000875af11580156126f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061271891906152fb565b604087810182905260208089018490526001600160801b03949094168089528c8201518d860151835192835295820194909452808201929092525191926001600160a01b0316917fe96b62a2783f0eb40eb1daf87ed80a62c56c56e33c3669bf7f1ce575bd5d81ac9181900360600190a3600061279d89602001518a60000151612b6d565b9050612819604051806101200160405280836001600160a01b031681526020018b60c001516001600160a01b031681526020018a6001600160a01b03168152602001896001600160a01b031681526020018681526020018581526020018760200151815260200187604001518152602001881515815250613d68565b50505050949350505050565b61282d6141a6565b60008061283a85856139fa565b9092509050600085516001811115612854576128546145bc565b0361291a576128fb856020015160405180610160016040528088604001516001600160a01b0316815260200188606001516001600160a01b03168152602001886080015162ffffff1681526020018860a0015160020b81526020018860c0015160020b81526020018581526020018481526020018861028001518152602001886102a001518152602001306001600160a01b03168152602001886101800151815250613de0565b606087015260408601526001600160801b0316602085015283526129ef565b60018551600181111561292f5761292f6145bc565b036129d6576128fb856020015160405180610160016040528088604001516001600160a01b0316815260200188606001516001600160a01b03168152602001886080015162ffffff1681526020018860a0015160020b81526020018860c0015160020b81526020018581526020018481526020018861028001518152602001886102a001518152602001306001600160a01b03168152602001886101800151815250613e65565b604051630e7b96f560e41b815260040160405180910390fd5b602085015161016086015184516040516323b872dd60e01b81526001600160a01b03909316926323b872dd92612a29923092600401614c2e565b600060405180830381600087803b158015612a4357600080fd5b505af1158015612a57573d6000803e3d6000fd5b50505050826000015185602001516001600160a01b03167fa9c03b58d729c750f50b2c6854d5db412e7faa78156e5ddf9225285e19011ff7856020015186604001518760600151604051612ac9939291906001600160801b039390931683526020830191909152604082015260600190565b60405180910390a3612b65604051806101200160405280612af288602001518960000151612b6d565b6001600160a01b031681526020018761016001516001600160a01b0316815260200187604001516001600160a01b0316815260200187606001516001600160a01b031681526020018481526020018381526020018560400151815260200185606001518152602001861515815250613d68565b505092915050565b600080826001811115612b8257612b826145bc565b03612bf057826001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be99190614ce4565b905061054a565b6001826001811115612c0457612c046145bc565b036129d657826001600160a01b0316638af3ac856040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bc5573d6000803e3d6000fd5b6000808415801590612c595750825115155b8015612c6d57506001600160a01b03861615155b1561305c576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa158015612cb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cdd9190614c68565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038916906370a0823190602401602060405180830381865afa158015612d27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d4b9190614c68565b60015460405163095ea7b360e01b81526001600160a01b0361010090920482166004820152602481018a90529192508a169063095ea7b3906044016020604051808303816000875af1158015612da5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dc99190615228565b5060015460405160009161010090046001600160a01b031690612ded90889061500a565b6000604051808303816000865af19150503d8060008114612e2a576040519150601f19603f3d011682016040523d82523d6000602084013e612e2f565b606091505b5050905080612e6f5760405162461bcd60e51b815260206004820152600c60248201526b73776170206661696c65642160a01b604482015260640161174f565b60015460405163095ea7b360e01b81526101009091046001600160a01b039081166004830152600060248301528b169063095ea7b3906044016020604051808303816000875af1158015612ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eeb9190615228565b506040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015612f33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f579190614c68565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015612fa1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fc59190614c68565b9050612fd18286614c08565b9650612fdd8482614c08565b95508886101561300057604051630d4205a160e11b815260040160405180910390fd5b8a6001600160a01b03168c6001600160a01b03167ffa2dda1cc1b86e41239702756b13effbc1a092b5c57e3ad320fbe4f3b13fe235898960405161304e929190918252602082015260400190565b60405180910390a350505050505b9550959350505050565b826001600160a01b0316856001600160a01b03161480156130845750805b1561315d57604051632e1a7d4d60e01b8152600481018390526001600160a01b03861690632e1a7d4d90602401600060405180830381600087803b1580156130cb57600080fd5b505af11580156130df573d6000803e3d6000fd5b505050506000846001600160a01b03168360405160006040518083038185875af1925050503d8060008114613130576040519150601f19603f3d011682016040523d82523d6000602084013e613135565b606091505b505090508061315757604051637cd69c3960e11b815260040160405180910390fd5b50613168565b61316883858461320b565b5050505050565b6113e78133613f7c565b6000613185838361163c565b613203576000838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556131bb3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161054a565b50600061054a565b6040516001600160a01b0383811660248301526044820183905261128e91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050613fb9565b6000613276838361163c565b15613203576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161054a565b6132dd61401c565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60008080341561345957896001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561336c57600080fd5b505af1158015613380573d6000803e3d6000fd5b5050505050886001600160a01b03168a6001600160a01b0316036133c757349250858311156133c2576040516307e205e160e41b815260040160405180910390fd5b613459565b876001600160a01b03168a6001600160a01b03160361340457349150848211156133c2576040516307e205e160e41b815260040160405180910390fd5b866001600160a01b03168a6001600160a01b031603613440575034838111156133c2576040516307e205e160e41b815260040160405180910390fd5b6040516392b0337360e01b815260040160405180910390fd5b82861115613585576040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa1580156134a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134cc9190614c68565b90506134e38a33306134de888c614c08565b61403f565b6040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa15801561352a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061354e9190614c68565b905061355a8589614c08565b6135648383614c08565b14613582576040516313ff771f60e21b815260040160405180910390fd5b50505b818511156136ac576040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156135d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135f89190614c68565b905061360a8933306134de878b614c08565b6040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa158015613651573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136759190614c68565b90506136818488614c08565b61368b8383614c08565b146136a9576040516313ff771f60e21b815260040160405180910390fd5b50505b80841180156136c357506001600160a01b03871615155b80156136e15750866001600160a01b0316896001600160a01b031614155b80156136ff5750866001600160a01b0316886001600160a01b031614155b15613823576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa15801561374b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061376f9190614c68565b90506137818833306134de868a614c08565b6040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156137c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137ec9190614c68565b90506137f88387614c08565b6138028383614c08565b14613820576040516313ff771f60e21b815260040160405180910390fd5b50505b50505050505050505050565b613837611e97565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2583361330a565b6000806001600160801b0386161561393c576040805160a0810182528881526001600160801b038089166020830190815282840188815260608401888152608085018b81529551630624e65f60e11b8152945160048601529151909216602484015290516044830152516064820152905160848201526001600160a01b03891690630c49ccbe9060a40160408051808303816000875af1158015613912573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139369190615204565b90925090505b965096945050505050565b6000808060001985870985870292508281108382030391505080600003613980576000841161397557600080fd5b5082900490506139f3565b80841161398c57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b60008083604001516001600160a01b0316846101a001516001600160a01b031603613aa2578361022001518461010001511015613a4a57604051634ff64a9f60e01b815260040160405180910390fd5b600080613a71866040015187606001518861022001518961024001518a6102600151612c47565b9150915081866101000151613a869190614c08565b935080866101200151613a999190614c1b565b92505050613c57565b83606001516001600160a01b0316846101a001516001600160a01b031603613b4757836101c001518461012001511015613aef57604051634ff64a9f60e01b815260040160405180910390fd5b600080613b1686606001518760400151886101c00151896101e001518a6102000151612c47565b9150915081866101200151613b2b9190614c08565b925080866101000151613b3e9190614c1b565b93505050613c57565b6101a08401516001600160a01b031615613c4857600080613b83866101a001518760400151886101c00151896101e001518a6102000151612c47565b91509150600080613baf886101a0015189606001518a61022001518b61024001518c6102600151612c47565b9150915082886101000151613bc49190614c1b565b955080886101200151613bd79190614c1b565b9450600082858a61022001518b6101c00151613bf39190614c1b565b613bfd9190614c08565b613c079190614c08565b90508015613c3e576000613c238a602001518b60000151612b6d565b9050613c3c818b61016001518c6101a00151858d613066565b505b5050505050613c57565b50506101008201516101208301515b8115613cdc576040808501516020860151915163095ea7b360e01b81526001600160a01b0392831660048201526024810185905291169063095ea7b3906044016020604051808303816000875af1158015613cb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cda9190615228565b505b8015613d61576060840151602085015160405163095ea7b360e01b81526001600160a01b0391821660048201526024810184905291169063095ea7b3906044016020604051808303816000875af1158015613d3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d5f9190615228565b505b9250929050565b60008160c001518260800151613d7e9190614c08565b905060008260e001518360a00151613d969190614c08565b90508115613dbc57613dbc83600001518460200151856040015185876101000151613066565b801561128e5761128e83600001518460200151856060015184876101000151613066565b600080600080856001600160a01b03166388316456866040518263ffffffff1660e01b8152600401613e129190615332565b6080604051808303816000875af1158015613e31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e5591906153f6565b9299919850965090945092505050565b600080600080600060405180610140016040528087600001516001600160a01b0316815260200187602001516001600160a01b03168152602001876060015160020b8152602001876080015160020b81526020018760a0015181526020018760c0015181526020018760e0015181526020018761010001518152602001306001600160a01b031681526020018761014001518152509050866001600160a01b0316639cc1a283826040518263ffffffff1660e01b8152600401613f289190615434565b6080604051808303816000875af1158015613f47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f6b91906153f6565b929a91995097509095509350505050565b613f86828261163c565b613fb55760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440161174f565b5050565b6000613fce6001600160a01b03841683614067565b90508051600014158015613ff3575080806020019051810190613ff19190615228565b155b1561128e57604051635274afe760e01b81526001600160a01b038416600482015260240161174f565b60015460ff16611ebb57604051638dfc202b60e01b815260040160405180910390fd5b61123384856001600160a01b03166323b872dd86868660405160240161323893929190614c2e565b60606139f38383600084600080856001600160a01b0316848660405161408d919061500a565b60006040518083038185875af1925050503d80600081146140ca576040519150601f19603f3d011682016040523d82523d6000602084013e6140cf565b606091505b50915091506140df8683836140e9565b9695505050505050565b6060826140fe576140f982614145565b6139f3565b815115801561411557506001600160a01b0384163b155b1561413e57604051639996b31560e01b81526001600160a01b038516600482015260240161174f565b50806139f3565b8051156141555780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6040518060a0016040528060006001600160801b03168152602001600081526020016000815260200160008152602001600081525090565b60405180608001604052806000815260200160006001600160801b0316815260200160008152602001600081525090565b6000602082840312156141e957600080fd5b81356001600160e01b0319811681146139f357600080fd5b6001600160a01b03811681146113e757600080fd5b803561422181614201565b919050565b60008060006060848603121561423b57600080fd5b833561424681614201565b92506020840135915060408401356001600160401b0381111561426857600080fd5b84016102a0818703121561427b57600080fd5b809150509250925092565b60008060008060006080868803121561429e57600080fd5b85356142a981614201565b945060208601356142b981614201565b93506040860135925060608601356001600160401b03808211156142dc57600080fd5b818801915088601f8301126142f057600080fd5b8135818111156142ff57600080fd5b89602082850101111561431157600080fd5b9699959850939650602001949392505050565b60006020828403121561433657600080fd5b5035919050565b6000806040838503121561435057600080fd5b82359150602083013561436281614201565b809150509250929050565b60006020828403121561437f57600080fd5b81356139f381614201565b60008060006040848603121561439f57600080fd5b83356001600160401b03808211156143b657600080fd5b818601915086601f8301126143ca57600080fd5b8135818111156143d957600080fd5b8760208260051b85010111156143ee57600080fd5b6020928301955093505084013561427b81614201565b60006020828403121561441657600080fd5b81356001600160401b0381111561442c57600080fd5b820161010081850312156139f357600080fd5b60008060006060848603121561445457600080fd5b833561445f81614201565b925060208401359150604084013561427b81614201565b60006020828403121561448857600080fd5b81356001600160401b0381111561449e57600080fd5b820161024081850312156139f357600080fd5b6000602082840312156144c357600080fd5b81356001600160401b038111156144d957600080fd5b82016102c081850312156139f357600080fd5b60008060006060848603121561450157600080fd5b833561450c81614201565b9250602084013561451c81614201565b9150604084013561427b81614201565b600281106113e757600080fd5b80356142218161452c565b60006020828403121561455657600080fd5b81356139f38161452c565b80356001600160401b038116811461422157600080fd5b6000806040838503121561458b57600080fd5b82356145968161452c565b91506145a460208401614561565b90509250929050565b80356003811061422157600080fd5b634e487b7160e01b600052602160045260246000fd5b600381106145e2576145e26145bc565b9052565b600281106145e2576145e26145bc565b6000808335601e1984360301811261460d57600080fd5b83016020810192503590506001600160401b0381111561462c57600080fd5b803603821315613d6157600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8060020b81146113e757600080fd5b803561422181614664565b80151581146113e757600080fd5b80356142218161467e565b6001600160801b03811681146113e757600080fd5b803561422181614697565b602081526146d0602082016146cb846145ad565b6145d2565b60006146de60208401614539565b6146eb60408401826145e6565b506146f860408401614216565b6001600160a01b03811660608401525060608301356080830152608083013560a083015260a083013560c083015260c083013560e083015261473d60e08401846145f6565b6102a061010081818701526147576102c08701848661463b565b93506101209250808701358387015250610140828701358187015261477e818801886145f6565b93509050610160601f19878603018188015261479b85858461463b565b94506147a8818901614673565b935050506101806147bd8187018460020b9052565b6147c8818801614673565b9250506101a06147dc8187018460020b9052565b6147e781880161468c565b9250506101c06147fa8187018415159052565b6148058188016146ac565b9250506101e061481f818701846001600160801b03169052565b610200925080870135838701525061022082870135818701526102409250808701358387015250614851828701614216565b915061026061486a818701846001600160a01b03169052565b61487581880161468c565b9250506102806148888187018415159052565b614893818801614561565b9250506148aa818601836001600160401b03169052565b5090949350505050565b60005b838110156148cf5781810151838201526020016148b7565b50506000910152565b600060018060a01b0380871683528086166020840152508360408301526080606083015282518060808401526149158160a08501602087016148b4565b601f01601f19169190910160a00195945050505050565b634e487b7160e01b600052604160045260246000fd5b6040516102a081016001600160401b03811182821017156149655761496561492c565b60405290565b60405161024081016001600160401b03811182821017156149655761496561492c565b6040516102c081016001600160401b03811182821017156149655761496561492c565b600082601f8301126149c257600080fd5b81356001600160401b03808211156149dc576149dc61492c565b604051601f8301601f19908116603f01168101908282118183101715614a0457614a0461492c565b81604052838152866020858801011115614a1d57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060208284031215614a4f57600080fd5b81356001600160401b0380821115614a6657600080fd5b908301906102a08286031215614a7b57600080fd5b614a83614942565b614a8c836145ad565b8152614a9a60208401614539565b6020820152614aab60408401614216565b6040820152606083013560608201526080830135608082015260a083013560a082015260c083013560c082015260e083013582811115614aea57600080fd5b614af6878286016149b1565b60e083015250610100838101359082015261012080840135908201526101408084013583811115614b2657600080fd5b614b32888287016149b1565b8284015250506101609150614b48828401614673565b828201526101809150614b5c828401614673565b828201526101a09150614b7082840161468c565b828201526101c09150614b848284016146ac565b918101919091526101e082810135908201526102008083013590820152610220808301359082015261024090614bbb828401614216565b828201526102609150614bcf82840161468c565b828201526102809150614be3828401614561565b91810191909152949350505050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561054a5761054a614bf2565b8082018082111561054a5761054a614bf2565b6001600160a01b039384168152919092166020820152604081019190915260600190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215614c7a57600080fd5b5051919050565b6000808335601e19843603018112614c9857600080fd5b8301803591506001600160401b03821115614cb257600080fd5b602001915036819003821315613d6157600080fd5b600060208284031215614cd957600080fd5b81356139f38161467e565b600060208284031215614cf657600080fd5b81516139f381614201565b60006102408236031215614d1457600080fd5b614d1c61496b565b614d2583614539565b8152614d3360208401614216565b602082015260408301356040820152606083013560608201526080830135608082015260a083013560a0820152614d6c60c08401614216565b60c082015260e083013560e0820152610100614d89818501614216565b9082015261012083810135908201526101408084013590820152610160808401356001600160401b0380821115614dbf57600080fd5b614dcb368388016149b1565b928401929092525061018084810135908301526101a080850135908301526101c090818501359080821115614dff57600080fd5b50614e0c368287016149b1565b8284015250506101e0808401358183015250610200808401358183015250610220614e38818501614561565b9082015292915050565b600060208284031215614e5457600080fd5b6139f382614561565b62ffffff811681146113e757600080fd5b803561422181614e5d565b60006102c08236031215614e8c57600080fd5b614e9461498e565b614e9d83614539565b8152614eab60208401614216565b6020820152614ebc60408401614216565b6040820152614ecd60608401614216565b6060820152614ede60808401614e6e565b6080820152614eef60a08401614673565b60a0820152614f0060c08401614673565b60c0820152614f1160e08401614561565b60e0820152610100838101359082015261012080840135908201526101408084013590820152610160614f45818501614216565b9082015261018083810135908201526101a0614f62818501614216565b908201526101c083810135908201526101e08084013590820152610200808401356001600160401b0380821115614f9857600080fd5b614fa4368388016149b1565b92840192909252506102208481013590830152610240808501359083015261026090818501359080821115614fd857600080fd5b50614fe5368287016149b1565b918301919091525061028083810135908201526102a092830135928101929092525090565b6000825161501c8184602087016148b4565b9190910192915050565b80516bffffffffffffffffffffffff8116811461422157600080fd5b805161422181614697565b6000806000806000806000806000806000806101808d8f03121561507057600080fd5b6150798d615026565b9b5060208d015161508981614201565b60408e0151909b5061509a81614201565b60608e0151909a506150ab81614201565b60808e01519099506150bc81614e5d565b60a08e01519098506150cd81614664565b60c08e01519097506150de81614664565b95506150ec60e08e01615042565b94506101008d015193506101208d0151925061510b6101408e01615042565b915061511a6101608e01615042565b90509295989b509295989b509295989b565b60008060008060008060008060008060006101608c8e03121561514e57600080fd5b6151578c615026565b9a5060208c015161516781614201565b60408d0151909a5061517881614201565b60608d015190995061518981614201565b60808d015190985061519a81614664565b60a08d01519097506151ab81614664565b60c08d01519096506151bc81614697565b8095505060e08c015193506101008c015192506101208c01516151de81614697565b6101408d01519092506151f081614697565b809150509295989b509295989b9093969950565b6000806040838503121561521757600080fd5b505080516020909101519092909150565b60006020828403121561523a57600080fd5b81516139f38161467e565b81516001600160a01b031681526101608101602083015161527160208401826001600160a01b03169052565b50604083015161528c60408401826001600160a01b03169052565b50606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516152e6828501826001600160401b03169052565b505061014080840151612b65828501826145e6565b60008060006060848603121561531057600080fd5b835161531b81614697565b602085015160409095015190969495509392505050565b81516001600160a01b031681526101608101602083015161535e60208401826001600160a01b03169052565b506040830151615375604084018262ffffff169052565b50606083015161538a606084018260020b9052565b50608083015161539f608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516153e5828501826001600160a01b03169052565b505061014092830151919092015290565b6000806000806080858703121561540c57600080fd5b84519350602085015161541e81614697565b6040860151606090960151949790965092505050565b81516001600160a01b031681526101408101602083015161546060208401826001600160a01b03169052565b506040830151615475604084018260020b9052565b50606083015161548a606084018260020b9052565b506080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401516154ce828501826001600160a01b03169052565b50506101209283015191909201529056fe10dac8c06a04bec0b551627dad28bc00d6516b0caacd1c7b345fcdb5211334e4a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775a2646970667358221220a85d36c094ba34877a437c6daa029339b13c6867ba25ffbd2d81e18698b1075f64736f6c63430008170033

Deployed Bytecode

0x60806040526004361061014f5760003560e01c80637b9f76b5116100b6578063c01279421161006f578063c0127942146103f5578063c0c53b8b14610444578063c31c9c0714610464578063c8bfbbbe146104a1578063d547741f146104d9578063d6ee2b42146104f957600080fd5b80637b9f76b51461030b5780638456cb591461032b57806385f438c11461034057806391d1485414610362578063a217fddf14610382578063b60739b91461039757600080fd5b8063340ed32a11610108578063340ed32a1461026957806336568abe146102895780633f4ba83a146102a95780635c975abb146102be57806371c87886146102d657806375b238fc146102e957600080fd5b806301ffc9a71461015b5780631017cd5714610190578063150b7a02146101b2578063248a9ca3146101eb5780632f2ff15d146102295780632f622e6b1461024957600080fd5b3661015657005b600080fd5b34801561016757600080fd5b5061017b6101763660046141d7565b610519565b60405190151581526020015b60405180910390f35b34801561019c57600080fd5b506101b06101ab366004614226565b610550565b005b3480156101be57600080fd5b506101d26101cd366004614286565b6105e0565b6040516001600160e01b03199091168152602001610187565b3480156101f757600080fd5b5061021b610206366004614324565b60009081526020819052604090206001015490565b604051908152602001610187565b34801561023557600080fd5b506101b061024436600461433d565b61120e565b34801561025557600080fd5b506101b061026436600461436d565b611239565b34801561027557600080fd5b506101b061028436600461438a565b611293565b34801561029557600080fd5b506101b06102a436600461433d565b611394565b3480156102b557600080fd5b506101b06113c7565b3480156102ca57600080fd5b5060015460ff1661017b565b61021b6102e4366004614404565b6113ea565b3480156102f557600080fd5b5061021b60008051602061550083398151915281565b34801561031757600080fd5b506101b061032636600461443f565b61159c565b34801561033757600080fd5b506101b061161c565b34801561034c57600080fd5b5061021b6000805160206154e083398151915281565b34801561036e57600080fd5b5061017b61037d36600461433d565b61163c565b34801561038e57600080fd5b5061021b600081565b6103aa6103a5366004614476565b611665565b6040516101879190600060a0820190506001600160801b0383511682526020830151602083015260408301516040830152606083015160608301526080830151608083015292915050565b6104086104033660046144b1565b6119ec565b6040516101879190815181526020808301516001600160801b031690820152604080830151908201526060918201519181019190915260800190565b34801561045057600080fd5b506101b061045f3660046144ec565b611cfa565b34801561047057600080fd5b506001546104899061010090046001600160a01b031681565b6040516001600160a01b039091168152602001610187565b3480156104ad57600080fd5b506104c16104bc366004614544565b611db2565b6040516001600160401b039091168152602001610187565b3480156104e557600080fd5b506101b06104f436600461433d565b611dfb565b34801561050557600080fd5b506101b0610514366004614578565b611e20565b60006001600160e01b03198216637965db0b60e01b148061054a57506301ffc9a760e01b6001600160e01b03198316145b92915050565b610558611e97565b826001600160a01b031663b88d4fde3330858560405160200161057b91906146b7565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016105a994939291906148d8565b600060405180830381600087803b1580156105c357600080fd5b505af11580156105d7573d6000803e3d6000fd5b50505050505050565b60006105ea611e97565b33306001600160a01b0387160361061457604051632797715160e01b815260040160405180910390fd5b600061062284860186614a3d565b905060008060006106388585602001518b611ebd565b9550505050925092506000806106c9604051806101200160405280896001600160a01b03168152602001876001600160a01b03168152602001866001600160a01b031681526020018d8152602001886101c001516001600160801b0316815260200188610220015181526020018860600151815260200188608001518152602001886101a00151151581525061205a565b61028088015191935091506001600160401b0316156107795761076e604051806101600160405280848152602001838152602001600081526020018861028001516001600160401b0316815260200160018081111561072a5761072a6145bc565b81526001600160a01b03808b166020830152604082018f90526102408a0151811660608301528881166080830152871660a0820152600060c090910152600161227a565b509395509193505050505b8560a0015182108061078f575085610100015181105b156107ad57604051634ff64a9f60e01b815260040160405180910390fd5b6002865160028111156107c2576107c26145bc565b03610b5a576107cf61416e565b856001600160a01b031687604001516001600160a01b0316036108e8576108e160405180610240016040528089602001516001811115610811576108116145bc565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001876001600160a01b031681526020018961010001518152602001896101200151815260200189610140015181526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a61026001516124e1565b9050610af2565b846001600160a01b031687604001516001600160a01b0316036109f7576108e16040518061024001604052808960200151600181111561092a5761092a6145bc565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001886001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018960a0015181526020018960c0015181526020018960e001518152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a61026001516124e1565b610aef60405180610240016040528089602001516001811115610a1c57610a1c6145bc565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b03168152602001896102200151815260200160006001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a61026001516124e1565b90505b805160208083015160408085015181516001600160801b039095168552928401919091528201528c906001600160a01b038a16907f4a3d983c4891bedb0622c5a26f90b626e9451fe3a832b73ed9c886f1aa489cda906060015b60405180910390a350611192565b600086516002811115610b6f57610b6f6145bc565b03610fb757610b7c6141a6565b856001600160a01b031687604001516001600160a01b031603610cd257610ccb604051806102c0016040528089602001516001811115610bbe57610bbe6145bc565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001876001600160a01b031681526020018961010001518152602001896101200151815260200189610140015181526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815250886102600151612825565b9050610f56565b846001600160a01b031687604001516001600160a01b031603610e1e57610ccb604051806102c0016040528089602001516001811115610d1457610d146145bc565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001886001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018960a0015181526020018960c0015181526020018960e001518152602001896101e001518152602001896102000151815250886102600151612825565b610f53604051806102c0016040528089602001516001811115610e4357610e436145bc565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b03168152602001896102200151815260200160006001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815250886102600151612825565b90505b805160208083015160408085015160608087015183519687526001600160801b039094169486019490945290840152908201528c9033907fe878b7324da2e10eb701c2cf0474248cdf5c088bb68aaf3045a6c15d1008b12d90608001610b4c565b600186516002811115610fcc57610fcc6145bc565b03611179576000610fe1888860200151612b6d565b9050600087604001516001600160a01b0316876001600160a01b03161461105f5760008061101e898b60400151888d60c001518e60e00151612c47565b915091508582101561104c5761104c848b61024001518b858a6110419190614c08565b8e6102600151613066565b6110568184614c1b565b9250505061106c565b6110698482614c1b565b90505b87604001516001600160a01b0316866001600160a01b0316146110dd576000806110a7888b60400151878d61012001518e6101400151612c47565b91509150848210156110ca576110ca848b61024001518a85896110419190614c08565b6110d48184614c1b565b925050506110ea565b6110e78382614c1b565b90505b8015801590611105575060408801516001600160a01b031615155b1561112557611125828961024001518a60400151848c6102600151613066565b60408089015181516001600160a01b039182168152602081018490528f92918c16917fc082f11600156d64071ed597a7b831f56741ad4e14954598e674e1ec2b61da0c910160405180910390a35050611192565b60405163e83deb0f60e01b815260040160405180910390fd5b866001600160a01b03166323b872dd308e8e6040518463ffffffff1660e01b81526004016111c293929190614c2e565b600060405180830381600087803b1580156111dc57600080fd5b505af11580156111f0573d6000803e3d6000fd5b50630a85bd0160e11b9a505050505050505050505095945050505050565b6000828152602081905260409020600101546112298161316f565b6112338383613179565b50505050565b6000805160206154e08339815191526112518161316f565b47801561128e576040516001600160a01b0384169082156108fc029083906000818181858888f19350505050158015611233573d6000803e3d6000fd5b505050565b6000805160206154e08339815191526112ab8161316f565b8260005b8181101561138c5760008686838181106112cb576112cb614c52565b90506020020160208101906112e0919061436d565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015611326573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061134a9190614c68565b905080156113835761138387878481811061136757611367614c52565b905060200201602081019061137c919061436d565b868361320b565b506001016112af565b505050505050565b6001600160a01b03811633146113bd5760405163334bd91960e11b815260040160405180910390fd5b61128e828261326a565b6000805160206155008339815191526113df8161316f565b6113e76132d5565b50565b60006113f4611e97565b611404606083016040840161436d565b6001600160a01b031661141d604084016020850161436d565b6001600160a01b0316036114445760405163100dac0560e11b815260040160405180910390fd5b611474611454602084018461436d565b611464604085016020860161436d565b6000808660600135600080613327565b60006114ea611489604085016020860161436d565b611499606086016040870161436d565b606086013560808701356114b060c0890189614c81565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612c4792505050565b92509050811561153b5761153b611504602085018561436d565b61151460c0860160a0870161436d565b611524606087016040880161436d565b85611536610100890160e08a01614cc7565b613066565b600061154b826060860135614c08565b9050801561159557611595611563602086018661436d565b61157360c0870160a0880161436d565b611583604088016020890161436d565b846115366101008a0160e08b01614cc7565b5050919050565b6000805160206154e08339815191526115b48161316f565b6040516323b872dd60e01b81526001600160a01b038516906323b872dd906115e490309086908890600401614c2e565b600060405180830381600087803b1580156115fe57600080fd5b505af1158015611612573d6000803e3d6000fd5b5050505050505050565b6000805160206155008339815191526116348161316f565b6113e761382f565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b61166d61416e565b611675611e97565b6000611687604084016020850161436d565b6001600160a01b0316636352211e84604001356040518263ffffffff1660e01b81526004016116b891815260200190565b602060405180830381865afa1580156116d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116f99190614ce4565b90506001600160a01b03811633146117585760405162461bcd60e51b815260206004820152601f60248201527f73656e646572206973206e6f74206f776e6572206f6620706f736974696f6e0060448201526064015b60405180910390fd5b60008061178561176e604087016020880161436d565b61177b6020880188614544565b8760400135611ebd565b505050509150915060006117b78660200160208101906117a5919061436d565b6117b26020890189614544565b612b6d565b90506117e58184846117d16101208b016101008c0161436d565b8a606001358b608001358c60a00135613327565b60006117f087614d01565b9050600061180661024089016102208a01614e42565b6001600160401b031611156119d3576118e860405180610160016040528089606001358152602001896080013581526020018960a001358152602001896102200160208101906118569190614e42565b6001600160401b031681526020016001815260200189602001602081019061187e919061436d565b6001600160a01b031681526040808b01356020830152016118a560e08b0160c08c0161436d565b6001600160a01b0390811682528781166020830152861660408201526060016118d66101208b016101008c0161436d565b6001600160a01b03169052600161227a565b50505060a0840152608083015260608201526101008101516001600160a01b038581169116148015906119325750826001600160a01b03168161010001516001600160a01b031614155b156119d3578060a001518161018001518261012001516119529190614c1b565b111561197157604051634ff64a9f60e01b815260040160405180910390fd5b8060a0015181610180015182610120015161198c9190614c1b565b10156119d35760008161018001518261012001516119aa9190614c1b565b8260a001516119b99190614c08565b90506119d18333846101000151843460001415613066565b505b6119e18185853415156124e1565b979650505050505050565b6119f46141a6565b6119fc611e97565b611a0c608083016060840161436d565b6001600160a01b0316611a25606084016040850161436d565b6001600160a01b031603611a4c5760405163100dac0560e11b815260040160405180910390fd5b6000611a6e611a61604085016020860161436d565b6117b26020860186614544565b9050611abd81611a84606086016040870161436d565b611a94608087016060880161436d565b611aa66101c088016101a0890161436d565b876101000135886101200135896101400135613327565b6000611ac884614e79565b90506000611add610100860160e08701614e42565b6001600160401b03161115611ce657611bec6040518061016001604052808661010001358152602001866101200135815260200186610140013581526020018660e0016020810190611b2f9190614e42565b6001600160401b0316815260200160018152602001866020016020810190611b57919061436d565b6001600160a01b0316815260006020820152604001611b7e6101808801610160890161436d565b6001600160a01b03168152602001611b9c606088016040890161436d565b6001600160a01b03168152602001611bba608088016060890161436d565b6001600160a01b03168152602001611bda6101c088016101a0890161436d565b6001600160a01b03169052600061227a565b50505061014084015261012083015261010082015260408101516101a08201516001600160a01b03908116911614801590611c42575080606001516001600160a01b0316816101a001516001600160a01b031614155b15611ce657806101400151816102200151826101c00151611c639190614c1b565b1115611c8257604051634ff64a9f60e01b815260040160405180910390fd5b806101400151816102200151826101c00151611c9e9190614c1b565b1015611ce6576000816102200151826101c00151611cbc9190614c1b565b826101400151611ccc9190614c08565b9050611ce48333846101a00151843460001415613066565b505b611cf281341515612825565b949350505050565b60035460ff1615611d1e57604051633c3282e760e01b815260040160405180910390fd5b6001600160a01b038116611d3157600080fd5b611d4960008051602061550083398151915283613179565b50611d55600083613179565b50611d6e6000805160206154e083398151915282613179565b50611d7a600082613179565b5050600180546001600160a01b0390931661010002610100600160a81b0319909316929092178255506003805460ff19169091179055565b600060026000836001811115611dca57611dca6145bc565b6001811115611ddb57611ddb6145bc565b81526020810191909152604001600020546001600160401b031692915050565b600082815260208190526040902060010154611e168161316f565b611233838361326a565b600080516020615500833981519152611e388161316f565b8160026000856001811115611e4f57611e4f6145bc565b6001811115611e6057611e606145bc565b815260200190815260200160002060006101000a8154816001600160401b0302191690836001600160401b03160217905550505050565b60015460ff1615611ebb5760405163d93c066560e01b815260040160405180910390fd5b565b6000806000806000806000808a6001600160a01b031689604051602401611ee691815260200190565b60408051601f198184030181529181526020820180516001600160e01b031663133f757160e31b17905251611f1b919061500a565b6000604051808303816000865af19150503d8060008114611f58576040519150601f19603f3d011682016040523d82523d6000602084013e611f5d565b606091505b509150915081611f8057604051631916db6f60e21b815260040160405180910390fd5b60008a6001811115611f9457611f946145bc565b03611feb5780806020019051810190611fad919061504d565b909192939495969798999a50909192939495969798995090919250909150905050809b50819950829a50839850849c50859d5050505050505061204c565b60018a6001811115611fff57611fff6145bc565b0361204c5780806020019051810190612018919061512c565b90919293949596979899509091929394959697985090919250909150905050809a50819850829950839b50849c5050505050505b505093975093979195509350565b6000806000806120868560000151866060015187608001518860a001518960c001518a60e0015161386a565b8651604080516080810182526060808b0151825230602083019081526001600160801b03838501818152928401818152945163fc6f786560e01b81529351600485015290516001600160a01b03908116602485015291518116604484015292519092166064820152939550919350169063fc6f78659060840160408051808303816000875af115801561211d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121419190615204565b610100870151919550935061227357600061215c8386614c08565b9050600061216a8386614c08565b905081156121eb57602087015160405163a9059cbb60e01b8152336004820152602481018490526001600160a01b039091169063a9059cbb906044016020604051808303816000875af11580156121c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e99190615228565b505b801561226a57604080880151905163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb906044016020604051808303816000875af1158015612244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122689190615228565b505b50508193508092505b5050915091565b600080600080600080600260008960800151600181111561229d5761229d6145bc565b60018111156122ae576122ae6145bc565b815260208101919091526040016000205460608901516001600160401b03918216911611156122f057604051639a33400560e01b815260040160405180910390fd5b87606001516001600160401b031660000361231e576040516303fbecdf60e51b815260040160405180910390fd5b87511561235857612345886000015189606001516001600160401b0316600160401b613947565b8851909350612355908490614c08565b95505b60208801511561239757612382886020015189606001516001600160401b0316600160401b613947565b91508188602001516123949190614c08565b94505b6040880151156123d6576123c1886040015189606001516001600160401b0316600160401b613947565b90508088604001516123d39190614c08565b93505b86156124d7578760e001516001600160a01b03168860c001518960a001516001600160a01b03167f07b9ff32d43e39b450a13b642c1e93282a8ea460336f1422bddc6164b304c2da6040518061016001604052808d61010001516001600160a01b031681526020018d61012001516001600160a01b031681526020018d61014001516001600160a01b031681526020018d6000015181526020018d6020015181526020018d6040015181526020018881526020018781526020018681526020018d606001516001600160401b031681526020018d6080015160018111156124bf576124bf6145bc565b90526040516124ce9190615245565b60405180910390a45b9295509295509295565b6124e961416e565b60008061261f604051806102c0016040528089600001516001811115612511576125116145bc565b815260200189602001516001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b03168152602001600062ffffff168152602001600060020b8152602001600060020b815260200160006001600160401b031681526020018960600151815260200189608001518152602001600081526020018960c001516001600160a01b031681526020018960e0015181526020018961010001516001600160a01b031681526020018961012001518152602001896101400151815260200189610160015181526020018961018001518152602001896101a001518152602001896101c001518152602001896101e001518152602001896102000151815250856139fa565b9150915060006040518060c0016040528089604001518152602001848152602001838152602001896101e00151815260200189610200015181526020018960e00151815250905087602001516001600160a01b031663219f5d17826040518263ffffffff1660e01b81526004016126d59190600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b6060604051808303816000875af11580156126f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061271891906152fb565b604087810182905260208089018490526001600160801b03949094168089528c8201518d860151835192835295820194909452808201929092525191926001600160a01b0316917fe96b62a2783f0eb40eb1daf87ed80a62c56c56e33c3669bf7f1ce575bd5d81ac9181900360600190a3600061279d89602001518a60000151612b6d565b9050612819604051806101200160405280836001600160a01b031681526020018b60c001516001600160a01b031681526020018a6001600160a01b03168152602001896001600160a01b031681526020018681526020018581526020018760200151815260200187604001518152602001881515815250613d68565b50505050949350505050565b61282d6141a6565b60008061283a85856139fa565b9092509050600085516001811115612854576128546145bc565b0361291a576128fb856020015160405180610160016040528088604001516001600160a01b0316815260200188606001516001600160a01b03168152602001886080015162ffffff1681526020018860a0015160020b81526020018860c0015160020b81526020018581526020018481526020018861028001518152602001886102a001518152602001306001600160a01b03168152602001886101800151815250613de0565b606087015260408601526001600160801b0316602085015283526129ef565b60018551600181111561292f5761292f6145bc565b036129d6576128fb856020015160405180610160016040528088604001516001600160a01b0316815260200188606001516001600160a01b03168152602001886080015162ffffff1681526020018860a0015160020b81526020018860c0015160020b81526020018581526020018481526020018861028001518152602001886102a001518152602001306001600160a01b03168152602001886101800151815250613e65565b604051630e7b96f560e41b815260040160405180910390fd5b602085015161016086015184516040516323b872dd60e01b81526001600160a01b03909316926323b872dd92612a29923092600401614c2e565b600060405180830381600087803b158015612a4357600080fd5b505af1158015612a57573d6000803e3d6000fd5b50505050826000015185602001516001600160a01b03167fa9c03b58d729c750f50b2c6854d5db412e7faa78156e5ddf9225285e19011ff7856020015186604001518760600151604051612ac9939291906001600160801b039390931683526020830191909152604082015260600190565b60405180910390a3612b65604051806101200160405280612af288602001518960000151612b6d565b6001600160a01b031681526020018761016001516001600160a01b0316815260200187604001516001600160a01b0316815260200187606001516001600160a01b031681526020018481526020018381526020018560400151815260200185606001518152602001861515815250613d68565b505092915050565b600080826001811115612b8257612b826145bc565b03612bf057826001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be99190614ce4565b905061054a565b6001826001811115612c0457612c046145bc565b036129d657826001600160a01b0316638af3ac856040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bc5573d6000803e3d6000fd5b6000808415801590612c595750825115155b8015612c6d57506001600160a01b03861615155b1561305c576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa158015612cb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cdd9190614c68565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038916906370a0823190602401602060405180830381865afa158015612d27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d4b9190614c68565b60015460405163095ea7b360e01b81526001600160a01b0361010090920482166004820152602481018a90529192508a169063095ea7b3906044016020604051808303816000875af1158015612da5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dc99190615228565b5060015460405160009161010090046001600160a01b031690612ded90889061500a565b6000604051808303816000865af19150503d8060008114612e2a576040519150601f19603f3d011682016040523d82523d6000602084013e612e2f565b606091505b5050905080612e6f5760405162461bcd60e51b815260206004820152600c60248201526b73776170206661696c65642160a01b604482015260640161174f565b60015460405163095ea7b360e01b81526101009091046001600160a01b039081166004830152600060248301528b169063095ea7b3906044016020604051808303816000875af1158015612ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eeb9190615228565b506040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015612f33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f579190614c68565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015612fa1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fc59190614c68565b9050612fd18286614c08565b9650612fdd8482614c08565b95508886101561300057604051630d4205a160e11b815260040160405180910390fd5b8a6001600160a01b03168c6001600160a01b03167ffa2dda1cc1b86e41239702756b13effbc1a092b5c57e3ad320fbe4f3b13fe235898960405161304e929190918252602082015260400190565b60405180910390a350505050505b9550959350505050565b826001600160a01b0316856001600160a01b03161480156130845750805b1561315d57604051632e1a7d4d60e01b8152600481018390526001600160a01b03861690632e1a7d4d90602401600060405180830381600087803b1580156130cb57600080fd5b505af11580156130df573d6000803e3d6000fd5b505050506000846001600160a01b03168360405160006040518083038185875af1925050503d8060008114613130576040519150601f19603f3d011682016040523d82523d6000602084013e613135565b606091505b505090508061315757604051637cd69c3960e11b815260040160405180910390fd5b50613168565b61316883858461320b565b5050505050565b6113e78133613f7c565b6000613185838361163c565b613203576000838152602081815260408083206001600160a01b03861684529091529020805460ff191660011790556131bb3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161054a565b50600061054a565b6040516001600160a01b0383811660248301526044820183905261128e91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050613fb9565b6000613276838361163c565b15613203576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161054a565b6132dd61401c565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60008080341561345957896001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561336c57600080fd5b505af1158015613380573d6000803e3d6000fd5b5050505050886001600160a01b03168a6001600160a01b0316036133c757349250858311156133c2576040516307e205e160e41b815260040160405180910390fd5b613459565b876001600160a01b03168a6001600160a01b03160361340457349150848211156133c2576040516307e205e160e41b815260040160405180910390fd5b866001600160a01b03168a6001600160a01b031603613440575034838111156133c2576040516307e205e160e41b815260040160405180910390fd5b6040516392b0337360e01b815260040160405180910390fd5b82861115613585576040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa1580156134a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134cc9190614c68565b90506134e38a33306134de888c614c08565b61403f565b6040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa15801561352a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061354e9190614c68565b905061355a8589614c08565b6135648383614c08565b14613582576040516313ff771f60e21b815260040160405180910390fd5b50505b818511156136ac576040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156135d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135f89190614c68565b905061360a8933306134de878b614c08565b6040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa158015613651573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136759190614c68565b90506136818488614c08565b61368b8383614c08565b146136a9576040516313ff771f60e21b815260040160405180910390fd5b50505b80841180156136c357506001600160a01b03871615155b80156136e15750866001600160a01b0316896001600160a01b031614155b80156136ff5750866001600160a01b0316886001600160a01b031614155b15613823576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa15801561374b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061376f9190614c68565b90506137818833306134de868a614c08565b6040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156137c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137ec9190614c68565b90506137f88387614c08565b6138028383614c08565b14613820576040516313ff771f60e21b815260040160405180910390fd5b50505b50505050505050505050565b613837611e97565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2583361330a565b6000806001600160801b0386161561393c576040805160a0810182528881526001600160801b038089166020830190815282840188815260608401888152608085018b81529551630624e65f60e11b8152945160048601529151909216602484015290516044830152516064820152905160848201526001600160a01b03891690630c49ccbe9060a40160408051808303816000875af1158015613912573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139369190615204565b90925090505b965096945050505050565b6000808060001985870985870292508281108382030391505080600003613980576000841161397557600080fd5b5082900490506139f3565b80841161398c57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b60008083604001516001600160a01b0316846101a001516001600160a01b031603613aa2578361022001518461010001511015613a4a57604051634ff64a9f60e01b815260040160405180910390fd5b600080613a71866040015187606001518861022001518961024001518a6102600151612c47565b9150915081866101000151613a869190614c08565b935080866101200151613a999190614c1b565b92505050613c57565b83606001516001600160a01b0316846101a001516001600160a01b031603613b4757836101c001518461012001511015613aef57604051634ff64a9f60e01b815260040160405180910390fd5b600080613b1686606001518760400151886101c00151896101e001518a6102000151612c47565b9150915081866101200151613b2b9190614c08565b925080866101000151613b3e9190614c1b565b93505050613c57565b6101a08401516001600160a01b031615613c4857600080613b83866101a001518760400151886101c00151896101e001518a6102000151612c47565b91509150600080613baf886101a0015189606001518a61022001518b61024001518c6102600151612c47565b9150915082886101000151613bc49190614c1b565b955080886101200151613bd79190614c1b565b9450600082858a61022001518b6101c00151613bf39190614c1b565b613bfd9190614c08565b613c079190614c08565b90508015613c3e576000613c238a602001518b60000151612b6d565b9050613c3c818b61016001518c6101a00151858d613066565b505b5050505050613c57565b50506101008201516101208301515b8115613cdc576040808501516020860151915163095ea7b360e01b81526001600160a01b0392831660048201526024810185905291169063095ea7b3906044016020604051808303816000875af1158015613cb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cda9190615228565b505b8015613d61576060840151602085015160405163095ea7b360e01b81526001600160a01b0391821660048201526024810184905291169063095ea7b3906044016020604051808303816000875af1158015613d3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d5f9190615228565b505b9250929050565b60008160c001518260800151613d7e9190614c08565b905060008260e001518360a00151613d969190614c08565b90508115613dbc57613dbc83600001518460200151856040015185876101000151613066565b801561128e5761128e83600001518460200151856060015184876101000151613066565b600080600080856001600160a01b03166388316456866040518263ffffffff1660e01b8152600401613e129190615332565b6080604051808303816000875af1158015613e31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e5591906153f6565b9299919850965090945092505050565b600080600080600060405180610140016040528087600001516001600160a01b0316815260200187602001516001600160a01b03168152602001876060015160020b8152602001876080015160020b81526020018760a0015181526020018760c0015181526020018760e0015181526020018761010001518152602001306001600160a01b031681526020018761014001518152509050866001600160a01b0316639cc1a283826040518263ffffffff1660e01b8152600401613f289190615434565b6080604051808303816000875af1158015613f47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f6b91906153f6565b929a91995097509095509350505050565b613f86828261163c565b613fb55760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440161174f565b5050565b6000613fce6001600160a01b03841683614067565b90508051600014158015613ff3575080806020019051810190613ff19190615228565b155b1561128e57604051635274afe760e01b81526001600160a01b038416600482015260240161174f565b60015460ff16611ebb57604051638dfc202b60e01b815260040160405180910390fd5b61123384856001600160a01b03166323b872dd86868660405160240161323893929190614c2e565b60606139f38383600084600080856001600160a01b0316848660405161408d919061500a565b60006040518083038185875af1925050503d80600081146140ca576040519150601f19603f3d011682016040523d82523d6000602084013e6140cf565b606091505b50915091506140df8683836140e9565b9695505050505050565b6060826140fe576140f982614145565b6139f3565b815115801561411557506001600160a01b0384163b155b1561413e57604051639996b31560e01b81526001600160a01b038516600482015260240161174f565b50806139f3565b8051156141555780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6040518060a0016040528060006001600160801b03168152602001600081526020016000815260200160008152602001600081525090565b60405180608001604052806000815260200160006001600160801b0316815260200160008152602001600081525090565b6000602082840312156141e957600080fd5b81356001600160e01b0319811681146139f357600080fd5b6001600160a01b03811681146113e757600080fd5b803561422181614201565b919050565b60008060006060848603121561423b57600080fd5b833561424681614201565b92506020840135915060408401356001600160401b0381111561426857600080fd5b84016102a0818703121561427b57600080fd5b809150509250925092565b60008060008060006080868803121561429e57600080fd5b85356142a981614201565b945060208601356142b981614201565b93506040860135925060608601356001600160401b03808211156142dc57600080fd5b818801915088601f8301126142f057600080fd5b8135818111156142ff57600080fd5b89602082850101111561431157600080fd5b9699959850939650602001949392505050565b60006020828403121561433657600080fd5b5035919050565b6000806040838503121561435057600080fd5b82359150602083013561436281614201565b809150509250929050565b60006020828403121561437f57600080fd5b81356139f381614201565b60008060006040848603121561439f57600080fd5b83356001600160401b03808211156143b657600080fd5b818601915086601f8301126143ca57600080fd5b8135818111156143d957600080fd5b8760208260051b85010111156143ee57600080fd5b6020928301955093505084013561427b81614201565b60006020828403121561441657600080fd5b81356001600160401b0381111561442c57600080fd5b820161010081850312156139f357600080fd5b60008060006060848603121561445457600080fd5b833561445f81614201565b925060208401359150604084013561427b81614201565b60006020828403121561448857600080fd5b81356001600160401b0381111561449e57600080fd5b820161024081850312156139f357600080fd5b6000602082840312156144c357600080fd5b81356001600160401b038111156144d957600080fd5b82016102c081850312156139f357600080fd5b60008060006060848603121561450157600080fd5b833561450c81614201565b9250602084013561451c81614201565b9150604084013561427b81614201565b600281106113e757600080fd5b80356142218161452c565b60006020828403121561455657600080fd5b81356139f38161452c565b80356001600160401b038116811461422157600080fd5b6000806040838503121561458b57600080fd5b82356145968161452c565b91506145a460208401614561565b90509250929050565b80356003811061422157600080fd5b634e487b7160e01b600052602160045260246000fd5b600381106145e2576145e26145bc565b9052565b600281106145e2576145e26145bc565b6000808335601e1984360301811261460d57600080fd5b83016020810192503590506001600160401b0381111561462c57600080fd5b803603821315613d6157600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8060020b81146113e757600080fd5b803561422181614664565b80151581146113e757600080fd5b80356142218161467e565b6001600160801b03811681146113e757600080fd5b803561422181614697565b602081526146d0602082016146cb846145ad565b6145d2565b60006146de60208401614539565b6146eb60408401826145e6565b506146f860408401614216565b6001600160a01b03811660608401525060608301356080830152608083013560a083015260a083013560c083015260c083013560e083015261473d60e08401846145f6565b6102a061010081818701526147576102c08701848661463b565b93506101209250808701358387015250610140828701358187015261477e818801886145f6565b93509050610160601f19878603018188015261479b85858461463b565b94506147a8818901614673565b935050506101806147bd8187018460020b9052565b6147c8818801614673565b9250506101a06147dc8187018460020b9052565b6147e781880161468c565b9250506101c06147fa8187018415159052565b6148058188016146ac565b9250506101e061481f818701846001600160801b03169052565b610200925080870135838701525061022082870135818701526102409250808701358387015250614851828701614216565b915061026061486a818701846001600160a01b03169052565b61487581880161468c565b9250506102806148888187018415159052565b614893818801614561565b9250506148aa818601836001600160401b03169052565b5090949350505050565b60005b838110156148cf5781810151838201526020016148b7565b50506000910152565b600060018060a01b0380871683528086166020840152508360408301526080606083015282518060808401526149158160a08501602087016148b4565b601f01601f19169190910160a00195945050505050565b634e487b7160e01b600052604160045260246000fd5b6040516102a081016001600160401b03811182821017156149655761496561492c565b60405290565b60405161024081016001600160401b03811182821017156149655761496561492c565b6040516102c081016001600160401b03811182821017156149655761496561492c565b600082601f8301126149c257600080fd5b81356001600160401b03808211156149dc576149dc61492c565b604051601f8301601f19908116603f01168101908282118183101715614a0457614a0461492c565b81604052838152866020858801011115614a1d57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060208284031215614a4f57600080fd5b81356001600160401b0380821115614a6657600080fd5b908301906102a08286031215614a7b57600080fd5b614a83614942565b614a8c836145ad565b8152614a9a60208401614539565b6020820152614aab60408401614216565b6040820152606083013560608201526080830135608082015260a083013560a082015260c083013560c082015260e083013582811115614aea57600080fd5b614af6878286016149b1565b60e083015250610100838101359082015261012080840135908201526101408084013583811115614b2657600080fd5b614b32888287016149b1565b8284015250506101609150614b48828401614673565b828201526101809150614b5c828401614673565b828201526101a09150614b7082840161468c565b828201526101c09150614b848284016146ac565b918101919091526101e082810135908201526102008083013590820152610220808301359082015261024090614bbb828401614216565b828201526102609150614bcf82840161468c565b828201526102809150614be3828401614561565b91810191909152949350505050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561054a5761054a614bf2565b8082018082111561054a5761054a614bf2565b6001600160a01b039384168152919092166020820152604081019190915260600190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215614c7a57600080fd5b5051919050565b6000808335601e19843603018112614c9857600080fd5b8301803591506001600160401b03821115614cb257600080fd5b602001915036819003821315613d6157600080fd5b600060208284031215614cd957600080fd5b81356139f38161467e565b600060208284031215614cf657600080fd5b81516139f381614201565b60006102408236031215614d1457600080fd5b614d1c61496b565b614d2583614539565b8152614d3360208401614216565b602082015260408301356040820152606083013560608201526080830135608082015260a083013560a0820152614d6c60c08401614216565b60c082015260e083013560e0820152610100614d89818501614216565b9082015261012083810135908201526101408084013590820152610160808401356001600160401b0380821115614dbf57600080fd5b614dcb368388016149b1565b928401929092525061018084810135908301526101a080850135908301526101c090818501359080821115614dff57600080fd5b50614e0c368287016149b1565b8284015250506101e0808401358183015250610200808401358183015250610220614e38818501614561565b9082015292915050565b600060208284031215614e5457600080fd5b6139f382614561565b62ffffff811681146113e757600080fd5b803561422181614e5d565b60006102c08236031215614e8c57600080fd5b614e9461498e565b614e9d83614539565b8152614eab60208401614216565b6020820152614ebc60408401614216565b6040820152614ecd60608401614216565b6060820152614ede60808401614e6e565b6080820152614eef60a08401614673565b60a0820152614f0060c08401614673565b60c0820152614f1160e08401614561565b60e0820152610100838101359082015261012080840135908201526101408084013590820152610160614f45818501614216565b9082015261018083810135908201526101a0614f62818501614216565b908201526101c083810135908201526101e08084013590820152610200808401356001600160401b0380821115614f9857600080fd5b614fa4368388016149b1565b92840192909252506102208481013590830152610240808501359083015261026090818501359080821115614fd857600080fd5b50614fe5368287016149b1565b918301919091525061028083810135908201526102a092830135928101929092525090565b6000825161501c8184602087016148b4565b9190910192915050565b80516bffffffffffffffffffffffff8116811461422157600080fd5b805161422181614697565b6000806000806000806000806000806000806101808d8f03121561507057600080fd5b6150798d615026565b9b5060208d015161508981614201565b60408e0151909b5061509a81614201565b60608e0151909a506150ab81614201565b60808e01519099506150bc81614e5d565b60a08e01519098506150cd81614664565b60c08e01519097506150de81614664565b95506150ec60e08e01615042565b94506101008d015193506101208d0151925061510b6101408e01615042565b915061511a6101608e01615042565b90509295989b509295989b509295989b565b60008060008060008060008060008060006101608c8e03121561514e57600080fd5b6151578c615026565b9a5060208c015161516781614201565b60408d0151909a5061517881614201565b60608d015190995061518981614201565b60808d015190985061519a81614664565b60a08d01519097506151ab81614664565b60c08d01519096506151bc81614697565b8095505060e08c015193506101008c015192506101208c01516151de81614697565b6101408d01519092506151f081614697565b809150509295989b509295989b9093969950565b6000806040838503121561521757600080fd5b505080516020909101519092909150565b60006020828403121561523a57600080fd5b81516139f38161467e565b81516001600160a01b031681526101608101602083015161527160208401826001600160a01b03169052565b50604083015161528c60408401826001600160a01b03169052565b50606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516152e6828501826001600160401b03169052565b505061014080840151612b65828501826145e6565b60008060006060848603121561531057600080fd5b835161531b81614697565b602085015160409095015190969495509392505050565b81516001600160a01b031681526101608101602083015161535e60208401826001600160a01b03169052565b506040830151615375604084018262ffffff169052565b50606083015161538a606084018260020b9052565b50608083015161539f608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516153e5828501826001600160a01b03169052565b505061014092830151919092015290565b6000806000806080858703121561540c57600080fd5b84519350602085015161541e81614697565b6040860151606090960151949790965092505050565b81516001600160a01b031681526101408101602083015161546060208401826001600160a01b03169052565b506040830151615475604084018260020b9052565b50606083015161548a606084018260020b9052565b506080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401516154ce828501826001600160a01b03169052565b50506101209283015191909201529056fe10dac8c06a04bec0b551627dad28bc00d6516b0caacd1c7b345fcdb5211334e4a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775a2646970667358221220a85d36c094ba34877a437c6daa029339b13c6867ba25ffbd2d81e18698b1075f64736f6c63430008170033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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