Skip to content

Commit

Permalink
Merge pull request #808 from tellor-io/superoeth
Browse files Browse the repository at this point in the history
Superoeth
  • Loading branch information
0xSpuddy authored Sep 24, 2024
2 parents 4636b4f + 4fc9123 commit 4e4f10c
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/telliot_feeds/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
1918988905,
808813,
534352,
8453,
}

GNOSIS_CHAINS = {100, 10200}
Expand Down
2 changes: 2 additions & 0 deletions src/telliot_feeds/feeds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]] = {
Expand Down
17 changes: 17 additions & 0 deletions src/telliot_feeds/feeds/superoethb_eth_feed.py
Original file line number Diff line number Diff line change
@@ -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"),
],
),
)
1 change: 1 addition & 0 deletions src/telliot_feeds/queries/price/spot_price.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"TARA/USD",
"PUFETH/USD",
"STONE/USD",
"SUPEROETHB/ETH",
]


Expand Down
6 changes: 6 additions & 0 deletions src/telliot_feeds/queries/query_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)
7 changes: 7 additions & 0 deletions src/telliot_feeds/reporters/tips/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/telliot_feeds/sources/price/spot/coingecko.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"tara": "taraxa",
"pufeth": "pufeth",
"stone": "stakestone-ether",
"superoethb": "super-oeth",
}

API_KEY = TelliotConfig().api_keys.find(name="coingecko")[0].key
Expand Down
22 changes: 22 additions & 0 deletions tests/feeds/test_superoethb_eth_feed.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4e4f10c

Please sign in to comment.