lidoLido Staking User APR 7days MA
    Updated 16 hours 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: about 16 hours 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-06-03 00:00:00.0002.7875604722.8154516053.0972894130.027875604722.8154516050.03097289413
    2
    2025-06-02 00:00:00.0002.7252364142.8090832743.028040460.027252364142.8090832740.0302804046
    3
    2025-06-01 00:00:00.0002.7078893132.8084741173.0087659030.027078893132.8084741170.03008765903
    4
    2025-05-31 00:00:00.0002.8854166632.8042593123.2060185140.028854166632.8042593120.03206018514
    5
    2025-05-30 00:00:00.0002.903504072.7919572443.2261156330.02903504072.7919572440.03226115633
    6
    2025-05-29 00:00:00.0002.8700012592.7971028893.1888902880.028700012592.7971028890.03188890288
    7
    2025-05-28 00:00:00.0002.8285530462.8068991443.1428367180.028285530462.8068991440.03142836718
    8
    2025-05-27 00:00:00.0002.7429821512.800635093.0477579450.027429821512.800635090.03047757945
    9
    2025-05-26 00:00:00.0002.7209723152.8273153283.0233025720.027209723152.8273153280.03023302572
    10
    2025-05-25 00:00:00.0002.6783856832.8755018532.9759840920.026783856832.8755018530.02975984092
    11
    2025-05-24 00:00:00.0002.7993021822.8676678253.1103357580.027993021822.8676678250.03110335758
    12
    2025-05-23 00:00:00.0002.9395235852.8614656643.2661373170.029395235852.8614656640.03266137317
    13
    2025-05-22 00:00:00.0002.9385750442.8506504633.2650833830.029385750442.8506504630.03265083383
    14
    2025-05-21 00:00:00.0002.7847046672.8325461433.0941162960.027847046672.8325461430.03094116296
    15
    2025-05-20 00:00:00.0002.9297438232.8491260453.2552709150.029297438232.8491260450.03255270915
    16
    2025-05-19 00:00:00.0003.0582779882.8493009253.3980866530.030582779882.8493009250.03398086653
    17
    2025-05-18 00:00:00.0002.6235474842.8305617962.915052760.026235474842.8305617960.0291505276
    18
    2025-05-17 00:00:00.0002.7558870552.9038330523.0620967280.027558870552.9038330520.03062096728
    19
    2025-05-16 00:00:00.0002.8638171822.9374385923.1820190910.028638171822.9374385920.03182019091
    20
    2025-05-15 00:00:00.0002.8118448053.0249992793.1242720060.028118448053.0249992790.03124272006
    95
    10KB
    328s