lidoLido Staking User APR 7days MA
    Updated 4 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 4 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-05-21 00:00:00.0002.7847046672.8325461433.0941162960.027847046672.8325461430.03094116296
    2
    2025-05-20 00:00:00.0002.9297438232.8491260453.2552709150.029297438232.8491260450.03255270915
    3
    2025-05-19 00:00:00.0003.0582779882.8493009253.3980866530.030582779882.8493009250.03398086653
    4
    2025-05-18 00:00:00.0002.6235474842.8305617962.915052760.026235474842.8305617960.0291505276
    5
    2025-05-17 00:00:00.0002.7558870552.9038330523.0620967280.027558870552.9038330520.03062096728
    6
    2025-05-16 00:00:00.0002.8638171822.9374385923.1820190910.028638171822.9374385920.03182019091
    7
    2025-05-15 00:00:00.0002.8118448053.0249992793.1242720060.028118448053.0249992790.03124272006
    8
    2025-05-14 00:00:00.0002.9007639783.010062093.2230710870.029007639783.010062090.03223071087
    9
    2025-05-13 00:00:00.0002.9309679822.9796406213.2566310920.029309679822.9796406210.03256631092
    10
    2025-05-12 00:00:00.0002.9271040892.9489915323.2523378770.029271040892.9489915320.03252337877
    11
    2025-05-11 00:00:00.0003.1364462752.9160227643.4849403060.031364462752.9160227640.03484940306
    12
    2025-05-10 00:00:00.0002.9911258332.846220483.3234731470.029911258332.846220480.03323473147
    13
    2025-05-09 00:00:00.0003.4767419912.8004948333.8630466560.034767419912.8004948330.03863046656
    14
    2025-05-08 00:00:00.0002.7072844852.694071833.0080938720.027072844852.694071830.03008093872
    15
    2025-05-07 00:00:00.0002.6878136942.7051170682.986459660.026878136942.7051170680.0298645966
    16
    2025-05-06 00:00:00.0002.7164243562.7046436253.0182492850.027164243562.7046436250.03018249285
    17
    2025-05-05 00:00:00.0002.6963227142.719942562.9959141270.026963227142.719942560.02995914127
    18
    2025-05-04 00:00:00.0002.6478302912.7210158542.9420336570.026478302912.7210158540.02942033657
    19
    2025-05-03 00:00:00.0002.6710462982.7271680352.967829220.026710462982.7271680350.0296782922
    20
    2025-05-02 00:00:00.0002.7317809692.740181153.0353121870.027317809692.740181150.03035312187
    ...
    110
    11KB
    199s