Flipside TeamETH Latest Stake Pie
    Updated 2025-03-20
    -- forked from ETH MoM Stake + Liquid @ https://flipsidecrypto.xyz/studio/queries/a26474e3-f6f4-46cc-91e5-4075b4d5dbf3

    with eth_data as (
    with eth_liquid as (
    with liquid_flows as (
    --deposits
    SELECT
    date_trunc('month', block_timestamp) as dmonth
    , 'deposits' as label
    , SUM(ETH_AMOUNT) as token_amount
    from ethereum.defi.ez_liquid_staking_deposits
    GROUP BY dmonth, label
    UNION ALL
    SELECT
    date_trunc('month', block_timestamp) as dmonth
    , 'withdraws' as label
    , SUM(ETH_AMOUNT) as token_amount
    from ethereum.defi.ez_liquid_staking_withdrawals
    GROUP BY dmonth, label
    )
    ,
    refine as (
    SELECT
    dmonth
    , SUM(CASE WHEN label = 'deposits' THEN token_amount ELSE token_amount*(-1) END) as net_flow
    , SUM(net_flow) OVER (ORDER BY DMONTH ASC) as liquid_stake_cumulative
    from liquid_flows
    GROUP BY dmonth
    )
    SELECT
    dmonth
    , liquid_stake_cumulative as liquid_stake
    Last run: about 1 month ago
    DMONTH
    LABEL
    TOTAL_STAKE
    LIQUID_STAKE
    1
    2024-09-01 00:00:00.000Native20442590.408397814206322.1309173
    2
    2024-09-01 00:00:00.000Liquid14206322.130917314206322.1309173
    2
    143B
    38s