with
pricet as (
select
hour::date as date,
avg(price) as token_price_usd
from
kaia.price.ez_prices_hourly
where
token_address = lower('0x8888888888885B073f3C81258C27E83DB228d5f3')
group by 1
),
stake_unstake as (
select
tx_hash,
block_timestamp,
origin_from_address as user,
decoded_log:value / 1e25 as amount,
'Stake' as event_name
from
kaia.core.ez_decoded_event_logs
where
contract_address = '0x8888888888885b073f3c81258c27e83db228d5f3'
and origin_to_address = '0x7c59930d1613ca2813e5793da72b324712f6899d'
and event_name = 'Transfer'
and origin_from_address = decoded_log:from
and origin_function_signature = '0x47e7ef24'
union all
select
tx_hash,
block_timestamp,
origin_from_address as user,
utils.udf_hex_to_int(right(data, 40))::bigint / 1e25 as amount,