Query editor
WITH moonshot_txs AS (SELECTtx_id,from_ownerFROM tokens_solana.transfersWHERE to_owner = '5wkyL2FLEcyUUgc3UeGntHTAfWfzDrVuxMnaMm7792Gk'),trades AS (-- SELECT-- a.block_time-- ,tx_id-- ,from_owner as tx_from-- ,'TRUMP' as token_symbol-- ,token_bought_amount-- ,amount_usd-- FROM dex_solana.trades a-- INNER JOIN moonshot_txs b USING(tx_id)-- WHERE token_bought_mint_address = '6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN'SELECTa.block_time,tx_id,signers[2] as tx_from,'TRUMP' as token_symbol,'sell' as direction,token_bought_amount,amount_usdFROM dex_solana.trades aINNER JOIN solana.transactions b ON a.tx_id = b.id AND DATE(a.block_time) = b.block_dateWHERE token_sold_mint_address = '6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN'and trader_id = '7rtiKSUDLBm59b1SBmD9oajcP8xE64vAGSMbAN5CXy1q'AND b.block_date >= DATE('2025-01-17')UNION ALLSELECTa.block_time,tx_id,signers[2] as tx_from,'TRUMP' as token_symbol,'buy' as direction,token_bought_amount,amount_usdFROM dex_solana.trades aINNER JOIN solana.transactions b ON a.tx_id = b.id AND DATE(a.block_time) = b.block_dateWHERE token_bought_mint_address = '6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN'and trader_id = '7rtiKSUDLBm59b1SBmD9oajcP8xE64vAGSMbAN5CXy1q'AND b.block_date >= DATE('2025-01-17'))SELECTdate_trunc('hour',block_time) as time,token_symbol,SUM(CASE WHEN direction = 'buy' THEN amount_usd ELSE 0 END) AS buy_volume,SUM(CASE WHEN direction = 'sell' THEN amount_usd ELSE 0 END) AS sell_volume,SUM(CASE WHEN direction = 'buy' THEN amount_usd ELSE 0 END) -SUM(CASE WHEN direction = 'sell' THEN amount_usd ELSE 0 END) AS net_volume,SUM(SUM(amount_usd)) OVER (ORDER BY date_trunc('hour', block_time)) AS cu_vol