Uniswap V2 - Swap Tokens | DeFi

Поділитися
Вставка
  • Опубліковано 9 лют 2025
  • Let's learn about DeFi. This video explains how to trade an ERC20 token for another using a decentralized exchange called Uniswap.
    Overview 0:20
    Solidity code 1:18
    Test 4:46
    Run test using Ganache 7:25
    #DeFi #Uniswap #SmartContract #Ethereum
    Code: github.com/t4s...
    References
    Uniswap app.uniswap.org/
    Etherscan etherscan.io
    Follow on Twitter: @ProgrammerSmart / programmersmart
    Join me on Discord: / discord
    Website: smartcontractp...

КОМЕНТАРІ • 92

  • @smartcontractprogrammer
    @smartcontractprogrammer  3 роки тому +11

    Overview 0:20
    Solidity code 1:18
    Test 4:46
    Run test using Ganache 7:25

    • @harveyvanresurreccion2434
      @harveyvanresurreccion2434 3 роки тому

      Hey, are there any other platform where I can contact you? Just wanted to ask few things about connecting smart contracts to front end. Thanks

    • @smartcontractprogrammer
      @smartcontractprogrammer  3 роки тому

      @@harveyvanresurreccion2434 discord.gg/Ny8sPaj

    • @makbyl2844
      @makbyl2844 3 роки тому

      Sup fella, I need your opinion. I plan to participate in UnoRe private sale, THi introduce a secured ecosystem for investing in risk capital. What is the best moment to jump in?

    • @smartcontractprogrammer
      @smartcontractprogrammer  3 роки тому +3

      @@makbyl2844 I buy high sell low. You're asking the wrong person

    • @yatsik3467
      @yatsik3467 3 роки тому

      Why haven’t I seen yachannel before?! It’s a pity youhaven’t reviewed COVIDCRYPTO yet. This unique covid charity project is fantastic! yaCandonate to charity & get huge profits at the same time!

  • @tomok284
    @tomok284 2 роки тому +3

    Thanks. This Defi series is exactly what I want. It includes the math, coding and demo. Please keep on!

  • @freshcharly167
    @freshcharly167 3 роки тому

    just discovered your video. Thank you first! Keep working on it I will share it to mass who are willing to learn!

  • @leefrancis6845
    @leefrancis6845 3 роки тому +1

    everything is soooo clear👍 this channel definitely deserves more viewers!

  • @umeraqeel7228
    @umeraqeel7228 3 роки тому

    one of the best channel for blockchain development

  • @mrvonbismarck5258
    @mrvonbismarck5258 3 роки тому +1

    Awesome content! I will share it with my friends.

  • @tariqlashley228
    @tariqlashley228 3 роки тому

    Thank you, Ive been seeeeeeeeeaaarching for this content for a minute. Subbed 👏🏾

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

    Again your video helped.
    Thank you, man!

  • @Eyesonaleks
    @Eyesonaleks 3 роки тому

    You are amazing! I've been looking for this all over the place

    • @jonangelmatute7532
      @jonangelmatute7532 3 роки тому

      Please, shoot a video about UnoRe (UNO). The idea of risk trading on crypto is so fresh. It is especially interesting to lget about developing your own insurance products. I've never heard of this before.

  • @basukivenkatpati3052
    @basukivenkatpati3052 2 роки тому +1

    which previous video are you talking about ?

  • @ToonGnarizard
    @ToonGnarizard 2 роки тому

    best channel in the space!

  • @josecerqueira1203
    @josecerqueira1203 3 роки тому

    WOW, so that is how todo End to End tests awesome!

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

    Thanks man, It helped a lot

  • @wagmicrypto173
    @wagmicrypto173 3 роки тому +5

    This was a very much needed video

  • @中村由美子-z4q
    @中村由美子-z4q 3 роки тому +2

    Great‼️

  • @viktorcortez5706
    @viktorcortez5706 2 роки тому

    Thanks for your videos. Now I can swap tokens between V2 and V3 using AAVE Flashloan)

  • @salem232
    @salem232 3 роки тому +1

    😍 awesome video!!! So well explained~~~
    🤓Will be looking forward to the video explaining how is pricing determined in Uniswap!!

    • @smartcontractprogrammer
      @smartcontractprogrammer  3 роки тому +2

      Be excited! Brain crushing heavy math coming your way XD

    • @salem232
      @salem232 3 роки тому

      @@smartcontractprogrammer 😂 I have all my math textbooks out and ready !!!

    • @BlurryBit
      @BlurryBit 3 роки тому +1

      Hey, u gf or what? U comments all vdos huhs.

    • @legrandesleepy8298
      @legrandesleepy8298 3 роки тому

      @@BlurryBit Is it any of your business?

  • @sachinaugustine9023
    @sachinaugustine9023 2 роки тому +1

    Hey ..... great video got a lot to learn from here. Im using hardhat instead of truffle for testing. Im unable to import artifacts.require(""IERC20"). For hardhat is there some other way of importing artifacts ??

  • @michaelguan326
    @michaelguan326 2 роки тому

    hi curious, how would one swap the tokens already sitting in a smart contract in uniswap? do i still need to approve? im getting like revert: stf error. have you heard of this?

  • @xanapodcasts7171
    @xanapodcasts7171 2 роки тому +1

    Thanks alot for the video but can you please make a swap video on V3

  • @saadsuri1173
    @saadsuri1173 2 роки тому

    I did the test for uniswap but it doesn't show the proper value for swapping in the out.

  • @Yash-qe3bv
    @Yash-qe3bv 3 роки тому +1

    4:53 what do you mean by mainnet fork?

    • @Yash-qe3bv
      @Yash-qe3bv 3 роки тому

      is it free to test real contracts on mainnet there?

    • @smartcontractprogrammer
      @smartcontractprogrammer  3 роки тому

      you can simulate transcactions on mainnet without paying fee
      ua-cam.com/video/G8bDhS24eds/v-deo.html

    • @Yash-qe3bv
      @Yash-qe3bv 3 роки тому +1

      @@smartcontractprogrammer thanks

  • @sunpulsekk
    @sunpulsekk 3 роки тому

    One of the best!

  • @sdfsfsfd437
    @sdfsfsfd437 3 роки тому

    thanks a lot! great video!

  • @christiankingg
    @christiankingg 2 роки тому +1

    Something you forgot to mention is that this will require an Infura project Id to add to the .env file.

  • @CryptoRootz
    @CryptoRootz 3 роки тому

    great video.

  • @itsjp5779
    @itsjp5779 2 роки тому +1

    Nice video. Is there a programmatic way of determining the best “path” (dai -> weth -> wbtc) instead of hard coding the “path”?

  • @federicogimenez2796
    @federicogimenez2796 2 роки тому +1

    @smartcontractprogrammer awesome content thx! you mention the setup of mainnet_fork is done in a previous video, where can I find it?

    • @federicogimenez2796
      @federicogimenez2796 2 роки тому +1

      nvm i guess you refer to the mainnet fork functionality of RPC providers like infura or alchemy, and how you can configure hardhat/truffle to access them

  • @yurylemesh87
    @yurylemesh87 3 роки тому

    Thanks!
    What happens if for some reason the transaction is unsuccessful during the execution of the swapTokensForExactTokens function. Will the tokens be on the balance of the contract and can anyone withdraw them?

    • @smartcontractprogrammer
      @smartcontractprogrammer  3 роки тому +1

      all changes will be undone. Some of your ETH will be taken for gas fee even if transaction fails

  • @hackerhubnft7675
    @hackerhubnft7675 2 роки тому

    What about multicall?

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

    May i ask...what does a smart contract looks like ?

  • @john-n-s
    @john-n-s 3 роки тому

    You are great bro

  • @aminghasemi2621
    @aminghasemi2621 3 роки тому

    how do you use approve outside of ERC20 contract?
    I mean it is impossible to call approve function of some ERC20 token outside of the contract.

    • @smartcontractprogrammer
      @smartcontractprogrammer  3 роки тому

      Like this?
      github.com/t4sk/defi-by-example/blob/main/test/test-uniswap.js#L26

    • @aminghasemi2621
      @aminghasemi2621 3 роки тому

      @@smartcontractprogrammer I was talking about this line
      github.com/t4sk/defi-by-example/blob/main/contracts/TestUniswap.sol#L20
      you cannot call approve function of some ERC20 contract outside of that contract (in solidity)

    • @smartcontractprogrammer
      @smartcontractprogrammer  3 роки тому

      @@aminghasemi2621 Please give me an example of what you to do

  • @titidinipunyaadek9670
    @titidinipunyaadek9670 3 роки тому +1

    this awesome sir, but can you teach us how to snipe token on uniswap. So we can be a early buyers of that token

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

    @smartcontractprogrammer: how to run solidity in vscode ?

  • @cloudcode6914
    @cloudcode6914 2 роки тому

    Great 👍

  • @nguyenminhat6594
    @nguyenminhat6594 3 роки тому

    Does this feature help us hide the transaction from the font-running bot?

  • @donnieamz2938
    @donnieamz2938 3 роки тому

    hello, where to find the bn.js file? i cannot find it from your github

  • @luongdanh825
    @luongdanh825 3 роки тому

    How about use evn in windown . This source .evn in command no found

  • @mahoganybeatz1915
    @mahoganybeatz1915 3 роки тому

    I'm skeptical about uniswap... i swapped out some FET tokens for Ocean and its like ocean stole my money cause it went to their smart contract. I made 3 swaps, two went through but the last swap didn't and all my FET is in OCeans contract. i was left with only 129 ocean tokens. I lost $14k worth of FET

  • @swanend
    @swanend 2 роки тому

    What is that DAI_WHALE address? Why we are using it?

  • @mahoganybeatz1915
    @mahoganybeatz1915 3 роки тому +1

    why do I have to do all of this coding? why can't i just swap on the platform?

  • @ICOReviewtoken
    @ICOReviewtoken 3 роки тому

    Can you please make a tutorial on how to create a defi deck like pancake swap from scratch ?

  • @atrulyrandomwalk
    @atrulyrandomwalk 3 роки тому

    Could you please explain the 10^18 math clearly? Isn't 1 DAI ~ $1???

  • @disqid5295
    @disqid5295 3 роки тому

    thx

  • @Nachoxt17
    @Nachoxt17 3 роки тому +1

    THANK YOU MEN YOU FUCKING BOSS I LOVE YOU

  • @steemycoinz
    @steemycoinz 3 роки тому

    is that 9.4 Billion in your wallet, very nice

    • @smartcontractprogrammer
      @smartcontractprogrammer  3 роки тому +1

      whale's wallet. Ganache can unlock any wallet

    • @steemycoinz
      @steemycoinz 3 роки тому

      @@smartcontractprogrammer awesome, i love you man, you are one of my personal heroes.

  • @savad1989
    @savad1989 3 роки тому

    Amazing video, may i know your TG or Email? Thanks...

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

    ua-cam.com/video/69wd2_keiIg/v-deo.html
    Gosto dessa teoria

  • @vitalij-k133
    @vitalij-k133 3 роки тому

    That looks great fella
    Btw, I am willing to to say that project UnoRe looksreally great. great devs and advisory team, gives me confidence toput money.