ETH Price: $2,030.14 (+2.67%)

Contract

0x85BCf17Ffb74D6410e6B5babf4Ea5D5E1eAF9F74
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Create Cell134026072021-10-12 8:37:511609 days ago1634027871IN
0x85BCf17F...E1eAF9F74
0 ETH0.041782966.89385756
Withdraw134025952021-10-12 8:35:201609 days ago1634027720IN
0x85BCf17F...E1eAF9F74
0 ETH0.0216584379.77528137
Create Cell134025852021-10-12 8:33:181609 days ago1634027598IN
0x85BCf17F...E1eAF9F74
0 ETH0.06270018100.80026897
Withdraw134025742021-10-12 8:29:141609 days ago1634027354IN
0x85BCf17F...E1eAF9F74
0 ETH0.0276445693.97671819
Create Cell133775252021-10-08 9:54:401613 days ago1633686880IN
0x85BCf17F...E1eAF9F74
0 ETH0.07226149108.27719994
Create Cell133775032021-10-08 9:49:111613 days ago1633686551IN
0x85BCf17F...E1eAF9F74
0 ETH0.0132869698.10946503
Withdraw133772892021-10-08 9:05:431613 days ago1633683943IN
0x85BCf17F...E1eAF9F74
0 ETH0.02595355123.96496793
Create Cell133711042021-10-07 9:56:431614 days ago1633600603IN
0x85BCf17F...E1eAF9F74
0 ETH0.07035557108.46913587
Withdraw133710232021-10-07 9:36:511614 days ago1633599411IN
0x85BCf17F...E1eAF9F74
0 ETH0.0192697191.99799189
Create Cell133647422021-10-06 10:04:161615 days ago1633514656IN
0x85BCf17F...E1eAF9F74
0 ETH0.07020091108.22802011
Safe Transfer Fr...133128782021-09-28 7:11:241623 days ago1632813084IN
0x85BCf17F...E1eAF9F74
0 ETH0.0144205498.60876144
Approve133127792021-09-28 6:48:101623 days ago1632811690IN
0x85BCf17F...E1eAF9F74
0 ETH0.00513024105.11509222
Create Cell132813252021-09-23 10:00:471628 days ago1632391247IN
0x85BCf17F...E1eAF9F74
0 ETH0.0212353539.02173213
Create Cell132812582021-09-23 9:45:181628 days ago1632390318IN
0x85BCf17F...E1eAF9F74
0 ETH0.034096352.57273001
Create Cell132812332021-09-23 9:38:071628 days ago1632389887IN
0x85BCf17F...E1eAF9F74
0 ETH0.0051218644.35475625
Withdraw132811752021-09-23 9:25:401628 days ago1632389140IN
0x85BCf17F...E1eAF9F74
0 ETH0.0132045964.03593888
Create Cell132809362021-09-23 8:35:211628 days ago1632386121IN
0x85BCf17F...E1eAF9F74
0 ETH0.0354330748.06289537
Commit Pending P...132809312021-09-23 8:33:521628 days ago1632386032IN
0x85BCf17F...E1eAF9F74
0 ETH0.0011726340.76593706
Set Pending Perm...132809242021-09-23 8:32:571628 days ago1632385977IN
0x85BCf17F...E1eAF9F74
0 ETH0.002095245.43045486
Create Cell132809102021-09-23 8:29:581628 days ago1632385798IN
0x85BCf17F...E1eAF9F74
0 ETH0.001712653.51064873
Safe Transfer Fr...132713512021-09-21 20:40:531630 days ago1632256853IN
0x85BCf17F...E1eAF9F74
0 ETH0.02505164188.48013921
Approve132713402021-09-21 20:38:091630 days ago1632256689IN
0x85BCf17F...E1eAF9F74
0 ETH0.00849662174.08973542
Create Cell132712782021-09-21 20:25:451630 days ago1632255945IN
0x85BCf17F...E1eAF9F74
0 ETH0.08495497119.88893114
Create Cell132689992021-09-21 11:58:531630 days ago1632225533IN
0x85BCf17F...E1eAF9F74
0 ETH0.0082545439.76196812
Create Cell132688182021-09-21 11:20:421630 days ago1632223242IN
0x85BCf17F...E1eAF9F74
0 ETH0.002452344.22867555
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
UniV3Cells

Compiler Version
v0.8.7+commit.e28d00a7

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/ITokenCells.sol";
import "./libraries/Array.sol";
import "./libraries/external/LiquidityAmounts.sol";
import "./libraries/external/TickMath.sol";
import "./Cells.sol";
import "./interfaces/external/univ3/IUniswapV3PoolState.sol";
import "./interfaces/external/univ3/IUniswapV3Factory.sol";
import "./interfaces/external/univ3/INonfungiblePositionManager.sol";

