Skip to content

Commit

Permalink
Stablecoin Dashboard: Adding new stablecoin metrics (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebMelendez01 authored Sep 4, 2024
1 parent a96dd8f commit ababc49
Show file tree
Hide file tree
Showing 27 changed files with 197 additions and 95 deletions.
6 changes: 5 additions & 1 deletion macros/metrics/get_p2p_metrics.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{% macro get_p2p_metrics(chain) %}
select date, p2p_native_transfer_volume, p2p_token_transfer_volume, p2p_stablecoin_transfer_volume, p2p_transfer_volume
select
date
, p2p_native_transfer_volume
, p2p_token_transfer_volume
, p2p_transfer_volume
from {{ ref("fact_" ~ chain ~ "_p2p_transfer_volume") }}
{% endmacro %}
69 changes: 58 additions & 11 deletions macros/metrics/get_stablecoin_metrics.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,59 @@
{% macro get_stablecoin_metrics(chain) %}
{% macro get_stablecoin_metrics(identifier, breakdown="chain") %}
with mau as (
select
chain,
date,
sum(total_supply) as stablecoin_total_supply,
sum(txns) as stablecoin_txns,
sum(dau) as stablecoin_dau,
sum(transfer_volume) as stablecoin_transfer_volume,
sum(deduped_transfer_volume) as deduped_stablecoin_transfer_volume
from {{ ref("agg_" ~ chain ~ "_stablecoin_metrics") }}
group by chain, date
{% endmacro %}
date_granularity as date
, '{{ identifier }}' as {{breakdown}}
, stablecoin_dau as stablecoin_mau
, artemis_stablecoin_dau as artemis_stablecoin_mau
, p2p_stablecoin_dau as p2p_stablecoin_mau
from {{ ref("agg_monthly_stablecoin_breakdown_" ~ breakdown) }}
{% if breakdown == "chain" %}
where lower(chain) = lower('{{ identifier }}')
{% elif breakdown == "symbol" %}
where lower(symbol) = lower('{{ identifier }}')
{% endif %}
)
, daily_metrics as (
select
date_granularity as date
, '{{ identifier }}' as {{ breakdown }}

, stablecoin_transfer_volume as stablecoin_transfer_volume
, stablecoin_daily_txns as stablecoin_txns
, stablecoin_dau

, artemis_stablecoin_transfer_volume
, artemis_stablecoin_daily_txns as artemis_stablecoin_txns
, artemis_stablecoin_dau

, p2p_stablecoin_transfer_volume
, p2p_stablecoin_daily_txns as p2p_stablecoin_txns
, p2p_stablecoin_dau

, stablecoin_supply as stablecoin_total_supply
from {{ ref("agg_daily_stablecoin_breakdown_" ~ breakdown) }}
{% if breakdown == "chain" %}
where lower(chain) = lower('{{ identifier }}')
{% elif breakdown == "symbol" %}
where lower(symbol) = lower('{{ identifier }}')
{% endif %}
)
select
daily_metrics.date
, daily_metrics.{{breakdown}} as {{ breakdown }}
, stablecoin_transfer_volume
, stablecoin_txns
, stablecoin_dau
, stablecoin_mau
, artemis_stablecoin_transfer_volume
, artemis_stablecoin_txns
, artemis_stablecoin_dau
, artemis_stablecoin_mau
, p2p_stablecoin_transfer_volume
, p2p_stablecoin_txns
, p2p_stablecoin_dau
, p2p_stablecoin_mau
, stablecoin_total_supply
from daily_metrics
left join mau on daily_metrics.date = mau.date
{% endmacro %}
18 changes: 0 additions & 18 deletions macros/stablecoins/stablecoin_ez_metrics.sql

This file was deleted.

13 changes: 10 additions & 3 deletions models/projects/arbitrum/core/ez_arbitrum_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,21 @@ select
stablecoin_total_supply,
stablecoin_txns,
stablecoin_dau,
stablecoin_mau,
stablecoin_transfer_volume,
deduped_stablecoin_transfer_volume,
artemis_stablecoin_txns,
artemis_stablecoin_dau,
artemis_stablecoin_mau,
artemis_stablecoin_transfer_volume,
p2p_stablecoin_txns,
p2p_stablecoin_dau,
p2p_stablecoin_mau,
p2p_stablecoin_transfer_volume,
nft_trading_volume,
p2p_native_transfer_volume,
p2p_token_transfer_volume,
p2p_stablecoin_transfer_volume,
p2p_transfer_volume,
coalesce(deduped_stablecoin_transfer_volume, 0) - coalesce(p2p_stablecoin_transfer_volume, 0) as non_p2p_stablecoin_transfer_volume,
coalesce(artemis_stablecoin_transfer_volume, 0) - coalesce(p2p_stablecoin_transfer_volume, 0) as non_p2p_stablecoin_transfer_volume,
coalesce(dex_volumes, 0) + coalesce(nft_trading_volume, 0) + coalesce(p2p_transfer_volume, 0) as settlement_volume
from fundamental_data
left join price_data on fundamental_data.date = price_data.date
Expand Down
13 changes: 10 additions & 3 deletions models/projects/avalanche/core/ez_avalanche_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,24 @@ select
stablecoin_total_supply,
stablecoin_txns,
stablecoin_dau,
stablecoin_mau,
stablecoin_transfer_volume,
deduped_stablecoin_transfer_volume,
artemis_stablecoin_txns,
artemis_stablecoin_dau,
artemis_stablecoin_mau,
artemis_stablecoin_transfer_volume,
p2p_stablecoin_txns,
p2p_stablecoin_dau,
p2p_stablecoin_mau,
p2p_stablecoin_transfer_volume,
total_staked_native,
total_staked_usd,
issuance,
nft_trading_volume,
p2p_native_transfer_volume,
p2p_token_transfer_volume,
p2p_stablecoin_transfer_volume,
p2p_transfer_volume,
coalesce(deduped_stablecoin_transfer_volume, 0) - coalesce(p2p_stablecoin_transfer_volume, 0) as non_p2p_stablecoin_transfer_volume,
coalesce(artemis_stablecoin_transfer_volume, 0) - coalesce(p2p_stablecoin_transfer_volume, 0) as non_p2p_stablecoin_transfer_volume,
coalesce(dex_volumes, 0) + coalesce(nft_trading_volume, 0) + coalesce(p2p_transfer_volume, 0) as settlement_volume
from staking_data
left join fundamental_data on staking_data.date = fundamental_data.date
Expand Down
13 changes: 10 additions & 3 deletions models/projects/base/core/ez_base_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,21 @@ select
stablecoin_total_supply,
stablecoin_txns,
stablecoin_dau,
stablecoin_mau,
stablecoin_transfer_volume,
deduped_stablecoin_transfer_volume,
artemis_stablecoin_txns,
artemis_stablecoin_dau,
artemis_stablecoin_mau,
artemis_stablecoin_transfer_volume,
p2p_stablecoin_txns,
p2p_stablecoin_dau,
p2p_stablecoin_mau,
p2p_stablecoin_transfer_volume,
nft_trading_volume,
p2p_native_transfer_volume,
p2p_token_transfer_volume,
p2p_stablecoin_transfer_volume,
p2p_transfer_volume,
coalesce(deduped_stablecoin_transfer_volume, 0) - coalesce(p2p_stablecoin_transfer_volume, 0) as non_p2p_stablecoin_transfer_volume,
coalesce(artemis_stablecoin_transfer_volume, 0) - coalesce(p2p_stablecoin_transfer_volume, 0) as non_p2p_stablecoin_transfer_volume,
coalesce(dex_volumes, 0) + coalesce(nft_trading_volume, 0) + coalesce(p2p_transfer_volume, 0) as settlement_volume
from fundamental_data
left join defillama_data on fundamental_data.date = defillama_data.date
Expand Down
10 changes: 9 additions & 1 deletion models/projects/bsc/core/ez_bsc_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@ select
stablecoin_total_supply,
stablecoin_txns,
stablecoin_dau,
stablecoin_mau,
stablecoin_transfer_volume,
deduped_stablecoin_transfer_volume,
artemis_stablecoin_txns,
artemis_stablecoin_dau,
artemis_stablecoin_mau,
artemis_stablecoin_transfer_volume,
p2p_stablecoin_txns,
p2p_stablecoin_dau,
p2p_stablecoin_mau,
p2p_stablecoin_transfer_volume,
nft_trading_volume
from fundamental_data
left join price_data on fundamental_data.date = price_data.date
Expand Down
5 changes: 2 additions & 3 deletions models/projects/busd/core/ez_busd_metrics.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{
config(
materialized="incremental",
unique_key="date",
materialized="table",
snowflake_warehouse="BUSD",
database="busd",
schema="core",
alias="ez_metrics",
)
}}

