UniswapV3Router

My bad, this contract is indeed a V3 contract which implements function exactInputSingle.

Your naming choice (SWAP_ROUTER_02) has confused me.

I'll have another look to see what could go wrong inside your contract function or inside the V3 contract function which your function calls...

Please conduct the following investigation process:

  1. Change your contract function to this:
function swapExactOutputSingle(uint256 amountIn, uint test) external returns (uint256 amountOut) {
    TransferHelper.safeTransferFrom(DAI, msg.sender, address(this), amountIn);
    require(test != 111, "safeTransferFrom did not revert");

    TransferHelper.safeApprove(DAI, address(swapRouter02), amountIn);
    require(test != 222, "safeApprove did not revert");

    IV3SwapRouter.ExactInputSingleParams memory params = IV3SwapRouter.ExactInputSingleParams({
        tokenIn: DAI,
        tokenOut: WETH9,
        fee: 3000,
        recipient: address(this),
        amountIn: amountIn,
        amountOutMinimum: 0,
        sqrtPriceLimitX96: 0
    });
        
    amountOut = swapRouter02.exactInputSingle(params);
    require(test != 333, "exactInputSingle did not revert");
}
  1. Redeploy the new contract

  2. Approve the new contract to transfer tokens from your wallet

  3. Execute the new contract function with input test = 111 and check the revert message

  4. Execute the new contract function with input test = 222 and check the revert message

  5. Execute the new contract function with input test = 333 and check the revert message

The above process should indicate the point at which your contract function reverts.

Please post the results in order to allow for further investigation.

Thanks, mate,I will redeploy it and post the result.

Mate,when I am trying to call the function,it throws this error,

Yes, the transaction is meant to revert with a message. You need to obtain that message somehow, and I suppose that by sending the transaction, you will be able to observe that message on goerli/basescan.

Yeah,I done that also,This my txn hash:https://goerli.basescan.org/tx/0x44c409037e7d005f9eb4e6591400aacc3fb186f9f99bdaea5f12a7d700d3eeb3

That's just one transaction, with the input test = 333.

You still "owe me" two additional transactions, with test = 111 and test = 222.

And there's an additional problem - basescan doesn't display the revert message.

My guess - this is because you haven't verified your contract source code, so please do that.

ok mate,i will do it

Hi mate,
1)test = 111
txnhash:https://goerli.basescan.org/tx/0x21a44eee5b55374fdbd60b86c4ec008bb2b5ad899410cd7cb6a31e1cff158f1e
2)test = 222,
txnhash:https://goerli.basescan.org/tx/0x836d23909e9cbf91bfcefa98109c8a5fa0bb23d759b95e8a815e36721d3b4719
3)test = 222
txnhash:https://goerli.basescan.org/tx/0x15626b7f22bc741a646bf2b8c374d6c6356c5e8d2f37de44571e9ad9f0baf60e

Good job!

So we see safeTransferFrom did not revert and safeApprove did not revert.

But we don't see exactInputSingle did not revert, which means that the line:

amountOut = swapRouter02.exactInputSingle(params);

Has reverted the transaction before the line:

require(test != 333, "exactInputSingle did not revert");

was executed (i.e., before this line "had the chance" to revert the transaction).

So what is the next step to solve that error, @barakman .

This is the Router contract which you are interacting with.

It implements a function which returns the address of a Factory contract:

This is the Factory contract.

It implements a function which returns the address of a Pool contract corresponding to a given pair of tokens and a given fee:


As you can see, there is currently no Pool contract corresponding to your pair of tokens and your fee.

But,when i am trying to swap these token in Pancakeswap,i am able to swap it
.Here is the txnHash:https://goerli.basescan.org/tx/0x99694e2d2208eeaadcdef262827b0347a5aa84775a79dadecabd6cf95b5af916

This pancakeswap router doesn't use the same factory as the uniswap router that your contract interacts with:

Then,How to create a pair Mate,Because i created a LP pair using pancakeswap.

Thanks mate,I will create and try it,and let you know mate

1 Like

I'm pretty sure that in order to execute a swap on this new pool, you'll need to transfer some liquidity to that pool after you create it. But I'm not very familiar with UniV3, so I might be wrong here.

ok mate,No probelm,I will check how to add liquidity to that pool

1 Like