This is an arbitrage trading bot for cryptocurrencies. This smart contract leverages flashloans to execute profitable trades on my behalf. 💰
Arbi-what? Flash-who? Arbitrage is a condition where an underlying asset is listed for two different prices on two different exchanges. A flashloan is a financial service that allows a user to borrow large amounts of money as long as they are returned in the same transaction.
How? Well the algorithm checks the prices of an ERC-20 token on different exchanges, determines the trade direction, determines profitability, then executes if and when specified conditions are met.
The algorithm, or 'smart contract', is deployed to the blockchain Here, it behaves like a bot on high alert. When the bot discovers arbitrage, it ① buys ERC-20 tokens through Market A (relatively low priced token), the ② bot receives the ERC-20 tokens, then the ③ bot 'swaps' the ERC-20 tokens from Market A for those in Market B (relatively high price), then the bot ④ sells the higher valued tokens for profit!
Demo Sequence:
- deployed solidity smart contracts to the "blockchain" (before video)
- ran a development framework that emulated a live blockchain (ganache)
- executed the
bot.js
script that waited for an arbitrage event - price differential was manually created using
manipulateprice.js
script - gained +0.41 WETH (wrapped ETH), which is roughly $663 USD as of SEP2023
demo.mp4
Notes:
- Price differential occurs in production environment naturally, as prices across different markets and exchanges are constantly in flux.
- Code redacted intentionally