Updated 2022-10-12
    with atom_price as ( select trunc(recorded_at,'day') as day,
    symbol,
    avg(price) as token_price
    from osmosis.core.dim_prices
    where day >= CURRENT_DATE - 7
    group by 1,2)
    ,
    swaps as ( select trunc(block_timestamp,'day') as day,
    tx_id,
    trader,
    b.project_name as token_in,
    from_amount/pow(10,from_decimal) as token_in_amount,
    c.project_name as token_out,
    to_amount/pow(10,to_decimal) as token_out_amount
    from osmosis.core.fact_swaps a join osmosis.core.dim_labels b
    on a.from_currency = b.address
    join osmosis.core.dim_labels c
    on a.to_currency = c.address
    where day >= CURRENT_DATE - 7
    and tx_status = 'SUCCEEDED'

    ),

    t3 as ( select a.day,
    tx_id,
    trader,
    token_in,
    token_in_amount,
    token_in_amount*b.token_price as token_in_usd,
    token_out,
    token_out_amount,
    token_out_amount*c.token_price as token_out_usd
    from swaps a left outer join atom_price b on
    a.day = b.day and a.token_in = b.symbol
    left outer join atom_price c on
    a.day = c.day and a.token_out = c.symbol
    Run a query to Download Data