maybeyonasmean_open_asset_bought
    Updated 2022-06-26
    with
    mean_data as (
    select
    block_timestamp,
    tx_hash,
    '0x'|| substr(topics[2],27) as user,
    regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
    ethereum.public.udf_hex_to_int(segmented_data[0]) as id,
    '0x'|| substr(segmented_data[1],25) as token_from,
    '0x'|| substr(segmented_data[2],25) as token_to,
    ethereum.public.udf_hex_to_int(segmented_data[3]) as time_period,
    ethereum.public.udf_hex_to_int(segmented_data[4]) as cycle_size,
    ethereum.public.udf_hex_to_int(segmented_data[5]) as start_cycle,
    ethereum.public.udf_hex_to_int(segmented_data[6]) as end_cycle,
    end_cycle-start_cycle+1 as iterations,
    case time_period
    when 14400 then '4 hours'
    when 86400 then '1 day'
    when 604800 then '1 week'
    else time_period end as time_period_eng
    from polygon.core.fact_event_logs
    where contract_address = lower('0x059d306A25c4cE8D7437D25743a8B94520536BD5')
    and topics[0] = '0x1915b09a20b5793f1bd89b84dc928fe4ee36b0b9270ec217a3b2c278999f0967'
    )

    select
    token_to,
    count(distinct user) as users,
    count(tx_hash) as txs
    from mean_data
    group by 1
    Run a query to Download Data