lidoLido Staking User APR 7days MA
    Updated 3 minutes ago
    /*
    Calculation details:
    1. Combine APR data for Legacy Oracle and V2 Oracle:
    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
    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
    2. Calculate 7 days MA Lido protocol APR, 7 days MA Lido staking APR, 30 days MA Lido staking APR
    */
    -- calculates PRE and POST rebase share rates
    with shares AS (
    SELECT
    DECODED_LOG:preTotalEther *1e27 / DECODED_LOG:preTotalShares as pre_share_rate
    , DECODED_LOG:postTotalEther * 1e27 / DECODED_LOG:postTotalShares as post_share_rate
    , *
    FROM ethereum.core.ez_decoded_event_logs
    where EVENT_NAME = 'TokenRebased'
    )
    -- combines legacy Oracle end new V2 Oracle data
    , oracles_data AS (
    --legacy oracle
    SELECT
    date_trunc('minute', BLOCK_TIMESTAMP) as time
    , ((DECODED_LOG:postTotalPooledEther - DECODED_LOG:preTotalPooledEther) * 365 * 86400 / DECODED_LOG:preTotalPooledEther ) / DECODED_LOG:timeElapsed * 100 AS protocol_apr
    , ((DECODED_LOG:postTotalPooledEther - DECODED_LOG:preTotalPooledEther) * 365 * 86400 / DECODED_LOG:preTotalPooledEther ) / DECODED_LOG:timeElapsed * 0.9 * 100 AS "Lido staking APR(instant)"
    , DECODED_LOG:postTotalPooledEther as postTotalPooledEther
    , DECODED_LOG:preTotalPooledEther as preTotalPooledEther
    FROM ethereum.core.ez_decoded_event_logs
    WHERE event_name = 'PostTotalShares'
    AND BLOCK_TIMESTAMP BETWEEN '2022-09-01 00:00' AND '2023-05-16 00:00'
    AND postTotalPooledEther > ''
    UNION all
    --new V2 oracle
    Last run: 3 minutes agoAuto-refreshes every 24 hours
    DAY
    COUNTER_INSTANTAPR
    COUNTER_MA7APR
    COUNTER_PROTOCOLAPR
    Lido staking APR(instant)
    Lido staking APR(ma_7)
    Protocol APR
    1
    2025-04-19 00:00:00.0002.6657216082.8076574772.9619128980.026657216082.8076574770.02961912898
    2
    2025-04-18 00:00:00.0002.7203482242.8389940283.0226091380.027203482242.8389940280.03022609138
    3
    2025-04-17 00:00:00.0002.7858426942.9017421193.0953807710.027858426942.9017421190.03095380771
    4
    2025-04-16 00:00:00.0002.8348889242.9802126453.1498765820.028348889242.9802126450.03149876582
    5
    2025-04-15 00:00:00.0002.8304370933.0453772243.1449301040.028304370933.0453772240.03144930104
    6
    2025-04-14 00:00:00.0002.9746514813.0867731093.3051683120.029746514813.0867731090.03305168312
    7
    2025-04-13 00:00:00.0002.8417123123.7110686983.1574581250.028417123123.7110686980.03157458125
    8
    2025-04-12 00:00:00.0002.8850774683.6854218643.2056416310.028850774683.6854218640.03205641631
    9
    2025-04-11 00:00:00.0003.1595848643.670502953.5106498490.031595848643.670502950.03510649849
    10
    2025-04-10 00:00:00.0003.3351363713.6262966283.7057070790.033351363713.6262966280.03705707079
    11
    2025-04-09 00:00:00.0003.2910409823.5772608843.6567122030.032910409823.5772608840.03656712203
    12
    2025-04-08 00:00:00.0003.1202082873.5013743863.4668980970.031202082873.5013743860.03466898097
    13
    2025-04-07 00:00:00.0007.34472063.4535562428.1608006660.0734472063.4535562420.08160800666
    14
    2025-04-06 00:00:00.0002.662184482.7959935932.9579827560.02662184482.7959935930.02957982756
    15
    2025-04-05 00:00:00.0002.7806450692.8104990813.0896056320.027806450692.8104990810.03089605632
    16
    2025-04-04 00:00:00.0002.8501406042.8147882873.1668228940.028501406042.8147882870.03166822894
    17
    2025-04-03 00:00:00.0002.9918861672.8386679163.3243179630.029918861672.8386679160.03324317963
    18
    2025-04-02 00:00:00.0002.7598354942.8037628643.0664838830.027598354942.8037628640.03066483883
    19
    2025-04-01 00:00:00.0002.7854812792.7935062093.0949791990.027854812792.7935062090.03094979199
    20
    2025-03-31 00:00:00.0002.7417820572.7817282843.0464245070.027417820572.7817282840.03046424507
    ...
    109
    11KB
    142s