Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stablecoins Cleanup: using macro to waterfall prices #519

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions macros/p2p/p2p_stablecoin_transfers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,7 @@ with
t1.from_address,
t1.to_address,
t1.amount,
transfer_volume * coalesce(
p.shifted_token_price_usd,
case
when c.coingecko_id = 'euro-coin' then ({{ avg_l7d_coingecko_price('euro-coin') }})
when c.coingecko_id = 'celo-euro' then ({{ avg_l7d_coingecko_price('celo-euro') }})
when c.coingecko_id = 'celo-real-creal' then ({{ avg_l7d_coingecko_price('celo-real-creal') }})
when c.coingecko_id = 'celo-kenyan-shilling' then ({{ avg_l7d_coingecko_price('celo-kenyan-shilling') }})
else 1
end
) as amount_usd
transfer_volume * {{waterfall_stablecoin_prices('c', 'd')}} as amount_usd
from stablecoin_transfers t1
join {{ ref("fact_"~chain~"_stablecoin_contracts") }} c
on lower(t1.contract_address) = lower(c.contract_address)
Expand Down
11 changes: 1 addition & 10 deletions macros/stablecoins/stablecoin_balances.sql
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,7 @@ with
, st.contract_address
, st.symbol
, stablecoin_supply_native
, stablecoin_supply_native * coalesce(
d.shifted_token_price_usd,
case
when c.coingecko_id = 'euro-coin' then ({{ avg_l7d_coingecko_price('euro-coin') }})
when c.coingecko_id = 'celo-euro' then ({{ avg_l7d_coingecko_price('celo-euro') }})
when c.coingecko_id = 'celo-real-creal' then ({{ avg_l7d_coingecko_price('celo-real-creal') }})
when c.coingecko_id = 'celo-kenyan-shilling' then ({{ avg_l7d_coingecko_price('celo-kenyan-shilling') }})
else 1
end
) as stablecoin_supply
, stablecoin_supply_native * {{waterfall_stablecoin_prices('c', 'd')}} as stablecoin_supply
from historical_supply_by_address_balances st
left join {{ ref( "fact_" ~ chain ~ "_stablecoin_contracts") }} c
on lower(st.contract_address) = lower(c.contract_address)
Expand Down
11 changes: 1 addition & 10 deletions macros/stablecoins/stablecoin_metrics_all.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,7 @@ with
, stablecoin_metrics.contract_address
, stablecoin_metrics.symbol
, from_address
, stablecoin_transfer_volume * coalesce(
d.shifted_token_price_usd,
case
when c.coingecko_id = 'euro-coin' then ({{ avg_l7d_coingecko_price('euro-coin') }})
when c.coingecko_id = 'celo-euro' then ({{ avg_l7d_coingecko_price('celo-euro') }})
when c.coingecko_id = 'celo-real-creal' then ({{ avg_l7d_coingecko_price('celo-real-creal') }})
when c.coingecko_id = 'celo-kenyan-shilling' then ({{ avg_l7d_coingecko_price('celo-kenyan-shilling') }})
else 1
end
) as stablecoin_transfer_volume
, stablecoin_transfer_volume * {{waterfall_stablecoin_prices('c', 'd')}} as stablecoin_transfer_volume
, stablecoin_daily_txns
from stablecoin_metrics
left join {{ ref( "fact_" ~ chain ~ "_stablecoin_contracts") }} c
Expand Down
11 changes: 1 addition & 10 deletions macros/stablecoins/stablecoin_metrics_artemis.sql
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,7 @@ with
, stablecoin_metrics.contract_address
, stablecoin_metrics.symbol
, from_address
, stablecoin_transfer_volume * coalesce(
d.shifted_token_price_usd,
case
when c.coingecko_id = 'euro-coin' then ({{ avg_l7d_coingecko_price('euro-coin') }})
when c.coingecko_id = 'celo-euro' then ({{ avg_l7d_coingecko_price('celo-euro') }})
when c.coingecko_id = 'celo-real-creal' then ({{ avg_l7d_coingecko_price('celo-real-creal') }})
when c.coingecko_id = 'celo-kenyan-shilling' then ({{ avg_l7d_coingecko_price('celo-kenyan-shilling') }})
else 1
end
) as stablecoin_transfer_volume
, stablecoin_transfer_volume * {{waterfall_stablecoin_prices('c', 'd')}} as stablecoin_transfer_volume
, stablecoin_daily_txns
from stablecoin_metrics
left join {{ ref( "fact_" ~ chain ~ "_stablecoin_contracts") }} c
Expand Down
Loading