The LP-9000 series defines the complete specification for the LX Decentralized Exchange, including order matching, API protocols, and high-frequency trading support.
LP-9000 defines the core architecture and requirements for the LX Decentralized Exchange, a high-performance trading platform achieving 434M+ orders/sec with sub-microsecond latency.
Requirement Specification Achieved Order Latency < 1 microsecond 2ns (GPU), 487ns (CPU) Throughput > 100M orders/sec 434M orders/sec Finality < 100ms 1ms (FPC consensus) Availability 99.99% 99.995%
┌─────────────────────────────────────────────────────────────┐
│ LX CORE (LP-9000) │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Orderbook │ │ Matching │ │ Settlement │ │
│ │ LP-9010 │ │ LP-9020 │ │ LP-9040 │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │ │
│ └────────────────┼────────────────┘ │
│ v │
│ ┌───────────────────────────────────────────────────────┐ │
│ │ Trading Engine (LP-9001) │ │
│ │ Go Engine | C++ Engine | GPU/MLX Engine │ │
│ └───────────────────────────────────────────────────────┘ │
│ │ │
│ ┌───────────────────────┴───────────────────────────────┐ │
│ │ API Layer (LP-9002) │ │
│ │ JSON-RPC | gRPC | WebSocket | REST | FIX │ │
│ └───────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Type Description Support Market Execute at best price Required Limit Execute at specified price or better Required Stop-Loss Trigger market order at stop price Required Stop-Limit Trigger limit order at stop price Required IOC Immediate or Cancel Required FOK Fill or Kill Required GTC Good Till Cancel Required GTD Good Till Date Optional Iceberg Hidden quantity Optional Bracket Entry with TP/SL Optional
LP-9001 specifies the multi-engine trading architecture supporting Pure Go, C++, and GPU acceleration for maximum performance across different hardware configurations.
type EngineType int
const (
EngineGo EngineType = iota // Pure Go, portable
EngineCPP // C++, low-latency
EngineGPU // GPU/MLX, ultra-high throughput
EngineAuto // Auto-select best available
)
Engine Throughput Latency Memory Use Case Go 1M/sec ~1ms Low General trading C++ 400K/sec 25-200ns Medium HFT GPU/MLX 434M/sec 2ns High Planet-scale
Source : pkg / lx / engine. go
// Engine interface - all engines implement this
type Engine interface {
PlaceOrder ( ctx context . Context , order * Order ) ( * OrderResult , error )
CancelOrder ( ctx context . Context , orderID string ) error
GetOrderBook ( ctx context . Context , symbol string , depth int ) ( * OrderBook , error )
Subscribe ( ctx context . Context , symbol string ) ( <-chan * Trade , error )
}
LP-9002 defines the complete API specification for interacting with the LX, including JSON-RPC, gRPC, WebSocket, REST, and FIX protocols.
Protocol Port Use Case Latency JSON-RPC 8545 Web clients ~10ms gRPC 50051 High-performance ~1ms WebSocket 8546 Real-time feeds ~5ms REST 443 Simple integration ~50ms FIX 4.4 9880 Institutional ~2ms
Method Description Parameters dex_placeOrder Place new order {symbol, side, type , price, quantity} dex_cancelOrder Cancel order {orderId} dex_getOrder Get order status {orderId} dex_getOrderBook Get orderbook {symbol, depth} dex_getTrades Get trade history {symbol, limit} dex_getBalance Get balances {address} dex_subscribe Subscribe to feed {channel, symbols}
// Request
{
"jsonrpc" : "2.0" ,
"id" : 1 ,
"method" : "dex_placeOrder" ,
"params" : {
"symbol" : "BTC-USD" ,
"side" : "buy" ,
"type" : "limit" ,
"price" : "50000.00" ,
"quantity" : "1.5" ,
"timeInForce" : "GTC"
}
}
// Response
{
"jsonrpc" : "2.0" ,
"id" : 1 ,
"result" : {
"orderId" : "ord_abc123" ,
"status" : "pending" ,
"symbol" : "BTC-USD" ,
"side" : "buy" ,
"type" : "limit" ,
"price" : "50000.00" ,
"quantity" : "1.5" ,
"filled" : "0" ,
"remaining" : "1.5" ,
"timestamp" : 1702300000000
}
}
Channel Description Example trades Real-time trades { "channel" : "trades" , "symbol" : "BTC-USD" } orderbook Orderbook updates { "channel" : "orderbook" , "symbol" : "BTC-USD" } ticker Price ticker { "channel" : "ticker" , "symbol" : "BTC-USD" } orders User orders { "channel" : "orders" } fills User fills { "channel" : "fills" }
LP-9003 specifies the low-level binary protocol and optimizations for achieving sub-microsecond latency in high-frequency trading scenarios.
┌────────────────────────────────────────────────────────────┐
│ Message Header (16 bytes) │
├──────────┬──────────┬──────────┬──────────┬───────────────┤
│ Magic(4) │ Size(4) │ Type(2) │ Seq(4) │ Checksum(2) │
├──────────┴──────────┴──────────┴──────────┴───────────────┤
│ Message Body (variable) │
└────────────────────────────────────────────────────────────┘
Type ID Name Size Description 0x01 NewOrder 64 bytes Place new order 0x02 CancelOrder 32 bytes Cancel order 0x03 ModifyOrder 48 bytes Modify existing order 0x10 OrderAck 24 bytes Order acknowledged 0x11 OrderFill 56 bytes Order filled 0x12 OrderCancel 24 bytes Order cancelled 0x20 BookUpdate var Orderbook update
Technique Latency Reduction Lock-free queues 50% SIMD batch processing 30% Memory-mapped I/O 40% CPU pinning 20% Kernel bypass (DPDK) 60%
LP-9010 defines the orderbook data structure, price level management, and order priority rules for the LX.
type OrderBook struct {
Symbol string
Bids * PriceLevelTree // Red-black tree, descending
Asks * PriceLevelTree // Red-black tree, ascending
OrderIndex map [ string ] * Order
Sequence uint64
}
type PriceLevel struct {
Price decimal . Decimal
Orders * list . List // FIFO queue
Volume decimal . Decimal
}
Price Priority : Better price first
Time Priority : Earlier orders first (FIFO)
Size Priority : Optional, for pro-rata matching
LP-9020 specifies the order matching algorithm, execution rules, and trade generation for the LX.
MATCH(order):
IF order.side == BUY:
opposite_side = orderbook.asks
ELSE:
opposite_side = orderbook.bids
WHILE order.remaining > 0 AND opposite_side.has_matching_price(order):
best_level = opposite_side.top()
FOR each resting_order IN best_level:
IF order.remaining == 0:
BREAK
fill_qty = MIN(order.remaining, resting_order.remaining)
fill_price = resting_order.price # Price-time priority
CREATE_TRADE(order, resting_order, fill_qty, fill_price)
UPDATE(order, resting_order, fill_qty)
IF best_level.empty():
REMOVE(best_level)
IF order.remaining > 0 AND order.type == LIMIT:
ADD_TO_BOOK(order)
Mode Description Use Case Price-Time FIFO at each price Standard Pro-Rata Proportional allocation Large orders Auction Batch matching Opening/closing
LP-9030 defines the market data distribution protocol, including real-time feeds, historical data, and aggregation methods.
Feed Latency Update Rate Use Case Level 1 <1ms Every trade Retail Level 2 <1ms Every change Active traders Level 3 <100us Every message Market makers OHLCV 1s Per interval Analytics
LP-9040 specifies the settlement protocol for finalizing trades on-chain using Warp messages and atomic swaps.
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Matching │───>│ Netting │───>│ On-Chain │
│ Engine │ │ Engine │ │ Settlement │
└─────────────┘ └─────────────┘ └─────────────┘
│ │ │
│ Trade │ Batch │ Finality
│ ~2ns │ ~10ms │ ~1ms
│ │ │
Mode Latency Cost Use Case Instant 1ms High Urgent Batched 1s Medium Standard Deferred 1min Low Large orders