Uniswap V3 Tutorial | Uniswap Smart Contract (Single Swap) | DeFi Tutorial

Поділитися
Вставка
  • Опубліковано 11 жов 2022
  • In this Uniswap tutorial create a smart contract that implements a simple ERC20 token swap (Uniswap single swap) using the Uniswap V3 protocol. This DeFi tutorial explores the Uniswap V3 ISwapRouter interface for executing token swaps from Uinswap liquidity pools. Follow along and learn about this important DeFi primitive.
    GitHub repo for this tutorial:
    github.com/jspruance/uniswap-...
    LINK:
    0x326C977E6efc84E512bB9C30f76E30c160eD06FB
    WETH:
    0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6
    USDC:
    0x07865c6E87B9F70255377e024ace6630C1Eaa37F
    Uniswap Swap Router address:
    0xE592427A0AEce92De3Edee1F18E0157C05861564
    SingleSwap.sol deployed:
    0xBdfCf1e48Fb8E7C66Fd7E0541BF9b1cf67558c49
    Deploy contract:
    npx hardhat run --network goerli scripts/deploySingleSwap.js
    GitHub direct link for Remix:
    import "github.com/Uniswap/v3-periphe...";
  • Наука та технологія

КОМЕНТАРІ • 93

  • @code.badger
    @code.badger Рік тому +34

    This channel is a hidden gem

  • @ouailtayarth4012
    @ouailtayarth4012 Рік тому +6

    I've been looking for this type of high-quality DeFi content for almost a month, and I just found it! Thank you for your efforts, and please keep up the good work

  • @quantaraum
    @quantaraum Рік тому +2

    i lovr the red string pullinh through your tutorial.
    you help us really understand the different sections and connecting each point on our own.
    Big props!
    much appreciated

  • @dannithomx
    @dannithomx Рік тому

    Thanks for this video, I was stuck up on this tiny thing that I just couldn't see it. It caused my swaps to keep reverting, thanks to you I was able to spot it and move past it. Great work, keep up the good work chief!!!

    • @redbeet4772
      @redbeet4772 11 місяців тому

      My swap also keep reverting, do you happen to know what I missed?

  • @luiscallero6288
    @luiscallero6288 4 місяці тому

    Love it how you go step by step and give it a clear and simple explanation of the contract provided by Uniswap. Uniswap should attach this video to better explain the documentation. Uniswap documentation is very poor. So your review is awesome!! Thanks!!

  • @BitcoinAndCryptoCurrency
    @BitcoinAndCryptoCurrency 10 місяців тому

    I have watched many videos on crypto and this is the first one I watched twice - loved it

  • @codywatt7775
    @codywatt7775 4 місяці тому

    Awesome work my friend. Thank you for putting in the time to make this for us. It has been super helpful!

  • @user-ir9xc3gg4v
    @user-ir9xc3gg4v 20 днів тому

    Thanks bro . great video !

  • @pratyushchauhan6944
    @pratyushchauhan6944 26 днів тому

    amazing contribution ser!!!

  • @LoreBaculima
    @LoreBaculima 10 місяців тому

    Super helpful, thank you!!!

  • @samadams4751
    @samadams4751 Рік тому +3

    Another great tutorial🙏

  • @matinjiryaeisharahi4294
    @matinjiryaeisharahi4294 8 місяців тому

    I appreciate you , It was very useful

  • @josephdelgiorgio3997
    @josephdelgiorgio3997 Рік тому +3

    Great video. I just applied to work at UniSwap, chances of getting hired are slim, but they have a great product and its awesome to see it work in realtime through the lens of these tutorials. Thank you!

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому +1

      Awesome! Glad you liked it and good luck : )

    • @harris998
      @harris998 8 місяців тому

      ​@@BlockExplorerMedia hello there, is there a way I can contact you regarding a Coding service question, maybe tw or email

  • @BitcoinAndCryptoCurrency
    @BitcoinAndCryptoCurrency 9 місяців тому

    very good to learn the currency future

  • @BitcoinAndCryptoCurrency
    @BitcoinAndCryptoCurrency 9 місяців тому +1

    informative and educational thanks

  • @oreosworldxp9654
    @oreosworldxp9654 3 місяці тому

    Bro this channel is based asf. Good shit bro. You’re smart dev. Let me find out you launch Pepe

  • @BitcoinAndCryptoCurrency
    @BitcoinAndCryptoCurrency 10 місяців тому

    very good and informative video

  • @sahbibayari7133
    @sahbibayari7133 Рік тому

    Thanks for sharing this diamonds infos ❤️

  • @BitcoinAndCryptoCurrency
    @BitcoinAndCryptoCurrency 10 місяців тому

    easy to understand thanks

  • @BitcoinAndCryptoCurrency
    @BitcoinAndCryptoCurrency 10 місяців тому

    pleased I chose this video to learn from

  • @Abdulkadir-vb3vj
    @Abdulkadir-vb3vj Рік тому

    Thanks for the great tutorial. Where can I get those test tokens? I mean LINK and USDC especially. I found no faucet for addresses you used.

  • @basitkhan3853
    @basitkhan3853 Рік тому

    Good content

  • @vinayakshukla2653
    @vinayakshukla2653 Рік тому

    thanksAloT very usefull

  • @BitcoinAndCryptoCurrency
    @BitcoinAndCryptoCurrency Рік тому

    my questions have been answered

  • @user-tt7hl2fb6i
    @user-tt7hl2fb6i 3 місяці тому

    Thank you for this video! It provides a great explanation!
    However I have one question. This example perfectly works on my edu project, but contract can`t take and return money directly to the "owner", metamask account. The swap works great before i try to connect it with the client metamask. I will be so grateful if you can help me to pair contract with metamask. Thanks in advance.

  • @xheikhfazi5481
    @xheikhfazi5481 Рік тому

    Great Content learning lots of stuff....

  • @thedemonlord300
    @thedemonlord300 7 місяців тому

    Hey could you tell me why we chose to write the functions of the IERC20 interface at the start of the contract instead of just importing the entire IERC20 contract like in the Flash Loan contract?

  • @dtory
    @dtory 9 місяців тому

    Hey, can you explain the use of ask
    Incase we want to deployed it on other network and Testnet other than bsc and Eth/tesnet

  • @xlogic5020
    @xlogic5020 Рік тому

    That's a great educational video ! l have a question. For example we have a wallet and l have eth in it. l want to swap eth to "x" token with a transfer prosess with this system. If l send eths to this contract. Can this contract do this for me or should l do some different changes ? l am looking forward your respond.

  • @roxanabraescu6180
    @roxanabraescu6180 Рік тому

    Hi, Thanks for your videos they are very educational..... Question ⁉️ I want a flashloan but I don't know how to code it or if it's possible... Example I want to buy eg, Eth from binance at lower price and then sell the Eth to eg, Kucoin for more. How can I specify in the code to buy from binance and sell on kucoin and then pay the flashloan??.

  • @diiialee7012
    @diiialee7012 Рік тому

    Do you prefer email? Or nah? Also is your patreon still accessible and you still use it.

  • @kurdvevoofficial
    @kurdvevoofficial Рік тому +1

    first thanks for you content tutu hope you make tut about erc20 token and full video and include all function such as :
    Tax
    Transferable
    Tradable
    Mintable
    Burnable
    Transfer Ownership
    Secure

  • @paraipan-rq2sj
    @paraipan-rq2sj Місяць тому

    very initeresting, but goerli is deprecated. how do i do to change to sepolia? im new to this . thank you .

  • @user-tx6hc8el1r
    @user-tx6hc8el1r 7 місяців тому

    Have you made a video where u can unclog the smart contract ?

  • @xheikhfazi5481
    @xheikhfazi5481 Рік тому

    Sir if you can help us that how we can get price of a pair on different exchanges like uniswap,sushiswap it will be a great favour...

  • @user-hl6hv3qu9c
    @user-hl6hv3qu9c 11 місяців тому

    where can i get copious amoutn of test tokens for usdc / weth ; unable to start with a 1000 each; any pointers will help even for polygon testnetwork

  • @velafresh
    @velafresh Місяць тому +1

    My token got split up into two routes 90% and 10% but I never received the 10% so basically I instantly lost $106 what exactly happen here do you think?

  • @amalnathsathyan6029
    @amalnathsathyan6029 11 місяців тому

    30:27
    I think the Quoter contract can get the reserves and give the prices.

  • @shankarmettur1551
    @shankarmettur1551 Рік тому

    I will create token new contract but I can not swap to another contract how to posible than liqudity pool make

  • @juanmosqueda2210
    @juanmosqueda2210 2 місяці тому

    I know this is kind an off topic but I'll take my shoot here too. Is possible to get the routerAddress by code? I am trying to replicate this in to the Fuji testnet but I can't find it in any documentation (Uniswap or Avalanche) so I'm wondering if it possible to code something that return that address but based in what I researched it looks like is simple not possible. Any help I will really appreciate it.

  • @ashishjanghel9340
    @ashishjanghel9340 Рік тому

    I am facing issue on your flashloan tutorial while running on mainnet polygon....can you please help

  • @stepchild5453
    @stepchild5453 10 місяців тому

    So I just need to import the github link to remix? That's gona run the universal router?

  • @ViralKiller
    @ViralKiller Рік тому

    is there a Python version of this?

  • @ramonmarino9396
    @ramonmarino9396 Рік тому

    Is it possible to do all this directly from etherscan?

  • @konkard9503
    @konkard9503 Рік тому +2

    Can you code a front run bot?

  • @Codewriter5482
    @Codewriter5482 Рік тому

    sir how to add faucet in goerli link token and usdc

  • @improvingmuslim
    @improvingmuslim Рік тому

    what if i want to do this on the polygon network?

  • @baselkelziye4552
    @baselkelziye4552 Рік тому

    hey man can you list some mid-advanced common projects that would improve my skills in sol, thanks for the great content btw

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому +3

      absolutely. i have been thinking about what level to target as I'm not quite sure if most of the viewers are beginner, intermediate or advanced. i think I need to do all of the above. anything in particular you'd like to see? I have some ideas for intermediate / common tutorials and maybe even do some more beginner ones. thanks!

    • @baselkelziye4552
      @baselkelziye4552 Рік тому +1

      @@BlockExplorerMedia im thinking of a multisig wallet as a practice for myself not sure if it will fit for the audience :D

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому +1

      No I think that would be a good one. Let me see what I can do.

    • @milanis7a
      @milanis7a Рік тому +1

      @@BlockExplorerMedia A tutorail for a makerdao clone would be dope!

  • @deethekingstevens7146
    @deethekingstevens7146 Рік тому

    Another good tutorial on Dex, but how can I get commission for every swap?

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому

      Thank you! When you become a liquidity provider you would earn interest based on the fees paid by other users doing swaps.

    • @razorjhon2622
      @razorjhon2622 Рік тому

      @@BlockExplorerMedia do you mean if i created a token whenever someone swap my token to another i will get fees ? can you explain please

  • @nocareit
    @nocareit Рік тому

    Hi, this code work for pancakeswap?

  • @douglasduarte360
    @douglasduarte360 5 місяців тому

    And how about Uniswap Swap Router address SEPOLIA ? I Can't find

  • @feff232
    @feff232 Рік тому

    This is absolutely 10million dollar knowledge and all it gets is 57 comments. Hilarious. Thanks man

  • @astrofoundation
    @astrofoundation Рік тому

    Hi block Explore....
    Can you make a tut where we can get buy and sell transactions for a token just like poocoin does

  • @TheGaneshshow
    @TheGaneshshow Рік тому

    hello sir,
    3.08 seconds,
    why you will get 4 lp shares or 12 pool tokens?
    Thank you sir.

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому +1

      I don't think the numbers in this slide are technically 100% accurate - the main idea is to show that in v2 liquidity tokens are distributed to liquidity providers in proportion to their contribution. Also note that in v3 they don't use liquidity tokens at all - instead an ERC-721 is issued representing the provider's share of the pool.

    • @TheGaneshshow
      @TheGaneshshow Рік тому +1

      @@BlockExplorerMedia Thank you sir very much!
      Sir, Please do a complete video on hardhat Testing.

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому +1

      I am planning to do a dedicated Hardhat video sometime soon.

  • @astrofoundation
    @astrofoundation Рік тому

    When are you back ?

  • @shq-cali6111
    @shq-cali6111 Рік тому

    hey man how r u . havent seen u active. i hope everything is okay

  • @harrydare8191
    @harrydare8191 Рік тому

    Why has he not been posting?

  • @diiialee7012
    @diiialee7012 Рік тому

    How can I reach you sir?

  • @user-we6ri4gi9y
    @user-we6ri4gi9y Місяць тому

    Smart contrat in The video différent in your repo😂

  • @TheGaneshshow
    @TheGaneshshow Рік тому

    Hello sir,
    poolFee = 3000,
    what is 3000 here?
    Thank you.

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому +1

      Expression of "0.3%" in Solidity since Solidity doesn't support floating point numbers. The conversion must take place in the Uniswap Pool contract.

    • @TheGaneshshow
      @TheGaneshshow Рік тому +2

      @@BlockExplorerMedia Thank you sir. I got it. There will no floating numbers.

  • @TheGaneshshow
    @TheGaneshshow Рік тому

    Hello Sir,
    14.47 secs,
    pool fee is 0.3%,
    But of which amount, it is 0.3%?
    Thank you sir.

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому +1

      The middle-tier fee is 0.3% of the desired token swap price. More info here:
      docs.uniswap.org/protocol/concepts/V3-overview/fees

    • @TheGaneshshow
      @TheGaneshshow Рік тому

      @@BlockExplorerMedia Thank you sir. My doubt is cleared.

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому +1

      Anytime!

    • @TheGaneshshow
      @TheGaneshshow Рік тому

      @@BlockExplorerMedia Hello sir,
      I want to talk to you one on one,
      Please reply sir.
      Thank you.

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому +1

      hey 20s - it's difficult for me to provide any support outside of the channel due to other obligations but you can reach me at my personal email at 'jgspruance' at g mail and I will try my best to get to it. thanks!

  • @-bolboi1676
    @-bolboi1676 Рік тому

    write a dex arbitrage trade bot

  • @difference018
    @difference018 Рік тому

    I keep getting this error Source "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol" not found: File import callback not supported. I think it is a problem with the remappings. Any help would be appreciated

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому

      hi, what are you doing at the time when this error occurs and are you encountering it in Visual Code or in Remix. Please check that you are using the correct import for each environment - relative for VC and direct github url for Remix. You can find both in the video description.

    • @difference018
      @difference018 Рік тому +2

      @@BlockExplorerMedia I solved the problem. In the remappings settings you should put "@uniswap/=node_modules/@uniswap/",
      "@openzeppelin/=node_modules/@openzeppelin/"
      Just thought others should know if they are having problems as well. Also set the optimizer to true in your hardhat config if you are getting the "stack too deep" error

    • @BlockExplorerMedia
      @BlockExplorerMedia  Рік тому

      Great - thanks for sharing.