Query editor
WITH all_chains AS (SELECTvalue AS amount,"from" AS user,contract_address AS token,evt_block_timeFROM eigenpie_arbitrum.Eigenpie_evt_Transferwhere to=0x08D639e1E3989De87324090C2eFdD4049CBC92F2and evt_block_time<=TRY_CAST('2025-08-14 23:59:59' AS TIMESTAMP)UNION ALLSELECT-value AS amount,"to" AS user,contract_address AS token,evt_block_timeFROM eigenpie_arbitrum.Eigenpie_evt_Transferwhere "from"=0x08D639e1E3989De87324090C2eFdD4049CBC92F2and evt_block_time<=TRY_CAST('2025-08-14 23:59:59' AS TIMESTAMP)),cumulative_balances AS (SELECTuser,token,evt_block_time,SUM(amount) OVER (PARTITION BY user, token ORDER BY evt_block_time) AS balanceFROM all_chains),holding_durations_with_lead AS (SELECTuser,token,evt_block_time AS start_time,LEAD(evt_block_time) OVER (PARTITION BY user, token ORDER BY evt_block_time) AS end_time,balanceFROM cumulative_balances),holding_durations AS (SELECTuser,token,start_time AS start_time,LEAST(COALESCE(end_time, TRY_CAST(now() AS TIMESTAMP)), TRY_CAST(now() AS TIMESTAMP)) AS end_time,balanceFROM holding_durations_with_lead),hourly_points AS (SELECTuser,token,date_diff('hour', start_time, end_time) AS hours_held,balanceFROM holding_durationsWHERE balance > 0 AND start_time < end_time)SELECTuser,token,SUM(hours_held * balance/1e18) AS eigenpie_points