From cba6aa36ef9d6e5805fbd7dae4785287b7f12407 Mon Sep 17 00:00:00 2001 From: 0xSpuddy Date: Mon, 23 Sep 2024 12:19:55 -0400 Subject: [PATCH 1/2] configs for Base --- src/telliot_feeds/constants.py | 1 + src/telliot_feeds/reporters/tips/__init__.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/telliot_feeds/constants.py b/src/telliot_feeds/constants.py index 71378a2d..a7dad874 100644 --- a/src/telliot_feeds/constants.py +++ b/src/telliot_feeds/constants.py @@ -29,6 +29,7 @@ 1918988905, 808813, 534352, + 8453, } GNOSIS_CHAINS = {100, 10200} diff --git a/src/telliot_feeds/reporters/tips/__init__.py b/src/telliot_feeds/reporters/tips/__init__.py index 5d85fafe..ed6b0358 100644 --- a/src/telliot_feeds/reporters/tips/__init__.py +++ b/src/telliot_feeds/reporters/tips/__init__.py @@ -288,6 +288,13 @@ def add_multicall_support( multicall3_address="0xcA11bde05977b3631167028862bE2a173976CA11", ) +add_multicall_support( + network="Base", + network_id=8453, + state_override=False, + multicall3_address="0xcA11bde05977b3631167028862bE2a173976CA11", +) + CATALOG_QUERY_IDS = {query_catalog._entries[tag].query.query_id: tag for tag in query_catalog._entries} CATALOG_QUERY_DATA = {query_catalog._entries[tag].query.query_data: tag for tag in query_catalog._entries} # A list of query types that have a generic source that can take any properly formatted inputs and return a price From 4fc9123983c70ab6b6bf1b304518af78a8e75923 Mon Sep 17 00:00:00 2001 From: 0xSpuddy Date: Mon, 23 Sep 2024 15:10:20 -0400 Subject: [PATCH 2/2] superoethb basic feed --- src/telliot_feeds/feeds/__init__.py | 2 ++ .../feeds/superoethb_eth_feed.py | 17 ++++++++++++++ src/telliot_feeds/queries/price/spot_price.py | 1 + src/telliot_feeds/queries/query_catalog.py | 6 +++++ .../sources/price/spot/coingecko.py | 1 + tests/feeds/test_superoethb_eth_feed.py | 22 +++++++++++++++++++ 6 files changed, 49 insertions(+) create mode 100644 src/telliot_feeds/feeds/superoethb_eth_feed.py create mode 100644 tests/feeds/test_superoethb_eth_feed.py 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