misaghlbWhat's All The Hubbub for Hubble Protocol? - ratio
    Updated 2022-10-09
    with bm as (
    select
    date(block_timestamp) as date,
    COUNT(DISTINCT tx_id) as tx_count,
    case when inner_instruction:instructions[0]:parsed:type = 'burn' then 'Burn' else 'Mint' END as type
    from solana.core.fact_events
    where program_id = 'HubbLeXBb7qyLHt3x7gvYaRrxQmmgExb7fCJgDqFuB6T'
    and (inner_instruction:instructions[0]:parsed:type = 'burn' or inner_instruction:instructions[0]:parsed:type = 'mintTo')
    and succeeded = TRUE
    group by date, type
    ),
    s as (
    select
    date(block_timestamp) as date,
    count (distinct tx_id) as tx_count,
    'Swap' as type
    from solana.core.fact_swaps
    where succeeded = TRUE
    AND (swap_from_mint = 'USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX' OR swap_to_mint = 'USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX' )
    group by date, type
    ),
    allt as (
    select
    date(block_timestamp) as date,
    count (distinct tx_id) as tx_count
    from solana.core.fact_events
    where program_id = 'HubbLeXBb7qyLHt3x7gvYaRrxQmmgExb7fCJgDqFuB6T'
    and succeeded = 'TRUE'
    GROUP by date
    )

    SELECT allt.date, (allt.tx_count - bm.tx_count) as trx, 'Other' as type
    from allt join s using(date) join bm using(date)

    UNION ALL

    Run a query to Download Data