Skip to content

Commit

Permalink
Son/drift update (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunny77D authored Dec 13, 2024
1 parent 2edf63a commit 6db70d7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions models/staging/drift/fact_drift_amm_revenue.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
WITH fact_drift_daily_perp_data AS (
SELECT
date
, max(latest_timestamp) as latest_timestamp
, sum(latest_excess_pnl) as latest_excess_pnl
FROM
{{ref('fact_drift_daily_perp_data')}}
GROUP BY 1
)
SELECT
date
, latest_timestamp
, latest_excess_pnl - LAG(latest_excess_pnl) OVER (ORDER BY date) as total_revenue
, latest_excess_pnl
FROM
Expand Down
1 change: 1 addition & 0 deletions models/staging/drift/fact_drift_daily_perp_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SELECT
AVG(value:oi_net::float) as daily_avg_net_open_interest,
AVG(value:net_user_pnl::float) as daily_avg_net_user_pnl,
MAX_BY(value:excess_pnl::float, TO_TIMESTAMP(value:timestamp::string, 'YYYY/MM/DD HH24:MI:SS')) as latest_excess_pnl,
MAX(TO_TIMESTAMP(value:timestamp::string, 'YYYY/MM/DD HH24:MI:SS')) as latest_timestamp,
AVG(value:est_funding_dollars::float) as daily_avg_est_funding_dollars
FROM {{ source("PROD_LANDING", "raw_drift_perp_market_data") }} ,
lateral flatten(input => parse_json(source_json))
Expand Down

0 comments on commit 6db70d7

Please sign in to comment.