ArioAmnis - Staked Distribution by Users Type
    Updated 2025-03-19
    with main as (
    select
    block_timestamp,
    tx_hash,
    sender as User_address,
    EVENT_DATA:amapt :: float / pow(10, 8) as amount
    FROM
    aptos.core.fact_events
    join aptos.core.fact_transactions using(tx_hash, block_timestamp)
    WHERE
    EVENT_ADDRESS = '0x111ae3e5bc816a5e63c2da97d0aa3886519e0cd5e4b046659fa35796bd11542a'
    AND EVENT_RESOURCE IN ('MintEvent')
    and SUCCESS = 'TRUE'
    ),
    first_tx as (
    select
    user_address,
    min(block_timestamp) as first_timestamp
    from
    main
    group by
    1
    )
    select
    --date_trunc(week, block_timestamp) as date,
    case
    when a.user_address = b.user_address then 'New'
    else 'Returning'
    end as User_Status,
    sum(amount) as Staked_Amount
    from
    main a
    left join first_tx b on a.block_timestamp = b.first_timestamp
    where
    block_timestamp > '2023-08-28'
    group by
    Last run: 20 days ago
    USER_STATUS
    STAKED_AMOUNT
    1
    New8839118.34900975
    2
    Returning40095381.2444318
    2
    57B
    2s