Skip to content

Commit

Permalink
Safe mantle models (duneanalytics#6777)
Browse files Browse the repository at this point in the history
* Add v1.4.1 singletons

L1 singleton 0x41675C099F32341bf84BFc5382aF534df5C7461a
L2 singleton 0x29fcB43b46531BcA003ddC8FCB67FFE91900C76

* Change goerli test

* Declare new Safe models for zkevm

* Implement Safe models for zkevm

* Update crosschain models with zkevm data

Models updated are:
- safe_native_transfers.all.sql -> Added safe_zkevm_matic_transfers
- safe_safes_all.sql -> Added safe_zkevm_safes
- safe_transactions_all.sql -> safe_zkevm_transactions

* Bugfix: Joining correctly on celo transactions for safe_celo_transactions spell

* Fix project start for safe_polygon_matic_transfers.sql

* Implement Safe mantle transfers spell

* Implement Safe mantle singletons model

* Implement Safe mantle txs spell

* Change project start date for Safe mantle models

* Add Mantle data to native transfers spell

* Add Safe mantles models for all Safes

* Add Safe mantle txs to all txs spell

* Add Safe mantle data to Safe schema

* Create Safe mantle schema

* Implement Safe mantle sources file

* Removing zkevm transactions model from wrong directory

* Fix names of proxy factory contracts

* Change file of Safe mantle native token transfers
  • Loading branch information
danielpartida committed Sep 23, 2024
1 parent 7f6532b commit 2d1d595
Show file tree
Hide file tree
Showing 10 changed files with 333 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{
config(
schema = 'safe_mantle',
alias= 'mnt_transfers',
partition_by = ['block_month'],
on_schema_change='fail',
materialized='incremental',
file_format ='delta',
incremental_strategy='merge',
unique_key = ['block_date', 'address', 'tx_hash', 'trace_address'],
post_hook = '{{ expose_spells(blockchains = \'["mantle"]\',
spell_type = "project",
spell_name = "safe",
contributors = \'["danielpartida"]\') }}'
)
}}

{% set project_start_date = '2023-07-12' %}

