Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Safe spells for scroll #6391

Merged
merged 42 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5444ebf
Add v1.4.1 singletons
danielpartida Feb 20, 2024
5862466
Change goerli test
danielpartida Feb 20, 2024
761f15a
Merge branch 'main' of https://github.com/5afe/spellbook
danielpartida Apr 9, 2024
8bf1492
Declare new Safe models for zkevm
danielpartida Apr 9, 2024
39d3840
Implement Safe models for zkevm
danielpartida Apr 9, 2024
8500052
Update crosschain models with zkevm data
danielpartida Apr 9, 2024
7715348
Bugfix: Joining correctly on celo transactions for safe_celo_transact…
danielpartida Apr 9, 2024
fd5cff2
Fix project start for safe_polygon_matic_transfers.sql
danielpartida Apr 9, 2024
52ce339
Merge branch 'main' of https://github.com/5afe/spellbook
danielpartida Jul 11, 2024
a127b2f
Create Safe ETH Scroll transfers spell
danielpartida Jul 11, 2024
3d50b6c
Create Scroll spell for Safes deployed
danielpartida Jul 11, 2024
6e79c43
Adapt Scroll Safe ETH transfers spell
danielpartida Jul 11, 2024
aaad25d
Implement Safe Scroll transactions and singletons spells
danielpartida Jul 11, 2024
055361d
Parametrize scroll Safe Scroll spells
danielpartida Jul 11, 2024
75fa6d2
Bugfix: Remove duplicated spell for Safe zkEVM
danielpartida Jul 11, 2024
1fe30ec
Create Safe scroll schema
danielpartida Jul 11, 2024
ae34a97
Add Scroll data to crosschain spells
danielpartida Jul 11, 2024
3c49490
Merge branch 'duneanalytics:main' into add-safes-on-scroll
danielpartida Jul 19, 2024
6fc38c7
Merge branch 'duneanalytics:main' into main
danielpartida Jul 26, 2024
875dba4
Merge branch 'duneanalytics:main' into main
danielpartida Jul 31, 2024
0173ad4
Merge branch 'main' into add-safes-on-scroll
danielpartida Jul 31, 2024
b5c4365
Move Safe scroll models to new Safe folder location
danielpartida Jul 31, 2024
f7b3da4
Add explicit sources of decoded tables to schema
danielpartida Jul 31, 2024
00b18dc
Update dbt_subprojects/hourly_spellbook/models/_project/safe/scroll/s…
danielpartida Aug 2, 2024
5fb42d8
Update dbt_subprojects/hourly_spellbook/models/_project/safe/scroll/s…
danielpartida Aug 2, 2024
58636e7
Update dbt_subprojects/hourly_spellbook/models/_project/safe/scroll/s…
danielpartida Aug 2, 2024
275be70
Update dbt_subprojects/hourly_spellbook/models/_project/safe/scroll/s…
danielpartida Aug 2, 2024
dd864c4
Merge branch 'duneanalytics:main' into main
danielpartida Aug 5, 2024
1757274
Merge branch 'main' into add-safes-on-scroll
danielpartida Aug 5, 2024
414c49b
Declare scroll source file
danielpartida Aug 5, 2024
660a521
Implement source schema under right folder
danielpartida Aug 5, 2024
f11a6c6
Merge branch 'duneanalytics:main' into main
danielpartida Aug 6, 2024
a5176e9
Merge branch 'main' into add-safes-on-scroll
danielpartida Aug 6, 2024
5ea0fd7
Merge branch 'duneanalytics:main' into main
danielpartida Aug 7, 2024
d57426e
Merge branch 'main' into add-safes-on-scroll
danielpartida Aug 7, 2024
e3b0bd5
Merge branch 'duneanalytics:main' into main
danielpartida Aug 7, 2024
57dc51b
Merge branch 'main' into add-safes-on-scroll
danielpartida Aug 7, 2024
80181bf
Fix merge
danielpartida Aug 7, 2024
e489553
Merge branch 'duneanalytics:main' into main
danielpartida Aug 8, 2024
7a4c4a3
Merge branch 'main' into add-safes-on-scroll
danielpartida Aug 8, 2024
a40871a
Fix merge conflicts
danielpartida Aug 8, 2024
760f1fb
Add missing specs to crosschain schemas
danielpartida Aug 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
danielpartida marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
schema = 'safe',
alias = 'native_transfers_all',
post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","bnb","celo","ethereum","gnosis","goerli","linea","optimism","polygon","zkevm","zksync"]\',
post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","bnb","celo","ethereum","gnosis","goerli","linea","optimism","polygon","scroll","zkevm","zksync"]\',
"project",
"safe",
\'["kryptaki", "danielpartida"]\') }}'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
schema = 'safe',
alias = 'safes_all',
post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","bnb","celo","ethereum","fantom","gnosis","goerli","linea","optimism","polygon","zkevm","zksync"]\',
post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","bnb","celo","ethereum","fantom","gnosis","goerli","linea","optimism","polygon","scroll","zkevm","zksync"]\',
"project",
"safe",
\'["tschubotz", "danielpartida", "kryptaki"]\') }}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ version: 2
models:
- name: safe_safes_all
meta:
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, goerli, optimism, polygon, zkevm, zksync
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, goerli, optimism, polygon, scroll, zkevm, zksync
project: safe
contributors: tschubotz, danielpartida, kryptaki
config:
tags: ['arbitrum', 'avalanche_c', 'bnb', 'celo','ethereum', 'fantom', 'gnosis', 'goerli', 'optimism', 'polygon', 'safe', 'zkevm', 'zksync']
tags: ['arbitrum', 'avalanche_c', 'bnb', 'celo','ethereum', 'fantom', 'gnosis', 'goerli', 'optimism', 'polygon', 'safe', 'scroll','zkevm', 'zksync']
description: >
Lists all Safes across chains.
columns:
Expand All @@ -32,14 +32,14 @@ models:

