Skip to content
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

feat: add script for feed table generator #607

Merged
merged 13 commits into from
Mar 28, 2025
10 changes: 10 additions & 0 deletions automations/custom_feeds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"feed_name": "SFLR/USD",
"feed_id": "0x2173464c522f555344000000000000000000000000",
"base_asset": "Staked Flare",
"provider_name": "Sceptre",
"provider_url": "https://www.sceptre.fi",
"contract": "0xD1002F3820ad32145b868aD889eC7753E3944c8D"
}
]
17 changes: 14 additions & 3 deletions docs/ftso/2-feeds.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import TabItem from "@theme/TabItem";
import Tabs from "@theme/Tabs";
import CodeBlock from "@theme/CodeBlock";
import BlockLatencyFeeds from "@site/src/components/DataTables/BlockLatencyFeeds";
import CustomFeeds from "@site/src/components/DataTables/CustomFeeds";

FTSOv2's block-latency feeds update incrementally with each new block on Flare, approximately every 1.8 seconds. Every feed leverages Flare's network of 100 independent data providers. These feeds primarily support cryptocurrency price data and are free to query on Flare, enabling decentralized applications to access up-to-date information without incurring additional costs.

Each block-latency feed is uniquely identified by an ID composed of three components in a structured encoding process:

1. **Category:** Indicates the type of asset - Crypto: `01`, Forex: `02`, Commodity: `03`, Stock: `04`
1. **Category:** Indicates the type of asset - Crypto: `01`, Forex: `02`, Commodity: `03`, Stock: `04`, Custom Feeds: `05`

2. **Hex-Encoded Feed Name:** The name of the feed is converted to a hexadecimal format.

Expand All @@ -31,13 +32,23 @@ The resulting string is then prefixed with `0x`.

- Feed IDs are **not** addresses. They are `bytes21` structured encodings that combine the category and feed name to ensure each feed has a unique identifier.
- **Do not** hardcode the number of decimals for a feed in your smart contract, as these can change as the feed value changes. You can use either of the following solutions:
- Check the number of decimal places every query ([`getFeedById`](/ftso/solidity-reference/FtsoV2Interface#getfeedbyid)).
- Use the feed value in Wei ([`getFeedByIdInWei`](/ftso/solidity-reference/FtsoV2Interface#getfeedbyidinwei)).
- Check the number of decimal places every query using [`getFeedById`](/ftso/solidity-reference/FtsoV2Interface#getfeedbyid).
- Use the feed value in Wei using [`getFeedByIdInWei`](/ftso/solidity-reference/FtsoV2Interface#getfeedbyidinwei).

:::

<BlockLatencyFeeds />

## Custom Feeds

:::warning

Custom Feeds, introduced in [FIP.13](https://proposals.flare.network/FIP/FIP_13.html), have a distinct risk profile compared to standard FTSO feeds. Unlike standard FTSO feeds, the security of a Custom Feed is conditional on the logic defined in its smart contract.

:::

<CustomFeeds />

## Need more feeds?

FTSOv2 can scale up to 1000 feeds. If you need additional FTSOv2 feeds beyond what is currently available, you can raise a New Feed Request Issue on GitHub. When a feed request is submitted, it is reviewed by the FTSO Management Group, which is comprised of the FTSO data providers as outlined in [FIP.08](https://proposals.flare.network/FIP/FIP_8.html#222-through-the-ftso-management-group).
Expand Down
59 changes: 59 additions & 0 deletions src/components/DataTables/CustomFeeds.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from "react";
import "tippy.js/dist/tippy.css";
import Link from "@docusaurus/Link";
import CopyButton from "../CopyButton";
import tableData from "../../../automations/custom_feeds.json";

const CustomFeeds = () => {
return (
<table className="data-table">
<thead>
<tr className="table-header">
<th>Name</th>
<th>Feed ID</th>
<th>Details</th>
</tr>
</thead>
<tbody>
{tableData.map((row, index) => {
return (
<tr key={index} className="table-row">
<td className="regular-font">{row.feed_name}</td>
<td className="feed-id mono-font">
<div className="feed-id-container">
<span className="feed-id-text">{row.feed_id}</span>
<CopyButton textToCopy={row.feed_id} />
</div>
</td>
<td className="regular-font">
Base Asset: {row.base_asset} (
<Link
to={row.provider_url}
target="_blank"
rel="noopener noreferrer"
>
{`${row.provider_name}`}
</Link>
) <br />
{row.contract && (
<>
Contract:{" "}
<Link
to={`https://flarescan.com/address/${row.contract}`}
target="_blank"
rel="noopener noreferrer"
>
{`${row.contract}`}
</Link>
</>
)}
</td>
</tr>
);
})}
</tbody>
</table>
);
};

export default CustomFeeds;
Loading