@@ -184,15 +184,7 @@ const useChartElem = (symbol: string, feedId: string) => {
184184 return ;
185185 }
186186
187- const benchmarkData = benchmarksApiResponseSchema . parse ( jsonData ) ;
188-
189- // Transform OHLC data to our format using close prices
190- const data = benchmarkData . t . map ( ( timestamp , i ) => ( {
191- time : timestamp as UTCTimestamp ,
192- price : benchmarkData . c [ i ] , // Use close price
193- confidence : 0 , // No confidence data from benchmarks API
194- status : PriceStatus . Trading ,
195- } ) ) ;
187+ const data = benchmarksApiResponseSchema . parse ( jsonData ) ;
196188
197189 // Get the current historical price data
198190 // Note that .data() returns (WhitespaceData | LineData)[], hence the type cast.
@@ -408,15 +400,24 @@ type ChartRefContents = {
408400 price : ISeriesApi < "Line" > ;
409401} ;
410402
411- const benchmarksApiResponseSchema = z . object ( {
412- s : z . string ( ) , // status
413- t : z . array ( z . number ( ) ) , // timestamp
414- o : z . array ( z . number ( ) ) , // open
415- h : z . array ( z . number ( ) ) , // high
416- l : z . array ( z . number ( ) ) , // low
417- c : z . array ( z . number ( ) ) , // close
418- v : z . array ( z . number ( ) ) , // volume
419- } ) ;
403+ const benchmarksApiResponseSchema = z
404+ . object ( {
405+ s : z . string ( ) ,
406+ t : z . array ( z . number ( ) ) ,
407+ o : z . array ( z . number ( ) ) ,
408+ h : z . array ( z . number ( ) ) ,
409+ l : z . array ( z . number ( ) ) ,
410+ c : z . array ( z . number ( ) ) ,
411+ v : z . array ( z . number ( ) ) ,
412+ } )
413+ . transform ( ( data ) =>
414+ data . t . map ( ( timestamp , i ) => ( {
415+ time : timestamp as UTCTimestamp ,
416+ price : data . c [ i ] , // Use close price for now
417+ confidence : 0 , // No confidence data from benchmarks API
418+ status : PriceStatus . Trading ,
419+ } ) ) ,
420+ ) ;
420421const priceFormat = {
421422 type : "price" ,
422423 precision : 5 ,
0 commit comments