MLDZMNmon2.2
    Updated 2023-10-27
    -- forked from mon2 @ https://flipsidecrypto.xyz/edit/queries/6681d17c-e4dc-43ad-b1bb-4b8e8640addb

    -- with t1 as (select
    -- tx_id
    -- from solana.core.fact_transactions s
    -- join (select distinct block_timestamp, tx_id
    -- from solana.core.fact_events where succeeded = True
    -- and program_id = 'monacoUXKtUi6vKsQwaLyxmXKSievfNWEcYXTgkbCih'
    -- ) events
    -- using(tx_id, block_timestamp)
    -- join lateral flatten (input => log_messages) logs
    -- where BLOCK_TIMESTAMP >= current_date-{{Days_back}}
    -- and logs.value ilike 'Program log: Instruction: MatchOrders'),

    with t1 as (select
    tx_id,signers[0] as user
    from solana.core.fact_transactions
    where instructions[0]:programId = 'monacoUXKtUi6vKsQwaLyxmXKSievfNWEcYXTgkbCih'
    and block_timestamp > current_date-{{Days_back}} --'2022-11-22'
    and split(log_messages[1], ':')[2] like '%MatchOrders%'
    ),

    price_tab as (SELECT
    RECORDED_HOUR::date as day,
    TOKEN_ADDRESS,
    avg(CLOSE) as price

    from solana.price.ez_token_prices_hourly
    group by 1,2
    )

    select
    count(distinct s.tx_id) as no_actions,
    count(distinct user) as no_users,
    count(distinct TX_FROM) as no_senders,
    count(distinct tx_to) as no_receivers,
    Run a query to Download Data