diff --git a/lazer/Cargo.lock b/lazer/Cargo.lock index 5e54c91b2e..3c31a2ef22 100644 --- a/lazer/Cargo.lock +++ b/lazer/Cargo.lock @@ -3783,7 +3783,7 @@ dependencies = [ [[package]] name = "pyth-lazer-protocol" -version = "0.6.2" +version = "0.7.0" dependencies = [ "alloy-primitives", "anyhow", diff --git a/lazer/contracts/solana/programs/pyth-lazer-solana-contract/Cargo.toml b/lazer/contracts/solana/programs/pyth-lazer-solana-contract/Cargo.toml index b825fdb290..449939c32f 100644 --- a/lazer/contracts/solana/programs/pyth-lazer-solana-contract/Cargo.toml +++ b/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.6.0" } +pyth-lazer-protocol = { path = "../../../../sdk/rust/protocol", version = "0.7.0" } anchor-lang = "0.30.1" bytemuck = "1.20.0" diff --git a/lazer/sdk/js/package.json b/lazer/sdk/js/package.json index e9b5a3de65..e84f0f2038 100644 --- a/lazer/sdk/js/package.json +++ b/lazer/sdk/js/package.json @@ -1,6 +1,6 @@ { "name": "@pythnetwork/pyth-lazer-sdk", - "version": "0.4.0", + "version": "0.5.0", "description": "Pyth Lazer SDK", "publishConfig": { "access": "public" diff --git a/lazer/sdk/js/src/protocol.ts b/lazer/sdk/js/src/protocol.ts index e698d7b88d..747a4cf3bf 100644 --- a/lazer/sdk/js/src/protocol.ts +++ b/lazer/sdk/js/src/protocol.ts @@ -20,6 +20,7 @@ export type Request = deliveryFormat?: DeliveryFormat; jsonBinaryEncoding?: JsonBinaryEncoding; parsed?: boolean; + ignoreInvalidFeedIds?: boolean; channel: Channel; } | { @@ -47,6 +48,12 @@ export type JsonBinaryData = { data: string; }; +export type InvalidFeedSubscriptionDetails = { + unknownIds: number[]; + unsupportedChannels: number[]; + unstable: number[]; +}; + export type Response = | { type: "error"; @@ -56,6 +63,12 @@ export type Response = type: "subscribed"; subscriptionId: number; } + | { + type: "subscribedWithInvalidFeedIdsIgnored"; + subscriptionId: number; + subscribedFeedIds: number[]; + ignoredInvalidFeedIds: InvalidFeedSubscriptionDetails; + } | { type: "unsubscribed"; subscriptionId: number; diff --git a/lazer/sdk/rust/client/Cargo.toml b/lazer/sdk/rust/client/Cargo.toml index a472028710..747af09517 100644 --- a/lazer/sdk/rust/client/Cargo.toml +++ b/lazer/sdk/rust/client/Cargo.toml @@ -6,7 +6,7 @@ description = "A Rust client for Pyth Lazer" license = "Apache-2.0" [dependencies] -pyth-lazer-protocol = { path = "../protocol", version = "0.6.0" } +pyth-lazer-protocol = { path = "../protocol", version = "0.7.0" } tokio = { version = "1", features = ["full"] } tokio-tungstenite = { version = "0.20", features = ["native-tls"] } futures-util = "0.3" diff --git a/lazer/sdk/rust/client/examples/subscribe_price_feeds.rs b/lazer/sdk/rust/client/examples/subscribe_price_feeds.rs index 4975b88191..d236aa4ba7 100644 --- a/lazer/sdk/rust/client/examples/subscribe_price_feeds.rs +++ b/lazer/sdk/rust/client/examples/subscribe_price_feeds.rs @@ -47,6 +47,7 @@ async fn main() -> anyhow::Result<()> { channel: Channel::FixedRate( FixedRate::from_ms(200).expect("unsupported update rate"), ), + ignore_invalid_feed_ids: false, }) .expect("invalid subscription params"), }, @@ -68,6 +69,7 @@ async fn main() -> anyhow::Result<()> { channel: Channel::FixedRate( FixedRate::from_ms(50).expect("unsupported update rate"), ), + ignore_invalid_feed_ids: false, }) .expect("invalid subscription params"), }, diff --git a/lazer/sdk/rust/protocol/Cargo.toml b/lazer/sdk/rust/protocol/Cargo.toml index e77407373d..975f44bbb9 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.6.2" +version = "0.7.0" edition = "2021" description = "Pyth Lazer SDK - protocol types." license = "Apache-2.0" diff --git a/lazer/sdk/rust/protocol/src/lib.rs b/lazer/sdk/rust/protocol/src/lib.rs index 351f16125a..d10bedeebc 100644 --- a/lazer/sdk/rust/protocol/src/lib.rs +++ b/lazer/sdk/rust/protocol/src/lib.rs @@ -9,6 +9,7 @@ pub mod router; mod serde_price_as_i64; mod serde_str; pub mod subscription; +pub mod symbol_state; #[test] fn magics_in_big_endian() { diff --git a/lazer/sdk/rust/protocol/src/router.rs b/lazer/sdk/rust/protocol/src/router.rs index 0985ebda4c..ddff77ed7b 100644 --- a/lazer/sdk/rust/protocol/src/router.rs +++ b/lazer/sdk/rust/protocol/src/router.rs @@ -358,6 +358,8 @@ pub struct SubscriptionParamsRepr { #[serde(default = "default_parsed")] pub parsed: bool, pub channel: Channel, + #[serde(default)] + pub ignore_invalid_feed_ids: bool, } #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)] diff --git a/lazer/sdk/rust/protocol/src/subscription.rs b/lazer/sdk/rust/protocol/src/subscription.rs index f702d5932c..3d5b2b8611 100644 --- a/lazer/sdk/rust/protocol/src/subscription.rs +++ b/lazer/sdk/rust/protocol/src/subscription.rs @@ -2,7 +2,7 @@ //! used across publishers, agents and routers. use { - crate::router::{JsonUpdate, SubscriptionParams}, + crate::router::{JsonUpdate, PriceFeedId, SubscriptionParams}, derive_more::From, serde::{Deserialize, Serialize}, }; @@ -40,6 +40,7 @@ pub struct UnsubscribeRequest { pub enum Response { Error(ErrorResponse), Subscribed(SubscribedResponse), + SubscribedWithInvalidFeedIdsIgnored(SubscribedWithInvalidFeedIdsIgnoredResponse), Unsubscribed(UnsubscribedResponse), SubscriptionError(SubscriptionErrorResponse), StreamUpdated(StreamUpdatedResponse), @@ -52,6 +53,22 @@ pub struct SubscribedResponse { pub subscription_id: SubscriptionId, } +#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct InvalidFeedSubscriptionDetails { + pub unknown_ids: Vec, + pub unsupported_channels: Vec, + pub unstable: Vec, +} + +#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct SubscribedWithInvalidFeedIdsIgnoredResponse { + pub subscription_id: SubscriptionId, + pub subscribed_feed_ids: Vec, + pub ignored_invalid_feed_ids: InvalidFeedSubscriptionDetails, +} + #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct UnsubscribedResponse { diff --git a/lazer/sdk/rust/protocol/src/symbol_state.rs b/lazer/sdk/rust/protocol/src/symbol_state.rs new file mode 100644 index 0000000000..fb0a763f8a --- /dev/null +++ b/lazer/sdk/rust/protocol/src/symbol_state.rs @@ -0,0 +1,20 @@ +use { + serde::{Deserialize, Serialize}, + std::fmt::Display, +}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum SymbolState { + Stable, + ComingSoon, +} + +impl Display for SymbolState { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SymbolState::Stable => write!(f, "stable"), + SymbolState::ComingSoon => write!(f, "coming_soon"), + } + } +}