Contract 0x231278edd38b00b07fbd52120cef685b9baebcc1 11

 
Txn Hash Method
Block
From
To
Value
0x812c348e1b54fe0cbb3de0eae0cff7705fc1412d26366bb8edad5ddf75de12a1Collect135092382024-04-22 17:43:431 hr 38 mins ago0xc483df0531491e1ea57ce38541fb2b003fc4c135 IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0004522425822.0352
0x75f06c98849a5e3e3a89626a2ea8366c40fb2d2f76c9dfb3f4a41fd0529874b8Lock135091532024-04-22 17:40:531 hr 41 mins ago0xdbd9307607636d33bea398d66921df5bda698b56 IN  UNCX Lockers: UniSwap V3 LP0.03 ETH0.0011770770521.671837166
0xa0eecc30bbffdb02538129be117dbf064a6a0a900387c4a529398671d868fb0aLock135086742024-04-22 17:24:551 hr 57 mins ago0xd06f1194e5ce2fbf4bf42efa45853cb5cce85d4e IN  UNCX Lockers: UniSwap V3 LP0.03 ETH0.0002293751720.31708944
0x8b58b534e6027e012a0a24ca8caa816d4df51119e3a4b646473c4377880f4473Collect135073442024-04-22 16:40:352 hrs 42 mins agoBriun Armstrung: Deployer IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000317281760.1474
0x8982c0bf17869b97026d069a67d681b826ef079bbddf2ebb6a71f34aa0ad14a0Withdraw135065152024-04-22 16:12:573 hrs 9 mins ago0x259ff342bcc45769b038ca743e0a7a7c313cb36e IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000503707850.145405126
0xc7bda361ecead3e2d0073f0351e9b53a9eb7f90f16066a5e87d0ef02baa147ffCollect135058162024-04-22 15:49:393 hrs 32 mins ago0x411d2a3bad1f39daa0960608b804c548e329a9ad IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000357154040.142039172
0x1e0081356258551c7452866ebc08c28790b5bc2dcff9d75ffc3014e7b1a21d20Collect135057142024-04-22 15:46:153 hrs 36 mins ago0x2daefca9ce50fe96d1654ed4600a8803fd295aa5 IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000353770790.139623887
0xc3bfe3b091a417d38c776b2629e94bafd421852c10aa73ce4bbd1e2af4a44242Collect135031572024-04-22 14:21:015 hrs 1 min ago0x0ef50c01489b0fb517f2210a5190f90085cf3aca IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000264321810.113787401
0x67285e0fcf0d71f56b8ca322e958156355f1fc383553148118efe8c0c16559a6Collect135006712024-04-22 12:58:096 hrs 24 mins ago0x81783d4f41f0ba0aee6803c269c6de7dc1d41231 IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000176979820.076125963
0xc9fea77af79088b1d657ebb9c025a277128b7ba03e985b170e6bd9b412ec10b6Lock134994622024-04-22 12:17:517 hrs 4 mins ago0x7af23c1db9f2f68765a42f68f494b7fb8075be70 IN  UNCX Lockers: UniSwap V3 LP0.03 ETH0.0000563063870.086538366
0x755a21bff776929b90e0999a4be76850378f5f4a1f5f6bfe3023edc018b629deCollect134964082024-04-22 10:36:038 hrs 46 mins agoBoshi: Deployer IN  UNCX Lockers: UniSwap V3 LP0 ETH0.000019485470.078049588
0x4959172c6ddae5a87b54e6f81bde7e1ab35721db902350cd7292e916aa24cf9eLock134949902024-04-22 9:48:479 hrs 33 mins ago0xb4a206a96253d49450f3a6c6ca6277b2eb76fe21 IN  UNCX Lockers: UniSwap V3 LP0.03 ETH0.0000551495020.084770897
0xdb33937123892afd51bbfff22bb91c1992d322bf0c13c9410e15a9807d572d60Collect134887692024-04-22 6:21:2513 hrs 1 min ago0xee15c57586fd1e83f1152c31a453e32bdb0a7710 IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000090819190.035890992
0xf1b23e5ce121a4418905960ba3a5ea5789f2821f31907f982ecf22ab8197ea05Lock134844872024-04-22 3:58:4115 hrs 23 mins ago0xe31d43298ef5c88f7d080f904b7d1a5f0d0c5439 IN  UNCX Lockers: UniSwap V3 LP0.03 ETH0.0000367681660.0468
0x43a878691150bab3e36a7b1e4f313c426e6dceb2b598f4208da99d477cc85308Lock134839442024-04-22 3:40:3515 hrs 42 mins ago0xec79b89d9ef0df36d574f7bccabed93bde1c7f00 IN  UNCX Lockers: UniSwap V3 LP0.03 ETH0.0000296454010.038697507
0x9a512e3d05cabeab14597bef9faf6c3ecf486743caca6e3343a8295b49c7ada7Collect134783732024-04-22 0:34:5318 hrs 47 mins ago0xa745edbdb2e2d54aced0af9c0f725e6dc74980e1 IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000040799730.028197161
0xfcb34e6c61fa53b149aae9e1230728b6bd0e7836ef10665f7d8ec9db13b1520aCollect134783612024-04-22 0:34:2918 hrs 48 mins ago0xa745edbdb2e2d54aced0af9c0f725e6dc74980e1 IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000121268410.028217248
0x321ad452e6f2e2347c7139e0a3f9d7571b348746dea46208cf578fb87c57a619Collect134736982024-04-21 21:59:0321 hrs 23 mins ago0x2023abb83459e93399e4a75a58e0ab25f912f5a9 IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000037108980.014317388
0x362567b72b9aae1c08fa40a6e09a774569c69f39c246041d1e2a3c1746688e8eCollect134717122024-04-21 20:52:5122 hrs 29 mins agoFungi: Deployer IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000049929170.024260732
0x479517b2ce20fdb7f005ac97177f8dea1aa1c8cfcfac83b97a5f054d8b57eab2Transfer Lock Ow...134648422024-04-21 17:03:511 day 2 hrs ago0xf136292437c00b59b99cf4c906c85e05643957b0 IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000049003960.097944579
0x04d56a3ccab8cc91b4fde2be4d876bce88b4a6960055cc3ebca7ea06882f3e1dRelock134647652024-04-21 17:01:171 day 2 hrs ago0xf136292437c00b59b99cf4c906c85e05643957b0 IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000053097720.101215046
0x634d4af13f3a845369579760307e37a6077ad6b07615369f310f553c8c211185Collect134646882024-04-21 16:58:431 day 2 hrs ago0xf136292437c00b59b99cf4c906c85e05643957b0 IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000244523160.102483806
0xeed35c5f431e71c49e5bc39e5ee1d4ae005c4a5ee9e9b007899e1741b8ccd9eeCollect134631592024-04-21 16:07:451 day 3 hrs ago0xea1151941e66faab319019628f9f26e03430d49a IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0002911513620.205765142
0xe81e753e6b69f45a3a5449b90d616eac14d7f06e6ab17d42fadb59a944e269bdTransfer Lock Ow...134613342024-04-21 15:06:551 day 4 hrs ago0x738791dd927a1f7441979cdabf4472b0b4520916 IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000113942990.162774553
0x5c7b30d97c855511f15b166dc72651fef4dbc2769c46c2f896399af117f16de2Collect134612952024-04-21 15:05:371 day 4 hrs ago0x738791dd927a1f7441979cdabf4472b0b4520916 IN  UNCX Lockers: UniSwap V3 LP0 ETH0.0000413813620.162960499
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x75f06c98849a5e3e3a89626a2ea8366c40fb2d2f76c9dfb3f4a41fd0529874b8135091532024-04-22 17:40:531 hr 41 mins ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0xa0eecc30bbffdb02538129be117dbf064a6a0a900387c4a529398671d868fb0a135086742024-04-22 17:24:551 hr 57 mins ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0xc9fea77af79088b1d657ebb9c025a277128b7ba03e985b170e6bd9b412ec10b6134994622024-04-22 12:17:517 hrs 4 mins ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0x4959172c6ddae5a87b54e6f81bde7e1ab35721db902350cd7292e916aa24cf9e134949902024-04-22 9:48:479 hrs 33 mins ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0xf1b23e5ce121a4418905960ba3a5ea5789f2821f31907f982ecf22ab8197ea05134844872024-04-22 3:58:4115 hrs 23 mins ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0x43a878691150bab3e36a7b1e4f313c426e6dceb2b598f4208da99d477cc85308134839442024-04-22 3:40:3515 hrs 42 mins ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0x7ff36a699c079b30b51f393be448af9e05715fe189b8dc296f52fd3541f13292134593852024-04-21 14:01:571 day 5 hrs ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0x6bcf7bccbacfb2cd9a9771a9dc152b9ebc173360b2105b9bb3a54e44eea3e64e134397372024-04-21 3:07:011 day 16 hrs ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0x832beb133d729cbb06f0e106ca676e791caef2e91632f501b940f7d20dd07139134392512024-04-21 2:50:491 day 16 hrs ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0x968c1319f9f577a001db242c025f3e926fead92bd357110f6a4504c24b4fa47d134332972024-04-20 23:32:211 day 19 hrs ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0xffe6d782df9cd865c6483f635520ce1d37fd030252018d3a70c5d8c576dba7fa134278382024-04-20 20:30:231 day 22 hrs ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0x81f35e3275567bcd408ddd38bcab054a67042ab7d3f52236c49ab2f1e22f3020134266912024-04-20 19:52:091 day 23 hrs ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0x81f35e3275567bcd408ddd38bcab054a67042ab7d3f52236c49ab2f1e22f3020134266912024-04-20 19:52:091 day 23 hrs ago 0x47a8bcc4ee028e7bbc13c579850f85024b2de300 UNCX Lockers: UniSwap V3 LP0.03 ETH
0x901ae531a58192bbaf3f623ffc81ae9ca61efdeaafc9fb62e43e2396c1e462bb134229322024-04-20 17:46:512 days 1 hr ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0x325112806d146a8501d817da67fad3224f7829f87dcd13e8719b56f273415437134168972024-04-20 14:25:412 days 4 hrs ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0xb8936e8296293b26975d251093982a335f88e0fa9fabd70c26d876531c7366d0134161922024-04-20 14:02:112 days 5 hrs ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0x59363b7b038adae115a3d6d8389c3b9b52541a2766e6db02022b92fefad98ba0134092162024-04-20 10:09:392 days 9 hrs ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0x4b2a682b2b27dea91a7729a357c1794577ca68c6980c70b92c5a448cc2d6665e134059782024-04-20 8:21:432 days 11 hrs ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0xa77a7f82a4632b1e6f7741ca11933395d7e7d5b6dffabc4bd7348a24c55da407133906762024-04-19 23:51:392 days 19 hrs ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0x1b87dffb588d4ddbff2c34b212439190f6100575432014abfd63a3ae4c1fd06a133901762024-04-19 23:34:592 days 19 hrs ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0xa2950361645255c5af13529be2b934d1af49d173100673e7702e33f3a351ee77133794142024-04-19 17:36:153 days 1 hr ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0xa2950361645255c5af13529be2b934d1af49d173100673e7702e33f3a351ee77133794142024-04-19 17:36:153 days 1 hr ago 0x72cf2be80607610bdaf23f0833c0545bef83e881 UNCX Lockers: UniSwap V3 LP0.03 ETH
0xf8b7540ac3fb2a8271a23e5662b0ba948bbb68aa6963042628293008f430bdf9133738852024-04-19 14:31:573 days 4 hrs ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0xe5d73eb3ae6e66903dbb0b1d1dbf9e292a647e133e551b9a134893915fbf6c4d133688952024-04-19 11:45:373 days 7 hrs ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
0x60fb950b383b6a8a5ce6ce87b1ce018c671a984f5e128b3c48092ad83ed65a78133648492024-04-19 9:30:453 days 9 hrs ago UNCX Lockers: UniSwap V3 LP0x04bda42de3bc32abb00df46004204424d4cf82870.03 ETH
[ Download CSV Export 
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0xD6Cd8fb001cBDAE91f0AF7A58A1602C945967D67
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
UNCX_LiquidityLocker_UniV3

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 1000 runs

Other Settings:
istanbul EvmVersion
File 1 of 25 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

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

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

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

File 2 of 25 : Ownable2Step.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.0;

import "./Ownable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

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

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

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() external {
        address sender = _msgSender();
        require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
        _transferOwnership(sender);
    }
}

File 3 of 25 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

File 6 of 25 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

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

File 7 of 25 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

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.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
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];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

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

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

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

import './pool/IUniswapV3PoolImmutables.sol';
import './pool/IUniswapV3PoolState.sol';
import './pool/IUniswapV3PoolDerivedState.sol';
import './pool/IUniswapV3PoolActions.sol';
import './pool/IUniswapV3PoolOwnerActions.sol';
import './pool/IUniswapV3PoolEvents.sol';

/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is
    IUniswapV3PoolImmutables,
    IUniswapV3PoolState,
    IUniswapV3PoolDerivedState,
    IUniswapV3PoolActions,
    IUniswapV3PoolOwnerActions,
    IUniswapV3PoolEvents
{

}

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

