Sbhn_NPcompulsory-amaranth
    Updated 2025-02-07
    with price_ena as (
    select hour::date as datee,
    avg(price) as usdprice
    from crosschain.price.ez_prices_hourly
    where symbol = 'ENA'
    group by 1
    ),

    price_swell as (
    select hour::date as datee,
    avg(price) as usdprice
    from crosschain.price.ez_prices_hourly
    where symbol = 'SWELL'
    group by 1
    ),

    price_eth as (
    select hour::date as datee,
    avg(price) as usdprice
    from ethereum.price.ez_prices_hourly
    where symbol = 'WETH'
    group by 1
    ),

    ETHSWELL as (
    with single_ETHSWELL as (
    select
    sum(ethereum.public.udf_hex_to_int(regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}')[0]) / pow(10,18)) as eth_single,
    sum((ethereum.public.udf_hex_to_int(regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}')[0]) / pow(10,18))*usdprice) as eth_single_usd,
    from swell.core.fact_event_logs
    join price_eth on block_timestamp::date=datee
    where topic_0 = '0xdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7'
    and origin_to_address = lower('0x7fe118bee84900faed30dab9ecfbead633392f05')
    ),

    pair_ETHSWELL as (
    QueryRunArchived: QueryRun has been archived