Query editor
/** [Title] TON Staking: Total Volume vs. APY Trend** [Description]* Combines the Total Staked Volume and the calculated APY based on seigniorage events.* - Left Axis (Area): APY (%) calculated from (Seigniorage / Staked Amount) * (Year / Interval)* - Right Axis (Line): Total Staked TON*/WITH Commits AS (SELECTevt_block_time,evt_block_number,totalStakedAmount / 1e27 AS total_staked_wton,(nextTotalSupply - prevTotalSupply) / 1e27 AS added_seigniorageFROM tokamak_network_ethereum.SeigManager_evt_CommitLog1WHERE evt_block_number >= 18732908),Commits_With_Interval AS (SELECT*,-- 이전 커밋과의 시간 차이(초) 계산LAG(evt_block_time) OVER (ORDER BY evt_block_number) as prev_timeFROM Commits)SELECTevt_block_time,total_staked_wton,added_seigniorage,-- [APY Calculation]-- Formula: (Reward / Principal) * (Seconds in a Year / Seconds since last reward) * 100CASEWHEN total_staked_wton > 0 AND date_diff('second', prev_time, evt_block_time) > 0THEN ((added_seigniorage / total_staked_wton) *(31536000.0 / date_diff('second', prev_time, evt_block_time))) * 100ELSE 0END as apy_percentFROM Commits_With_IntervalWHERE prev_time IS NOT NULL -- 첫 번째 데이터는 시간 차 계산 불가로 제외ORDER BY evt_block_time