binhachonFLOOR Tokens - #3
    Updated 2022-07-02
    with swap_txs as (
    select
    -- block_timestamp,
    -- case when token_in = lower('0xf59257E961883636290411c11ec5Ae622d19455e') then 'Sell' else 'Buy' end as type,
    -- case when amount_in_usd is not null then amount_in_usd else amount_out_usd end as amount_usd
    block_timestamp,
    direction,
    amount_usd
    from flipside_prod_db.ethereum.dex_swaps
    where token_address = lower('0xf59257E961883636290411c11ec5Ae622d19455e')
    and block_timestamp::date >= getdate() - interval'90 days'
    -- or token_out = lower('0xf59257E961883636290411c11ec5Ae622d19455e')
    )
    select
    date_trunc('day', block_timestamp) as time,
    sum(case when direction = 'OUT' then amount_usd else -amount_usd end) as volume,
    sum(volume) over (order by time) as total_volume
    from swap_txs
    group by 1
    Run a query to Download Data