@@ -487,7 +487,9 @@ def __init__(self, key: SolanaPublicKey, solana: SolanaClient, *, product: Optio
487
487
self .aggregate_price_info : Optional [PythPriceInfo ] = None
488
488
self .price_components : List [PythPriceComponent ] = []
489
489
self .derivations : Dict [EmaType , int ] = {}
490
+ self .timestamp : int = 0 # unix timestamp in seconds
490
491
self .min_publishers : Optional [int ] = None
492
+ self .prev_timestamp : int = 0 # unix timestamp in seconds
491
493
492
494
@property
493
495
def aggregate_price (self ) -> Optional [float ]:
@@ -552,15 +554,17 @@ def update_from(self, buffer: bytes, *, version: int, offset: int = 0) -> None:
552
554
price_type , exponent , num_components = struct .unpack_from ("<IiI" , buffer , offset )
553
555
offset += 16 # struct.calcsize("IiII") (last I is the number of quoters that make up the aggregate)
554
556
last_slot , valid_slot = struct .unpack_from ("<QQ" , buffer , offset )
555
- offset += 16 # QQ
557
+ offset += 16 # struct.calcsize("QQ")
556
558
derivations = list (struct .unpack_from ("<6q" , buffer , offset ))
557
559
self .derivations = dict ((type_ , derivations [type_ .value - 1 ]) for type_ in [EmaType .EMA_CONFIDENCE_VALUE , EmaType .EMA_PRICE_VALUE ])
558
- offset += 48 # 6q
559
- # All drv* _ fields sans min_publishers are currently unused
560
- _ , min_publishers = struct .unpack_from ("<qQ " , buffer , offset )
561
- offset += 16 # <qQ
560
+ offset += 48 # struct.calcsize("6q")
561
+ # drv[2-4] _ fields are currently unused
562
+ timestamp , min_publishers = struct .unpack_from ("<qB " , buffer , offset )
563
+ offset += 16 # struct.calcsize("qBbhi") ("bhi" is drv_2, drv_3, drv_4)
562
564
product_account_key_bytes , next_price_account_key_bytes = struct .unpack_from ("32s32s" , buffer , offset )
563
- offset += 96 # 32s32s32s
565
+ offset += 88 # struct.calcsize("32s32sQqQ") ("QqQ" is prev_slot, prev_price, prev_conf)
566
+ prev_timestamp = struct .unpack_from ("<q" , buffer , offset )[0 ]
567
+ offset += 8 # struct.calcsize("q")
564
568
elif version == _VERSION_1 :
565
569
price_type , exponent , num_components , _ , last_slot , valid_slot , product_account_key_bytes , next_price_account_key_bytes , aggregator_key_bytes = struct .unpack_from (
566
570
"<IiIIQQ32s32s32s" , buffer , offset )
@@ -595,7 +599,9 @@ def update_from(self, buffer: bytes, *, version: int, offset: int = 0) -> None:
595
599
next_price_account_key_bytes )
596
600
self .aggregate_price_info = aggregate_price_info
597
601
self .price_components = price_components
602
+ self .timestamp = timestamp
598
603
self .min_publishers = min_publishers
604
+ self .prev_timestamp = prev_timestamp
599
605
600
606
def __str__ (self ) -> str :
601
607
if self .product :
0 commit comments