How to make an arbitrage trading bot with moralists

how to make an arbitrage trading bot with moralists

for arbitrage you may need to process transactions fast and to make your own price processing/prediction, you can get latest transactions by using a speedy node

1 Like

do you have telegram

I usually don’t use telegram

1 Like

how to flash loans on dydx or aave with moralis using remix

1 Like

Hey - can you assist on how to write the arbitrage bot code for Moralis?

1 Like

maybe this tutorial will help you:

@Crypto86 @Jonnykashhh arbitrage bots can be tricky. the flashloan itself is the easiest part. the hardest part is fetching price data reliably. the easest way to start is to use uniswap because since there a Constant product market maker you can crudely calculate price data from the token reserves. Although this is not competitative at all its a good way to start because its easy. the way it works is you calculate the price of a token pair fromt he reserves of that pair on two exchanges say uniswap and sushiswap. You then can call built in functions from uniswap called getAmountIn() which you can use to figure out how much money you get in tonkenY for putting in tokenX. You can call this function on two exchanges for a token pair take the difference and if the difference minus gas fees is positive then you have an opportunity to arbitrage and then you can call a flashswap. also you can use the fact that many exchanges like sushiswap etc are exact clones of uniseap therefore you can fetch price data in the exact same way from these exchanges using the uniswap router contract. Thats ehy this way is easier. After this youy can move on to more complex strategys like using aave and using better price data strats etc

Make the bot firstly this way then look intp price price oracles and more complex things like using flashbots to prevent front running and 0 gas transactions. Ill link a video below. If you want to see an idea of how to right a function arb bot consider my repo below. its far frpm perfect and there is room for a ton of optimization but theres good documentation and a yechnical paper to go off to give you ideas how to make your own.

Link to my repo

link to flashbots

Ohh an you should take a day or so to fork and to understand the uniswpa contracts and fread their docs it will save you a lot of time in the long run


Thank you very much, it is quite helpful ’ is this an official Moralis tutorial?

I totally agree the Arbitrage bot can be quite complicated, i really appreciate all the information as well as the guidance. thank you for the help. I will keep you updated with my progress. Once again, thank you very much

1 Like

yes, that is an official tutorial from Moralis

1 Like

I really apprenticed thoroughness of your GitHub tutorial - it has been a great help on my self taught journey. Unfortunately, since December I have been fighting a rootkit hack-from-hell therefore I am just now getting back to my project. I sent you an email with a special request - hope to hear from you soon. Thanks for all you do to help the little guys in the crazy defi world.


1 Like