File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -248,7 +248,10 @@ pub struct PriceComp {
248
248
pub latest : PriceInfo ,
249
249
}
250
250
251
- /// An exponentially-weighted moving average.
251
+ #[ deprecated = "Type is renamed to Rational, please use the new name." ]
252
+ pub type Ema = Rational ;
253
+
254
+ /// An number represented as both `value` and also in rational as `numer/denom`.
252
255
#[ derive(
253
256
Copy ,
254
257
Clone ,
@@ -262,12 +265,9 @@ pub struct PriceComp {
262
265
serde:: Deserialize ,
263
266
) ]
264
267
#[ repr( C ) ]
265
- pub struct Ema {
266
- /// The current value of the EMA
268
+ pub struct Rational {
267
269
pub val : i64 ,
268
- /// numerator state for next update
269
270
pub numer : i64 ,
270
- /// denominator state for next update
271
271
pub denom : i64 ,
272
272
}
273
273
@@ -295,10 +295,10 @@ pub struct PriceAccount {
295
295
pub last_slot : u64 ,
296
296
/// valid slot-time of agg. price
297
297
pub valid_slot : u64 ,
298
- /// time-weighted average price
299
- pub twap : Ema ,
300
- /// time-weighted average confidence interval
301
- pub twac : Ema ,
298
+ /// exponentially moving average price
299
+ pub twap : Rational ,
300
+ /// exponentially moving average confidence interval
301
+ pub twac : Rational ,
302
302
/// space for future derived values
303
303
pub drv1 : i64 ,
304
304
/// space for future derived values
Original file line number Diff line number Diff line change @@ -5,12 +5,12 @@ use pyth_sdk_solana::state::{
5
5
AccKey ,
6
6
AccountType ,
7
7
CorpAction ,
8
- Ema ,
9
8
PriceAccount ,
10
9
PriceComp ,
11
10
PriceInfo ,
12
11
PriceStatus ,
13
12
PriceType ,
13
+ Rational ,
14
14
MAGIC ,
15
15
VERSION_2 ,
16
16
} ;
@@ -23,7 +23,7 @@ use common::test_instr_exec_ok;
23
23
fn price_account_all_zero ( ) -> PriceAccount {
24
24
let acc_key = AccKey { val : [ 0 ; 32 ] } ;
25
25
26
- let ema = Ema {
26
+ let rational = Rational {
27
27
val : 0 ,
28
28
numer : 0 ,
29
29
denom : 0 ,
@@ -54,8 +54,8 @@ fn price_account_all_zero() -> PriceAccount {
54
54
num_qt : 0 ,
55
55
last_slot : 0 ,
56
56
valid_slot : 0 ,
57
- twap : ema ,
58
- twac : ema ,
57
+ twap : rational ,
58
+ twac : rational ,
59
59
drv1 : 0 ,
60
60
drv2 : 0 ,
61
61
prod : acc_key,
You can’t perform that action at this time.
0 commit comments