Skip to content

Commit

Permalink
Merge pull request #24 from Synthetixio/public-updates
Browse files Browse the repository at this point in the history
Updates to publish
  • Loading branch information
Tburm authored Feb 1, 2024
2 parents 6f72ca7 + 5099c98 commit ac54ad4
Show file tree
Hide file tree
Showing 28 changed files with 636 additions and 181 deletions.
56 changes: 56 additions & 0 deletions dashboard/About.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import streamlit as st
from st_pages import Page, show_pages, add_page_title

st.set_page_config(page_title="Synthetix Dashboards", layout="wide")

hide_footer = """
<style>
footer {visibility: hidden;}
</style>
"""
st.markdown(hide_footer, unsafe_allow_html=True)

st.markdown(
"""
# Synthetix V3 Analytics
Discover the latest insights into the Synthetix V3 ecosystem.
## Base Andromeda Release
Andromeda, the latest Synthetix V3 deployment on the Base network, allows liquidity provision with USDC and seamless trading of perps using USDC collateral. For details, explore our [blog post](https://blog.synthetix.io/what-is-the-andromeda-release/).
### Dashboards:
- **Perps Stats**: Insights on volume, fees, and more across all markets.
- **Perps Markets**: Insights for each perps market.
- **Perps Monitor**: A consolidated view of all perps markets.
- **Core Stats**: Key metrics of the Core system, including debt, collateral, and LP performance.
- **Spot Markets**: Analysis of the USDC wrapper contracts.
- **Perps Integrators**: Activity overview by integrator.
- **Perps Accounts**: View recent activity by specific accounts.
- **Perps Keepers**: Track community keepers' settlement transactions.
## Additional Resources
- V3 details: [documentation](https://docs.synthetix.io/v/v3/)
- Updates: [blog](https://blog.synthetix.io/)
- Community: [discord](https://discord.com/invite/AEdUHzt)
"""
)

# page setup
PAGE_PREFIX = "dashboard/" if st.secrets.settings.IS_CLOUD == "true" else ""
SHOW_OP = True if st.secrets.settings.SHOW_OP == "true" else False

home_page = [Page(f"{PAGE_PREFIX}About.py", "About")]
op_pages = [
Page(f"{PAGE_PREFIX}pages/OP_Mainnet.py", "OP Mainnet"),
]
base_pages = [
Page(f"{PAGE_PREFIX}pages/Base_Mainnet.py", "Base Mainnet"),
Page(f"{PAGE_PREFIX}pages/Base_Sepolia.py", "Base Sepolia"),
]

# pages to show
pages_to_show = home_page + (op_pages if SHOW_OP else []) + base_pages
show_pages(pages_to_show)
2 changes: 1 addition & 1 deletion dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . .

# Command to run the service
CMD ["streamlit", "run", "Home.py"]
CMD ["streamlit", "run", "About.py"]
36 changes: 0 additions & 36 deletions dashboard/Home.py

This file was deleted.

26 changes: 26 additions & 0 deletions dashboard/modules/base_mainnet/core_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ def fetch_data(filters):
db,
)

df_apr = pd.read_sql_query(
f"""
SELECT * FROM base_mainnet.fct_core_apr
WHERE ts >= '{start_date}' and ts <= '{end_date}'
and market_id != 1
ORDER BY ts
""",
db,
)

db.close()

return {
Expand All @@ -74,6 +84,7 @@ def fetch_data(filters):
"account_delegation": df_account_delegation,
"market_updated": df_market_updated,
"pnl": df_pnl,
"apr": df_apr,
}


Expand Down Expand Up @@ -122,6 +133,19 @@ def make_charts(data):
"Pnl",
"market_id",
),
"hourly_pnl": chart_bars(
data["apr"],
"ts",
["hourly_pnl"],
"Hourly Pnl",
),
"apr": chart_lines(
data["apr"],
"ts",
["pnl_pct_24_hr", "pnl_pct_7_day", "apr"],
"APR",
smooth=True,
),
}


Expand Down Expand Up @@ -149,11 +173,13 @@ def main():
st.plotly_chart(charts["collateral"], use_container_width=True)
st.plotly_chart(charts["reported_debt"], use_container_width=True)
st.plotly_chart(charts["net_issuance"], use_container_width=True)
st.plotly_chart(charts["hourly_pnl"], use_container_width=True)

with col2:
st.plotly_chart(charts["delegation"], use_container_width=True)
st.plotly_chart(charts["credit_capacity"], use_container_width=True)
st.plotly_chart(charts["pnl"], use_container_width=True)
# st.plotly_chart(charts["apr"], use_container_width=True)

