A defi arbitrage bot that leverages flash loans
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
The ArbitrageAutomator
is a trading bot built for decentralized exchanges on the Ethereum blockchain. It achieves profits by finding differing prices for the same tokens on different exchanges, and then trading them away on one platform and for them on the other for a positive return. This is known as "arbitrage".
These arbitrage opportunities exist for two reasons:
- Liquidity Pool Size - most decentralized exchanges change their exchange rates for tokens based on how many tokens the exchange has itself. Thus, as tokens flow in and out of different exchanges' token pools, the prices on those exchanges fluctuate over time.
- Trading Method - some decentralized exchanges use order books for trades, which means traders directly determine the possible trades available to the bot at any given time. Meanwhile, other decentralized exchanges have purely automated market prices based on their liquidity pool size. As a result, the prices of the same tokens can be different on exchanges whose prices are determined in one of these two ways.
In addition to taking advantage of automated market makers (AMMs), which are made possible thanks to blockchain, the ArbitrageAutomator
also utilizes another blockchain innovation: flash loans.
Flash loans are zero risk, zero interest loans that can be taken out for very brief periods from decentralized exchanges. This is possible due to the nature of the Ethereum blockchain: when a transaction is attempted, it will either entirely be accepted by the blockchain, or entirely rejected if even one thing goes wrong. By including the borrowing and the repaying of the loan within the same transaction, the only outcomes are that the borrowing doesn't occur, or that the loan is taken out and repaid. There's no risk to the lender, and no risk or interest to the borrower.
Flash loans are used to fund the ArbitrageAutomator
's trades. First, it borrows tokens and uses them to buy a token on one exchange. It then sells those tokens at a higher price on a different decentralized exchange, and uses the returns to pay back the loan. By including all of these steps in one transaction, these loans and trades can be executed with zero risk.
Web3
Axios
-
Clone the repository.
-
Navigate to the project folder in the command line and install the necessary packages.
npm install
-
Deploy the Solidity files for the TradingBot smart contract.
-
Fill in the .env file:
- RPC_URL - public address of an Ethereum node
- ADDRESS - bot account public address
- PRIVATE_KEY - bot account private key
- CONTRACT_ADDRESS - smart contract address
- Run index.js
node src/index.js
- Congratulations! Your bot is now up and running. It will check for a new arbitrage opportunity every 3 seconds by default. This value can be changed at the bottom of
index.js
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the GNU GPL-3 License. See LICENSE
for more information.
Evan Gottschalk - @EvanOnEarth_eth - evan.blockchain@gmail.com
Project Link: https://github.com/EvanGottschalk/ArbitrageAutomator
Thinking about contributing to this project? Please do! Your Github username will then appear here.