Sbhn_NPhandsome-black
    Updated 2025-01-14
    with deposit as (
    SELECT date_trunc('day',block_timestamp) as date,
    count(DISTINCT origin_from_address) as depositors,
    sum(ethereum.public.udf_hex_to_int(regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}')[0]) / pow(10,18)) AS deposited
    from ink.core.fact_event_logs
    where topic_0 = '0x90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15'
    and origin_to_address = '0xcab283e4bb527aa9b157bae7180fef19e2aaa71a'
    group by 1),

    withdraw as (select date_trunc('day',block_timestamp) as date,
    count(DISTINCT origin_from_address) as withdrawers,
    sum(ethereum.public.udf_hex_to_int(regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}')[0]) / pow(10,18)) AS withdrawn
    from ink.core.fact_event_logs
    where topic_0 = '0x6c3a45613039e0a1117bd6ce110ab3c920271709c010983d921a2cd268e2ea47'
    and origin_to_address = '0xcab283e4bb527aa9b157bae7180fef19e2aaa71a'
    GROUP by 1)

    select date,
    depositors,
    withdrawers,
    deposited as "Deposited ETH",
    -withdrawn as "Withdrawn ETH",
    deposited-withdrawn as "NET Staked ETH",
    sum(deposited) over (order by date) as cumu_d,
    sum(withdrawn) over (order by date) as cumu_w,
    cumu_d-cumu_w as tvl,
    from deposit
    join withdraw using(date)
    order by 1 desc

    QueryRunArchived: QueryRun has been archived