Validating price data against benchmark api

Continuing the discussion from About the Benchmarks(Historic Prices) category:

Hey there :waving_hand:

I’ve been working on processing pyth updates on Solana via laser stream. I didn’t store publish_time during processing so can’t rely on hermes api for validating my price values, therefore, I’m using benchmark api. Here I’m facing an issue with missing records.

Problem:
For some blocks, the prices that I’ve processed don’t match with any price from the benchmark api around the approximate timestamp. The benchmark api has price for each second and not for each slot which might explain the missing prices?

Below is an example of multiple prices published to Solana in the same slot. Only one price matches the result from benchmark api.

publish time publish slot historical price processed price Solana slot
0 0 0 151.228657 350352021
1751348720 226909464 151.20808277 151.20808277 350352021

Please, help me understand the missing values and whether another method can be used for validation.

The first slot within a second is the unique price of that second and that is the one that benchmark api returns. If there is no price produced at that second (due to network forks/..) then benchmarks api return the first price after that timestamp.

To be more accurate, on each update we have publishTime and prevPublishTime (which is the publish time of the previous update), when you request for a price at time t , the benchmarks API returns the price update that matches the following: prevPublishTime < t <= publishTime . This is guaranteed to be at most one unique update.

In the following example, you can see that slot 100 will be the unique one for 12:00:00 and slot 104 will be unique one for 12:00:01 and 12:00:02

Slot Publish Time Prev Publish Time
100 12:00:00 11:59:59
101 12:00:00 12:00:00
104 12:00:02 12:00:00

Thank you!

Slot 104 example also explains why 2 prices published in the same slot on Solana has no matches from the benchmark api.

publish time publish slot historical price processed price Solana slot
0 0 0 151.47181393 350350590
0 0 0 151.46583148 350350590