Query editor
WITH tab1 AS (SELECT tx_hashFROM hyperevm.logs_decodedWHERE contract_address = from_hex('ff7b3e8c00e57ea31477c32a5b52a58eea47b072')AND event_name = 'PoolCreated'),tab2 AS (SELECT DISTINCT contract_addressFROM hyperevm.logsWHERE tx_hash IN (SELECT tx_hash FROM tab1)AND not contract_address = from_hex('ff7b3e8c00e57ea31477c32a5b52a58eea47b072')), tab3 as (SELECTblock_time,tx_hash,concat('0x', to_hex(contract_address)) AS address,concat('0x', to_hex(topic0)) AS topic0,topic1,topic2,concat('0x', to_hex(bytearray_substring(topic1, 13, 20))) AS indexed_1,concat('0x', to_hex(bytearray_substring(topic2, 13, 20))) AS indexed_2,try(varbinary_to_uint256(bytearray_substring(data, 1, 32))) AS amtFROM hyperevm.logs--WHERE tx_hash = from_hex('ccec62b5266538d763fc11ab96a9ec5cde5f7e663930ff00677e39620bc289cd')-- keep comparisons in VARBINARY spacewhere contract_address NOT IN (SELECT contract_address FROM tab2)AND (bytearray_substring(topic1, 13, 20) IN (SELECT contract_address FROM tab2)OR bytearray_substring(topic2, 13, 20) IN (SELECT contract_address FROM tab2))), tab4 as (selectdate_trunc('day', time) as day,avg(case when coin = 'HYPE' then oracle_px end) as hype_price,avg(case when coin = 'ETH' then oracle_px end) as eth_price,avg(case when coin = 'BTC' then oracle_px end) as btc_price,avg(case when coin = 'FARTCOIN' then oracle_px end) as fart_pricefrom hyperliquid.market_datawhere coin in ('HYPE', 'ETH', 'BTC', 'FARTCOIN')group by 1), tab5 as (selectblock_time,tx_hash,casewhen bytearray_substring(topic1, 13, 20) in (SELECT contract_address FROM tab2) then indexed_1when bytearray_substring(topic2, 13, 20) in (SELECT contract_address FROM tab2) then indexed_2end as pool,sum(case when bytearray_substring(topic1, 13, 20) in (SELECT contract_address FROM tab2) then 1 else 0 end) as inflows,sum(case when bytearray_substring(topic2, 13, 20) in (SELECT contract_address FROM tab2) then 1 else 0 end) as outflows,avg(value_usd) as swap_value_usd,sum(case when address = '0x5555555555555555555555555555555555555555' then 1 else 0 end) as is_hypefrom (select*,casewhen address = '0xB8CE59FC3717ADA4C02EADF9682A9E934F625EBB' then amt / power(10, 6)when address = '0xB50A96253ABDF803D85EFCDCE07AD8BECBC52BD5' then amt / power(10, 6)