@@ -487,7 +487,9 @@ def __init__(self, key: SolanaPublicKey, solana: SolanaClient, *, product: Optio
487487 self .aggregate_price_info : Optional [PythPriceInfo ] = None
488488 self .price_components : List [PythPriceComponent ] = []
489489 self .derivations : Dict [EmaType , int ] = {}
490+ self .timestamp : int = 0 # unix timestamp in seconds
490491 self .min_publishers : Optional [int ] = None
492+ self .prev_timestamp : int = 0 # unix timestamp in seconds
491493
492494 @property
493495 def aggregate_price (self ) -> Optional [float ]:
@@ -552,15 +554,17 @@ def update_from(self, buffer: bytes, *, version: int, offset: int = 0) -> None:
552554 price_type , exponent , num_components = struct .unpack_from ("<IiI" , buffer , offset )
553555 offset += 16 # struct.calcsize("IiII") (last I is the number of quoters that make up the aggregate)
554556 last_slot , valid_slot = struct .unpack_from ("<QQ" , buffer , offset )
555- offset += 16 # QQ
557+ offset += 16 # struct.calcsize("QQ")
556558 derivations = list (struct .unpack_from ("<6q" , buffer , offset ))
557559 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)
562564 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")
564568 elif version == _VERSION_1 :
565569 price_type , exponent , num_components , _ , last_slot , valid_slot , product_account_key_bytes , next_price_account_key_bytes , aggregator_key_bytes = struct .unpack_from (
566570 "<IiIIQQ32s32s32s" , buffer , offset )
@@ -595,7 +599,9 @@ def update_from(self, buffer: bytes, *, version: int, offset: int = 0) -> None:
595599 next_price_account_key_bytes )
596600 self .aggregate_price_info = aggregate_price_info
597601 self .price_components = price_components
602+ self .timestamp = timestamp
598603 self .min_publishers = min_publishers
604+ self .prev_timestamp = prev_timestamp
599605
600606 def __str__ (self ) -> str :
601607 if self .product :
0 commit comments