Query editor
-- Etherex Staking Behaviour:WITH rex_staking AS (SELECTDATE_TRUNC('day', block_time) as date,topic1 AS from_address,bytearray_to_uint256(data) / 1e18 AS rex_stakedFROM linea.logsWHEREcontract_address = 0xefd81eec32b9a8222d1842ec3d99c7532c31e348AND topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efAND topic2 = 0x000000000000000000000000c93b315971a4f260875103f5da84cb1e30f366ccAND block_time >= TIMESTAMP '2025-08-06 00:00:00'AND bytearray_to_uint256(data) > 0),-- daily statsdaily_staking_stats AS (SELECTdate,COUNT(*) as staking_transactions,COUNT(DISTINCT from_address) as unique_stakers,SUM(rex_staked) as total_rex_staked,AVG(rex_staked) as avg_stake_size,MIN(rex_staked) as min_stake,MAX(rex_staked) as max_stakeFROM rex_stakingGROUP BY date),-- get distinct wallet per daydistinct_wallets AS (SELECT DISTINCT from_address, dateFROM rex_staking),-- true cumulative unique stakerscumulative_unique AS (SELECTdate,COUNT(from_address) AS daily_new_unique_stakersFROM distinct_walletsGROUP BY date),cumulative_stakers AS (SELECTdate,SUM(daily_new_unique_stakers) OVER (ORDER BY date) AS true_cumulative_stakersFROM cumulative_unique),-- combine daily stats with cumulative stakersfinal_stats AS (SELECTd.date,d.staking_transactions,d.unique_stakers,ROUND(d.total_rex_staked, 0) as daily_staked,ROUND(d.avg_stake_size, 2) as avg_stake,SUM(d.total_rex_staked) OVER (ORDER BY d.date) AS total_staked_to_date,c.true_cumulative_stakers AS total_stakers_to_date