smartcontractsevmuniswap

Uniswap v3 nonfungiblePositionManager.mint revert after createAndInitializePoolIfNecessary


I use the official deploy tool "successfully" to deploy Uniswap v3 to a EVM comparable testnet. After NonfungiblePositionManager.createAndInitializePoolIfNecessary(), I call NonfungiblePositionManager.mint() to mint a new position but it always reverts. Here is the input I used:

 console.log("creating pool...");
   await NFPositionManagerInstance.createAndInitializePoolIfNecessary(
     DaiTokenInstance.address,
     USDTTokenInstance.address,
     3000,
     "80000000000000000000000000000"
   ); // this can be successfully triggered

   console.log("minting a position...")
   let tx = await NFPositionManagerInstance.mint({
      token0: DaiTokenInstance.address,
      token1: USDTTokenInstance.address,
      fee: 3000,
      tickLower: 193,
      tickUpper: 194,
      amount0Desired: 1000,
      amount1Desired: 1000,
      amount0Min: 0,
      amount1Min: 0, 
      recipient: "0x668417616f1502D13EA1f9528F83072A133e8E01",
      deadline: Math.round(+new Date()/1000 + 20)
   }); // this always revert

Anyone know what is going on? I plan to debug this deeply in the contract next.


Solution

  • I ran simulation on tenderly.co Changing ticks to numbers divisible by the tickSpacig fixed it.

    tenderly simulation