Тёмный

Introduction To DEX Arbitrage | Intermediate Solidity Tutorial 

James Bachini
Подписаться 23 тыс.
Просмотров 55 тыс.
50% 1

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

 

7 сен 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 322   
@calebanderson1532
@calebanderson1532 2 года назад
Of all explanations for arb bots I've seen this is definitely the obvious winner for easiest to understand nice one
@ismara6902
@ismara6902 2 года назад
great content! one of the most underrated channels, please keep up the good work!
@JamesBachini
@JamesBachini 2 года назад
Thanks 👍
@mikhaildubovskiy8873
@mikhaildubovskiy8873 Год назад
yeah its a good entry point to start implementing more advances strategies
@t9fiction
@t9fiction 2 года назад
Thankyou, Thankyou, Thankyou. May God bless you my friend.
@gamingsaloon7731
@gamingsaloon7731 Год назад
Hello James and thank you for this great job 🙏 it was a good complete example to enter the solidity world, I'm testing the bot on a watch mode (without triggering trades) and I just want to share with you some points: to solve the gas problem I've recalculated the correct routes as I will test it on usdt only, to do this I've created a new script that builds all possible routes then test each one by applying the function estimateDualDexTrade if it doesn't catch an error I parse the good route in temp file then copy the result to configuration. I will try to init a score property on each route and always select the first one, if the route gives an arbitrage opportunity I'll increase the score by 1 else I'll decrease it by 1 then sort the routes by the score property, when you've talked about scaling I think It's hard to say as you have tested the result on different conditions.
@JamesBachini
@JamesBachini Год назад
Sounds like a good idea to score different routes and check more profitable routes more frequently. To scale it I think you would probably want to run your own node and monitor the mempool for incoming trades
@Daniel-pc2ov
@Daniel-pc2ov Год назад
What language did you code it in?
@JamesBachini
@JamesBachini Год назад
@@Daniel-pc2ov the original contract was solidity with a NodeJS deployer/controller
@serbianwolfgaming3503
@serbianwolfgaming3503 2 года назад
Excellent presentation, everything is told in an accessible and understandable way. The tutorial was useful to me for using the bot. Thank you very much.
@razorjhon2622
@razorjhon2622 Год назад
I am really happy that i found your channel , can you please do more script based videos that would be helpful to learn more about blockchain
@jerrywang3225
@jerrywang3225 Год назад
I am glad to find your channel, so grateful for the free code which helps me a lot with my solidity skills, please update more content like this. Thanks again.
@iamgadgetboy
@iamgadgetboy 2 года назад
Awesome james nice concise explanation of the code and what it does in the scheme of things no fluff -perfect in its simplicity and showing more than some who leave you stranded with how and where to get hash numbers and where to put them in a tidy orderly manner. Thanks
@cultesmoments
@cultesmoments Год назад
Dear your code always work or not? thanks for all good video!
@Dexai-DexMachina
@Dexai-DexMachina Год назад
Nice. Good dex project can bring good profit
@Ay_official
@Ay_official 2 года назад
This video is so beautiful. Lots of knowledge and transparency from you… like the fact you pointed out that it’d not make so much profit
@JamesBachini
@JamesBachini 2 года назад
Yeah so many people have run it now too, it might be harder to find profitable trades. Definitely won't make a fortune but a good introduction to arbitrage and systems trading I hope.
@boratlovesrabbits
@boratlovesrabbits 2 года назад
im really sad i didnt find you channel earlier.
@sirThomas95
@sirThomas95 6 месяцев назад
deploying the contract on aurora didn't work for me, but it was fine on fantom
@bertrandthebault6899
@bertrandthebault6899 2 года назад
Amazing video Beautiful code Thank you 🙏 so much
@fookbc
@fookbc 2 года назад
牛逼克拉斯,niubility in chinese meas amazing, I gave this word to you ,YYDS(永远的神) another chinese word means "forever god",I also give it to you .RESPECT
@franklee2924
@franklee2924 2 года назад
Hi James, could you talk about sandwich and front running and MEV, that's also interesting topics. thx.
@JamesBachini
@JamesBachini 2 года назад
I'll do a flashbots tutorial at some point 👍
@franklee2924
@franklee2924 2 года назад
@@JamesBachini wow, can't wait for that
@Johnson-d8n
@Johnson-d8n Месяц назад
​@@JamesBachiniwe are still waiting for it sir
@chrismexc7848
@chrismexc7848 2 года назад
this is good, thank you!
@homeskills2708
@homeskills2708 27 дней назад
That's an amazing video, when will you make another video like this, that can work best for uniswap, pancakeswap, sushi swap. Etc
@JamesBachini
@JamesBachini 27 дней назад
I'll try and get some more recorded, thank you
@homeskills2708
@homeskills2708 24 дня назад
Thanks for your reply, we are waiting for it 🙏
@homeskills2708
@homeskills2708 23 дня назад
I tried the code in remix, I always use estimate dual trade function to estimate the profit before I will execute the trade and it works, but if I put a higher amount I will be getting “no arbitrage available" error message, if I use small amount it will work, what could be the course?
@JamesBachini
@JamesBachini 22 дня назад
@@homeskills2708 this is because there are no easy high profitability arbs found on that network currently
@panchopacheco1247
@panchopacheco1247 Год назад
Thanks for this great tutorial; I learned a lot. It felt great to see "# weth: 52bps" pop up on the log for the 1st time. In the video you mentioned that the dualDexTrade function isn't very gas efficient; would you explain why it's not, or how I could make it more gas efficient?
@JamesBachini
@JamesBachini Год назад
It was written for a network with zero gas fees at the time. In production you would likely want to monitor the mempool and trade against incoming transactions
@linjack7872
@linjack7872 2 года назад
good channel keep updating~
@ghoul3227
@ghoul3227 2 года назад
Great content men, new subscriber
@patrickdivine4319
@patrickdivine4319 Год назад
Honestly this video has been extremely helpful and I love the way you have kept it interactive. However I have a question; pls with the current transaction fees on aurora and and other expenses. Do you still think this code will be profitable. That is excluding the competition? I need to know it really does help. Thanks
@JamesBachini
@JamesBachini Год назад
You can just set a minimum profit variable to cover the transaction fee. In practice though a lot of people have forked this code so probably any network other than Aurora would be a better place to run it
@8218kelmo
@8218kelmo 2 года назад
why is it bringing this error TypeError: Cannot read property 'address' of undefined
@JamesBachini
@JamesBachini 2 года назад
Maybe a field missing in the credentials or config files?
@charlie.scot.
@charlie.scot. 2 года назад
Had the same issue and took me a good while to fix it. It was pretty simple for me. Cant read address of undefined means your [owner] isn't hooked up properly. For me I had stupidly changed the .env file name manually and accidentally left .txt on the end meaning the hardhat config file couldn't find the correct file. I removed that .txt and hey presto, I'm onto my next bug ha! Hope this helps
@eharrison
@eharrison Год назад
@@charlie.scot. and @James Bachini Hey guys, I've come across this same issue, and I've saved my file correctly as .env But I'm still getting the same error message when I try to run the deploy.js script Do you have any other suggestions with regards to getting the [owner] hooked up properly as you say in your message above? Would appreciate some guidance in getting over this obstacle, thank you!
@yassinehammouch6328
@yassinehammouch6328 2 года назад
can we have a version with flashloan that would be perfect for people who need a capital ?
@JamesBachini
@JamesBachini 2 года назад
I don't think it would be profitable for this use case as the fees for the loan would eat into profits and there wasn't much liquidity to scale it anyway. Flash loan > more volume > more slippage > lower margins > plus flashloan fees Some example code here if you still want to give it a try www.quicknode.com/guides/defi/how-to-make-a-flash-loan-using-aave
@jean-francoisguilbo7833
@jean-francoisguilbo7833 2 года назад
What are the benefits of doing route search and dual Dex swap from the arb contract address compare to doing it directly from your personal contract address?
@JamesBachini
@JamesBachini 2 года назад
You can have logic on the contract to revert the transaction if it loses money
@bertyguilbo8536
@bertyguilbo8536 2 года назад
​@@JamesBachini That's a huge benefit indeed. I thought it was something like the beauty of the code or skill show off ;-)
@william1000
@william1000 2 года назад
Wow great content
@qiaokang1701
@qiaokang1701 Год назад
very very cool
@Johnson-d8n
@Johnson-d8n 2 месяца назад
Such a nice video, can I change the network to other evm like bsc, arbitrum or base, inside the config file and deploy it... 2. Does the bot determine direction in the two dex, if the price is lower than the other one it will determine which dex it will buy first?
@JamesBachini
@JamesBachini 2 месяца назад
Yes you'll need to change the contract addresses too. You can code it to search for any routes between dexes
@Johnson-d8n
@Johnson-d8n Месяц назад
Thanks, the bot is performing trades using mostly the funds inside the base assets, not the tokens; it will perform trades between those assets, right? The more base assets, the more trades it can perform
@JamesBachini
@JamesBachini Месяц назад
​@@Johnson-d8nYes it should perform base asset > token > base asset
@Johnson-d8n
@Johnson-d8n Месяц назад
@@JamesBachini alright, can they frontrun me by using this bot?
@JamesBachini
@JamesBachini Месяц назад
@@Johnson-d8n depends on the network. If you were doing something on eth mainnet you'd probably want to use the flashbots fast rpc URL. Having said that it wouldn't be anywhere near competitive on eth mainnet
@pierremadier4392
@pierremadier4392 2 года назад
thanks
@shapourh6516
@shapourh6516 2 года назад
Thanks for this helpful tutorial, My question is what if we put some large amount like $20k or $70k in base assets, it will be profitable or slippage will destroy the benefits?
@JamesBachini
@JamesBachini 2 года назад
slippage will destroy it because the pools aren't liquid enough. There's code on github to work out optimal sizing for each transaction I believe as it will vary.
@shapourh6516
@shapourh6516 2 года назад
@@JamesBachini do you have that address for github?
@JamesBachini
@JamesBachini 2 года назад
@@shapourh6516 I don't sorry. It was a while ago I was looking at it.
@jarvy5703
@jarvy5703 2 года назад
Thanks for sharing! This exactly what I needed - an example to get started and play around with. Looking forward to tinkering :)
@JamesBachini
@JamesBachini 2 года назад
Good luck with the arbs 👍
@rolandonwa2369
@rolandonwa2369 2 месяца назад
Thank you very much for the great content, please how can I change the dex? I should change the router address of the preferred dex I want right? Or is there any additional steps
@JamesBachini
@JamesBachini 2 месяца назад
If it's based on uni v2 then yes just change the contract address. If it's something else then it might have a different swap function so you'll need to dig into their docs to see how it works programmatically
@rolandonwa2369
@rolandonwa2369 Месяц назад
Thanks for your response, like how much would be the minimum for trade, because the bot has been watching for opportunity yet it did want to execute trade, I also changed tokens and dexes, it didn't work, any advice on this?
@JamesBachini
@JamesBachini Месяц назад
​@@rolandonwa2369hard to say without much info to go on. You should be able to do tiny $0.01 trades. There is no minimum as such. Maybe try adjusting the profit requirement setting. Also if it's running on a chain or dex with low trading volume it won't find many trades as prices aren't moving much
@Microsization
@Microsization 2 года назад
In your opinion, could you combine this with flash loans and would that make more profit or be riskier?
@JamesBachini
@JamesBachini 2 года назад
Flash loans would create more slippage and fees so less profits. Not enough trading volume and liquidity on Aurora to make it viable. You are capped by how much capital you can push through without moving price any way so flash loans would only add more capital and fees which wouldn't work.
@Microsization
@Microsization 2 года назад
@@JamesBachiniThanks. Maybe another chain. Trying to figure out if it's worth the time to go down the rabbit hole. 😬
@kevinyap87
@kevinyap87 2 года назад
Hi James, first of all, thank you so much for the content. It helps a LOT for a newbie like me. I have a query here. Is there a benefit of doing all the "scans" of opportunity through smart contract ("estimateDualDexTrade") vs. interacting with the individual DEX's routers directly (calling router's getAmountsOut from Node JS)? Thanks again!! Looking forward to more of your contents!
@JamesBachini
@JamesBachini 2 года назад
There is in that you could potentially trade the same block and it would speed up execution and make it more competitive. On public RPC nodes you'll hit a lot of rate limits doing this so worth running your own version of geth.
@kevinyap87
@kevinyap87 2 года назад
Thank you for answering my question, James. That made a lot of sense!
@stevenverdekel7045
@stevenverdekel7045 2 года назад
Fascinating content. Have you tried integrating the use of Flash Loans into these bots? I understand these are used quite often in these arbitrage transactions.
@JamesBachini
@JamesBachini 2 года назад
There's wasn't enough trading volume on Aurora to make it worth a flashloan. You'd be paying a fee on the loan and higher slippage on the dex so would cut into margins. On something like Eth mainnet where millions are traded daily there's a lot more room for volume but then it becomes more competitive too.
@meshalalomar7472
@meshalalomar7472 Год назад
I'm not really into programming a lot, I only know few things here and there. Can you please explain how to execute the code you provided? Like what language, program, or system you used?
@JamesBachini
@JamesBachini Год назад
It's a solidity smart contract executed via nodejs which runs JavaScript
@user-li4ke9dk1e
@user-li4ke9dk1e Год назад
Hello, first thank's for this great tutorial, i would like to add another blockchain but i don't see how to get the "routes" can you help me for this part ?
@JamesBachini
@JamesBachini Год назад
Think there some info in the blog post linked in the description. It was a while ago but seem to remember brute forcing the routes using different combos of token addresses
@diegoalegria1647
@diegoalegria1647 Год назад
Hi ! Awesome video. I'm getting errors with the solidity compiler, don't exactly know how to change that. Then also, I'm trying to do the "cd Dex-Arbitrage", but it doesn't find the route to the folder. And last question, how can I use this code in a testnet ? Thank you in advance
@JamesBachini
@JamesBachini Год назад
Should be able to use it on a testnet but bare in mind there's not much trading volume so it won't find many trades. Check token and router addresses if you are getting errors
@RacecarJ0hnny
@RacecarJ0hnny Год назад
If I want to do stuff like this and get into MEV bots, should I learn JS before Solidity? I know Python and I know some C, C++, so I'm thinking I'd be better off not being lazy and learning JS before Solidity...
@JamesBachini
@JamesBachini Год назад
You could actually just use python and solidity or even python and vyper. Use python for the controller script and then solidity or vyper for the contract. JavaScript is useful to learn anyway as it's used a lot in testing (hardhat) and for connecting up web3 frameworks. But it's not essential for this type of thing. Bit of a wishy washy answer. Maybe start with CryptoZombies to get a feel for how it all works together and see where you end up and what bits interest you.
@RacecarJ0hnny
@RacecarJ0hnny Год назад
@@JamesBachini Ok, thanks for the advice! I'll start with Crypto Zombies since it always looked interesting anyways, just didn't know whether it had value or not as a hobby programmer.
@kehindeVHassan
@kehindeVHassan 2 года назад
Great piece James, to begin with, I'm a newbie in programming, but I've been wondering 🤔 is it possible to create a crypto token that never falls by removing/burning sold supplies instantly from the total supply? And is it possible to create a token contract that would auto run an arbitrage contract on its own to generate yields. Will really appreciate a kind and complete answer please 😁!
@JamesBachini
@JamesBachini 2 года назад
It's not possible to create a token that never falls unfortunately. Safemoon did something similar to what you are talking about where transaction fees went to liquidity pools to boost price but it was still highly volatile. With regards to a token contract with an underlying arbitrage strategy in theory this would be possible but in practice it's difficult for it to be competitive. Not sure if the incentives are there too. I.e. if someone has a profitable arb strategy why would they want to share the profits with token holders rather than just running it themselves. I think we will see more tokens in the future that have yield farming type strategies backing up the collateral which makes more sense to me as execution is less time critical.
@user-iu7bg8gr8l
@user-iu7bg8gr8l Год назад
Is it possible to profit from this bot with a small amount?
@JamesBachini
@JamesBachini Год назад
It's pretty old now and was only minimally profitable when aurora first launched in the middle of a bull market. The code has been forked hundreds of times since then so I'd assume it's pretty saturated. You might find a few dollar trades but it certainly won't make you rich overnight. Beware of any code that promises you will get rich quick
@user-iu7bg8gr8l
@user-iu7bg8gr8l Год назад
​@@JamesBachini I can't get it to run, I'm getting an error message on cloning, what libraries do I need to install and configure before starting
@JamesBachini
@JamesBachini Год назад
@@user-iu7bg8gr8l NodeJS and the dependencies in package.json
@adammr8523
@adammr8523 Год назад
Hi, except for uniswap and sushiswap how to get a list of router addresses ( compatible with this code ) on the ethereum mainet ? Many thanks.
@JamesBachini
@JamesBachini Год назад
Go through the list of ethereum dexes on DeFillama, anything based on Uni v2 should work. Can normally Google "nameOfDex router etherscan" and it'll come up with the address and source code which you can check to see if the function names for swaps are the same
@leozone6171
@leozone6171 2 года назад
Hi James, when you find one router has profit,how to calculation the _amount parameter that get max profit. thx.
@JamesBachini
@JamesBachini 2 года назад
It's quite complex to calculate the optimal sizing. You would need to get the pool sizes at a given state and then figure out a formula to calculate slippage and how that affects profits. There's some more info about calculating slippage for v3 pools here: x3finance.medium.com/how-to-calculate-swap-slippage-of-uniswap-v3-d433ed6d74b0
@duncanlangdon5951
@duncanlangdon5951 2 года назад
This is awesome thank you very much I am running it on ftm just to get a feel for how a bot run before i deploy my own but I am curious about how i can add more routes to the json because i added more dexes to the bot? I saw a reply you had saying that that function is in trade.js but is commented out but i am not seeing it. I would like to add it as a separate script that i can run and have write to the uniqueRoutes.json. Also i believe there is an error in the read me instruction because it says to run the bot you just use the deploy script again? I found that not to be the case also the slashes in the .\scripts\deploy.js were backwards for me because i am running on linux, I believe that could be good to specify in the readme
@JamesBachini
@JamesBachini 2 года назад
Hi Duncan, thanks for that I'll get the readme updated. To find the routes I just grabbed token addresses and tried every combination of them against popular base assets like usdt/usdc/ftm on every router. If there wasn't a pool for that combo then an error would be thrown and you can catch it and move on to the next. If there was a pool you wouldn't get an error and can write out thpse tokens and router addresses to a goodRoutes.json file
@user-cg1pq2kh6t
@user-cg1pq2kh6t 6 месяцев назад
how it can be profitable if others networks spent a gas?
@JamesBachini
@JamesBachini 6 месяцев назад
Trade profits need to outweigh gas costs. At time of making the video there were no gas costs on Aurora so this wasn't a challenge
@mark5907
@mark5907 2 года назад
Thanks for the tutorial! quick question, what do you mean by "no transaction fee on Aurora"? I followed your tutorial and located some arb on the Aurora Dexes. But when I try to manual swap then, I got charged by a small fee ETH (enough to wipe out the arb profits)?
@JamesBachini
@JamesBachini 2 года назад
When I made the video there were no transaction or gas fees on Aurora. They later introduced them a month or so ago unfortunately. There's some info about it on their twitter account
@mark5907
@mark5907 2 года назад
@@JamesBachini i see, thank you!
@TechWeLove
@TechWeLove 2 года назад
Is this a scam, cause people on twitter PM about this ? I'll watch the video, and watch more videos, etc. I hate scammers, so if anyone has any way to show me a government website, or something that helps me find answers to these concerns.
@JamesBachini
@JamesBachini 2 года назад
Don't buy trading systems from 3rd parties. If someone has something that makes money there is no reason to sell it. Write your own code, learn and continue to be sceptical
@cathy4769
@cathy4769 2 года назад
Not sure why always got Error: call revert exception (method="estimateDualDexTrade(address,address,address,address,uint256)", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.5.0) when running trade.js is it realted to the version?
@JamesBachini
@JamesBachini 2 года назад
Could be a token contract address or router issue maybe? I've never heard of the abi version causing an issue.
@maksym_promskyi
@maksym_promskyi 2 года назад
Cool
@22-Zar
@22-Zar 2 года назад
Thanks so much for the bot and video, so great to see the layout, I just have no real idea as to what’s going on exactly. How did you put together the list of all those different routes? Just taking a chance here but if you can pls can you make an in-depth video on this bot for the brand new coders like myself, would be excellent but thanks regardless great video
@JamesBachini
@JamesBachini 2 года назад
So the routes are just Token in > Dex > token out You can find dexes by looking on defillama. You can find router address for the Dex by doing a transaction and checking which contract you interacted with in a block explorer. And tokens can be found via the dexes analytics sites or by analysing transactions on the router
@22-Zar
@22-Zar 2 года назад
@@JamesBachini Hey thanks for the quick reply, I should've specified but the routes I was thinking about is the routes in the config files. At first I was confused as to how you made it to begin with, but reading the code now I see it first gets made under "const lookForDualTrade" and then info is appended to txt file in data folder. Now I'm trying to figure out from, for example ./data/fantomRouteLog.txt ... how does that info get copied to ./config/fantom.json .. how did you get the routes from the fantomRouteLog.txt to fantom.json file ... do you do it manually?
@JamesBachini
@JamesBachini 2 года назад
@@22-Zar yeah I think I just used vscode to add the formatting You can search for something like a newline and then hit alt enter and it'll highlight all and you can add the '],[' bits. I can't remember exactly but expect I did it something like that. A better alternative would just be to format it correctly in the script and use JSON.stringify before writing out to the file.
@22-Zar
@22-Zar 2 года назад
@@JamesBachini thanks James, I'm very new to coding but I've taken time to read the code as best I can and your video does explain it very well, so no real need for that "in-depth video" this is really great ... last question, if I want to use the BSC network can I just create a file like the aurora.json file in config folder, basically copy that but with BSC info and then run the controller to get the list of routes - then copy those routes to the config .json file again under "routes": [ ] and then run off that? Now I just want to figure out how can I use flash loans instead of my personal funds
@JamesBachini
@JamesBachini 2 года назад
@@22-Zar yes copy it but change the router addresses to the contract addresses for Pancakeswap and/or other bsc exchanges. The token addresses will be different too. Bscscan is the equivalent of etherscan and useful for this
@gonzaloalessandrelli5105
@gonzaloalessandrelli5105 2 года назад
wouldn't it be better if flashLoans tech is applied in the smart contract?
@JamesBachini
@JamesBachini 2 года назад
I don't think so because of the scaling issue. Flash loans are great when you need a lot of capital but here it would just cause more slippage and you'd have to pay the loan fee. The liquidity pools that I was trading on just weren't big enough to justify it. On ethereum mainnet trading into large liquidity pools there might be a case for it but then you are looking at MEV and flashbots. Uni v2 forks generally have a flash swap feature/function at 0.3% which is interesting for certain situations and fun to play with.
@mattis46
@mattis46 2 года назад
How do I set the gas limit? I do get this error: "cannot estimate gas; transaction may fail or may require manual gas limit"
@JamesBachini
@JamesBachini 2 года назад
That error normally just means the transaction will fail. Likely due to an incorrect router or token address
@tungbs0603l
@tungbs0603l 2 года назад
Hey. Great tutorial. I got this error on hardhat console: > arb = await IArb.attach(arbContract); Uncaught ReferenceError: arbContract is not defined at REPL10:1:48 I put the arbContract in the .env file. Pls help. Tks u.
@JamesBachini
@JamesBachini 2 года назад
Did you update the config/whatever.json file?
@stellanskoog
@stellanskoog 2 года назад
Loved this one! How did you generate the routes section in the config?
@JamesBachini
@JamesBachini 2 года назад
There's a function in the trade.js file which just brute forces them using the token list and router addresses. I logged any that didn't pop an error to a JSON file and then used that. Think it's called data/goodRoutes.json in the repo. The logging line is commented out I believe in trade.js
@stellanskoog
@stellanskoog 2 года назад
@@JamesBachini Thanks a lot James! The code works great. Currently running it on BSC.
@JamesBachini
@JamesBachini 2 года назад
@@stellanskoog bsc is pretty competitive on Pancakeswap and some of the established forks but hope it's getting a few trades in for you 👍
@stellanskoog
@stellanskoog 2 года назад
@@JamesBachini Definitely agree, you can find positive trades but i havent been able to beat the transaction fee. I tried it on 5 dexes, pancake, cafe, bakery, cheese and ape. With the 100 tokens with the largest market caps.
@cheesebeef890114
@cheesebeef890114 Год назад
i try the aurora one but got gas estimation fail, so tridexes need to amend your code I assume? also how will this work with some other dexes fork like balancer or solidly? thanks
@JamesBachini
@JamesBachini Год назад
Gas estimation error just means the tx is failing so check your config file and router/token addresses. Other dexes you will need to change the functions you are calling for swaps because they all work slightly differently
@cheesebeef890114
@cheesebeef890114 Год назад
@@JamesBachini thanks James! wonder you could make a video about Uniswap flash swap
@JamesBachini
@JamesBachini Год назад
@@cheesebeef890114 sure here is a video about Uniswap v3 flashloans with links to tutorial and code in the description ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-rte5Rk-XQ24.html
@user-xm9sd1mk7r
@user-xm9sd1mk7r Год назад
Is it still possible to make money on dex arbitrage with such competition?
@JamesBachini
@JamesBachini Год назад
Yes but this code is very over simplified and won't compete on mainnet where it becomes more of an MEV game
@leochong3605
@leochong3605 2 года назад
used the fund.js script to load wFTM to the contract but it does not load FTM. Does the contract need FTM for gas to be able to work?
@JamesBachini
@JamesBachini 2 года назад
The contract doesn't, the account in the .env file needs some FTM to pay gas fees because that is where the transactions will be executed from
@Divine_Patrick01
@Divine_Patrick01 Год назад
Pls James, what are the chances of successful trades say i configure the code for pentagular trade?
@JamesBachini
@JamesBachini Год назад
I think trading volumes on Aurora are quite low so you might be better looking at other chains
@Divine_Patrick01
@Divine_Patrick01 Год назад
@@JamesBachini how about fantom?
@JamesBachini
@JamesBachini Год назад
@@Divine_Patrick01 follow the users, if there are degens clicking buttons there will be opportunity for arbitrage. More users and trading volume the bigger the opportunity to find trades
@Divine_Patrick01
@Divine_Patrick01 Год назад
Pls james i need your help. I have tried to deploy the contract using the deploy script in the repo and i have put my private key in dotenv but then it keeps showing me this; * Invalid account: #0 for network: aurora - Expected string, received undefined * Invalid account: #0 for network: fantom - Expected string, received undefined. PLS what could be the problem? Any help would be greatly appreciated😭
@JamesBachini
@JamesBachini Год назад
Sounds strange. What network are you trying to deploy it on? Maybe double check the .env file, did you put a alchemy API key in there? Also check hardhat.config.js and remove any networks you don't need. Add --network aurora or whatever chain you are deploying on using the key from hardhat.config.js
@jeremyeisenberg1520
@jeremyeisenberg1520 14 дней назад
Is it feasible to deploy this on BSC?
@JamesBachini
@JamesBachini 10 дней назад
Yes you will need to update some of the contract addresses and perhaps swap functions for any dexes which aren't based on Uniswap V2 but BSC is EVM so it's compatible
@metav7
@metav7 Год назад
Can you please make a tutorial for mev bot?? And please also teach how to modify it. (I have seen alot of videos but all of these are scams.)
@JamesBachini
@JamesBachini Год назад
No one will release profitable code unfortunately 🤷🏼‍♂️
@metav7
@metav7 Год назад
@@JamesBachini but any guidance about it?? Or if i send you a github code link can you please check it to find out if there's any hidden scam in it??
@laxmikantpendam2632
@laxmikantpendam2632 2 года назад
hello sir. i am new to solidity coding. how to add new DEX to this contract ??? if any reference video, plez share the link. thanks !!!
@JamesBachini
@JamesBachini 2 года назад
There's a link to a full tutorial in the video or if you search dex arbitrage it should come up. You basically need to find the router address of the Dex using a block explorer. Check the function name matches etc.
@traceurlou2118
@traceurlou2118 2 года назад
Hi James, thank you for this wonderful tutorial. I have a question here: is it necessary to send some FTM to the fantom arbitrage contract (or ETH to the aurora arbitrage contract, since aurora now requires transaction fees)for gas fee? But I always failed to send FTM to the contract. Is it because the contract doesn't have a fallback() or receive() function?
@JamesBachini
@JamesBachini 2 года назад
No you only need the base asset that you are trading in the contract. You'll need some FTM in the wallet address in the .env file This fires off the transactions and pays the gas fee.
@traceurlou2118
@traceurlou2118 2 года назад
@@JamesBachini thanks for answering my question! I have another question: I put 500 wftm in the contract and run the trade script, but got "wftm: 0bps" all the time. Is it because 500wftm is too much that causing big slippage?
@JamesBachini
@JamesBachini 2 года назад
@@traceurlou2118 I wouldn't have thought so. Fantom is pretty competitive. I found every time I found a good trade the network RPC would go down for 30 seconds like someone ddos'ing it to take out competition. Probably need to run a private node to avoid that. You have the routes set up across a few dexes I assume? Maybe look at gas prices other bots are using to make sure you are competitive.
@traceurlou2118
@traceurlou2118 2 года назад
@@JamesBachini make sense. What is `minBasisPointsPerTrade` in the config file? You mentioned that in the video, but I still don't get it. Why aurora's minBasisPointsPerTrade is 0 while fantom is 50?
@jean-francoisguilbo7833
@jean-francoisguilbo7833 2 года назад
Aurora did not have fee (=0) but not anymore
@timiolthedoctorhack4675
@timiolthedoctorhack4675 Год назад
hello its a newbie, can anyone tell which private key i'm to supply to the in the .env file and is the bot still profitable thanks
@JamesBachini
@JamesBachini Год назад
The bot isn't going to be profitable or at least isn't going to make a significant amount of money. Set up a fresh test wallet to use and put the private key from that into the .env file
@duyhoatran2076
@duyhoatran2076 2 года назад
Really helpful video, but im still a novice and i have a question that how can i set baseasset’s input amount for each trade ? Is this random or have any function for this ? Tks James
@JamesBachini
@JamesBachini 2 года назад
Trade size is just set as the contracts balance of that token but you could set it manually here: github.com/jamesbachini/DEX-Arbitrage/blob/a1f23b3e3fe6d64350befef98713af5efbd2ff3f/scripts/trade.js#L52
@duyhoatran2076
@duyhoatran2076 2 года назад
@@JamesBachini is there any function that help optimal trade size to avoid losses because of slippage or low liquidity pool ?
@JamesBachini
@JamesBachini 2 года назад
@@duyhoatran2076 not in this code although it would be better to calculate a tradesize based on the liquidity available
@duyhoatran2076
@duyhoatran2076 2 года назад
@@JamesBachini yeah, thank u so much James
@eharrison
@eharrison Год назад
@@JamesBachini hey James, great video and thank you for sharing this code! Can you recommend any resources that would help us make this change to this code? I can see it's line 52 in the link you have shared above in this thread But I'm not sure how to code this yet, would appreciate if you can point me in the direction of where I can find that info to implement it myself Thank you
@duyhoatran2076
@duyhoatran2076 2 года назад
Hi James, I found many arbitrage bots in some ecosystems. I am trying to find a way to get pair's information without a hardcode, like Uniswap Subgraph. Do u have any idea about this? thank you
@JamesBachini
@JamesBachini 2 года назад
You could pass the pair in via a contract function. Finding the pairs, you could maybe look at the contract events if you want to trade newly setup liquidity pools or something like that
@duyhoatran2076
@duyhoatran2076 2 года назад
Hi James, i want to create a controller in python, do u have any source code or github link ? Thank u
@JamesBachini
@JamesBachini 2 года назад
I coded it in NodeJS but no reason you couldn't use python with an equivalent web3 library. There won't be anything premade unfortunately
@IlEstLibreMaxOff
@IlEstLibreMaxOff 2 года назад
Im conflicted, i like the tutorial, but the contracts are full of reentrency possibilities
@JamesBachini
@JamesBachini 2 года назад
The external functions are ownerOnly
@dedicatedserver8214
@dedicatedserver8214 Год назад
Hello, awesome video! Whats the difference between Arb.sol and InstaArb.sol?
@JamesBachini
@JamesBachini Год назад
InstaArb.sol was just an experiment to take much of the computation into a contract. Didn't work well but might have potential if you were running an internal node.
@williamj2063
@williamj2063 Месяц назад
Such a nice video, please can you give me a suggestion on what I will with this error message, after I changed the chains, also I have funds in those assets. It will load the assets and start displaying this error message Error: cannot estimate gas; transaction may fail or may require manual gas limit reason: 'cannot estimate gas; transaction may fail or may require manual gas limit', code: 'UNPREDICTABLE_GAS_LIMIT' error: ProviderError: execution reverted Please any advice to handle this issue
@JamesBachini
@JamesBachini Месяц назад
The error just means the tx is failing. Perhaps contract addresses need changing?
@williamj2063
@williamj2063 Месяц назад
​​@@JamesBachini thanks for your response, do you mean if I redeploy the contract it will resolve the issue? Because I recently deployed the contract on a polygon, also when I was using the aurora network it was not showing me the error message
@JamesBachini
@JamesBachini Месяц назад
@@williamj2063 some of the tokens and routers might have different addresses on different chains. So you'll need to update the config files accordingly with the correct token addresses and dexes you want to trade on
@williamj2063
@williamj2063 Месяц назад
@@JamesBachini all the tokens are correct with the chains I'm using and dexs, I always make sure I'm in the chain inside dex screener then select the tokens based on that dex and chain
@williamj2063
@williamj2063 Месяц назад
@@JamesBachini I was thinking that the tokens only works for erc20 only with 18 decimals right?
@Divine_Patrick01
@Divine_Patrick01 3 месяца назад
James pls how do I deploy this code to a cloud? Pls
@JamesBachini
@JamesBachini 3 месяца назад
Just setup a cloud instance ssh in and run it from there
@Divine_Patrick01
@Divine_Patrick01 3 месяца назад
@@JamesBachini thanks allot James...pls I have not done this before. How do I go about the ssh instance? Pls
@Divine_Patrick01
@Divine_Patrick01 Год назад
i finally deployed the contract using fantom. i configured it to include three routers and token addresses but when i run it, i get ; 'cannot estimate gas; transaction may fail or may require manual gas limit', code: 'UNPREDICTABLE_GAS_LIMIT', error: ProviderError: execution reverted
@JamesBachini
@JamesBachini Год назад
It just means the transaction is failing. Check token contract and router addresses and make sure they are v2 forks
@akrfinance8379
@akrfinance8379 Год назад
Why I can't use this code for Arbitrum ? Even if I adapt the INFURA ENDPOINT and the addresses of tokens and rooters
@JamesBachini
@JamesBachini Год назад
Should work. Its an old video that uses univ2. If you want to use it with non Uniswap clones then you'll need to adapt it a bit
@akrfinance8379
@akrfinance8379 Год назад
@@JamesBachini I got this error when I try to call a function from the IERC20 interface for exemple : call to IERC20.totalSupply errored: Internal JSON-RPC error. { "code": -32000, "message": "execution reverted" } The fact that I don't understand is, this error doesn't appear when I interact with the contract in the Aurora Blockchain (the only differences is the Blockchain where I deploy the contract) Can you tell me how to use it without non Uniswap clones ? (sorry it's a lot of questions)
@JamesBachini
@JamesBachini Год назад
@@akrfinance8379 you would need to change the function names that carry out the trades. Different dexes may use different functions and parameters so if you are dealing with something unusual you will need to customise the script for it
@akrfinance8379
@akrfinance8379 Год назад
@@JamesBachini For me the rooter address it's the only parameter I have to change to trade on a different dexes (the addresses token too). Why do I have to change function names ? And what functions are you talking about ? I adapt of course the script but I keep the functions, I only adapt the addresses. Thank you
@JamesBachini
@JamesBachini Год назад
@@akrfinance8379 the code uses uniswap v2 and its various clones which all use the same functions/code to do swaps. If you are using Uni v3 or another dex which isn't a fork of Uniswap v2 then you'll need to adapt it to suit that code.
@jkpantalacci7065
@jkpantalacci7065 2 года назад
Hi James, I've been looking for some time for an arbitrage bot allowing me to invest in it even with low relative profitability despite everything... I'm not a developer and I'm therefore looking to rely on a basic bot with which I can be confident, do you think it could be wise for me to deploy this bot that you present to us in this video, without having to modify it given the fact that I would be truly unable to do so, I looking to earn a small passive income using cryptocurrency arbitrage. Thank you for your video, your advice and your kindness... thank you very much
@JamesBachini
@JamesBachini 2 года назад
Hi, no the bot is really provided as a learning tool rather than something that will make consistent and reliable profits. The truth is no one will publish or sell a MeV or arbitrage trading bot that makes consistent profits. Something like yield farming would be a better option in my opinion. Be really careful not to fall for scams with people selling trading bots.
@jkpantalacci7065
@jkpantalacci7065 2 года назад
@@JamesBachini ok thanks
@austinekaranja1786
@austinekaranja1786 Год назад
how do you build the trading route?
@JamesBachini
@JamesBachini Год назад
Find the token contract addresses. In the code there's a bit to brute force the routes once you have addresses for the tokens and routers
@Idontreallycareatall
@Idontreallycareatall 2 года назад
Hi, James. I'm trying to adapt your contract for mainnet(uniswpv2, sushi), experimenting with golang instead of nodejs though. So the question is I'm stuck at `Fail with error 'TransferHelper: TRANSFER_FROM_FAILED'` no clue how to solve it, because I clearly see approve() call at the start of swap() function. Any suggestions would be highly appreciated. And thank you for the content of course.
@JamesBachini
@JamesBachini 2 года назад
It does sound like a token isn't approved or there isn't enough balance. Are you storing the tokens on the contract address? And approving them from the address where they are?
@Idontreallycareatall
@Idontreallycareatall 2 года назад
@@JamesBachini Sorry, but since you're quite involved in conversation I'd like to ask one more question.. What's the granularity of arbitrage contract/bot? I mean we only see new token prices after block update? Is it possible to go to sub block values?
@JamesBachini
@JamesBachini 2 года назад
@@Idontreallycareatall Yeah at the highest level people are modifying geth to monitor the mempool for incoming transactions and then executing arbs via flashbots to close any price discrepancies in the same block.
@Idontreallycareatall
@Idontreallycareatall 2 года назад
@@JamesBachini thank you so much (: have a nice weekend
@olayinkaadebisi7907
@olayinkaadebisi7907 2 года назад
Hello, can this code be modeled to work with a chain like avalanche?
@JamesBachini
@JamesBachini 2 года назад
Yes avalanche c chain is EVM compatible so the code is exactly the same. Just need to change the token and router addresses
@olayinkaadebisi7907
@olayinkaadebisi7907 2 года назад
@@JamesBachini would you be willing to shed more light on what that means? If it's not too much of a bother. I'm pretty new to the web3 space so I'm not quite familiar with those terms yet.
@JamesBachini
@JamesBachini 2 года назад
@@olayinkaadebisi7907 same code will work on avalanche. However tokens will often have different addresses on each chain. Also different chains have different DeXs (decentralized exchanges)
@cosyfireplaceambience1425
@cosyfireplaceambience1425 2 года назад
First of all, thank you for such an informative video. It’s really valuable for me. I deployed and tried the contract at Aurora. Then it worked exactly how you showed us here. After all I tried to deploy same contract to BSC testnet with particular changes like routes, tokens, swap addresses, dotenv, file names etc… I mean I just changed Auorora things with BSC testnet things. I successfully deployed it on BSC testnet and also mainnet too(with necessarry changes again). The issue I confronted is that when I started to trade.js, I’m getting an error code: ‘UNPREDICTABLE_GAS_LIMIT’ reason: cannot estimate gas: transaction may fail or may require manual gas limit. I have been reserching for complete 18 hours and I couldn’t solve the issue. And I’m really tired :( What could i miss? My wallets have necessary tokens. Routers and token addresses are all of them are correct. If you have a solution of it, could you please share? Thanks and sorry for long question.
@JamesBachini
@JamesBachini 2 года назад
I think in the code there's a commented out line to set the gas limit manually on the transaction. Check bscscan and see what other bots are paying in terms of gas and set it to that.
@4theen7even22
@4theen7even22 2 года назад
@@JamesBachini I tried to de-commrate but it obviously gives me syntax error, how should you insert it? Const TX = Await Arb.Connect (Owner) .Dualdextrade (Router1, Router2, Basetoken, Token2, Amount); {Gasprice: 1000000000003, Gaslimit: 500000};
@JamesBachini
@JamesBachini 2 года назад
@@4theen7even22 try putting the gas price object as the last variable passed through to the function
@bertyguilbo8536
@bertyguilbo8536 2 года назад
1)Contrarily to what deploy.js tells you, DO NOT ADD a line for arbContract in .env (set it only in configuration>fantom.json or aurora.json) otherwise some scripts will crash! 2)Just use deploy.js > fund.js > trade.js > recover.js (I've ignored instadeploy.js and instatrade.js which may be redundant with deploy.js > fund.js > trade.js )
@JamesBachini
@JamesBachini 2 года назад
@@bertyguilbo8536 absolutely correct. The insta...js scripts were just experiments I left in for anyone interested. deploy.js > fund.js > trade.js > recover.js are the only ones needed
@0xhin
@0xhin 2 года назад
Do you know any reason for this TypeError: Cannot read properties of undefined (reading 'balance') ?
@JamesBachini
@JamesBachini 2 года назад
Do you have funds in the .env wallet to pay gas fees and have you moved the baseAssets to the contract?
@0xhin
@0xhin 2 года назад
@@JamesBachini You are so kind, it seems that I made a small mistake, I will test it again, thanks for the reply.😊
@mattis46
@mattis46 2 года назад
@@JamesBachini wht do you mean with: "Do you have funds in the .env wallet to pay gas fees"?
@JamesBachini
@JamesBachini 2 года назад
@@mattis46 the wallet that you use to sign transactions is stored in the .env file. You need some funds in here to pay gas fees. This is normally the native token for that blockchain. i.e. BnB for BSC, ETH for Ethereum, Aurora also introduced transaction fees since I made the video which are payable in Eth
@mattis46
@mattis46 2 года назад
@@JamesBachini Thanks for your reply. I do have ETH in the Metamask Wallet (Aurora Network), but I do get this error anyways. Shall I add the ETH to the base assets in aurora.json file?
@equaliserTV
@equaliserTV 2 года назад
Hey James, I don't understand how to find out Routes I have Assets and Dex Router Addresses but have not clue how to find these Routes Addresses Could you please give me a hint?
@JamesBachini
@JamesBachini 2 года назад
Yeah just brute force them so try every asset pair on every router. Any routes that don't exist will revert with an error. Log the ones that do exist to a file and use that to loop through in future.
@equaliserTV
@equaliserTV 2 года назад
@@JamesBachini you mean brute force with transactions?
@JamesBachini
@JamesBachini 2 года назад
@@equaliserTV just try to look for profitable swaps by looping through an array of token address for each Dex. Many will fail because there isnt a liquidity pool for that pair setup. To save wasting time and RPC bandwidth remove those and continue on with the ones where there are pools and you are finding trades
@JamesBachini
@JamesBachini 2 года назад
@@equaliserTV to be fair this is a bit hacky and probably not the most elegant way of doing it. But say you want to find all the routes for trading across Dex1 to Dex2 so you start with base assets i.e. Eth usdt usdc. Then you try to swap them for any token you can find on Dex1 then you try to swap back to the base asset on Dex2 and see if it's profitable. You can make it more complex and find various routes i.e. baseAsset to token1 to token2 to baseAsset. The more complex the route the more variations you have to test to see if token1 and token2 are trading on the dexes. So looping through the token addresses and router addresses and logging what works will give you a more condensed list of potentially profitable routes to query regularly.
@equaliserTV
@equaliserTV 2 года назад
@@JamesBachini aight, get it thanks! 🙌
@kingfatpig3512
@kingfatpig3512 2 года назад
Hi James
@JamesBachini
@JamesBachini 2 года назад
Hi
@jarvadetoro7004
@jarvadetoro7004 2 года назад
Hello james, thanks for the indepth tutorial. However, i am stuck as I am trying to use the arb bot on different chains. Do I have to create the aurora.json file myself and create the routes manually or am I doing something wrong when executing the code. I was under the assumption that once I changed the tokenList.json and execute the code, the aurora.json file would get repopulated with the correct new tokens and routes. correct me if i am wrong. Esentially my question is how did you create the aurora.json file and the routes written below it.
@JamesBachini
@JamesBachini 2 года назад
No the router addresses for the Dex's and token contract addresses will all change between networks. You'll need to find out what they are for your specific chain and create a new file
@jarvadetoro7004
@jarvadetoro7004 2 года назад
@@JamesBachini I understand that the token addresses for a different chain will be different, as well as the router addresses. However, is there a script already in the repo that creates the routes from looking at tokenList.json or do I have to write it basically. That's my question. Thanks again for this tutorial
@JamesBachini
@JamesBachini 2 года назад
@@jarvadetoro7004 you have to write it. There's a function to build out the routes by brute forcing the token/router combinations but you probably wouldn't want to use that on a chain with gas fees
@jarvadetoro7004
@jarvadetoro7004 2 года назад
@@JamesBachini I have managed to do all the changes as outlined and fund the contract with the base assets, however when i run the trade.js I am getting the following error : TypeError: Cannot read property 'balance' of undefined at lookForDualTrade (C:\Users\DELL\Documents\arb_bot\DEX-Arbitrage\scripts\trade.js:52:50) Some help would be appreciated
@JamesBachini
@JamesBachini 2 года назад
@@jarvadetoro7004 sounds like an issue with one of the token contract addresses for the base assets. Try double checking them and your contract balance in a block explorer.
@linjack7872
@linjack7872 2 года назад
Have you considered taking courses at udemy?
@JamesBachini
@JamesBachini 2 года назад
Lol I could definitely do with taking a few courses and learning more to improve this hacky solidity code 🤣
@exeohe
@exeohe Год назад
ok i know nothing about coding or having a controller, where should i start?
@JamesBachini
@JamesBachini Год назад
Learning to code unfortunately. I think it would be hard to make a living from arbitrage trading without knowing how to code up trading bots etc. If you want to work in DeFi then solidity is the programming language of choice, for quants its python and for everything else its Javascript. If you have no preference I'd recommend learning Javascript first because it's used everywhere
@Amatteo1
@Amatteo1 Год назад
I know nothing about coding either so I just paid a dev to code me one and to help me set it up. It’s working great
@exeohe
@exeohe Год назад
@@JamesBachini Thank you very much for your responce. Is solidity primarily used for Ethereum Blockchain?
@JamesBachini
@JamesBachini Год назад
@@exeohe ethereum and EVM blockchains such as polygon, BnB chain, avalanche, layer 2s like Arbitrum/optimism etc.
@exeohe
@exeohe Год назад
@@JamesBachini right on, thats where ill be then, whats better, python or solidity?
@eharrison
@eharrison Год назад
Hi James, I'm running the "deploy.js" script and I keep getting the error message: "TypeError: Cannot read property 'address' of undefined" I've read through all of the comments below to try to find the answer but I can't seem to get over this particular hurdle Can you make any reccomendations of where I should be looking, in which file and which lines I should be looking at? Thank you
@JamesBachini
@JamesBachini Год назад
Do you have an address in the .env file? More details here jamesbachini.com/dex-arbitrage/
@eharrison
@eharrison Год назад
@@JamesBachini hey James, I managed to resolve this issue :) I had not "cd"'d into the "DEX-Arbitrage" folder But when I did and made edits to those json files it all worked out I'm now able to deposit/withdraw and will begin testing with a real balance soon I do however now sometimes find this error: "replacement fee too low" and "replacement transaction underpriced" (even when there appears to be no pending transactions on either my wallet or contract on polygonscan..) I'm going to keep trying more tomorrow If you've encountered this "fee too low" error before and could recommend the right direction for me to explore to resolve it that would be very helpful Thank you!
@JamesBachini
@JamesBachini Год назад
@@eharrison it sounds like there's a transaction still in pending because of a low gas fee and the miners not picking it up. Then you are trying to overwrite it with another transaction with the same nonce (perhaps after restarting the programme) and that's too low too. Try upping the gas fee to a competitive amount and you should be good to go.
@eharrison
@eharrison Год назад
@@JamesBachini yeh I found a couple other sources/articles that said the same thing So I managed to pull the $1 ish of test WETH out of the contract by going to Remix and manually altering the Gas fee in metamask I'm wondering however, for using "fund.js" to add some base assets to run the Bot for a bit longer to more routes Do you know of any fixes, if the "fee too low" eeors show up again, even whilst there are no current transactions pending either by my wallet or the contract? That's where I'm struggling to understand where this particular "fee too low" error is coming from (when there doesn't appear to be an existing transaction to replace) Thank you for your responses bro, I appreciate it!
@eharrison
@eharrison Год назад
@@JamesBachini Also wondering if there is a way for me to alter the gas fees, for the script functions like "Fund.js" - "Recover.js" and "Trade.js" Is there anywhere in the code where we can make some changes to the gas fees, in case of running into these errors again in future?
@Idontreallycareatall
@Idontreallycareatall 2 года назад
ah... the times when UST was a stable coin (: ahhaha
@BASSTR
@BASSTR 2 года назад
Can i do this with flashloan
@JamesBachini
@JamesBachini 2 года назад
In theory yes but fees and slippage on larger orders will erode margins
@BASSTR
@BASSTR 2 года назад
@@JamesBachini Oh I See It Now Thanks
@dannyellis971
@dannyellis971 Год назад
Oof I'm a beginner and have spent 3 days straight trying to figure out how to make a Arbitrage bot and still struggling.
@JamesBachini
@JamesBachini Год назад
You running into any particular errors in the code or just general?
@dannyellis971
@dannyellis971 Год назад
@@JamesBachini Just trying to learn Solidity in general. I’m not coming from any type of coding background. I’m watching tutorials that say “if I watch this I’ll be a solidity coding master in 4 hours!” and after 3 days straight watching tutorials I’m left scratching my head lol. But I will keep trying.
@JamesBachini
@JamesBachini Год назад
@@dannyellis971 have you tried cryptozombies? That's a great tutorial/game to get up to speed. It's going to be a lot to take in if you've never coded before. If you hit a particular bug or problem don't forget you can normally Google an error code and figure it out from the stackoverflow post as someone will have been there before too.
@Amatteo1
@Amatteo1 Год назад
I gave up after 2 days and just ended up paying a dev to code me one and to teach me how to deploy it all. It’s working great now and is very profitable
@eharrison
@eharrison Год назад
Hi James, is there anywhere in the code we can alter the Gas price? I'm trying on Polygon and I keep coming across the error "fee too low" and "replacement transaction underpriced" I've played around with it a bit and managed to withdraw from the contract using remix/metamask and manually increasing the gas fees in MM But I often come across this "underpriced" error when trying to deposit into the contract (so I can't even test it with real $ atm lol!) Is it possible that this error will be less likely to happen when the networks gas fees come down (as they are significantly higher than usual as I'm typing this) Let me know if there is anywhere in the code that I can play withthe gas fee amount when you get a chance please Thank you again for providing this code for us to test/modify and learn from! Great learning experience making changes to this thing :)
@JamesBachini
@JamesBachini Год назад
Example of setting a manual gas price on line 80 github.com/jamesbachini/DEX-Arbitrage/blob/a1f23b3e3fe6d64350befef98713af5efbd2ff3f/scripts/trade.js#L80
@JamesBachini
@JamesBachini Год назад
@@eharrison is there any line number or reference for this error: "TypeError: Cannot read property 'balance' of undefined" it sounds like the contract isn't defined or it's trying to check the balance of something that hasn't been created in the code yet. That could be having knock on effects so I'd start with trying to find out what is going wrong here
@eharrison
@eharrison Год назад
@@JamesBachini it also says "at lookForDualTrade" Lines 59 and 75 Line 59 is: let tradeSize = balances[targetRoute.token1].balance; And then line 75 is: await lookForDualTrade(); I'm guessing that I need to make changes so that "balance" can be read properly I'm not quite sure what "Cannot read property 'balance' of undefined" means yet I'm not sure what is undefined, or how to define it lol!
@eharrison
@eharrison Год назад
@@JamesBachini There's also one greyed out line in the error message: "at processTicksAndRejections (internal/process/task_queues.js:93:5)"
@eharrison
@eharrison Год назад
@@JamesBachini When you say the contract isn't defined, is there an additional process I need to do to define the contract? Should I verify the on Polygonscan using the bytecode (which I've not done yet)?
@mitchhammy3612
@mitchhammy3612 2 года назад
i'm very new to this so I was wondering I keep getting * Invalid account: #0 for network: aurora - Expected string, received undefined. Do you know what this means? Also is it an aurora wallet I need to connect or can I use me metamask as I want to use it with a test network?
@mitchhammy3612
@mitchhammy3612 2 года назад
Ok, I kinda figured it outever when I deposited to the arb address it shows no money when i run the script
@mitchhammy3612
@mitchhammy3612 2 года назад
So do I need to connect my metamask to the aurora network
@JamesBachini
@JamesBachini 2 года назад
You can use any address, it doesn't need to be your metamask wallet. There's a handy little too/repol in my GitHub called ethers-vanity-address which I use to make test wallets. Put the wallet credentials in a .env file and put some funds on there. Aurora you don't need anything to pay transaction fees but most other networks you do. Even testnets you need some free testnet play tokens from a faucet. You'll also need some of the base asset that you want to trade to send to the contract. There's a couple of scripts to help with this called scripts/fund.js and scripts/recover.js Check it all works with tiny amounts including recover.js so you can get any funds back out of the contract when finished.
@mitchhammy3612
@mitchhammy3612 2 года назад
Just to be clear and from what I understand, I need to transfer funds to a main wallet the baseAsset tokens (will just be using usdt) (does the wallet need to be on the aurora mainnet or will having funds in Binance Smart Chain be ok? if not how do I get funds into the aurora mainnet) and then deploy.js to get the contract key that goes into arbContract. Then, use fund.js to transfer funds from the wallet to arbcontract and then trade.js, then recover.js to get the funds back from the contract?
@JamesBachini
@JamesBachini 2 года назад
@@mitchhammy3612 the wallet needs to be on the same network you plan on running the bot. There was someone who left a comment about running it on Binance smart chain. I'd suggest setting up a separate wallet either in metamask or somewhere else and try it first with like less than $1 in USDT so you can make sure you can recover funds and everything works. You'll need to add the bsc network details to hardhat.config.js If you want to run it on Aurora you can bridge assets across from Binance smart chain to the aurora network using a tool like multichain or synapse
@chrisdrake7893
@chrisdrake7893 2 года назад
I just got scammed on this bot. If you say to not use third party, what to use then instead?
@JamesBachini
@JamesBachini 2 года назад
How did you get scammed? I don't think it can be from the bot in this video as the code is all open source and I wrote it myself. If you purchased a 3rd party bot then that was something else as all the code here is free and on GitHub. If someone promises you riches for $19.99/month it's probably a scam. Arbitrage is hard and you need to code your own solutions and tools to be competitive.
@chrisdrake7893
@chrisdrake7893 2 года назад
@@JamesBachini this video was presented as elementary with other info. I put some money into my wallet, and joined project through wallet's browser. Details on pm if you are interested.
@chrisdrake7893
@chrisdrake7893 2 года назад
Why my last comment dissappeared?
@JamesBachini
@JamesBachini 2 года назад
@@chrisdrake7893 I can still see it and you replied to it with this comment
@AlvenThe
@AlvenThe Год назад
This bot not a scam ...just make sure u have basic coding understanding to begin with. Don't use third party coded bot .instead use the original from GitHub repository and scale the bot urself.
@davidkulman2291
@davidkulman2291 2 года назад
Het James great video! But I do have 1 question. Is it ok to use the v2 router when uniswap runs on version 3? Thanks
@davidkulman2291
@davidkulman2291 2 года назад
Also how do you not have more subs. EatTheBlock charges 150$ for this exact although outdated info.
@JamesBachini
@JamesBachini 2 года назад
So Uniswap v3 has some licensing issues to stop people copying it. All the clones like Pancakeswap, Trisolaris, Sushi etc. Are based in v2. It's possible to set this up with v3 as well you just need to change the function and parameters. Example code here for ve swaps github.com/JohnRSim/0xtr.ee-Contracts/blob/main/contracts/SwapExample.sol Contract addresses in the code are for the polygon Mumbai testnet
@JamesBachini
@JamesBachini 2 года назад
Did I not mention in the terms I charge at least one beer if you make money from it and we meet at a conference in the future 😉
@davidkulman2291
@davidkulman2291 2 года назад
@@JamesBachini wow okay thanks a lot!
@hairystyles4212
@hairystyles4212 2 года назад
@@davidkulman2291 RIGHT James should really leave an 0x address, i'd send him some nice gratuity for this channel.
@Cutegirl_m-z
@Cutegirl_m-z 2 года назад
so hard to understand esp the english pronunciation
@gregthomas7812
@gregthomas7812 Год назад
i have encountered this problem reason: 'network does not support ENS', code: 'UNSUPPORTED_OPERATION', operation: 'ENS', network: 'unknown'
@JamesBachini
@JamesBachini Год назад
There is an incorrect address somewhere or you are using quotes around an address so it thinks the address is an ens domain
@gregthomas7812
@gregthomas7812 Год назад
@@JamesBachini Where can I check for the wrong address?
@JamesBachini
@JamesBachini Год назад
@@gregthomas7812 put it into a block explorer
@gregthomas7812
@gregthomas7812 Год назад
@@JamesBachini thank you
@softassets7370
@softassets7370 2 года назад
Awesome Tutorial James!. However I have a question. I used the bot as it is, on the Fantom network and as you said, results were not good. So I simply changed one of the router addresses to the router address of another Fantom dex. I also replaced the router dex address on the listed routes in fantom.json file. Here is where I have hit a roadblock. I get the following error "reason: 'cannot estimate gas; transaction may fail or may require manual gas limit', code: 'UNPREDICTABLE_GAS_LIMIT'". I have manually put the gas limit in the hardhat.config file with no success, passed the gas price into the function in trade.js like so: const tx = await arb.connect(owner).dualDexTrade(router1, router2, baseToken, token2, amount, { gasPrice: 50000000000, gasLimit: 500000 }); yet same error. I have tinkered with this, using various gas prices well above what I see on the Fantom block explorer to no avail. But anytime I roll back changes and bring back the original script as you made it with spiritswap and spookyswap it works. Can you solve this with a simple example using another dex, maybe jetswap? Thanks in advance!
@JamesBachini
@JamesBachini 2 года назад
The gas price error message just means the transaction is expected to fail. It will likely be because of one of the router addresses is incorrect or not compatible with Uniswap be type DEX functions. Check the address is not all lowercase as that can cause a checksum error.
@softassets7370
@softassets7370 2 года назад
@@JamesBachini So I double checked, replaced the router addresses with the dual case contract address. I used SpiritSwap with router address : 0x16327E3FbDaCA3bcF7E38F5Af2599D2DDc33aE52 as against Wigoswap with contract address: 0x5023882f4D1EC10544FCB2066abE9C1645E95AA0 . Wigoswap has verified contract on ftmscan . Its still the same error.
@JamesBachini
@JamesBachini 2 года назад
@@softassets7370 is wigoswap a uni v2 fork? I'm not familiar with it. If that's the only thing you changed it has to be where the problem is
@softassets7370
@softassets7370 2 года назад
@@JamesBachini Its is. Its stated as a uniswap fork on defilama. Anyway I tried it this time on Bsc between pancakeswap and bakeryswap with the same error. Surely bakeryswap is a uniswap v2 fork. maybe the full error log will be helpful. here it is: Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"name":"ProviderError","code":-32000,"_isProviderError":true}, method="call", transaction={"from":"0x5d78Eec03d7bBCcfF78bFf012CccfA423343B2fF","to":"0xDD9e3DEb5eD590fBb5E710731AA5D2e7d0f244b2","data":"0x068e7ca1000000000000000000000000cde540d7eafe93ac5fe6233bee57e1270d3e330f00000000000000000000000010ed43c718714eb63d5aa57b78b54704e256024e000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c0000000000000000000000001fa4a73a3f0133f0025378af00236f3abdee5d6300000000000000000000000000000000000000000000000000f8b0a10e470000","accessList":null}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.5.2) at Logger.makeError (C:\Users\myasu\DEX-Arbitrage ode_modules\@ethersproject\logger\src.ts\index.ts:225:28) at Logger.throwError (C:\Users\myasu\DEX-Arbitrage ode_modules\@ethersproject\logger\src.ts\index.ts:237:20) at checkError (C:\Users\myasu\DEX-Arbitrage ode_modules\@ethersproject\providers\src.ts\json-rpc-provider.ts:80:16) at EthersProviderWrapper. (C:\Users\myasu\DEX-Arbitrage ode_modules\@ethersproject\providers\src.ts\json-rpc-provider.ts:562:20) at step (C:\Users\myasu\DEX-Arbitrage ode_modules\@ethersproject\providers\lib\json-rpc-provider.js:48:23) at Object.throw (C:\Users\myasu\DEX-Arbitrage ode_modules\@ethersproject\providers\lib\json-rpc-provider.js:29:53) at rejected (C:\Users\myasu\DEX-Arbitrage ode_modules\@ethersproject\providers\lib\json-rpc-provider.js:21:65) at runMicrotasks () at processTicksAndRejections (node:internal/process/task_queues:96:5) { reason: 'cannot estimate gas; transaction may fail or may require manual gas limit', code: 'UNPREDICTABLE_GAS_LIMIT', error: ProviderError: execution reverted at HttpProvider.request (C:\Users\myasu\DEX-Arbitrage ode_modules\hardhat\src\internal\core\providers\http.ts:49:19) at LocalAccountsProvider.request (C:\Users\myasu\DEX-Arbitrage ode_modules\hardhat\src\internal\core\providers\accounts.ts:187:34) at runMicrotasks () at processTicksAndRejections (node:internal/process/task_queues:96:5) at EthersProviderWrapper.send (C:\Users\myasu\DEX-Arbitrage ode_modules\@nomiclabs\hardhat-ethers\src\internal\ethers-provider-wrapper.ts:13:20), method: 'call', transaction: { from: '0x5d78Eec03d7bBCcfF78bFf012CccfA423343B2fF', to: '0xDD9e3DEb5eD590fBb5E710731AA5D2e7d0f244b2', data: '0x068e7ca1000000000000000000000000cde540d7eafe93ac5fe6233bee57e1270d3e330f00000000000000000000000010ed43c718714eb63d5aa57b78b54704e256024e000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c0000000000000000000000001fa4a73a3f0133f0025378af00236f3abdee5d6300000000000000000000000000000000000000000000000000f8b0a10e470000', accessList: null } }
@JamesBachini
@JamesBachini 2 года назад
@@softassets7370 I think it's just showing that the transaction will fail. Not much else to go off. Likely an issue with a token or router address as that is all that's really changed
@CyberICS
@CyberICS 2 года назад
Hi i, thank you for sharing this, i tried it all of the router and token addresses are correct but i am getting a 'cannot estimate gas: transaction may fail or may require manual gas limit' code: unpredictable gas_limit. Tried to looked at the comments and included decommented it out and included at the end of the function (..gasPrice ,gasLimit) but i had yo change the syntax from gasLimit : 1000000001 to gasLimit =1000000 same with the gas price as i am getting a "unexpected token :" . Method: estimateGas
@JamesBachini
@JamesBachini 2 года назад
Hey double check the contract and router addresses including checksums. If you look at the GitHub closed issues there are 3-4 threads from people with similar problems. I think the error message is a bit misleading but it basically means the transaction will fail. The other thing is it won't work as standard with Uniswap v3 only v2 and the million v2 clones out there.
@harrisonfang
@harrisonfang 8 месяцев назад
I have been trying to edit and save this file but for some reason my edits will not go through. How do I save changes??
@JamesBachini
@JamesBachini 8 месяцев назад
Are you saving it locally? Should be able to save files fine unless there is some kind of write protection on your drive
@harrisonfang
@harrisonfang 7 месяцев назад
@@JamesBachini Yes trying to save locally I will try again this weekend
@harrisonfang
@harrisonfang 7 месяцев назад
@@JamesBachini I figured out how to save and edit. I noticed there is a lot of WETH9 in the code. If i am using this on another EVM that doesnt have ETH/WETH for gas but instead another coin do I need to edit all those WETH9 to whatever the gas coin is on that network?
@JamesBachini
@JamesBachini 7 месяцев назад
@@harrisonfang Uniswap always uses weth rather than the native Eth. So on Polygon for example they use wMatic rather than mastic. There is a list in the Uniswap docs I think of all the correct addresses
@harrisonfang
@harrisonfang 7 месяцев назад
@@JamesBachini Right. My question is for my case I am trying to test this on the SMR evm network which uses SMR for gas fees. In my case would I need to edit your code and replace everything that says WETH9 with SMR?
Далее
Flash Loan Arbitrage | Aave Flash Loan Tutorial
48:34
Просмотров 144 тыс.
Bike vs Super Bike Fast Challenge
00:30
Просмотров 6 млн
POV: Your kids ask to play the claw machine
00:20
Просмотров 8 млн
How to Make an App in 8 Days (2024) - Full Walkthrough
3:00:49
How I used AI to make a $20M memecoin
36:58
Просмотров 439 тыс.
Statistical Arbitrage with Cointegration for Beginners
18:30
How to Build an Exchange
38:17
Просмотров 175 тыс.
ChatGPT for Data Analytics: Full Course
3:35:30
Просмотров 263 тыс.
Bike vs Super Bike Fast Challenge
00:30
Просмотров 6 млн