diff --git a/src/integrations/all_bridge_explorer.py b/src/integrations/all_bridge_explorer.py index b439629..afb88c7 100644 --- a/src/integrations/all_bridge_explorer.py +++ b/src/integrations/all_bridge_explorer.py @@ -12,9 +12,7 @@ from requests.exceptions import HTTPError, RequestException, Timeout from src.integrations.models.all_bridge_explorer import ( - AllBridgeExplorerTokenInfo, - AllBridgeExplorerTransfer, -) + AllBridgeExplorerTokenInfo, AllBridgeExplorerTransfer) from src.integrations.utilities import get_raw_from_bq, pydantic_schema_to_list # Base URL for the API @@ -111,7 +109,9 @@ def get_all_bridge_explorer_latest_transfers( logging.error(f"Bad request error for URL: {url}. Error: {str(e)}") raise # Don't retry on 400 errors if attempt < max_retries - 1: - delay = (base_delay * 2**attempt) + (random.randint(0, 1000) / 1000) + delay = (base_delay * 2**attempt) + ( + random.randint(0, 1000) / 1000 + ) logging.warning( f"Request failed. Retrying in {delay:.2f} seconds..." ) diff --git a/src/streamlit_everclear/pages/2_Revenue_&_fees.py b/src/streamlit_everclear/pages/2_Revenue_&_fees.py index 48d135a..3e6347c 100644 --- a/src/streamlit_everclear/pages/2_Revenue_&_fees.py +++ b/src/streamlit_everclear/pages/2_Revenue_&_fees.py @@ -1,26 +1,17 @@ import logging -import pandas as pd from datetime import datetime, timedelta + +import pandas as pd import pytz import streamlit as st from setup import ( - get_raw_data_from_postgres_by_sql, get_chain_id_to_chain_name_data_from_bq, - get_raw_data_from_bq_df, get_db_url, + get_raw_data_from_bq_df, + get_raw_data_from_postgres_by_sql, ) -# TODO: - -# [ ] Adding Revenue -# [ ] Adding Fees - gas fee paid - by Everclear for message (Relay) -# [ ] Adding Message Cost - by Everclear for message Cost -# [ ] Add Date: Lasty X days - -# calculations steps for each -# 1. Revenue -> 1 bps fo orgin amount -# 2. Discount applied to invoice if any - per intent -# 3. pricing rate per intent by different timestamps +st.set_page_config(layout="wide") def apply_sidebar_filters( @@ -222,6 +213,11 @@ def calculate_revenue_fees_metrics(cdf): inplace=True, ) df["revenue_usd"] = df["origin_amount_usd"] * 0.0001 + # when status is not settled_and_completed revenue and hub status is dispatched_and_unsupported is 0 + df.loc[ + (df["hub_status"] == "DISPATCHED_UNSUPPORTED"), + "revenue_usd", + ] = 0 # total cost df["total_cost_usd"] = ( df["intent_message_cost_usd"] @@ -239,6 +235,7 @@ def calculate_revenue_fees_metrics(cdf): cols_to_keep = [ "id", "status", + "hub_status", "origin_timestamp", "settlement_timestamp", # chain and token diff --git a/src/streamlit_everclear/setup.py b/src/streamlit_everclear/setup.py index 4820edf..26572fe 100644 --- a/src/streamlit_everclear/setup.py +++ b/src/streamlit_everclear/setup.py @@ -1,6 +1,7 @@ # Adding the streamlit pages to the sidebar import logging import os + import pandas as pd import pandas_gbq as gbq import streamlit as st diff --git a/src/streamlit_everclear/sql/revenue_fee_gas_per_intent.sql b/src/streamlit_everclear/sql/revenue_fee_gas_per_intent.sql index ef07dc2..34d62d3 100644 --- a/src/streamlit_everclear/sql/revenue_fee_gas_per_intent.sql +++ b/src/streamlit_everclear/sql/revenue_fee_gas_per_intent.sql @@ -204,44 +204,3 @@ FROM SELECT * FROM semi s - - - - - - - -WITH raw AS ( - - SELECT - m.id AS message_id, - m.message_status, - m.type, - unnest(m.intent_ids) AS intent_ids, - origin_domain, - destination_domain, - array_length(m.intent_ids, 1) AS intent_count, - (m.gas_price::float * m.gas_limit::float) / array_length(m.intent_ids, 1) AS gas_amount_per_intent, - m.quote::float / array_length(m.intent_ids, 1) AS quote_per_intent -FROM - public.messages m - -) - - -SELECT - * -FROM raw r -WHERE intent_ids= '0xf99092486cb398504e688b19adb536e208f85fa709f8d901863b769e1b5455bc' - - - -SELECT - * -FROM public.messages m -WHERE m.id = '0xb50dda0adf08d1328ce8530527f8d8069910ff90e7a141c05c72483775b6cf61' - - - - -