Query editor
/*This query calculates for each day since 2022-09-10:- Lido protocol APR- Lido instant staking APR- 7 days MA Lido protocol APR- 7 days MA Lido staking APR- 30 days MA Lido staking APRCalculation details:- Combine APR data for Legacy Oracle and V2 Oracle:- V2:- calculate PRE and POST rebase share rates for the stETH for every oracle event- calculate protocol APR: SECONDS_IN_YEAR * (post_share_rate - pre_share_rate) / pre_share_rate / timeElapsed * 100 / 0.9- calculate Lido staking APR (Instant): SECONDS_IN_YEAR * (post_share_rate - pre_share_rate) / pre_share_rate / timeElapsed * 100- Legacy (from 2022-09-01 to 2023-05-16):- calculate protocol APR: (postTotalPooledEther - preTotalPooledEther) * SECONDS_IN_YEAR / preTotalPooledEther / timeElapsed * 100- calculate Lido staking APR (Instant): (postTotalPooledEther - preTotalPooledEther) * SECONDS_IN_YEAR / preTotalPooledEther / timeElapsed * 100 * 0.9- Calculate 7 days MA Lido protocol APR, 7 days MA Lido staking APR, 30 days MA Lido staking APR*/-- Sequence of DATEs starting from '2022-09-10' up to the current DATEWITHcalendar 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 protocol_apr,