- name: safe_transactions_all
meta:
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, goerli, optimism, polygon, zkevm, zksync
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, goerli, optimism, polygon, scroll, zkevm, zksync
project: safe
contributors: kryptaki, danielpartida
freshness:
warn_after: { count: 12, period: hour }
error_after: { count: 24, period: hour }
config:
tags: ['arbitrum', 'avalanche_c', 'bnb', 'celo','ethereum', 'fantom', 'gnosis', 'goerli', 'optimism', 'polygon', 'safe', 'zkevm', 'zksync']
tags: ['arbitrum', 'avalanche_c', 'bnb', 'celo','ethereum', 'fantom', 'gnosis', 'goerli', 'optimism', 'polygon', 'safe', 'scroll', 'zkevm', 'zksync']
description: "Safe transactions"
columns:
- *blockchain
Expand Down Expand Up @@ -94,14 +94,14 @@ models:

- name: safe_native_transfers_all
meta:
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, gnosis, goerli, optimism, polygon, zkevm, zksync
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, gnosis, goerli, optimism, polygon, scroll, zkevm, zksync
project: safe
contributors: kryptaki, tschubotz, danielpartida
freshness:
warn_after: { count: 12, period: hour }
error_after: { count: 24, period: hour }
config:
tags: ['arbitrum', 'avalanche_c', 'bnb', 'celo','ethereum', 'gnosis', 'goerli', 'optimism', 'polygon', 'safe', 'zkevm', 'zksync']
tags: ['arbitrum', 'avalanche_c', 'bnb', 'celo','ethereum', 'gnosis', 'goerli', 'optimism', 'polygon', 'safe', 'scroll', 'zkevm', 'zksync']
description: "Native gas token transfers into or out of Safes"
tests:
- dbt_utils.unique_combination_of_columns:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
schema = 'safe',
alias = 'transactions_all',
post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","bnb","celo","ethereum","fantom","gnosis","goerli","linea","optimism","polygon","zkevm","zksync"]\',
post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","bnb","celo","ethereum","fantom","gnosis","goerli","linea","optimism","polygon","scroll","zkevm","zksync"]\',
"project",
"safe",
\'["kryptaki", "danielpartida"]\') }}'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{{
config(
materialized='incremental',
schema = 'safe_scroll',
alias= 'eth_transfers',
partition_by = ['block_month'],
unique_key = ['block_date', 'address', 'tx_hash', 'trace_address'],
on_schema_change='fail',
file_format ='delta',
incremental_strategy='merge',
post_hook = '{{ expose_spells(
blockchains = \'["scroll"]\',
spell_type = "project",
spell_name = "safe",
contributors = \'["danielpartida"]\') }}'
)
}}

