nsa2000Daily variation of liquidity volume on Openbook
    Updated 2022-11-22
    ---this code is thankfully burrowed from alik110: https://app.flipsidecrypto.com/dashboard/Dw-8BN
    with pricet as (
    select block_timestamp::date as day,
    swap_from_mint as token,
    median (swap_to_amount/swap_from_amount) as USDPrice
    from solana.fact_swaps
    where swap_to_mint in ('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v','Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB') --USDC,USDT
    and swap_to_amount > 0
    and swap_from_amount > 0
    and block_timestamp >= CURRENT_DATE - 21
    and succeeded = 'TRUE'
    group by 1,2),

    openbooktable as (
    select tx_id
    from solana.core.fact_transactions
    where instructions[0]:programId = 'srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX'
    and succeeded = 'TRUE'
    and block_timestamp >= CURRENT_DATE - 21)

    select block_timestamp::date as date,
    sum (amount*usdprice) as Volume
    from solana.core.fact_transfers t1 join pricet t2 on t1.block_timestamp::Date = t2.day and t1.mint = t2.token
    where tx_id in (select tx_id from openbooktable)
    and block_timestamp >= CURRENT_DATE - 21
    group by 1
    order by 1
    Run a query to Download Data