contract UniV3Cells is IDelegatedCells, Cells {
    using SafeERC20 for IERC20;
    INonfungiblePositionManager public immutable positionManager;
    mapping(uint256 => uint256) public uniNfts;

    constructor(
        INonfungiblePositionManager _positionManager,
        string memory name,
        string memory symbol
    ) Cells(name, symbol) {
        positionManager = _positionManager;
    }

    /// -------------------  PUBLIC, VIEW  -------------------

    function delegated(uint256 nft)
        public
        view
        override
        returns (address[] memory tokens, uint256[] memory tokenAmounts)
    {
        uint256 uniNft = uniNfts[nft];
        require(uniNft > 0, "UNFT0");
        (
            ,
            ,
            address token0,
            address token1,
            uint24 fee,
            int24 tickLower,
            int24 tickUpper,
            uint128 liquidity,
            ,
            ,
            ,

        ) = positionManager.positions(uniNft);
        IUniswapV3PoolState pool = IUniswapV3PoolState(IUniswapV3Factory(positionManager.factory()).getPool(token0, token1, fee));
        (uint160 sqrtPriceX96, , , , , , ) = pool.slot0();
        uint160 sqrtPriceAX96 = TickMath.getSqrtRatioAtTick(tickLower);
        uint160 sqrtPriceBX96 = TickMath.getSqrtRatioAtTick(tickUpper);
        (uint256 amount0, uint256 amount1) = LiquidityAmounts.getAmountsForLiquidity(
            sqrtPriceX96,
            sqrtPriceAX96,
            sqrtPriceBX96,
            liquidity
        );
        tokenAmounts = new uint256[](2);
        tokens = new address[](2);
        tokens[0] = token0;
        tokens[1] = token1;
        tokenAmounts[0] = amount0;
        tokenAmounts[1] = amount1;
    }

    /// -------------------  PUBLIC, MUTATING, NFT_OWNER  -------------------

    function deposit(
        uint256 nft,
        address[] calldata tokens,
        uint256[] calldata tokenAmounts
    ) external override returns (uint256[] memory actualTokenAmounts) {
        require(_isApprovedOrOwner(_msgSender(), nft), "IO");
        require(Array.isSortedAndUnique(tokens), "SAU");
        require(tokens.length == tokenAmounts.length, "L");
        uint256 uniNft = uniNfts[nft];
        require(uniNft > 0, "UNFT0");
        (, , address token0, address token1, , , , , , , , ) = positionManager.positions(uniNft);
        address[] memory pTokens = new address[](2);
        pTokens[0] = token0;
        pTokens[1] = token1;
        uint256[] memory pTokenAmounts = Array.projectTokenAmounts(pTokens, tokens, tokenAmounts);
        for (uint256 i = 0; i < pTokenAmounts.length; i++) {
            IERC20(pTokens[i]).safeTransferFrom(_msgSender(), address(this), pTokenAmounts[i]);
            _allowTokenIfNecessary(pTokens[i]);
        }

        (
            ,
            uint256 amount0,
            uint256 amount1
        ) = positionManager.increaseLiquidity(
            INonfungiblePositionManager.IncreaseLiquidityParams({
                tokenId: uniNft,
                amount0Desired: pTokenAmounts[0],
                amount1Desired: pTokenAmounts[1],
                // TODO: allow for variable params
                amount0Min: 0,
                amount1Min: 0,
                deadline: block.timestamp + 600
            })
        );
        actualTokenAmounts = new uint256[](2);
        actualTokenAmounts[0] = amount0;
        actualTokenAmounts[1] = amount1;
        for (uint256 i = 0; i < pTokens.length; i++) {
            if (actualTokenAmounts[i] < pTokenAmounts[i]) {
                IERC20(pTokens[i]).safeTransfer(_msgSender(), pTokenAmounts[i] - actualTokenAmounts[i]);
            } 
        }
        emit Deposit(nft, tokens, actualTokenAmounts);
    }

    function withdraw(
        uint256 nft,
        address to,
        address[] calldata tokens,
        uint256[] calldata tokenAmounts
    ) external override returns (uint256[] memory actualTokenAmounts) {
        require(_isApprovedOrOwner(_msgSender(), nft), "IO");
        require(Array.isSortedAndUnique(tokens), "SAU");
        require(tokens.length == tokenAmounts.length, "L");
        uint256 uniNft = uniNfts[nft];
        require(uniNft > 0, "UNFT0");
        uint256 liquidity = _getWithdrawLiquidity(nft, uniNft, tokens, tokenAmounts);
        if (liquidity == 0) {
            actualTokenAmounts = new uint256[](2);
            actualTokenAmounts[0] = 0;
            actualTokenAmounts[1] = 0;
            return actualTokenAmounts;
        }
        (
            uint256 amount0,
            uint256 amount1
        ) = positionManager.decreaseLiquidity(
            INonfungiblePositionManager.DecreaseLiquidityParams({
                tokenId: uniNft,
                liquidity: uint128(liquidity),
                // TODO: allow for variable params
                amount0Min: 0,
                amount1Min: 0,
                deadline: block.timestamp + 600
            })
        );
        (
            uint256 actualAmount0,
            uint256 actualAmount1
        ) = positionManager.collect(INonfungiblePositionManager.CollectParams({
                tokenId: uniNft,
                recipient: to,
                amount0Max: uint128(amount0),
                amount1Max: uint128(amount1)
            })
        );
        actualTokenAmounts = new uint256[](2);
        actualTokenAmounts[0] = actualAmount0;
        actualTokenAmounts[1] = actualAmount1;
        emit Withdraw(nft, to, tokens, actualTokenAmounts);
    }

    /// -------------------  PRIVATE, VIEW  -------------------

    function _getWithdrawLiquidity(
        uint256 nft,
        uint256 uniNft, 
        address[] calldata tokens, 
        uint256[] calldata tokenAmounts
    ) internal view returns (uint256) {
        (address[] memory pTokens, uint256[] memory totalAmounts) = delegated(nft);
        uint256[] memory pTokenAmounts = Array.projectTokenAmounts(pTokens, tokens, tokenAmounts);
        (
            ,
            ,
            ,
            ,
            ,
            ,
            ,
            uint128 totalLiquidity,
            ,
            ,
            ,

        ) = positionManager.positions(uniNft);
        if (totalAmounts[0] == 0) {
            if (pTokenAmounts[0] == 0) {
                return totalLiquidity * pTokenAmounts[1] / totalAmounts[1]; // liquidity1
            } else {
                return 0;
            }
        }
        if (totalAmounts[1] == 0) {
            if (pTokenAmounts[1] == 0) {
                return totalLiquidity * pTokenAmounts[0] / totalAmounts[0]; // liquidity0
            } else {
                return 0;
            }
        }
        uint256 liquidity0 = totalLiquidity * pTokenAmounts[0] / totalAmounts[0];
        uint256 liquidity1 = totalLiquidity * pTokenAmounts[1] / totalAmounts[1];
        return liquidity0 < liquidity1 ? liquidity0 : liquidity1;
    }

    /// -------------------  PRIVATE, MUTATING  -------------------

    function _mintCellNft(address[] memory tokens, bytes memory params) internal virtual override returns (uint256) {
        require(params.length == 8 * 32, "IP");
        require(tokens.length == 2, "TL");
        uint24 fee;
        int24 tickLower;
        int24 tickUpper;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
        uint256 deadline;
        assembly {
            fee := mload(add(params, 32))
            tickLower := mload(add(params, 64))
            tickUpper := mload(add(params, 96))
            amount0Desired := mload(add(params, 128))
            amount1Desired := mload(add(params, 160))
            amount0Min := mload(add(params, 192))
            amount1Min := mload(add(params, 224))
            deadline := mload(add(params, 256))
        }
        
        // !!! Call to untrusted contracts
        IERC20(tokens[0]).safeTransferFrom(_msgSender(), address(this), amount0Desired);
        IERC20(tokens[1]).safeTransferFrom(_msgSender(), address(this), amount1Desired);
        _allowTokenIfNecessary(tokens[0]);
        _allowTokenIfNecessary(tokens[1]);
        // !!! End call
        (uint256 uniNft, , , ) = positionManager.mint(
            INonfungiblePositionManager.MintParams({
                token0: tokens[0],
                token1: tokens[1],
                fee: fee,
                tickLower: tickLower,
                tickUpper: tickUpper,
                amount0Desired: amount0Desired,
                amount1Desired: amount1Desired,
                amount0Min: amount0Min,
                amount1Min: amount1Min,
                recipient: address(this),
                deadline: deadline
            })
        );        
        uint256 cellNft = super._mintCellNft(tokens, params);
        uniNfts[cellNft] = uniNft;
        return cellNft;
    }

    function _allowTokenIfNecessary(address token) internal {
        // Since tokens are not stored at contract address after any tx - it's safe to give unlimited approval
        if (IERC20(token).allowance(address(positionManager), address(this)) < type(uint256).max / 2) {
            IERC20(token).approve(address(positionManager), type(uint256).max);
        }
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    function hasRole(bytes32 role, address account) external view returns (bool);

    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    function grantRole(bytes32 role, address account) external;

    function revokeRole(bytes32 role, address account) external;

    function renounceRole(bytes32 role, address account) external;
}

/**
 * @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:
 *
 * ```
 * 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}:
 *
 * ```
 * 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.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @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.
     *
     * _Available since v3.1._
     */
    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 {_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 Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

    /**
     * @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 override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/
     */
    function _checkRole(bytes32 role, address account) internal view {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(uint160(account), 20),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @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 override 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.
     */
    function grantRole(bytes32 role, address account) public virtual override 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.
     */
    function revokeRole(bytes32 role, address account) public virtual override 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 granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

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

    function _grantRole(bytes32 role, address account) private {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerable {
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);

    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
    using EnumerableSet for EnumerableSet.AddressSet;

    mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;

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

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view override returns (address) {
        return _roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view override returns (uint256) {
        return _roleMembers[role].length();
    }

    /**
     * @dev Overload {grantRole} to track enumerable memberships
     */
    function grantRole(bytes32 role, address account) public virtual override {
        super.grantRole(role, account);
        _roleMembers[role].add(account);
    }

    /**
     * @dev Overload {revokeRole} to track enumerable memberships
     */
    function revokeRole(bytes32 role, address account) public virtual override {
        super.revokeRole(role, account);
        _roleMembers[role].remove(account);
    }

    /**
     * @dev Overload {renounceRole} to track enumerable memberships
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        super.renounceRole(role, account);
        _roleMembers[role].remove(account);
    }

    /**
     * @dev Overload {_setupRole} to track enumerable memberships
     */
    function _setupRole(bytes32 role, address account) internal virtual override {
        super._setupRole(role, account);
        _roleMembers[role].add(account);
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

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

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: owner query for nonexistent token");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overriden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        require(operator != _msgSender(), "ERC721: approve to caller");

        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _safeTransfer(from, to, tokenId, _data);
    }

    /**
     * @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.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        require(_exists(tokenId), "ERC721: operator query for nonexistent token");
        address owner = ERC721.ownerOf(tokenId);
        return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, _data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param _data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721Receiver(to).onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * 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 Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

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

    /**
     * @dev Returns 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);

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

File 8 of 29 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

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

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

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

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

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) private pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./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);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastvalue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastvalue;
                // Update the index for the moved value
                set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "./access/GovernanceAccessControl.sol";
import "./interfaces/ICells.sol";
import "./libraries/Array.sol";

contract Cells is ICells, GovernanceAccessControl, ERC721 {
    bool public permissionless = false;
    bool public pendingPermissionless;
    uint256 public maxTokensPerCell = 10;
    uint256 public pendingMaxTokensPerCell;
    mapping(uint256 => address[]) private _managedTokens;
    mapping(uint256 => mapping(address => bool)) private _managedTokensIndex;
    uint256 private _topCellNft = 1;

    constructor(string memory name, string memory symbol) ERC721(name, symbol) {}

    /// -------------------  PUBLIC, VIEW  -------------------

    function managedTokens(uint256 nft) public view override returns (address[] memory) {
        return _managedTokens[nft];
    }

    function isManagedToken(uint256 nft, address token) public view override returns (bool) {
        return _managedTokensIndex[nft][token];
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(ERC721, IERC165, AccessControlEnumerable)
        returns (bool)
    {
        return interfaceId == type(ICells).interfaceId || super.supportsInterface(interfaceId);
    }

    /// -------------------  PUBLIC, MUTATING, GOVERNANCE  -------------------

    function setPendingPermissionless(bool _pendingPermissionless) external {
        require(_isGovernanceOrDelegate(), "PGD");
        pendingPermissionless = _pendingPermissionless;
    }

    function commitPendingPermissionless() external {
        require(_isGovernanceOrDelegate(), "PGD");
        permissionless = pendingPermissionless;
        pendingPermissionless = false;
    }

    function setPendingMaxTokensPerCell(uint256 _pendingMaxTokensPerCell) external {
        require(_isGovernanceOrDelegate(), "PGD");
        pendingMaxTokensPerCell = _pendingMaxTokensPerCell;
    }

    function commitPendingMaxTokensPerCell() external {
        require(_isGovernanceOrDelegate(), "PGD");
        maxTokensPerCell = pendingMaxTokensPerCell;
        pendingMaxTokensPerCell = 0;
    }

    /// -------------------  PUBLIC, MUTATING, GOVERNANCE OR PERMISSIONLESS  -------------------
    function createCell(address[] memory cellTokens, bytes memory params) external override returns (uint256) {
        require(permissionless || _isGovernanceOrDelegate(), "PGD");
        require(cellTokens.length <= maxTokensPerCell, "MT");
        require(Array.isSortedAndUnique(cellTokens), "SAU");
        uint256 nft = _mintCellNft(cellTokens, params);
        _managedTokens[nft] = cellTokens;
        for (uint256 i = 0; i < cellTokens.length; i++) {
            _managedTokensIndex[nft][cellTokens[i]] = true;
        }
        emit ICells.CreateCell(_msgSender(), nft, params);
        return nft;
    }

    /// -------------------  PRIVATE, MUTATING  -------------------

    function _mintCellNft(address[] memory, bytes memory) internal virtual returns (uint256) {
        uint256 nft = _topCellNft;
        _topCellNft += 1;
        _safeMint(_msgSender(), nft);
        return nft;
    }
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";

contract GovernanceAccessControl is AccessControlEnumerable {
    bytes32 internal constant GOVERNANCE_ROLE = keccak256("governance");
    bytes32 internal constant GOVERNANCE_DELEGATE_ROLE = keccak256("governance_delegate");

    constructor() {
        _setupRole(GOVERNANCE_ROLE, _msgSender());
        _setRoleAdmin(GOVERNANCE_ROLE, GOVERNANCE_ROLE);
        _setupRole(GOVERNANCE_DELEGATE_ROLE, _msgSender());
        _setRoleAdmin(GOVERNANCE_DELEGATE_ROLE, GOVERNANCE_ROLE);
    }

    function _isGovernanceOrDelegate() internal view returns (bool) {
        return hasRole(GOVERNANCE_ROLE, _msgSender()) || hasRole(GOVERNANCE_DELEGATE_ROLE, _msgSender());
    }

    function _isGovernance() internal view returns (bool) {
        return hasRole(GOVERNANCE_ROLE, _msgSender());
    }
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

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

interface ICells is IERC721 {
    function managedTokens(uint256 nft) external view returns (address[] memory);

    function isManagedToken(uint256 nft, address token) external view returns (bool);

    function createCell(address[] memory cellTokens, bytes memory params) external returns (uint256);

    event CreateCell(address indexed to, uint256 indexed nft, bytes params);
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

import "./ICells.sol";

interface IDelegatedCells is ICells {
    function delegated(uint256 nft) external view returns (address[] memory tokens, uint256[] memory tokenAmounts);

    function deposit(
        uint256 nft,
        address[] calldata tokens,
        uint256[] calldata tokenAmounts
    ) external returns (uint256[] memory actualTokenAmounts);

    function withdraw(
        uint256 nft,
        address to,
        address[] calldata tokens,
        uint256[] calldata tokenAmounts
    ) external returns (uint256[] memory actualTokenAmounts);


    event Deposit(
        uint256 nft,
        address[] tokens,
        uint256[] actualTokenAmounts
    );

    event Withdraw(
        uint256 nft,
        address to,
        address[] tokens,
        uint256[] actualTokenAmounts
    );
    // TODO: add methods for collecting liquidity mining rewards
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

import "./IDelegatedCells.sol";

interface ITokenCells is IDelegatedCells {
    function claimTokensToCell(
        uint256 nft,
        address[] calldata tokens,
        uint256[] calldata tokenAmounts
    ) external;
}

// SPDX-License-Identifier: GPL-2.0-or-later
// TODO: Check the license
pragma solidity 0.8.7;
pragma abicoder v2;

import "./IPeripheryImmutableState.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 IPeripheryImmutableState {
    /// @notice Emitted when liquidity is increased for a position NFT
    /// @dev Also emitted when a token is minted
    /// @param tokenId The ID of the token for which liquidity was increased
    /// @param liquidity The amount by which liquidity for the NFT position was increased
    /// @param amount0 The amount of token0 that was paid for the increase in liquidity
    /// @param amount1 The amount of token1 that was paid for the increase in liquidity
    event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    /// @notice Emitted when liquidity is decreased for a position NFT
    /// @param tokenId The ID of the token for which liquidity was decreased
    /// @param liquidity The amount by which liquidity for the NFT position was decreased
    /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity
    /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity
    event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
    /// @notice Emitted when tokens are collected for a position NFT
    /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior
    /// @param tokenId The ID of the token for which underlying tokens were collected
    /// @param recipient The address of the account that received the collected tokens
    /// @param amount0 The amount of token0 owed to the position that was collected
    /// @param amount1 The amount of token1 owed to the position that was collected
    event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);

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

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

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: GPL-2.0-or-later
// TODO: Check the license
pragma solidity =0.8.7;

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

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

// SPDX-License-Identifier: GPL-2.0-or-later
// TODO: Check the license
pragma solidity =0.8.7;

/// @title The interface for the Uniswap V3 Factory
/// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees
interface IUniswapV3Factory {
    /// @notice Emitted when the owner of the factory is changed
    /// @param oldOwner The owner before the owner was changed
    /// @param newOwner The owner after the owner was changed
    event OwnerChanged(address indexed oldOwner, address indexed newOwner);

    /// @notice Emitted when a pool is created
    /// @param token0 The first token of the pool by address sort order
    /// @param token1 The second token of the pool by address sort order
    /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
    /// @param tickSpacing The minimum number of ticks between initialized ticks
    /// @param pool The address of the created pool
    event PoolCreated(
        address indexed token0,
        address indexed token1,
        uint24 indexed fee,
        int24 tickSpacing,
        address pool
    );

    /// @notice Emitted when a new fee amount is enabled for pool creation via the factory
    /// @param fee The enabled fee, denominated in hundredths of a bip
    /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee
    event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing);

    /// @notice Returns the current owner of the factory
    /// @dev Can be changed by the current owner via setOwner
    /// @return The address of the factory owner
    function owner() external view returns (address);

    /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled
    /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context
    /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee
    /// @return The tick spacing
    function feeAmountTickSpacing(uint24 fee) external view returns (int24);

    /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist
    /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
    /// @param tokenA The contract address of either token0 or token1
    /// @param tokenB The contract address of the other token
    /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
    /// @return pool The pool address
    function getPool(
        address tokenA,
        address tokenB,
        uint24 fee
    ) external view returns (address pool);

    /// @notice Creates a pool for the given two tokens and fee
    /// @param tokenA One of the two tokens in the desired pool
    /// @param tokenB The other of the two tokens in the desired pool
    /// @param fee The desired fee for the pool
    /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved
    /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments
    /// are invalid.
    /// @return pool The address of the newly created pool
    function createPool(
        address tokenA,
        address tokenB,
        uint24 fee
    ) external returns (address pool);

    /// @notice Updates the owner of the factory
    /// @dev Must be called by the current owner
    /// @param _owner The new owner of the factory
    function setOwner(address _owner) external;

    /// @notice Enables a fee amount with the given tickSpacing
    /// @dev Fee amounts may never be removed once enabled
    /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)
    /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount
    function enableFeeAmount(uint24 fee, int24 tickSpacing) external;
}

// SPDX-License-Identifier: GPL-2.0-or-later
// TODO: Check the license
pragma solidity =0.8.7;

/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
    /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
    /// when accessed externally.
    /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
    /// tick The current tick of the pool, i.e. according to the last tick transition that was run.
    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
    /// boundary.
    /// observationIndex The index of the last oracle observation that was written,
    /// observationCardinality The current maximum number of observations stored in the pool,
    /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.
    /// feeProtocol The protocol fee for both tokens of the pool.
    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
    /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
    /// unlocked Whether the pool is currently locked to reentrancy
    function slot0()
        external
        view
        returns (
            uint160 sqrtPriceX96,
            int24 tick,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext,
            uint8 feeProtocol,
            bool unlocked
        );

    /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal0X128() external view returns (uint256);

    /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal1X128() external view returns (uint256);

    /// @notice The amounts of token0 and token1 that are owed to the protocol
    /// @dev Protocol fees will never exceed uint128 max in either token
    function protocolFees() external view returns (uint128 token0, uint128 token1);

    /// @notice The currently in range liquidity available to the pool
    /// @dev This value has no relationship to the total liquidity across all ticks
    function liquidity() external view returns (uint128);

    /// @notice Look up information about a specific tick in the pool
    /// @param tick The tick to look up
    /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
    /// tick upper,
    /// liquidityNet how much liquidity changes when the pool price crosses the tick,
    /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
    /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
    /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
    /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
    /// secondsOutside the seconds spent on the other side of the tick from the current tick,
    /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
    /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
    /// In addition, these values are only relative and must be used only in comparison to previous snapshots for
    /// a specific position.
    function ticks(int24 tick)
        external
        view
        returns (
            uint128 liquidityGross,
            int128 liquidityNet,
            uint256 feeGrowthOutside0X128,
            uint256 feeGrowthOutside1X128,
            int56 tickCumulativeOutside,
            uint160 secondsPerLiquidityOutsideX128,
            uint32 secondsOutside,
            bool initialized
        );

    /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
    function tickBitmap(int16 wordPosition) external view returns (uint256);

    /// @notice Returns the information about a position by the position's key
    /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
    /// @return _liquidity The amount of liquidity in the position,
    /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
    /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
    /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
    /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
    function positions(bytes32 key)
        external
        view
        returns (
            uint128 _liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

    /// @notice Returns data about a specific observation index
    /// @param index The element of the observations array to fetch
    /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
    /// ago, rather than at a specific index in the array.
    /// @return blockTimestamp The timestamp of the observation,
    /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
    /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
    /// Returns initialized whether the observation has been initialized and the values are safe to use
    function observations(uint256 index)
        external
        view
        returns (
            uint32 blockTimestamp,
            int56 tickCumulative,
            uint160 secondsPerLiquidityCumulativeX128,
            bool initialized
        );
}

// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

library Array {
    function bubbleSort(address[] memory arr) internal pure {
        uint256 l = arr.length;
        for (uint256 i = 0; i < l; i++) {
            for (uint256 j = i + 1; j < l; j++) {
                if (arr[i] > arr[j]) {
                    address temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
    }

    function isSortedAndUnique(address[] memory tokens) internal pure returns (bool) {
        if (tokens.length < 2) {
            return true;
        }
        for (uint256 i = 0; i < tokens.length - 1; i++) {
            if (tokens[i] >= tokens[i + 1]) {
                return false;
            }
        }
        return true;
    }

    /// @dev
    /// Requires both sets of tokens to be sorted. When tokens are not sorted, it's undefined behavior.
    /// If there is a token in tokensToProject that is not part of tokens and corresponding tokenAmountsToProject > 0, reverts.
    /// Zero token amount is eqiuvalent to missing token
    function projectTokenAmounts(
        address[] memory tokens,
        address[] memory tokensToProject,
        uint256[] memory tokenAmountsToProject
    ) internal pure returns (uint256[] memory) {
        uint256[] memory res = new uint256[](tokens.length);
        uint256 t = 0;
        uint256 tp = 0;
        while ((t < tokens.length) && (tp < tokensToProject.length)) {
            if (tokens[t] < tokensToProject[tp]) {
                res[t] = 0;
                t++;
            } else if (tokens[t] > tokensToProject[tp]) {
                if (tokenAmountsToProject[tp] == 0) {
                    tp++;
                } else {
                    revert("TPS");
                }
            } else {
                res[t] = tokenAmountsToProject[tp];
                t++;
                tp++;
            }
        }
        while (t < tokens.length) {
            res[t] = 0;
            t++;
        }
        return res;
    }

    /// @notice Splits each amount from `amounts` into k amounts according to `weights`.
    /// @dev Requires tokens and tokenAmounts to be vector of size n and delegatedTokenAmounts to be k x n matrix
    /// so that delegatedTokenAmounts[i] is a vector of size n
    /// norm is a vector 1 x k
    /// the error is up to k tokens due to rounding
    /// @param amounts Amounts to split, vector n x 1
    /// @param weights Weights of the split, matrix n x k, weights[i] is vector n x 1.
    /// Weights do not need to sum to 1 in each column, but they will be normalized on split.
    function splitAmounts(uint256[] memory amounts, uint256[][] memory weights)
        internal
        pure
        returns (uint256[][] memory)
    {
        uint256 k = weights.length;
        require(k > 0, "KGT0");
        uint256 n = amounts.length;
        require(n > 0, "NGT0");
        uint256[] memory weightsNorm = new uint256[](n);
        for (uint256 i = 0; i < k; i++) {
            require(weights[i].length == n, "NV");
        }
        for (uint256 j = 0; j < n; j++) {
            weightsNorm[j] = 0;
            for (uint256 i = 0; i < k; i++) {
                weightsNorm[j] += weights[i][j];
            }
        }

        uint256[][] memory res = new uint256[][](k);
        for (uint256 i = 0; i < k; i++) {
            res[i] = new uint256[](n);
            for (uint256 j = 0; j < n; j++) {
                res[i][j] = (weights[i][j] * amounts[j]) / weightsNorm[j];
            }
        }
        return res;
    }

    function _isSubsetOf(
        address[] memory tokens,
        address[] memory tokensToCheck,
        address[] memory amountsToCheck
    ) internal {}
}

File 26 of 29 : FixedPoint96.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.8.7;

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

// SPDX-License-Identifier: MIT
pragma solidity =0.8.7;

/// @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) {
        // diff: original lib works under 0.7.6 with overflows enabled
        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.
            // diff: original uint256 twos = -denominator & denominator;
            uint256 twos = uint256(-int256(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) {
        // diff: original lib works under 0.7.6 with overflows enabled
        unchecked {
            result = mulDiv(a, b, denominator);
            if (mulmod(a, b, denominator) > 0) {
                require(result < type(uint256).max);
                result++;
            }
        }
    }
}

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

import "./FullMath.sol";
import "./FixedPoint96.sol";

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

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

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

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

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

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

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

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

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

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

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

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

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

/// @title Math library for computing sqrt prices from ticks and vice versa
/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
/// prices between 2**-128 and 2**128
library TickMath {
    /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
    int24 internal constant MIN_TICK = -887272;
    /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
    int24 internal constant MAX_TICK = -MIN_TICK;

    /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)
    uint160 internal constant MIN_SQRT_RATIO = 4295128739;
    /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)
    uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;

    /// @notice Calculates sqrt(1.0001^tick) * 2^96
    /// @dev Throws if |tick| > max tick
    /// @param tick The input tick for the above formula
    /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
    /// at the given tick
    function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
        uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
        // diff: original require(absTick <= uint256(MAX_TICK), "T");
        require(absTick <= uint256(int256(MAX_TICK)), "T");

        uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;
        if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
        if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
        if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
        if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
        if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
        if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
        if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
        if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
        if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
        if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
        if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
        if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
        if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
        if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
        if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
        if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
        if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
        if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
        if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;

        if (tick > 0) ratio = type(uint256).max / ratio;

        // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
        // we then downcast because we know the result always fits within 160 bits due to our tick input constraint
        // we round up in the division so getTickAtSqrtRatio of the output price is always consistent
        sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
    }

    /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio
    /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may
    /// ever return.
    /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96
    /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio
    function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {
        // second inequality must be < because the price can never reach the price at the max tick
        require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, "R");
        uint256 ratio = uint256(sqrtPriceX96) << 32;

        uint256 r = ratio;
        uint256 msb = 0;

        assembly {
            let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(5, gt(r, 0xFFFFFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(4, gt(r, 0xFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(3, gt(r, 0xFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(2, gt(r, 0xF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(1, gt(r, 0x3))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := gt(r, 0x1)
            msb := or(msb, f)
        }

        if (msb >= 128) r = ratio >> (msb - 127);
        else r = ratio << (127 - msb);

        int256 log_2 = (int256(msb) - 128) << 64;

        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(63, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(62, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(61, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(60, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(59, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(58, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(57, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(56, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(55, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(54, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(53, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(52, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(51, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(50, f))
        }

        int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number

        int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);
        int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);

        tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;
    }
}

Settings
{
  "evmVersion": "istanbul",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"contract INonfungiblePositionManager","name":"_positionManager","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"nft","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"params","type":"bytes"}],"name":"CreateCell","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"nft","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"actualTokenAmounts","type":"uint256[]"}],"name":"Deposit","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":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"nft","type":"uint256"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"actualTokenAmounts","type":"uint256[]"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"commitPendingMaxTokensPerCell","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"commitPendingPermissionless","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"cellTokens","type":"address[]"},{"internalType":"bytes","name":"params","type":"bytes"}],"name":"createCell","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nft","type":"uint256"}],"name":"delegated","outputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"tokenAmounts","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nft","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"tokenAmounts","type":"uint256[]"}],"name":"deposit","outputs":[{"internalType":"uint256[]","name":"actualTokenAmounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nft","type":"uint256"},{"internalType":"address","name":"token","type":"address"}],"name":"isManagedToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nft","type":"uint256"}],"name":"managedTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTokensPerCell","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingMaxTokensPerCell","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingPermissionless","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permissionless","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"positionManager","outputs":[{"internalType":"contract INonfungiblePositionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","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":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pendingMaxTokensPerCell","type":"uint256"}],"name":"setPendingMaxTokensPerCell","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_pendingPermissionless","type":"bool"}],"name":"setPendingPermissionless","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":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"uniNfts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nft","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"tokenAmounts","type":"uint256[]"}],"name":"withdraw","outputs":[{"internalType":"uint256[]","name":"actualTokenAmounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"}]

60a06040526008805460ff19169055600a6009556001600d553480156200002557600080fd5b506040516200513738038062005137833981016040819052620000489162000429565b8181818162000067600080516020620050f78339815191523362000113565b62000082600080516020620050f78339815191528062000156565b6200009d600080516020620051178339815191523362000113565b620000c760008051602062005117833981519152600080516020620050f783398151915262000156565b8151620000dc906002906020850190620002cc565b508051620000f2906003906020840190620002cc565b505050505060609290921b6001600160601b03191660805250620005069050565b6200012a8282620001aa60201b62001ca91760201c565b60008281526001602090815260409091206200015191839062001cb7620001ba821b17901c565b505050565b600082815260208190526040902060010154819060405184907fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff90600090a460009182526020829052604090912060010155565b620001b68282620001da565b5050565b6000620001d1836001600160a01b0384166200027a565b90505b92915050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16620001b6576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620002363390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000818152600183016020526040812054620002c357508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620001d4565b506000620001d4565b828054620002da90620004b3565b90600052602060002090601f016020900481019282620002fe576000855562000349565b82601f106200031957805160ff191683800117855562000349565b8280016001018555821562000349579182015b82811115620003495782518255916020019190600101906200032c565b50620003579291506200035b565b5090565b5b808211156200035757600081556001016200035c565b600082601f8301126200038457600080fd5b81516001600160401b0380821115620003a157620003a1620004f0565b604051601f8301601f19908116603f01168101908282118183101715620003cc57620003cc620004f0565b81604052838152602092508683858801011115620003e957600080fd5b600091505b838210156200040d5785820183015181830184015290820190620003ee565b838211156200041f5760008385830101525b9695505050505050565b6000806000606084860312156200043f57600080fd5b83516001600160a01b03811681146200045757600080fd5b60208501519093506001600160401b03808211156200047557600080fd5b620004838783880162000372565b935060408601519150808211156200049a57600080fd5b50620004a98682870162000372565b9150509250925092565b600181811c90821680620004c857607f821691505b60208210811415620004ea57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b60805160601c614b8c6200056b600039600081816103e00152818161090f01528181610b5201528181610fcf0152818161108201528181611848015281816119ca015281816121c70152818161226c015281816124860152612db20152614b8c6000f3fe608060405234801561001057600080fd5b50600436106102275760003560e01c80639010d07c11610130578063c87b56dd116100b8578063ebcf2d771161007c578063ebcf2d771461050f578063ec15eb161461052f578063ee48184514610538578063ee7e2dd31461054a578063fe7f20341461058357600080fd5b8063c87b56dd14610487578063ca15c8731461049a578063d547741f146104ad578063de7f9e4e146104c0578063e985e9c5146104d357600080fd5b8063a217fddf116100ff578063a217fddf1461043d578063a22cb46514610445578063b539978214610458578063b7874baa14610461578063b88d4fde1461047457600080fd5b80639010d07c1461040257806391d148541461041557806395d89b4114610428578063a1256f9f1461043057600080fd5b8063248a9ca3116101b357806342842e0e1161018257806342842e0e1461039a57806344fbb334146103ad5780636352211e146103b557806370a08231146103c8578063791b98bc146103db57600080fd5b8063248a9ca31461033e5780632f2ff15d1461036157806336568abe14610374578063423b01ec1461038757600080fd5b80630d7a41b7116101fa5780630d7a41b7146102a957806313a24a30146102c957806318e44a49146102ea5780631bb7ad6b1461030b57806323b872dd1461032b57600080fd5b806301ffc9a71461022c57806306fdde0314610254578063081812fc14610269578063095ea7b314610294575b600080fd5b61023f61023a366004614136565b61058b565b60405190151581526020015b60405180910390f35b61025c6105b6565b60405161024b91906146bf565b61027c6102773660046140d6565b610648565b6040516001600160a01b03909116815260200161024b565b6102a76102a2366004613f95565b6106e2565b005b6102bc6102b73660046142df565b6107f8565b60405161024b91906146ac565b6102dc6102d7366004613fc1565b610e12565b60405190815260200161024b565b6102fd6102f83660046140d6565b610f93565b60405161024b92919061467e565b61031e6103193660046140d6565b61134a565b60405161024b919061466b565b6102a7610339366004613eba565b6113b6565b6102dc61034c3660046140d6565b60009081526020819052604090206001015490565b6102a761036f3660046140ef565b6113e7565b6102a76103823660046140ef565b611409565b6102a761039536600461409c565b61142b565b6102a76103a8366004613eba565b611469565b6102a7611484565b61027c6103c33660046140d6565b6114b5565b6102dc6103d6366004613e47565b61152c565b61027c7f000000000000000000000000000000000000000000000000000000000000000081565b61027c610410366004614114565b6115b3565b61023f6104233660046140ef565b6115d2565b61025c6115fb565b60085461023f9060ff1681565b6102dc600081565b6102a7610453366004613f67565b61160a565b6102dc600a5481565b6102bc61046f366004614253565b6116cf565b6102a7610482366004613efb565b611afd565b61025c6104953660046140d6565b611b35565b6102dc6104a83660046140d6565b611c1c565b6102a76104bb3660046140ef565b611c33565b6102a76104ce3660046140d6565b611c3d565b61023f6104e1366004613e81565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b6102dc61051d3660046140d6565b600e6020526000908152604090205481565b6102dc60095481565b60085461023f90610100900460ff1681565b61023f6105583660046140ef565b6000918252600c602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6102a7611c66565b60006001600160e01b03198216631ccd795160e31b14806105b057506105b082611ccc565b92915050565b6060600280546105c590614a05565b80601f01602080910402602001604051908101604052809291908181526020018280546105f190614a05565b801561063e5780601f106106135761010080835404028352916020019161063e565b820191906000526020600020905b81548152906001019060200180831161062157829003601f168201915b5050505050905090565b6000818152600460205260408120546001600160a01b03166106c65760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600660205260409020546001600160a01b031690565b60006106ed826114b5565b9050806001600160a01b0316836001600160a01b0316141561075b5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106bd565b336001600160a01b0382161480610777575061077781336104e1565b6107e95760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106bd565b6107f38383611d0c565b505050565b60606108043387611d7a565b6108355760405162461bcd60e51b8152602060048201526002602482015261494f60f01b60448201526064016106bd565b610871858580806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250611e7192505050565b61088d5760405162461bcd60e51b81526004016106bd90614741565b8382146108c05760405162461bcd60e51b81526020600482015260016024820152601360fa1b60448201526064016106bd565b6000868152600e6020526040902054806108ec5760405162461bcd60e51b81526004016106bd906147af565b60405163133f757160e31b81526004810182905260009081906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906399fbab88906024016101806040518083038186803b15801561095257600080fd5b505afa158015610966573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098a91906143b9565b50505050505050509350935050506000600267ffffffffffffffff8111156109b4576109b4614b07565b6040519080825280602002602001820160405280156109dd578160200160208202803683370190505b50905082816000815181106109f4576109f4614af1565b60200260200101906001600160a01b031690816001600160a01b0316815250508181600181518110610a2857610a28614af1565b60200260200101906001600160a01b031690816001600160a01b0316815250506000610ab8828b8b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516020808f0282810182019093528e82529093508e92508d918291850190849080828437600092019190915250611f1692505050565b905060005b8151811015610b4c57610b183330848481518110610add57610add614af1565b6020026020010151868581518110610af757610af7614af1565b60200260200101516001600160a01b0316612138909392919063ffffffff16565b610b3a838281518110610b2d57610b2d614af1565b60200260200101516121a3565b80610b4481614a40565b915050610abd565b506000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663219f5d176040518060c001604052808a815260200186600081518110610ba357610ba3614af1565b6020026020010151815260200186600181518110610bc357610bc3614af1565b60200260200101518152602001600081526020016000815260200142610258610bec9190614938565b9052604080516001600160e01b031960e085901b1681528251600482015260208301516024820152908201516044820152606082015160648201526080820151608482015260a09091015160a482015260c401606060405180830381600087803b158015610c5957600080fd5b505af1158015610c6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c919190614170565b6040805160028082526060820183529396509194509092506020830190803683370190505097508188600081518110610ccc57610ccc614af1565b6020026020010181815250508088600181518110610cec57610cec614af1565b60200260200101818152505060005b8451811015610dc457838181518110610d1657610d16614af1565b6020026020010151898281518110610d3057610d30614af1565b60200260200101511015610db257610db2338a8381518110610d5457610d54614af1565b6020026020010151868481518110610d6e57610d6e614af1565b6020026020010151610d8091906149ab565b878481518110610d9257610d92614af1565b60200260200101516001600160a01b03166122fb9092919063ffffffff16565b80610dbc81614a40565b915050610cfb565b507fe33829dd3495a41ba02f88de5eadec2635e25192c73dee8c65625206aa61e09a8d8d8d8b604051610dfa94939291906148db565b60405180910390a15050505050505095945050505050565b60085460009060ff1680610e295750610e2961232b565b610e455760405162461bcd60e51b81526004016106bd906146d2565b60095483511115610e7d5760405162461bcd60e51b8152602060048201526002602482015261135560f21b60448201526064016106bd565b610e8683611e71565b610ea25760405162461bcd60e51b81526004016106bd90614741565b6000610eae848461238c565b6000818152600b602090815260409091208651929350610ed2929091870190613cb3565b5060005b8451811015610f49576000828152600c60205260408120865160019290889085908110610f0557610f05614af1565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff191691151591909117905580610f4181614a40565b915050610ed6565b5080336001600160a01b03167fe423da5b0aa0eb7a8c8409551a7f9487952c6003da26568ea41ee22cf3133d4a85604051610f8491906146bf565b60405180910390a39392505050565b6000818152600e6020526040902054606090819080610fc45760405162461bcd60e51b81526004016106bd906147af565b6000806000806000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166399fbab88886040518263ffffffff1660e01b815260040161101b91815260200190565b6101806040518083038186803b15801561103457600080fd5b505afa158015611048573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061106c91906143b9565b50505050975097509750975097509750505060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156110d957600080fd5b505afa1580156110ed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111119190613e64565b604051630b4c774160e11b81526001600160a01b038981166004830152888116602483015262ffffff881660448301529190911690631698ee829060640160206040518083038186803b15801561116757600080fd5b505afa15801561117b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119f9190613e64565b90506000816001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156111dc57600080fd5b505afa1580156111f0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061121491906141a5565b50505050505090506000611227866125fa565b90506000611234866125fa565b90506000806112458585858a612a0f565b604080516002808252606082019092529294509092508160200160208202803683370190505060408051600280825260608201909252919f50816020016020820280368337019050509e508b8f6000815181106112a4576112a4614af1565b60200260200101906001600160a01b031690816001600160a01b0316815250508a8f6001815181106112d8576112d8614af1565b60200260200101906001600160a01b031690816001600160a01b031681525050818e60008151811061130c5761130c614af1565b602002602001018181525050808e60018151811061132c5761132c614af1565b60200260200101818152505050505050505050505050505050915091565b6000818152600b60209081526040918290208054835181840281018401909452808452606093928301828280156113aa57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161138c575b50505050509050919050565b6113c03382611d7a565b6113dc5760405162461bcd60e51b81526004016106bd9061475e565b6107f3838383612aab565b6113f18282612c4b565b60008281526001602052604090206107f39082611cb7565b6114138282612c71565b60008281526001602052604090206107f39082612ceb565b61143361232b565b61144f5760405162461bcd60e51b81526004016106bd906146d2565b600880549115156101000261ff0019909216919091179055565b6107f383838360405180602001604052806000815250611afd565b61148c61232b565b6114a85760405162461bcd60e51b81526004016106bd906146d2565b600a805460095560009055565b6000818152600460205260408120546001600160a01b0316806105b05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106bd565b60006001600160a01b0382166115975760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106bd565b506001600160a01b031660009081526005602052604090205490565b60008281526001602052604081206115cb9083612d00565b9392505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6060600380546105c590614a05565b6001600160a01b0382163314156116635760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106bd565b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60606116db3388611d7a565b61170c5760405162461bcd60e51b8152602060048201526002602482015261494f60f01b60448201526064016106bd565b611748858580806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250611e7192505050565b6117645760405162461bcd60e51b81526004016106bd90614741565b8382146117975760405162461bcd60e51b81526020600482015260016024820152601360fa1b60448201526064016106bd565b6000878152600e6020526040902054806117c35760405162461bcd60e51b81526004016106bd906147af565b60006117d3898389898989612d0c565b90508061184357604080516002808252606082018352909160208301908036833701905050925060008360008151811061180f5761180f614af1565b60200260200101818152505060008360018151811061183057611830614af1565b6020026020010181815250505050611af3565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630c49ccbe6040518060a00160405280878152602001866001600160801b031681526020016000815260200160008152602001426102586118b19190614938565b9052604080516001600160e01b031960e085901b1681528251600482015260208301516001600160801b0316602482015290820151604482015260608201516064820152608090910151608482015260a4016040805180830381600087803b15801561191c57600080fd5b505af1158015611930573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119549190614395565b604080516080810182528781526001600160a01b038e8116602083019081526001600160801b0380871684860190815281871660608601908152955163fc6f786560e01b8152945160048601529151831660248501529051811660448401529251909216606482015292945090925060009182917f0000000000000000000000000000000000000000000000000000000000000000169063fc6f7865906084016040805180830381600087803b158015611a0d57600080fd5b505af1158015611a21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a459190614395565b604080516002808252606082019092529294509092508160200160208202803683370190505096508187600081518110611a8157611a81614af1565b6020026020010181815250508087600181518110611aa157611aa1614af1565b6020026020010181815250507f8d04027fcc6b389782391c87ffe1fbc8b300720c147b657fc2cd85161fcf2fe98d8d8d8d8b604051611ae4959493929190614892565b60405180910390a15050505050505b9695505050505050565b611b073383611d7a565b611b235760405162461bcd60e51b81526004016106bd9061475e565b611b2f84848484613030565b50505050565b6000818152600460205260409020546060906001600160a01b0316611bb45760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016106bd565b6000611bcb60408051602081019091526000815290565b90506000815111611beb57604051806020016040528060008152506115cb565b80611bf584613063565b604051602001611c06929190614594565b6040516020818303038152906040529392505050565b60008181526001602052604081206105b090613161565b611413828261316b565b611c4561232b565b611c615760405162461bcd60e51b81526004016106bd906146d2565b600a55565b611c6e61232b565b611c8a5760405162461bcd60e51b81526004016106bd906146d2565b6008805461ff001960ff61010083041615151661ffff19909116179055565b611cb38282613191565b5050565b60006115cb836001600160a01b038416613215565b60006001600160e01b031982166380ac58cd60e01b1480611cfd57506001600160e01b03198216635b5e139f60e01b145b806105b057506105b082613264565b600081815260066020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611d41826114b5565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600460205260408120546001600160a01b0316611df35760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106bd565b6000611dfe836114b5565b9050806001600160a01b0316846001600160a01b03161480611e395750836001600160a01b0316611e2e84610648565b6001600160a01b0316145b80611e6957506001600160a01b0380821660009081526007602090815260408083209388168352929052205460ff165b949350505050565b6000600282511015611e8557506001919050565b60005b60018351611e9691906149ab565b811015611f0d5782611ea9826001614938565b81518110611eb957611eb9614af1565b60200260200101516001600160a01b0316838281518110611edc57611edc614af1565b60200260200101516001600160a01b031610611efb5750600092915050565b80611f0581614a40565b915050611e88565b50600192915050565b60606000845167ffffffffffffffff811115611f3457611f34614b07565b604051908082528060200260200182016040528015611f5d578160200160208202803683370190505b5090506000805b865182108015611f745750855181105b156120f357858181518110611f8b57611f8b614af1565b60200260200101516001600160a01b0316878381518110611fae57611fae614af1565b60200260200101516001600160a01b03161015611ff6576000838381518110611fd957611fd9614af1565b602090810291909101015281611fee81614a40565b925050611f64565b85818151811061200857612008614af1565b60200260200101516001600160a01b031687838151811061202b5761202b614af1565b60200260200101516001600160a01b031611156120a45784818151811061205457612054614af1565b602002602001015160001415612076578061206e81614a40565b915050611f64565b60405162461bcd60e51b815260206004820152600360248201526254505360e81b60448201526064016106bd565b8481815181106120b6576120b6614af1565b60200260200101518383815181106120d0576120d0614af1565b6020908102919091010152816120e581614a40565b925050808061206e90614a40565b865182101561212d57600083838151811061211057612110614af1565b60209081029190910101528161212581614a40565b9250506120f3565b509095945050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052611b2f9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613289565b6121b06002600019614950565b604051636eb1769f60e11b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116600483015230602483015283169063dd62ed3e9060440160206040518083038186803b15801561221757600080fd5b505afa15801561222b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061224f919061423a565b10156122f85760405163095ea7b360e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152600019602483015282169063095ea7b390604401602060405180830381600087803b1580156122c057600080fd5b505af11580156122d4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cb391906140b9565b50565b6040516001600160a01b0383166024820152604481018290526107f390849063a9059cbb60e01b9060640161216c565b60006123577fabea6fd3db56a6e6d0242111b43ebb13d1c42709651c032c7894962023a1f90a336115d2565b8061238757506123877fb2ca199e5d628271269f73708112899272988324e125fafee9627694e71b1d25336115d2565b905090565b60008151610100146123c55760405162461bcd60e51b8152602060048201526002602482015261049560f41b60448201526064016106bd565b82516002146123fb5760405162461bcd60e51b8152602060048201526002602482015261151360f21b60448201526064016106bd565b602082015160408301516060840151608085015160a086015160c087015160e088015161010089015161243d3330878e600081518110610af757610af7614af1565b6124563330868e600181518110610af757610af7614af1565b61246c8b600081518110610b2d57610b2d614af1565b6124828b600181518110610b2d57610b2d614af1565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663883164566040518061016001604052808f6000815181106124d2576124d2614af1565b60200260200101516001600160a01b031681526020018f6001815181106124fb576124fb614af1565b60200260200101516001600160a01b031681526020018c62ffffff1681526020018b60020b81526020018a60020b8152602001898152602001888152602001878152602001868152602001306001600160a01b03168152602001858152506040518263ffffffff1660e01b815260040161257591906147ce565b608060405180830381600087803b15801561258f57600080fd5b505af11580156125a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125c79190614359565b505050905060006125d88d8d61335b565b6000818152600e6020526040902092909255509b9a5050505050505050505050565b60008060008360020b12612611578260020b61261e565b8260020b61261e90614a92565b905061262d620d89e719614a6f565b60020b8111156126635760405162461bcd60e51b81526020600482015260016024820152601560fa1b60448201526064016106bd565b60006001821661267757600160801b612689565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156126c85760806126c3826ffff97272373d413259a46990580e213a614964565b901c90505b60048216156126f25760806126ed826ffff2e50f5f656932ef12357cf3c7fdcc614964565b901c90505b600882161561271c576080612717826fffe5caca7e10e4e61c3624eaa0941cd0614964565b901c90505b6010821615612746576080612741826fffcb9843d60f6159c9db58835c926644614964565b901c90505b602082161561277057608061276b826fff973b41fa98c081472e6896dfb254c0614964565b901c90505b604082161561279a576080612795826fff2ea16466c96a3843ec78b326b52861614964565b901c90505b60808216156127c45760806127bf826ffe5dee046a99a2a811c461f1969c3053614964565b901c90505b6101008216156127ef5760806127ea826ffcbe86c7900a88aedcffc83b479aa3a4614964565b901c90505b61020082161561281a576080612815826ff987a7253ac413176f2b074cf7815e54614964565b901c90505b610400821615612845576080612840826ff3392b0822b70005940c7a398e4b70f3614964565b901c90505b61080082161561287057608061286b826fe7159475a2c29b7443b29c7fa6e889d9614964565b901c90505b61100082161561289b576080612896826fd097f3bdfd2022b8845ad8f792aa5825614964565b901c90505b6120008216156128c65760806128c1826fa9f746462d870fdf8a65dc1f90e061e5614964565b901c90505b6140008216156128f15760806128ec826f70d869a156d2a1b890bb3df62baf32f7614964565b901c90505b61800082161561291c576080612917826f31be135f97d08fd981231505542fcfa6614964565b901c90505b62010000821615612948576080612943826f09aa508b5b7a84e1c677de54f3e99bc9614964565b901c90505b6202000082161561297357608061296e826e5d6af8dedb81196699c329225ee604614964565b901c90505b6204000082161561299d576080612998826d2216e584f5fa1ea926041bedfe98614964565b901c90505b620800008216156129c55760806129c0826b048a170391f7dc42444e8fa2614964565b901c90505b60008460020b13156129e0576129dd81600019614950565b90505b6129ef64010000000082614a5b565b156129fb5760016129fe565b60005b611e699060ff16602083901c614938565b600080836001600160a01b0316856001600160a01b03161115612a30579293925b846001600160a01b0316866001600160a01b031611612a5b57612a54858585613380565b9150612aa2565b836001600160a01b0316866001600160a01b03161015612a9457612a80868585613380565b9150612a8d8587856133f3565b9050612aa2565b612a9f8585856133f3565b90505b94509492505050565b826001600160a01b0316612abe826114b5565b6001600160a01b031614612b265760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016106bd565b6001600160a01b038216612b885760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106bd565b612b93600082611d0c565b6001600160a01b0383166000908152600560205260408120805460019290612bbc9084906149ab565b90915550506001600160a01b0382166000908152600560205260408120805460019290612bea908490614938565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600082815260208190526040902060010154612c67813361343d565b6107f38383613191565b6001600160a01b0381163314612ce15760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016106bd565b611cb382826134a1565b60006115cb836001600160a01b038416613506565b60006115cb83836135f9565b6000806000612d1a89610f93565b915091506000612d8e8389898080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516020808d0282810182019093528c82529093508c92508b918291850190849080828437600092019190915250611f1692505050565b60405163133f757160e31b8152600481018b90529091506000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906399fbab88906024016101806040518083038186803b158015612df557600080fd5b505afa158015612e09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e2d91906143b9565b5050505097505050505050505082600081518110612e4d57612e4d614af1565b602002602001015160001415612eec5781600081518110612e7057612e70614af1565b602002602001015160001415612edf5782600181518110612e9357612e93614af1565b602002602001015182600181518110612eae57612eae614af1565b6020026020010151826001600160801b0316612eca9190614964565b612ed49190614950565b945050505050611af3565b6000945050505050611af3565b82600181518110612eff57612eff614af1565b602002602001015160001415612f605781600181518110612f2257612f22614af1565b602002602001015160001415612edf5782600081518110612f4557612f45614af1565b602002602001015182600081518110612eae57612eae614af1565b600083600081518110612f7557612f75614af1565b602002602001015183600081518110612f9057612f90614af1565b6020026020010151836001600160801b0316612fac9190614964565b612fb69190614950565b9050600084600181518110612fcd57612fcd614af1565b602002602001015184600181518110612fe857612fe8614af1565b6020026020010151846001600160801b03166130049190614964565b61300e9190614950565b905080821061301d578061301f565b815b9d9c50505050505050505050505050565b61303b848484612aab565b61304784848484613623565b611b2f5760405162461bcd60e51b81526004016106bd906146ef565b6060816130875750506040805180820190915260018152600360fc1b602082015290565b8160005b81156130b1578061309b81614a40565b91506130aa9050600a83614950565b915061308b565b60008167ffffffffffffffff8111156130cc576130cc614b07565b6040519080825280601f01601f1916602001820160405280156130f6576020820181803683370190505b5090505b8415611e695761310b6001836149ab565b9150613118600a86614a5b565b613123906030614938565b60f81b81838151811061313857613138614af1565b60200101906001600160f81b031916908160001a90535061315a600a86614950565b94506130fa565b60006105b0825490565b600082815260208190526040902060010154613187813361343d565b6107f383836134a1565b61319b82826115d2565b611cb3576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556131d13390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600081815260018301602052604081205461325c575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556105b0565b5060006105b0565b60006001600160e01b03198216635a05180f60e01b14806105b057506105b082613730565b60006132de826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166137659092919063ffffffff16565b8051909150156107f357808060200190518101906132fc91906140b9565b6107f35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016106bd565b600d8054600091600190836133708385614938565b909155506115cb90503382613774565b6000826001600160a01b0316846001600160a01b031611156133a0579192915b6001600160a01b0384166133e96fffffffffffffffffffffffffffffffff60601b606085901b166133d18787614983565b6001600160a01b0316866001600160a01b031661378e565b611e699190614950565b6000826001600160a01b0316846001600160a01b03161115613413579192915b611e696001600160801b03831661342a8686614983565b6001600160a01b0316600160601b61378e565b61344782826115d2565b611cb35761345f816001600160a01b03166014613841565b61346a836020613841565b60405160200161347b9291906145c3565b60408051601f198184030181529082905262461bcd60e51b82526106bd916004016146bf565b6134ab82826115d2565b15611cb3576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600081815260018301602052604081205480156135ef57600061352a6001836149ab565b855490915060009061353e906001906149ab565b90508181146135a357600086600001828154811061355e5761355e614af1565b906000526020600020015490508087600001848154811061358157613581614af1565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806135b4576135b4614adb565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506105b0565b60009150506105b0565b600082600001828154811061361057613610614af1565b9060005260206000200154905092915050565b60006001600160a01b0384163b1561372557604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290613667903390899088908890600401614638565b602060405180830381600087803b15801561368157600080fd5b505af19250505080156136b1575060408051601f3d908101601f191682019092526136ae91810190614153565b60015b61370b573d8080156136df576040519150601f19603f3d011682016040523d82523d6000602084013e6136e4565b606091505b5080516137035760405162461bcd60e51b81526004016106bd906146ef565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611e69565b506001949350505050565b60006001600160e01b03198216637965db0b60e01b14806105b057506301ffc9a760e01b6001600160e01b03198316146105b0565b6060611e6984846000856139dd565b611cb3828260405180602001604052806000815250613b05565b6000808060001985870985870292508281108382030391505080600014156137c857600084116137bd57600080fd5b5082900490506115cb565b8084116137d457600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60606000613850836002614964565b61385b906002614938565b67ffffffffffffffff81111561387357613873614b07565b6040519080825280601f01601f19166020018201604052801561389d576020820181803683370190505b509050600360fc1b816000815181106138b8576138b8614af1565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106138e7576138e7614af1565b60200101906001600160f81b031916908160001a905350600061390b846002614964565b613916906001614938565b90505b600181111561398e576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061394a5761394a614af1565b1a60f81b82828151811061396057613960614af1565b60200101906001600160f81b031916908160001a90535060049490941c93613987816149ee565b9050613919565b5083156115cb5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016106bd565b606082471015613a3e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016106bd565b843b613a8c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106bd565b600080866001600160a01b03168587604051613aa89190614578565b60006040518083038185875af1925050503d8060008114613ae5576040519150601f19603f3d011682016040523d82523d6000602084013e613aea565b606091505b5091509150613afa828286613b38565b979650505050505050565b613b0f8383613b71565b613b1c6000848484613623565b6107f35760405162461bcd60e51b81526004016106bd906146ef565b60608315613b475750816115cb565b825115613b575782518084602001fd5b8160405162461bcd60e51b81526004016106bd91906146bf565b6001600160a01b038216613bc75760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106bd565b6000818152600460205260409020546001600160a01b031615613c2c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106bd565b6001600160a01b0382166000908152600560205260408120805460019290613c55908490614938565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054828255906000526020600020908101928215613d08579160200282015b82811115613d0857825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613cd3565b50613d14929150613d18565b5090565b5b80821115613d145760008155600101613d19565b8051613d3881614b1d565b919050565b60008083601f840112613d4f57600080fd5b50813567ffffffffffffffff811115613d6757600080fd5b6020830191508360208260051b8501011115613d8257600080fd5b9250929050565b600082601f830112613d9a57600080fd5b813567ffffffffffffffff811115613db457613db4614b07565b613dc7601f8201601f1916602001614907565b818152846020838601011115613ddc57600080fd5b816020850160208301376000918101602001919091529392505050565b8051600281900b8114613d3857600080fd5b80516001600160801b0381168114613d3857600080fd5b805161ffff81168114613d3857600080fd5b805162ffffff81168114613d3857600080fd5b600060208284031215613e5957600080fd5b81356115cb81614b1d565b600060208284031215613e7657600080fd5b81516115cb81614b1d565b60008060408385031215613e9457600080fd5b8235613e9f81614b1d565b91506020830135613eaf81614b1d565b809150509250929050565b600080600060608486031215613ecf57600080fd5b8335613eda81614b1d565b92506020840135613eea81614b1d565b929592945050506040919091013590565b60008060008060808587031215613f1157600080fd5b8435613f1c81614b1d565b93506020850135613f2c81614b1d565b925060408501359150606085013567ffffffffffffffff811115613f4f57600080fd5b613f5b87828801613d89565b91505092959194509250565b60008060408385031215613f7a57600080fd5b8235613f8581614b1d565b91506020830135613eaf81614b32565b60008060408385031215613fa857600080fd5b8235613fb381614b1d565b946020939093013593505050565b60008060408385031215613fd457600080fd5b823567ffffffffffffffff80821115613fec57600080fd5b818501915085601f83011261400057600080fd5b813560208282111561401457614014614b07565b8160051b614023828201614907565b8381528281019086840183880185018c101561403e57600080fd5b600097505b8588101561406d578035935061405884614b1d565b83835260019790970196918401918401614043565b50975050508601359250508082111561408557600080fd5b5061409285828601613d89565b9150509250929050565b6000602082840312156140ae57600080fd5b81356115cb81614b32565b6000602082840312156140cb57600080fd5b81516115cb81614b32565b6000602082840312156140e857600080fd5b5035919050565b6000806040838503121561410257600080fd5b823591506020830135613eaf81614b1d565b6000806040838503121561412757600080fd5b50508035926020909101359150565b60006020828403121561414857600080fd5b81356115cb81614b40565b60006020828403121561416557600080fd5b81516115cb81614b40565b60008060006060848603121561418557600080fd5b61418e84613e0b565b925060208401519150604084015190509250925092565b600080600080600080600060e0888a0312156141c057600080fd5b87516141cb81614b1d565b96506141d960208901613df9565b95506141e760408901613e22565b94506141f560608901613e22565b935061420360808901613e22565b925060a088015160ff8116811461421957600080fd5b60c089015190925061422a81614b32565b8091505092959891949750929550565b60006020828403121561424c57600080fd5b5051919050565b6000806000806000806080878903121561426c57600080fd5b86359550602087013561427e81614b1d565b9450604087013567ffffffffffffffff8082111561429b57600080fd5b6142a78a838b01613d3d565b909650945060608901359150808211156142c057600080fd5b506142cd89828a01613d3d565b979a9699509497509295939492505050565b6000806000806000606086880312156142f757600080fd5b85359450602086013567ffffffffffffffff8082111561431657600080fd5b61432289838a01613d3d565b9096509450604088013591508082111561433b57600080fd5b5061434888828901613d3d565b969995985093965092949392505050565b6000806000806080858703121561436f57600080fd5b8451935061437f60208601613e0b565b6040860151606090960151949790965092505050565b600080604083850312156143a857600080fd5b505080516020909101519092909150565b6000806000806000806000806000806000806101808d8f0312156143dc57600080fd5b8c516bffffffffffffffffffffffff811681146143f857600080fd5b9b5061440660208e01613d2d565b9a5061441460408e01613d2d565b995061442260608e01613d2d565b985061443060808e01613e34565b975061443e60a08e01613df9565b965061444c60c08e01613df9565b955061445a60e08e01613e0b565b94506101008d015193506101208d015192506144796101408e01613e0b565b91506144886101608e01613e0b565b90509295989b509295989b509295989b565b8183526000602080850194508260005b858110156144d85781356144bd81614b1d565b6001600160a01b0316875295820195908201906001016144aa565b509495945050505050565b600081518084526020808501945080840160005b838110156144d85781516001600160a01b0316875295820195908201906001016144f7565b600081518084526020808501945080840160005b838110156144d857815187529582019590820190600101614530565b600081518084526145648160208601602086016149c2565b601f01601f19169290920160200192915050565b6000825161458a8184602087016149c2565b9190910192915050565b600083516145a68184602088016149c2565b8351908301906145ba8183602088016149c2565b01949350505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516145fb8160178501602088016149c2565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161462c8160288401602088016149c2565b01602801949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611af39083018461454c565b6020815260006115cb60208301846144e3565b60408152600061469160408301856144e3565b82810360208401526146a3818561451c565b95945050505050565b6020815260006115cb602083018461451c565b6020815260006115cb602083018461454c565b6020808252600390820152621411d160ea1b604082015260600190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526003908201526253415560e81b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252600590820152640554e4654360dc1b604082015260600190565b81516001600160a01b03168152610160810160208301516147fa60208401826001600160a01b03169052565b506040830151614811604084018262ffffff169052565b506060830151614826606084018260020b9052565b50608083015161483b608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151614881828501826001600160a01b03169052565b505061014092830151919092015290565b8581526001600160a01b03851660208201526080604082018190526000906148bd908301858761449a565b82810360608401526148cf818561451c565b98975050505050505050565b8481526060602082015260006148f560608301858761449a565b8281036040840152613afa818561451c565b604051601f8201601f1916810167ffffffffffffffff8111828210171561493057614930614b07565b604052919050565b6000821982111561494b5761494b614aaf565b500190565b60008261495f5761495f614ac5565b500490565b600081600019048311821515161561497e5761497e614aaf565b500290565b60006001600160a01b03838116908316818110156149a3576149a3614aaf565b039392505050565b6000828210156149bd576149bd614aaf565b500390565b60005b838110156149dd5781810151838201526020016149c5565b83811115611b2f5750506000910152565b6000816149fd576149fd614aaf565b506000190190565b600181811c90821680614a1957607f821691505b60208210811415614a3a57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415614a5457614a54614aaf565b5060010190565b600082614a6a57614a6a614ac5565b500690565b60008160020b627fffff19811415614a8957614a89614aaf565b60000392915050565b6000600160ff1b821415614aa857614aa8614aaf565b5060000390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146122f857600080fd5b80151581146122f857600080fd5b6001600160e01b0319811681146122f857600080fdfea26469706673582212204815c6a7a7727c258c220656d42865999242c807e4e165ba17977559867c69c164736f6c63430008070033abea6fd3db56a6e6d0242111b43ebb13d1c42709651c032c7894962023a1f90ab2ca199e5d628271269f73708112899272988324e125fafee9627694e71b1d25000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000154d656c6c6f7720556e6956332043656c6c73205631000000000000000000000000000000000000000000000000000000000000000000000000000000000000054d55435631000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102275760003560e01c80639010d07c11610130578063c87b56dd116100b8578063ebcf2d771161007c578063ebcf2d771461050f578063ec15eb161461052f578063ee48184514610538578063ee7e2dd31461054a578063fe7f20341461058357600080fd5b8063c87b56dd14610487578063ca15c8731461049a578063d547741f146104ad578063de7f9e4e146104c0578063e985e9c5146104d357600080fd5b8063a217fddf116100ff578063a217fddf1461043d578063a22cb46514610445578063b539978214610458578063b7874baa14610461578063b88d4fde1461047457600080fd5b80639010d07c1461040257806391d148541461041557806395d89b4114610428578063a1256f9f1461043057600080fd5b8063248a9ca3116101b357806342842e0e1161018257806342842e0e1461039a57806344fbb334146103ad5780636352211e146103b557806370a08231146103c8578063791b98bc146103db57600080fd5b8063248a9ca31461033e5780632f2ff15d1461036157806336568abe14610374578063423b01ec1461038757600080fd5b80630d7a41b7116101fa5780630d7a41b7146102a957806313a24a30146102c957806318e44a49146102ea5780631bb7ad6b1461030b57806323b872dd1461032b57600080fd5b806301ffc9a71461022c57806306fdde0314610254578063081812fc14610269578063095ea7b314610294575b600080fd5b61023f61023a366004614136565b61058b565b60405190151581526020015b60405180910390f35b61025c6105b6565b60405161024b91906146bf565b61027c6102773660046140d6565b610648565b6040516001600160a01b03909116815260200161024b565b6102a76102a2366004613f95565b6106e2565b005b6102bc6102b73660046142df565b6107f8565b60405161024b91906146ac565b6102dc6102d7366004613fc1565b610e12565b60405190815260200161024b565b6102fd6102f83660046140d6565b610f93565b60405161024b92919061467e565b61031e6103193660046140d6565b61134a565b60405161024b919061466b565b6102a7610339366004613eba565b6113b6565b6102dc61034c3660046140d6565b60009081526020819052604090206001015490565b6102a761036f3660046140ef565b6113e7565b6102a76103823660046140ef565b611409565b6102a761039536600461409c565b61142b565b6102a76103a8366004613eba565b611469565b6102a7611484565b61027c6103c33660046140d6565b6114b5565b6102dc6103d6366004613e47565b61152c565b61027c7f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8881565b61027c610410366004614114565b6115b3565b61023f6104233660046140ef565b6115d2565b61025c6115fb565b60085461023f9060ff1681565b6102dc600081565b6102a7610453366004613f67565b61160a565b6102dc600a5481565b6102bc61046f366004614253565b6116cf565b6102a7610482366004613efb565b611afd565b61025c6104953660046140d6565b611b35565b6102dc6104a83660046140d6565b611c1c565b6102a76104bb3660046140ef565b611c33565b6102a76104ce3660046140d6565b611c3d565b61023f6104e1366004613e81565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b6102dc61051d3660046140d6565b600e6020526000908152604090205481565b6102dc60095481565b60085461023f90610100900460ff1681565b61023f6105583660046140ef565b6000918252600c602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6102a7611c66565b60006001600160e01b03198216631ccd795160e31b14806105b057506105b082611ccc565b92915050565b6060600280546105c590614a05565b80601f01602080910402602001604051908101604052809291908181526020018280546105f190614a05565b801561063e5780601f106106135761010080835404028352916020019161063e565b820191906000526020600020905b81548152906001019060200180831161062157829003601f168201915b5050505050905090565b6000818152600460205260408120546001600160a01b03166106c65760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600660205260409020546001600160a01b031690565b60006106ed826114b5565b9050806001600160a01b0316836001600160a01b0316141561075b5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106bd565b336001600160a01b0382161480610777575061077781336104e1565b6107e95760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106bd565b6107f38383611d0c565b505050565b60606108043387611d7a565b6108355760405162461bcd60e51b8152602060048201526002602482015261494f60f01b60448201526064016106bd565b610871858580806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250611e7192505050565b61088d5760405162461bcd60e51b81526004016106bd90614741565b8382146108c05760405162461bcd60e51b81526020600482015260016024820152601360fa1b60448201526064016106bd565b6000868152600e6020526040902054806108ec5760405162461bcd60e51b81526004016106bd906147af565b60405163133f757160e31b81526004810182905260009081906001600160a01b037f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8816906399fbab88906024016101806040518083038186803b15801561095257600080fd5b505afa158015610966573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098a91906143b9565b50505050505050509350935050506000600267ffffffffffffffff8111156109b4576109b4614b07565b6040519080825280602002602001820160405280156109dd578160200160208202803683370190505b50905082816000815181106109f4576109f4614af1565b60200260200101906001600160a01b031690816001600160a01b0316815250508181600181518110610a2857610a28614af1565b60200260200101906001600160a01b031690816001600160a01b0316815250506000610ab8828b8b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516020808f0282810182019093528e82529093508e92508d918291850190849080828437600092019190915250611f1692505050565b905060005b8151811015610b4c57610b183330848481518110610add57610add614af1565b6020026020010151868581518110610af757610af7614af1565b60200260200101516001600160a01b0316612138909392919063ffffffff16565b610b3a838281518110610b2d57610b2d614af1565b60200260200101516121a3565b80610b4481614a40565b915050610abd565b506000807f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663219f5d176040518060c001604052808a815260200186600081518110610ba357610ba3614af1565b6020026020010151815260200186600181518110610bc357610bc3614af1565b60200260200101518152602001600081526020016000815260200142610258610bec9190614938565b9052604080516001600160e01b031960e085901b1681528251600482015260208301516024820152908201516044820152606082015160648201526080820151608482015260a09091015160a482015260c401606060405180830381600087803b158015610c5957600080fd5b505af1158015610c6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c919190614170565b6040805160028082526060820183529396509194509092506020830190803683370190505097508188600081518110610ccc57610ccc614af1565b6020026020010181815250508088600181518110610cec57610cec614af1565b60200260200101818152505060005b8451811015610dc457838181518110610d1657610d16614af1565b6020026020010151898281518110610d3057610d30614af1565b60200260200101511015610db257610db2338a8381518110610d5457610d54614af1565b6020026020010151868481518110610d6e57610d6e614af1565b6020026020010151610d8091906149ab565b878481518110610d9257610d92614af1565b60200260200101516001600160a01b03166122fb9092919063ffffffff16565b80610dbc81614a40565b915050610cfb565b507fe33829dd3495a41ba02f88de5eadec2635e25192c73dee8c65625206aa61e09a8d8d8d8b604051610dfa94939291906148db565b60405180910390a15050505050505095945050505050565b60085460009060ff1680610e295750610e2961232b565b610e455760405162461bcd60e51b81526004016106bd906146d2565b60095483511115610e7d5760405162461bcd60e51b8152602060048201526002602482015261135560f21b60448201526064016106bd565b610e8683611e71565b610ea25760405162461bcd60e51b81526004016106bd90614741565b6000610eae848461238c565b6000818152600b602090815260409091208651929350610ed2929091870190613cb3565b5060005b8451811015610f49576000828152600c60205260408120865160019290889085908110610f0557610f05614af1565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff191691151591909117905580610f4181614a40565b915050610ed6565b5080336001600160a01b03167fe423da5b0aa0eb7a8c8409551a7f9487952c6003da26568ea41ee22cf3133d4a85604051610f8491906146bf565b60405180910390a39392505050565b6000818152600e6020526040902054606090819080610fc45760405162461bcd60e51b81526004016106bd906147af565b6000806000806000807f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03166399fbab88886040518263ffffffff1660e01b815260040161101b91815260200190565b6101806040518083038186803b15801561103457600080fd5b505afa158015611048573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061106c91906143b9565b50505050975097509750975097509750505060007f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156110d957600080fd5b505afa1580156110ed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111119190613e64565b604051630b4c774160e11b81526001600160a01b038981166004830152888116602483015262ffffff881660448301529190911690631698ee829060640160206040518083038186803b15801561116757600080fd5b505afa15801561117b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119f9190613e64565b90506000816001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156111dc57600080fd5b505afa1580156111f0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061121491906141a5565b50505050505090506000611227866125fa565b90506000611234866125fa565b90506000806112458585858a612a0f565b604080516002808252606082019092529294509092508160200160208202803683370190505060408051600280825260608201909252919f50816020016020820280368337019050509e508b8f6000815181106112a4576112a4614af1565b60200260200101906001600160a01b031690816001600160a01b0316815250508a8f6001815181106112d8576112d8614af1565b60200260200101906001600160a01b031690816001600160a01b031681525050818e60008151811061130c5761130c614af1565b602002602001018181525050808e60018151811061132c5761132c614af1565b60200260200101818152505050505050505050505050505050915091565b6000818152600b60209081526040918290208054835181840281018401909452808452606093928301828280156113aa57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161138c575b50505050509050919050565b6113c03382611d7a565b6113dc5760405162461bcd60e51b81526004016106bd9061475e565b6107f3838383612aab565b6113f18282612c4b565b60008281526001602052604090206107f39082611cb7565b6114138282612c71565b60008281526001602052604090206107f39082612ceb565b61143361232b565b61144f5760405162461bcd60e51b81526004016106bd906146d2565b600880549115156101000261ff0019909216919091179055565b6107f383838360405180602001604052806000815250611afd565b61148c61232b565b6114a85760405162461bcd60e51b81526004016106bd906146d2565b600a805460095560009055565b6000818152600460205260408120546001600160a01b0316806105b05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106bd565b60006001600160a01b0382166115975760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106bd565b506001600160a01b031660009081526005602052604090205490565b60008281526001602052604081206115cb9083612d00565b9392505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6060600380546105c590614a05565b6001600160a01b0382163314156116635760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106bd565b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60606116db3388611d7a565b61170c5760405162461bcd60e51b8152602060048201526002602482015261494f60f01b60448201526064016106bd565b611748858580806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250611e7192505050565b6117645760405162461bcd60e51b81526004016106bd90614741565b8382146117975760405162461bcd60e51b81526020600482015260016024820152601360fa1b60448201526064016106bd565b6000878152600e6020526040902054806117c35760405162461bcd60e51b81526004016106bd906147af565b60006117d3898389898989612d0c565b90508061184357604080516002808252606082018352909160208301908036833701905050925060008360008151811061180f5761180f614af1565b60200260200101818152505060008360018151811061183057611830614af1565b6020026020010181815250505050611af3565b6000807f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b0316630c49ccbe6040518060a00160405280878152602001866001600160801b031681526020016000815260200160008152602001426102586118b19190614938565b9052604080516001600160e01b031960e085901b1681528251600482015260208301516001600160801b0316602482015290820151604482015260608201516064820152608090910151608482015260a4016040805180830381600087803b15801561191c57600080fd5b505af1158015611930573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119549190614395565b604080516080810182528781526001600160a01b038e8116602083019081526001600160801b0380871684860190815281871660608601908152955163fc6f786560e01b8152945160048601529151831660248501529051811660448401529251909216606482015292945090925060009182917f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88169063fc6f7865906084016040805180830381600087803b158015611a0d57600080fd5b505af1158015611a21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a459190614395565b604080516002808252606082019092529294509092508160200160208202803683370190505096508187600081518110611a8157611a81614af1565b6020026020010181815250508087600181518110611aa157611aa1614af1565b6020026020010181815250507f8d04027fcc6b389782391c87ffe1fbc8b300720c147b657fc2cd85161fcf2fe98d8d8d8d8b604051611ae4959493929190614892565b60405180910390a15050505050505b9695505050505050565b611b073383611d7a565b611b235760405162461bcd60e51b81526004016106bd9061475e565b611b2f84848484613030565b50505050565b6000818152600460205260409020546060906001600160a01b0316611bb45760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016106bd565b6000611bcb60408051602081019091526000815290565b90506000815111611beb57604051806020016040528060008152506115cb565b80611bf584613063565b604051602001611c06929190614594565b6040516020818303038152906040529392505050565b60008181526001602052604081206105b090613161565b611413828261316b565b611c4561232b565b611c615760405162461bcd60e51b81526004016106bd906146d2565b600a55565b611c6e61232b565b611c8a5760405162461bcd60e51b81526004016106bd906146d2565b6008805461ff001960ff61010083041615151661ffff19909116179055565b611cb38282613191565b5050565b60006115cb836001600160a01b038416613215565b60006001600160e01b031982166380ac58cd60e01b1480611cfd57506001600160e01b03198216635b5e139f60e01b145b806105b057506105b082613264565b600081815260066020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611d41826114b5565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600460205260408120546001600160a01b0316611df35760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106bd565b6000611dfe836114b5565b9050806001600160a01b0316846001600160a01b03161480611e395750836001600160a01b0316611e2e84610648565b6001600160a01b0316145b80611e6957506001600160a01b0380821660009081526007602090815260408083209388168352929052205460ff165b949350505050565b6000600282511015611e8557506001919050565b60005b60018351611e9691906149ab565b811015611f0d5782611ea9826001614938565b81518110611eb957611eb9614af1565b60200260200101516001600160a01b0316838281518110611edc57611edc614af1565b60200260200101516001600160a01b031610611efb5750600092915050565b80611f0581614a40565b915050611e88565b50600192915050565b60606000845167ffffffffffffffff811115611f3457611f34614b07565b604051908082528060200260200182016040528015611f5d578160200160208202803683370190505b5090506000805b865182108015611f745750855181105b156120f357858181518110611f8b57611f8b614af1565b60200260200101516001600160a01b0316878381518110611fae57611fae614af1565b60200260200101516001600160a01b03161015611ff6576000838381518110611fd957611fd9614af1565b602090810291909101015281611fee81614a40565b925050611f64565b85818151811061200857612008614af1565b60200260200101516001600160a01b031687838151811061202b5761202b614af1565b60200260200101516001600160a01b031611156120a45784818151811061205457612054614af1565b602002602001015160001415612076578061206e81614a40565b915050611f64565b60405162461bcd60e51b815260206004820152600360248201526254505360e81b60448201526064016106bd565b8481815181106120b6576120b6614af1565b60200260200101518383815181106120d0576120d0614af1565b6020908102919091010152816120e581614a40565b925050808061206e90614a40565b865182101561212d57600083838151811061211057612110614af1565b60209081029190910101528161212581614a40565b9250506120f3565b509095945050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052611b2f9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613289565b6121b06002600019614950565b604051636eb1769f60e11b81526001600160a01b037f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe888116600483015230602483015283169063dd62ed3e9060440160206040518083038186803b15801561221757600080fd5b505afa15801561222b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061224f919061423a565b10156122f85760405163095ea7b360e01b81526001600160a01b037f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8881166004830152600019602483015282169063095ea7b390604401602060405180830381600087803b1580156122c057600080fd5b505af11580156122d4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cb391906140b9565b50565b6040516001600160a01b0383166024820152604481018290526107f390849063a9059cbb60e01b9060640161216c565b60006123577fabea6fd3db56a6e6d0242111b43ebb13d1c42709651c032c7894962023a1f90a336115d2565b8061238757506123877fb2ca199e5d628271269f73708112899272988324e125fafee9627694e71b1d25336115d2565b905090565b60008151610100146123c55760405162461bcd60e51b8152602060048201526002602482015261049560f41b60448201526064016106bd565b82516002146123fb5760405162461bcd60e51b8152602060048201526002602482015261151360f21b60448201526064016106bd565b602082015160408301516060840151608085015160a086015160c087015160e088015161010089015161243d3330878e600081518110610af757610af7614af1565b6124563330868e600181518110610af757610af7614af1565b61246c8b600081518110610b2d57610b2d614af1565b6124828b600181518110610b2d57610b2d614af1565b60007f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663883164566040518061016001604052808f6000815181106124d2576124d2614af1565b60200260200101516001600160a01b031681526020018f6001815181106124fb576124fb614af1565b60200260200101516001600160a01b031681526020018c62ffffff1681526020018b60020b81526020018a60020b8152602001898152602001888152602001878152602001868152602001306001600160a01b03168152602001858152506040518263ffffffff1660e01b815260040161257591906147ce565b608060405180830381600087803b15801561258f57600080fd5b505af11580156125a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125c79190614359565b505050905060006125d88d8d61335b565b6000818152600e6020526040902092909255509b9a5050505050505050505050565b60008060008360020b12612611578260020b61261e565b8260020b61261e90614a92565b905061262d620d89e719614a6f565b60020b8111156126635760405162461bcd60e51b81526020600482015260016024820152601560fa1b60448201526064016106bd565b60006001821661267757600160801b612689565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156126c85760806126c3826ffff97272373d413259a46990580e213a614964565b901c90505b60048216156126f25760806126ed826ffff2e50f5f656932ef12357cf3c7fdcc614964565b901c90505b600882161561271c576080612717826fffe5caca7e10e4e61c3624eaa0941cd0614964565b901c90505b6010821615612746576080612741826fffcb9843d60f6159c9db58835c926644614964565b901c90505b602082161561277057608061276b826fff973b41fa98c081472e6896dfb254c0614964565b901c90505b604082161561279a576080612795826fff2ea16466c96a3843ec78b326b52861614964565b901c90505b60808216156127c45760806127bf826ffe5dee046a99a2a811c461f1969c3053614964565b901c90505b6101008216156127ef5760806127ea826ffcbe86c7900a88aedcffc83b479aa3a4614964565b901c90505b61020082161561281a576080612815826ff987a7253ac413176f2b074cf7815e54614964565b901c90505b610400821615612845576080612840826ff3392b0822b70005940c7a398e4b70f3614964565b901c90505b61080082161561287057608061286b826fe7159475a2c29b7443b29c7fa6e889d9614964565b901c90505b61100082161561289b576080612896826fd097f3bdfd2022b8845ad8f792aa5825614964565b901c90505b6120008216156128c65760806128c1826fa9f746462d870fdf8a65dc1f90e061e5614964565b901c90505b6140008216156128f15760806128ec826f70d869a156d2a1b890bb3df62baf32f7614964565b901c90505b61800082161561291c576080612917826f31be135f97d08fd981231505542fcfa6614964565b901c90505b62010000821615612948576080612943826f09aa508b5b7a84e1c677de54f3e99bc9614964565b901c90505b6202000082161561297357608061296e826e5d6af8dedb81196699c329225ee604614964565b901c90505b6204000082161561299d576080612998826d2216e584f5fa1ea926041bedfe98614964565b901c90505b620800008216156129c55760806129c0826b048a170391f7dc42444e8fa2614964565b901c90505b60008460020b13156129e0576129dd81600019614950565b90505b6129ef64010000000082614a5b565b156129fb5760016129fe565b60005b611e699060ff16602083901c614938565b600080836001600160a01b0316856001600160a01b03161115612a30579293925b846001600160a01b0316866001600160a01b031611612a5b57612a54858585613380565b9150612aa2565b836001600160a01b0316866001600160a01b03161015612a9457612a80868585613380565b9150612a8d8587856133f3565b9050612aa2565b612a9f8585856133f3565b90505b94509492505050565b826001600160a01b0316612abe826114b5565b6001600160a01b031614612b265760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016106bd565b6001600160a01b038216612b885760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106bd565b612b93600082611d0c565b6001600160a01b0383166000908152600560205260408120805460019290612bbc9084906149ab565b90915550506001600160a01b0382166000908152600560205260408120805460019290612bea908490614938565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600082815260208190526040902060010154612c67813361343d565b6107f38383613191565b6001600160a01b0381163314612ce15760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016106bd565b611cb382826134a1565b60006115cb836001600160a01b038416613506565b60006115cb83836135f9565b6000806000612d1a89610f93565b915091506000612d8e8389898080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516020808d0282810182019093528c82529093508c92508b918291850190849080828437600092019190915250611f1692505050565b60405163133f757160e31b8152600481018b90529091506000906001600160a01b037f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8816906399fbab88906024016101806040518083038186803b158015612df557600080fd5b505afa158015612e09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e2d91906143b9565b5050505097505050505050505082600081518110612e4d57612e4d614af1565b602002602001015160001415612eec5781600081518110612e7057612e70614af1565b602002602001015160001415612edf5782600181518110612e9357612e93614af1565b602002602001015182600181518110612eae57612eae614af1565b6020026020010151826001600160801b0316612eca9190614964565b612ed49190614950565b945050505050611af3565b6000945050505050611af3565b82600181518110612eff57612eff614af1565b602002602001015160001415612f605781600181518110612f2257612f22614af1565b602002602001015160001415612edf5782600081518110612f4557612f45614af1565b602002602001015182600081518110612eae57612eae614af1565b600083600081518110612f7557612f75614af1565b602002602001015183600081518110612f9057612f90614af1565b6020026020010151836001600160801b0316612fac9190614964565b612fb69190614950565b9050600084600181518110612fcd57612fcd614af1565b602002602001015184600181518110612fe857612fe8614af1565b6020026020010151846001600160801b03166130049190614964565b61300e9190614950565b905080821061301d578061301f565b815b9d9c50505050505050505050505050565b61303b848484612aab565b61304784848484613623565b611b2f5760405162461bcd60e51b81526004016106bd906146ef565b6060816130875750506040805180820190915260018152600360fc1b602082015290565b8160005b81156130b1578061309b81614a40565b91506130aa9050600a83614950565b915061308b565b60008167ffffffffffffffff8111156130cc576130cc614b07565b6040519080825280601f01601f1916602001820160405280156130f6576020820181803683370190505b5090505b8415611e695761310b6001836149ab565b9150613118600a86614a5b565b613123906030614938565b60f81b81838151811061313857613138614af1565b60200101906001600160f81b031916908160001a90535061315a600a86614950565b94506130fa565b60006105b0825490565b600082815260208190526040902060010154613187813361343d565b6107f383836134a1565b61319b82826115d2565b611cb3576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556131d13390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600081815260018301602052604081205461325c575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556105b0565b5060006105b0565b60006001600160e01b03198216635a05180f60e01b14806105b057506105b082613730565b60006132de826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166137659092919063ffffffff16565b8051909150156107f357808060200190518101906132fc91906140b9565b6107f35760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016106bd565b600d8054600091600190836133708385614938565b909155506115cb90503382613774565b6000826001600160a01b0316846001600160a01b031611156133a0579192915b6001600160a01b0384166133e96fffffffffffffffffffffffffffffffff60601b606085901b166133d18787614983565b6001600160a01b0316866001600160a01b031661378e565b611e699190614950565b6000826001600160a01b0316846001600160a01b03161115613413579192915b611e696001600160801b03831661342a8686614983565b6001600160a01b0316600160601b61378e565b61344782826115d2565b611cb35761345f816001600160a01b03166014613841565b61346a836020613841565b60405160200161347b9291906145c3565b60408051601f198184030181529082905262461bcd60e51b82526106bd916004016146bf565b6134ab82826115d2565b15611cb3576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600081815260018301602052604081205480156135ef57600061352a6001836149ab565b855490915060009061353e906001906149ab565b90508181146135a357600086600001828154811061355e5761355e614af1565b906000526020600020015490508087600001848154811061358157613581614af1565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806135b4576135b4614adb565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506105b0565b60009150506105b0565b600082600001828154811061361057613610614af1565b9060005260206000200154905092915050565b60006001600160a01b0384163b1561372557604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290613667903390899088908890600401614638565b602060405180830381600087803b15801561368157600080fd5b505af19250505080156136b1575060408051601f3d908101601f191682019092526136ae91810190614153565b60015b61370b573d8080156136df576040519150601f19603f3d011682016040523d82523d6000602084013e6136e4565b606091505b5080516137035760405162461bcd60e51b81526004016106bd906146ef565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611e69565b506001949350505050565b60006001600160e01b03198216637965db0b60e01b14806105b057506301ffc9a760e01b6001600160e01b03198316146105b0565b6060611e6984846000856139dd565b611cb3828260405180602001604052806000815250613b05565b6000808060001985870985870292508281108382030391505080600014156137c857600084116137bd57600080fd5b5082900490506115cb565b8084116137d457600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60606000613850836002614964565b61385b906002614938565b67ffffffffffffffff81111561387357613873614b07565b6040519080825280601f01601f19166020018201604052801561389d576020820181803683370190505b509050600360fc1b816000815181106138b8576138b8614af1565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106138e7576138e7614af1565b60200101906001600160f81b031916908160001a905350600061390b846002614964565b613916906001614938565b90505b600181111561398e576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061394a5761394a614af1565b1a60f81b82828151811061396057613960614af1565b60200101906001600160f81b031916908160001a90535060049490941c93613987816149ee565b9050613919565b5083156115cb5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016106bd565b606082471015613a3e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016106bd565b843b613a8c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106bd565b600080866001600160a01b03168587604051613aa89190614578565b60006040518083038185875af1925050503d8060008114613ae5576040519150601f19603f3d011682016040523d82523d6000602084013e613aea565b606091505b5091509150613afa828286613b38565b979650505050505050565b613b0f8383613b71565b613b1c6000848484613623565b6107f35760405162461bcd60e51b81526004016106bd906146ef565b60608315613b475750816115cb565b825115613b575782518084602001fd5b8160405162461bcd60e51b81526004016106bd91906146bf565b6001600160a01b038216613bc75760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106bd565b6000818152600460205260409020546001600160a01b031615613c2c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106bd565b6001600160a01b0382166000908152600560205260408120805460019290613c55908490614938565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054828255906000526020600020908101928215613d08579160200282015b82811115613d0857825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613cd3565b50613d14929150613d18565b5090565b5b80821115613d145760008155600101613d19565b8051613d3881614b1d565b919050565b60008083601f840112613d4f57600080fd5b50813567ffffffffffffffff811115613d6757600080fd5b6020830191508360208260051b8501011115613d8257600080fd5b9250929050565b600082601f830112613d9a57600080fd5b813567ffffffffffffffff811115613db457613db4614b07565b613dc7601f8201601f1916602001614907565b818152846020838601011115613ddc57600080fd5b816020850160208301376000918101602001919091529392505050565b8051600281900b8114613d3857600080fd5b80516001600160801b0381168114613d3857600080fd5b805161ffff81168114613d3857600080fd5b805162ffffff81168114613d3857600080fd5b600060208284031215613e5957600080fd5b81356115cb81614b1d565b600060208284031215613e7657600080fd5b81516115cb81614b1d565b60008060408385031215613e9457600080fd5b8235613e9f81614b1d565b91506020830135613eaf81614b1d565b809150509250929050565b600080600060608486031215613ecf57600080fd5b8335613eda81614b1d565b92506020840135613eea81614b1d565b929592945050506040919091013590565b60008060008060808587031215613f1157600080fd5b8435613f1c81614b1d565b93506020850135613f2c81614b1d565b925060408501359150606085013567ffffffffffffffff811115613f4f57600080fd5b613f5b87828801613d89565b91505092959194509250565b60008060408385031215613f7a57600080fd5b8235613f8581614b1d565b91506020830135613eaf81614b32565b60008060408385031215613fa857600080fd5b8235613fb381614b1d565b946020939093013593505050565b60008060408385031215613fd457600080fd5b823567ffffffffffffffff80821115613fec57600080fd5b818501915085601f83011261400057600080fd5b813560208282111561401457614014614b07565b8160051b614023828201614907565b8381528281019086840183880185018c101561403e57600080fd5b600097505b8588101561406d578035935061405884614b1d565b83835260019790970196918401918401614043565b50975050508601359250508082111561408557600080fd5b5061409285828601613d89565b9150509250929050565b6000602082840312156140ae57600080fd5b81356115cb81614b32565b6000602082840312156140cb57600080fd5b81516115cb81614b32565b6000602082840312156140e857600080fd5b5035919050565b6000806040838503121561410257600080fd5b823591506020830135613eaf81614b1d565b6000806040838503121561412757600080fd5b50508035926020909101359150565b60006020828403121561414857600080fd5b81356115cb81614b40565b60006020828403121561416557600080fd5b81516115cb81614b40565b60008060006060848603121561418557600080fd5b61418e84613e0b565b925060208401519150604084015190509250925092565b600080600080600080600060e0888a0312156141c057600080fd5b87516141cb81614b1d565b96506141d960208901613df9565b95506141e760408901613e22565b94506141f560608901613e22565b935061420360808901613e22565b925060a088015160ff8116811461421957600080fd5b60c089015190925061422a81614b32565b8091505092959891949750929550565b60006020828403121561424c57600080fd5b5051919050565b6000806000806000806080878903121561426c57600080fd5b86359550602087013561427e81614b1d565b9450604087013567ffffffffffffffff8082111561429b57600080fd5b6142a78a838b01613d3d565b909650945060608901359150808211156142c057600080fd5b506142cd89828a01613d3d565b979a9699509497509295939492505050565b6000806000806000606086880312156142f757600080fd5b85359450602086013567ffffffffffffffff8082111561431657600080fd5b61432289838a01613d3d565b9096509450604088013591508082111561433b57600080fd5b5061434888828901613d3d565b969995985093965092949392505050565b6000806000806080858703121561436f57600080fd5b8451935061437f60208601613e0b565b6040860151606090960151949790965092505050565b600080604083850312156143a857600080fd5b505080516020909101519092909150565b6000806000806000806000806000806000806101808d8f0312156143dc57600080fd5b8c516bffffffffffffffffffffffff811681146143f857600080fd5b9b5061440660208e01613d2d565b9a5061441460408e01613d2d565b995061442260608e01613d2d565b985061443060808e01613e34565b975061443e60a08e01613df9565b965061444c60c08e01613df9565b955061445a60e08e01613e0b565b94506101008d015193506101208d015192506144796101408e01613e0b565b91506144886101608e01613e0b565b90509295989b509295989b509295989b565b8183526000602080850194508260005b858110156144d85781356144bd81614b1d565b6001600160a01b0316875295820195908201906001016144aa565b509495945050505050565b600081518084526020808501945080840160005b838110156144d85781516001600160a01b0316875295820195908201906001016144f7565b600081518084526020808501945080840160005b838110156144d857815187529582019590820190600101614530565b600081518084526145648160208601602086016149c2565b601f01601f19169290920160200192915050565b6000825161458a8184602087016149c2565b9190910192915050565b600083516145a68184602088016149c2565b8351908301906145ba8183602088016149c2565b01949350505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516145fb8160178501602088016149c2565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161462c8160288401602088016149c2565b01602801949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611af39083018461454c565b6020815260006115cb60208301846144e3565b60408152600061469160408301856144e3565b82810360208401526146a3818561451c565b95945050505050565b6020815260006115cb602083018461451c565b6020815260006115cb602083018461454c565b6020808252600390820152621411d160ea1b604082015260600190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526003908201526253415560e81b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252600590820152640554e4654360dc1b604082015260600190565b81516001600160a01b03168152610160810160208301516147fa60208401826001600160a01b03169052565b506040830151614811604084018262ffffff169052565b506060830151614826606084018260020b9052565b50608083015161483b608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151614881828501826001600160a01b03169052565b505061014092830151919092015290565b8581526001600160a01b03851660208201526080604082018190526000906148bd908301858761449a565b82810360608401526148cf818561451c565b98975050505050505050565b8481526060602082015260006148f560608301858761449a565b8281036040840152613afa818561451c565b604051601f8201601f1916810167ffffffffffffffff8111828210171561493057614930614b07565b604052919050565b6000821982111561494b5761494b614aaf565b500190565b60008261495f5761495f614ac5565b500490565b600081600019048311821515161561497e5761497e614aaf565b500290565b60006001600160a01b03838116908316818110156149a3576149a3614aaf565b039392505050565b6000828210156149bd576149bd614aaf565b500390565b60005b838110156149dd5781810151838201526020016149c5565b83811115611b2f5750506000910152565b6000816149fd576149fd614aaf565b506000190190565b600181811c90821680614a1957607f821691505b60208210811415614a3a57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415614a5457614a54614aaf565b5060010190565b600082614a6a57614a6a614ac5565b500690565b60008160020b627fffff19811415614a8957614a89614aaf565b60000392915050565b6000600160ff1b821415614aa857614aa8614aaf565b5060000390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146122f857600080fd5b80151581146122f857600080fd5b6001600160e01b0319811681146122f857600080fdfea26469706673582212204815c6a7a7727c258c220656d42865999242c807e4e165ba17977559867c69c164736f6c63430008070033

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

000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000154d656c6c6f7720556e6956332043656c6c73205631000000000000000000000000000000000000000000000000000000000000000000000000000000000000054d55435631000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _positionManager (address): 0xC36442b4a4522E871399CD717aBDD847Ab11FE88
Arg [1] : name (string): Mellow UniV3 Cells V1
Arg [2] : symbol (string): MUCV1

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [2] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000015
Arg [4] : 4d656c6c6f7720556e6956332043656c6c732056310000000000000000000000
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [6] : 4d55435631000000000000000000000000000000000000000000000000000000


Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]

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