From a1f6fdf58fdea06fc2f958ce2c661e8a963d58d4 Mon Sep 17 00:00:00 2001 From: spuddyminer Date: Wed, 18 Oct 2023 13:41:03 -0400 Subject: [PATCH 1/3] added message to show oracle contract for chainId --- src/telliot_feeds/utils/cfg.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/telliot_feeds/utils/cfg.py b/src/telliot_feeds/utils/cfg.py index 0cc5c5bc..6ae7b095 100644 --- a/src/telliot_feeds/utils/cfg.py +++ b/src/telliot_feeds/utils/cfg.py @@ -6,6 +6,7 @@ from chained_accounts import ChainedAccount from chained_accounts import find_accounts from simple_term_menu import TerminalMenu +from telliot_core.apps.core import Tellor360OracleContract from telliot_core.apps.telliot_config import TelliotConfig from telliot_core.model.endpoints import RPCEndpoint @@ -64,7 +65,8 @@ def setup_config( """ ) - click.echo(f"Your current settings...\nYour chain id: {cfg.main.chain_id}\n") + click.echo(f"Your current settings...\nYour chain id: {cfg.main.chain_id}") + click.echo(f"Oracle contract address: {check_oracle_address(cfg, account_name)}\n") if endpoint is not None: click.echo( @@ -150,6 +152,16 @@ def check_accounts(cfg: TelliotConfig, account_name: str) -> List[ChainedAccount return find_accounts(chain_id=cfg.main.chain_id, name=account_name) # type: ignore +def check_oracle_address(cfg: TelliotConfig, account_name: str) -> Optional[str]: + """Check oracle contract for the account's chain ID""" + + try: + return str(Tellor360OracleContract(node=check_endpoint(cfg), account=account_name).address) + except Exception as e: + logger.warning(f"No oracle contract found on chain id{cfg.main.chain_id}: " + str(e)) + return None + + def prompt_for_endpoint(chain_id: int) -> Optional[RPCEndpoint]: """Take user input to create a new RPCEndpoint""" rpc_url = click.prompt("Enter RPC URL", type=str) From ca2e56e7933bfb956d036f385d700256da79d801 Mon Sep 17 00:00:00 2001 From: spuddyminer Date: Wed, 18 Oct 2023 14:31:03 -0400 Subject: [PATCH 2/3] fix-bitfinex-typing-fail --- src/telliot_feeds/sources/ampleforth/bitfinex.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/telliot_feeds/sources/ampleforth/bitfinex.py b/src/telliot_feeds/sources/ampleforth/bitfinex.py index 4adca2a6..28fafccd 100644 --- a/src/telliot_feeds/sources/ampleforth/bitfinex.py +++ b/src/telliot_feeds/sources/ampleforth/bitfinex.py @@ -148,7 +148,9 @@ def calculate_vwap_via_all(symbol: dict[str, Any], start: int, end: int, show_de result["source"].update(source) result.update(p_result[i]) - all_vwaps = [v["vwap"] * v["volume"] for k, v in result.items() if k != "source" and v != NO_TRADES_FOUND] + all_vwaps = [ + v["vwap"] * v["volume"] for k, v in result.items() if k != "source" and v != NO_TRADES_FOUND # type: ignore + ] sum_volumes_and_prices = sum(all_vwaps) sum_volume = sum(v["volume"] for k, v in result.items() if k != "source" and "volume" in v) From 6bd05e9f2f564af66737a3b3e4a7ceed5741bf61 Mon Sep 17 00:00:00 2001 From: spuddyminer Date: Wed, 18 Oct 2023 21:44:14 -0400 Subject: [PATCH 3/3] Revert "fix-bitfinex-typing-fail" This reverts commit ca2e56e7933bfb956d036f385d700256da79d801. --- src/telliot_feeds/sources/ampleforth/bitfinex.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/telliot_feeds/sources/ampleforth/bitfinex.py b/src/telliot_feeds/sources/ampleforth/bitfinex.py index 28fafccd..4adca2a6 100644 --- a/src/telliot_feeds/sources/ampleforth/bitfinex.py +++ b/src/telliot_feeds/sources/ampleforth/bitfinex.py @@ -148,9 +148,7 @@ def calculate_vwap_via_all(symbol: dict[str, Any], start: int, end: int, show_de result["source"].update(source) result.update(p_result[i]) - all_vwaps = [ - v["vwap"] * v["volume"] for k, v in result.items() if k != "source" and v != NO_TRADES_FOUND # type: ignore - ] + all_vwaps = [v["vwap"] * v["volume"] for k, v in result.items() if k != "source" and v != NO_TRADES_FOUND] sum_volumes_and_prices = sum(all_vwaps) sum_volume = sum(v["volume"] for k, v in result.items() if k != "source" and "volume" in v)