Spaces:
Sleeping
Sleeping
updating graphs
Browse files
app.py
CHANGED
|
@@ -10,11 +10,6 @@ from app_trans_new import create_transcation_visualizations,create_active_agents
|
|
| 10 |
from app_value_locked import fetch_daily_value_locked
|
| 11 |
import os
|
| 12 |
|
| 13 |
-
from dotenv import load_dotenv
|
| 14 |
-
|
| 15 |
-
# Load environment variables from .env file
|
| 16 |
-
load_dotenv()
|
| 17 |
-
|
| 18 |
OPTIMISM_RPC_URL = os.getenv('OPTIMISM_RPC_URL')
|
| 19 |
print('OPTIMISM_RPC_URL',OPTIMISM_RPC_URL)
|
| 20 |
# Initialize a Web3 instance
|
|
@@ -183,63 +178,62 @@ def create_visualizations():
|
|
| 183 |
df_transactions, df_agents_weekly, df_agents_with_transactions_weekly, df_agents_with_transactions = process_transactions_and_agents(transactions_data)
|
| 184 |
# Map chain IDs to chain names
|
| 185 |
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
#
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
#
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
|
| 203 |
-
#
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
|
| 237 |
|
| 238 |
chain_name_map = {
|
| 239 |
10: "Optimism",
|
| 240 |
8453: "Base",
|
| 241 |
1: "Ethereum",
|
| 242 |
-
34443: "Mode"
|
| 243 |
}
|
| 244 |
df_transactions["sending_chain"] = df_transactions["sending_chain"].map(chain_name_map)
|
| 245 |
df_transactions["receiving_chain"] = df_transactions["receiving_chain"].map(chain_name_map)
|
|
@@ -435,15 +429,15 @@ def create_visualizations():
|
|
| 435 |
)
|
| 436 |
)
|
| 437 |
|
| 438 |
-
return fig_swaps_chain, fig_bridges_chain, fig_agents_registered, fig_agents_with_transactions_daily
|
| 439 |
|
| 440 |
# Gradio interface
|
| 441 |
def dashboard():
|
| 442 |
with gr.Blocks() as demo:
|
| 443 |
gr.Markdown("# Valory Transactions Dashboard")
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
|
| 448 |
fig_swaps_chain, fig_bridges_chain, fig_agents_registered, fig_agents_with_transactions_daily = create_visualizations()
|
| 449 |
#Fetch and display visualizations
|
|
@@ -458,14 +452,14 @@ def dashboard():
|
|
| 458 |
#fig_swaps_chain, fig_bridges_chain, fig_agents_daily, fig_agents_with_transactions_daily,fig_tvl = create_visualizations()
|
| 459 |
gr.Plot(fig_agents_registered)
|
| 460 |
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
|
| 470 |
return demo
|
| 471 |
|
|
|
|
| 10 |
from app_value_locked import fetch_daily_value_locked
|
| 11 |
import os
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
OPTIMISM_RPC_URL = os.getenv('OPTIMISM_RPC_URL')
|
| 14 |
print('OPTIMISM_RPC_URL',OPTIMISM_RPC_URL)
|
| 15 |
# Initialize a Web3 instance
|
|
|
|
| 178 |
df_transactions, df_agents_weekly, df_agents_with_transactions_weekly, df_agents_with_transactions = process_transactions_and_agents(transactions_data)
|
| 179 |
# Map chain IDs to chain names
|
| 180 |
|
| 181 |
+
# Fetch daily value locked data
|
| 182 |
+
df_tvl = fetch_daily_value_locked()
|
| 183 |
+
|
| 184 |
+
# Calculate total value locked per chain per day
|
| 185 |
+
df_tvl["total_value_locked_usd"] = df_tvl["amount0_usd"] + df_tvl["amount1_usd"]
|
| 186 |
+
df_tvl_daily = df_tvl.groupby(["date", "chain_name"])["total_value_locked_usd"].sum().reset_index()
|
| 187 |
+
df_tvl_daily['date'] = pd.to_datetime(df_tvl_daily['date'])
|
| 188 |
+
|
| 189 |
+
# Filter out dates with zero total value locked
|
| 190 |
+
df_tvl_daily = df_tvl_daily[df_tvl_daily["total_value_locked_usd"] > 0]
|
| 191 |
+
chain_name_map = {
|
| 192 |
+
"optimism": "Optimism",
|
| 193 |
+
"base": "Base",
|
| 194 |
+
"ethereum": "Ethereum"
|
| 195 |
+
}
|
| 196 |
+
df_tvl_daily["chain_name"] = df_tvl_daily["chain_name"].map(chain_name_map)
|
| 197 |
|
| 198 |
+
# Plot total value locked
|
| 199 |
+
fig_tvl = px.bar(
|
| 200 |
+
df_tvl_daily,
|
| 201 |
+
x="date",
|
| 202 |
+
y="total_value_locked_usd",
|
| 203 |
+
color="chain_name",
|
| 204 |
+
opacity=0.7,
|
| 205 |
+
title="Total Volume Invested in Pools in Different Chains Daily",
|
| 206 |
+
labels={"date": "Date","chain_name": "Transaction Chain", "total_value_locked_usd": "Total Volume Invested (USD)"},
|
| 207 |
+
barmode='stack',
|
| 208 |
+
color_discrete_map={
|
| 209 |
+
"Optimism": "blue",
|
| 210 |
+
"Base": "purple",
|
| 211 |
+
"Ethereum": "darkgreen"
|
| 212 |
+
}
|
| 213 |
+
)
|
| 214 |
+
fig_tvl.update_layout(
|
| 215 |
+
xaxis_title=None,
|
| 216 |
+
yaxis=dict(tickmode='linear', tick0=0, dtick=1),
|
| 217 |
+
xaxis=dict(
|
| 218 |
+
tickmode='array',
|
| 219 |
+
tickvals=df_tvl_daily['date'],
|
| 220 |
+
ticktext=df_tvl_daily['date'].dt.strftime('%b %d'),
|
| 221 |
+
tickangle=-45,
|
| 222 |
+
),
|
| 223 |
+
bargap=0.6, # Increase gap between bar groups (0-1)
|
| 224 |
+
bargroupgap=0.1, # Decrease gap between bars in a group (0-1)
|
| 225 |
+
height=600, # Specify width to prevent bars from being too wide
|
| 226 |
+
margin=dict(l=50, r=50, t=50, b=50), # Add margins
|
| 227 |
+
showlegend=True,
|
| 228 |
+
template='plotly_white'
|
| 229 |
+
)
|
| 230 |
+
fig_tvl.update_xaxes(tickformat="%b %d")
|
| 231 |
|
| 232 |
|
| 233 |
chain_name_map = {
|
| 234 |
10: "Optimism",
|
| 235 |
8453: "Base",
|
| 236 |
1: "Ethereum",
|
|
|
|
| 237 |
}
|
| 238 |
df_transactions["sending_chain"] = df_transactions["sending_chain"].map(chain_name_map)
|
| 239 |
df_transactions["receiving_chain"] = df_transactions["receiving_chain"].map(chain_name_map)
|
|
|
|
| 429 |
)
|
| 430 |
)
|
| 431 |
|
| 432 |
+
return fig_swaps_chain, fig_bridges_chain, fig_agents_registered, fig_agents_with_transactions_daily,fig_tvl
|
| 433 |
|
| 434 |
# Gradio interface
|
| 435 |
def dashboard():
|
| 436 |
with gr.Blocks() as demo:
|
| 437 |
gr.Markdown("# Valory Transactions Dashboard")
|
| 438 |
+
with gr.Tab("Chain Daily activity"):
|
| 439 |
+
fig_tx_chain = create_transcation_visualizations()
|
| 440 |
+
gr.Plot(fig_tx_chain)
|
| 441 |
|
| 442 |
fig_swaps_chain, fig_bridges_chain, fig_agents_registered, fig_agents_with_transactions_daily = create_visualizations()
|
| 443 |
#Fetch and display visualizations
|
|
|
|
| 452 |
#fig_swaps_chain, fig_bridges_chain, fig_agents_daily, fig_agents_with_transactions_daily,fig_tvl = create_visualizations()
|
| 453 |
gr.Plot(fig_agents_registered)
|
| 454 |
|
| 455 |
+
with gr.Tab("DAA"):
|
| 456 |
+
fig_agents_with_transactions_daily = create_active_agents_visualizations()
|
| 457 |
+
#fig_swaps_chain, fig_bridges_chain, fig_agents_daily, fig_agents_with_transactions_daily,fig_tvl = create_visualizations()
|
| 458 |
+
gr.Plot(fig_agents_with_transactions_daily)
|
| 459 |
+
|
| 460 |
+
with gr.Tab("Total Value Locked"):
|
| 461 |
+
#fig_swaps_chain, fig_bridges_chain, fig_agents_daily, fig_agents_with_transactions_daily, fig_tvl,fig_tvl = create_visualizations()
|
| 462 |
+
gr.Plot(fig_tvl)
|
| 463 |
|
| 464 |
return demo
|
| 465 |
|