Afonso_DiazUser Frequency
    Updated 2025-02-23
    with main as (
    select tx_hash, block_timestamp, borrower as user, token_symbol as symbol, amount_usd,
    case when platform ilike 'aave%' then 'Aave' else platform end as platform,
    'Borrow' as event_name
    from avalanche.defi.ez_lending_borrows
    union all
    select tx_hash, block_timestamp, depositor as user, token_symbol as symbol, amount_usd,
    case when platform ilike 'aave%' then 'Aave' else platform end as platform,
    'Deposit' as event_name
    from avalanche.defi.ez_lending_deposits
    union all
    select tx_hash, block_timestamp, depositor as user, token_symbol as symbol, amount_usd,
    case when platform ilike 'aave%' then 'Aave' else platform end as platform,
    'Withdraw' as event_name
    from avalanche.defi.ez_lending_withdraws
    union all
    select tx_hash, block_timestamp, payer as user, token_symbol as symbol, amount_usd,
    case when platform ilike 'aave%' then 'Aave' else platform end as platform,
    'Repay' as event_name
    from avalanche.defi.ez_lending_repayments
    ),

    user_activity as (
    select
    user,
    platform,
    count(*) as tx_count
    from main
    group by user, platform
    ),

    categorized_users as (
    select
    platform,
    case
    when tx_count between 1 and 5 then 'Casual User'
    QueryRunArchived: QueryRun has been archived