forked from duneanalytics/spellbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Polygon Stablecoin Balances (duneanalytics#7027)
* init polygon stable balances * run failed - limit view * tmp test * Revert "tmp test" This reverts commit 4362e50. * limit test * 2023 -> * limit * increase limit * lower limit --------- Co-authored-by: Alex Courouble <[email protected]>
- Loading branch information
1 parent
53bd40b
commit 32be262
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...jects/daily_spellbook/models/_sector/stablecoins/polygon/stablecoins_polygon_balances.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{{ | ||
config( | ||
schema = 'stablecoins_polygon', | ||
alias = 'balances', | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['day', 'address', 'token_address', 'blockchain'], | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')] | ||
) | ||
}} | ||
|
||
with | ||
stablecoin_tokens as ( | ||
select distinct | ||
symbol, | ||
contract_address as token_address | ||
from | ||
{{ source('tokens_polygon', 'erc20_stablecoins')}} | ||
) | ||
|
||
,balances as ( | ||
{{ | ||
balances_incremental_subset_daily( | ||
blockchain = 'polygon', | ||
token_list = 'stablecoin_tokens', | ||
start_date = '2023-08-01' | ||
) | ||
}} | ||
) | ||
|
||
select | ||
t.symbol | ||
,b.* | ||
from balances b | ||
left join stablecoin_tokens t | ||
on b.token_address = t.token_address | ||
|
62 changes: 62 additions & 0 deletions
62
...rojects/daily_spellbook/models/_sector/stablecoins/polygon/stablecoins_polygon_schema.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: stablecoins_polygon_balances | ||
|
||
meta: | ||
blockchain: polygon | ||
sector: stablecoin | ||
project: stablecoin | ||
contributors: synthquest | ||
|
||
config: | ||
tags: ['stablecoin', 'balances'] | ||
description: "Balances of stablecoin token holders" | ||
data_tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
combination_of_columns: | ||
- day | ||
- address | ||
- token_address | ||
columns: | ||
- &blockchain | ||
name: blockchain | ||
description: "Blockchain for the token" | ||
- &symbol | ||
name: symbol | ||
description: "Symbol for the token" | ||
- &version | ||
name: version | ||
description: "Version of the token" | ||
- &day | ||
name: day | ||
description: "Date on which the token balance is logged" | ||
- &address | ||
name: address | ||
description: "Address for the token holder" | ||
- &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" | ||
|
||
|