/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IUniswapV3PoolActions {
    /// @notice Sets the initial price for the pool
    /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
    /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
    function initialize(uint160 sqrtPriceX96) external;

    /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
    /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
    /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
    /// on tickLower, tickUpper, the amount of liquidity, and the current price.
    /// @param recipient The address for which the liquidity will be created
    /// @param tickLower The lower tick of the position in which to add liquidity
    /// @param tickUpper The upper tick of the position in which to add liquidity
    /// @param amount The amount of liquidity to mint
    /// @param data Any data that should be passed through to the callback
    /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
    /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
    function mint(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount,
        bytes calldata data
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Collects tokens owed to a position
    /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
    /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
    /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
    /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
    /// @param recipient The address which should receive the fees collected
    /// @param tickLower The lower tick of the position for which to collect fees
    /// @param tickUpper The upper tick of the position for which to collect fees
    /// @param amount0Requested How much token0 should be withdrawn from the fees owed
    /// @param amount1Requested How much token1 should be withdrawn from the fees owed
    /// @return amount0 The amount of fees collected in token0
    /// @return amount1 The amount of fees collected in token1
    function collect(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);

    /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
    /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
    /// @dev Fees must be collected separately via a call to #collect
    /// @param tickLower The lower tick of the position for which to burn liquidity
    /// @param tickUpper The upper tick of the position for which to burn liquidity
    /// @param amount How much liquidity to burn
    /// @return amount0 The amount of token0 sent to the recipient
    /// @return amount1 The amount of token1 sent to the recipient
    function burn(
        int24 tickLower,
        int24 tickUpper,
        uint128 amount
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Swap token0 for token1, or token1 for token0
    /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
    /// @param recipient The address to receive the output of the swap
    /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
    /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
    /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
    /// value after the swap. If one for zero, the price cannot be greater than this value after the swap
    /// @param data Any data to be passed through to the callback
    /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
    /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
    function swap(
        address recipient,
        bool zeroForOne,
        int256 amountSpecified,
        uint160 sqrtPriceLimitX96,
        bytes calldata data
    ) external returns (int256 amount0, int256 amount1);

    /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
    /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
    /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
    /// with 0 amount{0,1} and sending the donation amount(s) from the callback
    /// @param recipient The address which will receive the token0 and token1 amounts
    /// @param amount0 The amount of token0 to send
    /// @param amount1 The amount of token1 to send
    /// @param data Any data to be passed through to the callback
    function flash(
        address recipient,
        uint256 amount0,
        uint256 amount1,
        bytes calldata data
    ) external;

    /// @notice Increase the maximum number of price and liquidity observations that this pool will store
    /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
    /// the input observationCardinalityNext.
    /// @param observationCardinalityNext The desired minimum number of observations for the pool to store
    function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}

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

/// @title Pool state that is not stored
/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the
/// blockchain. The functions here may have variable gas costs.
interface IUniswapV3PoolDerivedState {
    /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
    /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
    /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
    /// you must call it with secondsAgos = [3600, 0].
    /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
    /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
    /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
    /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
    /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
    /// timestamp
    function observe(uint32[] calldata secondsAgos)
        external
        view
        returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);

    /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range
    /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.
    /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first
    /// snapshot is taken and the second snapshot is taken.
    /// @param tickLower The lower tick of the range
    /// @param tickUpper The upper tick of the range
    /// @return tickCumulativeInside The snapshot of the tick accumulator for the range
    /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range
    /// @return secondsInside The snapshot of seconds per liquidity for the range
    function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
        external
        view
        returns (
            int56 tickCumulativeInside,
            uint160 secondsPerLiquidityInsideX128,
            uint32 secondsInside
        );
}

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

/// @title Events emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolEvents {
    /// @notice Emitted exactly once by a pool when #initialize is first called on the pool
    /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
    /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
    /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
    event Initialize(uint160 sqrtPriceX96, int24 tick);

    /// @notice Emitted when liquidity is minted for a given position
    /// @param sender The address that minted the liquidity
    /// @param owner The owner of the position and recipient of any minted liquidity
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount The amount of liquidity minted to the position range
    /// @param amount0 How much token0 was required for the minted liquidity
    /// @param amount1 How much token1 was required for the minted liquidity
    event Mint(
        address sender,
        address indexed owner,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount,
        uint256 amount0,
        uint256 amount1
    );

    /// @notice Emitted when fees are collected by the owner of a position
    /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
    /// @param owner The owner of the position for which fees are collected
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount0 The amount of token0 fees collected
    /// @param amount1 The amount of token1 fees collected
    event Collect(
        address indexed owner,
        address recipient,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount0,
        uint128 amount1
    );

    /// @notice Emitted when a position's liquidity is removed
    /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
    /// @param owner The owner of the position for which liquidity is removed
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount The amount of liquidity to remove
    /// @param amount0 The amount of token0 withdrawn
    /// @param amount1 The amount of token1 withdrawn
    event Burn(
        address indexed owner,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount,
        uint256 amount0,
        uint256 amount1
    );

    /// @notice Emitted by the pool for any swaps between token0 and token1
    /// @param sender The address that initiated the swap call, and that received the callback
    /// @param recipient The address that received the output of the swap
    /// @param amount0 The delta of the token0 balance of the pool
    /// @param amount1 The delta of the token1 balance of the pool
    /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
    /// @param liquidity The liquidity of the pool after the swap
    /// @param tick The log base 1.0001 of price of the pool after the swap
    event Swap(
        address indexed sender,
        address indexed recipient,
        int256 amount0,
        int256 amount1,
        uint160 sqrtPriceX96,
        uint128 liquidity,
        int24 tick
    );

    /// @notice Emitted by the pool for any flashes of token0/token1
    /// @param sender The address that initiated the swap call, and that received the callback
    /// @param recipient The address that received the tokens from flash
    /// @param amount0 The amount of token0 that was flashed
    /// @param amount1 The amount of token1 that was flashed
    /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
    /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
    event Flash(
        address indexed sender,
        address indexed recipient,
        uint256 amount0,
        uint256 amount1,
        uint256 paid0,
        uint256 paid1
    );

    /// @notice Emitted by the pool for increases to the number of observations that can be stored
    /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index
    /// just before a mint/swap/burn.
    /// @param observationCardinalityNextOld The previous value of the next observation cardinality
    /// @param observationCardinalityNextNew The updated value of the next observation cardinality
    event IncreaseObservationCardinalityNext(
        uint16 observationCardinalityNextOld,
        uint16 observationCardinalityNextNew
    );

    /// @notice Emitted when the protocol fee is changed by the pool
    /// @param feeProtocol0Old The previous value of the token0 protocol fee
    /// @param feeProtocol1Old The previous value of the token1 protocol fee
    /// @param feeProtocol0New The updated value of the token0 protocol fee
    /// @param feeProtocol1New The updated value of the token1 protocol fee
    event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);

    /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner
    /// @param sender The address that collects the protocol fees
    /// @param recipient The address that receives the collected protocol fees
    /// @param amount0 The amount of token0 protocol fees that is withdrawn
    /// @param amount0 The amount of token1 protocol fees that is withdrawn
    event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
}

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

/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
    /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
    /// @return The contract address
    function factory() external view returns (address);

    /// @notice The first of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token0() external view returns (address);

    /// @notice The second of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token1() external view returns (address);

    /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
    /// @return The fee
    function fee() external view returns (uint24);

    /// @notice The pool tick spacing
    /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
    /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
    /// This value is an int24 to avoid casting even though it is always positive.
    /// @return The tick spacing
    function tickSpacing() external view returns (int24);

    /// @notice The maximum amount of position liquidity that can use any tick in the range
    /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
    /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
    /// @return The max amount of liquidity per tick
    function maxLiquidityPerTick() external view returns (uint128);
}

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

/// @title Permissioned pool actions
/// @notice Contains pool methods that may only be called by the factory owner
interface IUniswapV3PoolOwnerActions {
    /// @notice Set the denominator of the protocol's % share of the fees
    /// @param feeProtocol0 new protocol fee for token0 of the pool
    /// @param feeProtocol1 new protocol fee for token1 of the pool
    function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;

    /// @notice Collect the protocol fee accrued to the pool
    /// @param recipient The address to which collected protocol fees should be sent
    /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1
    /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0
    /// @return amount0 The protocol fee collected in token0
    /// @return amount1 The protocol fee collected in token1
    function collectProtocol(
        address recipient,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);
}

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

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

File 16 of 25 : FixedPoint96.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.4.0;

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

File 17 of 25 : TransferHelper.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.0;

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

library TransferHelper {
    /// @notice Transfers tokens from the targeted address to the given destination
    /// @notice Errors with 'STF' if transfer fails
    /// @param token The contract address of the token to be transferred
    /// @param from The originating address from which the tokens will be transferred
    /// @param to The destination address of the transfer
    /// @param value The amount to be transferred
    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) =
            token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');
    }

    /// @notice Transfers tokens from msg.sender to a recipient
    /// @dev Errors with ST if transfer fails
    /// @param token The contract address of the token which will be transferred
    /// @param to The recipient of the transfer
    /// @param value The value of the transfer
    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');
    }

    /// @notice Approves the stipulated contract to spend the given allowance in the given token
    /// @dev Errors with 'SA' if transfer fails
    /// @param token The contract address of the token to be approved
    /// @param to The target of the approval
    /// @param value The amount of the given token the target will be allowed to spend
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');
    }

    /// @notice Transfers ETH to the recipient address
    /// @dev Fails with `STE`
    /// @param to The destination of the transfer
    /// @param value The value to be transferred
    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'STE');
    }
}

File 18 of 25 : ICountryList.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.8.19;

/**
 * @dev Interface of the CountryList contract
 */
interface ICountryList {
  function countryIsValid (uint16 _countryCode) external view returns (bool);
}

File 19 of 25 : IMigrateV3NFT.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.8.19;

import "./uniswap-updated/INonfungiblePositionManager.sol";

/**
 * @dev Interface of the MigrateV3NFT contract
 */
interface IMigrateV3NFT {
  function migrate (uint256 lockId, INonfungiblePositionManager nftPositionManager, uint256 tokenId) external returns (bool);
}

File 20 of 25 : IUNCX_LiquidityLocker_UniV3.sol
// SPDX-License-Identifier: UNLICENSED
// ALL RIGHTS RESERVED
// UNCX by SDDTech reserves all rights on this code. You may not copy these contracts.

pragma solidity 0.8.19;

import "./uniswap-updated/INonfungiblePositionManager.sol";

/**
 * @dev Interface of the UNCX UniswapV3 Liquidity Locker
 */
interface IUNCX_LiquidityLocker_UniV3 {
    struct FeeStruct {
        string name; // name by which the fee is accessed
        uint256 lpFee; // 100 = 1%, 10,000 = 100%
        uint256 collectFee; // 100 = 1%, 10,000 = 100%
        uint256 flatFee; // in amount tokens
        address flatFeeToken; // address(0) = ETH otherwise ERC20 address expected
    }

    struct Lock {
        uint256 lock_id; // unique nonce per lock
        INonfungiblePositionManager nftPositionManager; // the nft position manager of the uniswap fork
        address pool; // the pool address
        uint256 nft_id; // the nft token id of the nft belonging to the nftPositionManager (there could be two nfts with id = 1, belonging to different amm forks and position managers)
        address owner; // the owner who can collect and withdraw
        address pendingOwner; //  two step process ownership transfer, the pending owner must accept ownership to own the lock
        address additionalCollector; // an additional address allowed to call collect (ideal for contracts to auto collect without having to use owner)
        address collectAddress; // The address to which automatic collections are sent
        uint256 unlockDate; // unlock date of the lock in seconds
        uint16 countryCode; // the country code of the locker / business
        uint256 ucf; // collect fee
    }

    struct LockParams {
        INonfungiblePositionManager nftPositionManager; // the NFT Position manager of the Uniswap V3 fork
        uint256 nft_id; // the nft token_id
        address dustRecipient; // receiver of dust tokens which do not fit into liquidity and initial collection fees
        address owner; // owner of the lock
        address additionalCollector; // an additional address allowed to call collect (ideal for contracts to auto collect without having to use owner)
        address collectAddress; // The address to which automatic collections are sent
        uint256 unlockDate; // unlock date of the lock in seconds
        uint16 countryCode; // the country code of the locker / business
        string feeName; // The fee name key you wish to accept, use "DEFAULT" if in doubt
        bytes[] r; // use an empty array => []
    }

    // User functions
    function lock (LockParams calldata params) external payable returns (uint256 lockId);
    function collect (uint256 lockId, address recipient, uint128 amount0Max, uint128 amount1Max) external returns (uint256 amount0, uint256 amount1, uint256 fee0, uint256 fee1);
    function withdraw (uint256 lockId, address receiver) external;
    function migrate (uint256 lockId) external;
    function relock(uint256 lockId, uint256 unlockDate) external;
    function setAdditionalCollector (uint256 lockId, address additionalCollector) external;
    function setCollectAddress (uint256 lockId, address collectAddress) external;
    function transferLockOwnership (uint256 lockId, address newOwner) external;
    function acceptLockOwnership (uint256 lockId, address collectAddress) external;
    function decreaseLiquidity(uint256 lockId, INonfungiblePositionManager.DecreaseLiquidityParams calldata params) external payable returns (uint256 amount0, uint256 amount1);
    function increaseLiquidity(uint256 lockId, INonfungiblePositionManager.IncreaseLiquidityParams calldata params) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1);

    // Admin functions
    function allowNftPositionManager (address nftPositionManager) external;
    function setMigrator(address migrator) external;
    function setUCF(uint256 lockId, uint256 ucf) external;
    function setMigrateInContract (address migrateInContract) external;

    // Getters
    function getLocksLength() external view returns (uint256);
    function getLock(uint256 lockId) external view returns (Lock memory lock);

    function getNumUserLocks(address user) external view returns (uint256 numLocks);
    function getUserLockAtIndex(address user, uint256 index) external view returns (Lock memory lock);

    function getFee (string memory name) external view returns (FeeStruct memory);
    function getAmountsForLiquidity (int24 currentTick, int24 tickLower, int24 tickHigher, uint128 liquidity) external pure returns (uint256 amount0, uint256 amount1);

    function nftPositionManagerIsAllowed (address nftPositionManager) external view returns (bool);

    // Events
    event onLock(
        uint256 lock_id,
        address nftPositionManager,
        uint256 nft_id,
        address owner,
        address additionalCollector,
        address collectAddress,
        uint256 unlockDate,
        uint16 countryCode,
        uint256 collectFee,
        address poolAddress,
        INonfungiblePositionManager.Position position
    );

    event onWithdraw(uint256 lock_id, address owner, address receiver);

    event onLockOwnershipTransferStarted(uint256 lockId, address currentOwner, address pendingOwner);

    event onTransferLockOwnership(uint256 lockId, address oldOwner, address newOwner, address newCollectAddress);

    event onMigrate(uint256 lockId);

    event onSetAdditionalCollector(uint256 lockId, address additionalCollector);

    event onSetCollectAddress(uint256 lockId, address collectAddress);

    event onSetMigrator(address migrator);

    event onRelock(uint256 lockId, uint256 unlockDate);

    event onIncreaseLiquidity(uint256 lockId);

    event onDecreaseLiquidity(uint256 lockId);

    event onRemoveFee(bytes32 nameHash);

    event onAddFee(bytes32 nameHash, string name, uint256 lpFee, uint256 collectFee, uint256 flatFee, address flatFeeToken);

    event onEditFee(bytes32 nameHash, string name, uint256 lpFee, uint256 collectFee, uint256 flatFee, address flatFeeToken);

    event onSetUCF(uint256 lockId, uint256 ucf);

    event OnAllowNftPositionManager(address nftPositionManager);
    
}

