Updated 2023-08-29
    -- forked from sp1 @ https://flipsidecrypto.xyz/edit/queries/c57a42bc-4af4-4d9e-af9d-1be9232e7472

    with price_tab as (SELECT
    recorded_hour::date as day,
    avg(close) as token_price
    FROM solana.core.ez_token_prices_hourly
    WHERE token_address = 'So11111111111111111111111111111111111111112'
    and day>=current_date-{{Days_back}}
    group by 1
    ),

    r_tab as (select *
    from solana.core.fact_events
    where succeeded = True
    and program_id = 'stkitrT1Uoy18Dk1fTrgPw8W6MVzoCfYoAFT4MLsmhq'
    and BLOCK_TIMESTAMP>=current_date-{{Days_back}}
    ),

    t_tab as (select
    *
    from solana.core.fact_transfers
    where tx_id in (select tx_id from r_tab)
    and BLOCK_TIMESTAMP>=current_date-{{Days_back}}
    ),

    t_tab1 as (select
    tx_id,
    min(index) as min_index,
    max(index) as max_index
    from t_tab
    group by 1
    ),

    t1 as (select
    t.tx_id,
    t.mint as mint_in,
    Run a query to Download Data