Uniswap / examples

120 stars 147 forks source link

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

Open antiwinter opened 1 year ago

antiwinter commented 1 year ago

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)?

Florian-S-A-W commented 1 year ago

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,
    })