{% set project_start_date = '2023-10-15' %}

select
t.*,
p.price * t.amount_raw / 1e18 AS amount_usd

from (

select
'scroll' as blockchain,
'ETH' as symbol,
s.address,
try_cast(date_trunc('day', et.block_time) as date) as block_date,
CAST(date_trunc('month', et.block_time) as DATE) as block_month,
et.block_time,
-CAST(et.value AS INT256) as amount_raw,
et.tx_hash,
array_join(et.trace_address, ',') as trace_address
from {{ source('scroll', 'traces') }} et
join {{ ref('safe_scroll_safes') }} s on et."from" = s.address
and et."from" != et.to -- exclude calls to self to guarantee unique key property
and et.success = true
and (lower(et.call_type) not in ('delegatecall', 'callcode', 'staticcall') or et.call_type is null)
and et.value > UINT256 '0' -- et.value is uint256 type
{% if not is_incremental() %}
where et.block_time > timestamp '{{project_start_date}}' -- for initial query optimisation
{% else %}
-- to prevent potential counterfactual safe deployment issues we take a bigger interval
where et.block_time > date_trunc('day', now() - interval '10' day)
{% endif %}

union all

select
'scroll' as blockchain,
'ETH' as symbol,
s.address,
try_cast(date_trunc('day', et.block_time) as date) as block_date,
CAST(date_trunc('month', et.block_time) as DATE) as block_month,
et.block_time,
CAST(et.value AS INT256) as amount_raw,
et.tx_hash,
array_join(et.trace_address, ',') as trace_address
from {{ source('scroll', 'traces') }} et
join {{ ref('safe_scroll_safes') }} s on et.to = s.address
and et."from" != et.to -- exclude calls to self to guarantee unique key property
and et.success = true
and (lower(et.call_type) not in ('delegatecall', 'callcode', 'staticcall') or et.call_type is null)
and et.value > UINT256 '0' -- et.value is uint256 type
{% if not is_incremental() %}
where et.block_time > timestamp '{{project_start_date}}' -- for initial query optimisation
{% endif %}
{% if is_incremental() %}
-- to prevent potential counterfactual safe deployment issues we take a bigger interval
where et.block_time > date_trunc('day', now() - interval '10' day)
{% endif %}
) t

left join {{ source('prices', 'usd') }} p on p.blockchain is null
and p.symbol = t.symbol
and p.minute = date_trunc('minute', t.block_time)
{% if is_incremental() %}
-- to prevent potential counterfactual safe deployment issues we take a bigger interval
and p.minute > date_trunc('day', now() - interval '10' day)
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{
config(
materialized='incremental',
schema = 'safe_scroll',
alias= 'safes',
partition_by = ['block_month'],
unique_key = ['block_date', 'address'],
on_schema_change='fail',
file_format ='delta',
incremental_strategy='merge',
post_hook = '{{ expose_spells(
blockchains = \'["scroll"]\',
spell_type = "project",
spell_name = "safe",
contributors = \'["danielpartida"]\') }}'
)
}}

{% set project_start_date = '2023-10-15' %}

select
'scroll' as blockchain,
et."from" as address,
case
when et.to = 0xd9db270c1b5e3bd161e8c8503c55ceabee709552 then '1.3.0'
when et.to = 0x3e5c63644e683549055b9be8653de26e0b4cd36e then '1.3.0L2'
when et.to = 0x41675C099F32341bf84BFc5382aF534df5C7461a then '1.4.1'
when et.to = 0x29fcB43b46531BcA003ddC8FCB67FFE91900C762 then '1.4.1L2'
else 'unknown'
end as creation_version,
try_cast(date_trunc('day', et.block_time) as date) as block_date,
CAST(date_trunc('month', et.block_time) as DATE) as block_month,
et.block_time as creation_time,
et.tx_hash
from {{ source('scroll', 'traces') }} et
join {{ ref('safe_scroll_singletons') }} s
on et.to = s.address
where et.success = true
and et.call_type = 'delegatecall' -- delegatecall to singleton is Safe (proxy) address
and bytearray_substring(et.input, 1, 4) in (
0xb63e800d -- setup method v1.3.0, v1.3.0L2, v1.4.1, v.1.4.1L2
)
and et.gas_used > 10000 -- to ensure the setup call was successful. excludes e.g. setup calls with missing params that fallback
{% if not is_incremental() %}
and et.block_time > TIMESTAMP '{{project_start_date}}' -- for initial query optimisation
{% else %}
and {{ incremental_predicate('et.block_time') }}
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
version: 2

