General: Stats: Stats Schema - FlipsideCrypto/fsc-evm GitHub Wiki

Stats Pipeline

Summary:

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.

Best Practices, Tips & Tricks:

<TO_DO>

Implementation Steps, Variables & Notes:

Examples, References & Sources:


Stats Table Set Up in Chain Specific Repos

Summary:

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.

Best Practices, Tips & Tricks:

  • 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.

Implementation Steps, Variables & Notes:

  1. Silver Schema (silver_stats)

    • Each silver model should be materialized as an incremental 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 references silver__transactions.sql and includes incremental logic on modified_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.
  2. Gold Schema (core)

    • The Gold stats model should be materialized as a view, includes the persist_docs and meta 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 on silver_stats__core_metrics_hourly.sql and price__ez_prices_hourly.sql on block_timestamp_hour / hour and token_address to enable native asset pricing calculations / columns.
    • Add the .yml file for the gold model, which includes table and column level descriptions.

Examples, References & Sources:

⚠️ **GitHub.com Fallback** ⚠️