Afonso_DiazBy token
    Updated 2025-02-17
    with

    pricet as (
    select
    hour::date as date,
    token_address,
    avg(price) as token_price_usd
    from
    flow.price.ez_prices_hourly
    where
    blockchain = 'flow evm'
    group by 1, 2
    ),

    main as (
    select
    tx_hash,
    block_timestamp,
    origin_from_address as swapper,
    decoded_log:tokenX::string as token_in,
    decoded_log:tokenY::string as token_out,
    decoded_log:amountX::bigint as amount_in_unadj,
    decoded_log:amountY::bigint as amount_out_unadj,
    amount_in_unadj / pow (10, b.decimals) as amount_in,
    amount_out_unadj / pow (10, c.decimals) as amount_out,
    b.symbol as symbol_in,
    c.symbol as symbol_out,
    amount_in * d.token_price_usd as amount_in_usd,
    amount_out * e.token_price_usd as amount_out_usd,
    nvl(amount_in_usd, amount_out_usd) as amount_usd
    from
    flow.core_evm.ez_decoded_event_logs
    left join
    flow.core_evm.dim_contracts b on b.address = decoded_log:tokenX::string
    left join
    flow.core_evm.dim_contracts c on c.address = decoded_log:tokenY::string
    QueryRunArchived: QueryRun has been archived