【问题标题】:Uniswap v3 nonfungiblePositionManager.mint revert after createAndInitializePoolIfNecessaryUniswap v3 nonfungiblePositionManager.mint 在 createAndInitializePoolIfNecessary 后恢复
【发布时间】:2022-08-29 06:38:03
【问题描述】:

我使用官方部署工具“成功”将 Uniswap v3 部署到 EVM 可比测试网。在NonfungiblePositionManager.createAndInitializePoolIfNecessary() 之后,我打电话给NonfungiblePositionManager.mint() 来创建一个新位置,但它总是会恢复。这是我使用的输入:

 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

有谁知道发生了什么?我计划接下来在合同中对此进行深入调试。

【问题讨论】:

    标签: smartcontracts evm uniswap


    【解决方案1】:

    我在tenderly.co 上运行了模拟 将刻度更改为可被tickSpacig 整除的数字已修复此问题。

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题。有几件事可能是问题所在,但我会先看看我正在工作的代码https://github.com/zack53/uniswapv3-pool-deploy/blob/main/src/test/TERC20.js。我遇到的问题专门与 tickLower 和 tickUpper 相关,因为无故恢复错误。我基本上必须从已部署对的 slot0 获取当前刻度,然后,我还从已部署对中获取了刻度间距。一旦我有了这些,我就用它们来计算允许我建立一个位置的刻度间距。部署的对是我自己部署的一对。两个标记都是 18 位小数。我的代码的 sn-p 如下所示:

          // Get tick and tick spacing
          let slot0 = await deployedPairContract.methods.slot0().call()
          let tickSpacing = parseInt(await deployedPairContract.methods.tickSpacing().call())
          // Get correct token order for deployed contract pair
          let token0 = await deployedPairContract.methods.token0().call()
          let token1 = await deployedPairContract.methods.token1().call()
          // Params needed for mint
          let params = {
            token0: token0,
            token1: token1,
            fee: pairFee,
            tickLower: parseInt(slot0.tick) - tickSpacing * 2,
            tickUpper: parseInt(slot0.tick) + tickSpacing * 2,
            amount0Desired: 10,
            amount1Desired: 10,
            amount0Min: 0,
            amount1Min: 0,
            recipient: accounts[0],
            deadline: 5000000000
          }
          await t1ERC20Contract.approve(UniSwapV3NPositionManagerAddress, BigNumber(1000).shiftedBy(decimals).toFixed(0), { from: accounts[0] })
          await t2ERC20Contract.approve(UniSwapV3NPositionManagerAddress, BigNumber(1000).shiftedBy(decimals).toFixed(0), { from: accounts[0] })
          await uniswapV3NPositionManager.methods.mint(params).send({ from: accounts[0] })
      

      【讨论】:

        猜你喜欢
        • 2022-11-04
        • 1970-01-01
        • 2022-10-26
        • 2015-11-07
        • 2022-07-29
        • 2023-01-05
        • 1970-01-01
        • 2022-12-10
        • 2022-11-14
        相关资源
        最近更新 更多