Query editor
-- ==========================================================-- River Pts -> (staked) RIVER daily totals + unique users-- (no hex(); distinct on varbinary user bytes)-- ==========================================================WITHparams AS (SELECTfrom_hex('a83f8792f5c80148e2789267ab71cbbddeb55e10') AS converter,from_hex('e5150ef2400709cd4c9ca96af38e56491cf9951cbdde6f882afa5c817d84ff5f') AS evt_topic0,1e18 AS token_decimals),raw AS (SELECTdate_trunc('day', l.block_time) AS dt,-- indexed user:topic1 后 20 bytes(仍然保留为 varbinary,直接用来 distinct)bytearray_substring(l.topic1, 13, 20) AS user_bytes,bytearray_to_uint256(bytearray_substring(l.data, 1, 32)) AS points,bytearray_to_uint256(bytearray_substring(l.data, 33, 32)) AS tokens,bytearray_to_uint256(bytearray_substring(l.data, 65, 32)) AS penalty,bytearray_to_uint256(bytearray_substring(l.data, 97, 32)) AS tokens_after_penaltyFROM bnb.logs lJOIN params p ON 1=1WHERE l.contract_address = p.converterAND l.topic0 = p.evt_topic0),daily AS (SELECTdt,COUNT(*) AS event_count,COUNT(DISTINCT user_bytes) AS unique_users,SUM(tokens_after_penalty) / (SELECT token_decimals FROM params) AS river_after_penaltyFROM rawGROUP BY 1)SELECTdt,river_after_penalty,SUM(river_after_penalty) OVER (ORDER BY dt) AS river_after_penalty_cum,event_count,unique_usersFROM dailyORDER BY dt;