From 316604534e40c59e8a9339e601a843a72571b15f Mon Sep 17 00:00:00 2001 From: Tina Zheng Date: Wed, 29 Nov 2023 11:54:21 -0500 Subject: [PATCH] add periphery immutable state --- contracts/NonfungiblePositionManagerV4.sol | 6 +++--- contracts/base/PeripheryImmutableState.sol | 15 +++++++++++++++ .../interfaces/INonfungiblePositionManagerV4.sol | 9 ++++++++- contracts/interfaces/IPeripheryImmutableState.sol | 11 +++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 contracts/base/PeripheryImmutableState.sol create mode 100644 contracts/interfaces/IPeripheryImmutableState.sol diff --git a/contracts/NonfungiblePositionManagerV4.sol b/contracts/NonfungiblePositionManagerV4.sol index 5bb9f239..f2f5fb58 100644 --- a/contracts/NonfungiblePositionManagerV4.sol +++ b/contracts/NonfungiblePositionManagerV4.sol @@ -12,12 +12,14 @@ import {Currency} from "@uniswap/v4-core/contracts/types/Currency.sol"; import {INonfungiblePositionManagerV4} from "./interfaces/INonfungiblePositionManagerV4.sol"; import {PeripheryValidation} from "./base/PeripheryValidation.sol"; import {PeripheryPayments} from "./base/PeripheryPayments.sol"; +import {PeripheryImmutableState} from "./base/PeripheryImmutableState.sol"; import {SelfPermit} from "./base/SelfPermit.sol"; import {Multicall} from "./base/Multicall.sol"; contract NonfungiblePositionManagerV4 is INonfungiblePositionManagerV4, ERC721, + PeripheryImmutableState, PeripheryValidation, PeripheryPayments, SelfPermit, @@ -25,8 +27,6 @@ contract NonfungiblePositionManagerV4 is { using PoolIdLibrary for PoolKey; - IPoolManager public immutable poolManager; - error InvalidTokenID(); error NotApproved(); error NotCleared(); @@ -68,9 +68,9 @@ contract NonfungiblePositionManagerV4 is // TODO: does it still need WETH address in the constructor here? // TODO: use ERC721Permit2 here constructor(IPoolManager _poolManager, address _tokenDescriptor_) + PeripheryImmutableState(_poolManager) ERC721("Uniswap V4 Positions NFT-V1", "UNI-V4-POS") { - poolManager = _poolManager; _tokenDescriptor = _tokenDescriptor_; } diff --git a/contracts/base/PeripheryImmutableState.sol b/contracts/base/PeripheryImmutableState.sol new file mode 100644 index 00000000..c5a6d284 --- /dev/null +++ b/contracts/base/PeripheryImmutableState.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.19; + +import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol"; +import {IPeripheryImmutableState} from "../interfaces/IPeripheryImmutableState.sol"; + +/// @title Immutable state +/// @notice Immutable state used by periphery contracts +abstract contract PeripheryImmutableState is IPeripheryImmutableState { + IPoolManager public immutable override poolManager; + + constructor(IPoolManager _poolManager) { + poolManager = _poolManager; + } +} diff --git a/contracts/interfaces/INonfungiblePositionManagerV4.sol b/contracts/interfaces/INonfungiblePositionManagerV4.sol index a167324c..990bbd42 100644 --- a/contracts/interfaces/INonfungiblePositionManagerV4.sol +++ b/contracts/interfaces/INonfungiblePositionManagerV4.sol @@ -8,11 +8,18 @@ import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol"; import {Currency} from "@uniswap/v4-core/contracts/types/Currency.sol"; import {IPeripheryPayments} from "./IPeripheryPayments.sol"; +import {IPeripheryImmutableState} from "./IPeripheryImmutableState.sol"; /// @title Non-fungible token for positions /// @notice Wraps Uniswap V4 positions in a non-fungible token interface which allows for them to be transferred /// and authorized. -interface INonfungiblePositionManagerV4 is ILockCallback, IPeripheryPayments, IERC721Metadata, IERC721Enumerable { +interface INonfungiblePositionManagerV4 is + ILockCallback, + IPeripheryPayments, + IPeripheryImmutableState, + IERC721Metadata, + IERC721Enumerable +{ /// @notice Emitted when liquidity is increased for a position NFT /// @dev Also emitted when a token is minted /// @param tokenId The ID of the token for which liquidity was increased diff --git a/contracts/interfaces/IPeripheryImmutableState.sol b/contracts/interfaces/IPeripheryImmutableState.sol new file mode 100644 index 00000000..9797b721 --- /dev/null +++ b/contracts/interfaces/IPeripheryImmutableState.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.19; + +import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol"; + +/// @title Immutable state +/// @notice Functions that return immutable state +interface IPeripheryImmutableState { + /// @return Returns the pool manager + function poolManager() external view returns (IPoolManager); +}