Query editor
WITH/* Get all RUNNER trades with exact timestamps */runner_trades AS (SELECTblock_time,amount_usd / NULLIF(token_bought_amount, 0) as price,amount_usdFROM dex.tradesWHERE token_bought_address = 0x18b6f6049A0af4Ed2BBe0090319174EeeF89f53aAND block_time >= DATE '2025-08-20' - INTERVAL '1' DAYAND block_time < DATE '2025-10-25' -- Changed to include full 10/24AND amount_usd > 0 AND token_bought_amount > 0AND amount_usd < 1000000UNION ALLSELECTblock_time,amount_usd / NULLIF(token_sold_amount, 0) as price,amount_usdFROM dex.tradesWHERE token_sold_address = 0x18b6f6049A0af4Ed2BBe0090319174EeeF89f53aAND block_time >= DATE '2025-08-20' - INTERVAL '1' DAYAND block_time < DATE '2025-10-25' -- Changed to include full 10/24AND amount_usd > 0 AND token_sold_amount > 0AND amount_usd < 1000000),/* Clean trades with reasonable prices */clean_trades AS (SELECT DISTINCTblock_time,priceFROM runner_tradesWHERE price > 0.00000001 AND price < 1000),/* RUNNER token outflows - CORRECTED DATE RANGE */runner_outflows AS (SELECTt.evt_block_time,DATE(t.evt_block_time) AS transfer_date,CAST(t.evt_tx_hash AS VARCHAR) AS evt_tx_hash,CAST(t.to AS VARCHAR) AS recipient,CAST(t.value AS DOUBLE) / 1e18 AS runner_amountFROM erc20_base.evt_transfer tWHERE t.contract_address = 0x18b6f6049A0af4Ed2BBe0090319174EeeF89f53aAND t."from" = 0xc7432bD4Fec564D04f5e2d88ea221229D3215dcaAND t.evt_block_time >= DATE '2025-08-20'AND t.evt_block_time < DATE '2025-10-25' -- Changed to include full 10/24AND CAST(t.value AS DOUBLE) > 0),/* Cross join to find closest prices */price_matches AS (SELECTro.*,ct.price,ct.block_time as trade_time,ABS(DATE_DIFF('second', ct.block_time, ro.evt_block_time)) as seconds_diff,