winnie-fsETH Staked 2 copy
    Updated 2023-04-18
    -- forked from h4wk / ETH Staked 2 @ https://flipsidecrypto.xyz/h4wk/q/eth-staked-7KhOt7

    -- Q9. What is the total amount of ETH that has been staked with Lido?
    -- Show the daily amount of ETH staked with Lido in the past 3 months.
    -- Are there any trends you can see?

    with weth_price as (
    select date_trunc(day, hour) as date,
    avg(price) as eth
    from ethereum.core.fact_hourly_token_prices
    where symbol = 'WETH' and hour::date < CURRENT_DATE and hour::date > CURRENT_DATE - 91
    group by symbol, date
    )
    select *, eth::double as eth_price from (
    select date_trunc(day, block_timestamp) as date,
    sum(event_inputs:amount/pow(10,18)) as amount,
    sum(amount) over (order by date asc rows between unbounded preceding and current row) as cumulative_amount,
    count(distinct(origin_from_address)) as address,
    sum(address) over (order by date asc rows between unbounded preceding and current row) as cumulative_address
    from ethereum.core.fact_event_logs
    where contract_address = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84'
    and event_name = 'Submitted'
    and origin_function_signature in ('0xa1903eab')
    and block_timestamp::date < CURRENT_DATE and block_timestamp::date > CURRENT_DATE - 91
    group by date
    ) e join weth_price p on e.date = p.date

    limit 12
    Run a query to Download Data