Keep same-range Uniswap v4 positions distinct by salt
A router can own multiple v4 liquidity positions in the same range. An index keyed only by owner and ticks merges their liquidity and fee state.
Rebuild the complete position identity
Start with chain, PoolManager and pool ID. Within that pool include the owner used by the core operation, lower and upper ticks, and the bytes32 salt supplied to modifyLiquidity. The two entries below differ only in salt.
owner R, ticks [-120, 120], salt 0
owner R, ticks [-120, 120], salt 1
An increase for salt one belongs to the second position. Do not automatically copy the user’s wallet into the owner field when a position manager is the core caller. Retain any application NFT or internal ID as a separate mapping.
Trace removal using the original salt
A later removal with a different salt addresses a different core position even if all price boundaries match. Reconcile event data with the original callback and manager records when a front end appears to show liquidity that the chosen position cannot remove. github.com PoolManager.sol