agent0.chainsync.dashboard

Dashboard utilities

Submodules

Functions

build_pool_dashboard(→ dict[str, pandas.DataFrame])

Builds the dataframes for the main dashboard page that focuses on pools.

build_wallet_dashboard(→ dict[str, pandas.DataFrame])

Builds the dataframes for the main dashboard page that focuses on pools.

plot_ohlcv(→ None)

Plots the ohlcv plot.

plot_outstanding_positions(data, axes)

Returns the fixed rate plot.

plot_rates(→ None)

Plots the fixed and variable rates.

plot_share_price(→ None)

Plots the vault share price.

reduce_plot_data(→ pandas.DataFrame)

Reduces the data we plot by looking for redundant rows with no change, and only return x and y columns

abbreviate_address(…)

Given a series of addresses, return the corresponding addresses in a human readable way.

build_user_mapping(→ pandas.DataFrame)

Builds a mapping from wallet addresses to usernames and any additional aliases

map_addresses(…)

Helper function to look up the aliases for an address.

Package Contents

agent0.chainsync.dashboard.build_pool_dashboard(hyperdrive_address: str, session: sqlalchemy.orm.Session, max_live_blocks: int = 20000, max_ticker_rows: int = 10000) dict[str, pandas.DataFrame]

Builds the dataframes for the main dashboard page that focuses on pools.

Parameters:
  • hyperdrive_address (str) – The hyperdrive address to filter the results on.

  • session (Session) – The initialized sqlalchemy db session object.

  • max_live_blocks (int, optional) – The maximum look-back length in blocks. Defaults to 5000.

  • max_ticker_rows (int, optional) – The maximum number of ticker rows to show. Defaults to 1000.

Returns:

A collection of dataframes ready to be shown in the dashboard.

Return type:

dict[str, DataFrame]

agent0.chainsync.dashboard.build_wallet_dashboard(wallet_addresses: list[str], session: sqlalchemy.orm.Session, user_map: pandas.DataFrame | None = None, max_plot_blocks: int = 5000, max_ticker_rows: int = 1000) dict[str, pandas.DataFrame]

Builds the dataframes for the main dashboard page that focuses on pools.

Parameters:
  • wallet_addresses (list[str]) – The list of wallet addresses to filter the results on.

  • session (Session) – The initialized sqlalchemy db session object.

  • user_map (pd.DataFrame | None, optional) – The mapping of wallet addresses to usernames. Will build from db if None.

  • max_plot_blocks (int, optional) – The maximum number of blocks to look in the past for plotting. Defaults to 5000.

  • max_ticker_rows (int, optional) – The maximum number of ticker rows to show. Defaults to 1000.

Returns:

A collection of dataframes ready to be shown in the dashboard.

Return type:

dict[str, DataFrame]

agent0.chainsync.dashboard.plot_ohlcv(ohlcv: pandas.DataFrame, ohlcv_ax: matplotlib.axes.Axes) None

Plots the ohlcv plot.

Parameters:
  • ohlcv (pd.DataFrame) – The ohlcv dataframe to plot.

  • ohlcv_ax (Axes) – The matplotlib axes to plot on.

agent0.chainsync.dashboard.plot_outstanding_positions(data: pandas.DataFrame, axes: matplotlib.axes.Axes)

Returns the fixed rate plot.

Parameters:
  • data (pd.DataFrame) – The data to plot.

  • axes (Axes) – The matplotlib axes to plot on.

agent0.chainsync.dashboard.plot_rates(fixed_rate: pandas.DataFrame, variable_rate: pandas.DataFrame, axes: matplotlib.axes.Axes) None

Plots the fixed and variable rates.

Parameters:
  • fixed_rate (pd.DataFrame) – The fixed rate dataframe.

  • variable_rate (pd.DataFrame) – The variable rate dataframe.

  • axes (Axes) – The matplotlib axes to plot on.

agent0.chainsync.dashboard.plot_share_price(vault_share_price: pandas.DataFrame, axes: matplotlib.axes.Axes) None

Plots the vault share price.

Parameters:
  • vault_share_price (pd.DataFrame) – The vault_share_price dataframe.

  • axes (Axes) – The matplotlib axes to plot on.

agent0.chainsync.dashboard.reduce_plot_data(data: pandas.DataFrame, x_column_name: str, y_column_name: str) pandas.DataFrame

Reduces the data we plot by looking for redundant rows with no change, and only return x and y columns

Parameters:
  • data (pd.DataFrame) – The data to plot.

  • x_column_name (str) – The name of the x column

  • y_column_name (str) – The name of the y column

Returns:

The reduced data

Return type:

pd.DataFrame

agent0.chainsync.dashboard.abbreviate_address(address: pandas.Series) pandas.Series
agent0.chainsync.dashboard.abbreviate_address(address: str) str

Given a series of addresses, return the corresponding addresses in a human readable way.

Parameters:

address (pd.Series | str)

Returns:

The corresponding abbreviated addresses in the same order (with the same indices), or a single abbreviated address string.

Return type:

pd.Series | str

agent0.chainsync.dashboard.build_user_mapping(addresses: pandas.Series, addr_to_username: pandas.DataFrame) pandas.DataFrame

Builds a mapping from wallet addresses to usernames and any additional aliases that address may have.

Given a pd.Series of wallet addresses, we build a corresponding dataframe that contains the mapping between that wallet address and any additional aliases that address may have. Specifically, the output dataframe contains the following columns:

address: The original wallet address abbr_address: The wallet address abbreviated (e.g., 0x0000…0000) username: The one-to-one mapped username for that address gathered from the addr_to_username postgres table format_name: A formatted name for labels combining username with abbr_address

If the address doesn’t exist in the lookup, the username and user will reflect the abbr_address.

Parameters:
  • addresses (pd.Series) – The list of addresses to build the user map for.

  • addr_to_username (pd.DataFrame) – The mapping of addresses to username returned from get_addr_to_username.

Returns:

A dataframe with 4 columns (address, abbr_address, username, format_name)

Return type:

pd.Dataframe

agent0.chainsync.dashboard.map_addresses(key: str, user_map: pandas.DataFrame, map_column=None) pandas.Series
agent0.chainsync.dashboard.map_addresses(key: pandas.Series | list, user_map: pandas.DataFrame, map_column=None) pandas.Series

Helper function to look up the aliases for an address.

Parameters:
  • key (pd.Series | list | str) – The pd.Series, list, or individual key(s) to look up.

  • user_map (pd.DataFrame) – The lookup dataframe returned from build_user_mapping

  • map_column (str | None) – The column that key is mapped to. If None, will default to address.

Returns:

A dataframe or series with 5 columns (address, abbr_address, username, user, format_name) in the same order as the input addresses series. Will return a dataframe if a series or list is passed in Will return a series if a single key is passed in

Return type:

pd.Dataframe | pd.Series