st.markdown("## Top Delegators")
st.dataframe(
Expand Down
2 changes: 1 addition & 1 deletion dashboard/modules/base_mainnet/perp_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def make_charts(data):


def main():
st.markdown("## Perps Account Lookup")
st.markdown("## V3 Perps Accounts")
data = fetch_data(filters)

## date filter
Expand Down
2 changes: 1 addition & 1 deletion dashboard/modules/base_mainnet/perp_integrators.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def make_charts(data):

def main():
## title
st.markdown("## Perps V3 Integrators")
st.markdown("## V3 Perps Integrators")

## inputs
with st.expander("Filters") as expander:
Expand Down
2 changes: 1 addition & 1 deletion dashboard/modules/base_mainnet/perp_keepers.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def make_charts(data):

def main():
## title
st.markdown("## Perps V3 Keepers")
st.markdown("## V3 Perps Keepers")

## inputs
with st.expander("Filters") as expander:
Expand Down
15 changes: 5 additions & 10 deletions dashboard/modules/base_mainnet/perp_markets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pandas as pd
import plotly.express as px
from datetime import datetime, timedelta
from utils import chart_lines, chart_market_oi, export_data
from utils import chart_lines, chart_oi, export_data
from utils import get_connection

## set default filters
Expand Down Expand Up @@ -54,22 +54,17 @@ def make_charts(data, asset):
df = data["market_history"][data["market_history"]["market_symbol"] == asset]

return {
"funding": chart_lines(
df,
"ts",
["funding_rate"],
"Funding Rate",
),
"price": chart_lines(df, "ts", ["price"], "Price"),
"funding": chart_lines(df, "ts", ["funding_rate"], "Funding Rate", smooth=True),
"price": chart_lines(df, "ts", ["price"], "Price", smooth=True),
"skew": chart_lines(df, "ts", ["skew"], "Market Skew"),
"oi": chart_lines(df, "ts", ["size_usd"], "Open Interest $"),
"oi_pct": chart_market_oi(data["market_history"], asset),
"oi_pct": chart_oi(data["market_history"], "ts", "Open Interest %"),
}


def main():
## title
st.markdown("## Perps V3 Markets")
st.markdown("## V3 Perps Markets")

## inputs
with st.expander("Filters") as expander:
Expand Down
2 changes: 1 addition & 1 deletion dashboard/modules/base_mainnet/perp_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def make_charts(data):

def main():
## title
st.markdown("## Perps V3 Market Monitor")
st.markdown("## V3 Perps Monitor")

## inputs
with st.expander("Filters") as expander:
Expand Down
117 changes: 117 additions & 0 deletions dashboard/modules/base_mainnet/perp_stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import streamlit as st
import pandas as pd
import sqlite3
import plotly.express as px
from datetime import datetime, timedelta
from utils import get_connection
from utils import chart_bars, chart_lines, export_data

## set default filters
filters = {
"start_date": datetime.today().date() - timedelta(days=14),
"end_date": datetime.today().date() + timedelta(days=1),
"resolution": "daily",
}


## data
@st.cache_data(ttl=1)
def fetch_data(filters):
# get filters
start_date = filters["start_date"]
end_date = filters["end_date"]
resolution = filters["resolution"]

# initialize connection
db = get_connection()

# read data
df_stats = pd.read_sql_query(
f"""
SELECT
ts,
volume,
trades,
fees,
liquidated_accounts,
liquidation_rewards,
cumulative_fees,
cumulative_volume
FROM base_mainnet.fct_perp_stats_{resolution}
WHERE ts >= '{start_date}' and ts <= '{end_date}'
""",
db,
)

db.close()

return {
"stats": df_stats,
}


@st.cache_data(ttl=1)
def make_charts(data):
return {
"volume": chart_bars(data["stats"], "ts", ["volume"], "Volume"),
"cumulative_volume": chart_lines(
data["stats"], "ts", ["cumulative_volume"], "Cumulative Volume", smooth=True
),
"cumulative_fees": chart_lines(
data["stats"], "ts", ["cumulative_fees"], "Cumulative Fees", smooth=True
),
"fees": chart_bars(data["stats"], "ts", ["fees"], "Exchange Fees"),
"trades": chart_bars(data["stats"], "ts", ["trades"], "Trades"),
"account_liquidations": chart_bars(
data["stats"], "ts", ["liquidated_accounts"], "Account Liquidations"
),
"liquidation_rewards": chart_bars(
data["stats"], "ts", ["liquidation_rewards"], "Liquidation Rewards"
),
}


def main():
## title
st.markdown("## V3 Perps Stats")

## inputs
with st.expander("Filters") as expander:
# resolution
filters["resolution"] = st.radio("Resolution", ["daily", "hourly"])

# date filter
filt_col1, filt_col2 = st.columns(2)
with filt_col1:
filters["start_date"] = st.date_input("Start", filters["start_date"])

with filt_col2:
filters["end_date"] = st.date_input("End", filters["end_date"])

## fetch data
data = fetch_data(filters)

## make the charts
charts = make_charts(data)

## display
col1, col2 = st.columns(2)

with col1:
st.plotly_chart(charts["cumulative_volume"], use_container_width=True)
st.plotly_chart(charts["cumulative_fees"], use_container_width=True)
st.plotly_chart(charts["account_liquidations"], use_container_width=True)
st.plotly_chart(charts["liquidation_rewards"], use_container_width=True)
pass

with col2:
st.plotly_chart(charts["volume"], use_container_width=True)
st.plotly_chart(charts["fees"], use_container_width=True)
st.plotly_chart(charts["trades"], use_container_width=True)
pass

## export
exports = [{"title": export, "df": data[export]} for export in data.keys()]
with st.expander("Exports"):
for export in exports:
export_data(export["title"], export["df"])
2 changes: 1 addition & 1 deletion dashboard/modules/base_sepolia/perp_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def make_charts(data):


def main():
st.markdown("## Perps Account Lookup")
st.markdown("## V3 Perps Accounts")
data = fetch_data(filters)

## date filter
Expand Down
2 changes: 1 addition & 1 deletion dashboard/modules/base_sepolia/perp_integrators.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def make_charts(data):

def main():
## title
st.markdown("## Perps V3 Integrators")
st.markdown("## V3 Perps Integrators")

## inputs
with st.expander("Filters") as expander:
Expand Down
2 changes: 1 addition & 1 deletion dashboard/modules/base_sepolia/perp_keepers.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def make_charts(data):

def main():
## title
st.markdown("## Perps V3 Keepers")
st.markdown("## V3 Perps Keepers")

## inputs
with st.expander("Filters") as expander:
Expand Down
Loading

0 comments on commit ac54ad4

Please sign in to comment.