Skip to main content

Monaco Protocol v0.3.0

Orderbooks and Flat Fees

This release introduces major improvements to orderbook functionality, fee management, and order lifecycle handling. Key highlights include real-time orderbook snapshots via WebSocket, flat fee support, and comprehensive time-in-force options.

What’s New

Orderbook Enhancements
  • Real-time Orderbook Snapshots: Full orderbook state via WebSocket with initial snapshot on subscription
  • Orderbook Magnitude Grouping: Optional price level aggregation for cleaner visualization (0.0001 to 10000 increments)
  • Improved Orderbook Endpoint: Enhanced REST API with better performance and data structure
Fee System Improvements
  • Flat Fee Support: New fee calculation method alongside existing basis point fees
  • Fee HTTP Endpoints: Dedicated API endpoints for fee management and queries
  • Pre-settlement Fee Calculation: Fees calculated before settlement for accurate balance checks
Time-in-Force Support
  • Full TIF Implementation: Support for GTC (Good-Till-Cancel), IOC (Immediate-or-Cancel), and FOK (Fill-or-Kill)
  • Order Rejection Events: New event types for rejected orders with detailed reasons
  • Enhanced Order Validation: Pre-validation for FOK orders to prevent partial fills
Order Management Improvements
  • Order Replacement: Renamed “Update Order” to “Replace Order” for clarity
  • Order Quantity Validation: Enhanced validation on order replacement
  • Consistent Enum Formatting: Uppercase enums across entire codebase (SPOT, MARGIN, BUY, SELL, etc.)
  • Side and Role Fields: Added to OrderPlaced and OrderPartiallyFilled WebSocket events

Technical Details

WebSocket Connection Methods Connect to WebSockets using either auto-connect during login or explicit connection:
Orderbook WebSocket with Magnitude Subscribe to orderbooks with optional price grouping:
Time-in-Force Orders

Architecture & Infrastructure

Admin API
  • New admin endpoints for system management and monitoring
  • Procedural macro-based authentication decorators replacing middleware
Authentication Improvements
  • Unified auth extractor with procedural macros
  • Replace middleware with #[require_auth], #[require_master], and #[require_permission] decorators
  • Cleaner, more maintainable authentication layer
Performance Optimizations
  • Reduced lock contention during API initialization and order expiration
  • Trading pair cache updates for faster lookups
  • Improved matching engine transaction handling
Testing & Code Quality
  • Split order E2E tests into multiple focused test suites
  • Resolved foreign key constraint violations in indexer tests
  • Enhanced test coverage with .env file support
  • Fixed IOC order event emission for partial fills

Bug Fixes

  • Fixed double serialization issues with consistent uppercase enum representation
  • Corrected BPS calculation in matching engine for order creation
  • Fixed maker order status and balance updates when trades occur
  • Resolved insufficient balance errors on order creation
  • Fixed IOC/FOK partial fill locked balance issues
  • Prevented duplicate blockchain events with enhanced duplicate checking
  • Fixed missing cancelled events for IOC orders
  • Improved order settlement status checks before cancellation

Documentation

  • Auto-generated API documentation from OpenAPI specs
  • Updated SDK documentation for latest features
  • Added cloud infrastructure architecture documentation
  • Comprehensive orderbook WebSocket examples
  • Enhanced trading pair and order object documentation

Packages Updated

Installation

Migration Notes

Breaking Changes:
  • Enum values are now consistently uppercase (SPOT, MARGIN, BUY, SELL, etc.)
  • Update any hardcoded lowercase enum strings to uppercase
New Features:
  • Orderbook magnitude parameter is optional (defaults to full precision)
  • Time-in-force defaults to GTC if not specified

Contributors

  • @kamwithak
  • @codebycarson
  • @ogarciarevett
  • @dssei
  • @ppitlehra
  • @Kbhat1

Full Changelog

This release merged 55 pull requests.