diff --git a/macros/stablecoins/stablecoin_breakdown.sql b/macros/stablecoins/stablecoin_breakdown.sql new file mode 100644 index 00000000..97e13903 --- /dev/null +++ b/macros/stablecoins/stablecoin_breakdown.sql @@ -0,0 +1,37 @@ +{% macro stablecoin_breakdown(breakdowns=[]) %} +select + date + {% for breakdown in breakdowns %} + , {{ breakdown }} + {% endfor %} + , count(distinct case when stablecoin_daily_txns > 0 then from_address end) as stablecoin_dau + , sum(stablecoin_transfer_volume) as stablecoin_transfer_volume + , sum(stablecoin_daily_txns) as stablecoin_daily_txns + , case + when sum(stablecoin_daily_txns) > 0 then sum(stablecoin_transfer_volume) / sum(stablecoin_daily_txns) + else 0 + end as stablecoin_avg_txn_value + , count(distinct case when artemis_stablecoin_daily_txns > 0 then from_address end) as artemis_stablecoin_dau + , sum(artemis_stablecoin_transfer_volume) as artemis_stablecoin_transfer_volume + , sum(artemis_stablecoin_daily_txns) as artemis_stablecoin_daily_txns + , case + when sum(artemis_stablecoin_daily_txns) > 0 then sum(artemis_stablecoin_transfer_volume) / sum(artemis_stablecoin_daily_txns) + else 0 + end as artemis_stablecoin_avg_txn_value + , count(distinct case when p2p_stablecoin_daily_txns > 0 then from_address end) as p2p_stablecoin_dau + , sum(p2p_stablecoin_transfer_volume) as p2p_stablecoin_transfer_volume + , sum(p2p_stablecoin_daily_txns) as p2p_stablecoin_daily_txns + , case + when sum(p2p_stablecoin_daily_txns) > 0 then sum(p2p_stablecoin_transfer_volume) / sum(p2p_stablecoin_daily_txns) + else 0 + end as p2p_stablecoin_avg_txn_value + + , sum(stablecoin_supply) as stablecoin_supply + , sum(case when is_wallet::number = 1 then stablecoin_supply else 0 end) as p2p_stablecoin_supply +from {{ ref("agg_daily_stablecoin_breakdown_silver") }} +group by date {% for breakdown in breakdowns %}, {{ breakdown }} {% endfor %} +order by date + + + +{% endmacro %} \ No newline at end of file diff --git a/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_category.sql b/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_category.sql new file mode 100644 index 00000000..eae95f8c --- /dev/null +++ b/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_category.sql @@ -0,0 +1,3 @@ +{{ config(materialized="table", snowflake_warehouse="STABLECOIN_V2_LG") }} + +{{ stablecoin_breakdown(["category"]) }} \ No newline at end of file diff --git a/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_category_chain.sql b/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_category_chain.sql new file mode 100644 index 00000000..353e7d2b --- /dev/null +++ b/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_category_chain.sql @@ -0,0 +1,3 @@ +{{ config(materialized="table", snowflake_warehouse="STABLECOIN_V2_LG_2") }} + +{{stablecoin_breakdown(["chain", "category"])}} diff --git a/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_category_symbol_chain.sql b/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_category_symbol_chain.sql new file mode 100644 index 00000000..1836627d --- /dev/null +++ b/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_category_symbol_chain.sql @@ -0,0 +1,2 @@ +{{ config(materialized="table", snowflake_warehouse="STABLECOIN_V2_LG_2") }} +{{ stablecoin_breakdown(["chain", "category", "symbol"]) }} diff --git a/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_chain.sql b/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_chain.sql new file mode 100644 index 00000000..544ac13f --- /dev/null +++ b/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_chain.sql @@ -0,0 +1,3 @@ +{{ config(materialized="table", snowflake_warehouse="STABLECOIN_V2_LG") }} + +{{ stablecoin_breakdown(["chain"]) }} \ No newline at end of file diff --git a/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_symbol.sql b/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_symbol.sql new file mode 100644 index 00000000..4c892b40 --- /dev/null +++ b/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_symbol.sql @@ -0,0 +1,3 @@ +{{ config(materialized="table", snowflake_warehouse="STABLECOIN_V2_LG") }} + +{{ stablecoin_breakdown(["symbol"]) }} diff --git a/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_symbol_chain.sql b/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_symbol_chain.sql new file mode 100644 index 00000000..4a9473fa --- /dev/null +++ b/models/metrics/stablecoins/breakdowns/agg_daily_stablecoin_breakdown_symbol_chain.sql @@ -0,0 +1,3 @@ +{{ config(materialized="table", snowflake_warehouse="STABLECOIN_V2_LG_2") }} + +{{ stablecoin_breakdown(["symbol", "chain"]) }}