Query editor
WITH fxh_price_latest AS (SELECT hour_vwap_fxh_usd AS fxh_usdFROM query_5495538ORDER BY block_hour DESCLIMIT 1),art_tokens AS (SELECT DISTINCT graduatedToken AS addressFROM fxhash_base.tokenlaunchpad_evt_graduated),trading AS (-- art token was BOUGHT (the other leg = FXH sold)SELECTDATE_TRUNC('day', block_time) AS block_date,token_bought_address AS token_address,tx_from AS user_address, -- << confirm column >>token_sold_amount * (SELECT fxh_usd FROM fxh_price_latest) AS amount_usdFROM dex.tradesWHERE blockchain = 'base'AND token_bought_address IN (SELECT address FROM art_tokens)UNION ALL-- art token was SOLD (the other leg = FXH bought)SELECTDATE_TRUNC('day', block_time) AS block_date,token_sold_address AS token_address,tx_from AS user_address, -- << confirm column >>token_bought_amount * (SELECT fxh_usd FROM fxh_price_latest) AS amount_usdFROM dex.tradesWHERE blockchain = 'base'AND token_sold_address IN (SELECT address FROM art_tokens)),daily AS (SELECTblock_date AS period,COUNT(DISTINCT user_address) AS unique_users,COUNT(*) AS txs,SUM(amount_usd) AS total_amountFROM tradingGROUP BY 1)SELECTperiod,unique_users,txs,total_amount,-- running cumulative USDSUM(total_amount) OVER (ORDER BY periodROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cumulative_total_amountFROM dailyORDER BY period DESC;