Reputation: 219
I am trying to build a web application using uniswap v3 for adding and removing the liquidity. I could able to add liquidity but for removing it I need a token, How to get it from uniswap?
Upvotes: 1
Views: 3225
Reputation: 2187
When you add liquidity on uniswap v3 an NFT is minted and sent to your address. The Transfer
event is emitted which contains the tokenId
. You can see an example here on etherscan.
To remove the liquidity, you have to listen for this event and tokenId
and then submit the same tokenId
to remove the liquidity by burning the NFT token. An example here.
Alternatively, you could query the tokenOfOwnerByIndex
function on the uni NFT contract and iterate from 0->n to get all of the NFTs liquidity positions owned by a user. This will give you all the tokenId
s of NFTs which the user owns.
Upvotes: 4