SocioCryptoNOTE Swaps
    Updated 2023-06-01
    with price as
    (
    SELECT
    date_Trunc('day',hour) as date,
    median(price) as price
    FROM
    ethereum.core.fact_hourly_token_prices
    WHERE
    token_address = '0xcfeaead4947f0705a14ec42ac3d44129e1ef3ed5'
    GROUP BY date
    )
    SELECT 'swap in' as title,
    b.date as date,
    sum(amount_in/pow(10,8)) as vol,
    sum(b.price*amount_in/pow(10,8)) as vol_usd,
    count(DISTINCT origin_from_ADDRESS) as senders
    FROM
    ethereum.core.ez_dex_swaps a
    LEFT JOIN price b
    on date_trunc('day',block_timestamp) = b.date
    WHERE a.token_in = '0xcfeaead4947f0705a14ec42ac3d44129e1ef3ed5'
    AND date between '2023-01-01' AND current_date -1
    GROUP by date
    UNION
    SELECT 'swap out' as title,
    b.date as date,
    sum(amount_out/pow(10,8)) as vol,
    sum(b.price*amount_out/pow(10,8)) as vol_usd,
    count(DISTINCT origin_from_ADDRESS) as senders
    FROM
    ethereum.core.ez_dex_swaps a
    LEFT JOIN price b
    on date_trunc('day',block_timestamp) = b.date
    WHERE a.token_out = '0xcfeaead4947f0705a14ec42ac3d44129e1ef3ed5'
    AND date between '2023-01-01' AND current_date -1
    GROUP by date
    Run a query to Download Data