mlhDaily Openbook's liquidity flow before and after FTX crisis
    Updated 2022-11-22
    with price as (select block_timestamp::date as day,
    swap_from_mint as token,
    median (swap_to_amount/swap_from_amount) as price
    from solana.fact_swaps
    where swap_to_mint in ('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
    'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB')
    and swap_to_amount > 0
    and swap_from_amount > 0
    and succeeded = 'TRUE'
    and block_timestamp >= CURRENT_DATE -24
    group by 1,2
    )
    select trunc(block_timestamp,'day') as date,
    case when date >= '2022-11-08' then 'After FTX Crisis'
    else 'Before FTX crisis' end as period,
    sum(amount*price) as volume,
    sum(volume) over (order by date) as cum_volume
    from solana.core.fact_transfers x
    join price y on x.block_timestamp::date = y.day and x.mint = y.token
    where tx_id in (select tx_id
    from (select tx_id
    from solana.core.fact_transactions
    where instructions[0]:programId = 'srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX'
    and succeeded = 'TRUE'
    and block_timestamp >= CURRENT_DATE -24
    )
    )
    and block_timestamp >= CURRENT_DATE -24
    group by 1, 2
    order by 1
    Run a query to Download Data