Afonso_Diaz2023-04-16 02:01 PM
    Updated 2023-04-16
    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,
    t.symbol,
    tx_id,
    fee,
    sender as user,
    (amount / pow(10, decimal)) * price_usd as amount_usd
    from osmosis.core.fact_transfers a
    join osmosis.core.fact_transactions
    using(tx_id)
    join t on t.date = block_timestamp::date and t.currency = a.currency
    where tx_succeeded = 1
    and transfer_type = 'IBC_TRANSFER_OUT'
    ),

    t3 as (
    select
    block_timestamp,
    tx_id,
    user,
    amount_usd,
    (
    case
    when fee like '%ibc/%' then (substring(fee, 0, position('ibc/' in fee) -1)::int)/pow(10, iff(t.symbol = 'LIKE', 9, 6))
    Run a query to Download Data