protocol level stats (#500)

* protocol level

* use new stats

* typo
This commit is contained in:
eric-laurello 2025-07-23 15:57:41 -04:00 committed by GitHub
parent 1f906c20ee
commit b49b884663
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 444 additions and 0 deletions

View File

@ -0,0 +1,27 @@
{% macro get_protocol_metrics_daily(blockchain_filter) %}
SELECT
block_date AS day_,
protocol AS protocol,
num_users AS n_users,
num_quality_users AS n_quality_users,
transaction_count AS n_transactions,
quality_transaction_count AS n_quality_transactions,
inflow_usd AS usd_inflows,
outflow_usd AS usd_outflows,
net_usd_inflow,
gross_usd_volume,
quality_inflow_usd AS quality_usd_inflows,
quality_outflow_usd AS quality_usd_outflows,
quality_net_usd_inflow AS quality_net_usd,
quality_gross_usd_volume AS quality_gross_usd
FROM
{{ ref('stats__ez_transfer_protocol_metrics_daily') }} A full
OUTER JOIN {{ ref('stats__ez_activity_protocol_metrics_daily') }}
b USING (
blockchain,
protocol,
block_date
)
WHERE
blockchain = '{{ blockchain_filter }}'
{% endmacro %}

View File

@ -0,0 +1,5 @@
{{ config(
materialized = 'view',
tags = ['metrics_daily']
) }}
{{ get_protocol_metrics_daily('arbitrum') }}

View File

@ -0,0 +1,47 @@
version: 2
models:
- name: chain_stats__ez_arbitrum_protocol_metrics
description: 'Daily aggregated protocol-level metrics for Arbitrum blockchain including user activity, transaction counts, and token flow data. Combines protocol interaction data with Flipside scoring to distinguish between total activity and quality user activity (Flipside score >= 4). Metrics track inflows, outflows, and user engagement at the protocol level.'
columns:
- name: day_
description: 'The date in YYYY-MM-DD format - all stats are aggregated at the daily level'
- name: protocol
description: 'Protocol names including versioning information (e.g. Uniswap v2, v3, etc.). Note: protocol names may not always match protocol names in other tables like dex_volume'
- name: n_users
description: 'Number of unique addresses submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_users
description: 'Number of unique quality addresses with Flipside score >= 4 submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_transactions
description: 'Number of unique transactions that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_transactions
description: 'Number of unique transactions by addresses with Flipside score >= 4 that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: usd_inflows
description: 'USD value of tokens sent INTO this protocol from all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: usd_outflows
description: 'USD value of tokens sent FROM this protocol to all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: net_usd_inflow
description: 'USD inflows minus outflows. Note: Price effects may cause net USD and token-level net changes to differ in direction (rare but possible with large, fast price changes)'
- name: gross_usd_volume
description: 'Total USD volume calculated as inflows plus outflows'
- name: quality_usd_inflows
description: 'USD value of token inflows from quality addresses with Flipside score >= 4'
- name: quality_usd_outflows
description: 'USD value of token outflows to quality addresses with Flipside score >= 4'
- name: quality_net_usd
description: 'Quality USD inflows minus quality USD outflows. Price effects may apply similar to net_usd_inflow'
- name: quality_gross_usd
description: 'Total quality USD volume calculated as quality inflows plus quality outflows'

View File

@ -0,0 +1,5 @@
{{ config(
materialized = 'view',
tags = ['metrics_daily']
) }}
{{ get_protocol_metrics_daily('avalanche') }}

View File

@ -0,0 +1,47 @@
version: 2
models:
- name: chain_stats__ez_avalanche_protocol_metrics
description: 'Daily aggregated protocol-level metrics for Avlanache blockchain including user activity, transaction counts, and token flow data. Combines protocol interaction data with Flipside scoring to distinguish between total activity and quality user activity (Flipside score >= 4). Metrics track inflows, outflows, and user engagement at the protocol level.'
columns:
- name: day_
description: 'The date in YYYY-MM-DD format - all stats are aggregated at the daily level'
- name: protocol
description: 'Protocol names including versioning information (e.g. Uniswap v2, v3, etc.). Note: protocol names may not always match protocol names in other tables like dex_volume'
- name: n_users
description: 'Number of unique addresses submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_users
description: 'Number of unique quality addresses with Flipside score >= 4 submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_transactions
description: 'Number of unique transactions that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_transactions
description: 'Number of unique transactions by addresses with Flipside score >= 4 that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: usd_inflows
description: 'USD value of tokens sent INTO this protocol from all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: usd_outflows
description: 'USD value of tokens sent FROM this protocol to all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: net_usd_inflow
description: 'USD inflows minus outflows. Note: Price effects may cause net USD and token-level net changes to differ in direction (rare but possible with large, fast price changes)'
- name: gross_usd_volume
description: 'Total USD volume calculated as inflows plus outflows'
- name: quality_usd_inflows
description: 'USD value of token inflows from quality addresses with Flipside score >= 4'
- name: quality_usd_outflows
description: 'USD value of token outflows to quality addresses with Flipside score >= 4'
- name: quality_net_usd
description: 'Quality USD inflows minus quality USD outflows. Price effects may apply similar to net_usd_inflow'
- name: quality_gross_usd
description: 'Total quality USD volume calculated as quality inflows plus quality outflows'

View File

@ -0,0 +1,5 @@
{{ config(
materialized = 'view',
tags = ['metrics_daily']
) }}
{{ get_protocol_metrics_daily('base') }}

View File

@ -0,0 +1,47 @@
version: 2
models:
- name: chain_stats__ez_base_protocol_metrics
description: 'Daily aggregated protocol-level metrics for Base blockchain including user activity, transaction counts, and token flow data. Combines protocol interaction data with Flipside scoring to distinguish between total activity and quality user activity (Flipside score >= 4). Metrics track inflows, outflows, and user engagement at the protocol level.'
columns:
- name: day_
description: 'The date in YYYY-MM-DD format - all stats are aggregated at the daily level'
- name: protocol
description: 'Protocol names including versioning information (e.g. Uniswap v2, v3, etc.). Note: protocol names may not always match protocol names in other tables like dex_volume'
- name: n_users
description: 'Number of unique addresses submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_users
description: 'Number of unique quality addresses with Flipside score >= 4 submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_transactions
description: 'Number of unique transactions that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_transactions
description: 'Number of unique transactions by addresses with Flipside score >= 4 that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: usd_inflows
description: 'USD value of tokens sent INTO this protocol from all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: usd_outflows
description: 'USD value of tokens sent FROM this protocol to all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: net_usd_inflow
description: 'USD inflows minus outflows. Note: Price effects may cause net USD and token-level net changes to differ in direction (rare but possible with large, fast price changes)'
- name: gross_usd_volume
description: 'Total USD volume calculated as inflows plus outflows'
- name: quality_usd_inflows
description: 'USD value of token inflows from quality addresses with Flipside score >= 4'
- name: quality_usd_outflows
description: 'USD value of token outflows to quality addresses with Flipside score >= 4'
- name: quality_net_usd
description: 'Quality USD inflows minus quality USD outflows. Price effects may apply similar to net_usd_inflow'
- name: quality_gross_usd
description: 'Total quality USD volume calculated as quality inflows plus quality outflows'

View File

@ -0,0 +1,5 @@
{{ config(
materialized = 'view',
tags = ['metrics_daily']
) }}
{{ get_protocol_metrics_daily('bsc') }}

View File

@ -0,0 +1,47 @@
version: 2
models:
- name: chain_stats__ez_bsc_protocol_metrics
description: 'Daily aggregated protocol-level metrics for Bsc blockchain including user activity, transaction counts, and token flow data. Combines protocol interaction data with Flipside scoring to distinguish between total activity and quality user activity (Flipside score >= 4). Metrics track inflows, outflows, and user engagement at the protocol level.'
columns:
- name: day_
description: 'The date in YYYY-MM-DD format - all stats are aggregated at the daily level'
- name: protocol
description: 'Protocol names including versioning information (e.g. Uniswap v2, v3, etc.). Note: protocol names may not always match protocol names in other tables like dex_volume'
- name: n_users
description: 'Number of unique addresses submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_users
description: 'Number of unique quality addresses with Flipside score >= 4 submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_transactions
description: 'Number of unique transactions that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_transactions
description: 'Number of unique transactions by addresses with Flipside score >= 4 that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: usd_inflows
description: 'USD value of tokens sent INTO this protocol from all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: usd_outflows
description: 'USD value of tokens sent FROM this protocol to all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: net_usd_inflow
description: 'USD inflows minus outflows. Note: Price effects may cause net USD and token-level net changes to differ in direction (rare but possible with large, fast price changes)'
- name: gross_usd_volume
description: 'Total USD volume calculated as inflows plus outflows'
- name: quality_usd_inflows
description: 'USD value of token inflows from quality addresses with Flipside score >= 4'
- name: quality_usd_outflows
description: 'USD value of token outflows to quality addresses with Flipside score >= 4'
- name: quality_net_usd
description: 'Quality USD inflows minus quality USD outflows. Price effects may apply similar to net_usd_inflow'
- name: quality_gross_usd
description: 'Total quality USD volume calculated as quality inflows plus quality outflows'

View File

@ -0,0 +1,5 @@
{{ config(
materialized = 'view',
tags = ['metrics_daily']
) }}
{{ get_protocol_metrics_daily('ethereum') }}

View File

@ -0,0 +1,47 @@
version: 2
models:
- name: chain_stats__ez_ethereum_protocol_metrics
description: 'Daily aggregated protocol-level metrics for Ethereum blockchain including user activity, transaction counts, and token flow data. Combines protocol interaction data with Flipside scoring to distinguish between total activity and quality user activity (Flipside score >= 4). Metrics track inflows, outflows, and user engagement at the protocol level.'
columns:
- name: day_
description: 'The date in YYYY-MM-DD format - all stats are aggregated at the daily level'
- name: protocol
description: 'Protocol names including versioning information (e.g. Uniswap v2, v3, etc.). Note: protocol names may not always match protocol names in other tables like dex_volume'
- name: n_users
description: 'Number of unique addresses submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_users
description: 'Number of unique quality addresses with Flipside score >= 4 submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_transactions
description: 'Number of unique transactions that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_transactions
description: 'Number of unique transactions by addresses with Flipside score >= 4 that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: usd_inflows
description: 'USD value of tokens sent INTO this protocol from all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: usd_outflows
description: 'USD value of tokens sent FROM this protocol to all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: net_usd_inflow
description: 'USD inflows minus outflows. Note: Price effects may cause net USD and token-level net changes to differ in direction (rare but possible with large, fast price changes)'
- name: gross_usd_volume
description: 'Total USD volume calculated as inflows plus outflows'
- name: quality_usd_inflows
description: 'USD value of token inflows from quality addresses with Flipside score >= 4'
- name: quality_usd_outflows
description: 'USD value of token outflows to quality addresses with Flipside score >= 4'
- name: quality_net_usd
description: 'Quality USD inflows minus quality USD outflows. Price effects may apply similar to net_usd_inflow'
- name: quality_gross_usd
description: 'Total quality USD volume calculated as quality inflows plus quality outflows'

View File

@ -0,0 +1,5 @@
{{ config(
materialized = 'view',
tags = ['metrics_daily']
) }}
{{ get_protocol_metrics_daily('near') }}

View File

@ -0,0 +1,47 @@
version: 2
models:
- name: chain_stats__ez_near_protocol_metrics
description: 'Daily aggregated protocol-level metrics for Near blockchain including user activity, transaction counts, and token flow data. Combines protocol interaction data with Flipside scoring to distinguish between total activity and quality user activity (Flipside score >= 4). Metrics track inflows, outflows, and user engagement at the protocol level.'
columns:
- name: day_
description: 'The date in YYYY-MM-DD format - all stats are aggregated at the daily level'
- name: protocol
description: 'Protocol names including versioning information (e.g. Uniswap v2, v3, etc.). Note: protocol names may not always match protocol names in other tables like dex_volume'
- name: n_users
description: 'Number of unique addresses submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_users
description: 'Number of unique quality addresses with Flipside score >= 4 submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_transactions
description: 'Number of unique transactions that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_transactions
description: 'Number of unique transactions by addresses with Flipside score >= 4 that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: usd_inflows
description: 'USD value of tokens sent INTO this protocol from all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: usd_outflows
description: 'USD value of tokens sent FROM this protocol to all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: net_usd_inflow
description: 'USD inflows minus outflows. Note: Price effects may cause net USD and token-level net changes to differ in direction (rare but possible with large, fast price changes)'
- name: gross_usd_volume
description: 'Total USD volume calculated as inflows plus outflows'
- name: quality_usd_inflows
description: 'USD value of token inflows from quality addresses with Flipside score >= 4'
- name: quality_usd_outflows
description: 'USD value of token outflows to quality addresses with Flipside score >= 4'
- name: quality_net_usd
description: 'Quality USD inflows minus quality USD outflows. Price effects may apply similar to net_usd_inflow'
- name: quality_gross_usd
description: 'Total quality USD volume calculated as quality inflows plus quality outflows'

View File

@ -0,0 +1,5 @@
{{ config(
materialized = 'view',
tags = ['metrics_daily']
) }}
{{ get_protocol_metrics_daily('optimism') }}

View File

@ -0,0 +1,47 @@
version: 2
models:
- name: chain_stats__ez_optimism_protocol_metrics
description: 'Daily aggregated protocol-level metrics for Optimism blockchain including user activity, transaction counts, and token flow data. Combines protocol interaction data with Flipside scoring to distinguish between total activity and quality user activity (Flipside score >= 4). Metrics track inflows, outflows, and user engagement at the protocol level.'
columns:
- name: day_
description: 'The date in YYYY-MM-DD format - all stats are aggregated at the daily level'
- name: protocol
description: 'Protocol names including versioning information (e.g. Uniswap v2, v3, etc.). Note: protocol names may not always match protocol names in other tables like dex_volume'
- name: n_users
description: 'Number of unique addresses submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_users
description: 'Number of unique quality addresses with Flipside score >= 4 submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_transactions
description: 'Number of unique transactions that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_transactions
description: 'Number of unique transactions by addresses with Flipside score >= 4 that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: usd_inflows
description: 'USD value of tokens sent INTO this protocol from all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: usd_outflows
description: 'USD value of tokens sent FROM this protocol to all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: net_usd_inflow
description: 'USD inflows minus outflows. Note: Price effects may cause net USD and token-level net changes to differ in direction (rare but possible with large, fast price changes)'
- name: gross_usd_volume
description: 'Total USD volume calculated as inflows plus outflows'
- name: quality_usd_inflows
description: 'USD value of token inflows from quality addresses with Flipside score >= 4'
- name: quality_usd_outflows
description: 'USD value of token outflows to quality addresses with Flipside score >= 4'
- name: quality_net_usd
description: 'Quality USD inflows minus quality USD outflows. Price effects may apply similar to net_usd_inflow'
- name: quality_gross_usd
description: 'Total quality USD volume calculated as quality inflows plus quality outflows'

View File

@ -0,0 +1,5 @@
{{ config(
materialized = 'view',
tags = ['metrics_daily']
) }}
{{ get_protocol_metrics_daily('polygon') }}

View File

@ -0,0 +1,47 @@
version: 2
models:
- name: chain_stats__ez_polygon_protocol_metrics
description: 'Daily aggregated protocol-level metrics for Polygon blockchain including user activity, transaction counts, and token flow data. Combines protocol interaction data with Flipside scoring to distinguish between total activity and quality user activity (Flipside score >= 4). Metrics track inflows, outflows, and user engagement at the protocol level.'
columns:
- name: day_
description: 'The date in YYYY-MM-DD format - all stats are aggregated at the daily level'
- name: protocol
description: 'Protocol names including versioning information (e.g. Uniswap v2, v3, etc.). Note: protocol names may not always match protocol names in other tables like dex_volume'
- name: n_users
description: 'Number of unique addresses submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_users
description: 'Number of unique quality addresses with Flipside score >= 4 submitting a transaction that interacts with any protocol contract. Same address can be counted across different protocols, but never more than once within a single protocol'
- name: n_transactions
description: 'Number of unique transactions that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: n_quality_transactions
description: 'Number of unique transactions by addresses with Flipside score >= 4 that emit 1 or more events from any protocol contract. Same transaction can be counted across different protocols, but never more than once within a single protocol'
- name: usd_inflows
description: 'USD value of tokens sent INTO this protocol from all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: usd_outflows
description: 'USD value of tokens sent FROM this protocol to all other addresses/protocols/contracts (excludes transfers within the same protocol)'
- name: net_usd_inflow
description: 'USD inflows minus outflows. Note: Price effects may cause net USD and token-level net changes to differ in direction (rare but possible with large, fast price changes)'
- name: gross_usd_volume
description: 'Total USD volume calculated as inflows plus outflows'
- name: quality_usd_inflows
description: 'USD value of token inflows from quality addresses with Flipside score >= 4'
- name: quality_usd_outflows
description: 'USD value of token outflows to quality addresses with Flipside score >= 4'
- name: quality_net_usd
description: 'Quality USD inflows minus quality USD outflows. Price effects may apply similar to net_usd_inflow'
- name: quality_gross_usd
description: 'Total quality USD volume calculated as quality inflows plus quality outflows'

View File

@ -601,6 +601,7 @@ sources:
schema: onchain_scores
tables:
- name: all_scores
- name: protocol_metrics
#=============================================================================
# ECLIPSE