Query editor
WITHcalendar AS (withday_seq AS (SELECT(sequence(cast('2022-09-10' AS DATE),cast(now() AS DATE),interval '1' day)) day)SELECTdays.dayFROMday_seqCROSS JOIN unnest (day) AS days (day)),-- Сalculate PRE and POST rebase share rates for the stETH from decoded project tableshares AS (SELECTpreTotalEther * 1e27 / preTotalShares AS pre_share_rate,postTotalEther * 1e27 / postTotalShares AS post_share_rate,*FROMlido_ethereum.steth_evt_TokenRebased),-- This CTE combines data from the legacy oracle end the new V2 oracle, calculating APR valuesoracles_data AS (--legacy oracleSELECT"evt_block_time" AS time,cast(("postTotalPooledEther" - "preTotalPooledEther") * 365 * 24 * 60 * 60 / ("preTotalPooledEther") AS double) / timeElapsed * 100 AS eth_staking_rate,cast(("postTotalPooledEther" - "preTotalPooledEther") * 365 * 24 * 60 * 60 / ("preTotalPooledEther") AS double) / timeElapsed * 0.9 * 100 AS "Lido staking APR(instant)","postTotalPooledEther","preTotalPooledEther"FROMlido_ethereum.LegacyOracle_evt_PostTotalSharesWHERE"evt_block_time" >= cast('2022-09-01 00:00' AS TIMESTAMP)AND "evt_block_time" <= cast('2023-05-16 00:00' AS TIMESTAMP)--new V2 oracleUNION allSELECTevt_block_time,(365 * 24 * 60 * 60 * (post_share_rate - pre_share_rate) / pre_share_rate / timeElapsed * 100) / 0.9 AS eth_staking_rate,365 * 24 * 60 * 60 * (post_share_rate - pre_share_rate) / pre_share_rate / timeElapsed * 100 AS "Lido staking APR(instant)",preTotalEther,postTotalEtherFROM