diff --git a/lazer/Cargo.lock b/lazer/Cargo.lock index a461f2a20f..84dc80f7b4 100644 --- a/lazer/Cargo.lock +++ b/lazer/Cargo.lock @@ -3771,7 +3771,7 @@ dependencies = [ "futures-util", "hex", "libsecp256k1 0.7.1", - "pyth-lazer-protocol 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pyth-lazer-protocol 0.5.0", "serde", "serde_json", "tokio", @@ -3783,18 +3783,14 @@ dependencies = [ [[package]] name = "pyth-lazer-protocol" version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "560a20d7f1040abad40245e524e657a2ec731e7e0560e25a1532301a1a04cb3f" dependencies = [ - "alloy-primitives", "anyhow", "base64 0.22.1", - "bincode", - "bs58 0.5.1", "byteorder", "derive_more", - "ed25519-dalek 2.1.1", - "hex", "itertools 0.13.0", - "libsecp256k1 0.7.1", "rust_decimal", "serde", "serde_json", @@ -3802,15 +3798,19 @@ dependencies = [ [[package]] name = "pyth-lazer-protocol" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "560a20d7f1040abad40245e524e657a2ec731e7e0560e25a1532301a1a04cb3f" +version = "0.5.1" dependencies = [ + "alloy-primitives", "anyhow", "base64 0.22.1", + "bincode", + "bs58 0.5.1", "byteorder", "derive_more", + "ed25519-dalek 2.1.1", + "hex", "itertools 0.13.0", + "libsecp256k1 0.7.1", "rust_decimal", "serde", "serde_json", @@ -3824,7 +3824,7 @@ dependencies = [ "bytemuck", "byteorder", "hex", - "pyth-lazer-protocol 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pyth-lazer-protocol 0.5.0", "solana-program-test", "solana-sdk", "thiserror 2.0.3", diff --git a/lazer/sdk/js/examples/index.ts b/lazer/sdk/js/examples/index.ts index 6b00c36ccb..3c3ea22657 100644 --- a/lazer/sdk/js/examples/index.ts +++ b/lazer/sdk/js/examples/index.ts @@ -62,7 +62,7 @@ await client.subscribe({ type: "subscribe", subscriptionId: 2, priceFeedIds: [1, 2, 3, 4, 5], - properties: ["price", "exponent", "publisherCount"], + properties: ["price", "exponent", "publisherCount", "confidence"], chains: ["evm"], deliveryFormat: "json", channel: "fixed_rate@200ms", diff --git a/lazer/sdk/js/package.json b/lazer/sdk/js/package.json index a55ab34d18..37bd04d0e4 100644 --- a/lazer/sdk/js/package.json +++ b/lazer/sdk/js/package.json @@ -1,6 +1,6 @@ { "name": "@pythnetwork/pyth-lazer-sdk", - "version": "0.3.2", + "version": "0.3.3", "description": "Pyth Lazer SDK", "publishConfig": { "access": "public" diff --git a/lazer/sdk/js/src/protocol.ts b/lazer/sdk/js/src/protocol.ts index 3f0b699302..8ca021232f 100644 --- a/lazer/sdk/js/src/protocol.ts +++ b/lazer/sdk/js/src/protocol.ts @@ -6,7 +6,8 @@ export type PriceFeedProperty = | "bestBidPrice" | "bestAskPrice" | "exponent" - | "publisherCount"; + | "publisherCount" + | "confidence"; export type Channel = "real_time" | "fixed_rate@50ms" | "fixed_rate@200ms"; export type Request = @@ -33,6 +34,7 @@ export type ParsedFeedPayload = { bestAskPrice?: string | undefined; publisherCount?: number | undefined; exponent?: number | undefined; + confidence?: string | undefined; }; export type ParsedPayload = { diff --git a/lazer/sdk/rust/protocol/Cargo.toml b/lazer/sdk/rust/protocol/Cargo.toml index af367147a9..dc55cbbb91 100644 --- a/lazer/sdk/rust/protocol/Cargo.toml +++ b/lazer/sdk/rust/protocol/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyth-lazer-protocol" -version = "0.5.0" +version = "0.5.1" edition = "2021" description = "Pyth Lazer SDK - protocol types." license = "Apache-2.0" diff --git a/lazer/sdk/rust/protocol/src/payload.rs b/lazer/sdk/rust/protocol/src/payload.rs index 24c100181f..46592e409c 100644 --- a/lazer/sdk/rust/protocol/src/payload.rs +++ b/lazer/sdk/rust/protocol/src/payload.rs @@ -35,6 +35,7 @@ pub enum PayloadPropertyValue { BestAskPrice(Option), PublisherCount(Option), Exponent(i16), + Confidence(Option), } #[derive(Debug, Clone, Default, Serialize, Deserialize)] @@ -78,6 +79,9 @@ impl PayloadData { PriceFeedProperty::Exponent => { PayloadPropertyValue::Exponent(*exponent) } + PriceFeedProperty::Confidence => { + PayloadPropertyValue::Confidence(feed.confidence) + } }) .collect(), }) @@ -115,6 +119,10 @@ impl PayloadData { writer.write_u8(PriceFeedProperty::Exponent as u8)?; writer.write_i16::(*exponent)?; } + PayloadPropertyValue::Confidence(confidence) => { + writer.write_u8(PriceFeedProperty::Confidence as u8)?; + write_option_price::(&mut writer, *confidence)?; + } } } } @@ -157,6 +165,8 @@ impl PayloadData { PayloadPropertyValue::PublisherCount(read_option_u16::(&mut reader)?) } else if property == PriceFeedProperty::Exponent as u8 { PayloadPropertyValue::Exponent(reader.read_i16::()?) + } else if property == PriceFeedProperty::Confidence as u8 { + PayloadPropertyValue::Confidence(read_option_price::(&mut reader)?) } else { bail!("unknown property"); }; diff --git a/lazer/sdk/rust/protocol/src/router.rs b/lazer/sdk/rust/protocol/src/router.rs index f3da3443a0..972e59c503 100644 --- a/lazer/sdk/rust/protocol/src/router.rs +++ b/lazer/sdk/rust/protocol/src/router.rs @@ -141,6 +141,7 @@ pub enum PriceFeedProperty { BestAskPrice, PublisherCount, Exponent, + Confidence, // More fields may be added later. } @@ -409,6 +410,9 @@ pub struct ParsedFeedPayload { #[serde(skip_serializing_if = "Option::is_none")] #[serde(default)] pub exponent: Option, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] + pub confidence: Option, // More fields may be added later. } @@ -426,6 +430,7 @@ impl ParsedFeedPayload { best_ask_price: None, publisher_count: None, exponent: None, + confidence: None, }; for &property in properties { match property { @@ -444,6 +449,9 @@ impl ParsedFeedPayload { PriceFeedProperty::Exponent => { output.exponent = exponent; } + PriceFeedProperty::Confidence => { + output.confidence = data.confidence; + } } } output @@ -461,6 +469,7 @@ impl ParsedFeedPayload { best_ask_price: data.best_ask_price, publisher_count: data.publisher_count, exponent, + confidence: data.confidence, } } }