Skip to content

Commit da8fe42

Browse files
committed
Rename twap/twac to ema_price/ema_conf
1 parent 71586e2 commit da8fe42

File tree

5 files changed

+18
-19
lines changed

5 files changed

+18
-19
lines changed

pyth-sdk-solana/examples/eth_price.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ fn main() {
3939
}
4040

4141

42-
let maybe_twap = eth_price.get_twap();
43-
match maybe_twap {
44-
Some(twap) => {
45-
println!("twap ............ {} x 10^{}", twap.price, twap.expo);
46-
println!("twac ............ {} x 10^{}", twap.conf, twap.expo);
42+
let maybe_ema_price = eth_price.get_ema_price();
43+
match maybe_ema_price {
44+
Some(ema_price) => {
45+
println!("twap ............ {} x 10^{}", ema_price.price, ema_price.expo);
46+
println!("twac ............ {} x 10^{}", ema_price.conf, ema_price.expo);
4747
}
4848
None => {
4949
println!("twap ............ unavailable");

pyth-sdk-solana/examples/get_accounts.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ fn main() {
9898
println!(" valid_slot ... {}", price_account.valid_slot);
9999
println!(" publish_slot . {}", price_account.agg.pub_slot);
100100

101-
let maybe_twap = price.get_twap();
102-
match maybe_twap {
103-
Some(twap) => {
104-
println!(" twap ......... {} x 10^{}", twap.price, twap.expo);
105-
println!(" twac ......... {} x 10^{}", twap.conf, twap.expo);
101+
let maybe_ema_price = price.get_ema_price();
102+
match maybe_ema_price {
103+
Some(ema_price) => {
104+
println!(" twap ......... {} x 10^{}", ema_price.price, ema_price.expo);
105+
println!(" twac ......... {} x 10^{}", ema_price.conf, ema_price.expo);
106106
}
107107
None => {
108108
println!(" twap ......... unavailable");

pyth-sdk-solana/src/state.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ pub struct PriceAccount {
296296
/// valid slot-time of agg. price
297297
pub valid_slot: u64,
298298
/// exponentially moving average price
299-
pub twap: Rational,
299+
pub ema_price: Rational,
300300
/// exponentially moving average confidence interval
301-
pub twac: Rational,
301+
pub ema_conf: Rational,
302302
/// space for future derived values
303303
pub drv1: i64,
304304
/// space for future derived values
@@ -347,8 +347,8 @@ impl PriceAccount {
347347
status,
348348
max_num_publishers: self.num,
349349
num_publishers: self.num_qt,
350-
ema_price: self.twap.val,
351-
ema_conf: self.twac.val as u64,
350+
ema_price: self.ema_price.val,
351+
ema_conf: self.ema_conf.val as u64,
352352
expo: self.expo,
353353
product_id: self.prod.val,
354354
}

pyth-sdk-solana/tests/stale_price.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ fn price_account_all_zero() -> PriceAccount {
5454
num_qt: 0,
5555
last_slot: 0,
5656
valid_slot: 0,
57-
twap: rational,
58-
twac: rational,
57+
ema_price: rational,
58+
ema_conf: rational,
5959
drv1: 0,
6060
drv2: 0,
6161
prod: acc_key,

pyth-sdk/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,14 @@ impl Price {
9696
}
9797

9898
/**
99-
* Get the time-weighted average price (TWAP) and a confidence interval on the result.
99+
* Get the exponential moving average price (ema_price) and a confidence interval on the result.
100100
* Returns `None` if the twap is currently unavailable.
101101
*
102102
* At the moment, the confidence interval returned by this method is computed in
103103
* a somewhat questionable way, so we do not recommend using it for high-value applications.
104104
*/
105-
pub fn get_twap(&self) -> Option<PriceConf> {
105+
pub fn get_ema_price(&self) -> Option<PriceConf> {
106106
// This method currently cannot return None, but may do so in the future.
107-
// Note that the twac is a positive number in i64, so safe to cast to u64.
108107
Some(PriceConf {
109108
price: self.ema_price,
110109
conf: self.ema_conf,

0 commit comments

Comments
 (0)