JonasoORBIT staking - users
    Updated 2024-08-26
    with

    AA as(
    select origin_from_address as user, from_address as contract, to_address as pool, amount as amount, contract_address, block_timestamp from blast.core.ez_token_transfers union all
    select origin_to_address as user, to_address as contract, from_address as pool, 0 - amount as amount, contract_address, block_timestamp from blast.core.ez_token_transfers ),

    A as(
    select *
    from AA
    where contract_address = '0x42e12d42b3d6c4a74a88a61063856756ea2db357'
    and pool in ('0xfa1fdcf4682b72e56e3b32ff1aba7afcd5e1c7a8')
    ),

    -- unique users
    B as(
    select date_trunc('week',time) as time, count(user) as user
    from (select user, min(block_timestamp) as time from A group by 1)
    group by 1 ),

    -- active user + txs
    C as(
    select date_trunc('week',block_timestamp) as time, count(distinct user) as active_user, count(*) as txs
    from A
    group by 1),

    -- total
    D as(
    select a.time,
    active_user as "Active users",
    txs as "Daily txs",
    '|' "|",
    user as "New users",
    sum(user) over (order by a.time) - user as "Retained users",
    sum(user) over (order by a.time) as "Total users"
    from B as a
    join C as b on a.time = b.time )
    Auto-refreshes every 24 hours
    QueryRunArchived: QueryRun has been archived