Query editor
with yieldUpdates as (selectblock_time,date_add('day',1,block_time) yieldEnd,varbinary_to_uint256(from_hex(SUBSTRING(cast(data as varchar), 3, 64)))/1e18 amountfrom ethereum.logswhere topic0 = 0x7474a7be12fbf55b809c895b4af3ddc6bae8efc45766987de4dea23150524c4d),time_series AS (SELECT hourFROM unnest(SEQUENCE(CAST('2024-12-16 00:00' AS TIMESTAMP), cast(date_trunc('hour',(select max(yieldEnd) from yieldUpdates)) as timestamp), INTERVAL '1' hour)) AS t(hour)),daily_yield as (selectdate_trunc('day', hour) day,sum(hourlyYield) dailyYield,sum(hourlyEmission) dailyEmissionfrom (selectts.hour,amount/24 hourlyYield,amount/24/d.USUALX*10000 hourlyEmissionfrom time_series ts, yieldUpdates yu, query_4460500 dwhere ts.hour >= applyTimeand ts.hour <= coalesce(nextChangeTime, current_timestamp)and ts.hour >= date_trunc('hour',block_time)and ts.hour <= date_trunc('hour',yieldEnd)) hygroup by 1)select * from (selectdy.day,dailyYield,dailyEmission,sum(dailyYield) over (order by dy.day) totalDistributed,sum(dailyEmission) over (order by dy.day) totalEmitted,dailyEmission/cs.supply dailyInflationfrom daily_yield dy left join query_4460598 cson dy.day = cs.daywhere dy.day <= current_dateand dy.day >= CAST('2024-12-18 00:00' AS TIMESTAMP))where day >= CAST(current_date - interval '3' month AS TIMESTAMP)