Skip to content

Commit

Permalink
Stablecoin balances evms (#6826)
Browse files Browse the repository at this point in the history
* init stablecoin balances evm chains

* remove blast

* remove gnosis & fantom

* remove duplicate entry

* handle duplicate entries

* open time limit

* remove optimism model

* fix naming

* update decimals
  • Loading branch information
Synthquest authored Oct 3, 2024
1 parent 07548db commit a02c461
Show file tree
Hide file tree
Showing 17 changed files with 697 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{
config(
schema = 'stablecoins_avalanche_c',
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_avalanche_c', 'erc20_stablecoins')}}
)

,balances as (
{{
balances_incremental_subset_daily(
blockchain = 'avalanche_c',
token_list = 'stablecoin_tokens',
start_date = '2021-01-27'
)
}}
)

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_avalanche_c_balances

meta:
blockchain: avalanche_c
sector: stablecoin
project: stablecoin
contributors: synthquest

config:
tags: ['stablecoin', 'balances']
description: "Balances of stablecoin token holders"
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"


Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{
config(
schema = 'stablecoins_base',
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_base', 'erc20_stablecoins')}}
)

,balances as (
{{
balances_incremental_subset_daily(
blockchain = 'base',
token_list = 'stablecoin_tokens',
start_date = '2023-07-20'
)
}}
)

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_base_balances

meta:
blockchain: base
sector: stablecoin
project: stablecoin
contributors: synthquest

config:
tags: ['stablecoin', 'balances']
description: "Balances of stablecoin token holders"
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"


Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{
config(
schema = 'stablecoins_ethereum',
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_ethereum', 'erc20_stablecoins')}}
)

,balances as (
{{
balances_incremental_subset_daily(
blockchain = 'ethereum',
token_list = 'stablecoin_tokens',
start_date = '2017-11-26'
)
}}
)

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_ethereum_balances

meta:
blockchain: ethereum
sector: stablecoin
project: stablecoin
contributors: synthquest

config:
tags: ['stablecoin', 'balances']
description: "Balances of stablecoin token holders"
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"


Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{
config(
schema = 'stablecoins_linea',
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_linea', 'erc20_stablecoins')}}
)

,balances as (
{{
balances_incremental_subset_daily(
blockchain = 'linea',
token_list = 'stablecoin_tokens',
start_date = '2023-07-13'
)
}}
)

select
t.symbol
,b.*
from balances b
left join stablecoin_tokens t
on b.token_address = t.token_address

Loading

0 comments on commit a02c461

Please sign in to comment.