diff --git a/lazer/Cargo.lock b/lazer/Cargo.lock index cedf88bec3..286144e885 100644 --- a/lazer/Cargo.lock +++ b/lazer/Cargo.lock @@ -3190,7 +3190,7 @@ dependencies = [ [[package]] name = "pyth-lazer-protocol" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "bincode", diff --git a/lazer/sdk/rust/protocol/Cargo.toml b/lazer/sdk/rust/protocol/Cargo.toml index 39ba1ab369..9162df803e 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.2.1" +version = "0.2.2" edition = "2021" description = "Pyth Lazer SDK - protocol types." license = "Apache-2.0" diff --git a/lazer/sdk/rust/protocol/src/api.rs b/lazer/sdk/rust/protocol/src/api.rs new file mode 100644 index 0000000000..e29ad29fad --- /dev/null +++ b/lazer/sdk/rust/protocol/src/api.rs @@ -0,0 +1,22 @@ +use serde::{Deserialize, Serialize}; + +use crate::{payload::AggregatedPriceFeedData, router::PriceFeedId}; + +/// A request sent from the client to the server. +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(tag = "type")] +#[serde(rename_all = "camelCase")] +pub enum ApiRequest { + LatestPrice(LatestPriceRequest), +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct LatestPriceRequest { + pub price_feed_ids: Vec, +} +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct LatestPriceResponse { + pub price_feed_ids: Vec, +} diff --git a/lazer/sdk/rust/protocol/src/lib.rs b/lazer/sdk/rust/protocol/src/lib.rs index 2f2f1e9f19..356fe00a43 100644 --- a/lazer/sdk/rust/protocol/src/lib.rs +++ b/lazer/sdk/rust/protocol/src/lib.rs @@ -1,5 +1,6 @@ //! Protocol types. +pub mod api; pub mod message; pub mod payload; pub mod publisher; diff --git a/lazer/sdk/rust/protocol/src/payload.rs b/lazer/sdk/rust/protocol/src/payload.rs index 7e08cf465d..1e56bfede4 100644 --- a/lazer/sdk/rust/protocol/src/payload.rs +++ b/lazer/sdk/rust/protocol/src/payload.rs @@ -5,6 +5,7 @@ use { crate::router::{ChannelId, Price}, anyhow::bail, byteorder::{ByteOrder, ReadBytesExt, WriteBytesExt, BE, LE}, + serde::{Deserialize, Serialize}, std::{ io::{Cursor, Read, Write}, num::NonZeroI64, @@ -35,7 +36,7 @@ pub enum PayloadPropertyValue { PublisherCount(Option), } -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct AggregatedPriceFeedData { pub price: Option, pub best_bid_price: Option,