Skip to content

Commit

Permalink
Add Safe Balances for Scroll (#7250)
Browse files Browse the repository at this point in the history
* Update safe_scroll_schema.yml

* Create safe_scroll_balances

* Rename safe_scroll_balances to safe_scroll_balances.sql

---------

Co-authored-by: Huang Geyang <Sukebeta@outlook.com>
  • Loading branch information
safeintern and Hosuke authored Dec 9, 2024
1 parent 231a014 commit 5e397b7
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{
config(
schema = 'safe_scroll',
alias = 'balances',
partition_by = ['day'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['day', 'address', 'token_address'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')]
)
}}

with safes as (
select
address,
blockchain
from {{ ref('safe_scroll_safes') }}
where blockchain = 'scroll'
),

balances as (
{{
balances_incremental_subset_daily(
blockchain = 'scroll',
address_list = 'safes',
start_date = '2021-07-01'
)
}}
)

select * from balances
where token_standard in ('native', 'erc20')
and token_address not in (
0xd74f5255d557944cf7dd0e45ff521520002d5748, --$9.8B were minted in a hack in 2023, all of which are stored in a Safe. Filtering out.
0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3 )
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,50 @@ models:
description: "Output data"
- &method
name: method
description: "Function method"
description: "Function method"

- name: safe_scroll_balances
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- day
- address
- token_address
meta:
blockchain: scroll
project: safe
contributors: safeintern
config:
tags: ['safe', 'scroll']
description: “Safe addresses balances”
columns:
- name: day
- name: blockchain
- name: address
- &token_symbol
name: token_symbol
description: "Symbol for the token"
- &token_address
name: token_address
description: "Address for the token"
- &token_standard
name: token_standard
description: "Standard for the token"
- &token_id
name: token_id
description: "ID for the token"
- &balance
name: balance
description: "Balance for the user"
- &balance_usd
name: balance_usd
description: "USD value of balance for the user"
- &last_updated
name: last_updated
description: "UTC timestamp when data was last updated"
- &next_update
name: next_update
description: "UTC timestamp when data is next updated"
- &unique_key_id
name: unique_key_id
description: "unique key"

0 comments on commit 5e397b7

Please sign in to comment.