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
    ),

    txns as (
    select
    tx_hash,
    block_timestamp,
    origin_from_address as user,
    contract_address as token_address,
    decoded_log:wad::bigint as amount_unadj,
    case origin_function_signature
    when '0x474cf53d' then 'Supply'
    when '0x66514c97' then 'Borrow'
    when '0x02c5fcf8' then 'Repay'
    else 'Withdraw'
    end as event_name
    from
    flow.core_evm.ez_decoded_event_logs
    where
    tx_succeeded
    and event_name = 'Transfer'
    and origin_to_address = '0xe847d70a35bbb9da4133edc1cc9ccffe0c379b4f'
    and origin_function_signature in ('0x474cf53d', '0x66514c97', '0x02c5fcf8', '0x80500d20')

    union all
    QueryRunArchived: QueryRun has been archived