Query editor
-- Query: Index Coop Product KPIs-- Dune ID: 2856053-- URL: https://dune.com/queries/2856053-- Description: TVL, NSF, cumulative NSF per product over time-- Parameters: {{End Date:}}, {{Trailing Days:}}---- Columns: day, symbol, unit_flow, unit_supply, price, nsf, tvl, c_nsf-- Depends on: query_2364999 (unit supply), result_index_coop_token_prices_daily (2812068), query_2364870 (tokens)withdaily_summary as (selects.day, s.symbol, coalesce(s.unit_flow, 0) as unit_flow, coalesce(s.unit_supply, 0) as unit_supply, p.price, coalesce(s.unit_flow, 0) * p.price as nsf, coalesce(s.unit_supply, 0) * p.price as tvlfrom query_2364999 sleft join dune.index_coop.result_index_coop_token_prices_daily pon s.day = p.dayand s.address = p.token_addressand s.blockchain = p.blockchainwhere price is not null), total as (selectday, 'Total' as symbol, 0 as unit_flows, 0 as supply, 0 as price, sum(nsf) as nsf, sum(tvl) as tvlfrom daily_summarygroup by 1, 2, 3, 4, 5), summary as (select * from daily_summaryunionselect * from total), final as (select*, sum(nsf) over (partition by symbol order by day asc rows between unbounded preceding and current row) as c_nsffrom summary)selects.*from final sleft join query_2364870 ion s.symbol = i.symboland i.is_bridged = false