cybergenlabHistorical Token Prices
    Updated 2025-02-11
    with token_meta as (
    select
    value:PLATFORM::string as platform,
    value:POOL_ADDRESS::string as pool_address,
    value:TOKEN_NAME::string as name,
    value:TICKER::string as ticker,
    value:TOKEN_ADDRESS::string as token_address,
    value:DECIMALS::numeric as decimals,
    value:SUPPLY::numeric as supply
    from (
    select
    livequery.live.udf_api('https://flipsidecrypto.xyz/api/v1/queries/7aa557ad-d182-4403-b9ca-8a4b774530a3/data/latest') as response
    ), lateral FLATTEN (input => response:data)
    order by 1 desc
    )

    , weth_price as (
    select
    date_trunc('day', hour) as date,
    avg(price) as price
    from base.price.ez_prices_hourly
    where symbol = 'WETH'
    and date_trunc('day', hour) = current_date()
    group by 1
    )

    , token_price_usdc as (
    select
    date_trunc('day', block_timestamp) as date,
    symbol_out,
    price as eth_price,
    avg((amount_out_usd/amount_out)) as price
    from base.defi.ez_dex_swaps, weth_price
    where contract_address in (select pool_address from token_meta)
    and symbol_out in ('CONVO','LUNA', 'AIXBT')
    and symbol_in= 'USDC'
    QueryRunArchived: QueryRun has been archived