Uniswap/examples

Q: How do I calculate currentPosition required by NonfungiblePositionManager.removeCallParameters?

antiwinter opened this issue · 1 comments

In the example code the currentPosition is constructed from CurrentConfig which is a const value and can be the same as the mint one. But in real use, there won't be such a CurrentConfig, then how can I calculate it from positionId or the object returned by positionContract.positions(tokenId)?

Hi @antiwinter ,
You get all the values you need from the positions function on the NonfungiblePositionManager Contract.
From the response of getPositionInfo() create the position like this:

const currentPositionInfo = await getPositionInfo(positionId)
const currentPosition = new Position({
      pool,
      liquidity: JSBI.BigInt(currentPositionInfo.liquidity.toString()),
      tickLower: currentPositionInfo.tickLower,
      tickUpper: currentPositionInfo.tickUpper,
    })