@@ -7,7 +7,9 @@ use crate::state::pyth_lazer_oracle::{
77use crate :: validate;
88use anchor_lang:: prelude:: * ;
99use pyth_lazer_solana_contract:: protocol:: message:: SolanaMessage ;
10- use pyth_lazer_solana_contract:: protocol:: payload:: { PayloadData , PayloadPropertyValue } ;
10+ use pyth_lazer_solana_contract:: protocol:: payload:: {
11+ PayloadData , PayloadPropertyValue , TimestampUs ,
12+ } ;
1113use pyth_lazer_solana_contract:: protocol:: router:: Price ;
1214use pyth_lazer_solana_contract:: Storage ;
1315use solana_program:: sysvar:: instructions:: load_current_index_checked;
@@ -76,23 +78,26 @@ pub fn handle_update_pyth_lazer_oracle<'c: 'info, 'info>(
7678 let mut best_bid_price: Option < Price > = None ;
7779 let mut best_ask_price: Option < Price > = None ;
7880 let mut exponent: Option < i16 > = None ;
79- let mut feed_update_timestamp: Option < TimestampUs > = None ;
81+ let mut feed_update_timestamp: Option < u64 > = None ;
8082
8183 for property in & payload_data. properties {
8284 match property {
8385 PayloadPropertyValue :: BestBidPrice ( price) => best_bid_price = * price,
8486 PayloadPropertyValue :: BestAskPrice ( price) => best_ask_price = * price,
8587 PayloadPropertyValue :: Exponent ( exp) => exponent = Some ( * exp) ,
86- PayloadPropertyValue :: FeedUpdateTimestamp ( timestamp) => {
87- feed_update_timestamp = * timestamp
88- }
88+ PayloadPropertyValue :: FeedUpdateTimestamp ( timestamp) => match timestamp {
89+ Some ( timestamp) => match * timestamp {
90+ TimestampUs ( ts) => feed_update_timestamp = Some ( ts) ,
91+ } ,
92+ None => return Err ( ErrorCode :: InvalidPythLazerMessage . into ( ) ) ,
93+ } ,
8994 _ => { }
9095 }
9196 }
9297
9398 match feed_update_timestamp {
9499 Some ( timestamp) => {
95- if timestamp > current_timestamp {
100+ if current_timestamp >= timestamp {
96101 msg ! (
97102 "Skipping lazer price update. current ts {} >= feed_update_timestamp {}" ,
98103 current_timestamp,
@@ -102,6 +107,7 @@ pub fn handle_update_pyth_lazer_oracle<'c: 'info, 'info>(
102107 }
103108 }
104109 None => {
110+ msg ! ( "Skipping lazer price update. feed_update_timestamp is None" , ) ;
105111 return Err ( ErrorCode :: InvalidPythLazerMessage . into ( ) ) ;
106112 }
107113 }
@@ -124,15 +130,15 @@ pub fn handle_update_pyth_lazer_oracle<'c: 'info, 'info>(
124130
125131 pyth_lazer_oracle. price = price;
126132 pyth_lazer_oracle. posted_slot = Clock :: get ( ) ?. slot ;
127- pyth_lazer_oracle. publish_time = feed_update_timestamp;
133+ pyth_lazer_oracle. publish_time = feed_update_timestamp. unwrap ( ) ;
128134 pyth_lazer_oracle. exponent = exponent. cast :: < i32 > ( ) ?;
129135 pyth_lazer_oracle. conf = conf. cast :: < u64 > ( ) ?;
130136 msg ! ( "Price updated to {}" , price) ;
131137
132138 msg ! (
133139 "Posting new lazer update. current ts {} < feed_update_timestamp {}" ,
134140 current_timestamp,
135- feed_update_timestamp
141+ feed_update_timestamp. unwrap ( )
136142 ) ;
137143 }
138144
0 commit comments