rajsOsmosis Swap Volume
    Updated 2022-11-14
    with prices as
    (
    SELECT
    date_trunc('day', recorded_at) as date,
    symbol,
    avg(price) as price
    from osmosis.core.dim_prices
    where recorded_at >= CURRENT_DATE - interval '30 days'
    group by 1,2
    )

    SELECT
    date_trunc('day', block_timestamp) as date,
    sum(case when p.symbol = 'INJ' then from_amount * p.price / pow(10,18)
    else from_amount * p.price / pow(10, from_decimal)
    end) as volume
    from osmosis.core.fact_swaps s
    left join osmosis.core.dim_labels l
    on s.from_currency = l.address
    left join osmosis.core.dim_labels l1
    on s.to_currency = l1.address
    left join prices p
    on l.project_name = p.symbol
    and date_trunc('day', block_timestamp) = p.date
    left join prices p1
    on l1.project_name = p1.symbol
    and date_trunc('day', s.block_timestamp) = p1.date
    where tx_status = 'SUCCEEDED'
    -- and p.symbol = 'INJ'
    and block_timestamp >= CURRENT_DATE - interval '30 days'
    group by 1
    order by 1 desc
    -- limit 3
    Run a query to Download Data