|
1 | 1 | # How Pyth Lazer works |
2 | 2 |
|
3 | | -Pyth Lazer is a permissioned service that provides ultra-low-latency price and market data to highly latency-sensitive users. |
| 3 | +Pyth Lazer is a permissioned service that provides ultra-low-latency market data to consumers. |
| 4 | +It aggregates data from multiple publishers and distributes it to consumers through a multi-tier architecture. |
4 | 5 |
|
5 | | -We are working on writing a detailed technical overview how Lazer works. Details will be added here as they are completed. |
| 6 | +## System Components |
| 7 | + |
| 8 | +The architecture consists of four main services that work together to provide ultra-low-latency data to consumers. |
| 9 | + |
| 10 | +### INSERT DIAGRAM HERE |
| 11 | + |
| 12 | +### Publishers |
| 13 | + |
| 14 | +Publishers are the entities that provide market data to Lazer. They submit price updates via authenticated WebSocket connections. |
| 15 | +Each publisher is configured with specific permissions defining which feeds they can update. |
| 16 | + |
| 17 | +### Relayers |
| 18 | + |
| 19 | +The Relayer is the ingestion layer that receives and validates all incoming updates from publishers. |
| 20 | + |
| 21 | +**Key responsibilities:** |
| 22 | + |
| 23 | +- **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. |
| 27 | + |
| 28 | +The Relayer also maintains a connection to the History Service to cache historical data for circuit breaker validation. |
| 29 | + |
| 30 | +### Aggregator Component |
| 31 | + |
| 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. |
| 34 | + |
| 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. |
| 38 | + |
| 39 | +### Router Service |
| 40 | + |
| 41 | +The Router is the real-time distribution layer that serves price feeds to consumers. |
| 42 | + |
| 43 | +**Key features:** |
| 44 | + |
| 45 | +- **WebSocket streaming**: Provides `/v1/stream` endpoint for real-time price updates |
| 46 | +- **HTTP REST API**: Offers `/v1/latest_price` for on-demand price queries |
| 47 | +- **Channel types**: Supports real-time and fixed-rate channels (1ms, 50ms, 200ms) |
| 48 | +- **Multi-chain support**: Generates on-chain payloads for Solana, EVM, and other chains |
| 49 | + |
| 50 | +### Message Transport Layer |
| 51 | + |
| 52 | +The system supports dual message queue backends for flexibility. This allows the system to be deployed in a multi-datacenter environment. |
| 53 | + |
| 54 | +- **NATS Jetstream**: Provides pub/sub messaging with stream persistence. |
| 55 | +- **Apache Kafka**: Can be used instead of NATS for message transport. |
0 commit comments