Uniswap V3 Multicall with SwapRouter | Multiple Swaps in 1 Transaction | Multicall, V3, SwapRouter

Поделиться
HTML-код
  • Опубликовано: 15 окт 2022
  • Get my free EthersJS cheatsheet to master Web3!
    👉 blockman-codes.ck.page/91b29a...
    ------------------------------------------
    Courses:
    👉 Build a Uniswap V3 interface that can do swaps: bit.ly/3JkXYqL
    ------------------------------------------
    Uniswap V3 multicall transactions allow you to include multiple transactions in the same Ethereum transaction and block. This minimizes the state change between each transaction.
    Today, we'll learn to send multicall transactions to Uniswap V3's SwapRouter.
    We'll use Uniswap V3 SwapRouter's multicall function to swap WETH for USDC, and WETH for UNI, both in the same block.
    ---------------------
    Package.json, ABIs and contract addresses:
    gist.github.com/BlockmanCodes...
  • НаукаНаука

Комментарии • 59

  • @blockmancodes
    @blockmancodes  Год назад

    Learn to use all the Uniswap swap and liquidity functionality with code. bit.ly/3JkXYqL

  • @tedyp3k
    @tedyp3k Год назад +1

    Great tutorial!
    However, you forgot to add approve functions before swap, otherwise it doesn't work (unless manually approved or swapped prior to this)
    Suggestion for next video: make the same multicall, but with smart contract so approve can be in same transaction. Thanks!

  • @chuongtran2208
    @chuongtran2208 Год назад

    Thank you very much, wish you good health always 😊

  • @IndependenceDEV
    @IndependenceDEV Год назад

    Thanks man, that's useful

  • @zhengzuo5118
    @zhengzuo5118 8 дней назад

    Multi swap should be done using ExactInput function by passing in the encoded path instead of three ExactInputSingle

  • @tejaswarambhe7464
    @tejaswarambhe7464 Год назад +1

    Is there a way to fetch estimated output tokens for the given input tokens using these smart contracts?
    If yes, I would like to know more about it.

  • @dzsobacsi
    @dzsobacsi Год назад

    Thanks for the great tutorial! what do you actually use the PeripheryPaymentsABI for?

  • @tamaraebiogosi9076
    @tamaraebiogosi9076 Год назад

    just used this idea to solve my 3 day old problem on python, thank you very much

  • @OdairATrujillo
    @OdairATrujillo 6 месяцев назад

    Thanks for de video, I have question: how do you decode the transaction data when you have read it from the blockchain?

  • @notify7610
    @notify7610 Год назад

    Wow! am actually learning 🌝

  • @xAA-pl4fd
    @xAA-pl4fd Год назад

    Thank you for this tutorial.
    it would be REALLY interesting to use Multicall with smart contracts, your code only works with stable ones to me, if I try to swap smart contracts V3 or V2 it doesn't work

  • @jacksonjiang6313
    @jacksonjiang6313 Год назад

    thanks for your video, but I got an error that says Error: cannot estimate gas. Where should I set this gas or gasLimit then?

  • @lucasonempera
    @lucasonempera Месяц назад

    hello @blockmancodes, its possible to do a multicall to make a swap if a direct pair does not exist?
    Token A -> Token B then Token B -> Token C, in one multicall?

  • @RonaldoGuedes
    @RonaldoGuedes 5 месяцев назад

    Can we approve a token to swap and make swap in one multicall?

  • @franvidal1918
    @franvidal1918 Год назад

    I can't find the .approve... isn't it needed with Multicall? Otherwise, my question is: If I approved, for example, 5 minutes ago: do I need to approve again?

  • @dmitryisakov3215
    @dmitryisakov3215 7 месяцев назад

    I can not find multicall fn in PSC V3 PositionManager

  • @bejojeffrin7033
    @bejojeffrin7033 Год назад

    Hi , is it possible to do this with alpha router? , because
    this sample requires the exact fee pool value to be passed (eg:3000, 100 etc).

    • @blockmancodes
      @blockmancodes  Год назад

      Alpha router will come up with it's own path between 2 tokens, which you can then send to the router

  • @viktorcortez5706
    @viktorcortez5706 Год назад

    So whst's the point of multi call?Seems like it’s the same as 2 exactinputSingle swaps. Smth with gas optimisation?

    • @blockmancodes
      @blockmancodes  Год назад +3

      Sometimes you really want 2 swaps in the same block or not at all. Can be relevant for arbitrage

  • @veliea5160
    @veliea5160 Год назад

    do we have to call `encodeDataFunction`. is it specific to ethers.js.

    • @blockmancodes
      @blockmancodes  Год назад

      In this case, its coming from the swap router contract. As far as I know for multicalls, we need to use sendTransaction, which requires encoded instructions

  • @ABCDEFGH-or2eb
    @ABCDEFGH-or2eb 10 месяцев назад

    I’m looking for a video where two different DEXs are involved, and I’d be able to send my money from one DEX to the other.

  • @bejojeffrin7033
    @bejojeffrin7033 Год назад

    Hi @blockmancodes , I followed this tutorial . While trying to execute the transaction , iam getting an error saying cannot estimate gas; transaction may fail or may require manual gas limit reason="execution reverted: STF", method="estimateGas" .Can you please help

    • @elijahhezekiah1
      @elijahhezekiah1 Год назад +1

      You need to add Gas Estimate to the Multical function or increase your gas estimate on your hardhat config

    • @blockmancodes
      @blockmancodes  Год назад

      First thing to try is adding a gas limit

    • @bejojeffrin7033
      @bejojeffrin7033 Год назад

      @@blockmancodes i tried it ,that was also not working . Then i tried approving the tokens to be spent before swapping and then it worked .But it is not working for mainnet

    • @blockmancodes
      @blockmancodes  Год назад

      @@bejojeffrin7033 Can you confirm you used the correct addesses on mainnet (will not be the same as testnet/local) for approving tokens. Otherwise, it should work the same on testnet vs mainnet

  • @xanapodcasts7171
    @xanapodcasts7171 Год назад +1

    How can this same thing be done using smart contracts?

    • @blockmancodes
      @blockmancodes  Год назад

      I'd need to make a whole other video because the syntax will be different. But the flow is similar. I'll add it to my list.

    • @xanapodcasts7171
      @xanapodcasts7171 Год назад

      @@blockmancodes yeah, I'd like that. Thank you for considering it.

  • @omersajid7145
    @omersajid7145 Год назад

    How can I trade within the pool that we have created using code?

    • @blockmancodes
      @blockmancodes  Год назад

      I think I covered an example of that in my Uniswap Flashloan video

  • @roxanabraescu6180
    @roxanabraescu6180 Год назад

    Newbie, what will happen if I copy the code from etherscan and change the wallet address

    • @blockmancodes
      @blockmancodes  Год назад

      I don't fully understand. Can you explain in more detail?

    • @roxanabraescu6180
      @roxanabraescu6180 Год назад

      @@blockmancodes you are searching Bitcoin can I search ethereum

  • @blockmancodes
    @blockmancodes  Год назад

    What else do you want to learn to do with Uniswap?

    • @junkymonkey9874
      @junkymonkey9874 Год назад

      I can swap native ETH for a token (and the reverse) through metamask and it looks like its uses multicall. How is this done programmatically?

    • @bilalhassan6363
      @bilalhassan6363 Год назад

      Can you please make this video using python and web3.py

    • @viktorcortez5706
      @viktorcortez5706 Год назад

      There is a mystery without answer. Quoter multihop. How to encode params to make it work? No info on uniswap at all.

    • @blockmancodes
      @blockmancodes  Год назад

      ​@@viktorcortez5706 Can you link me to the documentation for the method you want to call?

    • @zekaihuang5743
      @zekaihuang5743 Год назад

      Thank you very much. I have a question: How to wap ETH to UNI? If we need wrap ETH for WETH, we call WETH9 contract method with multicall?

  • @feff232
    @feff232 Год назад

    I get an error : Error: cannot estimate gas; transaction may fail or may require manual gas limit

    • @blockmancodes
      @blockmancodes  Год назад

      Can you try adding a gasLimit?

    • @feff232
      @feff232 Год назад

      ​@@blockmancodes Im pretty much new to the whole thing. All i can say is I tried setting the gas to 3million and got the same error and tried to rewatch and build it over and over and nothing changes. Even chatgpt cant help me on this one xD

  • @AriSmrd
    @AriSmrd Год назад

    hi can you teach me how to use on pancakeswap?

    • @blockmancodes
      @blockmancodes  Год назад

      It's on my long term roadmap, but I won't get to it for awhile

  • @iamgadgetboy
    @iamgadgetboy Год назад

    Blockman your tutorials are on point it has turned me into a subscriber that doesn't happen easily as there's alot of fluffy ones out there, I would like more on multi functional dapps, or break down a big real world arbitrage transaction on what you think happened from etherscan evidence, maybe. Thanks keep these up i'm already working thru all your vids slowly building up my node and solidity skills to get them as close to your understanding as poss.

    • @blockmancodes
      @blockmancodes  Год назад

      Thanks brother. I'm planning on doing a lot more arbitrage related content going forward

  • @muhammadbayupratama876
    @muhammadbayupratama876 Год назад

    hello sir, can i contact you? i will learning about blochchain

    • @blockmancodes
      @blockmancodes  Год назад

      I have an email in about page, but just for business inquiries.
      You can leave the question as a comment on any video. I try to respond to everyone.