maybeyonasstark_eth_deposit_balance
    Updated 2022-06-25
    with
    eth_moves as (
    select
    block_timestamp,
    tx_hash,
    case when topics[0] = '0xb4214c8c54fc7442f36d3682f59aebaf09358a4431835b30efb29d52cf9e1e91' then 'withdrawal' else 'deposit' end as type,
    '0x'||substr(topics[1],27) as user,
    ethereum.public.udf_hex_to_int(substr(data,3))/pow(10,18) as amount
    from ethereum.core.fact_event_logs
    where contract_address = '0xae0ee0a63a2ce6baeeffe56e7714fb4efe48d419'
    -- and event_name = 'LogDeposit'
    and topics[0] in (
    '0x9dbb0e7dda3e09710ce75b801addc87cf9d9c6c581641b3275fca409ad086c62', -- deposit
    '0xb4214c8c54fc7442f36d3682f59aebaf09358a4431835b30efb29d52cf9e1e91' -- withdrawal
    )
    ),
    daily_net as (
    select
    date(block_timestamp) as date,
    sum(
    case when type='deposit' then amount else -amount end
    ) as net_eth
    from eth_moves
    where block_timestamp >= '2022-04-25'
    group by 1
    )

    select
    date,
    sum(net_eth) over(order by date) as total_eth_deposited
    from daily_net
    limit 100

    -- limit 100
    Run a query to Download Data