1

I am trying to interact with Uniswap's SwapRouter smart contract directly on Rinkeby Etherscan, but with no success. I would like to swap ETH to DAI or ETH to WETH for example.

Here is what I am trying to do.

  1. Go to Uniswap SwapRouter smart countract on Rinkeby Etherscan and open smart contract's write functions.

  2. Then I expand the function exactInputSingle.

    • Here on the first field payableAmount (ether) I put 0.00000001

    • On the second field params (tuple) I put the following data:

{
    "tokenIn": "0xc778417E063141139Fce010982780140Aa0cD5Ab",    // WETH address
    "tokenOut": "0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735",   // DAI address
    "fee": 3000,                                                // Liquidity providers fee
    "recipient": "my-wallet-address", 
    "dealline": 1633596832,         // Timestamp in seconds
    "amountOut": 1000,              // Desired out amount 1000 DAI in this case
    "amountInMaximum": 0.00000001,  // Same value that I use on the first field payableAmount
    "sqrtPriceLimitX96": 0 
}
  1. Now when I click Write I get the following error:

invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.1.1)

Obviously value is undefined and my question is:

How am I suppose to pass the value?

I've tried to put the value inside the params tuple - not working.

I've tried to pass the value inside the first input (payableAmount) like {"value": 0.00000001} - not working.

I've tried to pass it before the tuple like this:

{"value":0.00000001}({"tokenIn": "...", "tokenOut": "...", ...})

but it is failing with another message:

({value:1e-8}) is not a function

I see that using Solidity, people are doing something like this:

uniswapRouter.exactInputSingle{ value: msg.value }(params);

Is it possible to do such a call using Etherscan or not?

Any help will be appreciated, thank you in advance!

2 Answers 2

1

I'm not familiar how the code is written on Etherscan but here some aspects which might be helpful.

  1. In order to successfully swap WETH to DAI there must be a Uniswap pool available on Rinkeby. I found a pool using the following addresses for WETH and DAI

    address public constant WETH = 0xc778417E063141139Fce010982780140Aa0cD5Ab; // WETH on Rinkeby Testnet

    address public constant DAI = 0x5592EC0cfb4dbc12D3aB100b257153436a1f0FEa; // DAI on Rinkeby Testnet

  2. Uniswap pools can have 3 different pool fees (500 WEI, 3000 WEI, 10000 WEI) - you have to find the fee for the pool you are using - in this case it is 500 WEI

  3. I don't know how you enter the ether amount using Etherscan but with regards to your params tuple it looks like you have used the params for the exactOutputSingle function. For exactInputSingle the params are:

             tokenIn: DAI,
             tokenOut: WETH9,
             fee: poolFee,
             recipient: msg.sender,
             deadline: block.timestamp,
             amountIn: amountIn,
             amountOutMinimum: 0,
             sqrtPriceLimitX96: 0
    

For more information take a look at the uniswapV3 docs https://docs.uniswap.org/protocol/guides/swaps/single-swaps

Hope that might be helpful

1
  • Thanks mate for your post. Good point for the tuple parameters. I did some checks once again on the javascript of etherscan.io (fortunately it is not minified) and I think the problem is coming from the code there, because this code is not able to select the input which is holding the payable amount and it is coming as undefined.
    – codtex
    Jan 7 at 8:03
0

Did you check if Rinkeby provides a pool for (WETH, DAI)? I had the issue on Ropsten, that (WETH, ENS) was not available. You might be running into the same issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.