Afonso_DiazTotal Symbol
    Updated 2025-02-18
    with

    pricet as (
    select
    hour::date as date,
    '0x2f6f07cdcf3588944bf4c42ac74ff24bf56e7590' as token_address,
    avg(price) as token_price_usd
    from
    crosschain.price.ez_prices_hourly
    where
    blockchain = 'ethereum'
    and token_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
    group by 1, 2
    ),

    main as (
    select
    tx_hash,
    block_timestamp,
    '0x' || right(topics[2], 40) as user,
    contract_address as token_address,
    case contract_address
    when '0x2f6f07cdcf3588944bf4c42ac74ff24bf56e7590' then 'WETH'
    when '0x674843c06ff83502ddb4d37c2e09c01cda38cbc8' then 'USDT'
    when '0xf1815bd50389c46847f0bda824ec8da914045d14' then 'stgUSDC'
    end as symbol,
    utils.udf_hex_to_int(data)::bigint as amount_unadj,
    amount_unadj / pow (10, case contract_address when '0x2f6f07cdcf3588944bf4c42ac74ff24bf56e7590' then 18 else 6 end) as amount,
    iff(contract_address = '0x2f6f07cdcf3588944bf4c42ac74ff24bf56e7590', token_price_usd, 1) * amount as amount_usd
    from
    flow.core_evm.fact_event_logs
    left join
    pricet on block_timestamp::date = date and contract_address = token_address
    where
    tx_succeeded
    and topics[0] = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
    QueryRunArchived: QueryRun has been archived