About this project
FlashLoanArbitrage is an automated DeFi trading bot built with Node.js that performs flash loan arbitrage on Ethereum. The project consists of a JavaScript driver script (`goflash.js`) and an associated smart contract.
How It Works
The bot monitors ETH/USDC prices across five platforms—Chainlink (oracle reference), Uniswap V2, SushiSwap, Curve Finance, and Balancer. When the price difference between any two venues reaches 0.9% or higher, the script triggers a flash loan through one of four supported protocols: Aave, dYdX, Uniswap V3, or Balancer. The smart contract borrows USDC, executes the cross-venue trade (buying ETH cheap and selling it dear), repays the loan plus fees, and returns any net profit to the user's wallet.
Supported Flash Loan Protocols
- Aave: up to 10,000,000 USDC, 0.05% fee
- dYdX: up to 500,000 USDC, 0.05% fee
- Uniswap V3: up to 5,000,000 USDC, 0.01% fee
- Balancer: up to 1,000,000 USDC, 0.02% fee
Setup and Usage
To run the bot, clone the repository and install dependencies with `npm install`. On first launch, the script generates or imports an Ethereum wallet, saving the private key to `wallet.json`. The interactive CLI menu allows selection of flash loan protocol, loan amount, and starting/stopping arbitrage monitoring. A wallet balance of at least 0.1 ETH is required for loans above 10 ETH to cover gas costs.
Key Behaviors
- Price data refreshes approximately every 60 seconds.
- The minimum threshold for triggering a trade is a 0.9% price spread.
- Trading fees (0.1%), slippage (0.05%), and gas are accounted for in profit calculations.
- The user's ETH is not transferred to the contract; it remains in the wallet and is only used for gas.
- Includes basic error handling for RPC failures, invalid private keys, and missing trading pairs.
Dependencies
- ethers ^6.11.1
- inquirer ^8.2.6
- chalk ^4.1.2
Security Notes
The project stores a private key in `wallet.json`; users are advised to add it to `.gitignore` and keep backups offline. The README states the project is shared as-is for educational purposes and asks users to proceed at their own risk.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.