A high-performance price matching engine for Solana-based trading applications. It listens to on-chain events to a program, maintains an in-memory order book, and provides an API for querying the current state.
- Real-Time Event Processing: Listens to Solana on-chain events via WebSocket and processes them in real-time.
- In-Memory Order Book: Maintains a high-performance, in-memory order book.
- Order Management: Handles order creation, cancellation, updates, and fills.
- HTTP API: Exposes an HTTP server to query the order book and system state.
- Database Integration: Persists event history to a PostgreSQL database.
-
Clone the repository:
git clone https://github.com/thris/matching-engine.git cd matching-engine
The project is organized into several modules:
api.rs: Handles API requests.engine.rs: The core matching engine logic.events.rs: Event definitions and handling.lib.rs: Crate root and utility functions.main.rs: The main application entry point.order.rs: Order-related data structures and logic.price.rs: Price calculation and related functions.processor.rs: Event processing and dispatching.server.rs: The HTTP server implementation.state.rs: Manages the application's state.types.rs: Common data types used throughout the application.
- tokio: Asynchronous runtime for Rust.
- axum: Web application framework.
- serde: Framework for serializing and deserializing Rust data structures.
- solana-client: Solana RPC client.
- sqlx: Asynchronous SQL toolkit for Rust.
- tracing: A framework for instrumenting Rust programs to collect structured, event-based diagnostic information.