File 21 of 25 : UNCX_LiquidityLocker_UniV3.sol
// SPDX-License-Identifier: UNLICENSED
// ALL RIGHTS RESERVED
// UNCX by SDDTech reserves all rights on this code. You may not copy these contracts.

pragma solidity 0.8.19;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

import {IUniswapV3Factory} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";
import {IUniswapV3Pool} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import {TransferHelper} from "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol";

import {TickMath} from './uniswap-updated/TickMath.sol';
import {LiquidityAmounts} from './uniswap-updated/LiquidityAmounts.sol';
import {INonfungiblePositionManager} from "./uniswap-updated/INonfungiblePositionManager.sol";
import {ICountryList} from "./ICountryList.sol";
import {IMigrateV3NFT} from "./IMigrateV3NFT.sol";
import {IUNCX_LiquidityLocker_UniV3} from "./IUNCX_LiquidityLocker_UniV3.sol";

/*
    Version 2.0
    
    The UNCX UniV3 Liquidity Locker Contract locks whitelisted exact forks of Uniswap V3's liquidity NFT's in this contract.

    This contract locks a Uniswap V3 forks NFT in the exact range it is when lock() is called, and the range cannot be changed until the lock has expired.

    Lock owners are still free to collect fees as they please, and add liquidity to their position, while the liquidity remains locked.

    You can also still view your NFT and its metrics on uniswap while it is locked. e.g. https://app.uniswap.org/#/pools/69
*/

interface IFeeResolver {
    function useFee(bytes[] memory r, address sender) external returns (IUNCX_LiquidityLocker_UniV3.FeeStruct memory fee);
}

