Timeline for Swap tokens back to ether on Uniswap V2 Router 02 (Sell tokens)
Current License: CC BY-SA 4.0
16 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 1, 2020 at 5:47 | comment | added | gbenroscience | Here is the working transaction: kovan.etherscan.io/tx/… | |
Jul 1, 2020 at 4:58 | comment | added | the_cranky_panda | No problem What was the issue, out of curiosity? | |
Jul 1, 2020 at 4:30 | comment | added | gbenroscience | Alright thanks for your help, I finally got it working. | |
Jul 1, 2020 at 4:15 | comment | added | the_cranky_panda | Your original question was about "Fail with error 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT. What could be the issue, please?'" which I answered and solved, not "I can't made a uniswap trade, please help me get working code" :) The other error should have been a separate question technically | |
Jul 1, 2020 at 3:58 | comment | added | gbenroscience | Hi, I didnt mark it as answered because all the tests I ran on my code using your suggestions didnt work, so I have no way of knowing if the question is answered or not. Anyway, if you were writing my code for me, you would have provided a working example of how to do the swap in your answer but you didnt. I spent valuable hours trying to glean out details from you, so dont blame me for not accepting your answer. Anyway, I give you the benefit of the doubt that I am the one not doing something right on my end. | |
Jul 1, 2020 at 3:52 | vote | accept | gbenroscience | ||
Jul 1, 2020 at 3:31 | comment | added | the_cranky_panda |
Oops, I meant that you should do approve(address(usi), amount) not approve(address(this), amount) . Anyway, the original question has been answered and I'm basically writing your code for you at this point so could you mark the question as answered please
|
|
Jun 30, 2020 at 22:41 | comment | added | gbenroscience |
It still failed with the same error after I added the code to approve. The dai_address in IERC20 dai = IERC20(dai_address) , is it same as the crypto address passed to the parameter in my example? Please see my edit to the question
|
|
Jun 30, 2020 at 21:53 | comment | added | the_cranky_panda | Definitely before :) | |
Jun 30, 2020 at 19:57 | comment | added | gbenroscience | Thanks a lot. One more thing though, will I do the approval before or after the call to swapExactTokensForEth? | |
Jun 30, 2020 at 19:24 | comment | added | the_cranky_panda |
You can't interact with UniswapV2Router2 to change the allowance amount in the Dai contract, you have to call the Dai contract itself. You need an ERC20 interface like github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/… and have IERC20 dai = IERC20(dai_address); dai.approve(address(this), amount_to_approve);
|
|
Jun 30, 2020 at 19:08 | comment | added | gbenroscience | I figured as much but I haven't done this before using Uniswap v2 Router02. Can you show a sample that will help with this? | |
Jun 30, 2020 at 19:05 | comment | added | the_cranky_panda |
I think it's because you haven't called approve on the Dai contract that will allow UniswapV2Router2 to withdraw your Dai and deposit it in to the Dai/Eth pair. You need to do dai.approve(address_of_your_contract, large_uint) Btw if you're using mainnet or a testnet, you can use dashboard.tenderly.co/explorer and it'll show you the code of the error
|
|
Jun 30, 2020 at 18:50 | comment | added | gbenroscience | please check my edit | |
Jun 30, 2020 at 18:41 | comment | added | gbenroscience | I changed it to getAmountsOut, now it says: Fail with error 'TransferHelper: TRANSFER_FROM_FAILED' kovan.etherscan.io/tx/… | |
Jun 30, 2020 at 17:39 | history | answered | the_cranky_panda | CC BY-SA 4.0 |