Query editor
WITH latest_day AS (SELECT DATE_TRUNC('day', MAX(block_time)) as latest_dateFROM dex_solana.tradesWHERE project = 'raydium'),withdraws AS (SELECT DISTINCTaccount_arguments[3] AS token_addressFROM solana.instruction_callsWHEREexecuting_account = '6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P'AND BYTEARRAY_SUBSTRING(data, 1, 8) = 0xb712469c946da122 /* global:withdraw sha256 first 8 byte */AND tx_success = TRUE),token_volumes AS (SELECTDATE_TRUNC('day', t.block_time) as trade_date,CASEWHEN t.token_bought_mint_address IN (SELECT token_address FROM withdraws) THEN t.token_bought_mint_addressWHEN t.token_sold_mint_address IN (SELECT token_address FROM withdraws) THEN t.token_sold_mint_addressEND as token_address,SUM(t.amount_usd) as token_volumeFROM dex_solana.trades tJOIN latest_day ld ON DATE_TRUNC('day', t.block_time) = ld.latest_dateWHERE t.project = 'raydium'AND (t.token_bought_mint_address IN (SELECT token_address FROM withdraws)OR t.token_sold_mint_address IN (SELECT token_address FROM withdraws))GROUP BY 1, 2)SELECTtrade_date,token_address,token_volume,SUM(token_volume) OVER (ORDER BY token_volume ASC) as cumulative_volumeFROM token_volumesWHERE token_address IS NOT NULLORDER BY token_volume DESC