{{ get_stablecoin_ez_metrics("BUSD") }}
{{ get_stablecoin_metrics("BUSD", breakdown='symbol') }}
10 changes: 9 additions & 1 deletion models/projects/celo/core/ez_celo_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,16 @@ select
stablecoin_total_supply,
stablecoin_txns,
stablecoin_dau,
stablecoin_mau,
stablecoin_transfer_volume,
deduped_stablecoin_transfer_volume
artemis_stablecoin_txns,
artemis_stablecoin_dau,
artemis_stablecoin_mau,
artemis_stablecoin_transfer_volume,
p2p_stablecoin_txns,
p2p_stablecoin_dau,
p2p_stablecoin_mau,
p2p_stablecoin_transfer_volume,
from fundamental_data
left join price_data on fundamental_data.date = price_data.date
left join defillama_data on fundamental_data.date = defillama_data.date
Expand Down
5 changes: 2 additions & 3 deletions models/projects/ceur/core/ez_ceur_metrics.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{
config(
materialized="incremental",
unique_key="date",
materialized="table",
snowflake_warehouse="CEUR",
database="ceur",
schema="core",
alias="ez_metrics",
)
}}

{{ get_stablecoin_ez_metrics("CEUR") }}
{{ get_stablecoin_metrics("cEUR", breakdown='symbol') }}
5 changes: 2 additions & 3 deletions models/projects/ckes/core/ez_ckes_metrics.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{
config(
materialized="incremental",
unique_key="date",
materialized="table",
snowflake_warehouse="CKES",
database="ckes",
schema="core",
alias="ez_metrics",
)
}}

