Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 5f0386e

Browse files
v2 account structure
1 parent 0607b61 commit 5f0386e

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

examples/get_accounts.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use pyth_client::{
77
Product,
88
Price,
99
PriceType,
10-
DeriveType,
1110
PriceStatus,
1211
CorpAction,
1312
cast,
@@ -122,10 +121,8 @@ fn main() {
122121
println!( " conf ......... {}", pa.agg.conf );
123122
println!( " valid_slot ... {}", pa.valid_slot );
124123
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] );
124+
println!( " twap ......... {}", pa.twap );
125+
println!( " volatility ... {}", pa.avol );
129126

130127
// go to next price account in list
131128
if pa.next.is_valid() {

src/lib.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,6 @@ pub enum PriceType
4242
Price
4343
}
4444

45-
// different types of calculations derived from aggregate price
46-
#[repr(C)]
47-
pub enum DeriveType
48-
{
49-
Unknown,
50-
TWAP,
51-
Volatility
52-
}
53-
5445
// solana public key
5546
#[repr(C)]
5647
pub struct AccKey
@@ -118,7 +109,14 @@ pub struct Price
118109
pub unused : u32,
119110
pub curr_slot : u64, // currently accumulating price slot
120111
pub valid_slot : u64, // valid slot-time of agg. price
121-
pub drv : [i64;8], // calculated values derived from agg. price
112+
pub twap : i64, // time-weighted average price
113+
pub avol : u64, // annualized price volatility
114+
pub drv0 : i64, // space for future derived values
115+
pub drv1 : i64, // space for future derived values
116+
pub drv2 : i64, // space for future derived values
117+
pub drv3 : i64, // space for future derived values
118+
pub drv4 : i64, // space for future derived values
119+
pub drv5 : i64, // space for future derived values
122120
pub prod : AccKey, // product account key
123121
pub next : AccKey, // next Price account in linked list
124122
pub agg_pub : AccKey, // quoter who computed last aggregate price

0 commit comments

Comments
 (0)