{{
safe_native_transfers(
blockchain = 'mantle',
native_token_symbol = 'MNT',
project_start_date = project_start_date
)
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{
config(
materialized='incremental',
schema = 'safe_mantle',
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 = \'["mantle"]\',
spell_type = "project",
spell_name = "safe",
contributors = \'["danielpartida"]\') }}'
)
}}

{% set project_start_date = '2023-07-12' %}

select
'mantle' 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('mantle', 'traces') }} et
join {{ ref('safe_mantle_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_mantle_safes
meta:
blockchain: mantle
project: safe
contributors: danielpartida
freshness:
warn_after: { count: 12, period: hour }
error_after: { count: 24, period: hour }
config:
tags: ['safe', 'mantle']
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_mantle_mnt_transfers
meta:
blockchain: mantle
project: safe
contributors: danielpartida
freshness:
warn_after: { count: 12, period: hour }
error_after: { count: 24, period: hour }
config:
tags: ['safe', 'transfers', 'mantle']
description: "MNT 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: MNT"
- *address
- *block_date
- *block_month
- &block_time
name: block_time
description: "Date of MNT transfer"
- &amount_raw
name: amount_raw
description: "Raw amount of transferred MNT"
- *tx_hash
- &trace_address
name: trace_address
- &amount_usd
name: amount_usd
description: "USD amount of transferred MNT"

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

- name: safe_mantle_transactions
meta:
blockchain: mantle
project: safe
contributors: danielpartida
freshness:
warn_after: { count: 12, period: hour }
error_after: { count: 24, period: hour }
config:
tags: ['safe', 'mantle']
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_mantle',
alias= 'singletons',
post_hook = '{{ expose_spells(
blockchains = \'["mantle"]\',
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_mantle', 'SafeProxyFactory_v1_3_0_evt_ProxyCreation') }}

union
select distinct singleton as address
from {{ source('gnosis_safe_mantle', 'SafeProxyFactory_v1_4_1_evt_ProxyCreation') }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{
config(
materialized='incremental',
schema = 'safe_mantle',
alias= 'transactions',
partition_by = ['block_month'],
unique_key = ['block_date', 'tx_hash', 'trace_address'],
file_format ='delta',
incremental_strategy='merge',
post_hook = '{{ expose_spells(
blockchains = \'["mantle"]\',
spell_type = "project",
spell_name = "safe",
contributors = \'["danielpartida"]\') }}'
)
}}

{% set project_start_date = '2023-07-12' %}

{{ safe_transactions('mantle', project_start_date) }}
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","blast","bnb","celo","ethereum","gnosis","goerli","linea","optimism","polygon","scroll","zkevm","zksync"]\',
post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","blast","bnb","celo","ethereum","gnosis","goerli","linea","mantle","optimism","polygon","scroll","zkevm","zksync"]\',
"project",
"safe",
\'["kryptaki", "danielpartida"]\') }}'
Expand All @@ -19,6 +19,7 @@
,ref('safe_gnosis_xdai_transfers')
,ref('safe_goerli_eth_transfers')
,ref('safe_linea_eth_transfers')
,ref('safe_mantle_mnt_transfers')
,ref('safe_optimism_eth_transfers')
,ref('safe_polygon_matic_transfers')
,ref('safe_scroll_eth_transfers')
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","blast","bnb","celo","ethereum","fantom","gnosis","goerli","linea","optimism","polygon","scroll","zkevm","zksync"]\',
post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","blast","bnb","celo","ethereum","fantom","gnosis","goerli","linea","mantle","optimism","polygon","scroll","zkevm","zksync"]\',
"project",
"safe",
\'["tschubotz", "danielpartida", "kryptaki"]\') }}'
Expand All @@ -20,6 +20,7 @@
,ref('safe_gnosis_safes')
,ref('safe_goerli_safes')
,ref('safe_linea_safes')
,ref('safe_mantle_safes')
,ref('safe_optimism_safes')
,ref('safe_polygon_safes')
,ref('safe_scroll_safes')
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, blast, bnb, celo, ethereum, fantom, gnosis, goerli, linea, optimism, polygon, scroll, zkevm, zksync
blockchain: arbitrum, avalanche_c, base, blast, bnb, celo, ethereum, fantom, gnosis, goerli, linea, , mantle, optimism, polygon, scroll, zkevm, zksync
project: safe
contributors: tschubotz, danielpartida, kryptaki
config:
tags: ['arbitrum', 'avalanche_c', 'base', 'blast', 'bnb', 'celo','ethereum', 'fantom', 'gnosis', 'goerli', 'linea', 'optimism', 'polygon', 'safe', 'scroll', 'zkevm', 'zksync']
tags: ['arbitrum', 'avalanche_c', 'base', 'blast', 'bnb', 'celo','ethereum', 'fantom', 'gnosis', 'goerli', 'linea', 'mantle', '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, blast, bnb, celo, ethereum, fantom, gnosis, goerli, linea, optimism, polygon, scroll, zkevm, zksync
blockchain: arbitrum, avalanche_c, base, blast, bnb, celo, ethereum, fantom, gnosis, goerli, linea, mantle, 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', 'base', 'blast', 'bnb', 'celo','ethereum', 'fantom', 'gnosis', 'goerli', 'linea', 'optimism', 'polygon', 'safe', 'scroll', 'zkevm', 'zksync']
tags: ['arbitrum', 'avalanche_c', 'base', 'blast', 'bnb', 'celo','ethereum', 'fantom', 'gnosis', 'goerli', 'linea', 'mantle', '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, blast, bnb, celo, ethereum, gnosis, goerli, linea, optimism, polygon, scroll, zkevm, zksync
blockchain: arbitrum, avalanche_c, base, blast, bnb, celo, ethereum, gnosis, goerli, linea, mantle, 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', 'base', 'blast', 'bnb', 'celo','ethereum', 'gnosis', 'goerli', 'linea', 'optimism', 'polygon', 'safe', 'scroll', 'zkevm', 'zksync']
tags: ['arbitrum', 'avalanche_c', 'base', 'blast', 'bnb', 'celo','ethereum', 'gnosis', 'goerli', 'linea', 'mantle', '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","blast","bnb","celo","ethereum","fantom","gnosis","goerli","linea","optimism","polygon","scroll","zkevm","zksync"]\',
post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","blast","bnb","celo","ethereum","fantom","gnosis","goerli","linea","mantle","optimism","polygon","scroll","zkevm","zksync"]\',
"project",
"safe",
\'["kryptaki", "danielpartida"]\') }}'
Expand All @@ -20,6 +20,7 @@
,ref('safe_gnosis_transactions')
,ref('safe_goerli_transactions')
,ref('safe_linea_transactions')
,ref('safe_mantle_transactions')
,ref('safe_optimism_transactions')
,ref('safe_polygon_transactions')
,ref('safe_scroll_transactions')
Expand Down
Loading

0 comments on commit 2d1d595

Please sign in to comment.