saeedmznWhat's All The Hubbub for Hubble Protocol? - USDH mints and burn
    Updated 2022-10-11
    with actions as (SELECT
    BLOCK_TIMESTAMP::date daily ,
    CASE
    WHEN inner_instruction:instructions[0]:parsed:info:mint in ('HBB111SCo9jkCejsZfz8Ec8nH7T6THF8KEKSnvwT6XK6','HBbyPnXAZD87i54d9amJxhiREGQUKjtVxFpagXFicCkV') then 'HBB'
    WHEN inner_instruction:instructions[0]:parsed:info:mint in ('usdhGSfp3gaciiK9ggMxrNtix1EfyXLWUNAzT56a4ki','USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX') then 'USDH'
    end Token,
    inner_instruction:instructions[0]:parsed:type action,
    -- case when inner_instruction:instructions[0]:parsed:type = 'mintTo' then 'Mint'
    -- when inner_instruction:instructions[0]:parsed:type = 'burn' then 'Burn'
    -- else inner_instruction:instructions[0]:parsed:type
    -- end as action ,
    count (distinct tx_id) num_transactions_,
    sum (zeroifnull(inner_instruction:instructions[0]:parsed:info:amount/1e6)) amount_

    from solana.core.fact_events
    where program_id = 'HubbLeXBb7qyLHt3x7gvYaRrxQmmgExb7fCJgDqFuB6T'
    and succeeded = true
    -- and index = 2
    group by 1,2,3 having Token is not NULL
    )
    select date_trunc(week,daily) weekly ,
    action ,
    sum (num_transactions_) num_transactions,
    sum (amount_) amount ,
    sum (num_transactions) over (partition by action order by weekly ) cum_transactions ,
    sum (amount) over (partition by action order by weekly ) cum_amount
    from actions
    where Token = 'USDH'
    group by 1 ,2
    Run a query to Download Data