PositionManager
Git Source - Generated with forge doc
Inherits: IPositionManager, ERC721Permit_v4, PoolInitializer_v4, Multicall_v4, DeltaResolver, ReentrancyLock, BaseActionsRouter, Notifier, Permit2Forwarder, NativeWrapper
The PositionManager (PosM) contract is responsible for creating liquidity positions on v4. PosM mints and manages ERC721 tokens associated with each position.
State Variables
nextTokenId
Used to get the ID that will be used for the next minted liquidity position
The ID of the next token that will be minted. Skips 0
uint256 public nextTokenId = 1;
tokenDescriptor
IPositionDescriptor public immutable tokenDescriptor;
positionInfo
mapping(uint256 tokenId => PositionInfo info) public positionInfo;
poolKeys
mapping(bytes25 poolId => PoolKey poolKey) public poolKeys;
Functions
constructor
constructor(
IPoolManager _poolManager,
IAllowanceTransfer _permit2,
uint256 _unsubscribeGasLimit,
IPositionDescriptor _tokenDescriptor,
IWETH9 _weth9
)
BaseActionsRouter(_poolManager)
Permit2Forwarder(_permit2)
ERC721Permit_v4("Uniswap v4 Positions NFT", "UNI-V4-POSM")
Notifier(_unsubscribeGasLimit)
NativeWrapper(_weth9);
checkDeadline
Reverts if the deadline has passed
modifier checkDeadline(uint256 deadline);
Parameters
| Name | Type | Description |
|---|---|---|
deadline | uint256 | The timestamp at which the call is no longer valid, passed in by the caller |
onlyIfApproved
Reverts if the caller is not the owner or approved for the ERC721 token
either msg.sender or msgSender() is passed in as the caller msgSender() should ONLY be used if this is called from within the unlockCallback, unless the codepath has reentrancy protection
modifier onlyIfApproved(address caller, uint256 tokenId) override;
Parameters
| Name | Type | Description |
|---|---|---|
caller | address | The address of the caller |
tokenId | uint256 | the unique identifier of the ERC721 token |
onlyIfPoolManagerLocked
Enforces that the PoolManager is locked.
modifier onlyIfPoolManagerLocked() override;
tokenURI
function tokenURI(uint256 tokenId) public view override returns (string memory);
modifyLiquidities
Unlocks Uniswap v4 PoolManager and batches actions for modifying liquidity
This is the standard entrypoint for the PositionManager
function modifyLiquidities(bytes calldata unlockData, uint256 deadline)
external
payable
isNotLocked
checkDeadline(deadline);
Parameters
| Name | Type | Description |
|---|---|---|
unlockData | bytes | is an encoding of actions, and parameters for those actions |
deadline | uint256 | is the deadline for the batched actions to be executed |
modifyLiquiditiesWithoutUnlock
Batches actions for modifying liquidity without unlocking v4 PoolManager
This must be called by a contract that has already unlocked the v4 PoolManager
function modifyLiquiditiesWithoutUnlock(bytes calldata actions, bytes[] calldata params) external payable isNotLocked;
Parameters
| Name | Type | Description |
|---|---|---|
actions | bytes | the actions to perform |
params | bytes[] | the parameters to provide for the actions |