Skip to content

Chore(lazer) add lazer docs #554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions components/LazerPriceIdTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { useEffect, useState } from "react";
import { StyledTd } from "./Table";

const fetchLazerPriceIdMetadata = async () => {
const response = await fetch(
"https://pyth-lazer-staging.dourolabs.app/history/v1/symbols"
);
const data = await response.json();
return data;
};

type LazerPriceIdMetadata = {
asset_type: string;
description: string;
exponent: number;
name: string;
pyth_lazer_id: number;
symbol: string;
};

enum LazerPriceIdStateType {
NotLoaded,
Loading,
Loaded,
Error,
}

const LazerPriceIdState = {
NotLoaded: () => ({ type: LazerPriceIdStateType.NotLoaded as const }),
Loading: () => ({ type: LazerPriceIdStateType.Loading as const }),
Loaded: (priceFeeds: LazerPriceIdMetadata[]) => ({
type: LazerPriceIdStateType.Loaded as const,
priceFeeds,
}),
Error: (error: unknown) => ({
type: LazerPriceIdStateType.Error as const,
error,
}),
};

type LazerPriceIdState = ReturnType<
typeof LazerPriceIdState[keyof typeof LazerPriceIdState]
>;

const useLazerPriceIdState = () => {
const [state, setState] = useState<LazerPriceIdState>(
LazerPriceIdState.NotLoaded()
);

useEffect(() => {
setState(LazerPriceIdState.Loading());
fetchLazerPriceIdMetadata()
.then((priceFeeds) => setState(LazerPriceIdState.Loaded(priceFeeds)))
.catch((error) => setState(LazerPriceIdState.Error(error)));
}, []);

return state;
};

export function LazerPriceIdTable() {
const lazerPriceIdState = useLazerPriceIdState();

switch (lazerPriceIdState.type) {
case LazerPriceIdStateType.NotLoaded:
return <div>Loading...</div>;
case LazerPriceIdStateType.Loading:
return <div>Loading...</div>;
case LazerPriceIdStateType.Loaded:
return (
<table>
<thead>
<tr>
<th>Asset Type</th>
<th>Description</th>
<th>Name</th>
<th>Symbol</th>
<th>Pyth Lazer Id</th>
<th>Exponent</th>
</tr>
</thead>
<tbody>
{lazerPriceIdState.priceFeeds.map((priceFeed) => (
<tr key={priceFeed.symbol}>
<StyledTd>{priceFeed.asset_type}</StyledTd>
<StyledTd>{priceFeed.description}</StyledTd>
<StyledTd>{priceFeed.name}</StyledTd>
<StyledTd>{priceFeed.symbol}</StyledTd>
<StyledTd>{priceFeed.pyth_lazer_id}</StyledTd>
<StyledTd>{priceFeed.exponent}</StyledTd>
</tr>
))}
</tbody>
</table>
);
case LazerPriceIdStateType.Error:
return <div>Error</div>;
}
}
5 changes: 5 additions & 0 deletions pages/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"type": "page"
},

"lazer": {
"title": "Lazer",
"type": "page"
},

"benchmarks": {
"title": "Benchmarks",
"type": "page"
Expand Down
5 changes: 5 additions & 0 deletions pages/home/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
"href": "/price-feeds"
},

"Lazer": {
"title": "Lazer →",
"href": "/lazer"
},

"Benchmarks": {
"title": "Benchmarks →",
"href": "/benchmarks"
Expand Down
1 change: 1 addition & 0 deletions pages/home/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Pyth Network offers several products for developers:

- [Price Feeds](../price-feeds) provide real-time prices for 500+ assets on 55+ blockchain ecosystems, including Solana, many EVM chains,
Aptos, Sui, NEAR, and several Cosmos chains.
- [Lazer](../lazer) [TODO]
- [Benchmarks](../benchmarks) provides historical Pyth prices for both on- and off-chain use.
- [Express Relay](../express-relay/) enables protocols to eliminate their MEV while gaining access to active searchers and liquidators.
- [Entropy](../entropy) allows developers to generate secure random numbers on the blockchain.
Expand Down
49 changes: 49 additions & 0 deletions pages/lazer/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"documentation-home": {
"title": "← Documentation Home",
"href": "/home"
},

"-- Lazer": {
"title": "Lazer",
"type": "separator"
},
"index": "Introduction",
"getting-started": "Getting Started",

"-- How-to Guides": {
"title": "How-To Guides",
"type": "separator"
},

"integrate-as-consumer": "Integrate as a Consumer",
"integrate-as-publisher": "Integrate as a Publisher",

"-- Reference Material": {
"title": "Reference Material",
"type": "separator"
},
"price-feeds": "Price Feeds",

"api-reference": {
"title": "HTTP API Reference ↗",
"href": "TODO:",
"newWindow": true
},

"websocket-api-reference": "Websocket API Reference",
"contract-addresses": "Contract Addresses",

"errors": "Error Codes",
"examples": {
"title": "Example Application ↗",
"href": "https://github.com/pyth-network/pyth-examples/tree/main/lazer",
"newWindow": true
},
"-- Understand Lazer": {
"title": "Understanding Lazer",
"type": "separator"
},

"how-lazer-works": "How Lazer Works"
}
3 changes: 3 additions & 0 deletions pages/lazer/getting-started.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Getting Started with Pyth Lazer

TODO: Fill this up.
5 changes: 5 additions & 0 deletions pages/lazer/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Lazer

TODO: Fill this up.

TODO: Add a banner up to get a access token.
3 changes: 3 additions & 0 deletions pages/lazer/integrate-as-consumer.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# How to Integrate Pyth Lazer as a Consumer

TODO: Fill this up.
4 changes: 4 additions & 0 deletions pages/lazer/integrate-as-consumer/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"evm": "EVM chains",
"svm": "SVM chains"
}
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions pages/lazer/integrate-as-publisher.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# How to Integrate Pyth Lazer as a Publisher

TODO: Fill this up.
5 changes: 5 additions & 0 deletions pages/lazer/price-feeds.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { LazerPriceIdTable } from "../../components/LazerPriceIdTable";

# Lazer Price Feeds

<LazerPriceIdTable />
Loading