Skip to content

Sequencer Service

Overview

The Sequencer is a NodeJs-based service, it processes all internal and external transactions performs risk checks, and updates account state.

Quick Start

Prerequisites

  • Node.js LTS
  • Docker and Docker Compose
  • NX CLI (yarn nx)

Setup & Running

  1. Create and populate .env file using the template in .env.example

  2. Build the service:

nx run sequencer:build
  1. Start with Docker Compose:
docker-compose up
  1. Stop and cleanup:
docker-compose down -v

Development

Run tests:

# Unit tests
nx run sequencer:test

# Integration tests (requires .env file in tests/it/)
nx run sequencer:it

Technical Specifications

Core Technology Stack

  • Runtime: Node.js LTS
  • Language: TypeScript 4.x
  • Build System: NX with ESBuild
  • Service Type: Application Service
  • Version: 0.0.1

Key Dependencies

  • Core:

  • ESBuild for TypeScript compilation

  • FastAPI for API endpoints
  • Redis for order storage and pub/sub
  • BigQuery for trade history

  • Testing:

  • Jest

  • Supertest
  • Redis Mock

  • Development:

  • ESLint
  • NX Monorepo Tools
  • TypeScript with strict mode

Service Architecture

Core Components

  1. API Layer (app.ts)

  2. RESTful endpoints

  3. Request validation
  4. Response handling
  5. Error management

  6. Order Management

  7. Limit order handling

  8. Market order processing
  9. RFQ system
  10. Order cancellation

  11. Matching Engine

  12. Order book maintenance

  13. Price-time priority matching
  14. Fill or Kill (FOK) orders
  15. Immediate or Cancel (IOC) orders

  16. Database Layer (db/)

  17. Redis integration for order books

  18. BigQuery for trade history
  19. Data persistence strategies
  20. Caching mechanisms

  21. Types & Validation (types/, validators/)

  22. Type definitions

  23. Input validation
  24. Schema enforcement
  25. Signature verification

  26. Utilities (utils/)

  27. Order processing helpers
  28. Signature validation
  29. Mathematical calculations
  30. Shared functionality

API Endpoints (TODO)

Infrastructure

Deployment

  • Containerized deployment (Dockerfile provided)
  • Redis requirement for funding data
  • BigQuery integration for transaction snapshots
  • Environment-based configuration

Build Configuration

  • Development and production builds
  • Source map support
  • TypeScript strict mode
  • ESLint integration

Testing Infrastructure

Unit Testing

  • Jest framework
  • Mocked dependencies
  • Comprehensive test coverage
  • Automated via CI/CD

Integration Testing

  • End-to-end API testing
  • Redis integration tests
  • Sequenced test execution
  • Environment-specific configurations

Development Tools

  • ESLint configuration
  • TypeScript strict mode
  • Automated testing
  • Hot reloading

Configuration

Environment Variables

Required variables:

ORDERBOOK_PORT=4000
REDIS_HOST=localhost
REDIS_PORT=6379
ORDERBOOK_SALT=your_salt
PROJECT_ID=your_gcp_project
SEQUENCER_API_URL=http://localhost:3000
PREMIA_API_KEY=your_api_key
ENV=local|dev|prod

Monitoring & Health

Endpoints

  • /healthcheck - Service health check
  • Metrics endpoint (TODO)

Logging

  • Structured JSON logging
  • Error tracking
  • Request tracing
  • Performance monitoring

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Run tests before committing
  4. Submit pull request

License

Proprietary - All rights reserved


This documentation is generated from the service README. For the most up-to-date information, refer to the original README