Skip to content

Commit

Permalink
feat(dbt): create 4337 playground model (#2325)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccerv1 authored Oct 7, 2024
1 parent bd437cf commit 244ba5b
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions warehouse/dbt/models/marts/superchain/4337_traces.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{
config(
materialized='table',
partition_by={
"field": "block_timestamp",
"data_type": "timestamp",
"granularity": "day",
}
)
}}

{% set start_date = '2024-06-01' %}
{% set end_date = '2024-09-01' %}
{% set networks = ["base", "optimism"] %}
{% set entrypoint_contracts = [
"'0x0000000071727de22e5e9d8baf0edac6f37da032'",
"'0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789'"]
%}
{% set union_queries = [] %}

{% for network in networks %}

{% set network_upper = network.upper() %}

{% set query %}
select
'{{ network_upper }}' as network,
traces.block_timestamp,
traces.transaction_hash,
traces.transaction_index,
traces.from_address,
traces.to_address,
traces.value,
traces.input,
traces.output,
traces.gas,
traces.gas_used,
traces.subtraces,
traces.trace_type,
traces.call_type,
traces.reward_type,
traces.error,
traces.status
from {{ oso_source(network, 'traces') }} as traces
where
(
traces.from_address in ({{ entrypoint_contracts | join(', ') }})
or traces.to_address in ({{ entrypoint_contracts | join(', ') }})
)
and traces.block_timestamp > '{{ start_date }}'
and traces.block_timestamp < '{{ end_date }}'
{% endset %}

{% do union_queries.append(query) %}
{% endfor %}

{% set final_query = union_queries | join(' union all ') %}

with filtered_traces as (
{{ final_query }}
)

select *
from filtered_traces

0 comments on commit 244ba5b

Please sign in to comment.