Skip to content

Commit 9b3c156

Browse files
authored
feat(lazer-protocol): Add latest price api interface (#2229)
* Add latest price api * Version bump
1 parent cbe35e9 commit 9b3c156

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

lazer/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lazer/sdk/rust/protocol/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyth-lazer-protocol"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
edition = "2021"
55
description = "Pyth Lazer SDK - protocol types."
66
license = "Apache-2.0"

lazer/sdk/rust/protocol/src/api.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
use crate::{payload::AggregatedPriceFeedData, router::PriceFeedId};
4+
5+
/// A request sent from the client to the server.
6+
#[derive(Debug, Clone, Serialize, Deserialize)]
7+
#[serde(tag = "type")]
8+
#[serde(rename_all = "camelCase")]
9+
pub enum ApiRequest {
10+
LatestPrice(LatestPriceRequest),
11+
}
12+
13+
#[derive(Debug, Clone, Serialize, Deserialize)]
14+
#[serde(rename_all = "camelCase")]
15+
pub struct LatestPriceRequest {
16+
pub price_feed_ids: Vec<PriceFeedId>,
17+
}
18+
#[derive(Debug, Clone, Serialize, Deserialize)]
19+
#[serde(rename_all = "camelCase")]
20+
pub struct LatestPriceResponse {
21+
pub price_feed_ids: Vec<AggregatedPriceFeedData>,
22+
}

lazer/sdk/rust/protocol/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Protocol types.
22
3+
pub mod api;
34
pub mod message;
45
pub mod payload;
56
pub mod publisher;

lazer/sdk/rust/protocol/src/payload.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use {
55
crate::router::{ChannelId, Price},
66
anyhow::bail,
77
byteorder::{ByteOrder, ReadBytesExt, WriteBytesExt, BE, LE},
8+
serde::{Deserialize, Serialize},
89
std::{
910
io::{Cursor, Read, Write},
1011
num::NonZeroI64,
@@ -35,7 +36,7 @@ pub enum PayloadPropertyValue {
3536
PublisherCount(Option<u16>),
3637
}
3738

38-
#[derive(Debug, Clone, Default)]
39+
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
3940
pub struct AggregatedPriceFeedData {
4041
pub price: Option<Price>,
4142
pub best_bid_price: Option<Price>,

0 commit comments

Comments
 (0)