joshstevens19 / simple-uniswap-sdk

Uniswap SDK which handles the routes automatically for you, changes in trade quotes reactive subscriptions, exposure to formatted easy to understand information, bringing back the best trade quotes automatically, generating transactions for you and much more.
MIT License
188 stars 95 forks source link

Unable to wrap ETH to WETH and unwrap WETH to ETH on Testnet #11

Open Z-Hau opened 3 years ago

Z-Hau commented 3 years ago

Unable to perform ETH > WETH and WETH > ETH on Testnet.

vm06007 commented 3 years ago

is this only for testnet?

vm06007 commented 3 years ago

I've experienced same on mainnet as well, swapped into ETH.MAINNET().contractAddress and got WETH back!

joshstevens19 commented 3 years ago

Can you give me a code sample so I can test this please. You should not get WETH using ETH logic like that and that would be something we should fix ASAP. ETH > WETH is supported on mainnet on this lib. A demo project on GitHub would be great. @vm06007

vm06007 commented 3 years ago

@joshstevens19 it looks like the route-path is not generated correctly, here is the output of trade object after it is created

Screen Shot 2021-08-28 at 6 34 15 PM

so despite the toToken is NO_CONTRACT_ADDRESS I'm still getting WETH swap, and not swapExactTokensForETH as expected

I can't share code, but it is straight forward just making pairFactory and then setting .trade(value);

following by

const signer = library.getSigner(account); await signer.sendTransaction(trade.transaction);

vm06007 commented 3 years ago

Screen Shot 2021-08-28 at 6 43 26 PM

vm06007 commented 3 years ago

if I can help somehow to resolve this let me know, happy to assist, meanwhile really cool package, sent you some dai: https://etherscan.io/tx/0x7f12891d19597ea32a419f932281f8ea228f244fed2f02a79ed649d1c4971908

joshstevens19 commented 3 years ago

Ahh nice spot ok will check this out tomorrow thanks a lot for your donation means a lot! Thanks for raising this issue 👍👍👍

joshstevens19 commented 3 years ago

So this is not part of this ticket but that is now fixed on version 3.4.2 for you @vm06007 great spot!! it now uses multicall to unwrap the weth for you so you get eth back now. I have tested this on rinkeby + mainnet both on input and output and seems to work fine. Let me know its all good your end and thanks again for raising.

In terms of unwrap and wrap eth on testnets should be pretty simple for me to add now I've done the changes for this so will look at that when I get a second as the ticket is quite old.

vm06007 commented 3 years ago

Okay cool! I'll upgrade, test it out and let you know

joshstevens19 commented 3 years ago

awesome this issue was only happening on v3 not v2 it seemed this was just an oversight from me that I forgot to unwrap it once the swap had done (after i refactored to allow native and weth to be separate things) yeah do let me know. Thanks again

vm06007 commented 3 years ago

looks good! tried on ropsten https://ropsten.etherscan.io/tx/0x21452ea2d7e895b2fb0b7a0fb993fa56af896210df397542b3676e72e45dee2f will give it a bit more testing on mainnet tomorrow.

joshstevens19 commented 3 years ago

Awesome!!!

vm06007 commented 3 years ago

All looks good! @joshstevens19 I've tried to send you another 0.05 ETH, but I think I've forgot one 0 https://etherscan.io/tx/0x6bf2ba27226061d09ddc680a9669fc7257812f71388faedd702f27baada38529 could you send it back to same wallet please? 😇

joshstevens19 commented 3 years ago

Haha!! Oh gosh @vm06007 thanks for the donation!! Yes you defo added a forgot a 0 haha il send it back to you once back on a computer later today, back to the same address yeah?

thanks again for your donation your a legend!!!!!

vm06007 commented 3 years ago

yeah :) same should be fine (0x6dbc5fbb69d43442a5bec07e18037896b1e2ef6d)

joshstevens19 commented 3 years ago

Sure will do this once back on PC (will be today) will send tx etherscan link once done. Thanks again for 0.05 ETH donation 👍

joshstevens19 commented 3 years ago

@vm06007 https://etherscan.io/tx/0xe0da6b719b9581af448ba2b56f99d0ef02467bc1da8c3fb019e5089aebfb63b8 < sent 0.45 ETH back! thanks again for the 0.05 donation! 👍