Mojtaba-BanaeiHubble Protocol - Part 1 - Kamino Top Token Minted
    Updated 2022-10-09
    with kamino_program as (
    SELECT
    -- tr.signers
    tx_id
    from
    solana.core.fact_events ev -- inner join solana.core.fact_transactions tr using(tx_id)
    WHERE
    -- address_name ilike '%Hubble %'
    program_id = '6LtLpnUFNByNXLyCoK9wA2MykKAmQNZKBdY8s47dehDc'
    -- and instruction:accounts[0] != 'H5s8388JNiFMigoy5fhEEED5nB5i2UGPxh1Gh3cBvqQd'
    -- and tx_id = '4VEyMHCskeLsYuTwnoxmfooAuvCvMXV2NrdQThXg8HLVKb9XHP6VNEkfrJR4ceWUs2wAR11r5tBhL4kitgYrRz7y'
    and block_timestamp >= CURRENT_DATE - INTERVAL'3 months'
    -- 1=1
    -- limit 10
    )
    , kamino_mints as (

    SELECT
    block_timestamp
    , value:parsed:info:mint as token
    , value:parsed:info:amount/1e6 as amount
    , instruction:accounts[0] as user
    , tx_id
    -- , *
    FROM
    solana.core.fact_events ,
    lateral flatten( input => inner_instruction:instructions )
    where
    tx_id in (SELECT tx_id from kamino_program )
    and value:parsed:type = 'mintTo'
    ) , kamino_burns as (

    SELECT
    block_timestamp
    , value:parsed:info:mint as token
    , value:parsed:info:amount/1e6 as amount