All Projects

DexOrders

Distributed order execution engine for Solana DEXs

Overview

DexOrders is a production-focused Solana order execution engine. It aggregates live quotes from Raydium, Meteora, Orca, and Jupiter, applies tuple-based routing strategies to pick the optimal venue, and streams real-time order progress over WebSocket. The execution path is designed around market orders for their immediate-fill semantics — the cleanest way to showcase parallel quote fetching, intelligent routing, and live telemetry without the orchestration overhead of resting orders. The core is a Fastify server backed by per-DEX BullMQ queues (rate-limited to 10 jobs/sec ≈ 100 orders/minute), a custom DexOrders Liquidity Engine modeling constant-product pools (x·y=k) with live reserve updates, and a PostgreSQL/Redis persistence layer. The stack also includes a historical backtesting engine with synthetic data generation and performance analytics.

Architecture

  1. 01Client POSTs `/api/orders/execute` → Fastify validates, persists to PostgreSQL, caches in Redis.
  2. 02Four quote jobs are dispatched in parallel — one per DEX queue — each rate-limited at the queue level.
  3. 03Workers call `MockDexRouter` backed by the DexOrders Liquidity Engine to produce realistic quotes.
  4. 04RoutingHub selects the winning quote via the configured strategy (price, slippage, liquidity, or latency).
  5. 05Chosen DEX runs the swap; reserves are updated; order status events stream to the client over WebSocket (`pending → routing → building → submitted → confirmed`).

What I learned

  • Designing backpressure-aware worker fan-out with BullMQ.
  • Reasoning about order lifecycles under partial failure and retries.
  • Modeling AMM math and slippage in a test-first fashion.