Query editor
-- Incremental Volume Query with start_date Parameter-- Fork of Query ID: 6422948-- Returns daily volume data for each token, starting from a specified date---- Parameters:-- {{start_date}}: Start date for data fetch (format: YYYY-MM-DD, e.g., '2025-10-09')-- {{token_list}}: comma-separated token addresses in format 'token1', 'token2'-- Use '__ALL__' to fetch all tokens (required - can't be empty)---- Usage:-- - For full backfill: start_date = '2025-10-09', token_list = '__ALL__'-- - For incremental: start_date = last fetched date (e.g., '2026-01-05')-- - For specific tokens: token_list = 'token1', 'token2', 'token3'WITH filtered_and_extracted AS (-- Combine filtering and extraction in one pass to reduce I/O-- Extract only what we need, when we need itSELECTblock_time,CAST(block_time AS DATE) AS trading_date,tx_id,-- Extract token immediately during scanCASEWHEN LENGTH(data) = 406 THEN to_base58(SUBSTR(data, 279, 32))WHEN LENGTH(data) = 670 THEN to_base58(SUBSTR(data, 543, 32))END AS token,-- Extract swap_type onceCASEWHEN to_hex(SUBSTR(data, 105, 1)) = '00' THEN 'buy'WHEN to_hex(SUBSTR(data, 105, 1)) = '01' THEN 'sell'END AS swap_type,-- Pre-calculate amounts (divide by 1e6 once)from_big_endian_64(reverse(SUBSTR(data, 106, 8))) / 1e6 AS input_amount,from_big_endian_64(reverse(SUBSTR(data, 114, 8))) / 1e6 AS output_amount,-- Extract quote_mint if needed for debuggingCASEWHEN LENGTH(data) = 406 THEN to_base58(SUBSTR(data, 311, 32))WHEN LENGTH(data) = 670 THEN to_base58(SUBSTR(data, 575, 32))END AS quote_mintFROM solana.instruction_callsWHERE-- Use parameterized start_date for incremental fetchingblock_time >= TIMESTAMP '{{start_date}}'AND tx_success = trueAND executing_account = 'FUTARELBfJfQ8RDGhg1wdhddq1odMAJUePHFuBYfUxKq'AND inner_executing_account = 'FUTARELBfJfQ8RDGhg1wdhddq1odMAJUePHFuBYfUxKq'AND account_arguments[1] = 'DGEympSS4qLvdr9r3uGHTfACdN8snShk4iGdJtZPxuBC'AND is_inner = true-- More expensive filters lastAND cardinality(account_arguments) = 1AND CAST(data AS VARCHAR) LIKE '0xe445a52e51cb9a1d%'AND LENGTH(data) >= 300AND array_join(log_messages, ' ') LIKE '%SpotSwap%'),token_filtered AS (-- Apply token filter and quality checksSELECTblock_time,trading_date,tx_id,