Afonso_DiazTop Borrowers
    Updated 2025-02-27
    with

    pricet as (
    select
    hour::date as date,
    token_address,
    avg(price) as token_price_usd
    from
    avalanche.price.ez_prices_hourly
    group by 1, 2
    ),

    events as (
    select
    tx_hash,
    block_timestamp,
    origin_from_address as user,
    contract_address as token_address,
    nvl(decoded_log:amount, decoded_log:value)::bigint as amount_unadj,
    'Deposit' as event_name
    from
    avalanche.core.ez_decoded_event_logs
    where
    origin_to_address = '0x0ebfebd41e1ea83be5e911cdcd2730a0ccee344d'
    and decoded_log:to = origin_to_address
    and decoded_log:from = origin_from_address
    and tx_status = 'SUCCESS'
    and event_name = 'Transfer'
    and tx_hash in (select distinct tx_hash from avalanche.core.ez_decoded_event_logs where event_name = 'Mint' and origin_to_address = '0x0ebfebd41e1ea83be5e911cdcd2730a0ccee344d')

    union all

    select
    tx_hash,
    block_timestamp,
    origin_from_address as user,
    QueryRunArchived: QueryRun has been archived