Updated 2024-12-08
    with

    pricet as (
    select
    hour::date as date,
    decimals,
    token_address,
    symbol,
    avg(price) as price_usd
    from
    near.price.ez_prices_hourly
    group by 1, 2, 3, 4
    ),

    supply as (
    select
    tx_hash,
    block_timestamp,
    args:amount as amount_unadj,
    signer_id as user,
    predecessor_id as token_address,
    'Supply' as event_name
    from
    near.core.fact_actions_events_function_call
    join
    lateral flatten (input => logs) f
    where
    receipt_succeeded
    and receiver_id = 'v1.nearlend-official.near'
    and method_name = 'ft_on_transfer'
    and try_parse_json(replace(f.value, 'EVENT_JSON:', '')):event = 'deposit'
    ),

    borrow as (
    select
    tx_hash,
    QueryRunArchived: QueryRun has been archived