-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #698 from tellor-io/new-feeds-wld-sweth
WLD/USD & SWETH/USD Spot Price feeds & Removed Dead Testnet From Tests
- Loading branch information
Showing
10 changed files
with
96 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"), | ||
], | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")], | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |