Skip to content

Commit

Permalink
adding jupiter perps txns + ez metrics by chain (#456)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwes authored Sep 5, 2024
1 parent fd298e2 commit c186381
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
3 changes: 2 additions & 1 deletion models/projects/jupiter/ez_jupiter_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ with
from {{ ref("fact_jupiter_fees_silver") }}
),
perps_data as (
select date, volume, traders
select date, volume, traders, txns
from {{ ref("fact_jupiter_perps_silver")}}
),
price_data as ({{ get_coingecko_metrics("jupiter-exchange-solana") }})
Expand All @@ -25,6 +25,7 @@ select
fees_data.fees as fees,
volume as trading_volume,
traders as unique_traders,
txns,
price,
market_cap,
fdmc
Expand Down
34 changes: 34 additions & 0 deletions models/projects/jupiter/ez_jupiter_metrics_by_chain.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{
config(
materialized="table",
snowflake_warehouse="JUPITER",
database="jupiter",
schema="core",
alias="ez_metrics_by_chain",
)
}}

with
fees_data as (
select date, fees
from {{ ref("fact_jupiter_fees_silver") }}
),
perps_data as (
select date, volume, traders, txns
from {{ ref("fact_jupiter_perps_silver")}}
),
price_data as ({{ get_coingecko_metrics("jupiter-exchange-solana") }})
select
fees_data.date as date,
'solana' as chain,
fees_data.fees as fees,
volume as trading_volume,
traders as unique_traders,
txns,
price,
market_cap,
fdmc
from fees_data
left join perps_data on perps_data.date = fees_data.date
left join price_data on fees_data.date = price_data.date
where fees_data.date < to_date(sysdate())
8 changes: 7 additions & 1 deletion models/projects/jupiter/fact_jupiter_perps_silver.sql
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,10 @@ perps_mat as(
FROM hex_cte
WHERE substring(hex_data,1+16,16) IN ('68452084d423bf2f', '806547a880485654') --LiquidatePosition, LiquidateFullPosition
)
SELECT date, sum(size_usd) as volume, sum(fees_usd) as fees, count(distinct owner) as traders FROM perps_mat group by 1 order by 1 desc
SELECT
date
, sum(size_usd) as volume
, sum(fees_usd) as fees
, count(distinct owner) as traders
, count(distinct tx_id) as txns
FROM perps_mat group by 1 order by 1 desc

0 comments on commit c186381

Please sign in to comment.