Skip to content

Commit

Permalink
update position manager skeleton with liquidity management file
Browse files Browse the repository at this point in the history
  • Loading branch information
tinaszheng committed Nov 29, 2023
1 parent 3166045 commit ad34755
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 20 deletions.
7 changes: 1 addition & 6 deletions contracts/NonfungiblePositionManagerV4.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ contract NonfungiblePositionManagerV4 is
/// @dev The address of the token descriptor contract, which handles generating token URIs for position tokens
address private immutable _tokenDescriptor;

// 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")
Expand Down Expand Up @@ -113,10 +111,6 @@ contract NonfungiblePositionManagerV4 is
);
}

function lockAcquired(bytes calldata rawData) external returns (bytes memory) {
// TODO: implement this
}

/// @inheritdoc INonfungiblePositionManagerV4
function createAndInitializePoolIfNecessary(PoolKey memory poolkey, uint160 sqrtPriceX96, bytes memory initData)
external
Expand All @@ -134,6 +128,7 @@ contract NonfungiblePositionManagerV4 is
returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1)
{
// TODO: implement this
// will do something like return mintEntry(params)
}

modifier isAuthorizedForToken(uint256 tokenId) {
Expand Down
22 changes: 22 additions & 0 deletions contracts/base/LiquidityManagement.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import {BalanceDelta} from "@uniswap/v4-core/contracts/types/BalanceDelta.sol";
import {ILockCallback} from "@uniswap/v4-core/contracts/interfaces/callback//ILockCallback.sol";
import {IPeripheryPayments} from "../interfaces/IPeripheryPayments.sol";
import {ILiquidityManagement} from "../interfaces/ILiquidityManagement.sol";
import {PeripheryImmutableState} from "./PeripheryImmutableState.sol";

abstract contract LiquidityManagement is ILockCallback, ILiquidityManagement, PeripheryImmutableState {
function mintEntry(MintParams memory params)
internal
returns (uint256 tokenId, uint128 liquidity, BalanceDelta delta)
{
// poolManager.lock call here
}

function lockAcquired(bytes calldata rawData) external override returns (bytes memory) {
// TODO: handle mint/add liquidity here
return abi.encode(0);
}
}
20 changes: 20 additions & 0 deletions contracts/interfaces/ILiquidityManagement.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import {ILockCallback} from "@uniswap/v4-core/contracts/interfaces/callback//ILockCallback.sol";
import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol";

interface ILiquidityManagement is ILockCallback {
struct MintParams {
PoolKey poolKey;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
address recipient;
uint256 deadline;
bytes hookData;
}
}
16 changes: 2 additions & 14 deletions contracts/interfaces/INonfungiblePositionManagerV4.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ pragma solidity ^0.8.19;

import {IERC721Metadata} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import {IERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import {ILockCallback} from "@uniswap/v4-core/contracts/interfaces/callback//ILockCallback.sol";
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 {ILiquidityManagement} from "./ILiquidityManagement.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,
ILiquidityManagement,
IPeripheryPayments,
IPeripheryImmutableState,
IERC721Metadata,
Expand Down Expand Up @@ -82,18 +82,6 @@ interface INonfungiblePositionManagerV4 is
uint128 tokensOwed1
);

struct MintParams {
PoolKey poolKey;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
address recipient;
uint256 deadline;
}

/// @notice Creates a new position wrapped in a NFT
/// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized
/// a method does not exist, i.e. the pool is assumed to be initialized.
Expand Down

0 comments on commit ad34755

Please sign in to comment.