{{ get_stablecoin_ez_metrics("CKES") }}
{{ get_stablecoin_metrics("cKES", breakdown='symbol') }}
5 changes: 2 additions & 3 deletions models/projects/creal/core/ez_creal_metrics.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{
config(
materialized="incremental",
unique_key="date",
materialized="table",
snowflake_warehouse="CREAL",
database="creal",
schema="core",
alias="ez_metrics",
)
}}

{{ get_stablecoin_ez_metrics("CREAL") }}
{{ get_stablecoin_metrics("cREAL", breakdown='symbol') }}
5 changes: 2 additions & 3 deletions models/projects/cusd/core/ez_cusd_metrics.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{
config(
materialized="incremental",
unique_key="date",
materialized="table",
snowflake_warehouse="CUSD",
database="cusd",
schema="core",
alias="ez_metrics",
)
}}

{{ get_stablecoin_ez_metrics("CUSD") }}
{{ get_stablecoin_metrics("cUSD", breakdown='symbol') }}
5 changes: 2 additions & 3 deletions models/projects/dai/core/ez_dai_metrics.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{
config(
materialized="incremental",
unique_key="date",
materialized="table",
snowflake_warehouse="DAI",
database="dai",
schema="core",
alias="ez_metrics",
)
}}

{{ get_stablecoin_ez_metrics("DAI") }}
{{ get_stablecoin_metrics("DAI", breakdown='symbol') }}
15 changes: 12 additions & 3 deletions models/projects/ethereum/core/ez_ethereum_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,21 @@ select
weekly_developers_sub_ecosystem,
weekly_contracts_deployed,
weekly_contract_deployers,

stablecoin_total_supply,
stablecoin_txns,
stablecoin_dau,
stablecoin_mau,
stablecoin_transfer_volume,
deduped_stablecoin_transfer_volume,
artemis_stablecoin_txns,
artemis_stablecoin_dau,
artemis_stablecoin_mau,
artemis_stablecoin_transfer_volume,
p2p_stablecoin_txns,
p2p_stablecoin_dau,
p2p_stablecoin_mau,
p2p_stablecoin_transfer_volume,

censored_blocks,
semi_censored_blocks,
non_censored_blocks,
Expand All @@ -92,9 +102,8 @@ select
nft_trading_volume,
p2p_native_transfer_volume,
p2p_token_transfer_volume,
p2p_stablecoin_transfer_volume,
p2p_transfer_volume,
coalesce(deduped_stablecoin_transfer_volume, 0) - coalesce(p2p_stablecoin_transfer_volume, 0) as non_p2p_stablecoin_transfer_volume,
coalesce(artemis_stablecoin_transfer_volume, 0) - coalesce(p2p_stablecoin_transfer_volume, 0) as non_p2p_stablecoin_transfer_volume,
coalesce(dex_volumes, 0) + coalesce(nft_trading_volume, 0) + coalesce(p2p_transfer_volume, 0) as settlement_volume,
blob_fees_native,
blob_fees,
Expand Down
5 changes: 2 additions & 3 deletions models/projects/eurc/core/ez_eurc_metrics.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{
config(
materialized="incremental",
unique_key="date",
materialized="table",
snowflake_warehouse="EURC",
database="eurc",
schema="core",
alias="ez_metrics",
)
}}

{{ get_stablecoin_ez_metrics("EURC") }}
{{ get_stablecoin_metrics("EURC", breakdown='symbol') }}
13 changes: 10 additions & 3 deletions models/projects/optimism/core/ez_optimism_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,21 @@ select
stablecoin_total_supply,
stablecoin_txns,
stablecoin_dau,
stablecoin_mau,
stablecoin_transfer_volume,
deduped_stablecoin_transfer_volume,
artemis_stablecoin_txns,
artemis_stablecoin_dau,
artemis_stablecoin_mau,
artemis_stablecoin_transfer_volume,
p2p_stablecoin_txns,
p2p_stablecoin_dau,
p2p_stablecoin_mau,
p2p_stablecoin_transfer_volume,
nft_trading_volume,
p2p_native_transfer_volume,
p2p_token_transfer_volume,
p2p_stablecoin_transfer_volume,
p2p_transfer_volume,
coalesce(deduped_stablecoin_transfer_volume, 0) - coalesce(p2p_stablecoin_transfer_volume, 0) as non_p2p_stablecoin_transfer_volume,
coalesce(artemis_stablecoin_transfer_volume, 0) - coalesce(p2p_stablecoin_transfer_volume, 0) as non_p2p_stablecoin_transfer_volume,
coalesce(dex_volumes, 0) + coalesce(nft_trading_volume, 0) + coalesce(p2p_transfer_volume, 0) as settlement_volume
from fundamental_data
left join price_data on fundamental_data.date = price_data.date
Expand Down
Loading

0 comments on commit ababc49

Please sign in to comment.