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

Mode chains feeds #782

Merged
merged 14 commits into from
Jun 14, 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
16 changes: 16 additions & 0 deletions examples/fileCID_query_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""Text Query Example """
from telliot_feeds.queries.fileCID import FileCIDQuery

q = FileCIDQuery(url="https://gateway.lighthouse.storage/ipfs/QmNVoZntCBiHq1PEqd1J31Ywy4crjVAVYFbMWMGUN2L3Lg")
print(q.descriptor)
print(f"tipQuery data: 0x{q.query_data.hex()}")
print(f"tipQuery ID: 0x{q.query_id.hex()}")

value = "QmNVoZntCBiHq1PEqd1J31Ywy4crjVAVYFbMWMGUN2L3Lg"
print(f"submitValue (str): {value}")

encoded_bytes = q.value_type.encode(value)
print(f"submitValue (bytes): 0x{encoded_bytes.hex()}")

decoded_value = q.value_type.decode(encoded_bytes)
print(f"Decoded value (float): {decoded_value}")
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ install_requires =
idna==3.4
ipfshttpclient==0.8.0a2
jsonschema==3.2.0
lru-dict==1.1.8
lru-dict==1.3.0
multiaddr==0.0.9
multicall==0.7.0
multidict==6.0.2
Expand Down
1 change: 1 addition & 0 deletions src/telliot_feeds/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
84532,
111,
60808,
919,
}

GNOSIS_CHAINS = {100, 10200}
Expand Down
10 changes: 10 additions & 0 deletions src/telliot_feeds/feeds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from telliot_feeds.feeds.evm_balance_current import evm_balance_current_feed_example
from telliot_feeds.feeds.evm_call_feed import evm_call_feed
from telliot_feeds.feeds.evm_call_feed import evm_call_feed_example
from telliot_feeds.feeds.ezeth_usd_feed import ezeth_usd_median_feed
from telliot_feeds.feeds.fil_usd_feed import fil_usd_median_feed
from telliot_feeds.feeds.fileCID_manual_feed import fileCID_manual_feed
from telliot_feeds.feeds.frax_usd_feed import frax_usd_median_feed
Expand Down Expand Up @@ -68,6 +69,7 @@
from telliot_feeds.feeds.mimicry.nft_index_feed import mimicry_nft_market_index_usd_feed
from telliot_feeds.feeds.mkr_usd_feed import mkr_usd_median_feed
from telliot_feeds.feeds.mnt_usd_feed import mnt_usd_median_feed
from telliot_feeds.feeds.mode_usd_feed import mode_usd_median_feed
from telliot_feeds.feeds.numeric_api_response_feed import numeric_api_response_feed
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
Expand All @@ -83,6 +85,7 @@
from telliot_feeds.feeds.reth_btc_feed import reth_btc_median_feed
from telliot_feeds.feeds.reth_usd_feed import reth_usd_median_feed
from telliot_feeds.feeds.ric_usd_feed import ric_usd_median_feed
from telliot_feeds.feeds.rseth_usd_feed import rseth_usd_median_feed
from telliot_feeds.feeds.sdai_usd_feed import sdai_usd_median_feed
from telliot_feeds.feeds.sfrax_usd_feed import sfrax_usd_feed
from telliot_feeds.feeds.shib_usd_feed import shib_usd_median_feed
Expand All @@ -108,8 +111,10 @@
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.weeth_usd_feed import weeth_usd_median_feed
from telliot_feeds.feeds.wld_usd_feed import wld_usd_median_feed
from telliot_feeds.feeds.wmnt_usd_feed import wmnt_usd_median_feed
from telliot_feeds.feeds.wrseth_usd_feed import wrseth_usd_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.wusdm_usd_feed import wusdm_usd_feed
Expand Down Expand Up @@ -212,6 +217,11 @@
"gyd-usd-spot": gyd_usd_median_feed,
"leth-usd-spot": leth_usd_feed,
"frxeth-usd-spot": frxeth_usd_median_feed,
"ezeth-usd-spot": ezeth_usd_median_feed,
"weeth-usd-spot": weeth_usd_median_feed,
"wrseth-usd-spot": wrseth_usd_feed,
"mode-usd-spot": mode_usd_median_feed,
"rseth-usd-spot": rseth_usd_median_feed,
}

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


ezeth_usd_median_feed = DataFeed(
query=SpotPrice(asset="EZETH", currency="USD"),
source=PriceAggregator(
asset="ezeth",
currency="usd",
algorithm="median",
sources=[
CoinGeckoSpotPriceSource(asset="ezeth", currency="usd"),
CurveFiUSDPriceSource(asset="ezeth", currency="usd"),
CoinpaprikaSpotPriceSource(asset="ezeth-renzo-restaked-eth", currency="usd"),
UniswapV3PriceSource(asset="ezeth", currency="usd"),
],
),
)
4 changes: 2 additions & 2 deletions src/telliot_feeds/feeds/fileCID_manual_feed.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from telliot_feeds.datafeed import DataFeed
from telliot_feeds.queries.fileCID import FileCID
from telliot_feeds.queries.fileCID import FileCIDQuery
from telliot_feeds.sources.manual.fileCID_manual_source import fileCIDManualSource

url = None

fileCID_manual_feed = DataFeed(query=FileCID(url=url), source=fileCIDManualSource())
fileCID_manual_feed = DataFeed(query=FileCIDQuery(url=url), source=fileCIDManualSource())
4 changes: 2 additions & 2 deletions src/telliot_feeds/feeds/manual_feed.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from telliot_feeds.datafeed import DataFeed
from telliot_feeds.queries.fileCID import FileCID
from telliot_feeds.queries.fileCID import FileCIDQuery
from telliot_feeds.sources.manual.fileCID_manual_source import fileCIDManualSource

url = None

fileCID_manual_feed = DataFeed(query=FileCID(url=url), source=fileCIDManualSource())
fileCID_manual_feed = DataFeed(query=FileCIDQuery(url=url), source=fileCIDManualSource())
20 changes: 20 additions & 0 deletions src/telliot_feeds/feeds/mode_usd_feed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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.kimexchange import kimexchangePriceSource
from telliot_feeds.sources.price_aggregator import PriceAggregator

mode_usd_median_feed = DataFeed(
query=SpotPrice(asset="MODE", currency="USD"),
source=PriceAggregator(
asset="mode",
currency="usd",
algorithm="median",
sources=[
CoinGeckoSpotPriceSource(asset="mode", currency="usd"),
CoinpaprikaSpotPriceSource(asset="mode-mode", currency="usd"),
kimexchangePriceSource(asset="mode", currency="usd"),
],
),
)
23 changes: 23 additions & 0 deletions src/telliot_feeds/feeds/rseth_usd_feed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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.curvefiprice import CurveFiUSDPriceSource
from telliot_feeds.sources.price.spot.uniswapV3 import UniswapV3PriceSource
from telliot_feeds.sources.price_aggregator import PriceAggregator


rseth_usd_median_feed = DataFeed(
query=SpotPrice(asset="rsETH", currency="USD"),
source=PriceAggregator(
asset="rseth",
currency="usd",
algorithm="median",
sources=[
CoinGeckoSpotPriceSource(asset="rseth", currency="usd"),
CurveFiUSDPriceSource(asset="rseth", currency="usd"),
CoinpaprikaSpotPriceSource(asset="rseth-rseth", currency="usd"),
UniswapV3PriceSource(asset="rseth", currency="usd"),
],
),
)
23 changes: 23 additions & 0 deletions src/telliot_feeds/feeds/weeth_usd_feed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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.curvefiprice import CurveFiUSDPriceSource
from telliot_feeds.sources.price.spot.uniswapV3 import UniswapV3PriceSource
from telliot_feeds.sources.price_aggregator import PriceAggregator


weeth_usd_median_feed = DataFeed(
query=SpotPrice(asset="WEETH", currency="USD"),
source=PriceAggregator(
asset="weeth",
currency="usd",
algorithm="median",
sources=[
CoinGeckoSpotPriceSource(asset="weeth", currency="usd"),
CurveFiUSDPriceSource(asset="weeth", currency="usd"),
CoinpaprikaSpotPriceSource(asset="weeth-wrapped-eeth", currency="usd"),
UniswapV3PriceSource(asset="weeth", currency="usd"),
],
),
)
8 changes: 8 additions & 0 deletions src/telliot_feeds/feeds/wrseth_usd_feed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from telliot_feeds.datafeed import DataFeed
from telliot_feeds.queries.price.spot_price import SpotPrice
from telliot_feeds.sources.wrseth_source import wrsETHSpotPriceSource


wrseth_usd_feed = DataFeed(
query=SpotPrice(asset="WRSETH", currency="USD"), source=wrsETHSpotPriceSource(asset="wrseth", currency="usd")
)
25 changes: 19 additions & 6 deletions src/telliot_feeds/queries/fileCID.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
""" :mod:`telliot_feeds.queries.string_query`