contract UNCX_LiquidityLocker_UniV3 is IUNCX_LiquidityLocker_UniV3, Ownable2Step, IERC721Receiver, ReentrancyGuard {
    using EnumerableSet for EnumerableSet.UintSet;
    using EnumerableSet for EnumerableSet.Bytes32Set;
    using EnumerableSet for EnumerableSet.AddressSet;

    mapping(bytes32 nameHash => FeeStruct) private FEES; // map keccak(fee_name) to fee struct e.g. keccak256("DEFAULT") => FeeStruct
    EnumerableSet.Bytes32Set private FEE_LOOKUP; // contains keccak(feeName)
    EnumerableSet.AddressSet private allowedNftPositionManagers;

    IFeeResolver public FEE_RESOLVER; // Resolve R fees

    address public AUTO_COLLECT_ACCOUNT; // account controlled by UNCX to auto collect fees if a fee option involving collection fees was accepted
    address payable public FEE_ADDR_LP; // LP fee destination
    address payable public FEE_ADDR_COLLECT; // collect fee destination
    uint256 public constant FEE_DENOMINATOR = 10000; // denominator for all fees

    ICountryList public immutable COUNTRY_LIST;
    IMigrateV3NFT public MIGRATOR; // migrate to future amm versions while liquidity remains locked
    address public MIGRATE_IN; // address of the migration in contract
    uint256 public NONCE = 0; // incremental lock nonce counter, this is the unique ID for the next lock

    // If a locks unlock date is set to ETERNAL_LOCK the lock is eternal and not ever withdrawable.
    // It can however be migrated by the owner to future AMMS and is therefore preferrable to burning liquidity, or sending liquidity NFT's to the dead address.
    uint256 public constant ETERNAL_LOCK = type(uint256).max;

    // a mapping of lock_id => Lock
    mapping(uint256 lockId => Lock) public LOCKS;

    mapping(address userAddress => EnumerableSet.UintSet) private USER_LOCKS; // a set of all lock_ids owned by a user, useful for on chain enumeration.

    constructor(ICountryList _countryList, address payable _autoCollectAddress, address payable _lpFeeReceiver, address payable _collectFeeReceiver) {
        COUNTRY_LIST = _countryList;
        AUTO_COLLECT_ACCOUNT = _autoCollectAddress;
        FEE_ADDR_LP = _lpFeeReceiver;
        FEE_ADDR_COLLECT = _collectFeeReceiver;
        addOrEditFee("DEFAULT", 50, 200, 0, address(0));
        addOrEditFee("LVP", 80, 100, 0, address(0));
        addOrEditFee("LLP", 30, 350, 0, address(0));
    }

    function allowNftPositionManager (address _nftPositionManager) external onlyOwner {
        allowedNftPositionManagers.add(_nftPositionManager);
        emit OnAllowNftPositionManager(_nftPositionManager);
    }

    function setFeeResolver (IFeeResolver _resolver) external onlyOwner {
        FEE_RESOLVER = _resolver;
    }

    function setFeeParams (address _autoCollectAccount, address payable _lpFeeReceiver, address payable _collectFeeReceiver) external onlyOwner {
        AUTO_COLLECT_ACCOUNT = _autoCollectAccount;
        FEE_ADDR_LP = _lpFeeReceiver;
        FEE_ADDR_COLLECT = _collectFeeReceiver;
    }

    function addOrEditFee(string memory _name, uint256 _lpFee, uint256 _collectFee, uint256 _flatFee, address _flatFeeToken) public onlyOwner {
        bytes32 nameHash = keccak256(abi.encodePacked(_name));

        FeeStruct memory newFee = FeeStruct(_name, _lpFee, _collectFee, _flatFee, _flatFeeToken);
        FEES[nameHash] = newFee;

        if (!FEE_LOOKUP.contains(nameHash)) {
            FEE_LOOKUP.add(nameHash);
            emit onAddFee(nameHash, newFee.name, newFee.lpFee, newFee.collectFee, newFee.flatFee, newFee.flatFeeToken);
        } else {
            emit onEditFee(nameHash, newFee.name, newFee.lpFee, newFee.collectFee, newFee.flatFee, newFee.flatFeeToken);
        }
    }

    function removeFee (string memory _name) external onlyOwner {
        bytes32 nameHash = keccak256(abi.encodePacked(_name));
        require(nameHash != keccak256(abi.encodePacked("DEFAULT")), "DEFAULT");
        require(FEE_LOOKUP.contains(nameHash), "Fee not exists");
        FEE_LOOKUP.remove(nameHash);
        delete FEES[nameHash];
        emit onRemoveFee(nameHash);
    }

    function getFee (string memory _name) public override view returns (FeeStruct memory) {
        bytes32 feeHash = keccak256(abi.encodePacked(_name));
        require(FEE_LOOKUP.contains(feeHash), "NOT FOUND");
        return FEES[feeHash];
    }

    function getFeeOptionAtIndex (uint256 _index) external view returns (FeeStruct memory) {
        return FEES[FEE_LOOKUP.at(_index)];
    }

    function getFeeOptionLength () external view returns (uint256) {
        return FEE_LOOKUP.length();
    }

    function deductFlatFee (FeeStruct memory fee) private {
        if (fee.flatFeeToken == address(0)) { // fee in gas token
            require(msg.value == fee.flatFee, 'FLAT FEE');
            (bool success, ) = FEE_ADDR_LP.call{value: fee.flatFee}("");
            if (!success) {
                revert("Gas token transfer failed");
            }
        } else { // fee in another token
            TransferHelper.safeTransferFrom(fee.flatFeeToken, msg.sender, FEE_ADDR_LP, fee.flatFee);
        }
    }

    /**
    @dev locks nft in its current range and collects fees and sends them back to collector
    @param params The locking params as seen in IUNCX_LiquidityLocker_UniV3.sol
    *
    * This will fail with rebasing tokens (liquidity nfts already stuck on univ3).
    */
    function lock (LockParams calldata params) external payable override nonReentrant returns (uint256) {
        require(params.owner != address(0), "OWNER CANNOT = address(0)");
        require(params.collectAddress != address(0), 'COLLECT_ADDR');
        require(params.unlockDate < 1e10 || params.unlockDate == ETERNAL_LOCK, 'MILLISECONDS'); // prevents errors when timestamp entered in milliseconds
        require(params.unlockDate > block.timestamp, 'DATE PASSED');
        require(COUNTRY_LIST.countryIsValid(params.countryCode), 'COUNTRY');
        require(allowedNftPositionManagers.contains(address(params.nftPositionManager)), 'INVALID NFT POSITION MANAGER');
        FeeStruct memory fee;

        if (msg.sender == MIGRATE_IN) {
            fee.collectFee = abi.decode(params.r[0], (uint256));
        } else {
            if (params.r.length > 0) {
                fee = FEE_RESOLVER.useFee(params.r, msg.sender);
            } else {
                fee = getFee(params.feeName);
            }

            if (fee.flatFee > 0) {
                deductFlatFee(fee);
            }
        }

        params.nftPositionManager.safeTransferFrom(msg.sender, address(this), params.nft_id);

        INonfungiblePositionManager.Position memory position;
        (,,position.token0,position.token1,position.fee,position.tickLower,position.tickUpper,position.liquidity,,,,) = params.nftPositionManager.positions(params.nft_id);
        IUniswapV3Factory factory = IUniswapV3Factory(params.nftPositionManager.factory());
        address pool = factory.getPool(position.token0, position.token1, position.fee);

        // collect fees for user to prevent being charged a fee on existing fees
        params.nftPositionManager.collect(INonfungiblePositionManager.CollectParams(params.nft_id, params.dustRecipient, type(uint128).max, type(uint128).max));

        // Take lp fee
        if (fee.lpFee > 0) {
            uint128 liquidity = _getLiquidity(params.nftPositionManager, params.nft_id);
            params.nftPositionManager.decreaseLiquidity(INonfungiblePositionManager.DecreaseLiquidityParams(params.nft_id, uint128(liquidity * fee.lpFee / FEE_DENOMINATOR), 0, 0, block.timestamp));
            params.nftPositionManager.collect(INonfungiblePositionManager.CollectParams(params.nft_id, FEE_ADDR_LP, type(uint128).max, type(uint128).max));
        }

        Lock memory newLock;
        newLock.lock_id = NONCE;
        newLock.nftPositionManager = params.nftPositionManager;
        newLock.pool = pool;
        newLock.nft_id = params.nft_id;
        newLock.owner = params.owner;
        newLock.additionalCollector = params.additionalCollector;
        newLock.collectAddress = params.collectAddress;
        newLock.unlockDate = params.unlockDate;
        newLock.countryCode = params.countryCode;
        newLock.ucf = fee.collectFee;
        LOCKS[NONCE] = newLock;
        USER_LOCKS[params.owner].add(NONCE);
        NONCE++;

        emitLockEvent(newLock.lock_id);

        return newLock.lock_id;
    }

    function emitLockEvent (uint256 _lockId) private {
        Lock memory newLock = LOCKS[_lockId];
        INonfungiblePositionManager.Position memory position;
        (,,position.token0,position.token1,position.fee,position.tickLower,position.tickUpper,position.liquidity,,,,) = newLock.nftPositionManager.positions(newLock.nft_id);
        emit onLock(
            newLock.lock_id, 
            address(newLock.nftPositionManager), 
            newLock.nft_id,
            newLock.owner,
            newLock.additionalCollector,
            newLock.collectAddress,
            newLock.unlockDate,
            newLock.countryCode,
            newLock.ucf,
            newLock.pool,
            position
        );
    }

    /**
    * @dev Collect fees to _recipient if msg.sender is the owner of _lockId
    */
    function collect (uint256 _lockId, address _recipient, uint128 _amount0Max, uint128 _amount1Max) external override nonReentrant returns (uint256 amount0, uint256 amount1, uint256 fee0, uint256 fee1) {
        (amount0, amount1, fee0, fee1) = _collect(_lockId, _recipient, _amount0Max, _amount1Max);
    }

    /**
    * @dev Private collect function, wrap this in re-entrancy guard calls
    */
    function _collect (uint256 _lockId, address _recipient, uint128 _amount0Max, uint128 _amount1Max) private returns(uint256 amount0, uint256 amount1, uint256 fee0, uint256 fee1) {
        Lock memory userLock = LOCKS[_lockId];
        bool collectorIsBot = AUTO_COLLECT_ACCOUNT == msg.sender;
        require(userLock.owner == msg.sender || userLock.additionalCollector == msg.sender || collectorIsBot, "OWNER");
        if (userLock.ucf == 0) { // No Protocol fee
            (amount0, amount1) = userLock.nftPositionManager.collect(INonfungiblePositionManager.CollectParams(userLock.nft_id, _recipient, _amount0Max, _amount1Max));
        } else { // Protocol fees
            (,,address _token0,address _token1,,,,,,,,) = userLock.nftPositionManager.positions(userLock.nft_id);

            uint256 balance0 = IERC20(_token0).balanceOf(address(this));
            uint256 balance1 = IERC20(_token1).balanceOf(address(this));

            userLock.nftPositionManager.collect(INonfungiblePositionManager.CollectParams(userLock.nft_id, address(this), _amount0Max, _amount1Max));

            balance0 = IERC20(_token0).balanceOf(address(this)) - balance0;
            balance1 = IERC20(_token1).balanceOf(address(this)) - balance1;
            address feeTo = collectorIsBot ? _recipient : FEE_ADDR_COLLECT;
            address remainderTo = collectorIsBot ? userLock.collectAddress : _recipient;

            if (balance0 > 0) {
                fee0 = balance0 * userLock.ucf / FEE_DENOMINATOR;
                TransferHelper.safeTransfer(_token0, feeTo, fee0);
                amount0 = balance0 - fee0;
                TransferHelper.safeTransfer(_token0, remainderTo, amount0);
            }
            if (balance1 > 0) {
                fee1 = balance1 * userLock.ucf / FEE_DENOMINATOR;
                TransferHelper.safeTransfer(_token1, feeTo, fee1);
                amount1 = balance1 - fee1;
                TransferHelper.safeTransfer(_token1, remainderTo, amount1);
            }
        }
    }

    /**
    * @dev increases liquidity. Can be called by anyone. 
    * You should ideally call increaseLiquidity from the NftPositionManager directly for gas efficiency. 
    * This method is here just for convenience for some contracts which solely interact with the UNCX lockers / lockIds
    */
    function increaseLiquidity(uint256 _lockId, INonfungiblePositionManager.IncreaseLiquidityParams calldata params) external payable override nonReentrant returns (uint128 liquidity, uint256 amount0, uint256 amount1) {
        Lock memory userLock = LOCKS[_lockId];
        require(userLock.nft_id == params.tokenId, "NFT ID");

        (,,address token0,address token1,,,,,,,,) = userLock.nftPositionManager.positions(userLock.nft_id);

        uint256 balance0Before = IERC20(token0).balanceOf(address(this));
        uint256 balance1Before = IERC20(token1).balanceOf(address(this));

        TransferHelper.safeTransferFrom(token0, msg.sender, address(this), params.amount0Desired);
        TransferHelper.safeTransferFrom(token1, msg.sender, address(this), params.amount1Desired);
        TransferHelper.safeApprove(token0, address(userLock.nftPositionManager), params.amount0Desired);
        TransferHelper.safeApprove(token1, address(userLock.nftPositionManager), params.amount1Desired);

        (liquidity, amount0, amount1) = userLock.nftPositionManager.increaseLiquidity(params);

        uint256 balance0diff = IERC20(token0).balanceOf(address(this)) - balance0Before;
        uint256 balance1diff = IERC20(token1).balanceOf(address(this)) - balance1Before;
        if (balance0diff > 0) {
            TransferHelper.safeTransfer(token0, msg.sender, balance0diff);
        }
        if (balance1diff > 0) {
            TransferHelper.safeTransfer(token1, msg.sender, balance1diff);
        }

        emit onIncreaseLiquidity(_lockId); // This can be called directly from the NFT position manager in which case this event won't fire
    }

    /**
    * @dev decrease liquidity if a lock has expired (useful before relocking)
    */
    function decreaseLiquidity(uint256 _lockId, INonfungiblePositionManager.DecreaseLiquidityParams calldata params) external payable override nonReentrant returns (uint256 amount0, uint256 amount1) {
        isLockAdmin(_lockId);
        Lock memory userLock = LOCKS[_lockId];
        require(userLock.nft_id == params.tokenId, 'NFT ID');
        if (userLock.unlockDate == ETERNAL_LOCK) {
            revert('ETERNAL_LOCK');
        } else {
            require(userLock.unlockDate < block.timestamp, 'NOT YET');
        }
        _collect(_lockId, msg.sender, type(uint128).max, type(uint128).max); // collect protocol fees
        (amount0, amount1) = userLock.nftPositionManager.decreaseLiquidity(params);
        userLock.nftPositionManager.collect(INonfungiblePositionManager.CollectParams(userLock.nft_id, msg.sender, type(uint128).max, type(uint128).max));
        emit onDecreaseLiquidity(_lockId);
    }

    /**
    * @dev set the unlock date further in the future
    */
    function relock(uint256 _lockId, uint256 _unlockDate) external override nonReentrant {
        isLockAdmin(_lockId);
        Lock storage userLock = LOCKS[_lockId];
        require(_unlockDate > userLock.unlockDate, 'DATE');
        require(_unlockDate > block.timestamp, 'DATE PASSED');
        require(_unlockDate < 1e10 || _unlockDate == ETERNAL_LOCK, 'MILLISECONDS'); // prevents errors when timestamp entered in milliseconds
        userLock.unlockDate = _unlockDate;
        emit onRelock(_lockId, userLock.unlockDate);
    }

    /**
    * @dev withdraw a UniV3 liquidity NFT and send it to _receiver
    * Only callable once unlockDate has expired
    */
    function withdraw (uint256 _lockId, address _receiver) external override nonReentrant {
        isLockAdmin(_lockId);
        Lock memory userLock = LOCKS[_lockId];
        if (userLock.unlockDate == ETERNAL_LOCK) {
            revert('ETERNAL_LOCK');
        } else {
            require(userLock.unlockDate < block.timestamp, 'NOT YET');
        }

        if (userLock.ucf > 0) {
            _collect(_lockId, _receiver, type(uint128).max, type(uint128).max);
        }

        userLock.nftPositionManager.safeTransferFrom(address(this), _receiver, userLock.nft_id);
        USER_LOCKS[userLock.owner].remove(_lockId);

        emit onWithdraw(_lockId, userLock.owner, _receiver);

        delete LOCKS[_lockId]; // clear the state for this lock (reset all values to zero)
    }

    /**
    * @dev set migrate in contract address
    */
    function setMigrateInContract (address _migrateIn) external override onlyOwner {
        MIGRATE_IN = _migrateIn;
    }

    /**
    * @dev migrate a lock to a new amm version (Uniswap V4)
    */
    function migrate (uint256 _lockId) external override nonReentrant {
        require(address(MIGRATOR) != address(0), "NOT SET");
        isLockAdmin(_lockId);
        Lock memory userLock = LOCKS[_lockId];
        userLock.nftPositionManager.approve(address(MIGRATOR), userLock.nft_id);
        MIGRATOR.migrate(_lockId, userLock.nftPositionManager, userLock.nft_id);
        USER_LOCKS[userLock.owner].remove(_lockId);

        delete LOCKS[_lockId]; // clear the state for this lock (reset all values to zero)

        emit onMigrate(_lockId);
    }

    /**
    * @dev allow a lock owner to add an additional address, usually a contract, to collect fees. Useful for bots
    */
    function setAdditionalCollector (uint256 _lockId, address _additionalCollector) external override nonReentrant {
        isLockAdmin(_lockId);
        Lock storage userLock = LOCKS[_lockId];
        userLock.additionalCollector = _additionalCollector;

        emit onSetAdditionalCollector(_lockId, _additionalCollector);
    }

    /**
    * @dev set the adress to which fees are automatically collected
    */
    function setCollectAddress (uint256 _lockId, address _collectAddress) external override nonReentrant {
        isLockAdmin(_lockId);
        require(_collectAddress != address(0), 'COLLECT_ADDR');
        Lock storage userLock = LOCKS[_lockId];
        userLock.collectAddress = _collectAddress;

        emit onSetCollectAddress(_lockId, _collectAddress);
    }

    /**
    * @dev transfer ownership of a lock to _newOwner 
    */
    function transferLockOwnership (uint256 _lockId, address _newOwner) external override nonReentrant {
        isLockAdmin(_lockId);
        require(msg.sender != _newOwner, "SAME OWNER");
        Lock storage userLock = LOCKS[_lockId];
        userLock.pendingOwner = _newOwner;

        emit onLockOwnershipTransferStarted(_lockId, msg.sender, _newOwner);
    }

    /**
    * @dev accept lock ownership transfer
    */
    function acceptLockOwnership (uint256 _lockId, address _collectAddress) external override nonReentrant {
        Lock storage userLock = LOCKS[_lockId];
        require(userLock.pendingOwner == msg.sender, "OWNER");

        address oldOwner = userLock.owner;
        USER_LOCKS[userLock.owner].remove(_lockId);
        userLock.owner = msg.sender;
        userLock.pendingOwner = address(0);
        userLock.collectAddress = _collectAddress;
        userLock.additionalCollector = address(0);
        USER_LOCKS[msg.sender].add(_lockId);

        emit onTransferLockOwnership(_lockId, oldOwner, msg.sender, _collectAddress);
    }

    /**
    * @dev set the migrator contract which allows locked LP NFT's to be migrated to future AMM versions
    */
    function setMigrator(address _migrator) external override onlyOwner {
        MIGRATOR = IMigrateV3NFT(_migrator);

        emit onSetMigrator(_migrator);
    }

    /**
    * @dev set ucf
    */
    function setUCF(uint256 _lockId, uint256 _ucf) external override onlyOwner {
        Lock storage l = LOCKS[_lockId];
        require(_ucf < l.ucf, "L");
        l.ucf = _ucf;
        emit onSetUCF(_lockId, _ucf);
    }

    /**
    * @dev check if msg.sender is the owner of lock with _lockId
    */
    function isLockAdmin (uint256 _lockId) private view {
        Lock memory userLock = LOCKS[_lockId];
        require(userLock.owner == msg.sender, "OWNER");
    }

    /**
    * @dev returns a Lock struct for _lockId
    */
    function getLock(uint256 _lockId) external view override returns (Lock memory _lock) {
        _lock = LOCKS[_lockId];
    }

    /**
    * @dev gets the number of unique locks in this contract, used to page through the lock array (includes expired and withdrawn locks)
    */
    function getLocksLength() external view override returns (uint256) {
        return NONCE;
    }

    /**
    * @dev gets the number of locks for a user
    */
    function getNumUserLocks(address _user) external view override returns (uint256) {
        return USER_LOCKS[_user].length();
    }

    /**
    * @dev gets the lock at a specific index for a user
    */
    function getUserLockAtIndex(address _user, uint256 _index) external view override returns (Lock memory) {
        return LOCKS[USER_LOCKS[_user].at(_index)];
    }

    function _setPartialMintParamsFromPosition (INonfungiblePositionManager _nftPositionManager, uint256 _tokenId) private view returns (INonfungiblePositionManager.MintParams memory) {
        INonfungiblePositionManager.MintParams memory m;
        (,,m.token0,m.token1,m.fee,,,,,,,) = _nftPositionManager.positions(_tokenId);
        return m;
    }

    /**
    * @dev check if a nft position manager is whitelisted to lock
    */
    function nftPositionManagerIsAllowed (address _nftPositionManager) external view returns (bool) {
        return allowedNftPositionManagers.contains(_nftPositionManager);
    }

    /**
    * @dev get a locks liquidity in amounts of token0 and token1 for a generic position (not from state)
    */
    function getAmountsForLiquidity (int24 currentTick, int24 tickLower, int24 tickHigher, uint128 liquidity) public pure override returns (uint256, uint256) {
        return LiquidityAmounts.getAmountsForLiquidity(
            TickMath.getSqrtRatioAtTick(currentTick),
            TickMath.getSqrtRatioAtTick(tickLower),
            TickMath.getSqrtRatioAtTick(tickHigher),
            liquidity
        );
    }

    /**
    * @dev returns just the liquidity value from a position
    */
    function _getLiquidity (INonfungiblePositionManager _nftPositionManager, uint256 _tokenId) private view returns (uint128) {
        (,,,,,,,uint128 liquidity,,,,) = _nftPositionManager.positions(_tokenId);
        return liquidity;
    }

    /**
    * @dev Allows admin to remove any eth mistakenly sent to the contract
    */
    function adminRefundEth (uint256 _amount, address payable _receiver) external onlyOwner nonReentrant {
        (bool success, ) = _receiver.call{value: _amount}("");
        if (!success) {
            revert("Gas token transfer failed");
        }
    }

    /**
    * @dev Allows admin to remove any ERC20's mistakenly sent to the contract
    * Since this contract is only for locking NFT liquidity, this allows removal of ERC20 tokens and cannot remove locked NFT liquidity.
    */
    function adminRefundERC20 (address _token, address _receiver, uint256 _amount) external onlyOwner nonReentrant {
        // TransferHelper.safeTransfer = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
        // Attempting to transfer nfts with this function (substituting a nft_id for _amount) wil fail with 'ST' as NFTS do not have the same interface
        TransferHelper.safeTransfer(_token, _receiver, _amount);
    }

    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external override returns (bytes4) {
        return IERC721Receiver.onERC721Received.selector;
    }

}

File 22 of 25 : FullMath.sol
// SPDX-License-Identifier: MIT
// Sourced from OpenZepplin but edited to remove un-needed functions
// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/Math.sol

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library FullMath {
    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // 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(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

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

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            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 for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the 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.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // 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 preconditions 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 * inverse;
            return result;
        }
    }
}

File 23 of 25 : INonfungiblePositionManager.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

// Importing from @uniswap doesnt work with @openzepplins latest release so this is refactored
// Source: https://github.com/Uniswap/v3-periphery/blob/main/contracts/interfaces/INonfungiblePositionManager.sol

interface INonfungiblePositionManager {

    function approve(address to, uint256 tokenId) external;
    
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

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

    function mint(
        MintParams calldata params
    )
        external
        payable
        returns (
            uint256 tokenId,
            uint128 liquidity,
            uint256 amount0,
            uint256 amount1
        );

    struct Position {
        uint96 nonce;
        address operator;
        address token0;
        address token1;
        uint24 fee;
        int24 tickLower;
        int24 tickUpper;
        uint128 liquidity;
        uint256 feeGrowthInside0LastX128;
        uint256 feeGrowthInside1LastX128;
        uint128 tokensOwed0;
        uint128 tokensOwed1;
    }

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

