marquprimary asset deposits - kamino
    Updated 2024-11-28
    with

    deposit_txs as (

    select
    fact_decoded_instructions.block_timestamp
    , fact_decoded_instructions.tx_id
    , fact_transfers.amount
    , fact_transfers.mint
    from solana.core.fact_decoded_instructions
    left join solana.core.fact_transfers
    using(block_timestamp, tx_id)
    where fact_decoded_instructions.program_id = 'KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD'
    and fact_decoded_instructions.event_type in (
    'depositReserveLiquidity'
    , 'depositReserveLiquidityAndObligationCollateral'
    )
    and (fact_decoded_instructions.decoded_instruction :accounts[4] :pubkey = fact_transfers.mint
    or fact_decoded_instructions.decoded_instruction :accounts[5] :pubkey = fact_transfers.mint)
    and fact_decoded_instructions.decoded_instruction :accounts[0] :pubkey = fact_transfers.tx_from

    and block_timestamp ::date > current_date() - interval '30 days'
    ),

    aggregated as (

    select

    date_trunc('day', block_timestamp) as date
    , mint as token_address
    , sum(amount) as amount_token

    from deposit_txs
    group by date, mint
    QueryRunArchived: QueryRun has been archived