Skip to content

Commit 08019ef

Browse files
Chore(lazer) add lazer docs (#554)
* layout * table * pre-commit * temp * fetch price updates guide * update * evm example * updates * push * update * restructure * update * udpate * fix build * svm guide update * fix: remove todos and non existent links --------- Co-authored-by: Ali Behjati <bahjatia@gmail.com>
1 parent 07d830b commit 08019ef

17 files changed

+716
-0
lines changed

components/LazerPriceIdTable.tsx

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import { useEffect, useState } from "react";
2+
import { StyledTd } from "./Table";
3+
import { Spinner } from "./Spinner";
4+
const fetchLazerPriceIdMetadata = async () => {
5+
const response = await fetch(
6+
"https://pyth-lazer-staging.dourolabs.app/history/v1/symbols"
7+
);
8+
const data = await response.json();
9+
return data;
10+
};
11+
12+
type LazerPriceIdMetadata = {
13+
asset_type: string;
14+
description: string;
15+
exponent: number;
16+
name: string;
17+
pyth_lazer_id: number;
18+
symbol: string;
19+
};
20+
21+
enum LazerPriceIdStateType {
22+
NotLoaded,
23+
Loading,
24+
Loaded,
25+
Error,
26+
}
27+
28+
const LazerPriceIdState = {
29+
NotLoaded: () => ({ type: LazerPriceIdStateType.NotLoaded as const }),
30+
Loading: () => ({ type: LazerPriceIdStateType.Loading as const }),
31+
Loaded: (priceFeeds: LazerPriceIdMetadata[]) => ({
32+
type: LazerPriceIdStateType.Loaded as const,
33+
priceFeeds,
34+
}),
35+
Error: (error: unknown) => ({
36+
type: LazerPriceIdStateType.Error as const,
37+
error,
38+
}),
39+
};
40+
41+
type LazerPriceIdState = ReturnType<
42+
typeof LazerPriceIdState[keyof typeof LazerPriceIdState]
43+
>;
44+
45+
const useLazerPriceIdState = () => {
46+
const [state, setState] = useState<LazerPriceIdState>(
47+
LazerPriceIdState.NotLoaded()
48+
);
49+
50+
useEffect(() => {
51+
setState(LazerPriceIdState.Loading());
52+
fetchLazerPriceIdMetadata()
53+
.then((priceFeeds) => setState(LazerPriceIdState.Loaded(priceFeeds)))
54+
.catch((error) => setState(LazerPriceIdState.Error(error)));
55+
}, []);
56+
57+
return state;
58+
};
59+
60+
export function LazerPriceIdTable() {
61+
const lazerPriceIdState = useLazerPriceIdState();
62+
63+
switch (lazerPriceIdState.type) {
64+
case LazerPriceIdStateType.NotLoaded:
65+
return <div>Loading...</div>;
66+
case LazerPriceIdStateType.Loading:
67+
return <Spinner />;
68+
case LazerPriceIdStateType.Loaded:
69+
return (
70+
<table>
71+
<thead>
72+
<tr>
73+
<th>Asset Type</th>
74+
<th>Description</th>
75+
<th>Name</th>
76+
<th>Symbol</th>
77+
<th>Pyth Lazer Id</th>
78+
<th>Exponent</th>
79+
</tr>
80+
</thead>
81+
<tbody>
82+
{lazerPriceIdState.priceFeeds.map((priceFeed) => (
83+
<tr key={priceFeed.symbol}>
84+
<StyledTd>{priceFeed.asset_type}</StyledTd>
85+
<StyledTd>{priceFeed.description}</StyledTd>
86+
<StyledTd>{priceFeed.name}</StyledTd>
87+
<StyledTd>{priceFeed.symbol}</StyledTd>
88+
<StyledTd>{priceFeed.pyth_lazer_id}</StyledTd>
89+
<StyledTd>{priceFeed.exponent}</StyledTd>
90+
</tr>
91+
))}
92+
</tbody>
93+
</table>
94+
);
95+
case LazerPriceIdStateType.Error:
96+
return <div>Error</div>;
97+
}
98+
}

components/Spinner.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { SVGProps } from "react";
2+
export const Spinner = (props: SVGProps<SVGSVGElement>) => (
3+
<div role="status">
4+
<svg
5+
aria-hidden="true"
6+
className="w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600"
7+
viewBox="0 0 100 101"
8+
fill="none"
9+
xmlns="http://www.w3.org/2000/svg"
10+
{...props}
11+
>
12+
<path
13+
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
14+
fill="currentColor"
15+
/>
16+
<path
17+
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
18+
fill="currentFill"
19+
/>
20+
</svg>
21+
<span className="sr-only">Loading...</span>
22+
</div>
23+
);

images/lazer/Pyth_Laser_table.png

159 KB
Loading

pages/_meta.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
"type": "page"
1010
},
1111

