BlockTrackermain (Cellana)
    Updated 2024-05-23
    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_hourly_token_prices
    group by 1 , 2
    )
    , swaps as (
    select
    a.block_number,
    a.block_timestamp,
    a.tx_hash,
    a.event_index,
    b.sender as swapper,
    event_data : pool :: string as pool_address,
    event_data: from_token :: string as token_in,
    event_data : to_token :: string as token_out,
    event_data:amount_in :: float as amount_in_raw,
    event_data:amount_out :: float as amount_out_raw
    from aptos.core.fact_events a
    join aptos.core.fact_transactions b using(tx_hash)
    where
    a.event_address = '0x4bf51972879e3b95c4781a5cdcb9e1ee24ef483e7d22f2d903626f126df62bd1'
    and a.event_resource ILIKE 'SwapEvent%'
    and a.SUCCESS = 'TRUE'
    and a.block_timestamp::date >= '2024-01-01'--dateadd(day, -90 , current_date())