Afonso_DiazTop Users
    Updated 2025-04-21
    with

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

    main as (
    select
    tx_hash,
    block_timestamp,
    origin_from_address as user,
    value as collateral_amount,
    collateral_amount * token_price_usd as collateral_amount_usd,
    utils.udf_hex_to_int(regexp_substr_all(substr(input,11, len(input)), '.{64}')[2])::bigint / 1e18 as borrow_amount
    from
    mezo.testnet.fact_traces
    join
    pricet on block_timestamp::date = date
    where
    origin_to_address = '0x20faea18b6a1d0fcdbccfffe3d164314744baf30'
    and to_address = origin_to_address
    and input like '0x8e54c119%'
    and trace_succeeded
    and tx_succeeded

    union all

    select
    QueryRunArchived: QueryRun has been archived