Afonso_Diaz2023-04-15 11:41 PM
    Updated 2023-04-15
    with t as (
    select
    recorded_hour::date as date,
    currency,
    symbol,
    avg(price) as price_usd
    from osmosis.core.ez_prices
    group by 1, 2, 3
    ),

    t2 as (
    select
    block_timestamp,
    symbol,
    tx_id,
    trader as swapper,
    (from_amount / pow(10, from_decimal)) * price_usd as amount_usd
    from osmosis.core.fact_swaps a
    join t on date = block_timestamp::date and t.currency = a.from_currency
    where block_timestamp >= '2023-01-01' and block_timestamp < '2023-04-01'
    and tx_succeeded = 1

    union all

    select
    block_timestamp,
    symbol,
    tx_id,
    trader as swapper,
    (to_amount / pow(10, to_decimal)) * price_usd as amount_usd
    from osmosis.core.fact_swaps a
    join t on date = block_timestamp::date and t.currency = a.to_currency
    where block_timestamp >= '2023-01-01' and block_timestamp < '2023-04-01'
    and tx_succeeded = 1
    )

    Run a query to Download Data