Query editor
WITH exit_requests AS (SELECTdate_add('hour', - (extract(hour from block_time) % 8), date_trunc('hour', block_time)) AS time,COUNT(*) AS new_exit_requests -- per 8 hours 新退出請求數FROM beacon.voluntary_exitsWHERE block_time >= CURRENT_TIMESTAMP - INTERVAL '1' YEARAND block_time <= CURRENT_TIMESTAMPGROUP BY 1),entrance_requests AS (SELECTdate_add('hour', - (extract(hour from block_time) % 8), date_trunc('hour', block_time)) AS time,COUNT(*) AS new_entrance_requests -- per 8 hours 新進入請求數FROM ethereum.logsWHERE contract_address = 0x00000000219ab540356cbb839cbe05303d7705faAND topic0 = 0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5AND block_time >= CURRENT_TIMESTAMP - INTERVAL '1' YEARAND block_time <= CURRENT_TIMESTAMPGROUP BY 1),price_data AS (SELECTdate_add('hour', - (extract(hour from minute) % 8), date_trunc('hour', minute)) AS time,AVG(price) AS eth_priceFROM prices.usdWHERE symbol = 'ETH'AND contract_address IS NULLAND minute >= CURRENT_TIMESTAMP - INTERVAL '1' YEARAND minute <= CURRENT_TIMESTAMPGROUP BY 1ORDER BY 1),combined_requests AS (SELECTCOALESCE(ent.time, ex.time) AS time,COALESCE(ent.new_entrance_requests, 0) AS new_entrance_requests,COALESCE(ex.new_exit_requests, 0) AS new_exit_requests,COALESCE(ent.new_entrance_requests, 0) - COALESCE(ex.new_exit_requests, 0) AS net_requestsFROM entrance_requests entFULL OUTER JOIN exit_requests ex ON ent.time = ex.time)SELECTCOALESCE(cr.time, p.time) AS time,cr.new_entrance_requests,cr.new_exit_requests,cr.net_requests,p.eth_priceFROM combined_requests crFULL OUTER JOIN price_data p ON cr.time = p.timeWHERE COALESCE(cr.time, p.time) IS NOT NULLORDER BY time DESC