"""
# Copyright (c) 2021-, Tellor Development Community
# Distributed under the terms of the MIT License.
from dataclasses import dataclass
from typing import Any
from typing import Optional

from eth_abi import decode
from eth_abi import encode

from telliot_feeds.dtypes.value_type import ValueType
from telliot_feeds.queries.abi_query import AbiQuery


class CIDValueType(ValueType):
"""A ValueType for CID Values."""

def encode(self, value: str) -> Any:
"""Encode a string value."""
return encode([self.abi_type], [value]) # type: ignore

def decode(self, bytes_val: bytes) -> Any:
"""Decode bytes into a string value."""
return decode([self.abi_type], bytes_val) # type: ignore


@dataclass
class FileCID(AbiQuery):
class FileCIDQuery(AbiQuery):
"""
A query type for IPFS content identifier CIDs
More info: add link to dataspec
Expand All @@ -27,6 +40,6 @@ def __init__(self, url: Optional[str]):
abi = [{"name": "url", "type": "string"}]

@property
def value_type(self) -> ValueType:
def value_type(self) -> CIDValueType:
"""Returns a datatype for ipfs CIDs."""
return ValueType(abi_type="string", packed=False)
return CIDValueType(abi_type="string", packed=False)
5 changes: 5 additions & 0 deletions src/telliot_feeds/queries/price/spot_price.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
"LETH/USD",
"FRXETH/USD",
"SFUEL/USD",
"EZETH/USD",
"WEETH/USD",
"WRSETH/USD",
"MODE/USD",
"RSETH/USD",
]


