Deebs-DeFi-j9fRbzWBTC Buy/ Sell
    Updated 2023-06-14
    -- forked from ETH Buy and Sell @ https://flipsidecrypto.xyz/edit/queries/3dd736dd-e4fe-4805-a12a-8282f2f88fe7

    WITH buys AS(
    select
    date_trunc('hour',BLOCK_TIMESTAMP) AS DATE,
    SUM(amount_out) AS total_bought
    from ethereum.core.ez_dex_swaps
    WHERE DATE BETWEEN {{start_date}} AND {{end_date}}
    AND token_out=lower('0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599')
    group by 1
    ),
    sells AS(
    select
    date_trunc('hour',BLOCK_TIMESTAMP) AS DATE,
    SUM(amount_in) AS total_sold
    from ethereum.core.ez_dex_swaps
    WHERE DATE BETWEEN {{start_date}} AND {{end_date}}
    AND token_in=lower('0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599')
    group by 1
    ),
    price AS(
    select
    date_trunc('hour', HOUR) AS DATE,
    Symbol,
    avg(price) as price
    from crosschain.core.ez_hourly_prices
    WHERE DATE BETWEEN {{start_date}} AND {{end_date}}
    AND TOKEN_ADDRESS=lower('0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599')
    group by 1,2
    )
    SELECT
    b.date,
    b.total_bought,
    s.total_sold,
    p.price
    FROM buys b
    Run a query to Download Data