Hello everyone,
I tried to just copy-paste the UniswapV2 factory and UniswapV2 Router in order to learn how everything work but I have a problem : when I try to addLiquidity with 2 tokens, I can't...
The error is : Transaction has been reverted by the EVM.
The factory contract : https://goerli.etherscan.io/address/0x952C4F94A3887914dE1024e9a2dc7BF2791313f9#code
The router contract : https://goerli.etherscan.io/address/0x9576c73e58C1Dad8A23Eb8554d0e835245c67b25#code
I don't understand why it doesn't work, because it's the same contract, maybe I missed something ?
I managed to add liquidity with the (real) UniswapV2Router, this is the tx : https://goerli.etherscan.io/tx/0xb1f9f541cad4c2631be214d25c1005fbac8e163075764d98021a7c5f4ab52f66
And this is the tx where I have the error : https://goerli.etherscan.io/tx/0x4f23b915a7bf26ae0db1c1a9c7fb957348c3aab38a1531f99fbbbe1777337a26
There is a picture of the error on MetaMask :
Thank you for your time, have a good day !
Looking into the details of your failed transaction:
Function: addLiquidity(address tokenA,address tokenB,uint256 amountADesired,uint256 amountBDesired,uint256 amountAMin,uint256 amountBMin,address to,uint256 deadline)
MethodID: 0xe8e33700
[0]: 000000000000000000000000c4ef2d58ed6d82b526b08c6cbf197512e49e615d
[1]: 000000000000000000000000075ddee5920040b10f24a3ed16a61bb5bcd1204c
[2]: 000000000000000000000000000000000000000000000000d02ab486cedc0000
[3]: 000000000000000000000000000000000000000000000000d02ab486cedc0000
[4]: 0000000000000000000000000000000000000000000000000000000000000001
[5]: 0000000000000000000000000000000000000000000000000000000000000001
[6]: 0000000000000000000000004f1d70a9e9f0ed850fcf00546325ce1cd6f03423
[7]: 00000000000000000000000000000000000000000000000000000000646daf32
And then into the details of your successful transaction:
Function: addLiquidity(address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline)
MethodID: 0xe8e33700
[0]: 000000000000000000000000075ddee5920040b10f24a3ed16a61bb5bcd1204c
[1]: 000000000000000000000000c4ef2d58ed6d82b526b08c6cbf197512e49e615d
[2]: 000000000000000000000000000000000000000000000000d02ab486cedc0000
[3]: 000000000000000000000000000000000000000000000000d02ab486cedc0000
[4]: 0000000000000000000000000000000000000000000000000000000000000001
[5]: 0000000000000000000000000000000000000000000000000000000000000001
[6]: 0000000000000000000000004f1d70a9e9f0ed850fcf00546325ce1cd6f03423
[7]: 00000000000000000000000000000000000000000000000000000000646c6f60
They appear different.
In additions to that, the two contracts deployed at the provided token addresses don't seem like standard ERC20 token contracts:
But they worked for you in the successful transaction, so I'm not gonna be the judge of that...
Hi, thank you for your answer.
The difference between those transactions is that [0] and [1] are inverted (but no problem because it's address token A and address token B). And the [7] is the deadline.
Yes the two contracts are some test contract I've deployed !
Well, before determining that your transaction fails because it runs on the new contract, can you first make sure that it is the exact same transaction which completes successfully on the original contract?
yes, there is the details :
tx1 on the actual Uniswap Router (succeed) :
tx2 on the copy-past uniswap router (fails) :
everything is the same (same method, same amounts, same addresses) just the two tokens are inverted and the deadline is not the same
Dude, those aren't identical transactions!
As I explained on the previous comment, you are not passing the same input values in the same order.
Before determining that the problem is in a specific contract vs another contract, you need to make sure that you are doing the same thing on both contracts (I've also explained that in the previous comment).