Skip to content

Commit

Permalink
Finalizes rf4 impact metric schema (#1708)
Browse files Browse the repository at this point in the history
* feat: add log version of select impact metrics

* chore: add trusted user model and AA related copy to descriptions

* add: log metrics and copy

* feat: include AA events in relevant metrics
  • Loading branch information
ccerv1 authored Jun 24, 2024
1 parent 81a8df3 commit 03a7e4c
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
with txns as (
with transactions_std as (
select
bucket_day,
project_id,
from_artifact_name,
bucket_day
from_artifact_name as address
from {{ ref('rf4_events_daily_to_project') }}
where
event_type = 'CONTRACT_INVOCATION_SUCCESS_DAILY_COUNT'
and bucket_day >= '2023-10-01'
),

transactions_4337 as (
select
bucket_day,
project_id,
to_artifact_name as address
from {{ ref('rf4_4337_events') }}
where
event_type = '4337_INTERACTION'
and bucket_day >= '2023-10-01'
),

txns as (
select * from transactions_std
union all
select * from transactions_4337
),

daas as (
select
project_id,
bucket_day,
COUNT(distinct from_artifact_name) as active_addresses
COUNT(distinct address) as active_addresses
from txns
group by
project_id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
{# TODO: double check the math on total_months #}
with txns as (
with transactions_std as (
select
project_id,
from_artifact_name,
from_artifact_name as address,
TIMESTAMP_TRUNC(bucket_day, month) as bucket_month
from {{ ref('rf4_events_daily_to_project') }}
where
event_type = 'CONTRACT_INVOCATION_SUCCESS_DAILY_COUNT'
and bucket_day >= '2023-10-01'
),

transactions_4337 as (
select
project_id,
to_artifact_name as address,
TIMESTAMP_TRUNC(bucket_day, month) as bucket_month
from {{ ref('rf4_4337_events') }}
where
event_type = '4337_INTERACTION'
and bucket_day >= '2023-10-01'
),

txns as (
select * from transactions_std
union all
select * from transactions_4337
),

maas as (
select
project_id,
bucket_month,
COUNT(distinct from_artifact_name) as active_addresses
COUNT(distinct address) as active_addresses
from txns
group by
project_id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,49 @@
with txns as (
with transactions_std as (
select
project_id,
from_artifact_name,
bucket_day,
project_id,
from_artifact_name as address,
TIMESTAMP_TRUNC(bucket_day, month) as bucket_month
from {{ ref('rf4_events_daily_to_project') }}
where
event_type = 'CONTRACT_INVOCATION_SUCCESS_DAILY_COUNT'
and bucket_day >= '2023-10-01'
),

transactions_4337 as (
select
bucket_day,
project_id,
to_artifact_name as address,
TIMESTAMP_TRUNC(bucket_day, month) as bucket_month
from {{ ref('rf4_4337_events') }}
where
event_type = '4337_INTERACTION'
and bucket_day >= '2023-10-01'
),

txns as (
select * from transactions_std
union all
select * from transactions_4337
),

address_stats as (
select
project_id,
from_artifact_name,
address,
COUNT(distinct bucket_month) as months,
MAX(bucket_day) as last_day
from txns
group by
project_id,
from_artifact_name
address
)

select
project_id,
'recurring_addresses' as metric,
COUNT(distinct from_artifact_name) as amount
COUNT(distinct address) as amount
from address_stats
where
months >= 3
Expand Down
41 changes: 37 additions & 4 deletions warehouse/dbt/models/marts/superchain/metrics/rf4_transactions.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
with transactions_std as (
select
project_id,
SUM(amount) as amount
from {{ ref('rf4_events_daily_to_project') }}
where
event_type = 'CONTRACT_INVOCATION_SUCCESS_DAILY_COUNT'
and bucket_day >= '2023-10-01'
group by
project_id
),

transactions_4337 as (
select
project_id,
SUM(amount) as amount
from {{ ref('rf4_4337_events') }}
where
event_type = '4337_INTERACTION'
and bucket_day >= '2023-10-01'
group by
project_id
),

transactions as (
select
project_id,
amount
from transactions_std
union all
select
project_id,
amount
from transactions_4337
)

select
project_id,
'transaction_count' as metric,
SUM(amount) as amount
from {{ ref('rf4_events_daily_to_project') }}
where
event_type = 'CONTRACT_INVOCATION_SUCCESS_DAILY_COUNT'
and bucket_day >= '2023-10-01'
from transactions
group by
project_id
2 changes: 1 addition & 1 deletion warehouse/dbt/models/marts/superchain/rf4_4337_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ select
from_artifact_name,
to_artifact_name,
event_source,
'4337 INTERACTION' as event_type,
'4337_INTERACTION' as event_type,
count(distinct transaction_hash) as amount
from raw_4337_events
where project_id is not null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ select
pivot_metrics.recurring_addresses,
pivot_metrics.trusted_recurring_users,
pivot_metrics.power_user_addresses,
pivot_metrics.openrank_trusted_users_count
pivot_metrics.openrank_trusted_users_count,
COALESCE(LOG10(pivot_metrics.gas_fees + 1), 0) as log_gas_fees,
COALESCE(LOG10(pivot_metrics.transaction_count + 1), 0)
as log_transaction_count,
COALESCE(LOG10(pivot_metrics.trusted_transaction_count + 1), 0)
as log_trusted_transaction_count
from pivot_metrics
left join {{ ref('projects_v1') }}
on pivot_metrics.project_id = projects_v1.project_id
Expand Down
Loading

0 comments on commit 03a7e4c

Please sign in to comment.