12+
"lazer": {
13+
"title": "Lazer",
14+
"type": "page"
15+
},
16+
1217
"benchmarks": {
1318
"title": "Benchmarks",
1419
"type": "page"

pages/home/_meta.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
"href": "/price-feeds"
1212
},
1313

14+
"Lazer": {
15+
"title": "Lazer →",
16+
"href": "/lazer"
17+
},
18+
1419
"Benchmarks": {
1520
"title": "Benchmarks →",
1621
"href": "/benchmarks"

pages/home/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Pyth Network offers several products for developers:
88

99
- [Price Feeds](../price-feeds) provide real-time prices for 500+ assets on 55+ blockchain ecosystems, including Solana, many EVM chains,
1010
Aptos, Sui, NEAR, and several Cosmos chains.
11+
- [Lazer](../lazer) [TODO]
1112
- [Benchmarks](../benchmarks) provides historical Pyth prices for both on- and off-chain use.
1213
- [Express Relay](../express-relay/) enables protocols to eliminate their MEV while gaining access to active searchers and liquidators.
1314
- [Entropy](../entropy) allows developers to generate secure random numbers on the blockchain.

pages/lazer/_meta.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"documentation-home": {
3+
"title": "← Documentation Home",
4+
"href": "/home"
5+
},
6+
7+
"-- Lazer": {
8+
"title": "Lazer",
9+
"type": "separator"
10+
},
11+
"index": "Introduction",
12+
"getting-started": "Getting Started",
13+
14+
"-- How-to Guides": {
15+
"title": "How-To Guides",
16+
"type": "separator"
17+
},
18+
19+
"subscribe-price-updates": "Subscribe to Price Updates",
20+
"integrate-as-consumer": "Integrate as a Consumer",
21+
"integrate-as-publisher": "Integrate as a Publisher",
22+
23+
"-- Reference Material": {
24+
"title": "Reference Material",
25+
"type": "separator"
26+
},
27+
"price-feeds-ids": "Price Feed IDs",
28+
29+
"websocket-api-reference": {
30+
"title": "Websocket API Reference ↗",
31+
"href": "https://pyth-lazer.dourolabs.app/docs",
32+
"newWindow": true
33+
},
34+
35+
"examples": {
36+
"title": "Example Applications ↗",
37+
"href": "https://github.com/pyth-network/pyth-examples/tree/main/lazer",
38+
"newWindow": true
39+
},
40+
"-- Understand Lazer": {
41+
"title": "Understanding Lazer",
42+
"type": "separator"
43+
},
44+
45+
"how-lazer-works": "How Lazer Works"
46+
}

pages/lazer/getting-started.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Getting Started with Pyth Lazer
2+
3+
Please refer to the how-to guides to get started.

pages/lazer/how-lazer-works.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# How Pyth Lazer works
2+
3+
Pyth Lazer is a permissioned service that provides ultra-low-latency price and market data to highly latency-sensitive users.
4+
5+
We are working on writing a detailed technical overview how Lazer works. Details will be added here as they are completed.

pages/lazer/index.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Image from "next/image";
2+
3+
# Pyth Lazer
4+
5+
Pyth Lazer is a low latency, highly customizable price oracle.
6+
It offers a customizable set of price feeds, target chains (EVM or Solana) and channels (real time or fixed rate):
7+
8+
- Real time channels send updates as frequently as they become available;
9+
- Fixed rate channels send updates at fixed time intervals (you can choose between 50 ms or 200 ms).
10+
11+
The table below shows the difference between Pyth Core and Pyth Lazer:
12+
13+
| | **Pyth Core** | **Pyth Lazer** |
14+
| ----------------------- | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
15+
| **Solution Type** | Stable, secure, and decentralized price data source for a broad spectrum of DeFi or TradFi applications. | **Permissioned** service focused on **ultra-low-latency** price and market data for highly latency-sensitive users. |
16+
| **Frequency** | 400ms on Pythnet appchain with support for risk mitigation via Benchmarks and confidence intervals. | **1ms** (**real-time**), 50ms, and 200ms channels, **customizable** frequencies, and throttling support to address different needs. |
17+
| **Data Types** | Aggregate price and confidence intervals. | Aggregate price, bid/ask price, and **customizable** market data (market depth and more). |
18+
| **Fees** | On-chain fee per signed cross-chain price update. | On-chain fee per signed cross-chain price update. |
19+
| **Update Costs** | >1,000-byte proofs and complex signature verification. | **100-byte proofs** and simple signature verification. |
20+
| **Integration Process** | Open and permissionless integration for any Web3 or Web2 protocol. | **Specialized** and **permissioned** solution for protocols prioritizing performance over some elements of decentralization. |

0 commit comments

Comments
 (0)