|
|
@@ -58,6 +58,16 @@ pub struct RpcPriceFeedMetadata {
|
|
|
pub prev_publish_time: Option<UnixTimestamp>,
|
|
|
}
|
|
|
|
|
|
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
|
|
+pub struct RpcPriceFeedMetadataV2 {
|
|
|
+ #[schema(value_type = Option<u64>, example=85480034)]
|
|
|
+ pub slot: Option<Slot>,
|
|
|
+ #[schema(value_type = Option<i64>, example=doc_examples::timestamp_example)]
|
|
|
+ pub proof_available_time: Option<UnixTimestamp>,
|
|
|
+ #[schema(value_type = Option<i64>, example=doc_examples::timestamp_example)]
|
|
|
+ pub prev_publish_time: Option<UnixTimestamp>,
|
|
|
+}
|
|
|
+
|
|
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
|
|
pub struct RpcPriceFeed {
|
|
|
pub id: RpcPriceIdentifier,
|
|
|
@@ -179,3 +189,60 @@ impl RpcPriceIdentifier {
|
|
|
RpcPriceIdentifier(id.to_bytes())
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+#[derive(Clone, Copy, Debug, Default, serde::Deserialize, serde::Serialize)]
|
|
|
+pub enum EncodingType {
|
|
|
+ #[default]
|
|
|
+ #[serde(rename = "hex")]
|
|
|
+ Hex,
|
|
|
+ #[serde(rename = "base64")]
|
|
|
+ Base64,
|
|
|
+}
|
|
|
+
|
|
|
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
|
|
+pub struct BinaryPriceUpdate {
|
|
|
+ pub encoding: EncodingType,
|
|
|
+ pub data: Vec<String>,
|
|
|
+}
|
|
|
+
|
|
|
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
|
|
+pub struct ParsedPriceUpdate {
|
|
|
+ pub id: String,
|
|
|
+ pub price: RpcPrice,
|
|
|
+ pub ema_price: RpcPrice,
|
|
|
+ pub metadata: RpcPriceFeedMetadataV2,
|
|
|
+}
|
|
|
+
|
|
|
+impl From<PriceFeedUpdate> for ParsedPriceUpdate {
|
|
|
+ fn from(price_feed_update: PriceFeedUpdate) -> Self {
|
|
|
+ let price_feed = price_feed_update.price_feed;
|
|
|
+
|
|
|
+ Self {
|
|
|
+ id: price_feed.id.to_string(),
|
|
|
+ price: RpcPrice {
|
|
|
+ price: price_feed.get_price_unchecked().price,
|
|
|
+ conf: price_feed.get_price_unchecked().conf,
|
|
|
+ expo: price_feed.get_price_unchecked().expo,
|
|
|
+ publish_time: price_feed.get_price_unchecked().publish_time,
|
|
|
+ },
|
|
|
+ ema_price: RpcPrice {
|
|
|
+ price: price_feed.get_ema_price_unchecked().price,
|
|
|
+ conf: price_feed.get_ema_price_unchecked().conf,
|
|
|
+ expo: price_feed.get_ema_price_unchecked().expo,
|
|
|
+ publish_time: price_feed.get_ema_price_unchecked().publish_time,
|
|
|
+ },
|
|
|
+ metadata: RpcPriceFeedMetadataV2 {
|
|
|
+ proof_available_time: price_feed_update.received_at,
|
|
|
+ slot: price_feed_update.slot,
|
|
|
+ prev_publish_time: price_feed_update.prev_publish_time,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
|
|
+pub struct PriceUpdate {
|
|
|
+ pub binary: BinaryPriceUpdate,
|
|
|
+ #[serde(skip_serializing_if = "Option::is_none")]
|
|
|
+ pub parsed: Option<Vec<ParsedPriceUpdate>>,
|
|
|
+}
|