Hi! I am trying to understand deeper the relationship between the UniswapV3Pool.sol contract in this repo and the NonfungiblePositionManager.sol contract in the v3-periphery repo. As a summary, my question is: How does the pool contract know which position to burn if the message sender owns more than 1 position in a single tick range?
Minting Liquidity
I mint liquidity via the NFT manager since it implements a uniswapV3MintCallback. The NFT contract calls the addLiquidity method with parameters
I can burn liquidity directly on the pool contract without going through the NFT contract. I just need to supply the tick range and the amount of liquidity I'd like to burn:
so the pool burns liquidity of the position in the tick range owned by the owner of the message, so I'd need to send the transaction from the NFT contract address which is the owner of the liquidity minted in the first section. This is reinforced by the NFT contract which calls the following code in the decreaseLiquidity method
This implies that the pool knows the NFT contract has sent the message so knows the NFT contract liquidity should be burned.
Problem
However, the NFT position manager contract has loads of positions, since the majority of NFT positions are owned by the NFT manager contract. The position is obtained by the following line
position = positions.get(owner, tickLower, tickUpper);
But there will be multiple NFTs that have the same tick range, and so this method should have multiple valid responses of positions with the NFT contract owner with that tick range. So how does the pool contract know which particular position to remove liquidity from?
Hi! I am trying to understand deeper the relationship between the
UniswapV3Pool.sol
contract in this repo and theNonfungiblePositionManager.sol
contract in thev3-periphery
repo. As a summary, my question is: How does the pool contract know which position to burn if the message sender owns more than 1 position in a single tick range?Minting Liquidity
I mint liquidity via the NFT manager since it implements a
uniswapV3MintCallback
. The NFT contract calls theaddLiquidity
method with parametersIn particular, note how the recipient is defined as the NFT manager contract. This maps up to the
mint
on the pool contract:which then goes on to modify a position of the NFT contract
Burning Liquidity
I can burn liquidity directly on the pool contract without going through the NFT contract. I just need to supply the tick range and the amount of liquidity I'd like to burn:
But how does the pool know which position to burn? I believe this comes in the modify position section of the code:
so the pool burns liquidity of the position in the tick range owned by the owner of the message, so I'd need to send the transaction from the NFT contract address which is the owner of the liquidity minted in the first section. This is reinforced by the NFT contract which calls the following code in the
decreaseLiquidity
methodThis implies that the pool knows the NFT contract has sent the message so knows the NFT contract liquidity should be burned.
Problem
However, the NFT position manager contract has loads of positions, since the majority of NFT positions are owned by the NFT manager contract. The position is obtained by the following line
But there will be multiple NFTs that have the same tick range, and so this method should have multiple valid responses of positions with the NFT contract owner with that tick range. So how does the pool contract know which particular position to remove liquidity from?