Afonso_DiazRetention Rate (Monthly cohort)
    Updated 2025-03-12
    -- Base CTE: Filter transactions involving KaiKai/Kaiching
    with storage_deposit as (
    select
    tx_hash,
    block_timestamp,
    action_data:args:account_id::string as user
    from
    near.core.ez_actions
    where
    tx_succeeded
    and receipt_predecessor_id = 'hotwallet.kaiching'
    and receipt_receiver_id = 'wallet.kaiching'
    and receipt_signer_id = receipt_predecessor_id
    and action_data:method_name = 'storage_deposit'
    and user is not null
    and year(block_timestamp) >= 2025
    ),

    earlier as (
    select
    tx_hash,
    block_timestamp,
    iff(tx_signer ilike '%.kaiching', tx_signer, tx_receiver) as user
    from
    near.core.fact_transactions
    where
    tx_succeeded
    and (
    tx_signer ilike '%.kaiching'
    or tx_receiver ilike '%.kaiching'
    )
    ),

    main as (
    select
    tx_hash,
    QueryRunArchived: QueryRun has been archived