Updated 2023-06-14
    -- forked from SUM AVAX @ https://flipsidecrypto.xyz/edit/queries/bc2ce65e-075e-45dd-9326-9231bf6ce506

    -- forked from SUM ARB @ https://flipsidecrypto.xyz/edit/queries/3ea4a61e-ea58-4b31-94ce-4f6a414a4087

    -- forked from SUM ETH @ https://flipsidecrypto.xyz/edit/queries/799a7cd2-d1c1-4099-b33e-5f9db7194c4c

    -- forked from ETH Buy and Sell @ https://flipsidecrypto.xyz/edit/queries/3dd736dd-e4fe-4805-a12a-8282f2f88fe7

    WITH buys AS(
    select
    CASE
    WHEN token_out=lower('0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599') THEN 'BOUGHT'
    END AS ACTION,
    SUM(amount_out) AS total_bought_sold
    from ethereum.core.ez_dex_swaps
    WHERE BLOCK_TIMESTAMP BETWEEN {{start_date}} AND {{end_date}}
    AND token_out=lower('0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599')
    group by 1
    ),
    sells AS(
    select
    CASE
    WHEN token_in=lower('0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599') THEN 'SOLD'
    END AS ACTION,
    SUM(amount_in) AS total_bought_sold
    from ethereum.core.ez_dex_swaps
    WHERE BLOCK_TIMESTAMP BETWEEN {{start_date}} AND {{end_date}}
    AND token_in=lower('0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599')
    group by 1
    )

    SELECT
    action,
    total_bought_sold
    FROM buys
    UNION ALL
    Run a query to Download Data