Updated 2024-11-24
    with
    token_info as (
    select
    token_address,
    symbol,
    name,
    decimals
    from aptos.core.dim_tokens
    )


    ,prices as (
    select
    hour,
    symbol,
    decimals,
    token_address,
    price
    from aptos.price.ez_prices_hourly
    )
    , swaps as (
    SELECT
    a.block_timestamp,
    a.block_number,
    a.tx_hash,
    a.event_index,
    b.sender as swapper,
    CASE
    WHEN a.event_data:x_in :: int = 0 THEN TRIM(SPLIT(a.event_type, ',')[1] :: string, ' ')
    WHEN a.event_data:x_in :: int != 0 THEN TRIM(SPLIT_PART(SPLIT(a.event_type, ',')[0], '<', 2) :: string, ' ')
    END AS token_in,
    CASE
    WHEN a.event_data:y_in :: int = 0 THEN TRIM(SPLIT(a.event_type, ',')[1] :: string, ' ')
    WHEN a.event_data:y_in :: int != 0 THEN TRIM(SPLIT_PART(SPLIT(a.event_type, ',')[0], '<', 2) :: string, ' ')
    END AS token_out,
    CASE
    QueryRunArchived: QueryRun has been archived