S Price: $0.529857 (+9.49%)
    /

    Contract Diff Checker

    Contract Name:
    LpLocker

    Contract Source Code:

    // SPDX-License-Identifier: MIT
    // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
    
    pragma solidity ^0.8.20;
    
    import {Context} from "../utils/Context.sol";
    
    /**
     * @dev Contract module which provides a basic access control mechanism, where
     * there is an account (an owner) that can be granted exclusive access to
     * specific functions.
     *
     * The initial owner is set to the address provided by the deployer. This can
     * later be changed with {transferOwnership}.
     *
     * This module is used through inheritance. It will make available the modifier
     * `onlyOwner`, which can be applied to your functions to restrict their use to
     * the owner.
     */
    abstract contract Ownable is Context {
        address private _owner;
    
        /**
         * @dev The caller account is not authorized to perform an operation.
         */
        error OwnableUnauthorizedAccount(address account);
    
        /**
         * @dev The owner is not a valid owner account. (eg. `address(0)`)
         */
        error OwnableInvalidOwner(address owner);
    
        event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    
        /**
         * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
         */
        constructor(address initialOwner) {
            if (initialOwner == address(0)) {
                revert OwnableInvalidOwner(address(0));
            }
            _transferOwnership(initialOwner);
        }
    
        /**
         * @dev Throws if called by any account other than the owner.
         */
        modifier onlyOwner() {
            _checkOwner();
            _;
        }
    
        /**
         * @dev Returns the address of the current owner.
         */
        function owner() public view virtual returns (address) {
            return _owner;
        }
    
        /**
         * @dev Throws if the sender is not the owner.
         */
        function _checkOwner() internal view virtual {
            if (owner() != _msgSender()) {
                revert OwnableUnauthorizedAccount(_msgSender());
            }
        }
    
        /**
         * @dev Leaves the contract without owner. It will not be possible to call
         * `onlyOwner` functions. Can only be called by the current owner.
         *
         * NOTE: Renouncing ownership will leave the contract without an owner,
         * thereby disabling any functionality that is only available to the owner.
         */
        function renounceOwnership() public virtual onlyOwner {
            _transferOwnership(address(0));
        }
    
        /**
         * @dev Transfers ownership of the contract to a new account (`newOwner`).
         * Can only be called by the current owner.
         */
        function transferOwnership(address newOwner) public virtual onlyOwner {
            if (newOwner == address(0)) {
                revert OwnableInvalidOwner(address(0));
            }
            _transferOwnership(newOwner);
        }
    
        /**
         * @dev Transfers ownership of the contract to a new account (`newOwner`).
         * Internal function without access restriction.
         */
        function _transferOwnership(address newOwner) internal virtual {
            address oldOwner = _owner;
            _owner = newOwner;
            emit OwnershipTransferred(oldOwner, newOwner);
        }
    }

    // SPDX-License-Identifier: MIT
    // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
    
    pragma solidity ^0.8.20;
    
    /**
     * @dev Interface of the ERC20 standard as defined in the EIP.
     */
    interface IERC20 {
        /**
         * @dev Emitted when `value` tokens are moved from one account (`from`) to
         * another (`to`).
         *
         * Note that `value` may be zero.
         */
        event Transfer(address indexed from, address indexed to, uint256 value);
    
        /**
         * @dev Emitted when the allowance of a `spender` for an `owner` is set by
         * a call to {approve}. `value` is the new allowance.
         */
        event Approval(address indexed owner, address indexed spender, uint256 value);
    
        /**
         * @dev Returns the value of tokens in existence.
         */
        function totalSupply() external view returns (uint256);
    
        /**
         * @dev Returns the value of tokens owned by `account`.
         */
        function balanceOf(address account) external view returns (uint256);
    
        /**
         * @dev Moves a `value` amount of tokens from the caller's account to `to`.
         *
         * Returns a boolean value indicating whether the operation succeeded.
         *
         * Emits a {Transfer} event.
         */
        function transfer(address to, uint256 value) external returns (bool);
    
        /**
         * @dev Returns the remaining number of tokens that `spender` will be
         * allowed to spend on behalf of `owner` through {transferFrom}. This is
         * zero by default.
         *
         * This value changes when {approve} or {transferFrom} are called.
         */
        function allowance(address owner, address spender) external view returns (uint256);
    
        /**
         * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
         * caller's tokens.
         *
         * Returns a boolean value indicating whether the operation succeeded.
         *
         * IMPORTANT: Beware that changing an allowance with this method brings the risk
         * that someone may use both the old and the new allowance by unfortunate
         * transaction ordering. One possible solution to mitigate this race
         * condition is to first reduce the spender's allowance to 0 and set the
         * desired value afterwards:
         * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
         *
         * Emits an {Approval} event.
         */
        function approve(address spender, uint256 value) external returns (bool);
    
        /**
         * @dev Moves a `value` amount of tokens from `from` to `to` using the
         * allowance mechanism. `value` is then deducted from the caller's
         * allowance.
         *
         * Returns a boolean value indicating whether the operation succeeded.
         *
         * Emits a {Transfer} event.
         */
        function transferFrom(address from, address to, uint256 value) external returns (bool);
    }

    // SPDX-License-Identifier: MIT
    // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)
    
    pragma solidity ^0.8.20;
    
    import {IERC165} from "../../utils/introspection/IERC165.sol";
    
    /**
     * @dev Required interface of an ERC721 compliant contract.
     */
    interface IERC721 is IERC165 {
        /**
         * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
         */
        event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
    
        /**
         * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
         */
        event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
    
        /**
         * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
         */
        event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
    
        /**
         * @dev Returns the number of tokens in ``owner``'s account.
         */
        function balanceOf(address owner) external view returns (uint256 balance);
    
        /**
         * @dev Returns the owner of the `tokenId` token.
         *
         * Requirements:
         *
         * - `tokenId` must exist.
         */
        function ownerOf(uint256 tokenId) external view returns (address owner);
    
        /**
         * @dev Safely transfers `tokenId` token from `from` to `to`.
         *
         * Requirements:
         *
         * - `from` cannot be the zero address.
         * - `to` cannot be the zero address.
         * - `tokenId` token must exist and be owned by `from`.
         * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
         * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
         *   a safe transfer.
         *
         * Emits a {Transfer} event.
         */
        function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
    
        /**
         * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
         * are aware of the ERC721 protocol to prevent tokens from being forever locked.
         *
         * Requirements:
         *
         * - `from` cannot be the zero address.
         * - `to` cannot be the zero address.
         * - `tokenId` token must exist and be owned by `from`.
         * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
         *   {setApprovalForAll}.
         * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
         *   a safe transfer.
         *
         * Emits a {Transfer} event.
         */
        function safeTransferFrom(address from, address to, uint256 tokenId) external;
    
        /**
         * @dev Transfers `tokenId` token from `from` to `to`.
         *
         * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
         * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
         * understand this adds an external call which potentially creates a reentrancy vulnerability.
         *
         * Requirements:
         *
         * - `from` cannot be the zero address.
         * - `to` cannot be the zero address.
         * - `tokenId` token must be owned by `from`.
         * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
         *
         * Emits a {Transfer} event.
         */
        function transferFrom(address from, address to, uint256 tokenId) external;
    
        /**
         * @dev Gives permission to `to` to transfer `tokenId` token to another account.
         * The approval is cleared when the token is transferred.
         *
         * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
         *
         * Requirements:
         *
         * - The caller must own the token or be an approved operator.
         * - `tokenId` must exist.
         *
         * Emits an {Approval} event.
         */
        function approve(address to, uint256 tokenId) external;
    
        /**
         * @dev Approve or remove `operator` as an operator for the caller.
         * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
         *
         * Requirements:
         *
         * - The `operator` cannot be the address zero.
         *
         * Emits an {ApprovalForAll} event.
         */
        function setApprovalForAll(address operator, bool approved) external;
    
        /**
         * @dev Returns the account approved for `tokenId` token.
         *
         * Requirements:
         *
         * - `tokenId` must exist.
         */
        function getApproved(uint256 tokenId) external view returns (address operator);
    
        /**
         * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
         *
         * See {setApprovalForAll}
         */
        function isApprovedForAll(address owner, address operator) external view returns (bool);
    }

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

    // SPDX-License-Identifier: MIT
    // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
    
    pragma solidity ^0.8.20;
    
    /**
     * @dev Collection of functions related to the address type
     */
    library Address {
        /**
         * @dev The ETH balance of the account is not enough to perform the operation.
         */
        error AddressInsufficientBalance(address account);
    
        /**
         * @dev There's no code at `target` (it is not a contract).
         */
        error AddressEmptyCode(address target);
    
        /**
         * @dev A call to an address target failed. The target may have reverted.
         */
        error FailedInnerCall();
    
        /**
         * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
         * `recipient`, forwarding all available gas and reverting on errors.
         *
         * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
         * of certain opcodes, possibly making contracts go over the 2300 gas limit
         * imposed by `transfer`, making them unable to receive funds via
         * `transfer`. {sendValue} removes this limitation.
         *
         * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
         *
         * IMPORTANT: because control is transferred to `recipient`, care must be
         * taken to not create reentrancy vulnerabilities. Consider using
         * {ReentrancyGuard} or the
         * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
         */
        function sendValue(address payable recipient, uint256 amount) internal {
            if (address(this).balance < amount) {
                revert AddressInsufficientBalance(address(this));
            }
    
            (bool success, ) = recipient.call{value: amount}("");
            if (!success) {
                revert FailedInnerCall();
            }
        }
    
        /**
         * @dev Performs a Solidity function call using a low level `call`. A
         * plain `call` is an unsafe replacement for a function call: use this
         * function instead.
         *
         * If `target` reverts with a revert reason or custom error, it is bubbled
         * up by this function (like regular Solidity function calls). However, if
         * the call reverted with no returned reason, this function reverts with a
         * {FailedInnerCall} error.
         *
         * Returns the raw returned data. To convert to the expected return value,
         * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
         *
         * Requirements:
         *
         * - `target` must be a contract.
         * - calling `target` with `data` must not revert.
         */
        function functionCall(address target, bytes memory data) internal returns (bytes memory) {
            return functionCallWithValue(target, data, 0);
        }
    
        /**
         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
         * but also transferring `value` wei to `target`.
         *
         * Requirements:
         *
         * - the calling contract must have an ETH balance of at least `value`.
         * - the called Solidity function must be `payable`.
         */
        function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
            if (address(this).balance < value) {
                revert AddressInsufficientBalance(address(this));
            }
            (bool success, bytes memory returndata) = target.call{value: value}(data);
            return verifyCallResultFromTarget(target, success, returndata);
        }
    
        /**
         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
         * but performing a static call.
         */
        function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
            (bool success, bytes memory returndata) = target.staticcall(data);
            return verifyCallResultFromTarget(target, success, returndata);
        }
    
        /**
         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
         * but performing a delegate call.
         */
        function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
            (bool success, bytes memory returndata) = target.delegatecall(data);
            return verifyCallResultFromTarget(target, success, returndata);
        }
    
        /**
         * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
         * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
         * unsuccessful call.
         */
        function verifyCallResultFromTarget(
            address target,
            bool success,
            bytes memory returndata
        ) internal view returns (bytes memory) {
            if (!success) {
                _revert(returndata);
            } else {
                // only check if target is a contract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                if (returndata.length == 0 && target.code.length == 0) {
                    revert AddressEmptyCode(target);
                }
                return returndata;
            }
        }
    
        /**
         * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
         * revert reason or with a default {FailedInnerCall} error.
         */
        function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
            if (!success) {
                _revert(returndata);
            } else {
                return returndata;
            }
        }
    
        /**
         * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
         */
        function _revert(bytes memory returndata) private pure {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert FailedInnerCall();
            }
        }
    }

    // SPDX-License-Identifier: MIT
    // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
    
    pragma solidity ^0.8.20;
    
    /**
     * @dev Provides information about the current execution context, including the
     * sender of the transaction and its data. While these are generally available
     * via msg.sender and msg.data, they should not be accessed in such a direct
     * manner, since when dealing with meta-transactions the account sending and
     * paying for execution may not be the actual sender (as far as an application
     * is concerned).
     *
     * This contract is only required for intermediate, library-like contracts.
     */
    abstract contract Context {
        function _msgSender() internal view virtual returns (address) {
            return msg.sender;
        }
    
        function _msgData() internal view virtual returns (bytes calldata) {
            return msg.data;
        }
    
        function _contextSuffixLength() internal view virtual returns (uint256) {
            return 0;
        }
    }

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

    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.25;
    
    import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
    
    interface NonFungibleContract is IERC721 {
        /// @notice Returns the position information associated with a given token ID.
        /// @dev Throws if the token ID is not valid.
        /// @param tokenId The ID of the token that represents the position
        /// @return nonce The nonce for permits
        /// @return operator The address that is approved for spending
        /// @return token0 The address of the token0 for a specific pool
        /// @return token1 The address of the token1 for a specific pool
        /// @return fee The fee associated with the pool
        /// @return tickLower The lower end of the tick range for the position
        /// @return tickUpper The higher end of the tick range for the position
        /// @return liquidity The liquidity of the position
        /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
        /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
        /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
        /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
        function positions(
            uint256 tokenId
        )
            external
            view
            returns (
                uint96 nonce,
                address operator,
                address token0,
                address token1,
                uint24 fee,
                int24 tickLower,
                int24 tickUpper,
                uint128 liquidity,
                uint256 feeGrowthInside0LastX128,
                uint256 feeGrowthInside1LastX128,
                uint128 tokensOwed0,
                uint128 tokensOwed1
            );
    
        struct CollectParams {
            uint256 tokenId;
            address recipient;
            uint128 amount0Max;
            uint128 amount1Max;
        }
    
        /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient
        /// @param params tokenId The ID of the NFT for which tokens are being collected,
        /// recipient The account that should receive the tokens,
        /// amount0Max The maximum amount of token0 to collect,
        /// amount1Max The maximum amount of token1 to collect
        /// @return amount0 The amount of fees collected in token0
        /// @return amount1 The amount of fees collected in token1
        function collect(
            CollectParams calldata params
        ) external payable returns (uint256 amount0, uint256 amount1);
    }

    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.26;
    
    import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
    import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
    import "@openzeppelin/contracts/access/Ownable.sol";
    import "@openzeppelin/contracts/utils/Context.sol";
    import "@openzeppelin/contracts/utils/Address.sol";
    import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
    import {NonFungibleContract} from "./IManager.sol";
    
    interface INonfungiblePositionManager is IERC721 {
        struct CollectParams {
            uint256 tokenId;
            address recipient;
            uint128 amount0Max;
            uint128 amount1Max;
        }
    
        function collect(
            CollectParams calldata params
        ) external payable returns (uint256 amount0, uint256 amount1);
    }
    
    contract LpLocker is Ownable, IERC721Receiver {
        event ERC721Released(address indexed token, uint256 amount);
    
        event LockId(uint256 _id);
    
        event LockDuration(uint256 _time);
        event Received(address indexed from, uint256 tokenId);
    
        event ClaimedFees(
            address indexed claimer,
            address indexed token0,
            address indexed token1,
            uint256 amount0,
            uint256 amount1,
            uint256 totalAmount1,
            uint256 totalAmount0
        );
    
        uint256 private _released;
        mapping(address => uint256) public _erc721Released;
        IERC721 private SafeERC721;
        uint64 private immutable _duration;
        address private immutable e721Token;
        bool private flag;
        NonFungibleContract private positionManager;
        string public constant version = "1.0";
        uint256 public _fee;
        address public _feeRecipient;
    
        /**
         * @dev Sets the sender as the initial owner, the beneficiary as the pending owner, and the duration for the lock
         * vesting duration of the vesting wallet.
         */
        constructor(
            address token,
            address beneficiary,
            uint64 durationSeconds,
            uint256 fee,
            address feeRecipient
        ) payable Ownable(beneficiary) {
            _duration = durationSeconds;
            SafeERC721 = IERC721(token);
            //already false but lets be safe
            flag = false;
            e721Token = token;
            _fee = fee;
            _feeRecipient = feeRecipient;
            emit LockDuration(durationSeconds);
        }
    
        function initializer(uint256 token_id) public {
            require(flag == false, "contract already initialized");
            _erc721Released[e721Token] = token_id;
            flag = true;
            positionManager = NonFungibleContract(e721Token);
    
            if (positionManager.ownerOf(token_id) != address(this)) {
                SafeERC721.transferFrom(owner(), address(this), token_id);
            }
    
            emit LockId(token_id);
        }
    
        /**
         * @dev Getter for the vesting duration.
         */
        function duration() public view virtual returns (uint256) {
            return _duration;
        }
    
        /**
         * @dev The contract should be able to receive Eth.
         */
        receive() external payable virtual {}
    
        /**
         * @dev Getter for the end timestamp.
         */
        function end() public view virtual returns (uint256) {
            return duration();
        }
    
        /**
         * @dev returns the tokenId of the locked LP
         */
        function released(address token) public view virtual returns (uint256) {
            return _erc721Released[token];
        }
    
        /**
         * @dev Release the token that have already vested.
         *
         * Emits a {ERC721Released} event.
         */
        function release() public virtual {
            if (vestingSchedule() != 0) {
                revert();
            }
            uint256 id = _erc721Released[e721Token];
            emit ERC721Released(e721Token, id);
            SafeERC721.transferFrom(address(this), owner(), id);
        }
    
        function withdrawERC20(address _token) public {
            require(owner() == msg.sender, "only owner can call");
            IERC20 IToken = IERC20(_token);
            IToken.transferFrom(address(this), owner(), IToken.balanceOf(owner()));
        }
    
        /**
         * @dev sourced from: https://docs.uniswap.org/contracts/v3/reference/deployments
         */
        function _getAddresses()
            internal
            view
            returns (
                address weth,
                INonfungiblePositionManager nonFungiblePositionManager
            )
        {
            uint256 chainId = block.chainid;
            // base
            if (chainId == 8453) {
                weth = 0x4200000000000000000000000000000000000006;
                nonFungiblePositionManager = INonfungiblePositionManager(
                    0x03a520b32C04BF3bEEf7BEb72E919cf822Ed34f1
                );
            }
            // degen chain
            if (chainId == 666666666) {
                // wrapped degen
                weth = 0xEb54dACB4C2ccb64F8074eceEa33b5eBb38E5387;
                nonFungiblePositionManager = INonfungiblePositionManager( // proxy swap
                    0x56c65e35f2Dd06f659BCFe327C4D7F21c9b69C2f
                );
            }
    
            if (chainId == 5112) {
                // wrapped ETH
                weth = 0x4200000000000000000000000000000000000006;
                nonFungiblePositionManager = INonfungiblePositionManager( // proxy swap
                    0xD088322Fa988225B3936555894E1D21c1A727859
                );
            }
    
            if (chainId == 56) {
                weth = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c;
                nonFungiblePositionManager = INonfungiblePositionManager(
                    0x46A15B0b27311cedF172AB29E4f4766fbE7F4364
                );
            }
    
            if (chainId == 146) {
                weth = 0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38;
                nonFungiblePositionManager = INonfungiblePositionManager(
                    0x77DcC9b09C6Ae94CDC726540735682A38e18d690
                );
            }
        }
    
        //Use collect fees to collect the fees
        function collectFees(address _recipient, uint256 _tokenId) public {
            require(owner() == msg.sender, "only owner can call");
            (
                ,
                INonfungiblePositionManager nonfungiblePositionManager
            ) = _getAddresses();
    
            if (_fee == 0) {
                (uint256 amount0, uint256 amount1) = nonfungiblePositionManager
                    .collect(
                        INonfungiblePositionManager.CollectParams({
                            recipient: _recipient,
                            amount0Max: type(uint128).max,
                            amount1Max: type(uint128).max,
                            tokenId: _tokenId
                        })
                    );
    
                emit ClaimedFees(
                    _recipient,
                    address(0),
                    address(0),
                    amount0,
                    amount1,
                    amount0,
                    amount1
                );
            } else {
                (uint256 amount0, uint256 amount1) = nonfungiblePositionManager
                    .collect(
                        INonfungiblePositionManager.CollectParams({
                            recipient: address(this),
                            amount0Max: type(uint128).max,
                            amount1Max: type(uint128).max,
                            tokenId: _tokenId
                        })
                    );
    
                (
                    ,
                    ,
                    address token0,
                    address token1,
                    ,
                    ,
                    ,
                    ,
                    ,
                    ,
                    ,
    
                ) = positionManager.positions(_tokenId);
    
                IERC20 feeToken0 = IERC20(token0);
                IERC20 feeToken1 = IERC20(token1);
    
                uint256 protocolFee0 = (amount0 * _fee) / 100;
                uint256 protocolFee1 = (amount1 * _fee) / 100;
    
                uint256 recipientFee0 = amount0 - protocolFee0;
                uint256 recipientFee1 = amount1 - protocolFee1;
    
                feeToken0.transfer(_recipient, recipientFee0);
                feeToken1.transfer(_recipient, recipientFee1);
    
                feeToken0.transfer(_feeRecipient, protocolFee0);
                feeToken1.transfer(_feeRecipient, protocolFee1);
    
                emit ClaimedFees(
                    _recipient,
                    token0,
                    token1,
                    recipientFee0,
                    recipientFee1,
                    amount0,
                    amount1
                );
            }
        }
        /**
         * Checks the vesting schedule for the token
         */
        function vestingSchedule() public view returns (uint256) {
            if (block.timestamp > duration()) {
                return 0;
            } else {
                return duration() - block.timestamp;
            }
        }
    
        function onERC721Received(
            address,
            address from,
            uint256 id,
            bytes calldata data
        ) external override returns (bytes4) {
            emit Received(from, id);
    
            return IERC721Receiver.onERC721Received.selector;
        }
    }

    Contract Name:
    LpLocker

    Contract Source Code:

    // SPDX-License-Identifier: MIT
    // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
    
    pragma solidity ^0.8.20;
    
    import {Context} from "../utils/Context.sol";
    
    /**
     * @dev Contract module which provides a basic access control mechanism, where
     * there is an account (an owner) that can be granted exclusive access to
     * specific functions.
     *
     * The initial owner is set to the address provided by the deployer. This can
     * later be changed with {transferOwnership}.
     *
     * This module is used through inheritance. It will make available the modifier
     * `onlyOwner`, which can be applied to your functions to restrict their use to
     * the owner.
     */
    abstract contract Ownable is Context {
        address private _owner;
    
        /**
         * @dev The caller account is not authorized to perform an operation.
         */
        error OwnableUnauthorizedAccount(address account);
    
        /**
         * @dev The owner is not a valid owner account. (eg. `address(0)`)
         */
        error OwnableInvalidOwner(address owner);
    
        event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    
        /**
         * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
         */
        constructor(address initialOwner) {
            if (initialOwner == address(0)) {
                revert OwnableInvalidOwner(address(0));
            }
            _transferOwnership(initialOwner);
        }
    
        /**
         * @dev Throws if called by any account other than the owner.
         */
        modifier onlyOwner() {
            _checkOwner();
            _;
        }
    
        /**
         * @dev Returns the address of the current owner.
         */
        function owner() public view virtual returns (address) {
            return _owner;
        }
    
        /**
         * @dev Throws if the sender is not the owner.
         */
        function _checkOwner() internal view virtual {
            if (owner() != _msgSender()) {
                revert OwnableUnauthorizedAccount(_msgSender());
            }
        }
    
        /**
         * @dev Leaves the contract without owner. It will not be possible to call
         * `onlyOwner` functions. Can only be called by the current owner.
         *
         * NOTE: Renouncing ownership will leave the contract without an owner,
         * thereby disabling any functionality that is only available to the owner.
         */
        function renounceOwnership() public virtual onlyOwner {
            _transferOwnership(address(0));
        }
    
        /**
         * @dev Transfers ownership of the contract to a new account (`newOwner`).
         * Can only be called by the current owner.
         */
        function transferOwnership(address newOwner) public virtual onlyOwner {
            if (newOwner == address(0)) {
                revert OwnableInvalidOwner(address(0));
            }
            _transferOwnership(newOwner);
        }
    
        /**
         * @dev Transfers ownership of the contract to a new account (`newOwner`).
         * Internal function without access restriction.
         */
        function _transferOwnership(address newOwner) internal virtual {
            address oldOwner = _owner;
            _owner = newOwner;
            emit OwnershipTransferred(oldOwner, newOwner);
        }
    }

    // SPDX-License-Identifier: MIT
    // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
    
    pragma solidity ^0.8.20;
    
    /**
     * @dev Interface of the ERC20 standard as defined in the EIP.
     */
    interface IERC20 {
        /**
         * @dev Emitted when `value` tokens are moved from one account (`from`) to
         * another (`to`).
         *
         * Note that `value` may be zero.
         */
        event Transfer(address indexed from, address indexed to, uint256 value);
    
        /**
         * @dev Emitted when the allowance of a `spender` for an `owner` is set by
         * a call to {approve}. `value` is the new allowance.
         */
        event Approval(address indexed owner, address indexed spender, uint256 value);
    
        /**
         * @dev Returns the value of tokens in existence.
         */
        function totalSupply() external view returns (uint256);
    
        /**
         * @dev Returns the value of tokens owned by `account`.
         */
        function balanceOf(address account) external view returns (uint256);
    
        /**
         * @dev Moves a `value` amount of tokens from the caller's account to `to`.
         *
         * Returns a boolean value indicating whether the operation succeeded.
         *
         * Emits a {Transfer} event.
         */
        function transfer(address to, uint256 value) external returns (bool);
    
        /**
         * @dev Returns the remaining number of tokens that `spender` will be
         * allowed to spend on behalf of `owner` through {transferFrom}. This is
         * zero by default.
         *
         * This value changes when {approve} or {transferFrom} are called.
         */
        function allowance(address owner, address spender) external view returns (uint256);
    
        /**
         * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
         * caller's tokens.
         *
         * Returns a boolean value indicating whether the operation succeeded.
         *
         * IMPORTANT: Beware that changing an allowance with this method brings the risk
         * that someone may use both the old and the new allowance by unfortunate
         * transaction ordering. One possible solution to mitigate this race
         * condition is to first reduce the spender's allowance to 0 and set the
         * desired value afterwards:
         * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
         *
         * Emits an {Approval} event.
         */
        function approve(address spender, uint256 value) external returns (bool);
    
        /**
         * @dev Moves a `value` amount of tokens from `from` to `to` using the
         * allowance mechanism. `value` is then deducted from the caller's
         * allowance.
         *
         * Returns a boolean value indicating whether the operation succeeded.
         *
         * Emits a {Transfer} event.
         */
        function transferFrom(address from, address to, uint256 value) external returns (bool);
    }

    // SPDX-License-Identifier: MIT
    // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)
    
    pragma solidity ^0.8.20;
    
    import {IERC165} from "../../utils/introspection/IERC165.sol";
    
    /**
     * @dev Required interface of an ERC721 compliant contract.
     */
    interface IERC721 is IERC165 {
        /**
         * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
         */
        event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
    
        /**
         * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
         */
        event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
    
        /**
         * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
         */
        event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
    
        /**
         * @dev Returns the number of tokens in ``owner``'s account.
         */
        function balanceOf(address owner) external view returns (uint256 balance);
    
        /**
         * @dev Returns the owner of the `tokenId` token.
         *
         * Requirements:
         *
         * - `tokenId` must exist.
         */
        function ownerOf(uint256 tokenId) external view returns (address owner);
    
        /**
         * @dev Safely transfers `tokenId` token from `from` to `to`.
         *
         * Requirements:
         *
         * - `from` cannot be the zero address.
         * - `to` cannot be the zero address.
         * - `tokenId` token must exist and be owned by `from`.
         * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
         * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
         *   a safe transfer.
         *
         * Emits a {Transfer} event.
         */
        function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
    
        /**
         * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
         * are aware of the ERC721 protocol to prevent tokens from being forever locked.
         *
         * Requirements:
         *
         * - `from` cannot be the zero address.
         * - `to` cannot be the zero address.
         * - `tokenId` token must exist and be owned by `from`.
         * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
         *   {setApprovalForAll}.
         * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
         *   a safe transfer.
         *
         * Emits a {Transfer} event.
         */
        function safeTransferFrom(address from, address to, uint256 tokenId) external;
    
        /**
         * @dev Transfers `tokenId` token from `from` to `to`.
         *
         * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
         * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
         * understand this adds an external call which potentially creates a reentrancy vulnerability.
         *
         * Requirements:
         *
         * - `from` cannot be the zero address.
         * - `to` cannot be the zero address.
         * - `tokenId` token must be owned by `from`.
         * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
         *
         * Emits a {Transfer} event.
         */
        function transferFrom(address from, address to, uint256 tokenId) external;
    
        /**
         * @dev Gives permission to `to` to transfer `tokenId` token to another account.
         * The approval is cleared when the token is transferred.
         *
         * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
         *
         * Requirements:
         *
         * - The caller must own the token or be an approved operator.
         * - `tokenId` must exist.
         *
         * Emits an {Approval} event.
         */
        function approve(address to, uint256 tokenId) external;
    
        /**
         * @dev Approve or remove `operator` as an operator for the caller.
         * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
         *
         * Requirements:
         *
         * - The `operator` cannot be the address zero.
         *
         * Emits an {ApprovalForAll} event.
         */
        function setApprovalForAll(address operator, bool approved) external;
    
        /**
         * @dev Returns the account approved for `tokenId` token.
         *
         * Requirements:
         *
         * - `tokenId` must exist.
         */
        function getApproved(uint256 tokenId) external view returns (address operator);
    
        /**
         * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
         *
         * See {setApprovalForAll}
         */
        function isApprovedForAll(address owner, address operator) external view returns (bool);
    }

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

    // SPDX-License-Identifier: MIT
    // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
    
    pragma solidity ^0.8.20;
    
    /**
     * @dev Collection of functions related to the address type
     */
    library Address {
        /**
         * @dev The ETH balance of the account is not enough to perform the operation.
         */
        error AddressInsufficientBalance(address account);
    
        /**
         * @dev There's no code at `target` (it is not a contract).
         */
        error AddressEmptyCode(address target);
    
        /**
         * @dev A call to an address target failed. The target may have reverted.
         */
        error FailedInnerCall();
    
        /**
         * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
         * `recipient`, forwarding all available gas and reverting on errors.
         *
         * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
         * of certain opcodes, possibly making contracts go over the 2300 gas limit
         * imposed by `transfer`, making them unable to receive funds via
         * `transfer`. {sendValue} removes this limitation.
         *
         * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
         *
         * IMPORTANT: because control is transferred to `recipient`, care must be
         * taken to not create reentrancy vulnerabilities. Consider using
         * {ReentrancyGuard} or the
         * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
         */
        function sendValue(address payable recipient, uint256 amount) internal {
            if (address(this).balance < amount) {
                revert AddressInsufficientBalance(address(this));
            }
    
            (bool success, ) = recipient.call{value: amount}("");
            if (!success) {
                revert FailedInnerCall();
            }
        }
    
        /**
         * @dev Performs a Solidity function call using a low level `call`. A
         * plain `call` is an unsafe replacement for a function call: use this
         * function instead.
         *
         * If `target` reverts with a revert reason or custom error, it is bubbled
         * up by this function (like regular Solidity function calls). However, if
         * the call reverted with no returned reason, this function reverts with a
         * {FailedInnerCall} error.
         *
         * Returns the raw returned data. To convert to the expected return value,
         * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
         *
         * Requirements:
         *
         * - `target` must be a contract.
         * - calling `target` with `data` must not revert.
         */
        function functionCall(address target, bytes memory data) internal returns (bytes memory) {
            return functionCallWithValue(target, data, 0);
        }
    
        /**
         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
         * but also transferring `value` wei to `target`.
         *
         * Requirements:
         *
         * - the calling contract must have an ETH balance of at least `value`.
         * - the called Solidity function must be `payable`.
         */
        function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
            if (address(this).balance < value) {
                revert AddressInsufficientBalance(address(this));
            }
            (bool success, bytes memory returndata) = target.call{value: value}(data);
            return verifyCallResultFromTarget(target, success, returndata);
        }
    
        /**
         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
         * but performing a static call.
         */
        function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
            (bool success, bytes memory returndata) = target.staticcall(data);
            return verifyCallResultFromTarget(target, success, returndata);
        }
    
        /**
         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
         * but performing a delegate call.
         */
        function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
            (bool success, bytes memory returndata) = target.delegatecall(data);
            return verifyCallResultFromTarget(target, success, returndata);
        }
    
        /**
         * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
         * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
         * unsuccessful call.
         */
        function verifyCallResultFromTarget(
            address target,
            bool success,
            bytes memory returndata
        ) internal view returns (bytes memory) {
            if (!success) {
                _revert(returndata);
            } else {
                // only check if target is a contract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                if (returndata.length == 0 && target.code.length == 0) {
                    revert AddressEmptyCode(target);
                }
                return returndata;
            }
        }
    
        /**
         * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
         * revert reason or with a default {FailedInnerCall} error.
         */
        function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
            if (!success) {
                _revert(returndata);
            } else {
                return returndata;
            }
        }
    
        /**
         * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
         */
        function _revert(bytes memory returndata) private pure {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert FailedInnerCall();
            }
        }
    }

    // SPDX-License-Identifier: MIT
    // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
    
    pragma solidity ^0.8.20;
    
    /**
     * @dev Provides information about the current execution context, including the
     * sender of the transaction and its data. While these are generally available
     * via msg.sender and msg.data, they should not be accessed in such a direct
     * manner, since when dealing with meta-transactions the account sending and
     * paying for execution may not be the actual sender (as far as an application
     * is concerned).
     *
     * This contract is only required for intermediate, library-like contracts.
     */
    abstract contract Context {
        function _msgSender() internal view virtual returns (address) {
            return msg.sender;
        }
    
        function _msgData() internal view virtual returns (bytes calldata) {
            return msg.data;
        }
    
        function _contextSuffixLength() internal view virtual returns (uint256) {
            return 0;
        }
    }

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

    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.25;
    
    import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
    
    interface NonFungibleContract is IERC721 {
        /// @notice Returns the position information associated with a given token ID.
        /// @dev Throws if the token ID is not valid.
        /// @param tokenId The ID of the token that represents the position
        /// @return nonce The nonce for permits
        /// @return operator The address that is approved for spending
        /// @return token0 The address of the token0 for a specific pool
        /// @return token1 The address of the token1 for a specific pool
        /// @return fee The fee associated with the pool
        /// @return tickLower The lower end of the tick range for the position
        /// @return tickUpper The higher end of the tick range for the position
        /// @return liquidity The liquidity of the position
        /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
        /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
        /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
        /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
        function positions(
            uint256 tokenId
        )
            external
            view
            returns (
                uint96 nonce,
                address operator,
                address token0,
                address token1,
                uint24 fee,
                int24 tickLower,
                int24 tickUpper,
                uint128 liquidity,
                uint256 feeGrowthInside0LastX128,
                uint256 feeGrowthInside1LastX128,
                uint128 tokensOwed0,
                uint128 tokensOwed1
            );
    
        struct CollectParams {
            uint256 tokenId;
            address recipient;
            uint128 amount0Max;
            uint128 amount1Max;
        }
    
        /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient
        /// @param params tokenId The ID of the NFT for which tokens are being collected,
        /// recipient The account that should receive the tokens,
        /// amount0Max The maximum amount of token0 to collect,
        /// amount1Max The maximum amount of token1 to collect
        /// @return amount0 The amount of fees collected in token0
        /// @return amount1 The amount of fees collected in token1
        function collect(
            CollectParams calldata params
        ) external payable returns (uint256 amount0, uint256 amount1);
    }

    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.26;
    
    import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
    import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
    import "@openzeppelin/contracts/access/Ownable.sol";
    import "@openzeppelin/contracts/utils/Context.sol";
    import "@openzeppelin/contracts/utils/Address.sol";
    import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
    import {NonFungibleContract} from "./IManager.sol";
    
    interface INonfungiblePositionManager is IERC721 {
        struct CollectParams {
            uint256 tokenId;
            address recipient;
            uint128 amount0Max;
            uint128 amount1Max;
        }
    
        function collect(
            CollectParams calldata params
        ) external payable returns (uint256 amount0, uint256 amount1);
    }
    
    contract LpLocker is Ownable, IERC721Receiver {
        event ERC721Released(address indexed token, uint256 amount);
    
        event LockId(uint256 _id);
    
        event LockDuration(uint256 _time);
        event Received(address indexed from, uint256 tokenId);
    
        event ClaimedFees(
            address indexed claimer,
            address indexed token0,
            address indexed token1,
            uint256 amount0,
            uint256 amount1,
            uint256 totalAmount1,
            uint256 totalAmount0
        );
    
        uint256 private _released;
        mapping(address => uint256) public _erc721Released;
        IERC721 private SafeERC721;
        uint64 private immutable _duration;
        address private immutable e721Token;
        bool private flag;
        NonFungibleContract private positionManager;
        string public constant version = "1.0";
        uint256 public _fee;
        address public _feeRecipient;
    
        /**
         * @dev Sets the sender as the initial owner, the beneficiary as the pending owner, and the duration for the lock
         * vesting duration of the vesting wallet.
         */
        constructor(
            address token,
            address beneficiary,
            uint64 durationSeconds,
            uint256 fee,
            address feeRecipient
        ) payable Ownable(beneficiary) {
            _duration = durationSeconds;
            SafeERC721 = IERC721(token);
            //already false but lets be safe
            flag = false;
            e721Token = token;
            _fee = fee;
            _feeRecipient = feeRecipient;
            emit LockDuration(durationSeconds);
        }
    
        function initializer(uint256 token_id) public {
            require(flag == false, "contract already initialized");
            _erc721Released[e721Token] = token_id;
            flag = true;
            positionManager = NonFungibleContract(e721Token);
    
            if (positionManager.ownerOf(token_id) != address(this)) {
                SafeERC721.transferFrom(owner(), address(this), token_id);
            }
    
            emit LockId(token_id);
        }
    
        /**
         * @dev Getter for the vesting duration.
         */
        function duration() public view virtual returns (uint256) {
            return _duration;
        }
    
        /**
         * @dev The contract should be able to receive Eth.
         */
        receive() external payable virtual {}
    
        /**
         * @dev Getter for the end timestamp.
         */
        function end() public view virtual returns (uint256) {
            return duration();
        }
    
        /**
         * @dev returns the tokenId of the locked LP
         */
        function released(address token) public view virtual returns (uint256) {
            return _erc721Released[token];
        }
    
        /**
         * @dev Release the token that have already vested.
         *
         * Emits a {ERC721Released} event.
         */
        function release() public virtual {
            if (vestingSchedule() != 0) {
                revert();
            }
            uint256 id = _erc721Released[e721Token];
            emit ERC721Released(e721Token, id);
            SafeERC721.transferFrom(address(this), owner(), id);
        }
    
        function withdrawERC20(address _token) public {
            require(owner() == msg.sender, "only owner can call");
            IERC20 IToken = IERC20(_token);
            IToken.transferFrom(address(this), owner(), IToken.balanceOf(owner()));
        }
    
        /**
         * @dev sourced from: https://docs.uniswap.org/contracts/v3/reference/deployments
         */
        function _getAddresses()
            internal
            view
            returns (
                address weth,
                INonfungiblePositionManager nonFungiblePositionManager
            )
        {
            uint256 chainId = block.chainid;
            // base
            if (chainId == 8453) {
                weth = 0x4200000000000000000000000000000000000006;
                nonFungiblePositionManager = INonfungiblePositionManager(
                    0x03a520b32C04BF3bEEf7BEb72E919cf822Ed34f1
                );
            }
            // degen chain
            if (chainId == 666666666) {
                // wrapped degen
                weth = 0xEb54dACB4C2ccb64F8074eceEa33b5eBb38E5387;
                nonFungiblePositionManager = INonfungiblePositionManager( // proxy swap
                    0x56c65e35f2Dd06f659BCFe327C4D7F21c9b69C2f
                );
            }
    
            if (chainId == 5112) {
                // wrapped ETH
                weth = 0x4200000000000000000000000000000000000006;
                nonFungiblePositionManager = INonfungiblePositionManager( // proxy swap
                    0xD088322Fa988225B3936555894E1D21c1A727859
                );
            }
    
            if (chainId == 56) {
                weth = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c;
                nonFungiblePositionManager = INonfungiblePositionManager(
                    0x46A15B0b27311cedF172AB29E4f4766fbE7F4364
                );
            }
    
            if (chainId == 146) {
                weth = 0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38;
                nonFungiblePositionManager = INonfungiblePositionManager(
                    0x77DcC9b09C6Ae94CDC726540735682A38e18d690
                );
            }
        }
    
        //Use collect fees to collect the fees
        function collectFees(address _recipient, uint256 _tokenId) public {
            require(owner() == msg.sender, "only owner can call");
            (
                ,
                INonfungiblePositionManager nonfungiblePositionManager
            ) = _getAddresses();
    
            if (_fee == 0) {
                (uint256 amount0, uint256 amount1) = nonfungiblePositionManager
                    .collect(
                        INonfungiblePositionManager.CollectParams({
                            recipient: _recipient,
                            amount0Max: type(uint128).max,
                            amount1Max: type(uint128).max,
                            tokenId: _tokenId
                        })
                    );
    
                emit ClaimedFees(
                    _recipient,
                    address(0),
                    address(0),
                    amount0,
                    amount1,
                    amount0,
                    amount1
                );
            } else {
                (uint256 amount0, uint256 amount1) = nonfungiblePositionManager
                    .collect(
                        INonfungiblePositionManager.CollectParams({
                            recipient: address(this),
                            amount0Max: type(uint128).max,
                            amount1Max: type(uint128).max,
                            tokenId: _tokenId
                        })
                    );
    
                (
                    ,
                    ,
                    address token0,
                    address token1,
                    ,
                    ,
                    ,
                    ,
                    ,
                    ,
                    ,
    
                ) = positionManager.positions(_tokenId);
    
                IERC20 feeToken0 = IERC20(token0);
                IERC20 feeToken1 = IERC20(token1);
    
                uint256 protocolFee0 = (amount0 * _fee) / 100;
                uint256 protocolFee1 = (amount1 * _fee) / 100;
    
                uint256 recipientFee0 = amount0 - protocolFee0;
                uint256 recipientFee1 = amount1 - protocolFee1;
    
                feeToken0.transfer(_recipient, recipientFee0);
                feeToken1.transfer(_recipient, recipientFee1);
    
                feeToken0.transfer(_feeRecipient, protocolFee0);
                feeToken1.transfer(_feeRecipient, protocolFee1);
    
                emit ClaimedFees(
                    _recipient,
                    token0,
                    token1,
                    recipientFee0,
                    recipientFee1,
                    amount0,
                    amount1
                );
            }
        }
        /**
         * Checks the vesting schedule for the token
         */
        function vestingSchedule() public view returns (uint256) {
            if (block.timestamp > duration()) {
                return 0;
            } else {
                return duration() - block.timestamp;
            }
        }
    
        function onERC721Received(
            address,
            address from,
            uint256 id,
            bytes calldata data
        ) external override returns (bytes4) {
            emit Received(from, id);
    
            return IERC721Receiver.onERC721Received.selector;
        }
    }

    Context size (optional):