Skip to content

Commit f8c719b

Browse files
committed
feat(lazer): add feed kind to protocol
1 parent 0129da1 commit f8c719b

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

lazer/publisher_sdk/rust/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::publisher_update::{FeedUpdate, FundingRateUpdate, PriceUpdate};
33
use crate::state::FeedState;
44
use pyth_lazer_protocol::jrpc::{FeedUpdateParams, UpdateParams};
55
use pyth_lazer_protocol::symbol_state::SymbolState;
6+
use pyth_lazer_protocol::FeedKind;
67

78
pub mod transaction_envelope {
89
pub use crate::protobuf::transaction_envelope::*;
@@ -87,3 +88,21 @@ impl From<SymbolState> for FeedState {
8788
}
8889
}
8990
}
91+
92+
impl From<FeedKind> for protobuf::state::FeedKind {
93+
fn from(value: FeedKind) -> Self {
94+
match value {
95+
FeedKind::Price => protobuf::state::FeedKind::PRICE,
96+
FeedKind::FundingRate => protobuf::state::FeedKind::FUNDING_RATE,
97+
}
98+
}
99+
}
100+
101+
impl From<protobuf::state::FeedKind> for FeedKind {
102+
fn from(value: protobuf::state::FeedKind) -> Self {
103+
match value {
104+
protobuf::state::FeedKind::PRICE => FeedKind::Price,
105+
protobuf::state::FeedKind::FUNDING_RATE => FeedKind::FundingRate,
106+
}
107+
}
108+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use {
2+
serde::{Deserialize, Serialize},
3+
std::fmt::Display,
4+
};
5+
6+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
7+
#[serde(rename_all = "camelCase")]
8+
pub enum FeedKind {
9+
Price,
10+
FundingRate,
11+
}
12+
13+
impl Display for FeedKind {
14+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15+
match self {
16+
FeedKind::Price => write!(f, "price"),
17+
FeedKind::FundingRate => write!(f, "fundingRate"),
18+
}
19+
}
20+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
pub mod api;
44
pub mod binary_update;
5+
mod feed_kind;
56
pub mod jrpc;
67
pub mod message;
78
pub mod payload;
@@ -13,6 +14,8 @@ pub mod subscription;
1314
pub mod symbol_state;
1415
pub mod time;
1516

17+
pub use crate::feed_kind::FeedKind;
18+
1619
#[test]
1720
fn magics_in_big_endian() {
1821
use crate::{

0 commit comments

Comments
 (0)