Updated 2024-07-22
    with pricet as (
    select
    hour::date as date,
    token_address,
    decimals,
    symbol,
    avg(price) as price_usd
    from aptos.price.ez_prices_hourly
    group by 1, 2, 3, 4

    union all

    select
    hour::date,
    '0xfaf4e633ae9eb31366c9ca24214231760926576c7b625313b3688b5e900731f6::staking::ThalaAPT',
    8,
    'thAPT',
    avg(price)
    from aptos.price.ez_prices_hourly
    where symbol = 'APT'
    group by 1, 2, 3, 4
    ),

    main as (
    select
    tx_hash,
    block_timestamp,
    sender as user,
    event_data:amount_0 as amount0_unadj,
    event_data:amount_1 as amount1_unadj,
    split(split(event_type, 'LiquidityEvent<')[1], ', ')[0] as token0_address,
    split(split(event_type, 'LiquidityEvent<')[1], ', ')[1] as token1_address,
    iff(event_resource like 'AddLiquidityEvent%', 'ADD_LIQUIDITY', 'REMOVE_LIQUIDITY') as action,
    'Stable Liquidity' as liquidity_type
    from aptos.core.fact_events
    join aptos.core.fact_transactions
    QueryRunArchived: QueryRun has been archived