Browse Source

fix(lazer): remove Default from AggregatedPriceFeedData, always set exponent (#3208)

Pavel Strakhov 3 days ago
parent
commit
227a086c7d

+ 6 - 6
Cargo.lock

@@ -5740,7 +5740,7 @@ dependencies = [
 
 [[package]]
 name = "pyth-lazer-client"
-version = "10.0.0"
+version = "11.0.0"
 dependencies = [
  "alloy-primitives 0.8.25",
  "anyhow",
@@ -5760,8 +5760,8 @@ dependencies = [
  "humantime-serde",
  "libsecp256k1 0.7.2",
  "protobuf-json-mapping",
- "pyth-lazer-protocol 0.21.0",
- "pyth-lazer-publisher-sdk 0.21.0",
+ "pyth-lazer-protocol 0.22.0",
+ "pyth-lazer-publisher-sdk 0.22.0",
  "reqwest 0.12.23",
  "serde",
  "serde_json",
@@ -5798,7 +5798,7 @@ dependencies = [
 
 [[package]]
 name = "pyth-lazer-protocol"
-version = "0.21.0"
+version = "0.22.0"
 dependencies = [
  "alloy-primitives 0.8.25",
  "anyhow",
@@ -5839,13 +5839,13 @@ dependencies = [
 
 [[package]]
 name = "pyth-lazer-publisher-sdk"
-version = "0.21.0"
+version = "0.22.0"
 dependencies = [
  "anyhow",
  "fs-err",
  "protobuf",
  "protobuf-codegen",
- "pyth-lazer-protocol 0.21.0",
+ "pyth-lazer-protocol 0.22.0",
  "serde_json",
 ]
 

+ 1 - 1
lazer/contracts/solana/programs/pyth-lazer-solana-contract/Cargo.toml

@@ -19,7 +19,7 @@ no-log-ix-name = []
 idl-build = ["anchor-lang/idl-build"]
 
 [dependencies]
-pyth-lazer-protocol = { path = "../../../../sdk/rust/protocol", version = "0.21.0" }
+pyth-lazer-protocol = { path = "../../../../sdk/rust/protocol", version = "0.22.0" }
 
 anchor-lang = "0.31.1"
 bytemuck = { version = "1.20.0", features = ["derive"] }

+ 2 - 2
lazer/publisher_sdk/rust/Cargo.toml

@@ -1,13 +1,13 @@
 [package]
 name = "pyth-lazer-publisher-sdk"
-version = "0.21.0"
+version = "0.22.0"
 edition = "2021"
 description = "Pyth Lazer Publisher SDK types."
 license = "Apache-2.0"
 repository = "https://github.com/pyth-network/pyth-crosschain"
 
 [dependencies]
-pyth-lazer-protocol = { version = "0.21.0", path = "../../sdk/rust/protocol" }
+pyth-lazer-protocol = { version = "0.22.0", path = "../../sdk/rust/protocol" }
 anyhow = "1.0.98"
 protobuf = "3.7.2"
 serde_json = "1.0.140"

+ 3 - 3
lazer/sdk/rust/client/Cargo.toml

@@ -1,13 +1,13 @@
 [package]
 name = "pyth-lazer-client"
-version = "10.0.0"
+version = "11.0.0"
 edition = "2021"
 description = "A Rust client for Pyth Lazer"
 license = "Apache-2.0"
 
 [dependencies]
-pyth-lazer-protocol = { path = "../protocol", version = "0.21.0" }
-pyth-lazer-publisher-sdk = { path = "../../../publisher_sdk/rust", version = "0.21.0" }
+pyth-lazer-protocol = { path = "../protocol", version = "0.22.0" }
+pyth-lazer-publisher-sdk = { path = "../../../publisher_sdk/rust", version = "0.22.0" }
 
 tokio = { version = "1", features = ["full"] }
 tokio-stream = "0.1.17"

+ 1 - 1
lazer/sdk/rust/protocol/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "pyth-lazer-protocol"
-version = "0.21.0"
+version = "0.22.0"
 edition = "2021"
 description = "Pyth Lazer SDK - protocol types."
 license = "Apache-2.0"

+ 17 - 1
lazer/sdk/rust/protocol/src/payload.rs

@@ -43,7 +43,7 @@ pub enum PayloadPropertyValue {
     FundingRateInterval(Option<DurationUs>),
 }
 
-#[derive(Debug, Clone, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
 pub struct AggregatedPriceFeedData {
     pub price: Option<Price>,
     pub best_bid_price: Option<Price>,
@@ -56,6 +56,22 @@ pub struct AggregatedPriceFeedData {
     pub funding_rate_interval: Option<DurationUs>,
 }
 
+impl AggregatedPriceFeedData {
+    pub fn empty(exponent: i16) -> Self {
+        Self {
+            price: None,
+            best_bid_price: None,
+            best_ask_price: None,
+            publisher_count: 0,
+            exponent,
+            confidence: None,
+            funding_rate: None,
+            funding_timestamp: None,
+            funding_rate_interval: None,
+        }
+    }
+}
+
 /// First bytes of a payload's encoding
 /// (in LE or BE depending on the byte order used for encoding the rest of the payload)
 pub const PAYLOAD_FORMAT_MAGIC: u32 = 2479346549;