Тёмный

Uniswap and Sushiswap Arbitrage Code | Uniswap V2 | EthersJS | DeFi 

Blockman Codes
Подписаться 7 тыс.
Просмотров 7 тыс.
50% 1

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
------------------------------------------
How do you programmatically check for arbitrage between swap pairs on Uniswap V2 and SushiSwap with code.
Uniswap V2 and SushiSwap use the same router contract code, so out of all arbitrage implementations, this is a good introduction.
In this tutorial we compute if an arbitrage opportunity exists between the protocols for a pair of tokens.
------------------------------------------
Starter Code
```
const ethers = require('ethers');
const provider = new ethers.providers.JsonRpcProvider('mainnet.infura.io/v3/abc');
const token0 = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; // WETH
const token1 = '0x6b175474e89094c44da98b954eedeac495271d0f'; // DAI
const uniRouterAddress = '0x7a250d5630b4cf539739df2c5dacb4c659f2488d';
const sushiRouterAddress = '0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'
const PATH = [token0, token1]
const routerAbi = [
'function getAmountsOut(uint amountIn, address[] memory path) public view returns (uint[] memory amounts)',
]
const uniRouter = new ethers.Contract(uniRouterAddress, routerAbi, provider);
const sushiRouter = new ethers.Contract(sushiRouterAddress, routerAbi, provider);
const amountIn = ethers.utils.parseEther('1');
```

Наука

Опубликовано:

 

