Skip to content

NgBaoAnn/spot-arbitrage-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

106 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DexArb — Flash Loan DEX Arbitrage Bot

Kiếm lời từ chênh lệch giá giữa các DEX — Không cần vốn, Không rủi ro

Architecture

Off-chain Bot (Node.js) → Smart Contract (Solidity) → Balancer V2 + DEX Swaps

Project Structure

blockchain/
├── contracts/                    # On-chain Layer (TV1)
│   ├── src/
│   │   ├── FlashLoanArbitrage.sol    # Main contract
│   │   └── interfaces/
│   │       ├── IBalancerVault.sol     # Balancer V2 flash loan
│   │       ├── ISwapRouter.sol       # Uniswap V3
│   │       ├── IUniswapV2Router.sol  # Sushiswap
│   │       └── IERC20.sol
│   ├── test/
│   │   └── FlashLoanArbitrage.t.sol  # Foundry tests
│   ├── script/
│   │   └── Deploy.s.sol             # Deployment script
│   └── foundry.toml
│
├── bot/                          # Off-chain Layer
│   ├── src/
│   │   ├── index.ts                  # Bot orchestrator (TV2)
│   │   ├── monitor/
│   │   │   ├── index.ts              # Price aggregator (TV2)
│   │   │   ├── uniswap.ts           # Uniswap V3 prices (TV3)
│   │   │   └── sushiswap.ts         # Sushiswap prices (TV4)
│   │   ├── detector/
│   │   │   └── index.ts             # Arbitrage detector (TV2)
│   │   ├── calculator/
│   │   │   └── index.ts             # Profit calculator (TV2)
│   │   ├── executor/
│   │   │   └── index.ts             # Contract executor (TV2)
│   │   ├── helpers/
│   │   │   ├── uniswapSwap.ts       # Uniswap swap helper (TV3)
│   │   │   └── sushiSwap.ts         # Sushiswap swap helper (TV4)
│   │   ├── config/
│   │   │   └── index.ts             # Network & DEX addresses (TV3)
│   │   └── types/
│   │       └── index.ts             # Shared TypeScript types
│   ├── package.json
│   └── tsconfig.json
│
├── frontend/                     # Dashboard Layer (TV4)
│   ├── app/
│   │   ├── layout.tsx               # Root layout + providers
│   │   └── page.tsx                 # Main dashboard
│   ├── components/
│   │   ├── StatsCards.tsx           # Profit, trades, win rate
│   │   ├── PriceTable.tsx           # Real-time DEX prices
│   │   ├── TradeHistory.tsx         # Past trades from events
│   │   └── WalletConnect.tsx        # MetaMask + withdraw
│   ├── hooks/
│   │   └── useArbitrageEvents.ts    # Custom event hook
│   ├── lib/
│   │   └── contracts.ts             # ABI + addresses
│   └── public/
│
├── scripts/
│   └── simulate.ts                   # Fork simulation (TV1)
│
├── docs/                         # Documentation
│   ├── dexarb-flash-loan-idea.md
│   ├── dexarb-project-proposal.md
│   ├── dexarb-analysis-wbs.md
│   ├── dexarb-report.tex
│   └── dexarb-slides.tex
│
├── .env.example
├── .gitignore
└── README.md

Quick Start

# 1. Smart Contract
cd contracts
forge install
forge build
forge test

# 2. Bot
cd bot
npm install
cp ../.env.example ../.env  # Fill in your keys
npm run dev

# 3. Frontend
cd frontend
npm install
npm run dev

Tech Stack

Layer Technology
Smart Contract Solidity 0.8.19, Foundry
Flash Loan Balancer V2 (0% fee)
Bot Node.js 18+, ethers.js v6
Cache Redis
Frontend Next.js 14, Wagmi, RainbowKit
MEV Protection Flashbots Protect

Team — Make Antigravity Great Again

Member Role
TV1 Smart Contract / Security
TV2 Backend / Bot Logic
TV3 Infra + Uniswap V3 Integration
TV4 Frontend + Sushiswap Integration

License

MIT

About

Spot Trading Arbitrage Bot - Multi-Exchange Price Arbitrage Engine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors