diff --git a/dbt_subprojects/daily_spellbook/models/_sector/stablecoins/polygon/stablecoins_polygon_balances.sql b/dbt_subprojects/daily_spellbook/models/_sector/stablecoins/polygon/stablecoins_polygon_balances.sql new file mode 100644 index 00000000000..b6b967dd08a --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_sector/stablecoins/polygon/stablecoins_polygon_balances.sql @@ -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 + \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_sector/stablecoins/polygon/stablecoins_polygon_schema.yml b/dbt_subprojects/daily_spellbook/models/_sector/stablecoins/polygon/stablecoins_polygon_schema.yml new file mode 100644 index 00000000000..dcf90cc30d7 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_sector/stablecoins/polygon/stablecoins_polygon_schema.yml @@ -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" + + \ No newline at end of file