31 май 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 72   
@blockmancodes
@blockmancodes 11 месяцев назад
Learn to use all of Uniswap's swap and liquidity functionality with code. bit.ly/3JkXYqL
@ponchobunz4518
@ponchobunz4518 Год назад
Thanks for a being real and not someone selling a course
@edublox4790
@edublox4790 2 месяца назад
He does sell a course but its worth it
@vilanovaalejandro500
@vilanovaalejandro500 Год назад
Every time I look deeper into crypto trading with code you’re the only one with consistent, updated and easy to understand videos. Thank you for being on RU-vid. I needed this information
@blockmancodes
@blockmancodes Год назад
Thanks for the kind words brother!
@vilanovaalejandro500
@vilanovaalejandro500 Год назад
For anyone that had any errors in the video I had a mistake of using the uniswapv3 router address instead of uniswapv2. Both sushiswap and uniswapv2 have the amounts out function but not uniswapv3.
@elcinhasanov641
@elcinhasanov641 6 месяцев назад
Great tutorial! Big thanks!
@user-jh2bf4rs5v
@user-jh2bf4rs5v 7 месяцев назад
Can you tell if you take into account current gas value when calculating prices for arbitrage to make prices more precise?
@user-cr8mk4nm6b
@user-cr8mk4nm6b 8 месяцев назад
what if we need to do with some pairs where decimal is not equal.
@rezayazdanpanah9306
@rezayazdanpanah9306 4 месяца назад
thanks for video.i can't undrestand why you add fee to uni price and subtraction other.why you dont subtraction both?please explain to me
@m.sundaram2123
@m.sundaram2123 4 месяца назад
Hi sir is is possible to transfer token from private network to eth?
@ojazzista
@ojazzista 4 месяца назад
Doesn't the router already account for the DEX fees when we call getAmountsOut?
@studioschaplin8180
@studioschaplin8180 Год назад
Blockman Codes & shares his knowledge with all!!! Thank you!
@blockmancodes
@blockmancodes Год назад
More to come!
@daveinvest1914
@daveinvest1914 8 месяцев назад
powerdul, how do one subscribe to your program ?
@blockmancodes
@blockmancodes Год назад
What other arbitrage related tutorials would you like to see?
@SuperDividenz
@SuperDividenz Год назад
flash loans MEV.boost
@tos3269
@tos3269 Год назад
mev
@satyasai69
@satyasai69 Год назад
Mev
@fabio_6236
@fabio_6236 Год назад
searcher flashbots
@fwankanboaz4143
@fwankanboaz4143 Год назад
Is it possible to make binance/uniswap abitrage coding?
4 месяца назад
don't we have to consider the "impermanent loss" in this scenarios? Since we will swap from ETH to DAI in one than from DAI to ETH in the other one? Or am I thinking about it in the wrong way?
4 месяца назад
and one more question, don't we need to calculate the other direction of the prices on the second exchange? Like: ETH/DAI on uniswap and DAI/ETH on sushiswap? since the prices are different inside the same exchange
@aandresriera7927
@aandresriera7927 Год назад
Great content!! you are the only one that I've found, that actually explains better, and more completely the arbitrage between crypto assets. You won a sub. Correct me if I'm wrong, I'm making a project that involves arbitrage, this formula, the one that you presented here, is not taking into account the slippage, which will affect the return right? Should be added to this formula as well, or calculated separatly?
@blockmancodes
@blockmancodes Год назад
Thanks you! Yes, you'll want to ensure you're still profitable after slippage and gas
@rockysin5932
@rockysin5932 Год назад
Great work 👍
@blockmancodes
@blockmancodes Год назад
Glad it's helpful!
@jomatojingle5623
@jomatojingle5623 Год назад
Thankyou very much dude. ♥️🔥
@blockmancodes
@blockmancodes Год назад
My pleasure
@user-nm7vh1hd3l
@user-nm7vh1hd3l Год назад
Hi, please, can you explain, how can I swap Exact tokens0 for maximum amount of tokens1 with swap() function of uniswap v2 pair contract? (I don’t need to use Router)
@blockmancodes
@blockmancodes Год назад
I'll do a video on using swap() on the pair
@ThePlankton5165
@ThePlankton5165 8 месяцев назад
I decided to test the entire code at AirCode. Deploying the code was a success, but how do you reveal things like the prices on the exchanges like you did at 9:36?
@ThePlankton5165
@ThePlankton5165 8 месяцев назад
OK, I see it looks like I need to change the infura URL, but after that, every time I deploy, nothing more happens, and it still says “404 page not found”. I would like to know how to fix this, pronto.
@ThePlankton5165
@ThePlankton5165 8 месяцев назад
Or maybe I just have to click the link to run the code in AirCode. But I get this error: {“code”:-1, “error”:”missing ) after argument list”} I have no clue what is wrong with my code. I cannot find a difference between my code and your code besides the infura URL. Can you help me? Please and thanks.
@ThePlankton5165
@ThePlankton5165 7 месяцев назад
@BlockmanCodes Are you going to answer me? It’s been over one month!
@jerrywang3225
@jerrywang3225 Год назад
Great tutorial, can you add the function for the script to monitor the spread all the time. Thanks
@blockmancodes
@blockmancodes Год назад
Thanks. I'll keep that in mind for the next arb tutorial I make. It's just a loop that needs to be added
@user-qw8go9gk4w
@user-qw8go9gk4w Год назад
Hi, congrats on your level of knowledge and thanks for sharing I think you could share the full code, I think many of us are beginners and can't manage, in this case, although I like it, at least for me it's useless Anyway, I subscribed, because I like how you explain
@blockmancodes
@blockmancodes Год назад
I would honestly like to. But it lowers watch time a lot and then the algorithm will recommend my videos less :(
@oliverli9630
@oliverli9630 10 месяцев назад
nice
@rezayazdanpanah9306
@rezayazdanpanah9306 4 месяца назад
when uniPrice greater than we must sell to uni but in your code you sell to suchi
@shaikazaruddin45
@shaikazaruddin45 Год назад
Can you please do on binance chain like pancakeswap arbitrage
@nithin3476
@nithin3476 5 месяцев назад
what about someone excutes the sandwich attack for our transaction?
@SuperDividenz
@SuperDividenz Год назад
can this be deployed on different exchanges and chains?
@blockmancodes
@blockmancodes Год назад
You'll have to change the addresses
@Pawie_Eth
@Pawie_Eth 11 месяцев назад
Hey, can you make a course on how we can build our arbitrage Bot from ground app as well MEV bot that does sandwich attacks please? I will literally be the 1st who buys it
@blockmancodes
@blockmancodes 11 месяцев назад
That's my next project ;)
@Pawie_Eth
@Pawie_Eth 11 месяцев назад
@@blockmancodes you’re awesome! Literally! Is it going to be a RU-vid video or a course actually? Also when will it be released approximately? I’m excited!
@tafikjili6964
@tafikjili6964 Год назад
Great course continue we want to build a arbitrage bot between uniswap v2 and v3 and sell it i will buy it
@blockmancodes
@blockmancodes Год назад
I'd like to do some arbitrage bot tutorials in the future
@ohhu6098
@ohhu6098 10 месяцев назад
How can we find out if tokens use the same contract?
@blockmancodes
@blockmancodes 10 месяцев назад
Can you clarify what you mean with an example?
@ohhu6098
@ohhu6098 10 месяцев назад
I think I got confused with the dex router addresses.. the real thing I need an answer to is when using other coins other than that used in this example.. (weth/dai) what would I need to change in order to make it weth/(something else). I heard you mention having the same decimal places helps so I'd aim to find that.. do I just change the dai contract address? Thanks in advance ❤
@michaelmekonnenasres1312
@michaelmekonnenasres1312 Год назад
good
@apersaz4178
@apersaz4178 7 месяцев назад
Hello. I am watching your videos, for which I can only thank you and I have tested the code for this, but for example, on the Polygon network the two "Exchanges" via Web give a similar price (around 1810 DAI) while your program gives a very big difference (from 1731 on Uniswap to 1792 on Sushiswap). What are these differences due to and what is the way to obtain the price with the greatest precision to be able to evaluate a real arbitration option?
@blackotaku9630
@blackotaku9630 5 месяцев назад
this uses a function that calls for the market conditions at the current time of txn. it changes from time to time from the pool activity.
@ikesafemath
@ikesafemath 11 месяцев назад
Hello Blockman pls what would it cost me to learn flash loan with arbitrage from u
@blockmancodes
@blockmancodes 11 месяцев назад
Thanks for the question. I don't have time to personally mentor, but I'm working on a flashloan course
@ikesafemath
@ikesafemath 11 месяцев назад
@@blockmancodes ok i look forward to be part of it.thank u
@anyasikem8834
@anyasikem8834 Год назад
nice bro pls can you make the code for coins with different decimals?
@blockmancodes
@blockmancodes Год назад
Thanks for watching! I'll include tokens with different decimals in upcoming arbitrage tutorials
@anyasikem8834
@anyasikem8834 Год назад
@@blockmancodes tanks bro
@tafikjili6964
@tafikjili6964 Год назад
please give us github link
@blockmancodes
@blockmancodes Год назад
I honestly would like to provide code. But it lowers watch time a lot, and then the algorithm won't recommend my tutorials as much
@craigkanyemba
@craigkanyemba Год назад
I have been following your work, for the past 3 months or so. thanks again. If you don't mind, please add your invite to Discord.
@blockmancodes
@blockmancodes Год назад
Thanks for following! Appreciate it! I used to have a public discord but it was too much work to answer questions about 80+ videos. Now I only have it for my course
@vilanovaalejandro500
@vilanovaalejandro500 Год назад
@@blockmancodes what’s on your course?
@rezayazdanpanah9306
@rezayazdanpanah9306 4 месяца назад
when uniPrice greater than we must sell to uni but in your code you sell to suchi
Далее
Мама ударила дочь #shorts #iribaby
00:17
Rust's Alien Data Types 👽 Box, Rc, Arc
11:54
Просмотров 132 тыс.
Uniswap V3 Arbitrage
19:19
Просмотров 3,2 тыс.
Furucombo Advanced Flashloan Workshop
40:20
Просмотров 14 тыс.
Code Uniswap V2 & SushiSwap Swaps | EthersJS | DeFi
9:48
Pydantic is all you need: Jason Liu
17:55
Просмотров 164 тыс.
How To Flashloan Crypto Arbitrage Trading, Furu Combo
9:57
How to Trade on Uniswap (Step-by-Step Tutorial)
12:44
🤔Почему Samsung ПОМОГАЕТ Apple?
0:48
Просмотров 462 тыс.