Minting new position on Uniswap V3 using hardhat


This Content is from Stack Overflow. Question asked by FatherSena

So basically I am trying to mint a position in a pool created by me.

To create and initialise the pool:

  const factory = await ethers.getContractAt("UniswapV3Factory", factoryAddress)
  let poolAddress = await factory.getPool("0x40a42Baf86Fc821f972Ad2aC878729063CeEF403", "0x4bf010f1b9beDA5450a8dD702ED602A104ff65EE", 500);

  const pool = await ethers.getContractAt("UniswapV3Pool", poolAddress);
    await pool.initialize(BigNumber.from(2).pow(96));
  } catch(exception){
    console.log("Pool already initialized");

Then to try to had liquidity I tried this:

  let signer = await ethers.getSigner("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266");

  await pool.connect(signer).mint(signer.address,-20,20,10000000,[]);

I realise it is missing the transfer of the tokens (which is suposed to come in a callback of the min function) but I don’t know how to implement it! Any ideas?

Or is this simply the wrong approach and there is a better on?


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?