Skip to content

Commit

Permalink
Merge pull request #727 from tellor-io/ogv-eth-feed
Browse files Browse the repository at this point in the history
OGV/ETH Spot
  • Loading branch information
0xSpuddy authored Jan 4, 2024
2 parents 84dec04 + 2ffe8ae commit 25e4df2
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/telliot_feeds/feeds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
from telliot_feeds.feeds.numeric_api_response_manual_feed import numeric_api_response_manual_feed
from telliot_feeds.feeds.oeth_eth_feed import oeth_eth_median_feed
from telliot_feeds.feeds.oeth_usd_feed import oeth_usd_median_feed
from telliot_feeds.feeds.ogv_eth_feed import ogv_eth_median_feed
from telliot_feeds.feeds.olympus import ohm_eth_median_feed
from telliot_feeds.feeds.op_usd_feed import op_usd_median_feed
from telliot_feeds.feeds.ousd_usd_feed import ousd_usd_median_feed
Expand Down Expand Up @@ -168,6 +169,7 @@
"wbeth-usd-spot": wbeth_usd_median_feed,
"oeth-usd-spot": oeth_usd_median_feed,
"pyth-usd-spot": pyth_usd_median_feed,
"ogv-eth-spot": ogv_eth_median_feed,
}

DATAFEED_BUILDER_MAPPING: Dict[str, DataFeed[Any]] = {
Expand Down
19 changes: 19 additions & 0 deletions src/telliot_feeds/feeds/ogv_eth_feed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from telliot_feeds.datafeed import DataFeed
from telliot_feeds.queries.price.spot_price import SpotPrice
from telliot_feeds.sources.price.spot.coinpaprika import CoinpaprikaSpotPriceSource
from telliot_feeds.sources.price.spot.uniswapV3 import UniswapV3PriceSource
from telliot_feeds.sources.price_aggregator import PriceAggregator


ogv_eth_median_feed = DataFeed(
query=SpotPrice(asset="ogv", currency="ETH"),
source=PriceAggregator(
asset="ogv",
currency="eth",
algorithm="median",
sources=[
CoinpaprikaSpotPriceSource(asset="ogv-origin-dollar-governance", currency="eth"),
UniswapV3PriceSource(asset="ogv", 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 @@ -72,6 +72,7 @@
"WBETH/USD",
"OETH/USD",
"PYTH/USD",
"OGV/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 @@ -471,3 +471,9 @@
title="PYTH/USD spot price",
q=SpotPrice(asset="pyth", currency="usd"),
)

query_catalog.add_entry(
tag="ogv-eth-spot",
title="OGV/ETH spot price",
q=SpotPrice(asset="ogv", currency="eth"),
)
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 @@ -62,6 +62,7 @@
"cbeth": "coinbase-wrapped-staked-eth",
"wbeth": "wrapped-beacon-eth",
"pyth": "pyth-network",
"ogv": "origin-defi-governance",
}


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 @@ -25,6 +25,7 @@
"sweth": "0xf951e335afb289353dc249e82926178eac7ded78",
"cbeth": "0xbe9895146f7af43049ca1c1ae358b0541ea49704",
"oeth": "0x856c4efb76c1d1ae02e20ceb03a2a6a08b0b8dc3",
"ogv": "0x9c354503c38481a7a7a51629142963f98ecc12d0",
}


Expand Down
22 changes: 22 additions & 0 deletions tests/feeds/test_ogv_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.ogv_eth_feed import ogv_eth_median_feed


@pytest.mark.asyncio
async def test_ogv_eth_median_feed(caplog):
"""Retrieve median ogv/ETH price."""
v, _ = await ogv_eth_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"ogv/eth Price: {v}")

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

Please sign in to comment.