How notlelouch/arbibot works
Project type and purpose
• This is a backend service written in Go that functions as a high-performance, cross-exchange arbitrage bot.
• It is a CLI/daemon application that connects via WebSocket and REST to cryptocurrency exchanges (Hyperliquid, KuCoin), processes real-time order book data, identifies price discrepancies, and triggers trades.
File structure
• Top level:
• cmd/arbibot/main.go – the entrypoint
• internal/ – application code (no public API)
• assets/ – static files (demo gif)
• internal/ modules:
• exchange/… – one sub-package per exchange: hyperliquid, kucoin. Each handles connection setup, authentication, subscription to market data, order execution.
• arbitrage/… – core logic for comparing prices across exchanges, calculating spreads, and deciding when to execute trades.
• types/… – shared domain types (order book entries, price ticks, arbitrage opportunities).
• ui/… – simple dashboard (likely console or HTTP) for displaying live arbitrage stats.
README for additional insights
• Emphasizes real-time WebSocket feeds, low latency, modular design, graceful shutdown.
• Supported exchanges listed, demonstrating easy extension by adding new exchange sub-packages.
a. Main components
• ArbiBot Entrypoint (cmd/arbibot)
• Exchange Connectors (Hyperliquid WS client, KuCoin WS/REST client)
• Arbitrage Engine (internal/arbitrage)
• Shared Types Library (internal/types)
• UI Dashboard (internal/ui)
• External Exchanges (Hyperliquid, KuCoin)
b. Relationships and interactions
1. EntryPoint initializes connectors and the arbitrage engine.
2. Exchange Connectors open WebSocket/REST streams to external exchanges.
3. Market data flows (order book updates) from connectors into the Arbitrage Engine.
4. Arbitrage Engine analyzes data, emits “Opportunity” events.
5. On decision, the engine invokes connectors’ trade methods.
6. UI Dashboard subscribes to engine events and renders real-time stats.
7. Graceful shutdown signal propagates to all components, closing connections.
c. Architectural patterns/design principles
• Layered modularity: separates concerns into connectors, core logic, types, and UI.
• Plugin-style connectors: each exchange implements a uniform interface.
• Event-driven flow: data updates trigger analysis and trade events.
• Dependency inversion: core engine depends on interfaces defined in types, concrete implementations reside in exchange sub-packages.
d. Key technologies/frameworks
• Go modules for dependency management
• Go’s concurrency primitives (goroutines, channels) for streaming data and event handling
• WebSocket libraries (built-in or third-party) for real-time feeds
• REST client for authenticated trading APIs
• Makefile for building and running