BlockTrackeroverview (swap) Thala
    Updated 2024-10-15
    with
    token_info as (
    select
    token_address,
    symbol,
    name,
    decimals
    from aptos.core.dim_tokens
    )
    ,prices as (
    select
    date_trunc('hour',hour) as hour,
    symbol,
    median(price) as price
    from aptos.price.ez_prices_hourly
    group by 1 , 2
    )
    , swaps as (
    select
    a.block_number,
    a.block_timestamp,
    a.tx_hash,
    a.event_index,
    b.sender as swapper,
    CASE when event_data:idx_in = '1' then TRIM(SPLIT(event_type, ',')[1],' ')
    when event_data:idx_in = '0' then TRIM(SPLIT_PART(SPLIT(event_type, ',')[0], '<', 2),' ')
    end as token_in,
    CASE when event_data:idx_out = '0' then TRIM(SPLIT_PART(SPLIT(event_type, ',')[0], '<', 2),' ')
    when event_data:idx_out = '1' then TRIM(SPLIT(event_type, ',')[1],' ')
    end as token_out,
    event_data:amount_in :: int as amount_in_raw,
    event_data:amount_out :: int as amount_out_raw
    from aptos.core.fact_events a
    join aptos.core.fact_transactions b using(tx_hash)
    where
    a.event_address = '0x48271d39d0b05bd6efca2278f22277d6fcc375504f9839fd73f74ace240861af'
    QueryRunArchived: QueryRun has been archived