theericstonePre-stETH ETH -- for Plot
    Updated 2021-08-20
    with stakes as (
    SELECT
    tx_from_address as from_address,
    max(block_id) as max_block,
    sum(event_inputs:amount)/pow(10,18) as amount_staked
    from ethereum.events_emitted
    where contract_address = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84'
    and event_name = 'Submitted'
    and block_timestamp > '2021-08-01'
    group by 1
    ),
    eth_received as (
    SELECT
    to_address,
    block_timestamp,
    coalesce(from_label,'unlabeled') as label,
    coalesce(from_label_subtype,'unlabeled') as label_subtype,
    coalesce(from_address_name,'unlabeled') as address_name,
    s.amount_staked,
    amount,
    amount_usd,
    sum(amount) over (partition by to_address order by block_timestamp desc) as eth_cumu,
    row_number() over (partition by to_address order by block_timestamp desc) as tx_number
    FROM
    ethereum.udm_events ue
    join stakes s on s.from_address = ue.to_address
    where block_id < max_block
    and block_timestamp > '2021-07-01'
    and contract_address IS NULL and symbol = 'ETH' and amount > 0
    order by to_address, block_timestamp desc
    ),
    lastx as (
    select
    to_address,
    min(tx_number) as min_tx
    from eth_received
    Run a query to Download Data