Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wbtc-usd-spot added #733

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/telliot_feeds/feeds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
from telliot_feeds.feeds.uspce_feed import uspce_feed
from telliot_feeds.feeds.vesq import vsq_usd_median_feed
from telliot_feeds.feeds.wbeth_usd_feed import wbeth_usd_median_feed
from telliot_feeds.feeds.wbtc_usd_feed import wbtc_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
Expand Down Expand Up @@ -174,6 +175,7 @@
"ogv-eth-spot": ogv_eth_median_feed,
"brc20-ordi-usd-spot": ordi_usd_median_feed,
"meth-usd-spot": meth_usd_median_feed,
"wbtc-usd-spot": wbtc_usd_median_feed,
}

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

wbtc_usd_median_feed = DataFeed(
query=SpotPrice(asset="WBTC", currency="USD"),
source=PriceAggregator(
asset="wbtc",
currency="usd",
algorithm="median",
sources=[
CoinGeckoSpotPriceSource(asset="wbtc", currency="usd"),
CoinpaprikaSpotPriceSource(asset="wbtc-wrapped-bitcoin", currency="eth"),
KrakenSpotPriceSource(asset="wbtc", currency="usd"),
UniswapV3PriceSource(asset="wbtc", currency="usd"),
],
),
)
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 @@ -75,6 +75,7 @@
"OGV/ETH",
"ORDI/USD",
"METH/USD",
"WBTC/USD",
]


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 @@ -489,3 +489,9 @@
title="METH/USD spot price",
q=SpotPrice(asset="meth", currency="usd"),
)

query_catalog.add_entry(
tag="wbtc-usd-spot",
title="WBTC/USD spot price",
q=SpotPrice(asset="wbtc", currency="usd"),
)
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 @@ -65,6 +65,7 @@
"ogv": "origin-defi-governance",
"ordi": "ordinals",
"meth": "mantle-staked-ether",
"wbtc": "wrapped-bitcoin",
}


Expand Down
2 changes: 1 addition & 1 deletion src/telliot_feeds/sources/price/spot/kraken.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# Hardcoded supported assets & currencies
# Search for supported assets here: https://api.kraken.com/0/public/Assets
KRAKEN_ASSETS = {"ETH", "MATIC", "MKR", "SUSHI", "USDC", "XBT"}
KRAKEN_ASSETS = {"ETH", "MATIC", "MKR", "SUSHI", "USDC", "XBT", "WBTC"}
KRAKEN_CURRENCIES = {"USD"}


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 @@ -26,6 +26,7 @@
"cbeth": "0xbe9895146f7af43049ca1c1ae358b0541ea49704",
"oeth": "0x856c4efb76c1d1ae02e20ceb03a2a6a08b0b8dc3",
"ogv": "0x9c354503c38481a7a7a51629142963f98ecc12d0",
"wbtc": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
}


Expand Down
22 changes: 22 additions & 0 deletions tests/feeds/test_wbtc_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.wbtc_usd_feed import wbtc_usd_median_feed


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

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

# Get list of data sources from sources dict
source_prices = [source.latest[0] for source in wbtc_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
Loading