Query editor
selectcount(*) as locked,coalesce(sum(stakedDays), CAST(0 as UINT256)) as cumulativeStakedDays,coalesce(sum(stakedDays), CAST(0 as UINT256)) / count(*) as avgStakedDays,lockedDay + stakedDays as endDayfrom(selectbitwise_right_shift(bitwise_left_shift(starter.data0,56 -- chop off bytes to left),240 -- leave a number of bytes of space (256-uintXXX)) as stakedDays,(bitwise_right_shift(bitwise_left_shift(starter.data0,216 -- chop off bytes to left),216 -- leave a number of bytes of space (256-uintXXX)) / 86400) - 18233 as lockedDayfromhex_ethereum.HEX_evt_StakeStart starterfull join hex_ethereum.HEX_call_stakeEnd ender on starter.stakeId = ender.stakeIdParamwhereender.stakeIdParam is Null)where lockedDay + stakedDays > CAST((date_diff('day', DATE '1970-01-01', now()) - 18233 - {{DAYS_IN_PAST}}) as UINT256)and lockedDay + stakedDays < CAST((date_diff('day', DATE '1970-01-01', now()) - 18233 + {{DAYS_FROM_NOW}}) as UINT256)group bylockedDay + stakedDaysorder bylockedDay + stakedDays;