Skip to content

Commit dedb1a6

Browse files
committed
feat: enable accumulator_v2 on price creation
1 parent 5ee8b5f commit dedb1a6

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

program/rust/src/processor/add_price.rs

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use {
22
crate::{
33
accounts::{
44
PriceAccount,
5+
PriceAccountFlags,
56
ProductAccount,
67
PythAccount,
78
},
@@ -78,6 +79,10 @@ pub fn add_price(
7879
price_data.product_account = *product_account.key;
7980
price_data.next_price_account = product_data.first_price_account;
8081
price_data.min_pub_ = PRICE_ACCOUNT_DEFAULT_MIN_PUB;
82+
price_data
83+
.flags
84+
.insert(PriceAccountFlags::ACCUMULATOR_V2 | PriceAccountFlags::MESSAGE_BUFFER_CLEARED);
85+
8186
product_data.first_price_account = *price_account.key;
8287

8388
Ok(())

program/rust/src/tests/test_full_publisher_set.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ async fn test_full_publisher_set() -> Result<(), Box<dyn std::error::Error>> {
7979
.await
8080
.unwrap();
8181

82-
assert_eq!(price_data.agg_.price_, 110);
83-
assert_eq!(price_data.agg_.conf_, 20);
82+
assert_eq!(price_data.agg_.price_, 0);
83+
assert_eq!(price_data.agg_.conf_, 0);
8484
}
8585

8686
Ok(())

program/rust/src/tests/test_publish.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ async fn test_publish() {
102102
assert_eq!(price_data.comp_[0].latest_.conf_, 0);
103103
assert_eq!(price_data.comp_[0].latest_.status_, PC_STATUS_UNKNOWN);
104104

105-
assert_eq!(price_data.comp_[0].agg_.price_, 150);
106-
assert_eq!(price_data.comp_[0].agg_.conf_, 7);
107-
assert_eq!(price_data.comp_[0].agg_.status_, PC_STATUS_TRADING);
105+
assert_eq!(price_data.comp_[0].agg_.price_, 0);
106+
assert_eq!(price_data.comp_[0].agg_.conf_, 0);
107+
assert_eq!(price_data.comp_[0].agg_.status_, PC_STATUS_UNKNOWN);
108108
}
109109
}

program/rust/src/tests/test_publish_batch.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ async fn test_publish_batch() {
111111
.get_account_data_as::<PriceAccount>(*price)
112112
.await
113113
.unwrap();
114-
let quote = quotes.get(key).unwrap();
114+
let _quote = quotes.get(key).unwrap();
115115
let new_quote = new_quotes.get(key).unwrap();
116116

117117
assert_eq!(price_data.comp_[0].latest_.price_, new_quote.price);
@@ -125,11 +125,8 @@ async fn test_publish_batch() {
125125
)
126126
.unwrap()
127127
);
128-
assert_eq!(price_data.comp_[0].agg_.price_, quote.price);
129-
assert_eq!(price_data.comp_[0].agg_.conf_, quote.confidence);
130-
assert_eq!(
131-
price_data.comp_[0].agg_.status_,
132-
get_status_for_conf_price_ratio(quote.price, quote.confidence, quote.status).unwrap()
133-
);
128+
assert_eq!(price_data.comp_[0].agg_.price_, 0);
129+
assert_eq!(price_data.comp_[0].agg_.conf_, 0);
130+
assert_eq!(price_data.comp_[0].agg_.status_, PC_STATUS_UNKNOWN);
134131
}
135132
}

0 commit comments

Comments
 (0)