diff --git a/.gitignore b/.gitignore index 42032f2..edc2f71 100644 --- a/.gitignore +++ b/.gitignore @@ -174,4 +174,5 @@ cython_debug/ .pypirc .DS_Store -.vscode \ No newline at end of file +.vscode +.idea diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..35f236d --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12.6 diff --git a/src/database/general_db.py b/src/database/general_db.py index 80f7dc6..3a559fb 100644 --- a/src/database/general_db.py +++ b/src/database/general_db.py @@ -1,6 +1,7 @@ from utils.data_processor import fetch_non_time_series_data -from typing import Tuple, List, Dict, Any -from database.db_utils import db_pool +from typing import Tuple, List, Dict, Any, Literal +from datetime import datetime, timezone, date + async def fetch_etherlink_transactions(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: @@ -12,7 +13,8 @@ async def fetch_etherlink_transactions(conn) -> Tuple[List[Dict[str, Any]], Exce except Exception as e: return None, e -async def fetch_tzkt_transactions(conn) -> Tuple[List[Dict[str, Any]], Exception]: + +async def fetch_tzkt_transactions_by_month(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: query = """ select date(month), transaction_count from mv_tzkt_monthly_transactions @@ -22,6 +24,62 @@ async def fetch_tzkt_transactions(conn) -> Tuple[List[Dict[str, Any]], Exception except Exception as e: return None, e + +async def fetch_tzkt_transaction_count_by_day(conn, interval: Literal["1d", "1M"], limit: int = 7) -> Tuple[List[List[int]], None] | Tuple[None, Exception]: + try: + query = "" + + match interval: + case "1d": + query = f""" + WITH last_day AS (SELECT max(mv_tzkt_daily_transactions.day) AS max_day + FROM mv_tzkt_daily_transactions) + SELECT t.day AS time, + t.transaction_count AS total_transactions, + c.contract_calls_count AS total_contract_calls + FROM mv_tzkt_daily_transactions t + INNER JOIN mv_tzkt_daily_contract_calls c ON t.day = c.day, + last_day + WHERE t.day >= last_day.max_day - INTERVAL '{limit - 2} days' + ORDER BY time; + """ + + case "1M": + query = f""" + SELECT DATE_TRUNC('month', t.day)::date AS month, + SUM(t.transaction_count) AS total_transactions, + SUM(c.contract_calls_count) AS total_contract_calls + FROM mv_tzkt_daily_transactions t + INNER JOIN mv_tzkt_daily_contract_calls c ON t.day = c.day + WHERE t.day >= DATE_TRUNC('month', CURRENT_DATE) - INTERVAL '{limit - 2} months' + AND t.day <= CURRENT_DATE + GROUP BY DATE_TRUNC('month', t.day) + ORDER BY month; + """ + + rows = await conn.fetch(query) + column_data: List[List[int]] = [] + + for row in rows: + transaction_date: date = row[0] + + timestamp = datetime.combine( + transaction_date, datetime.min.time(), tzinfo=timezone.utc) + tx_count: int = row[1] + call_count: int = row[2] + + column_data.append([ + int(timestamp.timestamp() * 1000), # we need milliseconds + tx_count, + call_count + ]) + + return column_data, None + + except Exception as e: + return None, e + + async def fetch_etherlink_users(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: query = """ @@ -31,7 +89,8 @@ async def fetch_etherlink_users(conn) -> Tuple[List[Dict[str, Any]], Exception]: return data, None except Exception as e: return None, e - + + async def fetch_tzkt_users(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: query = """ @@ -42,6 +101,7 @@ async def fetch_tzkt_users(conn) -> Tuple[List[Dict[str, Any]], Exception]: except Exception as e: return None, e + async def fetch_bot_users(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: query = """ @@ -50,7 +110,8 @@ async def fetch_bot_users(conn) -> Tuple[List[Dict[str, Any]], Exception]: data = await fetch_non_time_series_data(conn, query, "bot_users", ["time", "bot_users"]) return data, None except Exception as e: - return None, e + return None, e + async def fetch_bot_transactions(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: @@ -61,7 +122,8 @@ async def fetch_bot_transactions(conn) -> Tuple[List[Dict[str, Any]], Exception] return data, None except Exception as e: return None, e - + + async def fetch_etherlink_recurring_users(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: query = """ @@ -72,6 +134,7 @@ async def fetch_etherlink_recurring_users(conn) -> Tuple[List[Dict[str, Any]], E except Exception as e: return None, e + async def fetch_tzkt_recurring_users(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: query = """ @@ -82,6 +145,7 @@ async def fetch_tzkt_recurring_users(conn) -> Tuple[List[Dict[str, Any]], Except except Exception as e: return None, e + async def fetch_etherlink_plus_one_users(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: query = """ @@ -92,6 +156,7 @@ async def fetch_etherlink_plus_one_users(conn) -> Tuple[List[Dict[str, Any]], Ex except Exception as e: return None, e + async def fetch_tzkt_plus_one_users(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: query = """ @@ -102,15 +167,16 @@ async def fetch_tzkt_plus_one_users(conn) -> Tuple[List[Dict[str, Any]], Excepti except Exception as e: return None, e + async def fetch_top_projects_transactions(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: query = """ - SELECT project, tx_count, layer - FROM mv_etherlink_projects_transactions + SELECT project, tx_count, layer + FROM mv_etherlink_projects_transactions WHERE month = (SELECT MAX(month) FROM mv_etherlink_projects_transactions) AND tx_count > 0 UNION ALL - SELECT project, tx_count, layer + SELECT project, tx_count, layer FROM mv_tzkt_projects_transactions WHERE month = (SELECT MAX(month) FROM mv_tzkt_projects_transactions) AND tx_count > 0 @@ -121,6 +187,7 @@ async def fetch_top_projects_transactions(conn) -> Tuple[List[Dict[str, Any]], E except Exception as e: return None, e + async def fetch_top_projects_users(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: query = """ @@ -138,17 +205,18 @@ async def fetch_top_projects_users(conn) -> Tuple[List[Dict[str, Any]], Exceptio except Exception as e: return None, e + async def fetch_top_projects_tvl(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: query = """ - select project, round(sum(t.tvl))::INTEGER as tvl, - CASE + select project, round(sum(t.tvl))::INTEGER as tvl, + CASE WHEN layer = 1 THEN 'Tezos L1' WHEN layer = 2 THEN 'Etherlink' - END AS layer + END AS layer FROM tvl t - join - (select distinct project, layer from + join + (select distinct project, layer from project_mappings) pm ON SPLIT_PART(pm.project, ' ', 1) = SPLIT_PART(t.project_name, ' ', 1) WHERE t.date = ( @@ -163,18 +231,19 @@ async def fetch_top_projects_tvl(conn) -> Tuple[List[Dict[str, Any]], Exception] except Exception as e: return None, e + async def fetch_total_tvl_etherlink(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: query = """ - SELECT + SELECT DATE_TRUNC('month', day) AS month, AVG(daily_total_tvl) AS avg_daily_total_tvl FROM ( - SELECT + SELECT DATE(date) AS day, SUM(tvl - tf_tvl) AS daily_total_tvl FROM tvl - WHERE + WHERE chain = 'Etherlink' and category IS DISTINCT FROM 'RWA' AND date >= CURRENT_DATE - INTERVAL '12 months' @@ -183,15 +252,15 @@ async def fetch_total_tvl_etherlink(conn) -> Tuple[List[Dict[str, Any]], Excepti ) daily_sums GROUP BY DATE_TRUNC('month', daily_sums.day) UNION ALL - SELECT + SELECT CURRENT_DATE - INTERVAL '30 days' AS period, AVG(daily_total_tvl) AS avg_daily_total_tvl FROM ( - SELECT + SELECT DATE(date) AS day, SUM(tvl - tf_tvl) AS daily_total_tvl FROM tvl - WHERE + WHERE chain = 'Etherlink' and category IS DISTINCT FROM 'RWA' AND date >= CURRENT_DATE - INTERVAL '30 days' @@ -204,18 +273,19 @@ async def fetch_total_tvl_etherlink(conn) -> Tuple[List[Dict[str, Any]], Excepti except Exception as e: return None, e + async def fetch_total_tvl_tezos(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: query = """ - SELECT + SELECT DATE_TRUNC('month', day) AS month, AVG(daily_total_tvl) AS avg_daily_total_tvl FROM ( - SELECT + SELECT DATE(date) AS day, SUM(tvl - tf_tvl) AS daily_total_tvl FROM tvl - WHERE + WHERE chain = 'Tezos' AND date >= CURRENT_DATE - INTERVAL '12 months' and date < date_trunc('month', current_date) @@ -224,15 +294,15 @@ async def fetch_total_tvl_tezos(conn) -> Tuple[List[Dict[str, Any]], Exception]: ) daily_sums GROUP BY DATE_TRUNC('month', daily_sums.day) UNION ALL - SELECT + SELECT CURRENT_DATE - INTERVAL '30 days' AS period, AVG(daily_total_tvl) AS avg_daily_total_tvl FROM ( - SELECT + SELECT DATE(date) AS day, SUM(tvl - tf_tvl) AS daily_total_tvl FROM tvl - WHERE + WHERE chain = 'Tezos' AND date >= CURRENT_DATE - INTERVAL '30 days' and project_name not in ('KordFi', 'Flame DeFi', 'Matter Defi', 'Crunchy', 'Crunchy Liquid Staking', 'Gate-io', 'Latoken', 'Bitfinex') @@ -245,18 +315,19 @@ async def fetch_total_tvl_tezos(conn) -> Tuple[List[Dict[str, Any]], Exception]: except Exception as e: return None, e + async def fetch_total_tvl_tf(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: query = """ - SELECT + SELECT DATE_TRUNC('month', day) AS month, AVG(daily_total_tvl) AS avg_daily_total_tvl FROM ( - SELECT + SELECT DATE(date) AS day, SUM(tf_tvl) AS daily_total_tvl FROM tvl - WHERE + WHERE date >= CURRENT_DATE - INTERVAL '12 months' and date < date_trunc('month', current_date) and project_name not in ('KordFi', 'Flame DeFi', 'Matter Defi', 'Crunchy', 'Crunchy Liquid Staking', 'Gate-io', 'Latoken', 'Bitfinex') @@ -265,15 +336,15 @@ async def fetch_total_tvl_tf(conn) -> Tuple[List[Dict[str, Any]], Exception]: where daily_total_tvl > 0 GROUP BY DATE_TRUNC('month', daily_sums.day) UNION all - SELECT + SELECT CURRENT_DATE - INTERVAL '30 days' AS period, AVG(daily_total_tvl) AS avg_daily_total_tvl FROM ( - SELECT + SELECT DATE(date) AS day, SUM(tf_tvl) AS daily_total_tvl FROM tvl - WHERE + WHERE date >= CURRENT_DATE - INTERVAL '30 days' and project_name not in ('KordFi', 'Flame DeFi', 'Matter Defi', 'Crunchy', 'Crunchy Liquid Staking', 'Gate-io', 'Latoken', 'Bitfinex') GROUP BY DATE(date) diff --git a/src/database/report_db.py b/src/database/report_db.py index 4657dc8..1ef3fed 100644 --- a/src/database/report_db.py +++ b/src/database/report_db.py @@ -1,6 +1,7 @@ from utils.data_processor import fetch_non_time_series_data from typing import Tuple, List, Dict, Any + async def fetch_targets(conn) -> Tuple[List[Dict[str, Any]], Exception]: try: query = """ @@ -24,7 +25,7 @@ async def fetch_targets(conn) -> Tuple[List[Dict[str, Any]], Exception]: tvl.tvl_sum * 100.0 / NULLIF( CASE WHEN TRIM(COALESCE(tvl_goal, '')) = '' THEN 0 - WHEN tvl_goal ~ '^-?[0-9]+(\.[0-9]+)?$' THEN CAST(tvl_goal AS numeric) + WHEN tvl_goal ~ '^-?[0-9]+(\\.[0-9]+)?$' THEN CAST(tvl_goal AS numeric) ELSE NULL END, 0 ) AS numeric @@ -43,4 +44,4 @@ async def fetch_targets(conn) -> Tuple[List[Dict[str, Any]], Exception]: data = await fetch_non_time_series_data(conn, query, "report", ["employee/vertical", "mau_target", "mau_actual", "mau_percentage", "tvl_target", "tvl actual", "tvl_percentage"]) return data, None except Exception as e: - return None, e \ No newline at end of file + return None, e diff --git a/src/routers/stats.py b/src/routers/stats.py index aa621cc..f1260c4 100644 --- a/src/routers/stats.py +++ b/src/routers/stats.py @@ -1,13 +1,15 @@ from database.db_utils import get_db_conn from database.defi_db import fetch_borrow_supply, fetch_borrow_supply_cap, fetch_max_slippage, fetch_slippage -from database.general_db import fetch_bot_transactions, fetch_bot_users, fetch_etherlink_plus_one_users, fetch_etherlink_recurring_users, fetch_etherlink_transactions, fetch_etherlink_users, fetch_top_projects_transactions, fetch_top_projects_tvl, fetch_top_projects_users, fetch_total_tvl_etherlink, fetch_total_tvl_tezos, fetch_total_tvl_tf, fetch_tzkt_plus_one_users, fetch_tzkt_recurring_users, fetch_tzkt_transactions, fetch_tzkt_users +from database.general_db import fetch_bot_transactions, fetch_bot_users, fetch_etherlink_plus_one_users, fetch_etherlink_recurring_users, fetch_etherlink_transactions, fetch_etherlink_users, fetch_top_projects_transactions, fetch_top_projects_tvl, fetch_top_projects_users, fetch_total_tvl_etherlink, fetch_total_tvl_tezos, fetch_total_tvl_tf, fetch_tzkt_plus_one_users, fetch_tzkt_recurring_users, fetch_tzkt_transactions_by_month, fetch_tzkt_transaction_count_by_day, fetch_tzkt_users from database.team_db import fetch_team_etherlink_transactions, fetch_team_etherlink_users, fetch_team_goals_users, fetch_team_predicted_users, fetch_team_projects_transactions, fetch_team_projects_transactions_split, fetch_team_projects_users, fetch_team_projects_users_split, fetch_team_tzkt_transactions, fetch_team_tzkt_users, fetch_team_actual_users from database.individual_db import fetch_owner_actual_tvl, fetch_owner_predicted_tvl, fetch_owner_goals_tvl, fetch_owner_projects_tvl_split_chain, fetch_owner_top_projects_tvl, fetch_owner_top_projects_users, fetch_owner_actual_users, fetch_owner_goals_users, fetch_owner_predicted_users from database.report_db import fetch_targets from fastapi import Depends, Query, APIRouter +from typing import Literal stats_router = APIRouter(prefix="/v1/stats") + @stats_router.get("/team_goals_users") async def get_team_goals_users(department: str = Query(..., description="Department name"), conn=Depends(get_db_conn)): data, err = await fetch_team_goals_users(department, conn) @@ -15,6 +17,7 @@ async def get_team_goals_users(department: str = Query(..., description="Departm return {"error": str(err)} return data + @stats_router.get("/team_actual_users") async def get_team_actual_users(department: str = Query(..., description="Department name"), conn=Depends(get_db_conn)): data, err = await fetch_team_actual_users(department, conn) @@ -22,6 +25,7 @@ async def get_team_actual_users(department: str = Query(..., description="Depart return {"error": str(err)} return data + @stats_router.get("/team_predicted_users") async def get_team_predicted_users(department: str = Query(..., description="Department name"), conn=Depends(get_db_conn)): data, err = await fetch_team_predicted_users(department, conn) @@ -29,6 +33,7 @@ async def get_team_predicted_users(department: str = Query(..., description="Dep return {"error": str(err)} return data + @stats_router.get("/team_transactions") async def get_team_tzkt_transactions(department: str = Query(..., description="Department name"), conn=Depends(get_db_conn)): data, err = await fetch_team_tzkt_transactions(department, conn) @@ -36,6 +41,7 @@ async def get_team_tzkt_transactions(department: str = Query(..., description="D return {"error": str(err)} return data + @stats_router.get("/team_users") async def get_team_tzkt_users(department: str = Query(..., description="Department name"), conn=Depends(get_db_conn)): data, err = await fetch_team_tzkt_users(department, conn) @@ -43,6 +49,7 @@ async def get_team_tzkt_users(department: str = Query(..., description="Departme return {"error": str(err)} return data + @stats_router.get("/team_transactions_etherlink") async def get_team_etherlink_transactions(department: str = Query(..., description="Department name"), conn=Depends(get_db_conn)): data, err = await fetch_team_etherlink_transactions(department, conn) @@ -50,6 +57,7 @@ async def get_team_etherlink_transactions(department: str = Query(..., descripti return {"error": str(err)} return data + @stats_router.get("/team_users_etherlink") async def get_team_etherlink_users(department: str = Query(..., description="Department name"), conn=Depends(get_db_conn)): data, err = await fetch_team_etherlink_users(department, conn) @@ -57,6 +65,7 @@ async def get_team_etherlink_users(department: str = Query(..., description="Dep return {"error": str(err)} return data + @stats_router.get("/team_projects_transactions") async def get_team_projects_transactions(department: str = Query(..., description="Department name"), conn=Depends(get_db_conn)): data, err = await fetch_team_projects_transactions(department, conn) @@ -64,6 +73,7 @@ async def get_team_projects_transactions(department: str = Query(..., descriptio return {"error": str(err)} return data + @stats_router.get("/team_projects_users") async def get_team_projects_users(department: str = Query(..., description="Department name"), conn=Depends(get_db_conn)): data, err = await fetch_team_projects_users(department, conn) @@ -71,6 +81,7 @@ async def get_team_projects_users(department: str = Query(..., description="Depa return {"error": str(err)} return data + @stats_router.get("/team_projects_transactions_monthly") async def get_team_projects_transactions_split(department: str = Query(..., description="Department name"), conn=Depends(get_db_conn)): data, err = await fetch_team_projects_transactions_split(department, conn) @@ -78,6 +89,7 @@ async def get_team_projects_transactions_split(department: str = Query(..., desc return {"error": str(err)} return data + @stats_router.get("/team_projects_users_monthly") async def get_team_projects_users_split(department: str = Query(..., description="Department name"), conn=Depends(get_db_conn)): data, err = await fetch_team_projects_users_split(department, conn) @@ -85,6 +97,7 @@ async def get_team_projects_users_split(department: str = Query(..., description return {"error": str(err)} return data + @stats_router.get("/owner_actual_users") async def get_owner_actual_users(owner: str = Query(..., description="Owner name"), conn=Depends(get_db_conn)): data, err = await fetch_owner_actual_users(owner, conn) @@ -92,6 +105,7 @@ async def get_owner_actual_users(owner: str = Query(..., description="Owner name return {"error": str(err)} return data + @stats_router.get("/owner_goals_users") async def get_owner_goals_users(owner: str = Query(..., description="Owner name"), conn=Depends(get_db_conn)): data, err = await fetch_owner_goals_users(owner, conn) @@ -99,6 +113,7 @@ async def get_owner_goals_users(owner: str = Query(..., description="Owner name" return {"error": str(err)} return data + @stats_router.get("/owner_predicted_users") async def get_owner_predicted_users(owner: str = Query(..., description="Owner name"), conn=Depends(get_db_conn)): data, err = await fetch_owner_predicted_users(owner, conn) @@ -106,6 +121,7 @@ async def get_owner_predicted_users(owner: str = Query(..., description="Owner n return {"error": str(err)} return data + @stats_router.get("/owner_top_projects") async def get_top_projects_users_owner(owner: str = Query(..., description="Owner name"), conn=Depends(get_db_conn)): data, err = await fetch_owner_top_projects_users(owner, conn) @@ -113,6 +129,7 @@ async def get_top_projects_users_owner(owner: str = Query(..., description="Owne return {"error": str(err)} return data + @stats_router.get("/owner_actual_tvl") async def get_owner_actual_tvl(owner: str = Query(..., description="Owner name"), conn=Depends(get_db_conn)): data, err = await fetch_owner_actual_tvl(owner, conn) @@ -120,6 +137,7 @@ async def get_owner_actual_tvl(owner: str = Query(..., description="Owner name") return {"error": str(err)} return data + @stats_router.get("/owner_predicted_tvl") async def get_owner_predicted_tvl(owner: str = Query(..., description="Owner name"), conn=Depends(get_db_conn)): data, err = await fetch_owner_predicted_tvl(owner, conn) @@ -127,6 +145,7 @@ async def get_owner_predicted_tvl(owner: str = Query(..., description="Owner nam return {"error": str(err)} return data + @stats_router.get("/owner_goals_tvl") async def get_owner_goals_tvl(owner: str = Query(..., description="Owner name"), conn=Depends(get_db_conn)): data, err = await fetch_owner_goals_tvl(owner, conn) @@ -134,6 +153,7 @@ async def get_owner_goals_tvl(owner: str = Query(..., description="Owner name"), return {"error": str(err)} return data + @stats_router.get("/owner_tvl_split") async def get_owner_tvl_split(owner: str = Query(..., description="Owner name"), conn=Depends(get_db_conn)): data, err = await fetch_owner_top_projects_tvl(owner, conn) @@ -141,6 +161,7 @@ async def get_owner_tvl_split(owner: str = Query(..., description="Owner name"), return {"error": str(err)} return data + @stats_router.get("/owner_tvl_split_chain") async def get_owner_tvl_split_chain(owner: str = Query(..., description="Owner name"), conn=Depends(get_db_conn)): data, err = await fetch_owner_projects_tvl_split_chain(owner, conn) @@ -148,6 +169,7 @@ async def get_owner_tvl_split_chain(owner: str = Query(..., description="Owner n return {"error": str(err)} return data + @stats_router.get("/etherlink_transactions") async def get_etherlink_transactions(conn=Depends(get_db_conn)): data, err = await fetch_etherlink_transactions(conn) @@ -155,13 +177,25 @@ async def get_etherlink_transactions(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/tzkt_transactions") async def get_tzkt_transactions(conn=Depends(get_db_conn)): - data, err = await fetch_tzkt_transactions(conn) + data, err = await fetch_tzkt_transactions_by_month(conn) + if err: + return {"error": str(err)} + return data + + +@stats_router.get("/tzkt_transactions/count") +async def get_transactions_count(conn=Depends(get_db_conn), limit: int = 7, collapse: Literal["1d", "1M"] = "1d"): + data, err = await fetch_tzkt_transaction_count_by_day(conn, collapse, limit) + if err: return {"error": str(err)} + return data + @stats_router.get("/bot_transactions") async def get_bot_transactions(conn=Depends(get_db_conn)): data, err = await fetch_bot_transactions(conn) @@ -169,6 +203,7 @@ async def get_bot_transactions(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/etherlink_users") async def get_etherlink_users(conn=Depends(get_db_conn)): data, err = await fetch_etherlink_users(conn) @@ -176,6 +211,7 @@ async def get_etherlink_users(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/bot_users") async def get_bot_users(conn=Depends(get_db_conn)): data, err = await fetch_bot_users(conn) @@ -183,6 +219,7 @@ async def get_bot_users(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/tzkt_users") async def get_tzkt_users(conn=Depends(get_db_conn)): data, err = await fetch_tzkt_users(conn) @@ -190,6 +227,7 @@ async def get_tzkt_users(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/etherlink_plus_one") async def get_etherlink_plus_one_users(conn=Depends(get_db_conn)): data, err = await fetch_etherlink_plus_one_users(conn) @@ -197,6 +235,7 @@ async def get_etherlink_plus_one_users(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/tzkt_plus_one") async def get_tzkt_plus_one_users(conn=Depends(get_db_conn)): data, err = await fetch_tzkt_plus_one_users(conn) @@ -204,6 +243,7 @@ async def get_tzkt_plus_one_users(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/etherlink_recurring_users") async def get_etherlink_recurring_users(conn=Depends(get_db_conn)): data, err = await fetch_etherlink_recurring_users(conn) @@ -211,6 +251,7 @@ async def get_etherlink_recurring_users(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/tzkt_recurring_users") async def get_tzkt_recurring_users(conn=Depends(get_db_conn)): data, err = await fetch_tzkt_recurring_users(conn) @@ -218,6 +259,7 @@ async def get_tzkt_recurring_users(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/transactions_group_by_project") async def get_top_projects_transactions(conn=Depends(get_db_conn)): data, err = await fetch_top_projects_transactions(conn) @@ -225,6 +267,7 @@ async def get_top_projects_transactions(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/user_group_by_project") async def get_top_projects_users(conn=Depends(get_db_conn)): data, err = await fetch_top_projects_users(conn) @@ -232,6 +275,7 @@ async def get_top_projects_users(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/tvl_group_by_project") async def get_top_projects_tvl(conn=Depends(get_db_conn)): data, err = await fetch_top_projects_tvl(conn) @@ -239,6 +283,7 @@ async def get_top_projects_tvl(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/etherlink_tvl") async def fetch_etherlink_tvl(conn=Depends(get_db_conn)): data, err = await fetch_total_tvl_etherlink(conn) @@ -246,6 +291,7 @@ async def fetch_etherlink_tvl(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/tezos_tvl") async def fetch_tezos_tvl(conn=Depends(get_db_conn)): data, err = await fetch_total_tvl_tezos(conn) @@ -253,6 +299,7 @@ async def fetch_tezos_tvl(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/tf_tvl") async def fetch_tf_tvl(conn=Depends(get_db_conn)): data, err = await fetch_total_tvl_tf(conn) @@ -260,6 +307,7 @@ async def fetch_tf_tvl(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/slippage") async def get_slippage(conn=Depends(get_db_conn)): data, err = await fetch_slippage(conn) @@ -267,6 +315,7 @@ async def get_slippage(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/max_slippage") async def get_max_slippage(conn=Depends(get_db_conn)): data, err = await fetch_max_slippage(conn) @@ -274,6 +323,7 @@ async def get_max_slippage(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/supply_borrow") async def get_supply_borrow(token: str = Query(..., description="Token"), conn=Depends(get_db_conn)): data, err = await fetch_borrow_supply(token, conn) @@ -281,6 +331,7 @@ async def get_supply_borrow(token: str = Query(..., description="Token"), conn=D return {"error": str(err)} return data + @stats_router.get("/supply_borrow_cap") async def get_supply_borrow_cap(conn=Depends(get_db_conn)): data, err = await fetch_borrow_supply_cap(conn) @@ -288,6 +339,7 @@ async def get_supply_borrow_cap(conn=Depends(get_db_conn)): return {"error": str(err)} return data + @stats_router.get("/report_targets") async def get_report_targets(conn=Depends(get_db_conn)): data, err = await fetch_targets(conn)