models:
- name: safe_scroll_safes
meta:
blockchain: scroll
project: safe
contributors: danielpartida
freshness:
warn_after: { count: 12, period: hour }
error_after: { count: 24, period: hour }
config:
tags: ['safe', 'scroll']
description: "Safe addresses"
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- block_date
- address
columns:
- &blockchain
name: blockchain
description: "The blockchain on which the Safe is deployed"
- &address
name: address
description: "Safe contract address"
- &creation_version
name: creation_version
description: "Version of initially created safe"
- &block_date
name: block_date
- &block_month
name: block_month
- &creation_time
name: creation_time
description: "Date/time of safe creation"
- &tx_hash
name: tx_hash

- name: safe_scroll_eth_transfers
meta:
blockchain: scroll
project: safe
contributors: danielpartida
freshness:
warn_after: { count: 12, period: hour }
error_after: { count: 24, period: hour }
config:
tags: ['safe', 'transfers', 'scroll']
description: "ETH transfers for safes"
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- block_date
- address
- tx_hash
- trace_address
columns:
- *blockchain
- &symbol
name: symbol
description: "Symbol of native gas token: ETH"
- *address
- *block_date
- *block_month
- &block_time
name: block_time
description: "Date of ETH transfer"
- &amount_raw
name: amount_raw
description: "Raw amount of transferred ETH"
- *tx_hash
- &trace_address
name: trace_address
- &amount_usd
name: amount_usd
description: "USD amount of transferred ETH"

- name: safe_scroll_singletons
meta:
blockchain: scroll
project: safe
contributors: danielpartida
freshness:
warn_after: { count: 12, period: hour }
error_after: { count: 24, period: hour }
config:
tags: ['safe', 'singletons', 'scroll']
description: "Singletons addresses used with Safes"
columns:
- name: address
description: "Safe contract address"

- name: safe_scroll_transactions
meta:
blockchain: scroll
project: safe
contributors: danielpartida
freshness:
warn_after: { count: 12, period: hour }
error_after: { count: 24, period: hour }
config:
tags: ['safe', 'scroll']
description: "Safe transactions"
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- block_date
- tx_hash
- trace_address
columns:
- *blockchain
- *block_date
- *block_month
- *block_time
- &block_number
name: block_number
description: "Number of block"
- *tx_hash
- name: address
description: "Safe contract address"
- &to
name: to
description: "Destination address"
- &value
name: value
description: "Value of transaction"
- &gas
name: gas
description: "Gas limit set for transaction"
- &execution_gas_used
name: execution_gas_used
description: "Execution gas used during transaction, for more details see https://dune.com/docs/data-tables/raw/evm/traces/?h=traces#gas-used-in-traces"
- &total_gas_used
name: total_gas_used
description: "Total gas used during transaction"
- &tx_index
name: tx_index
description: "Transaction index"
- &sub_traces
name: sub_traces
description: "Number of sub traces"
- *trace_address
- &success
name: success
description: "Success state of transaction"
- &error
name: error
description: "Error of transaction if any"
- &code
name: code
description: "Code"
- &input
name: input
description: "Input data"
- &output
name: output
description: "Output data"
- &method
name: method
description: "Function method"
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{
config(
materialized='table',
schema = 'safe_scroll',
alias= 'singletons',
post_hook = '{{ expose_spells(
blockchains = \'["scroll"]\',
spell_type = "project",
spell_name = "safe",
contributors = \'["danielpartida"]\') }}'
)
}}


-- Fetch all known singleton/mastercopy addresses used via factories.
select distinct singleton as address
from {{ source('gnosis_safe_scroll', 'GnosisSafeProxyFactory_v1_3_0_evt_ProxyCreation') }}

union
select distinct singleton as address
from {{ source('gnosis_safe_scroll', 'SafeProxyFactory_v1_4_1_evt_ProxyCreation') }}
Loading
Loading