Add support for a new spot price
This page outlines the steps to add support for reporting a new spot price to your Telliot reporter.
Last updated
This page outlines the steps to add support for reporting a new spot price to your Telliot reporter.
Last updated
When creating a new feed, it is highly incentivised to share it with the community via the Fetch open source . This ensures all the reporters are aligned on new feeds requirements so that the safety of the network can be validated by DVMs and the whole community of reporters.
Each reporter is responsible for the data they're submitting.
Make sure to check FIRST which feed you are reporting and what sources they are using! (Submitting data to Testnet first is a great way to test your new feed without risking real money)
Submitting data that is deemed incorrect may be challenged by anyone in the community and you risk losing at least 1 stake per report disputed!
It's highly beneficial and recommended to check within the community of reporters which feeds and sources are being accepted as truth and what are the thresholds of tolerance for monitoring data submitted.
You can get more info on all the above at the official telegram group:
Python >= 3.9, < 3.10
Setup environment (see )
Add spot price to catalog. See src/telliot_feeds/queries/query_catalog.py
. For example let's add a query called btctest-usd-spot
for testing, adding BTCTEST/USD
:
Add data feed in src/telliot_feeds/feeds/
. For example, for adding BTCTEST/USD
, create file src/telliot_feeds/feeds/btctest_usd_feed.py
:
In the above example, we use the PriceAggregator
to aggregate the price from multiple sources (automatic API fetches, not sources that require manual entry). The algorithm
can be median
or mean
. The sources
can be any combination of those found in src/telliot_feeds/sources/price/spot/
directory or you can add your own, of course.
You're limited by what asset and currency pairs are supported by the underlying APIs (data providers). For example, if you want to add BTC/JPY
, you might use the CoinGeckoSpotPriceSource
and BinanceSpotPriceSource
(which support BTC/JPY
), but not the CoinbaseSpotPriceSource
(which does not support BTC/JPY
).
You will need to check the documentation of the underlying APIs for which pairs they support or how to parse their values correctly.
3. Add feed to CATALOG_FEEDS
constant in src/telliot_feeds/feeds/__init__.py
:
Add currency/asset to supported lists in src/telliot_feeds/queries/price/spot_price.py
. For example, for adding BTCTEST/USD
:
Test your new feed in tests/feeds/
. For example, once you've created a data feed for an BTCTEST/USD
spot price using an aggregate of a few price sources, create file tests/feeds/test_btctest_usd_feed.py
:
It's recommend to alway share with the community the sources you're using.
This provides alignment on what the current sources are being used as truth for monitoring.
There's a V1 and V2 versions for pulseX source in /source/spot/price.
Make sure to use the one where your token address, for the feed you're creating, is available.
to import from pulsex_subgraph
or pulsex_subgraph_v2
sources, just use:
Adding pulseX v1 as a source example:
import the function:
in the feed file, like this:
In the example, we're using Coingecko, Binance and PulseX to get the price for BTC now.
After that, search the token address in pulseX v1 website (to confirm it is available) and add support for it in Telliot inside this file:
~telliot-feeds/src/telliot_feeds/sources/price/spot/pulsex_subgraph.py
like this:
If you want to create a Testnet token feed (using the testnet RPC) set the token key to start with t*
when fetching the source. This will tell the program to use Testnet RPC to fetch the price.
If the token is for Mainnet, just set it under #mainnet tokens
. The program will use the Mainnet RPC for the token keys not starting with t*
.
Now, if we report with btctest-usd-spot
it should use the sources we created, including pulseX v1 for this example.
To use pulseX v2, follow the same process but pay attention to the name of the sources.
It's recommend to alway share with the community the sources you're using.
This provides alignment on what the current sources are being used as truth for monitoring.
We can use the Dex Screener API source to fetch prices from specific pools the API supports.
Check the current supported pools and chains inside the telliot_feeds/sources/price/spot/dexscreener_api.py
file.
If the pool or chain you want is not listed, add it, following the same pattern as the current ones.
Double check pool addresses match the asset you desire.
Add the source to the feed you're creating or editing in the file:
Add the chain, pool, asset and currency. For example, for PulseChain mainnet, in 9inch exchange, FETCH/USDL pool.
The API gets the price in USD from the pool.
Test your feed in Testnet to make sure it works as expected.
It's recommend to alway share with the community the sources you're using.
This provides alignment on what the current sources are being used as truth for monitoring.
This source works only with V3 pools (forks of PancakeSwap, like 9inch). Using stable coin pools we can get an asset USD price, like FETCH/USDL, for example.
Here's how to copy the file and use it with a different pool
Copy and rename the file in telliot_feeds/sources/price/spot/nineinch_v3_rpc.py
Edit the pool in this line (fetch/usd in example), which will be the pool to fetch the assets for:
Add support for the source in your feed:
Try to submit a test report to check on data in Testnet.
This is important because you need to confirm the order of the assets. By default the source tries to match the 'asset' and 'currency' order you set in the Feed file.
So, even if the pool has the order inverted, like, usdl/fetch, setting asset as 'fetch' and currency as 'usdl' will put the assets in order and then calculate their respective values.
Since the pool is paired with a stable coin, the fetched price can be used as a FETCH/USD price. Note this price is a straight balance price from the pool token amounts. It is representative for that pool balance amounts only.
The names for 'asset' and 'currency' must match the names in the pool. So, although you're reporting to FETCH/USD query (again, because it's a stable usd pool) the assets in the pool are FETCH and USDL and they match in feed's file 'asset' and 'currency' fields.
It's recommend to alway share with the community the sources you're using.
This provides alignment on what the current sources are being used as truth for monitoring.
Create a pull request to merge your changes into the main
branch .
Submitting the feed or edits first to Fetch's is also recommended. This way everyone can update accordingly and keep the network safe and you won't risk being disputed when submitting new or edited data to Mainnet.
Submitting the feed or edits first to Fetch's is also recommended. This way everyone can update accordingly and keep the network safe and you won't risk being disputed when submitting new or edited data to Mainnet.
Check the basic to add a new feed.
Submitting the feed or edits first to Fetch's is also recommended. This way everyone can update accordingly and keep the network safe and you won't risk being disputed when submitting new or edited data to Mainnet.
Check the basic to add a new feed.
Currently the source works for FETCH/USDL pool, but you want to use it, copy the file and change the name of the source to match your requirement. You can also upgrade the file to accept multiple pools and submit it for further review to be included in the repo.
Submitting the feed or edits first to Fetch's is also recommended. This way everyone can update accordingly and keep the network safe and you won't risk being disputed when submitting new or edited data to Mainnet.