i_dan$TYBG: Price & MCap
    Updated 2024-11-18
    with TYBGPrice as (
    SELECT
    DATE_TRUNC('hour', block_timestamp) AS Hour
    , MEDIAN(amount_out_usd/amount_out) AS t_price
    FROM base.defi.ez_dex_swaps
    WHERE 1=1
    AND token_out = lower('0x0d97F261b1e88845184f678e2d1e7a98D9FD38dE')
    AND amount_out > 0
    AND amount_out_usd > 0
    GROUP BY
    1
    ORDER BY 1 DESC
    )

    SELECT
    date_trunc(day, Hour) as day
    , avg(t_price) as Price
    , 125000000000 as Circulating_Supply
    , Price * Circulating_Supply as Market_Cap
    , lag(Market_Cap, 1 , Market_Cap) over(order by day) as Prev_MC
    , (Market_Cap - Prev_MC)/Prev_MC * 100 as "MC CHANGE %"
    FROM TYBGPrice
    GROUP BY
    1
    ORDER BY
    1 DESC
    QueryRunArchived: QueryRun has been archived