Query editor
WITHvol_eom AS (SELECTCAST(date_trunc('month', metric_date) AS DATE) AS month_start,metric_date,CAST(ethereum_cumulative_volume AS DOUBLE) AS eth_cum,CAST(starknet_cumulative_volume AS DOUBLE) AS sn_cumFROM query_5706539),vol_eom_rank AS (SELECTmonth_start, metric_date, eth_cum, sn_cum,ROW_NUMBER() OVER (PARTITION BY month_start ORDER BY metric_date DESC) AS rnFROM vol_eom),vol_eom_picked AS (SELECT month_start, eth_cum AS eth_cum_eom, sn_cum AS sn_cum_eomFROM vol_eom_rankWHERE rn = 1),vol_monthly AS (SELECTmonth_start,COALESCE(eth_cum_eom - LAG(eth_cum_eom) OVER (ORDER BY month_start), eth_cum_eom) AS ethereum_monthly_volume_usd,COALESCE(sn_cum_eom - LAG(sn_cum_eom) OVER (ORDER BY month_start), sn_cum_eom) AS starknet_monthly_volume_usdFROM vol_eom_picked),oi_base AS (SELECTCAST(date_trunc('month', metric_date) AS DATE) AS month_start,metric_date,CAST(ethereum_daily_open_interest_usd AS DOUBLE) AS eth_oi,CAST(starknet_daily_open_interest_usd AS DOUBLE) AS sn_oiFROM query_5709695),oi_rank AS (SELECTmonth_start, metric_date, eth_oi, sn_oi,ROW_NUMBER() OVER (PARTITION BY month_start ORDER BY metric_date DESC) AS rnFROM oi_base),oi_eom AS (SELECTmonth_start,eth_oi AS ethereum_eom_open_interest_usd,sn_oi AS starknet_eom_open_interest_usdFROM oi_rankWHERE rn = 1),tvl_base AS (SELECTCAST(date_trunc('month', day) AS DATE) AS month_start,day,CAST(balance_ethereum AS DOUBLE) AS balance_ethereum,CAST(balance_starknet AS DOUBLE) AS balance_starknetFROM query_5706907),tvl_rank AS (