@@ -37,20 +37,17 @@ class PythPriceStatus(Enum):
37
37
class PythPriceType (Enum ):
38
38
UNKNOWN = 0
39
39
PRICE = 1
40
- # TWAP/VOL removed after V2
41
- TWAP = 2
42
- VOLATILITY = 3
43
40
44
41
45
- # Join time-weighted exponential moving average for TWAP and TWAC
46
- class TwEmaType (Enum ):
42
+ # Join exponential moving average for EMA price and EMA confidence
43
+ class EmaType (Enum ):
47
44
UNKNOWN = 0
48
- TWAPVALUE = 1
49
- TWAPNUMERATOR = 2
50
- TWAPDENOMINATOR = 3
51
- TWACVALUE = 4
52
- TWACNUMERATOR = 5
53
- TWACDENOMINATOR = 6
45
+ EMA_PRICE_VALUE = 1
46
+ EMA_PRICE_NUMERATOR = 2
47
+ EMA_PRICE_DENOMINATOR = 3
48
+ EMA_CONFIDENCE_VALUE = 4
49
+ EMA_CONFIDENCE_NUMERATOR = 5
50
+ EMA_CONFIDENCE_DENOMINATOR = 6
54
51
55
52
56
53
def _check_base64 (format : str ):
@@ -524,7 +521,7 @@ def __init__(self, key: SolanaPublicKey, solana: SolanaClient, *, product: Optio
524
521
self .next_price_account_key : Optional [SolanaPublicKey ] = None
525
522
self .aggregate_price_info : Optional [PythPriceInfo ] = None
526
523
self .price_components : List [PythPriceComponent ] = []
527
- self .derivations : Dict [TwEmaType , int ] = {}
524
+ self .derivations : Dict [EmaType , int ] = {}
528
525
self .min_publishers : Optional [int ] = None
529
526
530
527
@property
@@ -592,7 +589,7 @@ def update_from(self, buffer: bytes, *, version: int, offset: int = 0) -> None:
592
589
last_slot , valid_slot = struct .unpack_from ("<QQ" , buffer , offset )
593
590
offset += 16 # QQ
594
591
derivations = list (struct .unpack_from ("<6q" , buffer , offset ))
595
- self .derivations = dict ((type_ , derivations [type_ .value - 1 ]) for type_ in [TwEmaType . TWACVALUE , TwEmaType . TWAPVALUE ])
592
+ self .derivations = dict ((type_ , derivations [type_ .value - 1 ]) for type_ in [EmaType . EMA_CONFIDENCE_VALUE , EmaType . EMA_PRICE_VALUE ])
596
593
offset += 48 # 6q
597
594
# All drv*_ fields sans min_publishers are currently unused
598
595
_ , min_publishers = struct .unpack_from ("<qQ" , buffer , offset )
@@ -654,7 +651,7 @@ def to_json(self):
654
651
"next_price_account_key" : str (self .next_price_account_key ),
655
652
"aggregate_price_info" : self .aggregate_price_info .to_json (),
656
653
"price_components" : [x .to_json () for x in self .price_components ],
657
- "derivations" : {TwEmaType (x ).name : self .derivations .get (x ) for x in list (self .derivations .keys ())},
654
+ "derivations" : {EmaType (x ).name : self .derivations .get (x ) for x in list (self .derivations .keys ())},
658
655
"min_publishers" : self .min_publishers ,
659
656
"aggregate_price" : self .aggregate_price ,
660
657
"aggregate_price_confidence_interval" : self .aggregate_price_confidence_interval
0 commit comments