    function collect(
        CollectParams calldata params
    ) external payable returns (uint256 amount0, uint256 amount1);

    function factory() external view returns (address);

    function burn(uint256 tokenId) external payable;
}

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

import {FullMath} from "./FullMath.sol";
import '@uniswap/v3-core/contracts/libraries/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);
        }
    }
}

File 25 of 25 : TickMath.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.9;

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

        // EDIT: 0.8 compatibility
        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",
  "optimizer": {
    "enabled": true,
    "runs": 1000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract ICountryList","name":"_countryList","type":"address"},{"internalType":"address payable","name":"_autoCollectAddress","type":"address"},{"internalType":"address payable","name":"_lpFeeReceiver","type":"address"},{"internalType":"address payable","name":"_collectFeeReceiver","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"nftPositionManager","type":"address"}],"name":"OnAllowNftPositionManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"nameHash","type":"bytes32"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"uint256","name":"lpFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collectFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"flatFee","type":"uint256"},{"indexed":false,"internalType":"address","name":"flatFeeToken","type":"address"}],"name":"onAddFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockId","type":"uint256"}],"name":"onDecreaseLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"nameHash","type":"bytes32"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"uint256","name":"lpFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collectFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"flatFee","type":"uint256"},{"indexed":false,"internalType":"address","name":"flatFeeToken","type":"address"}],"name":"onEditFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockId","type":"uint256"}],"name":"onIncreaseLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lock_id","type":"uint256"},{"indexed":false,"internalType":"address","name":"nftPositionManager","type":"address"},{"indexed":false,"internalType":"uint256","name":"nft_id","type":"uint256"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"additionalCollector","type":"address"},{"indexed":false,"internalType":"address","name":"collectAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"unlockDate","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"countryCode","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"collectFee","type":"uint256"},{"indexed":false,"internalType":"address","name":"poolAddress","type":"address"},{"components":[{"internalType":"uint96","name":"nonce","type":"uint96"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"feeGrowthInside0LastX128","type":"uint256"},{"internalType":"uint256","name":"feeGrowthInside1LastX128","type":"uint256"},{"internalType":"uint128","name":"tokensOwed0","type":"uint128"},{"internalType":"uint128","name":"tokensOwed1","type":"uint128"}],"indexed":false,"internalType":"struct INonfungiblePositionManager.Position","name":"position","type":"tuple"}],"name":"onLock","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockId","type":"uint256"},{"indexed":false,"internalType":"address","name":"currentOwner","type":"address"},{"indexed":false,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"onLockOwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockId","type":"uint256"}],"name":"onMigrate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"unlockDate","type":"uint256"}],"name":"onRelock","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"nameHash","type":"bytes32"}],"name":"onRemoveFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockId","type":"uint256"},{"indexed":false,"internalType":"address","name":"additionalCollector","type":"address"}],"name":"onSetAdditionalCollector","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockId","type":"uint256"},{"indexed":false,"internalType":"address","name":"collectAddress","type":"address"}],"name":"onSetCollectAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"migrator","type":"address"}],"name":"onSetMigrator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ucf","type":"uint256"}],"name":"onSetUCF","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockId","type":"uint256"},{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newCollectAddress","type":"address"}],"name":"onTransferLockOwnership","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lock_id","type":"uint256"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"}],"name":"onWithdraw","type":"event"},{"inputs":[],"name":"AUTO_COLLECT_ACCOUNT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"COUNTRY_LIST","outputs":[{"internalType":"contract ICountryList","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ETERNAL_LOCK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_ADDR_COLLECT","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_ADDR_LP","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_DENOMINATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_RESOLVER","outputs":[{"internalType":"contract IFeeResolver","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"lockId","type":"uint256"}],"name":"LOCKS","outputs":[{"internalType":"uint256","name":"lock_id","type":"uint256"},{"internalType":"contract INonfungiblePositionManager","name":"nftPositionManager","type":"address"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"nft_id","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"pendingOwner","type":"address"},{"internalType":"address","name":"additionalCollector","type":"address"},{"internalType":"address","name":"collectAddress","type":"address"},{"internalType":"uint256","name":"unlockDate","type":"uint256"},{"internalType":"uint16","name":"countryCode","type":"uint16"},{"internalType":"uint256","name":"ucf","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIGRATE_IN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIGRATOR","outputs":[{"internalType":"contract IMigrateV3NFT","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NONCE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockId","type":"uint256"},{"internalType":"address","name":"_collectAddress","type":"address"}],"name":"acceptLockOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"uint256","name":"_lpFee","type":"uint256"},{"internalType":"uint256","name":"_collectFee","type":"uint256"},{"internalType":"uint256","name":"_flatFee","type":"uint256"},{"internalType":"address","name":"_flatFeeToken","type":"address"}],"name":"addOrEditFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"adminRefundERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address payable","name":"_receiver","type":"address"}],"name":"adminRefundEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nftPositionManager","type":"address"}],"name":"allowNftPositionManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockId","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint128","name":"_amount0Max","type":"uint128"},{"internalType":"uint128","name":"_amount1Max","type":"uint128"}],"name":"collect","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"uint256","name":"fee0","type":"uint256"},{"internalType":"uint256","name":"fee1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockId","type":"uint256"},{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct INonfungiblePositionManager.DecreaseLiquidityParams","name":"params","type":"tuple"}],"name":"decreaseLiquidity","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"int24","name":"currentTick","type":"int24"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickHigher","type":"int24"},{"internalType":"uint128","name":"liquidity","type":"uint128"}],"name":"getAmountsForLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"}],"name":"getFee","outputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"lpFee","type":"uint256"},{"internalType":"uint256","name":"collectFee","type":"uint256"},{"internalType":"uint256","name":"flatFee","type":"uint256"},{"internalType":"address","name":"flatFeeToken","type":"address"}],"internalType":"struct IUNCX_LiquidityLocker_UniV3.FeeStruct","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getFeeOptionAtIndex","outputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"lpFee","type":"uint256"},{"internalType":"uint256","name":"collectFee","type":"uint256"},{"internalType":"uint256","name":"flatFee","type":"uint256"},{"internalType":"address","name":"flatFeeToken","type":"address"}],"internalType":"struct IUNCX_LiquidityLocker_UniV3.FeeStruct","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFeeOptionLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockId","type":"uint256"}],"name":"getLock","outputs":[{"components":[{"internalType":"uint256","name":"lock_id","type":"uint256"},{"internalType":"contract INonfungiblePositionManager","name":"nftPositionManager","type":"address"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"nft_id","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"pendingOwner","type":"address"},{"internalType":"address","name":"additionalCollector","type":"address"},{"internalType":"address","name":"collectAddress","type":"address"},{"internalType":"uint256","name":"unlockDate","type":"uint256"},{"internalType":"uint16","name":"countryCode","type":"uint16"},{"internalType":"uint256","name":"ucf","type":"uint256"}],"internalType":"struct IUNCX_LiquidityLocker_UniV3.Lock","name":"_lock","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLocksLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getNumUserLocks","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getUserLockAtIndex","outputs":[{"components":[{"internalType":"uint256","name":"lock_id","type":"uint256"},{"internalType":"contract INonfungiblePositionManager","name":"nftPositionManager","type":"address"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"nft_id","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"pendingOwner","type":"address"},{"internalType":"address","name":"additionalCollector","type":"address"},{"internalType":"address","name":"collectAddress","type":"address"},{"internalType":"uint256","name":"unlockDate","type":"uint256"},{"internalType":"uint16","name":"countryCode","type":"uint16"},{"internalType":"uint256","name":"ucf","type":"uint256"}],"internalType":"struct IUNCX_LiquidityLocker_UniV3.Lock","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockId","type":"uint256"},{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount0Desired","type":"uint256"},{"internalType":"uint256","name":"amount1Desired","type":"uint256"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct INonfungiblePositionManager.IncreaseLiquidityParams","name":"params","type":"tuple"}],"name":"increaseLiquidity","outputs":[{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"contract INonfungiblePositionManager","name":"nftPositionManager","type":"address"},{"internalType":"uint256","name":"nft_id","type":"uint256"},{"internalType":"address","name":"dustRecipient","type":"address"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"additionalCollector","type":"address"},{"internalType":"address","name":"collectAddress","type":"address"},{"internalType":"uint256","name":"unlockDate","type":"uint256"},{"internalType":"uint16","name":"countryCode","type":"uint16"},{"internalType":"string","name":"feeName","type":"string"},{"internalType":"bytes[]","name":"r","type":"bytes[]"}],"internalType":"struct IUNCX_LiquidityLocker_UniV3.LockParams","name":"params","type":"tuple"}],"name":"lock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockId","type":"uint256"}],"name":"migrate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nftPositionManager","type":"address"}],"name":"nftPositionManagerIsAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockId","type":"uint256"},{"internalType":"uint256","name":"_unlockDate","type":"uint256"}],"name":"relock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"}],"name":"removeFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockId","type":"uint256"},{"internalType":"address","name":"_additionalCollector","type":"address"}],"name":"setAdditionalCollector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockId","type":"uint256"},{"internalType":"address","name":"_collectAddress","type":"address"}],"name":"setCollectAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_autoCollectAccount","type":"address"},{"internalType":"address payable","name":"_lpFeeReceiver","type":"address"},{"internalType":"address payable","name":"_collectFeeReceiver","type":"address"}],"name":"setFeeParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IFeeResolver","name":"_resolver","type":"address"}],"name":"setFeeResolver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_migrateIn","type":"address"}],"name":"setMigrateInContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_migrator","type":"address"}],"name":"setMigrator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockId","type":"uint256"},{"internalType":"uint256","name":"_ucf","type":"uint256"}],"name":"setUCF","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockId","type":"uint256"},{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferLockOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockId","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Deployed Bytecode

0x6080604052600436106103075760003560e01c80639ecd74721161019a578063d5fdb732116100e1578063ed1eee681161008a578063f2fde38b11610064578063f2fde38b14610af1578063fae2e64814610b11578063fe0ab56114610b3157600080fd5b8063ed1eee6814610a9e578063ef24894414610abe578063f11478f814610ade57600080fd5b8063e091dd1a116100bb578063e091dd1a14610a4a578063e30c397814610a60578063e7a7bdfe14610a7e57600080fd5b8063d5fdb732146108f9578063d68f4dd114610919578063d73792a914610a3457600080fd5b8063b25128db11610143578063c7a85b401161011d578063c7a85b40146107c1578063cf0d5af3146107e1578063d1f55d45146108d957600080fd5b8063b25128db14610761578063b2fb30cb14610781578063b707a288146107a157600080fd5b8063a35a96b811610174578063a35a96b81461070e578063ab9ae18014610721578063ac4521c61461074157600080fd5b80639ecd74721461068c5780639f185a0b146106ac578063a339df12146106d957600080fd5b8063454b06081161025e57806375eb8e69116102075780638b52a6ee116101e15780638b52a6ee1461061e5780638da5cb5b1461063e5780639b7748401461065c57600080fd5b806375eb8e69146105c657806379ba5097146105dc57806383fb69ad146105f157600080fd5b80635a04fb69116102385780635a04fb6914610571578063611f6fe614610591578063715018a6146105b157600080fd5b8063454b06081461051c578063489c18b01461053c578063544534e71461055157600080fd5b8063150b7a02116102c057806323cf31181161029a57806323cf31181461049c578063260e12b0146104bc578063280f3867146104fc57600080fd5b8063150b7a02146103ce57806318694155146104445780631f113fc31461047c57600080fd5b8063066b58c7116102f1578063066b58c71461035657806309564ab01461038e5780630ae300bf146103ae57600080fd5b8062f714ce1461030c578063038975a11461032e575b600080fd5b34801561031857600080fd5b5061032c610327366004614e3b565b610b65565b005b34801561033a57600080fd5b50610343610e31565b6040519081526020015b60405180910390f35b34801561036257600080fd5b50600954610376906001600160a01b031681565b6040516001600160a01b03909116815260200161034d565b34801561039a57600080fd5b5061032c6103a9366004614e6b565b610e42565b3480156103ba57600080fd5b50600a54610376906001600160a01b031681565b3480156103da57600080fd5b506104136103e9366004614eb6565b7f150b7a020000000000000000000000000000000000000000000000000000000095945050505050565b6040517fffffffff00000000000000000000000000000000000000000000000000000000909116815260200161034d565b610457610452366004614f55565b610e89565b604080516001600160801b03909416845260208401929092529082015260600161034d565b34801561048857600080fd5b50600b54610376906001600160a01b031681565b3480156104a857600080fd5b5061032c6104b7366004614f8d565b611347565b3480156104c857600080fd5b506104dc6104d7366004614fbf565b6113a4565b60408051948552602085019390935291830152606082015260800161034d565b34801561050857600080fd5b5061032c610517366004615012565b6113dd565b34801561052857600080fd5b5061032c610537366004615053565b611407565b34801561054857600080fd5b50600e54610343565b34801561055d57600080fd5b5061032c61056c366004614f8d565b6116fc565b34801561057d57600080fd5b5061032c61058c366004614e3b565b611749565b34801561059d57600080fd5b506103436105ac366004614f8d565b611831565b3480156105bd57600080fd5b5061032c611858565b3480156105d257600080fd5b5061034360001981565b3480156105e857600080fd5b5061032c61186c565b3480156105fd57600080fd5b5061061161060c366004615053565b6118f7565b60405161034d91906150bc565b34801561062a57600080fd5b5061032c610639366004614f8d565b611a24565b34801561064a57600080fd5b506000546001600160a01b0316610376565b34801561066857600080fd5b5061067c610677366004614f8d565b611a4e565b604051901515815260200161034d565b34801561069857600080fd5b50600c54610376906001600160a01b031681565b3480156106b857600080fd5b506106cc6106c7366004615115565b611a5b565b60405161034d9190615141565b3480156106e557600080fd5b506106f96106f4366004615232565b611b83565b6040805192835260208301919091520161034d565b61034361071c366004615273565b611bb8565b34801561072d57600080fd5b5061032c61073c366004614e3b565b612862565b34801561074d57600080fd5b5061032c61075c366004614e3b565b612920565b34801561076d57600080fd5b5061032c61077c366004614e3b565b612995565b34801561078d57600080fd5b5061032c61079c3660046152af565b612acc565b3480156107ad57600080fd5b5061032c6107bc366004614e3b565b612c09565b3480156107cd57600080fd5b50600d54610376906001600160a01b031681565b3480156107ed57600080fd5b5061086d6107fc366004615053565b600f60205260009081526040902080546001820154600283015460038401546004850154600586015460068701546007880154600889015460098a0154600a909a015498996001600160a01b039889169997891698969795871696948516959385169490921692909161ffff16908b565b604080519b8c526001600160a01b039a8b1660208d0152988a16988b019890985260608a0196909652938716608089015291861660a0880152851660c087015290931660e085015261010084019290925261ffff9091166101208301526101408201526101600161034d565b3480156108e557600080fd5b50600854610376906001600160a01b031681565b34801561090557600080fd5b5061032c6109143660046153bf565b612cc3565b34801561092557600080fd5b506106cc610934366004615053565b6040805161016081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052610140810191909152506000908152600f60209081526040918290208251610160810184528154815260018201546001600160a01b03908116938201939093526002820154831693810193909352600381015460608401526004810154821660808401526005810154821660a08401526006810154821660c0840152600781015490911660e08301526008810154610100830152600981015461ffff16610120830152600a015461014082015290565b348015610a4057600080fd5b5061034361271081565b348015610a5657600080fd5b50610343600e5481565b348015610a6c57600080fd5b506001546001600160a01b0316610376565b348015610a8a57600080fd5b5061032c610a993660046153f4565b612e3b565b348015610aaa57600080fd5b50610611610ab93660046153bf565b612fd3565b348015610aca57600080fd5b5061032c610ad93660046152af565b613175565b6106f9610aec366004615463565b613224565b348015610afd57600080fd5b5061032c610b0c366004614f8d565b613527565b348015610b1d57600080fd5b5061032c610b2c366004614f8d565b613598565b348015610b3d57600080fd5b506103767f000000000000000000000000fa104eb3925a27e6263e05acc88f2e983a89063781565b610b6d6135c2565b610b7682613619565b6000828152600f6020908152604091829020825161016081018452815481526001808301546001600160a01b03908116948301949094526002830154841694820194909452600382015460608201526004820154831660808201526005820154831660a08201526006820154831660c0820152600782015490921660e083015260088101546101008301819052600982015461ffff16610120840152600a90910154610140830152909101610c615760405162461bcd60e51b815260206004820152600c60248201526b455445524e414c5f4c4f434b60a01b60448201526064015b60405180910390fd5b4281610100015110610c9f5760405162461bcd60e51b81526020600482015260076024820152661393d50816515560ca1b6044820152606401610c58565b61014081015115610cc257610cbd83836001600160801b03806136f4565b505050505b60208101516060820151604051632142170760e11b81523060048201526001600160a01b03858116602483015260448201929092529116906342842e0e90606401600060405180830381600087803b158015610d1d57600080fd5b505af1158015610d31573d6000803e3d6000fd5b50505060808201516001600160a01b03166000908152601060205260409020610d5b915084613cf3565b506080810151604080518581526001600160a01b03928316602082015291841682820152517fcf3f38c6e10e7fa2c0a2d09ff592596efa8ea3865dd7aabb9bff9c5189c607a89181900360600190a1506000828152600f602052604081208181556001810180546001600160a01b0319908116909155600282018054821690556003820183905560048201805482169055600582018054821690556006820180548216905560078201805490911690556008810182905560098101805461ffff19169055600a0155610e2d6001600255565b5050565b6000610e3d6004613d06565b905090565b610e4a613d10565b600980546001600160a01b039485166001600160a01b031991821617909155600a805493851693821693909317909255600b8054919093169116179055565b6000806000610e966135c2565b6000858152600f60209081526040918290208251610160810184528154815260018201546001600160a01b039081169382019390935260028201548316938101939093526003810154606084018190526004820154831660808501526005820154831660a08501526006820154831660c0850152600782015490921660e08401526008810154610100840152600981015461ffff16610120840152600a0154610140830152853514610f735760405162461bcd60e51b815260206004820152600660248201526513919508125160d21b6044820152606401610c58565b60008082602001516001600160a01b03166399fbab8884606001516040518263ffffffff1660e01b8152600401610fac91815260200190565b61018060405180830381865afa158015610fca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fee91906154c1565b50506040516370a0823160e01b8152306004820152979b5095995060009850506001600160a01b038a1696506370a0823195602401945061102f9350505050565b602060405180830381865afa15801561104c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107091906155a2565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038416906370a0823190602401602060405180830381865afa1580156110ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110de91906155a2565b90506110f08433308c60200135613d6a565b6111008333308c60400135613d6a565b6111138486602001518b60200135613ea7565b6111268386602001518b60400135613ea7565b602080860151604080517f219f5d170000000000000000000000000000000000000000000000000000000081528c356004820152928c013560248401528b0135604483015260608b0135606483015260808b0135608483015260a08b013560a48301526001600160a01b03169063219f5d179060c4016060604051808303816000875af11580156111bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111df91906155bb565b6040516370a0823160e01b8152306004820152929a50909850965060009083906001600160a01b038716906370a0823190602401602060405180830381865afa158015611230573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061125491906155a2565b61125e9190615608565b6040516370a0823160e01b815230600482015290915060009083906001600160a01b038716906370a0823190602401602060405180830381865afa1580156112aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ce91906155a2565b6112d89190615608565b905081156112eb576112eb863384613fc2565b80156112fc576112fc853383613fc2565b6040518c81527f38f5d789b3e0e71e68d20081e98d4b02ae7ecab7482b6634306b2261e90f806f9060200160405180910390a1505050505050506113406001600255565b9250925092565b61134f613d10565b600c80546001600160a01b0319166001600160a01b0383169081179091556040519081527f48af0f3916eee80364290b1aca1b04532ba7394a23ceeb066b5df1aa9c5b51c4906020015b60405180910390a150565b6000806000806113b26135c2565b6113be888888886136f4565b929650909450925090506113d26001600255565b945094509450949050565b6113e5613d10565b6113ed6135c2565b6113f8838383613fc2565b6114026001600255565b505050565b61140f6135c2565b600c546001600160a01b03166114675760405162461bcd60e51b815260206004820152600760248201527f4e4f5420534554000000000000000000000000000000000000000000000000006044820152606401610c58565b61147081613619565b6000818152600f60209081526040918290208251610160810184528154815260018201546001600160a01b039081169382018490526002830154811682860152600383015460608301819052600480850154831660808501526005850154831660a08501526006850154831660c08501526007850154831660e08501526008850154610100850152600985015461ffff16610120850152600a90940154610140840152600c54955163095ea7b360e01b8152959091169285019290925260248401919091529163095ea7b390604401600060405180830381600087803b15801561155957600080fd5b505af115801561156d573d6000803e3d6000fd5b5050600c54602084015160608501516040517f4ef88bea000000000000000000000000000000000000000000000000000000008152600481018890526001600160a01b039283166024820152604481019190915291169250634ef88bea91506064016020604051808303816000875af11580156115ee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611612919061561b565b5060808101516001600160a01b031660009081526010602052604090206116399083613cf3565b506000828152600f60205260408082208281556001810180546001600160a01b0319908116909155600282018054821690556003820184905560048201805482169055600582018054821690556006820180548216905560078201805490911690556008810183905560098101805461ffff19169055600a0191909155517f97923ecdf32419caa09669588eaa60fcc1c41069814b4f4f52ec31e9fdec1aea906116e69084815260200190565b60405180910390a1506116f96001600255565b50565b611704613d10565b61170f6006826140ef565b506040516001600160a01b03821681527f80669cb83f5f4061c84fc5d3662ece37df30172baec31097d527ede111e413c290602001611399565b6117516135c2565b61175a82613619565b6001600160a01b03811633036117b25760405162461bcd60e51b815260206004820152600a60248201527f53414d45204f574e4552000000000000000000000000000000000000000000006044820152606401610c58565b6000828152600f60209081526040918290206005810180546001600160a01b0319166001600160a01b03861690811790915583518681523393810193909352928201929092527f7336363d3c1722824dac3c93d1256b57d394f59da51548af7e779e47c13fff10906060015b60405180910390a150610e2d6001600255565b6001600160a01b038116600090815260106020526040812061185290613d06565b92915050565b611860613d10565b61186a6000614104565b565b60015433906001600160a01b031681146118ee5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f74207468652060448201527f6e6577206f776e657200000000000000000000000000000000000000000000006064820152608401610c58565b6116f981614104565b6119326040518060a001604052806060815260200160008152602001600081526020016000815260200160006001600160a01b031681525090565b6003600061194160048561411d565b81526020019081526020016000206040518060a001604052908160008201805461196a9061563d565b80601f01602080910402602001604051908101604052809291908181526020018280546119969061563d565b80156119e35780601f106119b8576101008083540402835291602001916119e3565b820191906000526020600020905b8154815290600101906020018083116119c657829003601f168201915b50505091835250506001820154602082015260028201546040820152600382015460608201526004909101546001600160a01b031660809091015292915050565b611a2c613d10565b600d80546001600160a01b0319166001600160a01b0392909216919091179055565b6000611852600683614129565b604080516101608101825260008082526020808301829052828401829052606083018290526080830182905260a0830182905260c0830182905260e083018290526101008301829052610120830182905261014083018290526001600160a01b0386168252601090529182209091600f91611ad6908561411d565b815260208082019290925260409081016000208151610160810183528154815260018201546001600160a01b03908116948201949094526002820154841692810192909252600381015460608301526004810154831660808301526005810154831660a08301526006810154831660c0830152600781015490921660e08201526008820154610100820152600982015461ffff16610120820152600a909101546101408201529392505050565b600080611baa611b928761414b565b611b9b8761414b565b611ba48761414b565b86614594565b915091505b94509492505050565b6000611bc26135c2565b6000611bd46080840160608501614f8d565b6001600160a01b031603611c2a5760405162461bcd60e51b815260206004820152601960248201527f4f574e45522043414e4e4f54203d2061646472657373283029000000000000006044820152606401610c58565b6000611c3c60c0840160a08501614f8d565b6001600160a01b031603611c815760405162461bcd60e51b815260206004820152600c60248201526b21a7a62622a1aa2fa0a2222960a11b6044820152606401610c58565b6402540be4008260c001351080611c9d57506000198260c00135145b611cd85760405162461bcd60e51b815260206004820152600c60248201526b4d494c4c495345434f4e445360a01b6044820152606401610c58565b428260c0013511611d195760405162461bcd60e51b815260206004820152600b60248201526a1110551148141054d4d15160aa1b6044820152606401610c58565b6001600160a01b037f000000000000000000000000fa104eb3925a27e6263e05acc88f2e983a89063716635cb49b55611d59610100850160e08601615677565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815261ffff9091166004820152602401602060405180830381865afa158015611db0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dd4919061561b565b611e205760405162461bcd60e51b815260206004820152600760248201527f434f554e545259000000000000000000000000000000000000000000000000006044820152606401610c58565b611e38611e306020840184614f8d565b600690614129565b611e845760405162461bcd60e51b815260206004820152601c60248201527f494e56414c4944204e465420504f534954494f4e204d414e41474552000000006044820152606401610c58565b611ebf6040518060a001604052806060815260200160008152602001600081526020016000815260200160006001600160a01b031681525090565b600d546001600160a01b03163303611f1957611edf61012084018461569b565b6000818110611ef057611ef06156e5565b9050602002810190611f0291906156fb565b810190611f0f9190615053565b604082015261201e565b6000611f2961012085018561569b565b90501115611fbd576008546001600160a01b03166332c07c9e611f5061012086018661569b565b336040518463ffffffff1660e01b8152600401611f6f9392919061576b565b6000604051808303816000875af1158015611f8e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611fb69190810190615815565b905061200b565b612008611fce6101008501856156fb565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612fd392505050565b90505b60608101511561201e5761201e8161462f565b61202b6020840184614f8d565b604051632142170760e11b8152336004820152306024820152602085013560448201526001600160a01b0391909116906342842e0e90606401600060405180830381600087803b15801561207e57600080fd5b505af1158015612092573d6000803e3d6000fd5b50506040805161018081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081019190915291506120fe9050565b61210b6020850185614f8d565b60405163133f757160e31b8152602086013560048201526001600160a01b0391909116906399fbab889060240161018060405180830381865afa158015612156573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061217a91906154c1565b505050506001600160801b031660e0890152600290810b60c08901520b60a087015262ffffff1660808601526001600160a01b03908116606086015216604084015250600090506121ce6020860186614f8d565b6001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa15801561220b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061222f91906158eb565b6040808401516060850151608086015192517f1698ee820000000000000000000000000000000000000000000000000000000081526001600160a01b039283166004820152908216602482015262ffffff9092166044830152919250600091831690631698ee8290606401602060405180830381865afa1580156122b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122db91906158eb565b90506122ea6020870187614f8d565b6001600160a01b031663fc6f78656040518060800160405280896020013581526020018960400160208101906123209190614f8d565b6001600160a01b0390811682526001600160801b0360208084018290526040938401829052835160e087901b7fffffffff0000000000000000000000000000000000000000000000000000000016815285516004820152908501519092166024830152918301518216604482015260609092015116606482015260840160408051808303816000875af11580156123bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123df9190615908565b50506020840151156125e55760006124076123fd6020890189614f8d565b8860200135614760565b90506124166020880188614f8d565b6001600160a01b0316630c49ccbe6040518060a001604052808a6020013581526020016127108960200151866001600160801b0316612455919061592c565b61245f9190615959565b6001600160801b031681526020016000815260200160008152602001428152506040518263ffffffff1660e01b81526004016124d99190600060a082019050825182526001600160801b03602084015116602083015260408301516040830152606083015160608301526080830151608083015292915050565b60408051808303816000875af11580156124f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061251b9190615908565b5061252b90506020880188614f8d565b6040805160808101825260208a8101358252600a546001600160a01b039081169183019182526001600160801b0383850181815260608501828152955163fc6f786560e01b815294516004860152925182166024850152915182166044840152925116606482015291169063fc6f78659060840160408051808303816000875af11580156125bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125e19190615908565b5050505b604080516101608101825260006020808301829052928201819052606082018190526080820181905260a0820181905260c0820181905260e0820181905261010082018190526101208201819052610140820152600e5481529061264b90880188614f8d565b6001600160a01b0390811660208084019190915290831660408301528701356060808301919091526126839060808901908901614f8d565b6001600160a01b03166080808301919091526126a59060a08901908901614f8d565b6001600160a01b031660c0808301919091526126c690880160a08901614f8d565b6001600160a01b031660e08083019190915260c0880135610100808401919091526126f691908901908901615677565b61ffff90811661012083019081526040878101516101408501908152600e80546000908152600f602090815284822088518155908801516001820180546001600160a01b03199081166001600160a01b03938416179091559589015160028301805488169183169190911790556060808a015160038401556080808b01516004850180548a1691851691909117905560a08b01516005850180548a1691851691909117905560c08b01516006850180548a1691851691909117905560e08b01516007850180549099169316929092179096556101008901516008830155955160098201805461ffff191691909816179096559151600a90950194909455925461282b93909260109261280c918d01908d01614f8d565b6001600160a01b031681526020810191909152604001600020906147e3565b50600e805490600061283c8361596d565b9091555050805161284c906147ef565b5194505050505061285d6001600255565b919050565b61286a613d10565b6128726135c2565b6000816001600160a01b03168360405160006040518083038185875af1925050503d80600081146128bf576040519150601f19603f3d011682016040523d82523d6000602084013e6128c4565b606091505b50509050806129155760405162461bcd60e51b815260206004820152601960248201527f47617320746f6b656e207472616e73666572206661696c6564000000000000006044820152606401610c58565b50610e2d6001600255565b6129286135c2565b61293182613619565b6000828152600f60209081526040918290206006810180546001600160a01b0319166001600160a01b038616908117909155835186815292830152917fda22afd9d1e0640f160cada74dec56452db8535daf46772df2c5f7a3af46485f910161181e565b61299d6135c2565b6000828152600f6020526040902060058101546001600160a01b031633146129ef5760405162461bcd60e51b815260206004820152600560248201526427aba722a960d91b6044820152606401610c58565b60048101546001600160a01b03166000818152601060205260409020612a159085613cf3565b50600482018054336001600160a01b031991821681179092556005840180548216905560078401805482166001600160a01b03871617905560068401805490911690556000908152601060205260409020612a7090856147e3565b50604080518581526001600160a01b03838116602083015233828401528516606082015290517f4e602365e8ca79d90aa843bdcc20695568e4a35d5ff284b2f9a6e4c1ff9120529181900360800190a15050610e2d6001600255565b612ad46135c2565b612add82613619565b6000828152600f6020526040902060088101548211612b405760405162461bcd60e51b8152600401610c589060208082526004908201527f4441544500000000000000000000000000000000000000000000000000000000604082015260600190565b428211612b7d5760405162461bcd60e51b815260206004820152600b60248201526a1110551148141054d4d15160aa1b6044820152606401610c58565b6402540be400821080612b91575060001982145b612bcc5760405162461bcd60e51b815260206004820152600c60248201526b4d494c4c495345434f4e445360a01b6044820152606401610c58565b6008810182905560408051848152602081018490527fefaff1b90138281d215452c67f793017f52e456f65c28ac63f5309a89a059b47910161181e565b612c116135c2565b612c1a82613619565b6001600160a01b038116612c5f5760405162461bcd60e51b815260206004820152600c60248201526b21a7a62622a1aa2fa0a2222960a11b6044820152606401610c58565b6000828152600f60209081526040918290206007810180546001600160a01b0319166001600160a01b038616908117909155835186815292830152917ff47f77d5d198f5b58faaca8c7dc86ebe53925091c07487a01ec62159ff16664e910161181e565b612ccb613d10565b600081604051602001612cde9190615986565b604051602081830303815290604052805190602001209050604051602001612d1390661111519055531560ca1b815260070190565b604051602081830303815290604052805190602001208103612d615760405162461bcd60e51b81526020600482015260076024820152661111519055531560ca1b6044820152606401610c58565b612d6c600482614a40565b612db85760405162461bcd60e51b815260206004820152600e60248201527f466565206e6f74206578697374730000000000000000000000000000000000006044820152606401610c58565b612dc3600482613cf3565b50600081815260036020526040812090612ddd8282614dd8565b5060006001820181905560028201819055600382015560040180546001600160a01b03191690556040518181527faea1931d5fe74928dff1db9836d2d9de778b60cb4afc9ec70c9a1f16b58598a59060200160405180910390a15050565b612e43613d10565b600085604051602001612e569190615986565b60408051601f19818403018152828252805160209182012060a084018352898452838201899052838301889052606084018790526001600160a01b038616608085015260008181526003909252919020825191935082918190612eb990826159e8565b50602082015160018201556040820151600282015560608201516003820155608090910151600491820180546001600160a01b0319166001600160a01b03909216919091179055612f0a9083614a40565b612f7457612f196004836147e3565b507f335d96fad821252e8298f51336937e44332b3731a3c3f249b2cdb77652b33e4f8282600001518360200151846040015185606001518660800151604051612f6796959493929190615aa8565b60405180910390a1612fca565b7fdd151e7029525c623e7c09af0f71271bd7642edd1bf2f64d97bc552faba7c86d8282600001518360200151846040015185606001518660800151604051612fc196959493929190615aa8565b60405180910390a15b50505050505050565b61300e6040518060a001604052806060815260200160008152602001600081526020016000815260200160006001600160a01b031681525090565b6000826040516020016130219190615986565b60408051601f1981840301815291905280516020909101209050613046600482614a40565b6130925760405162461bcd60e51b815260206004820152600960248201527f4e4f5420464f554e4400000000000000000000000000000000000000000000006044820152606401610c58565b60008181526003602052604090819020815160a081019092528054829082906130ba9061563d565b80601f01602080910402602001604051908101604052809291908181526020018280546130e69061563d565b80156131335780601f1061310857610100808354040283529160200191613133565b820191906000526020600020905b81548152906001019060200180831161311657829003601f168201915b50505091835250506001820154602082015260028201546040820152600382015460608201526004909101546001600160a01b03166080909101529392505050565b61317d613d10565b6000828152600f60205260409020600a81015482106131de5760405162461bcd60e51b815260206004820152600160248201527f4c000000000000000000000000000000000000000000000000000000000000006044820152606401610c58565b600a810182905560408051848152602081018490527fa4b63b21571e7c2b944a681b0a39cda220f85f67aaa7aa4d23fcf7d31e2379a391015b60405180910390a1505050565b60008061322f6135c2565b61323884613619565b6000848152600f60209081526040918290208251610160810184528154815260018201546001600160a01b039081169382019390935260028201548316938101939093526003810154606084018190526004820154831660808501526005820154831660a08501526006820154831660c0850152600782015490921660e08401526008810154610100840152600981015461ffff16610120840152600a01546101408301528435146133155760405162461bcd60e51b815260206004820152600660248201526513919508125160d21b6044820152606401610c58565b6000198161010001510361335a5760405162461bcd60e51b815260206004820152600c60248201526b455445524e414c5f4c4f434b60a01b6044820152606401610c58565b42816101000151106133985760405162461bcd60e51b81526020600482015260076024820152661393d50816515560ca1b6044820152606401610c58565b6133ab85336001600160801b03806136f4565b5050505080602001516001600160a01b0316630c49ccbe856040518263ffffffff1660e01b81526004016133df9190615aef565b60408051808303816000875af11580156133fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134219190615908565b602083810151604080516080810182526060808801518252339482019485526001600160801b03828401818152918301818152935163fc6f786560e01b81529251600484015294516001600160a01b0390811660248401529051851660448301529151909316606484015293965091945091169063fc6f78659060840160408051808303816000875af11580156134bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134e09190615908565b50506040518581527fffeb250f5933abd95c7c8e2c0317b8041dc9c5a309b73fa772f533ddd085dd3a9060200160405180910390a1506135206001600255565b9250929050565b61352f613d10565b600180546001600160a01b0383166001600160a01b031990911681179091556135606000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6135a0613d10565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b60028054036136135760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c58565b60028055565b6000818152600f60209081526040918290208251610160810184528154815260018201546001600160a01b039081169382019390935260028201548316938101939093526003810154606084015260048101548216608084018190526005820154831660a08501526006820154831660c0850152600782015490921660e08401526008810154610100840152600981015461ffff16610120840152600a01546101408301523314610e2d5760405162461bcd60e51b815260206004820152600560248201526427aba722a960d91b6044820152606401610c58565b6000848152600f602090815260408083208151610160810183528154815260018201546001600160a01b039081169482019490945260028201548416928101929092526003810154606083015260048101548316608083018190526005820154841660a08401526006820154841660c08401526007820154841660e0840152600882015461010084015260098083015461ffff16610120850152600a909201546101408401529054849384938493909233921682149114806137c2575060c08201516001600160a01b031633145b806137ca5750805b6137fe5760405162461bcd60e51b815260206004820152600560248201526427aba722a960d91b6044820152606401610c58565b8161014001516000036138d3576020808301516040805160808101825260608087015182526001600160a01b038e81169583019586526001600160801b03808f168486019081528e8216938501938452945163fc6f786560e01b815293516004850152955181166024840152925185166044830152519093166064840152169063fc6f78659060840160408051808303816000875af11580156138a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138c99190615908565b9096509450613ce6565b60008083602001516001600160a01b03166399fbab8885606001516040518263ffffffff1660e01b815260040161390c91815260200190565b61018060405180830381865afa15801561392a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061394e91906154c1565b50506040516370a0823160e01b8152306004820152979b5095995060009850506001600160a01b038a1696506370a0823195602401945061398f9350505050565b602060405180830381865afa1580156139ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139d091906155a2565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038416906370a0823190602401602060405180830381865afa158015613a1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a3e91906155a2565b905085602001516001600160a01b031663fc6f7865604051806080016040528089606001518152602001306001600160a01b031681526020018f6001600160801b031681526020018e6001600160801b03168152506040518263ffffffff1660e01b8152600401613aed9190815181526020808301516001600160a01b0316908201526040808301516001600160801b0390811691830191909152606092830151169181019190915260800190565b60408051808303816000875af1158015613b0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b2f9190615908565b50506040516370a0823160e01b815230600482015282906001600160a01b038616906370a0823190602401602060405180830381865afa158015613b77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b9b91906155a2565b613ba59190615608565b6040516370a0823160e01b815230600482015290925081906001600160a01b038516906370a0823190602401602060405180830381865afa158015613bee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c1291906155a2565b613c1c9190615608565b9050600085613c3657600b546001600160a01b0316613c38565b8d5b9050600086613c47578e613c4d565b8760e001515b90508315613c975761271088610140015185613c69919061592c565b613c739190615959565b9950613c8086838c613fc2565b613c8a8a85615608565b9b50613c9786828e613fc2565b8215613cdf5761271088610140015184613cb1919061592c565b613cbb9190615959565b9850613cc885838b613fc2565b613cd28984615608565b9a50613cdf85828d613fc2565b5050505050505b5050945094509450949050565b6000613cff8383614a58565b9392505050565b6000611852825490565b6000546001600160a01b0316331461186a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c58565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03167f23b872dd000000000000000000000000000000000000000000000000000000001790529151600092839290881691613de79190615986565b6000604051808303816000865af19150503d8060008114613e24576040519150601f19603f3d011682016040523d82523d6000602084013e613e29565b606091505b5091509150818015613e53575080511580613e53575080806020019051810190613e53919061561b565b613e9f5760405162461bcd60e51b815260206004820152600360248201527f53544600000000000000000000000000000000000000000000000000000000006044820152606401610c58565b505050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1790529151600092839290871691613f039190615986565b6000604051808303816000865af19150503d8060008114613f40576040519150601f19603f3d011682016040523d82523d6000602084013e613f45565b606091505b5091509150818015613f6f575080511580613f6f575080806020019051810190613f6f919061561b565b613fbb5760405162461bcd60e51b815260206004820152600260248201527f53410000000000000000000000000000000000000000000000000000000000006044820152606401610c58565b5050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b03167fa9059cbb0000000000000000000000000000000000000000000000000000000017905291516000928392908716916140379190615986565b6000604051808303816000865af19150503d8060008114614074576040519150601f19603f3d011682016040523d82523d6000602084013e614079565b606091505b50915091508180156140a35750805115806140a35750808060200190518101906140a3919061561b565b613fbb5760405162461bcd60e51b815260206004820152600260248201527f53540000000000000000000000000000000000000000000000000000000000006044820152606401610c58565b6000613cff836001600160a01b038416614b52565b600180546001600160a01b03191690556116f981614ba1565b6000613cff8383614bf1565b6001600160a01b03811660009081526001830160205260408120541515613cff565b60008060008360020b12614162578260020b61416f565b8260020b61416f90615b39565b905061417e620d89e719615b71565b60020b8111156141d05760405162461bcd60e51b815260206004820152600160248201527f54000000000000000000000000000000000000000000000000000000000000006044820152606401610c58565b6000816001166000036141f457700100000000000000000000000000000000614206565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615614245576080614240826ffff97272373d413259a46990580e213a61592c565b901c90505b600482161561426f57608061426a826ffff2e50f5f656932ef12357cf3c7fdcc61592c565b901c90505b6008821615614299576080614294826fffe5caca7e10e4e61c3624eaa0941cd061592c565b901c90505b60108216156142c35760806142be826fffcb9843d60f6159c9db58835c92664461592c565b901c90505b60208216156142ed5760806142e8826fff973b41fa98c081472e6896dfb254c061592c565b901c90505b6040821615614317576080614312826fff2ea16466c96a3843ec78b326b5286161592c565b901c90505b608082161561434157608061433c826ffe5dee046a99a2a811c461f1969c305361592c565b901c90505b61010082161561436c576080614367826ffcbe86c7900a88aedcffc83b479aa3a461592c565b901c90505b610200821615614397576080614392826ff987a7253ac413176f2b074cf7815e5461592c565b901c90505b6104008216156143c25760806143bd826ff3392b0822b70005940c7a398e4b70f361592c565b901c90505b6108008216156143ed5760806143e8826fe7159475a2c29b7443b29c7fa6e889d961592c565b901c90505b611000821615614418576080614413826fd097f3bdfd2022b8845ad8f792aa582561592c565b901c90505b61200082161561444357608061443e826fa9f746462d870fdf8a65dc1f90e061e561592c565b901c90505b61400082161561446e576080614469826f70d869a156d2a1b890bb3df62baf32f761592c565b901c90505b618000821615614499576080614494826f31be135f97d08fd981231505542fcfa661592c565b901c90505b620100008216156144c55760806144c0826f09aa508b5b7a84e1c677de54f3e99bc961592c565b901c90505b620200008216156144f05760806144eb826e5d6af8dedb81196699c329225ee60461592c565b901c90505b6204000082161561451a576080614515826d2216e584f5fa1ea926041bedfe9861592c565b901c90505b6208000082161561454257608061453d826b048a170391f7dc42444e8fa261592c565b901c90505b60008460020b131561455d5761455a81600019615959565b90505b61456c64010000000082615b93565b1561457857600161457b565b60005b61458c9060ff16602083901c615ba7565b949350505050565b600080836001600160a01b0316856001600160a01b031611156145b5579293925b846001600160a01b0316866001600160a01b0316116145e0576145d9858585614c1b565b9150611baf565b836001600160a01b0316866001600160a01b0316101561461957614605868585614c1b565b9150614612858785614c97565b9050611baf565b614624858585614c97565b905094509492505050565b60808101516001600160a01b031661473b57806060015134146146945760405162461bcd60e51b815260206004820152600860248201527f464c4154204645450000000000000000000000000000000000000000000000006044820152606401610c58565b600a5460608201516040516000926001600160a01b031691908381818185875af1925050503d80600081146146e5576040519150601f19603f3d011682016040523d82523d6000602084013e6146ea565b606091505b5050905080610e2d5760405162461bcd60e51b815260206004820152601960248201527f47617320746f6b656e207472616e73666572206661696c6564000000000000006044820152606401610c58565b6080810151600a5460608301516116f9929133916001600160a01b0390911690613d6a565b60405163133f757160e31b81526004810182905260009081906001600160a01b038516906399fbab889060240161018060405180830381865afa1580156147ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147cf91906154c1565b50929e9d5050505050505050505050505050565b6000613cff8383614b52565b6000818152600f60209081526040808320815161016080820184528254825260018301546001600160a01b039081168387015260028401548116838601526003840154606080850191909152600485015482166080808601919091526005860154831660a0808701919091526006870154841660c080880191909152600788015490941660e080880191909152600888015461010080890191909152600989015461ffff16610120808a0191909152600a90990154610140808a01919091528a5161018081018c528d81529b8c018d9052998b018c9052938a018b90529189018a9052880189905291870188905290860187905285018690529184018590529183018490528201929092526020820151606083015160405163133f757160e31b81526001600160a01b03909216916399fbab88916149339160040190815260200190565b61018060405180830381865afa158015614951573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061497591906154c1565b5050506001600160801b0390911660e0808b0191909152600292830b60c0808c01919091529390920b60a08a01525062ffffff9092166080808901919091526001600160a01b039384166060808a019190915293909416604080890191909152885160208a0151948a0151958a0151928a0151938a01516101008b01516101208c01516101408d01518d86015195517f3bf9c85fbe37d401523942f10940796acef64062e1a1c45647978e32f4969f5c9c506132179b50949997959394929391929091908d90615bba565b60008181526001830160205260408120541515613cff565b60008181526001830160205260408120548015614b41576000614a7c600183615608565b8554909150600090614a9090600190615608565b9050818114614af5576000866000018281548110614ab057614ab06156e5565b9060005260206000200154905080876000018481548110614ad357614ad36156e5565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080614b0657614b06615cf2565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050611852565b6000915050611852565b5092915050565b6000818152600183016020526040812054614b9957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611852565b506000611852565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000826000018281548110614c0857614c086156e5565b9060005260206000200154905092915050565b6000826001600160a01b0316846001600160a01b03161115614c3b579192915b6001600160a01b038416614c8d7bffffffffffffffffffffffffffffffff000000000000000000000000606085901b16614c758787615d08565b6001600160a01b0316866001600160a01b0316614ce6565b61458c9190615959565b6000826001600160a01b0316846001600160a01b03161115614cb7579192915b61458c6001600160801b038316614cce8686615d08565b6001600160a01b03166c010000000000000000000000005b6000808060001985870985870292508281108382030391505080600003614d2057838281614d1657614d16615943565b0492505050613cff565b808411614d6f5760405162461bcd60e51b815260206004820152601560248201527f4d6174683a206d756c446976206f766572666c6f7700000000000000000000006044820152606401610c58565b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b508054614de49061563d565b6000825580601f10614df4575050565b601f0160209004906000526020600020908101906116f991905b80821115614e225760008155600101614e0e565b5090565b6001600160a01b03811681146116f957600080fd5b60008060408385031215614e4e57600080fd5b823591506020830135614e6081614e26565b809150509250929050565b600080600060608486031215614e8057600080fd5b8335614e8b81614e26565b92506020840135614e9b81614e26565b91506040840135614eab81614e26565b809150509250925092565b600080600080600060808688031215614ece57600080fd5b8535614ed981614e26565b94506020860135614ee981614e26565b935060408601359250606086013567ffffffffffffffff80821115614f0d57600080fd5b818801915088601f830112614f2157600080fd5b813581811115614f3057600080fd5b896020828501011115614f4257600080fd5b9699959850939650602001949392505050565b60008082840360e0811215614f6957600080fd5b8335925060c0601f1982011215614f7f57600080fd5b506020830190509250929050565b600060208284031215614f9f57600080fd5b8135613cff81614e26565b6001600160801b03811681146116f957600080fd5b60008060008060808587031215614fd557600080fd5b843593506020850135614fe781614e26565b92506040850135614ff781614faa565b9150606085013561500781614faa565b939692955090935050565b60008060006060848603121561502757600080fd5b833561503281614e26565b9250602084013561504281614e26565b929592945050506040919091013590565b60006020828403121561506557600080fd5b5035919050565b60005b8381101561508757818101518382015260200161506f565b50506000910152565b600081518084526150a881602086016020860161506c565b601f01601f19169290920160200192915050565b602081526000825160a060208401526150d860c0840182615090565b90506020840151604084015260408401516060840152606084015160808401526001600160a01b0360808501511660a08401528091505092915050565b6000806040838503121561512857600080fd5b823561513381614e26565b946020939093013593505050565b81518152602080830151610160830191615165908401826001600160a01b03169052565b50604083015161518060408401826001600160a01b03169052565b506060830151606083015260808301516151a560808401826001600160a01b03169052565b5060a08301516151c060a08401826001600160a01b03169052565b5060c08301516151db60c08401826001600160a01b03169052565b5060e08301516151f660e08401826001600160a01b03169052565b5061010083810151908301526101208084015161ffff811682850152505061014092830151919092015290565b8060020b81146116f957600080fd5b6000806000806080858703121561524857600080fd5b843561525381615223565b9350602085013561526381615223565b92506040850135614ff781615223565b60006020828403121561528557600080fd5b813567ffffffffffffffff81111561529c57600080fd5b82016101408185031215613cff57600080fd5b600080604083850312156152c257600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b60405160a0810167ffffffffffffffff8111828210171561530a5761530a6152d1565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715615339576153396152d1565b604052919050565b600067ffffffffffffffff82111561535b5761535b6152d1565b50601f01601f191660200190565b600082601f83011261537a57600080fd5b813561538d61538882615341565b615310565b8181528460208386010111156153a257600080fd5b816020850160208301376000918101602001919091529392505050565b6000602082840312156153d157600080fd5b813567ffffffffffffffff8111156153e857600080fd5b61458c84828501615369565b600080600080600060a0868803121561540c57600080fd5b853567ffffffffffffffff81111561542357600080fd5b61542f88828901615369565b955050602086013593506040860135925060608601359150608086013561545581614e26565b809150509295509295909350565b60008082840360c081121561547757600080fd5b8335925060a0601f1982011215614f7f57600080fd5b805161285d81614e26565b805162ffffff8116811461285d57600080fd5b805161285d81615223565b805161285d81614faa565b6000806000806000806000806000806000806101808d8f0312156154e457600080fd5b8c516bffffffffffffffffffffffff8116811461550057600080fd5b9b5061550e60208e0161548d565b9a5061551c60408e0161548d565b995061552a60608e0161548d565b985061553860808e01615498565b975061554660a08e016154ab565b965061555460c08e016154ab565b955061556260e08e016154b6565b94506101008d015193506101208d015192506155816101408e016154b6565b91506155906101608e016154b6565b90509295989b509295989b509295989b565b6000602082840312156155b457600080fd5b5051919050565b6000806000606084860312156155d057600080fd5b83516155db81614faa565b602085015160409095015190969495509392505050565b634e487b7160e01b600052601160045260246000fd5b81810381811115611852576118526155f2565b60006020828403121561562d57600080fd5b81518015158114613cff57600080fd5b600181811c9082168061565157607f821691505b60208210810361567157634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561568957600080fd5b813561ffff81168114613cff57600080fd5b6000808335601e198436030181126156b257600080fd5b83018035915067ffffffffffffffff8211156156cd57600080fd5b6020019150600581901b360382131561352057600080fd5b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261571257600080fd5b83018035915067ffffffffffffffff82111561572d57600080fd5b60200191503681900382131561352057600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6040808252810183905260006060600585901b8301810190830186835b878110156157fc57858403605f190183528135368a9003601e190181126157ae57600080fd5b8901602081810191359067ffffffffffffffff8211156157cd57600080fd5b8136038313156157dc57600080fd5b6157e7878385615742565b96509485019493909301925050600101615788565b5050506001600160a01b0384166020840152905061458c565b6000602080838503121561582857600080fd5b825167ffffffffffffffff8082111561584057600080fd5b9084019060a0828703121561585457600080fd5b61585c6152e7565b82518281111561586b57600080fd5b83019150601f8201871361587e57600080fd5b815161588c61538882615341565b81815288868386010111156158a057600080fd5b6158af8287830188870161506c565b8083525050838301518482015260408301516040820152606083015160608201526158dc6080840161548d565b60808201529695505050505050565b6000602082840312156158fd57600080fd5b8151613cff81614e26565b6000806040838503121561591b57600080fd5b505080516020909101519092909150565b8082028115828204841417611852576118526155f2565b634e487b7160e01b600052601260045260246000fd5b60008261596857615968615943565b500490565b60006001820161597f5761597f6155f2565b5060010190565b6000825161599881846020870161506c565b9190910192915050565b601f82111561140257600081815260208120601f850160051c810160208610156159c95750805b601f850160051c820191505b81811015613e9f578281556001016159d5565b815167ffffffffffffffff811115615a0257615a026152d1565b615a1681615a10845461563d565b846159a2565b602080601f831160018114615a4b5760008415615a335750858301515b600019600386901b1c1916600185901b178555613e9f565b600085815260208120601f198616915b82811015615a7a57888601518255948401946001909101908401615a5b565b5085821015615a985787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b86815260c060208201526000615ac160c0830188615090565b90508560408301528460608301528360808301526001600160a01b03831660a0830152979650505050505050565b8135815260a081016020830135615b0581614faa565b6001600160801b03811660208401525060408301356040830152606083013560608301526080830135608083015292915050565b60007f80000000000000000000000000000000000000000000000000000000000000008203615b6a57615b6a6155f2565b5060000390565b60008160020b627fffff198103615b8a57615b8a6155f2565b60000392915050565b600082615ba257615ba2615943565b500690565b80820180821115611852576118526155f2565b60006102c0820190508c82526001600160a01b03808d1660208401528b6040840152808b166060840152808a16608084015280891660a08401528760c084015261ffff871660e08401526101008681850152610120828716818601526101409250615c3583860187516bffffffffffffffffffffffff169052565b6020860151610160615c51818801836001600160a01b03169052565b60408801516001600160a01b039081166101808901526060890151166101a0880152608088015162ffffff166101c088015260a0880151600290810b6101e089015260c0890151900b61020088015260e08801516001600160801b039081166102208901529388015161024088015291870151610260870152509185015181166102808501529301519092166102a0909101529a9950505050505050505050565b634e487b7160e01b600052603160045260246000fd5b6001600160a01b03828116828216039080821115614b4b57614b4b6155f256fea26469706673582212200c3452abb516d33cc906ea746e79734a28a7f0f0b868369d4386ec52f4eccf3964736f6c63430008130033

Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.