Expand Down
34 changes: 32 additions & 2 deletions src/telliot_feeds/queries/query_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from telliot_feeds.queries.evm_balance import EVMBalance
from telliot_feeds.queries.evm_balance_current import EVMBalanceCurrent
from telliot_feeds.queries.evm_call import EVMCall
from telliot_feeds.queries.fileCID import FileCID
from telliot_feeds.queries.fileCID import FileCIDQuery
from telliot_feeds.queries.gas_price_oracle import GasPriceOracle
from telliot_feeds.queries.mimicry.collection_stat import MimicryCollectionStat
from telliot_feeds.queries.mimicry.macro_market_mash_up import MimicryMacroMarketMashup
Expand Down Expand Up @@ -600,5 +600,35 @@
query_catalog.add_entry(
tag="filecid-query-example",
title="FileCID query example",
q=FileCID(url="https://raw.githubusercontent.com/tellor-io/dataSpecs/main/README.md"),
q=FileCIDQuery(url="https://raw.githubusercontent.com/tellor-io/dataSpecs/main/README.md"),
)

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

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

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

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

query_catalog.add_entry(
tag="mode-usd-spot",
title="MODE/USD spot price",
q=SpotPrice(asset="mode", currency="usd"),
)
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 @@ -239,6 +239,13 @@ def add_multicall_support(
multicall3_address="0xcA11bde05977b3631167028862bE2a173976CA11",
)

add_multicall_support(
network="mode-sepolia-vtnhnpim72",
network_id=919,
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
5 changes: 5 additions & 0 deletions src/telliot_feeds/sources/price/spot/coingecko.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
"frax": "frax",
"gyd": "gyroscope-gyd",
"frxeth": "frax-ether",
"ezeth": "renzo-restaked-eth",
"weeth": "wrapped-eeth",
"wrseth": "wrapped-rseth",
"rseth": "kelp-dao-restaked-eth",
"mode": "mode",
}

API_KEY = TelliotConfig().api_keys.find(name="coingecko")[0].key
Expand Down
3 changes: 3 additions & 0 deletions src/telliot_feeds/sources/price/spot/curvefiprice.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"btc": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
"frax": "0x853d955acef822db058eb8505911ed77f175b99e",
"frxeth": "0x5e8422345238f34275888049021821e8e08caa1f",
"ezeth": "0xbf5495efe5db9ce00f80364c8b423567e58d2110",
"weeth": "0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee",
"rseth": "0xa1290d69c65a6fe4df752f95823fae25cb99e5a7",
}


Expand Down
Loading
Loading