Skip to content

Commit

Permalink
Polygon Stablecoin Balances (duneanalytics#7027)
Browse files Browse the repository at this point in the history
* 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
Synthquest and couralex6 authored Oct 31, 2024
1 parent 53bd40b commit 32be262
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
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

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"


0 comments on commit 32be262

Please sign in to comment.