Query editor
WITH liquidium_tx AS (SELECTCAST(tx_id AS VARCHAR) AS tx_id,CAST(from_iso8601_timestamp(start_date) AS TIMESTAMP) AS start_date, -- Handle ISO 8601 timestampborrower_taproot,lender_taproot,borrower_segwit,lender_segwit,principal_amount_sats / 100000000.0 AS principal_amount_btc, -- Convert sats to BTCcollateraltype,slugFROM dune.liquidiumfi.dataset_liquidium_v2UNION ALLSELECTCAST(tx_id AS VARCHAR) AS tx_id,CAST(from_iso8601_timestamp(start_date) AS TIMESTAMP) AS start_date, -- Handle ISO 8601 timestampborrower_taproot,lender_taproot,borrower_segwit,lender_segwit,principal_amount_sats / 100000000.0 AS principal_amount_btc, -- Convert sats to BTCcollateraltype,slugFROM dune.liquidiumfi.dataset_liquidium_v3UNION ALLSELECTDISTINCT tx_id,CAST(from_iso8601_timestamp(start_date) AS TIMESTAMP) AS start_date, -- Handle ISO 8601 timestampborrower_taproot,lender_taproot,borrower_segwit,lender_segwit,principal_amount_sats / 100000000.0 AS principal_amount_btc, -- Convert sats to BTCcollateraltype,slugFROM dune.liquidiumfi.liquidium_tx3_live),-- Add week_start outside of liquidium_txliquidium_tx_with_week AS (SELECTDATE_TRUNC('week', start_date) AS week_start, -- Truncate to start of the weekslug,principal_amount_btc,collateraltypeFROM liquidium_tx),-- Aggregate volumes for Rune collections per weekrune_volumes AS (SELECTweek_start,slug AS rune_slug,SUM(principal_amount_btc) AS rune_volume_btcFROM liquidium_tx_with_weekWHERE collateraltype = 'Rune'GROUP BY week_start, slugHAVING SUM(principal_amount_btc) > 0 -- Exclude zero-volume slugs),-- Aggregate volumes for Ordinals collections per weekordinal_volumes AS (SELECT