You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: program/rust/src/processor/upd_price.rs
+36-73
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,10 @@ use {
2
2
crate::{
3
3
accounts::{
4
4
PriceAccount,
5
+
PriceInfo,
5
6
PythOracleSerialize,
6
7
UPD_PRICE_WRITE_SEED,
7
8
},
8
-
c_oracle_header::PC_STATUS_TRADING,
9
9
deserialize::{
10
10
load,
11
11
load_checked,
@@ -128,8 +128,7 @@ pub fn upd_price(
128
128
let clock = Clock::from_account_info(clock_account)?;
129
129
130
130
letmut publisher_index:usize = 0;
131
-
let slots_since_last_successful_aggregate:u64;
132
-
let noninitial_price_update_after_program_upgrade:bool;
131
+
let latest_aggregate_price:PriceInfo;
133
132
134
133
// The price_data borrow happens in a scope because it must be
135
134
// dropped before we borrow again as raw data pointer for the C
@@ -150,16 +149,7 @@ pub fn upd_price(
150
149
OracleError::PermissionViolation.into(),
151
150
)?;
152
151
153
-
// We use last_slot_ to calculate slots_since_last_successful_aggregate. This is because last_slot_ is updated after the aggregate price is updated successfully.
// Check if the program upgrade has happened in the current slot and aggregate price has been updated, if so, use the old logic to update twap/twac/price_cumulative.
157
-
// This is to ensure that twap/twac/price_cumulative are calculated correctly during the migration.
158
-
// We check if prev_twap_.denom_ is == 0 because when the program upgrade has happened, denom_ is initialized to 0 and it can only stay the same or increase while numer_ can be negative if prices are negative.
159
-
// And we check if slots_since_last_successful_aggregate == 0 to check if the aggregate price has been updated in the current slot.
0 commit comments