A decentralized arbitrage trading system leveraging flash loans for cross-DEX arbitrage opportunities.
ArbitrageX/
│── contracts/ # Smart Contracts (Solidity)
│ ├── FlashLoanService.sol # Flash Loan logic
│ ├── ArbitrageExecutor.sol # Executes arbitrage trades
│ ├── interfaces/ # External contract interfaces
│ ├── mocks/ # Mock contracts for testing
│
│── backend/ # Backend API & Execution Engine
│ ├── api/ # Express API Server
│ ├── execution/ # Trade Execution Logic
│ ├── ai/ # AI Learning Bot
│ ├── database/ # MongoDB Integration
│
│── frontend/ # Web Dashboard
│ ├── components/ # UI Components
│ ├── pages/ # Dashboard Pages
│ ├── services/ # API Integration
│
│── scripts/ # Deployment Scripts
│── tests/ # Testing Suite
- Node.js v18+
- Hardhat
- MongoDB
- Ethers.js v6
- TypeScript
- Create a
config/.env
file with the following variables:
# Network Configuration
INFURA_API_KEY=your_key
SEPOLIA_PRIVATE_KEY=your_key
ETHERSCAN_API_KEY=your_key
# Contract Addresses
SEPOLIA_AAVE_POOL=0x6Ae43d3271ff6888e7Fc43Fd7321a503ff738951
SEPOLIA_UNISWAP_ROUTER=0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E
SEPOLIA_SUSHISWAP_ROUTER=0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506
# Backend Configuration
MONGODB_URI=mongodb://localhost:27017/arbitragex
API_PORT=3000
WS_PORT=3001
# Optional: AI Configuration
ENABLE_AI_OPTIMIZATION=false
- Install dependencies:
# Install root project dependencies
npm install
# Install contract dependencies
cd contracts && npm install
# Install backend dependencies
cd backend && npm install
# Install frontend dependencies
cd frontend && npm install
- Compile contracts:
npx hardhat compile
- Run tests:
npx hardhat test
- Deploy to Sepolia testnet:
npx hardhat run scripts/deploy-phase1.ts --network sepolia
- Verify contracts:
# FlashLoanService
npx hardhat verify --network sepolia <FLASH_LOAN_ADDRESS> <AAVE_POOL>
# ArbitrageExecutor
npx hardhat verify --network sepolia <ARBITRAGE_EXECUTOR> <UNISWAP> <SUSHISWAP> <FLASH_LOAN_ADDRESS>
- Start MongoDB:
docker-compose -f backend/docker-compose.yml up -d
- Start API server:
cd backend/api && npm run start:prod
- Start execution engine:
cd backend/execution && npm run bot:start
- Build frontend:
cd frontend && npm run build
- Start frontend server:
serve -s build -l 3001
# Run all tests
npm test
# Run specific test file
npx hardhat test test/FlashLoanArbitrage.test.ts
# Run with gas reporting
REPORT_GAS=true npx hardhat test
cd backend && npm test
cd frontend && npm test
- All smart contracts are thoroughly tested and follow best practices
- Flash loan validation ensures profitable trades only
- Slippage protection prevents sandwich attacks
- Gas optimization for cost-effective execution
- Automated security checks in CI/CD pipeline
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.