Yeah... you did a great job explaining this. I've now got about 10 documents from the Uniswap docs and other tutorials that can go in the bin. Much appreciated.
Awesome, thanks. If anyone is having trouble doing the swap, If you don't have any WETH in the wallet to start with you'll have to add value manually to the transaction.
Best explainer of code for uniswap trx I've found on youtube. Line by line function explainer with reference to documentation is such a benefit. Thanks! Subscribed and will be looking at all your vids.
If I may suggest something I would love to see in one of the new videos: how to programmatically access the parameters displayed by Uniswap (i.e. exchange rate, expected price, price impact, ...). Thank you very much in advance for your exceptional efforts and the way of presenting the chosen topic.
Is there any way you can create a video on how to also convert between WETH and stablecoins? Since WETH has 18 decimals and USDC has 6 decimals I'm not sure if I am doing something wrong. Also explaining how you would change the gas estimate and approval amount would be different in mainnet circumstances would be appreciated. Overall this is the clearest video Ive seen about making swaps. I'm still a beginner to defi so understanding the pools and how to swap between exchanges is something you've really helped me with. Thanks!
Hi there. Could you explain to me how to create the directories for the new blank note? Because I can't find the option in the Remix. Thank you so much.
Can anyone help with the dreaded: "error\":{\"code\":-32000,\"message\":\"transaction underpriced\"} on Polygon. I raised the gas price, reset my MetaMask. One source suggested aligning my gpo.ignorePrice with the txPool.pricelimit but didn't explain how. Please share any solutions or suggestions
Do you have any video on how to transfer any other tokens except eth? I’ve been trying to make swapExactTokensForTokens function in uniswap router to make it work, but still failing. I tried doing this same thing with just using the explorer contract write with wagmi, is it possible to do this that way without uniswap sdk?
To continue, we need clearer explanations and tips along with where we can contact you for programming tips. Token exchange and wallet transfer best explained so far.
Hi, now that ropsten network is depreceated post the merge upgrade of ethereum, I tried to replicate above steps in Goerli testnet. I was also able to find the pool address of UNI/WETH pool in goerli testnet through your another video. Although the approve transaction is running successfully, but the swap transaction fails with error STF. Can you please replicate this tutorial for post merge upgrade viewers as well, preferrably on goerli? Thanks!
Hello, firstly thanks for this, I am trying to execute it on mainnet with polygon. Only problem I have is that I am getting error: transaction underpriced. I adjusted the fee but it makes no difference. From reading forums it appears I need to set the gat price to at least 30 gwei. The response after executing the script is showing the gasPrice parameter = null, but the parameters 'gas price' is not taken by the ExactInputSingle function, so where is it specified?!
Hi, thank you for your videos. I have a question about Uniswap SDK that you used in this video. You got ABI of swapRouter from uni sdk, but actually I am trying to create this functionality using regular java. And I stuck at this moment, because I can’t find actual smart contract that responsive for that functionality of swapping tokens on V3. Can you please provide more information where I can obtain this ABI to create wrapper of this smartcontract?
Hey Blockman, thanks again for doing this video. I have my trades working but sometime I wont know if a trade didnt go through until I look on etherscan. Is there a way to know if tx went through at all on the program? Thanks in advance.
Great video! Where do we find pool addresses for test nets? I am connecting to Polygon Mumbai but can't find the correct pool and token addresses for the network.
@@blockmancodes I know how to query Uniswap V3 pools directly for their reserves (within the tick) but I don't know how to interact with that specific pool via the Uniswap V3 router and quoter. Would be great if you could show how to do this!
I'm actually interested in v2 to v3 swaps and vice versa, for trading between Uniswap and uniswap clones (i.e. sushiswap). From what I can see, it's just the swap function with a bit of junk data in the callback, but I can't quite figure out if I need to write a specific contract for v2/v3 swaps or if I can do it with ethers.js.
hi, when I update inputAmount from 0.001 to 0.01, I got "Error: invalid BigNumber string (argument="value", value="1e+21", code=INVALID_ARGUMENT, version=bignumber/5.6.2)". I wonder where went wrong?
Ropsten has now been deprecated, can this be converted and be done on Goerli testnet? How can I find the WETH/UNI pool address to replace the "0x4D7C363DED4B3b4e1F954494d2Bc3955e49699cC"?
It will work on Goerli if you have the correct addresses. There's no perfect way to find tokens for testnets. Etherscan searches, google, checking how many wallets have the token, etc...
Amazing stuff!! Sir, I wonder that is it possible to post some videos about using the Ganache fork network to do some transactions using Uniswap?? Thanks
Thanks for watching! I'll be covering most V3 swap and liquidity functions in my Uniswap course so I probably won't be doing TH-cam videos on them. Though I'll continue making videos on other V3 topics.
i tried this directly on optimism mainnet. it works. thank you sir. quick question tho, on Line 34 of uniswapTrader.js file, why did u define state and not use it?
how would one tweak this if they have the contracts for both tokens but no pool has been created yet, so we would run the script so that once a pool with those 2 tokens has been detected it buys
a) Continuously ping the factory getPool functions until you get a response indicating the pool exists b) Monitor events for new pool creations and check if the tokens match
How to setup "inputAmount" for USDC token for example? Got always this message "'{"jsonrpc":"2.0","id":65,"error":{"code":-32000,"message":"insufficient funds for gas * price + value"}}'"
@@blockmancodes I checked, i have more than 100 eth at Goerli network. Do you plan to create video about bridge tokens via script. (For example ETH-ARB bridge)?)
@@blockmancodes Also can you advice please. When i am tryng to swap more than 0.0099eth (for example 0.01) always got error "Error: invalid BigNumber string (argument="value", value="1e+21", code=INVALID_ARGUMENT, version=bignumber/5.7.0)" In the internet i found information, that js doesn't support so big numbers. Is it true?
Awesome, It is a great help for the community. I was looking for a solution how I can swap `UNI -> ETH`. I've tried similar approach, but got error with STF. Can you provide any clue?
@@blockmancodes Yes, I actually need to show the ETH balance to users. I found the idea of using WETH. I think I have to invoke the swapRouter multicall method to get the amount in ETH. But your videos helped a lot. Thank you very much. I am sorry for asking one more thing, By any chance do you have any code snippet/example how to invoke swapRouter multicall using ethers js? This will save a lot of time.
Much respect for these videos. You a coding monster. Does the wallet secret have spaces? And how can I send to test net and Mainnet? I need to make a swap with UNISWAP UNIVERSAL ROUTER. ASAP. Trying to learn as quick as possible. Thank you for the content!
The wallet secret is a long string of "random" characters. You may be mixing it up with the pass phrase. Figure out how to fork mainnet. This will speed you up when testing.
I've seen a lot of people get this error because they approve WETH but only have ETH in their wallet. Can you check that 1st if you haven't?
ปีที่แล้ว
@@blockmancodes I can't quite remember but I believe this message was misleading and was due to not enough gas supplied. I had the proper amount of assets to transfer, I just had too low gas limit as far as I remember.
best uniswap tut on youtube! i also tried doing it on bsc testnet, deploying via hardhat ok, and approving approved amount ok, but getting gas estimate error on swapExactInputSingle...
The videos are great. I'm trying to get it to work in Polygon but no way. It stops me in the approve of the contract. Do you have a Telegram group to be able to make more dynamic queries? Thank you
Hey! I'll be doing some polygon videos in the near future. I'll be sure to cover this. Too busy to manage a Telegram group at the moment but it's on my future roadmap.
@@blockmancodes Hi, I also tried to get this to work on Polygon, but failed ... Have you done a uniswap v3 polygon video yet, or some pointers on what is different there? thanks for the great video!
Just another excellent video. Yes, please move on with your suggestions to tweak gas fee and slippage. It's probably possible to get current gas fee for the selected network and depends of it set gas fee for swap transaction. Unfortunately, I still didn't manage to run this example successfully. For some reason I'm getting repeatedly the same error: 'insufficient funds for intrinsic transaction cost', code: 'INSUFFICIENT_FUNDS' although I have enough assets (over 0.2 ETH) and gas fee it seems that is currently 0.0062 ETH which is subtracted even if transaction failed (so your recommendation to run it on testnet is in place). Probably my problem is that I don't have WETH in my wallet but just ETH. Don't know currently how to wrap ETH on testnet. Any suggestion is welcome.
Bingo! It seems to work. One thing is not very clear to me and that is the exchange rate difference. Namely, it turns out that for 0.001 WETH I get only 0.00045 UNI. Maybe it's because I'm on a testnet. By the way, I also tried testing using Pocket Network as a provider. It's reporting an error SERVER_ERROR, which was not the case with the examples from your previous examples.
Glad you got it working! And you're correct, the weird swap rate is because it's on testnet. You probably know this but if you go to Uniswap and change to Ropsten in your Metamask you can also see these different prices. I haven't tried the code with Pocket but thanks for letting me know. I wonder if it's just some different configuration required.
@@blockmancodes Actually got the pool address u hv explained in another video. It was after one video inside your uniswap playlist. Just in wrong order I guess.
Learn to use all of Uniswap's swap and liquidity functionality with code. bit.ly/3JkXYqL
in this video in the description i see 67 dollars and i want to pay that 67 dollars is it still okay
Yeah... you did a great job explaining this. I've now got about 10 documents from the Uniswap docs and other tutorials that can go in the bin. Much appreciated.
Glad it was helpful brother
Awesome, thanks. If anyone is having trouble doing the swap, If you don't have any WETH in the wallet to start with you'll have to add value manually to the transaction.
Hi
How can I add Swaped value to tether to my wallet
Many thanks
Best explainer of code for uniswap trx I've found on youtube. Line by line function explainer with reference to documentation is such a benefit. Thanks! Subscribed and will be looking at all your vids.
Thank brother!
If I may suggest something I would love to see in one of the new videos: how to programmatically access the parameters displayed by Uniswap (i.e. exchange rate, expected price, price impact, ...). Thank you very much in advance for your exceptional efforts and the way of presenting the chosen topic.
Thanks for the suggestion! Adding that to my todo list.
@@blockmancodes Looking forward to see new great videos! Thank you very much.
Is there any way you can create a video on how to also convert between WETH and stablecoins? Since WETH has 18 decimals and USDC has 6 decimals I'm not sure if I am doing something wrong. Also explaining how you would change the gas estimate and approval amount would be different in mainnet circumstances would be appreciated. Overall this is the clearest video Ive seen about making swaps. I'm still a beginner to defi so understanding the pools and how to swap between exchanges is something you've really helped me with. Thanks!
Hi there. Could you explain to me how to create the directories for the new blank note? Because I can't find the option in the Remix. Thank you so much.
Can anyone help with the dreaded: "error\":{\"code\":-32000,\"message\":\"transaction underpriced\"} on Polygon.
I raised the gas price, reset my MetaMask. One source suggested aligning my gpo.ignorePrice with the txPool.pricelimit
but didn't explain how. Please share any solutions or suggestions
Really helpful
Eagerly waiting for your next tutorial on defi
Hi I hope you are doing well
How can I add swaped value to to my crypto wallet
Do you have any video on how to transfer any other tokens except eth?
I’ve been trying to make swapExactTokensForTokens function in uniswap router to make it work, but still failing. I tried doing this same thing with just using the explorer contract write with wagmi, is it possible to do this that way without uniswap sdk?
To continue, we need clearer explanations and tips along with where we can contact you for programming tips. Token exchange and wallet transfer best explained so far.
まじで神です。Goat🐏
Nice video. Please do more video about trading bot and arbitrage bot.
i tried this last 3 weeks but i cant get it to work. but i do swaps with v2.
Amazing! Don’t forget please about making pancakeSwap V3 tutorials
Thanks for the reminder :)
Hi, now that ropsten network is depreceated post the merge upgrade of ethereum, I tried to replicate above steps in Goerli testnet. I was also able to find the pool address of UNI/WETH pool in goerli testnet through your another video. Although the approve transaction is running successfully, but the swap transaction fails with error STF. Can you please replicate this tutorial for post merge upgrade viewers as well, preferrably on goerli? Thanks!
I was also struggling with this. It turned out that you have to have some WETH to do the transaction. It does not work with unwrapped ETH.
Can confirm that adding WETH solved this problem on Goerli 👌
Explain better than everyone in TH-cam!
Thanks sir. 🫡
Really great video. Well done and thank you!
Hello, firstly thanks for this, I am trying to execute it on mainnet with polygon.
Only problem I have is that I am getting error: transaction underpriced. I adjusted the fee but it makes no difference. From reading forums it appears I need to set the gat price to at least 30 gwei. The response after executing the script is showing the gasPrice parameter = null, but the parameters 'gas price' is not taken by the ExactInputSingle function, so where is it specified?!
Is an await not required when calling the slot0() function at @17:15 ?
Any idea how I can find the pool address for uniswap's WETH/UNI pool on Sepolia?
Same problem... also, in general, how do I find suitable pools for token swaps?
did you find it?
Highly Appreciated Bro
Glad it's helpful brother
Hi, thank you for your videos. I have a question about Uniswap SDK that you used in this video. You got ABI of swapRouter from uni sdk, but actually I am trying to create this functionality using regular java. And I stuck at this moment, because I can’t find actual smart contract that responsive for that functionality of swapping tokens on V3. Can you please provide more information where I can obtain this ABI to create wrapper of this smartcontract?
You can get any popular ABI from etherscan in the contract code section at the bottom
Hey Blockman, thanks again for doing this video. I have my trades working but sometime I wont know if a trade didnt go through until I look on etherscan. Is there a way to know if tx went through at all on the program? Thanks in advance.
Yes. I can do a video on this soon
Hello
There are two videos you did, another with alpharouter. Can you pls tell which one is for what?
Given a choice, use the alpharouter. It's more optimized.
Great video! Where do we find pool addresses for test nets? I am connecting to Polygon Mumbai but can't find the correct pool and token addresses for the network.
I have another video on finding token and pool addresses. Can you find it?
What else do you want to learn to do with Uniswap?
Can you show how to do a multihop swap with v3 like eth > usdc > uni? Im still struggling with a multihop swap
@@TN-jz5gb Added to my to-do list!
@@blockmancodes I know how to query Uniswap V3 pools directly for their reserves (within the tick) but I don't know how to interact with that specific pool via the Uniswap V3 router and quoter. Would be great if you could show how to do this!
@@timgraf7793 Can you clarify "interact with that specific pool via the Uniswap V3 router and quoter"?
You want to swap tokens, or do something else?
I'm actually interested in v2 to v3 swaps and vice versa, for trading between Uniswap and uniswap clones (i.e. sushiswap). From what I can see, it's just the swap function with a bit of junk data in the callback, but I can't quite figure out if I need to write a specific contract for v2/v3 swaps or if I can do it with ethers.js.
thank you for sharing sir
hi, when I update inputAmount from 0.001 to 0.01, I got "Error: invalid BigNumber string (argument="value", value="1e+21", code=INVALID_ARGUMENT, version=bignumber/5.6.2)". I wonder where went wrong?
It seems have something to do with approvalAmount, after i change *1000 to *10, it works.
@@vincentli1994 Good job!
Ropsten has now been deprecated, can this be converted and be done on Goerli testnet? How can I find the WETH/UNI pool address to replace the "0x4D7C363DED4B3b4e1F954494d2Bc3955e49699cC"?
It will work on Goerli if you have the correct addresses. There's no perfect way to find tokens for testnets. Etherscan searches, google, checking how many wallets have the token, etc...
This is a great tutorial!What parameters do I need to add Uniswap v3 in an arbitrage smart contract written in V2 (eg flashbots)?thanks(newby asking)
It totally depends on the code in your contract. Is it public code or something you wrote yourself?
Amazing stuff!! Sir, I wonder that is it possible to post some videos about using the Ganache fork network to do some transactions using Uniswap?? Thanks
Added it to my to-do list!
Hey can you make a video on swapping both ways and with one of the tokens being variable
For sure, it's on my to-do list.
Great stuff thank you so much!
Glad it was helpful!
Thanks. do exactInput demo please
Thanks for watching!
I'll be covering most V3 swap and liquidity functions in my Uniswap course so I probably won't be doing TH-cam videos on them.
Though I'll continue making videos on other V3 topics.
can you guide me how to buy tokens fast on pankerswap on bsc or other networks with usdt usdc
I'll add it to my todo list
Thank you for this awesome tutorial. Does this still work for Goreli
As of today, this should still work on Goerli
i tried this directly on optimism mainnet. it works. thank you sir. quick question tho, on Line 34 of uniswapTrader.js file, why did u define state and not use it?
is it for the swap params?
Good catch brother! It's not needed. I was originally going to make the tutorial more complicated, but changed my mind and didn't remove that.
how would one tweak this if they have the contracts for both tokens but no pool has been created yet, so we would run the script so that once a pool with those 2 tokens has been detected it buys
a) Continuously ping the factory getPool functions until you get a response indicating the pool exists
b) Monitor events for new pool creations and check if the tokens match
hi, mate, any idea to get real time data from dex(uniswap, etc) like cex data stream?
Did you try the subgraph?
great tutorial.
Thanks brother
Could we interact with pool contract directly without SwapRouter? and how
Yes you can. The swap router calls swap on a pool under the hood. I'll try to do a quick video sometime soon
@@blockmancodes great! can't wait!
How to setup "inputAmount" for USDC token for example?
Got always this message "'{"jsonrpc":"2.0","id":65,"error":{"code":-32000,"message":"insufficient funds for gas * price + value"}}'"
Sounds like you don't have enough ETH in your wallet for the transaction
@@blockmancodes I checked, i have more than 100 eth at Goerli network. Do you plan to create video about bridge tokens via script. (For example ETH-ARB bridge)?)
@@blockmancodes Also can you advice please. When i am tryng to swap more than 0.0099eth (for example 0.01) always got error "Error: invalid BigNumber string (argument="value", value="1e+21", code=INVALID_ARGUMENT, version=bignumber/5.7.0)" In the internet i found information, that js doesn't support so big numbers. Is it true?
Thanks for the great video. Any plans to do this same content but written in Python?
Thanks! TBH I have a few thousand tutorials on my to-do list so I probably won't get to Python for a long time
@@blockmancodes pretty small to-do list
Do you have an equivalent video for Uniswap V2?
Working on one
I watched you video about Error: VM Exception while processing transaction: reverted with reason string 'STF' . But I'm still fighting this stuff))
Do you have WETH (not ETH) in your wallet?
I'm newbie,
can someone tell me how can i get 'INFURA_URL_TESTNET=' value. tks
Create a free account on Infura io, create a project then get the endpoint URL from settings
Awesome, It is a great help for the community.
I was looking for a solution how I can swap `UNI -> ETH`. I've tried similar approach, but got error with STF. Can you provide any clue?
Try with WETH rather than ETH?
@@blockmancodes Yes, I actually need to show the ETH balance to users. I found the idea of using WETH. I think I have to invoke the swapRouter multicall method to get the amount in ETH. But your videos helped a lot. Thank you very much.
I am sorry for asking one more thing, By any chance do you have any code snippet/example how to invoke swapRouter multicall using ethers js? This will save a lot of time.
@@YeasinRahaman I don't have any code examples sitting around for multicall. But will try to put together a quick video sometime soon
@@blockmancodes Thanks a lot. Really appreciate your help.
Much respect for these videos. You a coding monster.
Does the wallet secret have spaces? And how can I send to test net and Mainnet?
I need to make a swap with UNISWAP UNIVERSAL ROUTER.
ASAP. Trying to learn as quick as possible.
Thank you for the content!
The wallet secret is a long string of "random" characters. You may be mixing it up with the pass phrase.
Figure out how to fork mainnet. This will speed you up when testing.
@@blockmancodes just bought your class.
Does will this teach how to form main and test net?
Whatever I do, I get 'Failed with STF' error. I have unlimited token approval already. Do I miss something?
I've seen a lot of people get this error because they approve WETH but only have ETH in their wallet. Can you check that 1st if you haven't?
@@blockmancodes I can't quite remember but I believe this message was misleading and was due to not enough gas supplied. I had the proper amount of assets to transfer, I just had too low gas limit as far as I remember.
Can you please make a similar video for pancakeswap? I tried tweaking this one with corresponding addresses but couldn't get it to work 🙁
On my todo list brother
best uniswap tut on youtube! i also tried doing it on bsc testnet, deploying via hardhat ok, and approving approved amount ok, but getting gas estimate error on swapExactInputSingle...
The videos are great. I'm trying to get it to work in Polygon but no way. It stops me in the approve of the contract. Do you have a Telegram group to be able to make more dynamic queries? Thank you
Hey! I'll be doing some polygon videos in the near future. I'll be sure to cover this.
Too busy to manage a Telegram group at the moment but it's on my future roadmap.
@@blockmancodes Hi, I also tried to get this to work on Polygon, but failed ... Have you done a uniswap v3 polygon video yet, or some pointers on what is different there? thanks for the great video!
@@julian007swiss Hey brother. I haven't done any Polygon videos yet. But hoping to do some this year sometime
Please do multi hop swaps!
Added to my roadmap brother. May take me a while to get to it though
Just another excellent video. Yes, please move on with your suggestions to tweak gas fee and slippage. It's probably possible to get current gas fee for the selected network and depends of it set gas fee for swap transaction. Unfortunately, I still didn't manage to run this example successfully. For some reason I'm getting repeatedly the same error: 'insufficient funds for intrinsic transaction cost', code: 'INSUFFICIENT_FUNDS' although I have enough assets (over 0.2 ETH) and gas fee it seems that is currently 0.0062 ETH which is subtracted even if transaction failed (so your recommendation to run it on testnet is in place). Probably my problem is that I don't have WETH in my wallet but just ETH. Don't know currently how to wrap ETH on testnet. Any suggestion is welcome.
Bingo! It seems to work. One thing is not very clear to me and that is the exchange rate difference. Namely, it turns out that for 0.001 WETH I get only 0.00045 UNI. Maybe it's because I'm on a testnet.
By the way, I also tried testing using Pocket Network as a provider. It's reporting an error SERVER_ERROR, which was not the case with the examples from your previous examples.
Glad you got it working! And you're correct, the weird swap rate is because it's on testnet.
You probably know this but if you go to Uniswap and change to Ropsten in your Metamask you can also see these different prices.
I haven't tried the code with Pocket but thanks for letting me know. I wonder if it's just some different configuration required.
@@blockmancodes Tested also yesterday with Alchemy. Works fine.
how do you get testnet url ?
You can create an account on Infura to get one
Can I use this on Remix?
I'm not an expert on remix, but this is all javascript so you can easily run locally
@@blockmancodes is there a website to code JavaScript like Remix? Or do I have to download software?
I’m a super noob at the moment
From where did u get address for uni/eth
You can find addresses by searching Etherscan
@@blockmancodes Actually got the pool address u hv explained in another video.
It was after one video inside your uniswap playlist. Just in wrong order I guess.
Hi i finally did it thanks
USEEEEEEEEEEEE TYPESCRIPTTTT MY FRIEND
I love you man ❤️ no homo
Haha thanks brother
Can you do same video for polygon mainnet? Or how to use testnet and all popular mainnet.
Added to my todo list