@@ -58,6 +58,16 @@ pub struct RpcPriceFeedMetadata {
58
58
pub prev_publish_time : Option < UnixTimestamp > ,
59
59
}
60
60
61
+ #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , ToSchema ) ]
62
+ pub struct RpcPriceFeedMetadataV2 {
63
+ #[ schema( value_type = Option <u64 >, example=85480034 ) ]
64
+ pub slot : Option < Slot > ,
65
+ #[ schema( value_type = Option <i64 >, example=doc_examples:: timestamp_example) ]
66
+ pub proof_available_time : Option < UnixTimestamp > ,
67
+ #[ schema( value_type = Option <i64 >, example=doc_examples:: timestamp_example) ]
68
+ pub prev_publish_time : Option < UnixTimestamp > ,
69
+ }
70
+
61
71
#[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , ToSchema ) ]
62
72
pub struct RpcPriceFeed {
63
73
pub id : RpcPriceIdentifier ,
@@ -179,3 +189,60 @@ impl RpcPriceIdentifier {
179
189
RpcPriceIdentifier ( id. to_bytes ( ) )
180
190
}
181
191
}
192
+
193
+ #[ derive( Clone , Copy , Debug , Default , serde:: Deserialize , serde:: Serialize ) ]
194
+ pub enum EncodingType {
195
+ #[ default]
196
+ #[ serde( rename = "hex" ) ]
197
+ Hex ,
198
+ #[ serde( rename = "base64" ) ]
199
+ Base64 ,
200
+ }
201
+
202
+ #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , ToSchema ) ]
203
+ pub struct BinaryPriceUpdate {
204
+ pub encoding : EncodingType ,
205
+ pub data : Vec < String > ,
206
+ }
207
+
208
+ #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , ToSchema ) ]
209
+ pub struct ParsedPriceUpdate {
210
+ pub id : String ,
211
+ pub price : RpcPrice ,
212
+ pub ema_price : RpcPrice ,
213
+ pub metadata : RpcPriceFeedMetadataV2 ,
214
+ }
215
+
216
+ impl From < PriceFeedUpdate > for ParsedPriceUpdate {
217
+ fn from ( price_feed_update : PriceFeedUpdate ) -> Self {
218
+ let price_feed = price_feed_update. price_feed ;
219
+
220
+ Self {
221
+ id : price_feed. id . to_string ( ) ,
222
+ price : RpcPrice {
223
+ price : price_feed. get_price_unchecked ( ) . price ,
224
+ conf : price_feed. get_price_unchecked ( ) . conf ,
225
+ expo : price_feed. get_price_unchecked ( ) . expo ,
226
+ publish_time : price_feed. get_price_unchecked ( ) . publish_time ,
227
+ } ,
228
+ ema_price : RpcPrice {
229
+ price : price_feed. get_ema_price_unchecked ( ) . price ,
230
+ conf : price_feed. get_ema_price_unchecked ( ) . conf ,
231
+ expo : price_feed. get_ema_price_unchecked ( ) . expo ,
232
+ publish_time : price_feed. get_ema_price_unchecked ( ) . publish_time ,
233
+ } ,
234
+ metadata : RpcPriceFeedMetadataV2 {
235
+ proof_available_time : price_feed_update. received_at ,
236
+ slot : price_feed_update. slot ,
237
+ prev_publish_time : price_feed_update. prev_publish_time ,
238
+ } ,
239
+ }
240
+ }
241
+ }
242
+
243
+ #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , ToSchema ) ]
244
+ pub struct PriceUpdate {
245
+ pub binary : BinaryPriceUpdate ,
246
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
247
+ pub parsed : Option < Vec < ParsedPriceUpdate > > ,
248
+ }
0 commit comments