diff --git a/src/telliot_feeds/feeds/__init__.py b/src/telliot_feeds/feeds/__init__.py index 60da0d86..32675727 100644 --- a/src/telliot_feeds/feeds/__init__.py +++ b/src/telliot_feeds/feeds/__init__.py @@ -97,6 +97,7 @@ from telliot_feeds.feeds.steth_usd_feed import steth_usd_median_feed from telliot_feeds.feeds.stone_usd_feed import stone_usd_median_feed from telliot_feeds.feeds.string_query_feed import string_query_feed +from telliot_feeds.feeds.superoethb_eth_feed import superoethb_eth_median_feed from telliot_feeds.feeds.sushi_usd_feed import sushi_usd_median_feed from telliot_feeds.feeds.sweth_usd_feed import sweth_usd_median_feed from telliot_feeds.feeds.tara_usd_feed import tara_usd_median_feed @@ -230,6 +231,7 @@ "tara-usd-spot": tara_usd_median_feed, "pufeth-usd-spot": pufeth_usd_median_feed, "stone-usd-spot": stone_usd_median_feed, + "superoethb-eth-spot": superoethb_eth_median_feed, } DATAFEED_BUILDER_MAPPING: Dict[str, DataFeed[Any]] = { diff --git a/src/telliot_feeds/feeds/superoethb_eth_feed.py b/src/telliot_feeds/feeds/superoethb_eth_feed.py new file mode 100644 index 00000000..fdfab4d4 --- /dev/null +++ b/src/telliot_feeds/feeds/superoethb_eth_feed.py @@ -0,0 +1,17 @@ +from telliot_feeds.datafeed import DataFeed +from telliot_feeds.queries.price.spot_price import SpotPrice +from telliot_feeds.sources.price.spot.coingecko import CoinGeckoSpotPriceSource +from telliot_feeds.sources.price_aggregator import PriceAggregator + + +superoethb_eth_median_feed = DataFeed( + query=SpotPrice(asset="SUPEROETHB", currency="ETH"), + source=PriceAggregator( + asset="superoethb", + currency="eth", + algorithm="median", + sources=[ + CoinGeckoSpotPriceSource(asset="superoethb", currency="eth"), + ], + ), +) diff --git a/src/telliot_feeds/queries/price/spot_price.py b/src/telliot_feeds/queries/price/spot_price.py index 3a243927..4a19065a 100644 --- a/src/telliot_feeds/queries/price/spot_price.py +++ b/src/telliot_feeds/queries/price/spot_price.py @@ -99,6 +99,7 @@ "TARA/USD", "PUFETH/USD", "STONE/USD", + "SUPEROETHB/ETH", ] diff --git a/src/telliot_feeds/queries/query_catalog.py b/src/telliot_feeds/queries/query_catalog.py index 5e471c9f..9928b200 100644 --- a/src/telliot_feeds/queries/query_catalog.py +++ b/src/telliot_feeds/queries/query_catalog.py @@ -656,3 +656,9 @@ title="STONE/USD spot price", q=SpotPrice(asset="stone", currency="usd"), ) + +query_catalog.add_entry( + tag="superoethb-eth-spot", + title="superOETHb/ETH spot price", + q=SpotPrice(asset="superoethb", currency="eth"), +) diff --git a/src/telliot_feeds/sources/price/spot/coingecko.py b/src/telliot_feeds/sources/price/spot/coingecko.py index c0c3b0b6..bc316670 100644 --- a/src/telliot_feeds/sources/price/spot/coingecko.py +++ b/src/telliot_feeds/sources/price/spot/coingecko.py @@ -91,6 +91,7 @@ "tara": "taraxa", "pufeth": "pufeth", "stone": "stakestone-ether", + "superoethb": "super-oeth", } API_KEY = TelliotConfig().api_keys.find(name="coingecko")[0].key diff --git a/tests/feeds/test_superoethb_eth_feed.py b/tests/feeds/test_superoethb_eth_feed.py new file mode 100644 index 00000000..a56662d4 --- /dev/null +++ b/tests/feeds/test_superoethb_eth_feed.py @@ -0,0 +1,22 @@ +import statistics + +import pytest + +from telliot_feeds.feeds.superoethb_eth_feed import superoethb_eth_median_feed + + +@pytest.mark.asyncio +async def test_superoethb_eth_median_feed(caplog): + """Retrieve median superOETHb/ETH price.""" + v, _ = await superoethb_eth_median_feed.source.fetch_new_datapoint() + + assert v is not None + assert v > 0 + assert "sources used in aggregate: 1" in caplog.text.lower() + print(f"superOETHb/eth Price: {v}") + + # Get list of data sources from sources dict + source_prices = [source.latest[0] for source in superoethb_eth_median_feed.source.sources if source.latest[0]] + + # Make sure error is less than decimal tolerance + assert (v - statistics.median(source_prices)) < 10**-6