Query editor
WITH successful_transactions AS (SELECTcreated_at,fid,parent_fid,hash,LOWER(SUBSTR(SUBSTR(text, STRPOS(text, 'tx/') + 3, 66), 3)) AS transaction_id,text,idFROM dune.neynar.dataset_farcaster_castsWHEREfid = 886870-- AND text LIKE '%Your transaction was successful:%'), transactions_with_trade_details AS (SELECTst.created_at,st.transaction_id,st.parent_fid AS trader_fid,st.hash AS cast_hash,t.token_bought_symbol,t.token_sold_symbol,t.token_bought_amount,t.token_sold_amount,t.amount_usd,t.taker,t.makerFROM successful_transactions AS stJOIN dex.trades AS tON st.transaction_id = LOWER(TO_HEX(t.tx_hash))WHEREt.blockchain = 'base')SELECTdate_trunc('day', created_at) as created,--token_bought_symbol,SUM(amount_usd) AS volume,COUNT(DISTINCT taker) AS unique_traders,SUM(amount_usd * 0.008) as fee,SUM(SUM(amount_usd)) OVER (ORDER BY date_trunc('day', created_at)) AS cumulative_volume,SUM(COUNT(DISTINCT taker)) OVER (ORDER BY date_trunc('day', created_at)) AS cumulative_unique_traders,SUM(SUM(amount_usd * 0.008)) OVER (ORDER BY date_trunc('day', created_at)) AS cumulative_feeFROM transactions_with_trade_detailsGROUP BY1ORDER BY1 DESC