General: Stats: Stats Schema - FlipsideCrypto/fsc-evm GitHub Wiki
This guide covers the Stats Pipeline, which involves Silver and Gold DBT models and aggregates metrics by category, enabling users to easily analyze blockchain stats, while reducing computational resources and requirements.
<TO_DO>
This guide covers how to build and deploy all tables and views associated with the Stats pipeline, in each respective Blockchain's repository, primarily with references to the Silver and Gold fsc_evm stats macros.
Please reference the Stats Pipeline
section above for more information regarding how the pipeline was established, and how each underlying model is intended to function.
- We're constantly brainstorming and researching new stats tables to build, typically based on frequently ran user queries or community requests for aggregated data.
- The implementation steps are not specific to a single stats table, but serve as a general guide on how to build and deploy any stats table or view.
-
Silver Schema (
silver_stats
)- Each
silver
model should be materialized as anincremental
table, with the following example configuration parameters. Note, the config may change dependent on the underlying logic required for a specific Stats table.
{{ config( materialized = 'incremental', incremental_strategy = 'delete+insert', unique_key = "block_timestamp_hour", cluster_by = ['block_timestamp_hour::DATE'], tags = ['curated'] ) }}
- Add the following Silver (
silver_stats
) schema models (silver_stats__<table_name>
). Please reference fsc_evm stats macros.-
silver_stats__core_metrics_hourly.sql
: Transaction-level, core metrics associated with a specific blockchain(s). Directly referencessilver__transactions.sql
and includes incremental logic onmodified_timestamp
.- This model apply aggregation functions (COUNT, SUM, MIN, MAX etc.) to total various blockchain metrics on an hourly basis.
- Define or update the definitions for the following variables in
dbt_project.yml
:
## STATS STATS_TOKEN_ADDRESS: '0xTokenAddress' ### REQUIRED
-
- Add the
.yml
file for the silver model, which includes DBT tests.
- Each
-
Gold Schema (
core
)- The Gold
stats
model should be materialized as aview
, includes thepersist_docs
andmeta
params for database level tags.
{{ config( materialized = 'view', persist_docs ={ "relation": true, "columns": true }, meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'STATS, METRICS, CORE, HOURLY', } } } ) }}
- To add the following
stats
schema model (stats__<table_name>
), please reference fsc_evm stats macros.-
stats__ez_core_metrics_hourly.sql
: Includes an LEFT JOIN onsilver_stats__core_metrics_hourly.sql
andprice__ez_prices_hourly.sql
onblock_timestamp_hour
/hour
andtoken_address
to enable native asset pricing calculations / columns.
-
- Add the
.yml
file for the gold model, which includes table and column level descriptions.
- The Gold