You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the following method to mint a Uniswap v3 position:
function mintPosition(
addresstoken0,
addresstoken1,
uint24poolFee,
uint256amount0,
uint256amount1,
int24rangeLeft,
int24rangeRight) externalpayableoverridereturns (
uint256tokenId,
uint128liquidity,
uint256actualAmount0,
uint256actualAmount1
)
{
// Approve the position manager
TransferHelper.safeApprove(token0, address(nonfungiblePositionManager), amount0);
TransferHelper.safeApprove(token1, address(nonfungiblePositionManager), amount1);
INonfungiblePositionManager.MintParams memory params =
INonfungiblePositionManager.MintParams({
token0: token0,
token1: token1,
fee: poolFee,
tickLower: rangeLeft,
tickUpper: rangeRight,
amount0Desired: amount0,
amount1Desired: amount1,
amount0Min: 0,
amount1Min: 0,
recipient: address(this),
deadline: block.timestamp
});
// Note that the pool defined by token0/token1 and fee tier poolFee must already be created and initialized in order to mint// THIS TRANSACTION FAILS WITHOUT A REASON STRING
(tokenId, liquidity, actualAmount0, actualAmount1) = nonfungiblePositionManager.mint(params);
// Create a deposit_createDeposit(msg.sender, tokenId);
// Remove allowance and refund in both assets.if (actualAmount0 < amount0) {
TransferHelper.safeApprove(token0, address(nonfungiblePositionManager), 0);
uint256 refund0 = amount0 - actualAmount0;
TransferHelper.safeTransfer(token0, msg.sender, refund0);
}
if (actualAmount1 < amount1) {
TransferHelper.safeApprove(token1, address(nonfungiblePositionManager), 0);
uint256 refund1 = amount1 - actualAmount1;
TransferHelper.safeTransfer(token1, msg.sender, refund1);
}
}
I am able to mint a DAI-USDC 0.01% with this method. But when trying to create an ETH-USDC 0.3% pool it fails without a reason string
My test code is this:
it("Should create a new ETH-USDC 0.3% position",asyncfunction(){constFEE=3000;const{ contract, owner }=awaitloadFixture(deployUniswapPoolFixture)constethAmount=10n**18n;constusdcAmount=3000n*10n**6n;consttickLower=-887272// Math.ceil(baseLog(BASE, Math.sqrt(1/1400)));consttickUpper=-tickLower// Math.ceil(baseLog(BASE, Math.sqrt(1/1200)));awaitweth.connect(owner).deposit({value: 100n*10n**18n});awaitweth.connect(owner).approve(contract.address,100n*10n**18n);awaitnetwork.provider.request({method: "hardhat_impersonateAccount",params: [USDC_WHALE]})constusdcWhale=awaitethers.getSigner(USDC_WHALE);expect(awaitusdc.balanceOf(USDC_WHALE)).to.be.greaterThan(usdcAmount);awaitusdc.connect(usdcWhale).transfer(owner.address,usdcAmount);awaitusdc.connect(owner).transfer(contract.address,usdcAmount);constnewPosition=awaitcontract.mintPosition(MAINNET_TOKENS.ETH,MAINNET_TOKENS.USDC,FEE,ethAmount,usdcAmount,tickLower,tickUpper);console.log(awaitdai.balanceOf(owner.address));// expect(daiBalanceAfter).to.be.equal(0);});
And I get the following error:
Error: Transaction reverted without a reason string
at <UnrecognizedContract>.<unknown> (0xc36442b4a4522e871399cd717abdd847ab11fe88)
at UniswapPool.mintPosition (contracts/uniswap/UniswapPool.sol:95)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at HardhatNode._mineBlockWithPendingTxs (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:1802:23)
at HardhatNode.mineBlock (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:491:16)
at EthModule._sendTransactionAndReturnHash (node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:1522:18)
at HardhatNetworkProvider.request (node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:118:18)
at EthersProviderWrapper.send (node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)
Note that I'm using MIN_TICK and MAX_TICK for the range
Can you please help me to understand what is wrong with my code?
Thank you very much in advance
The text was updated successfully, but these errors were encountered:
I am using the following method to mint a Uniswap v3 position:
I am able to mint a DAI-USDC 0.01% with this method. But when trying to create an ETH-USDC 0.3% pool it fails without a reason string
My test code is this:
And I get the following error:
Note that I'm using MIN_TICK and MAX_TICK for the range
Can you please help me to understand what is wrong with my code?
Thank you very much in advance
The text was updated successfully, but these errors were encountered: