SalehTotal-Dist
    Updated 2025-02-08
    with lst_swell_price as (
    select
    hour::date as swell_date
    ,median(PRICE) as swell_price
    from ethereum.price.ez_prices_hourly
    where TOKEN_ADDRESS=lower('0x0a6E7Ba5042B38349e437ec6Db6214AEC7B35676')
    and hour::date >= '2024-11-01'
    group by 1
    )
    , lst_deposit as (
    select
    block_timestamp::date as date
    ,tx_hash
    ,ORIGIN_FROM_ADDRESS as wallet
    ,DECODED_LOG:assets/1e18 as amount
    ,DECODED_LOG:assets/1e18*swell_price as amount_usd
    from ethereum.core.ez_decoded_event_logs
    join lst_swell_price on block_timestamp::date = swell_date
    where block_timestamp::date>='2024-11-01'
    and TX_STATUS='SUCCESS'
    and EVENT_REMOVED = false
    -- and tx_hash='0xf71bcdd758bd745870d1cfae74bdddb4f8005f5109f9659ad81675bb6a8878f6'
    and EVENT_NAME='Deposit'
    and CONTRACT_ADDRESS='0x358d94b5b2f147d741088803d932acb566acb7b6'
    and CONTRACT_NAME='rSWELL'
    and ORIGIN_FUNCTION_SIGNATURE='0x6e553f65'
    )
    ,lst_withdraw as (
    select
    block_timestamp::date as date
    ,tx_hash
    ,ORIGIN_FROM_ADDRESS as wallet
    ,-1*DECODED_LOG:value/1e18 as amount
    ,-1*DECODED_LOG:value/1e18*swell_price as amount_usd
    from ethereum.core.ez_decoded_event_logs
    -- from swell.core.ez_decoded_event_logs
    QueryRunArchived: QueryRun has been archived