@@ -352,22 +352,34 @@ function Page() {
352
352
)
353
353
return undefined ;
354
354
355
- const timestampsS = tokenInHistoricalUsdPrices
356
- . filter ( ( _ , index ) => index % 10 === 0 ) // 1*10 = 10 minutes
357
- . map ( ( item ) => item . timestampS ) ;
358
-
359
- return timestampsS . map ( ( timestampS ) => ( {
360
- timestampS,
361
- ratio : + new BigNumber (
362
- tokenInHistoricalUsdPrices . find (
363
- ( item ) => item . timestampS === timestampS ,
364
- ) ?. value ?? 0 ,
365
- ) . div (
366
- tokenOutHistoricalUsdPrices . find (
367
- ( item ) => item . timestampS === timestampS ,
368
- ) ?. value ?? 1 ,
369
- ) ,
370
- } ) ) ;
355
+ const minTimestampS = Math . max (
356
+ Math . min ( ...tokenInHistoricalUsdPrices . map ( ( item ) => item . timestampS ) ) ,
357
+ Math . min ( ...tokenOutHistoricalUsdPrices . map ( ( item ) => item . timestampS ) ) ,
358
+ ) ;
359
+ const maxTimestampS = Math . min (
360
+ Math . max ( ...tokenInHistoricalUsdPrices . map ( ( item ) => item . timestampS ) ) ,
361
+ Math . max ( ...tokenOutHistoricalUsdPrices . map ( ( item ) => item . timestampS ) ) ,
362
+ ) ;
363
+
364
+ const timestampsS : number [ ] = [ minTimestampS ] ;
365
+ while ( timestampsS [ timestampsS . length - 1 ] < maxTimestampS ) {
366
+ timestampsS . push ( timestampsS [ timestampsS . length - 1 ] + 60 * 1 ) ; // 1 minute
367
+ }
368
+
369
+ return timestampsS
370
+ . filter ( ( timestampS , index ) => index % 10 === 0 ) // 1*10 = 10 minutes
371
+ . map ( ( timestampS ) => ( {
372
+ timestampS,
373
+ ratio : + new BigNumber (
374
+ tokenInHistoricalUsdPrices . find (
375
+ ( item ) => item . timestampS === timestampS ,
376
+ ) ?. value ?? 0 ,
377
+ ) . div (
378
+ tokenOutHistoricalUsdPrices . find (
379
+ ( item ) => item . timestampS === timestampS ,
380
+ ) ?. value ?? 1 ,
381
+ ) ,
382
+ } ) ) ;
371
383
} ) ( ) ;
372
384
const tokensRatio1DChange =
373
385
tokensCurrentRatio !== undefined && tokensHistoricalRatios !== undefined
0 commit comments