Updated 2025-02-14
    with

    pricet as (
    select
    hour::date as date,
    avg(price) as token_price_usd
    from
    ronin.price.ez_prices_hourly
    where
    symbol = 'RON'
    group by 1
    ),


    main as (
    select
    tx_hash,
    block_timestamp,
    '0x' || right(topics[2], 40) as pool_id,
    origin_from_address as user,
    utils.udf_hex_to_int(data)::bigint / 1e18 as amount,
    amount * token_price_usd as amount_usd,
    case origin_function_signature
    when '0x4d99dd16' then 'Unstake'
    when '0x5c19a95c' then 'Stake'
    when '0x097e4a9d' then 'Reward Claimed'
    end as event_name
    from
    ronin.core.fact_event_logs
    left join
    pricet on block_timestamp::date = date
    where
    tx_succeeded
    and origin_to_address = '0x545edb750eb8769c868429be9586f5857a768758'
    and topics[0] in ('0xe5541a6b6103d4fa7e021ed54fad39c66f27a76bd13d374cf6240ae6bd0bb72b', '0x4d10bd049775c77bd7f255195afba5088028ecb3c7c277d393ccff7934f2f92c')
    and origin_function_signature in ('0x4d99dd16', '0x5c19a95c', '0x097e4a9d')
    QueryRunArchived: QueryRun has been archived