Skip to content

Commit

Permalink
Merge pull request #698 from tellor-io/new-feeds-wld-sweth
Browse files Browse the repository at this point in the history
WLD/USD & SWETH/USD Spot Price feeds & Removed Dead Testnet From Tests
  • Loading branch information
akremstudy authored Jul 26, 2023
2 parents cd44b79 + d33e5d2 commit 4246941
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/telliot_feeds/feeds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
from telliot_feeds.feeds.steth_usd_feed import steth_usd_median_feed
from telliot_feeds.feeds.string_query_feed import string_query_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.tellor_rng_feed import tellor_rng_feed
from telliot_feeds.feeds.tellor_rng_manual_feed import tellor_rng_manual_feed
from telliot_feeds.feeds.trb_usd_feed import trb_usd_median_feed
Expand All @@ -79,6 +80,7 @@
from telliot_feeds.feeds.usdt_usd_feed import usdt_usd_median_feed
from telliot_feeds.feeds.uspce_feed import uspce_feed
from telliot_feeds.feeds.vesq import vsq_usd_median_feed
from telliot_feeds.feeds.wld_usd_feed import wld_usd_median_feed
from telliot_feeds.feeds.wsteth_feed import wsteth_eth_median_feed
from telliot_feeds.feeds.wsteth_feed import wsteth_usd_median_feed
from telliot_feeds.feeds.xdai_usd_feed import xdai_usd_median_feed
Expand Down Expand Up @@ -154,6 +156,8 @@
"soy-usd-custom": soy,
"ousd-usd-spot": ousd_usd_median_feed,
"oeth-eth-spot": oeth_eth_median_feed,
"wld-usd-spot": wld_usd_median_feed,
"sweth-usd-spot": sweth_usd_median_feed,
}

DATAFEED_BUILDER_MAPPING: Dict[str, DataFeed[Any]] = {
Expand Down
18 changes: 18 additions & 0 deletions src/telliot_feeds/feeds/sweth_usd_feed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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.spot.uniswapV3 import UniswapV3PriceSource
from telliot_feeds.sources.price_aggregator import PriceAggregator

sweth_usd_median_feed = DataFeed(
query=SpotPrice(asset="SWETH", currency="USD"),
source=PriceAggregator(
asset="sweth",
currency="usd",
algorithm="median",
sources=[
CoinGeckoSpotPriceSource(asset="sweth", currency="usd"),
UniswapV3PriceSource(asset="sweth", currency="usd"),
],
),
)
14 changes: 14 additions & 0 deletions src/telliot_feeds/feeds/wld_usd_feed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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

wld_usd_median_feed = DataFeed(
query=SpotPrice(asset="WLD", currency="USD"),
source=PriceAggregator(
asset="wld",
currency="usd",
algorithm="median",
sources=[CoinGeckoSpotPriceSource(asset="wld", currency="usd")],
),
)
2 changes: 2 additions & 0 deletions src/telliot_feeds/queries/price/spot_price.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"YFI/USD",
"STETH/BTC",
"STETH/USD",
"SWETH/USD",
"RETH/BTC",
"RETH/USD",
"WSTETH/USD",
Expand All @@ -65,6 +66,7 @@
"BRL/USD",
"OUSD/USD",
"OETH/ETH",
"WLD/USD",
]


Expand Down
12 changes: 12 additions & 0 deletions src/telliot_feeds/queries/query_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,3 +429,15 @@
title="OETH/ETH spot price",
q=SpotPrice(asset="oeth", currency="eth"),
)

query_catalog.add_entry(
tag="wld-usd-spot",
title="WLD/USD spot price",
q=SpotPrice(asset="wld", currency="usd"),
)

query_catalog.add_entry(
tag="sweth-usd-spot",
title="SWETH/USD spot price",
q=SpotPrice(asset="sweth", currency="usd"),
)
2 changes: 2 additions & 0 deletions src/telliot_feeds/sources/price/spot/coingecko.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
"pls": "pulsechain",
"oeth": "origin-ether",
"ousd": "origin-dollar",
"sweth": "sweth",
"wld": "worldcoin",
}


Expand Down
1 change: 1 addition & 0 deletions src/telliot_feeds/sources/price/spot/uniswapV3.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"reth": "0xae78736cd615f374d3085123a210448e74fc6393",
"pls": "0xa882606494d86804b5514e07e6bd2d6a6ee6d68a",
"ousd": "0x2a8e1e676ec238d8a992307b495b45b3feaa5e86",
"sweth": "0xf951e335afb289353dc249e82926178eac7ded78",
}


Expand Down
10 changes: 0 additions & 10 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,6 @@ def mumbai_test_cfg():
return local_node_cfg(chain_id=80001)


@pytest.fixture(scope="function", autouse=True)
def rinkeby_test_cfg():
return local_node_cfg(chain_id=4)


@pytest.fixture(scope="function", autouse=True)
def ropsten_test_cfg():
return local_node_cfg(chain_id=3)


@pytest.fixture(scope="function", autouse=True)
def goerli_test_cfg():
return local_node_cfg(chain_id=5)
Expand Down
22 changes: 22 additions & 0 deletions tests/feeds/test_sweth_usd_feed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import statistics

import pytest

from telliot_feeds.feeds.sweth_usd_feed import sweth_usd_median_feed


@pytest.mark.asyncio
async def test_sweth_usd_median_feed(caplog):
"""Retrieve median SWETH/USD price."""
v, _ = await sweth_usd_median_feed.source.fetch_new_datapoint()

assert v is not None
assert v > 0
assert "sources used in aggregate: 2" in caplog.text.lower()
print(f"SWETH/USD Price: {v}")

# Get list of data sources from sources dict
source_prices = [source.latest[0] for source in sweth_usd_median_feed.source.sources if source.latest[0]]

# Make sure error is less than decimal tolerance
assert (v - statistics.median(source_prices)) < 10**-6
21 changes: 21 additions & 0 deletions tests/feeds/test_wld_usd_feed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import statistics

import pytest

from telliot_feeds.feeds.wld_usd_feed import wld_usd_median_feed


@pytest.mark.asyncio
async def test_wld_asset_price_feed():
"""Retrieve median WLD/USD price."""
v, _ = await wld_usd_median_feed.source.fetch_new_datapoint()

assert v is not None
assert v > 0
print(f"WLD/USD Price: {v}")

# Get list of data sources from sources dict
source_prices = [source.latest[0] for source in wld_usd_median_feed.source.sources]

# Make sure error is less than decimal tolerance
assert (v - statistics.median(source_prices)) < 10**-6

0 comments on commit 4246941

Please sign in to comment.