Skip to content

Commit 01880f7

Browse files
authored
feat(pyth-lazer) Create schema for lazer agent JRPC endpoint (#2836)
1 parent 4bdfb72 commit 01880f7

File tree

10 files changed

+498
-48
lines changed

10 files changed

+498
-48
lines changed

Cargo.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lazer/contracts/solana/Cargo.lock

Lines changed: 13 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lazer/contracts/solana/programs/pyth-lazer-solana-contract/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ no-log-ix-name = []
1919
idl-build = ["anchor-lang/idl-build"]
2020

2121
[dependencies]
22-
pyth-lazer-protocol = { path = "../../../../sdk/rust/protocol", version = "0.7.2" }
22+
pyth-lazer-protocol = { path = "../../../../sdk/rust/protocol", version = "0.8.0" }
2323

2424
anchor-lang = "0.30.1"
2525
bytemuck = "1.20.0"

lazer/publisher_sdk/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "Apache-2.0"
77
repository = "https://github.com/pyth-network/pyth-crosschain"
88

99
[dependencies]
10-
pyth-lazer-protocol = { version = "0.7.2", path = "../../sdk/rust/protocol" }
10+
pyth-lazer-protocol = { version = "0.8.0", path = "../../sdk/rust/protocol" }
1111
anyhow = "1.0.98"
1212
protobuf = "3.7.2"
1313
serde-value = "0.7.0"

lazer/publisher_sdk/rust/src/lib.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
use std::{collections::BTreeMap, time::Duration};
22

3+
use crate::publisher_update::feed_update::Update;
4+
use crate::publisher_update::{FeedUpdate, FundingRateUpdate, PriceUpdate};
35
use ::protobuf::MessageField;
46
use anyhow::{bail, ensure, Context};
57
use humantime::format_duration;
68
use protobuf::dynamic_value::{dynamic_value, DynamicValue};
9+
use pyth_lazer_protocol::jrpc::{FeedUpdateParams, UpdateParams};
710
use pyth_lazer_protocol::router::TimestampUs;
811

912
pub mod transaction_envelope {
@@ -164,3 +167,38 @@ impl TryFrom<DynamicValue> for serde_value::Value {
164167
}
165168
}
166169
}
170+
171+
impl From<FeedUpdateParams> for FeedUpdate {
172+
fn from(value: FeedUpdateParams) -> Self {
173+
FeedUpdate {
174+
feed_id: Some(value.feed_id.0),
175+
source_timestamp: value.source_timestamp.into(),
176+
update: Some(value.update.into()),
177+
special_fields: Default::default(),
178+
}
179+
}
180+
}
181+
182+
impl From<UpdateParams> for Update {
183+
fn from(value: UpdateParams) -> Self {
184+
match value {
185+
UpdateParams::PriceUpdate {
186+
price,
187+
best_bid_price,
188+
best_ask_price,
189+
} => Update::PriceUpdate(PriceUpdate {
190+
price: Some(price.0.into()),
191+
best_bid_price: best_bid_price.map(|p| p.0.into()),
192+
best_ask_price: best_ask_price.map(|p| p.0.into()),
193+
special_fields: Default::default(),
194+
}),
195+
UpdateParams::FundingRateUpdate { price, rate } => {
196+
Update::FundingRateUpdate(FundingRateUpdate {
197+
price: price.map(|p| p.0.into()),
198+
rate: Some(rate.0),
199+
special_fields: Default::default(),
200+
})
201+
}
202+
}
203+
}
204+
}

lazer/sdk/rust/client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description = "A Rust client for Pyth Lazer"
66
license = "Apache-2.0"
77

88
[dependencies]
9-
pyth-lazer-protocol = { path = "../protocol", version = "0.7.2" }
9+
pyth-lazer-protocol = { path = "../protocol", version = "0.8.0" }
1010
tokio = { version = "1", features = ["full"] }
1111
tokio-tungstenite = { version = "0.20", features = ["native-tls"] }
1212
futures-util = "0.3"

lazer/sdk/rust/protocol/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyth-lazer-protocol"
3-
version = "0.7.3"
3+
version = "0.8.0"
44
edition = "2021"
55
description = "Pyth Lazer SDK - protocol types."
66
license = "Apache-2.0"
@@ -14,8 +14,8 @@ serde_json = "1.0"
1414
derive_more = { version = "1.0.0", features = ["from"] }
1515
itertools = "0.13.0"
1616
rust_decimal = "1.36.0"
17-
base64 = "0.22.1"
1817
protobuf = "3.7.2"
18+
humantime-serde = "1.1.1"
1919

2020
[dev-dependencies]
2121
bincode = "1.3.3"

0 commit comments

Comments
 (0)