freemartianSwap From Amount USD
    Updated 2022-11-16
    with prices as (select
    recorded_at::date as day,
    symbol,
    avg(price) as price_usd
    from osmosis.core.dim_prices
    where recorded_at > CURRENT_DATE - 60
    group by 1, 2),

    source as (
    select
    block_timestamp::date as day,
    from_currency,
    from_amount/pow(10,from_decimal) as from_adj_amount,
    from_adj_amount * c.price_usd as from_usd
    from osmosis.core.fact_swaps a LEFT JOIN osmosis.core.dim_labels b on a.from_currency = b.ADDRESS
    left join prices c on LOWER(b.PROJECT_NAME) = lower(c.symbol) and c.day = a.block_timestamp::date
    where block_timestamp > CURRENT_DATE - 60
    and tx_status = 'SUCCEEDED')

    select
    day,
    from_currency,
    project_name,
    sum(from_usd) as from_amount
    from source s inner join osmosis.core.dim_labels l on l.address = s.from_currency
    group by 1, 2, 3
    having from_amount is not null

    Run a query to Download Data