Query editor
-- 24h KPI counters + spot USD price. Casts swap amounts to DECIMAL(38,0)-- before SUM to preserve precision on wei-scale sums. spot_price_usd_per_cashcat-- is the last swap's WETH/CASHCAT ratio multiplied by current-hour Ethereum--- mainnet WETH-USD (prices.usd), assuming Robinhood-chain WETH is a bridged/-- wrapped variant pegged to mainnet ETH.WITH swap_logs AS (SELECTblock_time,bytearray_substring(topic2, 13, 20) AS recipient,CAST(bytearray_to_int256(bytearray_substring(data, 1, 32)) AS DECIMAL(38,0)) AS amount0_raw,CAST(bytearray_to_int256(bytearray_substring(data, 33, 32)) AS DECIMAL(38,0)) AS amount1_rawFROM robinhood.logsWHERE contract_address = {{pool_address}}AND topic0 = 0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67AND block_time > now() - interval '24' hour),swap_stats AS (SELECTCOUNT(*) AS swaps_24h,CAST(SUM(CASE WHEN '{{cashcat_is_token0}}' = 'true' THEN abs(amount0_raw)ELSE abs(amount1_raw) END) AS DOUBLE)/ 1e18 AS swap_volume_cashcat_24h,COUNT(DISTINCT recipient) AS unique_swappers_24hFROM swap_logs),transfer_logs AS (SELECT topic1, topic2FROM robinhood.logsWHERE contract_address = 0x020bfc650a365f8bb26819deaabf3e21291018b4AND topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efAND block_time > now() - interval '24' hour),transfer_stats AS (SELECT(SELECT COUNT(*) FROM transfer_logs) AS transfers_24h,(SELECT COUNT(DISTINCT addr) FROM (SELECT bytearray_substring(topic1, 13, 20) AS addr FROM transfer_logsUNION ALLSELECT bytearray_substring(topic2, 13, 20) FROM transfer_logs) uWHERE addr <> 0x0000000000000000000000000000000000000000) AS unique_active_addrs_24h),last_swap_recent AS (SELECTCAST(bytearray_to_int256(bytearray_substring(data, 1, 32)) AS DOUBLE) AS amount0_raw,CAST(bytearray_to_int256(bytearray_substring(data, 33, 32)) AS DOUBLE) AS amount1_raw,block_timeFROM robinhood.logsWHERE contract_address = {{pool_address}}AND topic0 = 0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67AND block_time > now() - interval '30' dayORDER BY block_time DESCLIMIT 1),last_price_weth AS (SELECTCASEWHEN '{{cashcat_is_token0}}' = 'true' THEN abs(amount1_raw) / NULLIF(abs(amount0_raw), 0)ELSE abs(amount0_raw) / NULLIF(abs(amount1_raw), 0)END AS last_weth_per_cashcat