Updated 2024-11-26
    -- forked from Ario / Kamino - Deposit/Withtdraw @ https://flipsidecrypto.xyz/Ario/q/ZerFavHKzn1q/kamino---deposit-withtdraw

    with Deposit as (
    select
    tx_id,
    block_timestamp,
    signers [0] as Depositor,
    DECODED_INSTRUCTION:accounts [3] :pubkey :: string as lendingMarketAuthority
    from
    solana.core.fact_decoded_instructions
    where
    program_id = 'KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD'
    and event_type = 'depositReserveLiquidityAndObligationCollateral'
    and block_timestamp >= current_timestamp - interval '90 days'
    group by
    1,
    2,
    3,
    4
    ),
    prices as (
    select
    date_trunc(day, hour) as date,
    TOKEN_ADDRESS,
    SYMBOL,
    avg(price) as price
    from
    solana.price.ez_prices_hourly
    where
    date >= current_timestamp - interval '90 days'
    group by
    1,
    2,
    3
    ),
    Deposit_Volume as (
    QueryRunArchived: QueryRun has been archived