You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 28, 2025. It is now read-only.
Pyth Lazer is a permissioned service that provides ultra-low-latency market data to consumers.
4
6
It aggregates data from multiple publishers and distributes it to consumers through a multi-tier architecture.
5
7
6
-
## System Components
8
+
## System Services
7
9
8
-
The architecture consists of four main services that work together to provide ultra-low-latency data to consumers.
10
+
The architecture consists of five main services that work together to provide ultra-low-latency data to consumers.
9
11
10
12
### INSERT DIAGRAM HERE
11
13
12
14
### Publishers
13
15
14
-
Publishers are the entities that provide market data to Lazer. They submit price updates via authenticated WebSocket connections.
16
+
Publishers are the entities that provide market data to Lazer. They submit updates via authenticated WebSocket connections.
15
17
Each publisher is configured with specific permissions defining which feeds they can update.
16
18
17
19
### Relayers
18
20
19
-
The Relayer is the ingestion layer that receives and validates all incoming updates from publishers.
21
+
The Relayer service is the ingestion layer that receives and validates all incoming updates from publishers.
20
22
21
23
**Key responsibilities:**
22
24
23
25
-**Authentication**: Validates publisher access tokens and optional Ed25519 signatures.
24
-
-**Rate limiting**: Enforces configurable limits of price updates per publisher.
25
-
-**Message forwarding**: Publishes validated updates to NATS or Kafka.
26
-
-**History Service**: Maintains a connection to the History Service to cache historical data for circuit breaker validation.
26
+
-**Rate limiting**: Enforces configurable limits on publisher updates.
27
+
-**Message forwarding**: Publishes validated updates to an internal message queue (a NATS cluster).
28
+
29
+
**Douro Labs** operates the relayer service for the Pyth Lazer network.
30
+
31
+
<Callouttype="info">
32
+
The Douro Labs-operated relayer follows a strict, deterministic processing model:
33
+
-**No price dropping**: All validated updates are forwarded to the message queue without dropping any prices.
34
+
-**FCFS processing**: Updates are processed on a first-come-first-served basis without prioritization.
35
+
-**Deterministic operation**: The relayer operates according to its configured logic and does not deviate from it.
27
36
28
-
The Relayer also maintains a connection to the History Service to cache historical data for circuit breaker validation.
37
+
This ensures reliable, predictable data flow from publishers to consumers.
29
38
30
-
### Aggregator Component
39
+
</Callout>
31
40
32
-
The Aggregator is a library component embedded within both the Router and History Service.
33
-
It consumes publisher updates from the message bus and computes aggregated price feeds.
41
+
### Message Queue
34
42
35
-
**Aggregation logic:**
36
-
The Aggregator computes median prices, confidence intervals (using interquartile range), and best bid/ask prices from multiple publisher inputs.
37
-
It filters out stale data and ensures minimum publisher requirements are met before publishing aggregated updates.
43
+
The system uses NATS JetStream as the primary message queue for pub/sub messaging with stream persistence.
44
+
This allows the system to be deployed in a multi-datacenter environment and ensures reliable message delivery between services.
38
45
39
-
### Router Service
46
+
**Message ordering**: NATS JetStream guarantees message ordering within a single stream, ensuring that updates from publishers are processed in the order they were received by the Relayer.
47
+
This ordering guarantee is critical for maintaining consistent feed state across all aggregators.
40
48
41
-
The Router is the real-time distribution layer that serves price feeds to consumers.
49
+
### Routers
50
+
51
+
The Router is the real-time distribution layer that serves data to consumers.
52
+
It embeds aggregation logic to compute median prices, confidence intervals (using interquartile range), and best bid/ask prices from multiple publisher inputs.
42
53
43
54
**Key features:**
44
55
@@ -47,9 +58,20 @@ The Router is the real-time distribution layer that serves price feeds to consum
47
58
-**Channel types**: Supports real-time and fixed-rate channels (1ms, 50ms, 200ms)
48
59
-**Multi-chain support**: Generates on-chain payloads for Solana, EVM, and other chains
49
60
50
-
### Message Transport Layer
61
+
#### Aggregation logic
62
+
63
+
Each Router embeds an aggregator component that consumes publisher updates from NATS and computes aggregated data feeds. The aggregator:
51
64
52
-
The system supports dual message queue backends for flexibility. This allows the system to be deployed in a multi-datacenter environment.
65
+
- Computes median values resistant to outlier data from individual publishers.
66
+
- Calculates confidence intervals using interquartile range to measure data spread.
67
+
- Determines best bid/ask values filtered to ensure market consistency.
68
+
- Automatically removes stale publisher data based on configurable timeouts.
69
+
70
+
### History Service
71
+
72
+
The History Service provides persistence and historical data queries.
73
+
74
+
**Key responsibilities:**
53
75
54
-
-**NATS Jetstream**: Provides pub/sub messaging with stream persistence.
55
-
-**Apache Kafka**: Can be used instead of NATS for message transport.
76
+
-Data persistence: Stores all publisher updates, aggregated data, and transactions in ClickHouse.
77
+
-Historical queries: Provides REST API for querying historical data.
0 commit comments