🔗 GitHub Repository: https://github.com/SanyamBK/EternaLabs
🚀 Live Deployment: https://eternalabs-production.up.railway.app
🎮 Interactive Demo: https://eternalabs-production.up.railway.app/demo
📺 Demo Video: https://youtu.be/SGaKzuuAVn4
This repository implements a mock order execution engine for a single order type (market orders by default) with DEX routing, real-time WebSocket status updates, and an order processing queue. The DEX router simulates Raydium and Meteora with realistic network delays and price variance.
Core features:
- Single endpoint
/api/orders/executesupporting both POST and WebSocket upgrades. - MockDEx router comparing quotes and selecting best execution venue.
- BullMQ + Redis-based queue with exponential backoff (≤3 attempts).
- WebSocket lifecycle events: pending → routing → building → submitted → confirmed/failed.
- Docker Compose for local testing (Redis + Postgres + App).
- Unit tests (Jest) and a Postman collection.
I implemented market orders to demonstrate the full execution lifecycle and routing. Market orders emphasize immediate routing & execution, allowing us to show deterministic matching and end-to-end status events. The engine is modular and can be extended to:
- Limit orders: add a price watcher component that enqueues when market price meets target.
- Sniper orders: add a block/tx watch and token listing monitor to trigger an immediate market buy.
- Clone and install:
git clone https://github.com/SanyamBK/EternaLabs.git
cd EternaLabs
npm install- Start with Docker:
docker-compose up --build- Start app:
npm run dev
# server on http://localhost:3000- Accepts JSON:
{ userId, type, tokenIn, tokenOut, amountIn } - Returns:
{ orderId, ws }(ws is suggested subscription path) - After POST, open a WebSocket to the server and send
{ subscribeOrderId: "<orderId>" }to receive status updates.
- Connect to
ws://localhost:3000/api/orders/execute(or same path upgraded via ws). - Send:
{ subscribeOrderId: "<orderId>" } - Events received: JSON objects with
statusfield and additional info (chosenDex, txHash, error).
- Mock DEX: Emulates price spreads (2-5%) and 2–3s execution delays. This keeps the focus on routing logic and system architecture.
- BullMQ: provides robust retries and concurrency settings. Default concurrency is configured in worker.
- WebSocket manager: lightweight in-memory map for connection management. Production: use Redis pub/sub for multi-instance.
- Persistence: orders stored in Postgres (simple table). In this mock, primary focus is on lifecycle and routing; persistence hooks are present.
Run tests:
npm testImport postman/OrderExecution.postman_collection.json to experiment.
Live on Railway: https://eternalabs-production.up.railway.app
The application is deployed with:
- Managed Redis instance (Railway Redis service)
- Managed PostgreSQL database (Railway Postgres service)
- Auto-deployment from GitHub main branch
To test the live API:
Interactive Demo UI: Visit https://eternalabs-production.up.railway.app/demo for a full-featured web interface with:
- Real-time order status updates via WebSocket
- Visual display of DEX routing decisions (Raydium vs Meteora)
- Quick test buttons for common token pairs
- Live statistics dashboard
cURL Example:
curl -X POST https://eternalabs-production.up.railway.app/api/orders/execute \
-H "Content-Type: application/json" \
-d '{"tokenIn":"SOL","tokenOut":"USDC","amountIn":1.5}'- For local development, use Docker Compose (see Quickstart above)
- Replace MockDexRouter with Raydium/Meteora SDKs for real devnet execution
- Integrate
@raydium-io/raydium-sdk-v2and Meteora SDK. - Add wallet signing, devnet faucet, and transaction confirmation flows.
- Implement rate limiting and authentication.
Sanyam Barwar — sanyam22447@iiitd.ac.in