@@ -7,11 +7,12 @@ use pyth_client::{
7
7
Product ,
8
8
Price ,
9
9
PriceType ,
10
+ DeriveType ,
10
11
PriceStatus ,
11
12
CorpAction ,
12
13
cast,
13
14
MAGIC ,
14
- VERSION_1 ,
15
+ VERSION_2 ,
15
16
PROD_HDR_SIZE
16
17
} ;
17
18
use solana_client:: {
@@ -41,8 +42,6 @@ fn get_price_type( ptype: &PriceType ) -> &'static str
41
42
match ptype {
42
43
PriceType :: Unknown => "unknown" ,
43
44
PriceType :: Price => "price" ,
44
- PriceType :: TWAP => "twap" ,
45
- PriceType :: Volatility => "volatility" ,
46
45
}
47
46
}
48
47
@@ -66,7 +65,7 @@ fn get_corp_act( cact: &CorpAction ) -> &'static str
66
65
fn main ( ) {
67
66
// get pyth mapping account
68
67
let url = "http://api.devnet.solana.com" ;
69
- let key = "ArppEFcsybCLE8CRtQJLQ9tLv2peGmQoKWFuiUWm4KBP " ;
68
+ let key = "BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2 " ;
70
69
let clnt = RpcClient :: new ( url. to_string ( ) ) ;
71
70
let mut akey = Pubkey :: from_str ( key ) . unwrap ( ) ;
72
71
@@ -77,7 +76,7 @@ fn main() {
77
76
assert_eq ! ( map_acct. magic, MAGIC , "not a valid pyth account" ) ;
78
77
assert_eq ! ( map_acct. atype, AccountType :: Mapping as u32 ,
79
78
"not a valid pyth mapping account" ) ;
80
- assert_eq ! ( map_acct. ver, VERSION_1 ,
79
+ assert_eq ! ( map_acct. ver, VERSION_2 ,
81
80
"unexpected pyth mapping account version" ) ;
82
81
83
82
// iget and print each Product in Mapping directory
@@ -89,7 +88,7 @@ fn main() {
89
88
assert_eq ! ( prod_acct. magic, MAGIC , "not a valid pyth account" ) ;
90
89
assert_eq ! ( prod_acct. atype, AccountType :: Product as u32 ,
91
90
"not a valid pyth product account" ) ;
92
- assert_eq ! ( prod_acct. ver, VERSION_1 ,
91
+ assert_eq ! ( prod_acct. ver, VERSION_2 ,
93
92
"unexpected pyth product account version" ) ;
94
93
95
94
// print key and reference data for this Product
@@ -112,7 +111,7 @@ fn main() {
112
111
assert_eq ! ( pa. magic, MAGIC , "not a valid pyth account" ) ;
113
112
assert_eq ! ( pa. atype, AccountType :: Price as u32 ,
114
113
"not a valid pyth price account" ) ;
115
- assert_eq ! ( pa. ver, VERSION_1 ,
114
+ assert_eq ! ( pa. ver, VERSION_2 ,
116
115
"unexpected pyth price account version" ) ;
117
116
println ! ( " price_account .. {:?}" , px_pkey ) ;
118
117
println ! ( " price_type ... {}" , get_price_type( & pa. ptype) ) ;
@@ -123,6 +122,10 @@ fn main() {
123
122
println ! ( " conf ......... {}" , pa. agg. conf ) ;
124
123
println ! ( " valid_slot ... {}" , pa. valid_slot ) ;
125
124
println ! ( " publish_slot . {}" , pa. agg. pub_slot ) ;
125
+ println ! ( " twap ......... {}" ,
126
+ pa. drv[ ( DeriveType :: TWAP as usize ) -1 ] ) ;
127
+ println ! ( " volatility ... {}" ,
128
+ pa. drv[ ( DeriveType :: Volatility as usize ) -1 ] ) ;
126
129
127
130
// go to next price account in list
128
131
if pa. next . is_valid ( ) {
@@ -146,3 +149,4 @@ fn main() {
146
149
akey = Pubkey :: new ( & map_acct. next . val ) ;
147
150
}
148
151
}
152
+
0 commit comments