Query editor
/* ===================================================================================================================Pendle TVL and Revenue DailyA Demonstration of the calculation of Pendle TVL and Revenue metricsDetailed explanations are available in the dependent query.NOTE on freshness: the p_team.result_* materialized views below currentlyrefresh WEEKLY (Thursdays ~01:22-01:57 UTC), and dune.p_team.sy_price_dailyis synced daily at 00:30 UTC from BigQuery -- BEFORE the day's prices landthere, so the price feed trails by ~2 days. The HAVING guard in daily_tvldrops the trailing unpriced days so the report always ends on the latestday that has real USD values instead of showing a NULL/empty tail.=================================================================================================================== */with daily_tvl as (select ds, sum(sy_value_in_usd) as pendle_tvlfrom dune.p_team.result_pendle_market_tvl_tracker -- materialized view of query_5530935, refreshed weekly (Thu ~01:22 UTC)where ds != current_dategroup by 1-- drop trailing days where sy_price_daily has no prices yet (sy_value_in_usd all NULL):having sum(sy_value_in_usd) is not null), daily_revenue as (select ds,sum(yt_fees_in_usd) as yt_fees_in_usd,sum(amm_swap_fees_in_usd) as amm_swap_fees_in_usd,sum(limit_order_fees_in_usd) as limit_order_fees_in_usd,sum(other_fees_in_usd) as other_fees_in_usd,sum(yt_fees_revenue_in_usd) as yt_fees_revenue_in_usd,sum(amm_swap_fees_revenue_in_usd) as amm_swap_fees_revenue_in_usd,sum(limit_order_fees_revenue_in_usd) as limit_order_fees_revenue_in_usd,sum(other_fees_revenue_in_usd) as other_fees_revenue_in_usdfrom dune.p_team.result_pendle_revenue_tracker daily_revenue -- materialized view of query_5533886, refreshed weekly (Thu ~01:22 UTC)group by 1), daily_volume as (select ds,sum(amm_sy_volume_in_usd) as amm_volume_in_usd,sum(limit_order_sy_volume_in_usd) as limit_order_volume_in_usd,sum(amm_sy_volume_in_usd) + sum(limit_order_sy_volume_in_usd) as volume_in_usdfrom (select ds, 0 as amm_sy_volume_in_usd, limit_order_sy_volume_in_usdfrom dune.p_team.result_pendle_limit_order_notional_trading_volume_by_chain_and_market -- materialized view of query_5547427, refreshed weekly (Thu ~01:57 UTC)union allselect ds, amm_sy_volume_in_usd, 0 as limit_order_sy_volume_in_usdfrom dune.p_team.result_pendle_amm_notional_trading_volume_by_chain_and_market -- materialized view of query_5547253, refreshed weekly (Thu ~01:54 UTC))group by 1)select daily_tvl.ds,daily_tvl.pendle_tvl,daily_revenue.yt_fees_in_usd,daily_revenue.amm_swap_fees_in_usd,daily_revenue.limit_order_fees_in_usd,daily_revenue.other_fees_in_usd,daily_revenue.yt_fees_in_usd+ daily_revenue.amm_swap_fees_in_usd+ daily_revenue.limit_order_fees_in_usd+ daily_revenue.other_fees_in_usd as total_fees,daily_revenue.yt_fees_revenue_in_usd+ daily_revenue.amm_swap_fees_revenue_in_usd+ daily_revenue.limit_order_fees_revenue_in_usd