Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 85a5286

Browse files
committed
chore(lazer) Add how lazer works-2
1 parent 1873d8f commit 85a5286

File tree

1 file changed

+42
-20
lines changed

1 file changed

+42
-20
lines changed

pages/lazer/how-lazer-works.mdx

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,55 @@
1+
import { Callout } from "nextra/components";
2+
13
# How Pyth Lazer works
24

35
Pyth Lazer is a permissioned service that provides ultra-low-latency market data to consumers.
46
It aggregates data from multiple publishers and distributes it to consumers through a multi-tier architecture.
57

6-
## System Components
8+
## System Services
79

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.
911

1012
### INSERT DIAGRAM HERE
1113

1214
### Publishers
1315

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.
1517
Each publisher is configured with specific permissions defining which feeds they can update.
1618

1719
### Relayers
1820

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.
2022

2123
**Key responsibilities:**
2224

2325
- **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+
<Callout type="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.
2736

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.
2938

30-
### Aggregator Component
39+
</Callout>
3140

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
3442

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.
3845

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.
4048

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.
4253

4354
**Key features:**
4455

@@ -47,9 +58,20 @@ The Router is the real-time distribution layer that serves price feeds to consum
4758
- **Channel types**: Supports real-time and fixed-rate channels (1ms, 50ms, 200ms)
4859
- **Multi-chain support**: Generates on-chain payloads for Solana, EVM, and other chains
4960

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:
5164

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:**
5375

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

Comments
 (0)