Skip to content

Commit

Permalink
Stablecoin V2: Adding new stablecoin models (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebMelendez01 authored Aug 14, 2024
1 parent 5f355ac commit 39ea0b8
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 0 deletions.
37 changes: 37 additions & 0 deletions macros/stablecoins/stablecoin_breakdown.sql
Original file line number Diff line number Diff line change
@@ -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 %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{ config(materialized="table", snowflake_warehouse="STABLECOIN_V2_LG") }}

{{ stablecoin_breakdown(["category"]) }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{ config(materialized="table", snowflake_warehouse="STABLECOIN_V2_LG_2") }}

{{stablecoin_breakdown(["chain", "category"])}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{ config(materialized="table", snowflake_warehouse="STABLECOIN_V2_LG_2") }}
{{ stablecoin_breakdown(["chain", "category", "symbol"]) }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{ config(materialized="table", snowflake_warehouse="STABLECOIN_V2_LG") }}

{{ stablecoin_breakdown(["chain"]) }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{ config(materialized="table", snowflake_warehouse="STABLECOIN_V2_LG") }}

{{ stablecoin_breakdown(["symbol"]) }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{ config(materialized="table", snowflake_warehouse="STABLECOIN_V2_LG_2") }}

{{ stablecoin_breakdown(["symbol", "chain"]) }}

0 comments on commit 39ea0b8

Please sign in to comment.