Skip to content

Commit 2cd32ee

Browse files
feat: update lazer publisher example (#53)
1 parent 9ac35e4 commit 2cd32ee

File tree

3 files changed

+38
-17
lines changed

3 files changed

+38
-17
lines changed

lazer/publisher/Cargo.lock

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

lazer/publisher/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
pyth-lazer-protocol = "0.1.0"
7+
pyth-lazer-protocol = "0.7.2"
88

99
tokio = { version = "1.40.0", features = ["full"] }
1010
anyhow = "1.0.89"

lazer/publisher/src/main.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use {
22
futures::{SinkExt, StreamExt},
33
pyth_lazer_protocol::{
4-
publisher::PriceFeedData,
4+
publisher::PriceFeedDataV2,
55
router::{Price, PriceFeedId, TimestampUs},
66
},
77
std::time::Duration,
@@ -37,22 +37,14 @@ async fn run() -> anyhow::Result<()> {
3737
i += 1;
3838
sleep(Duration::from_secs(1)).await;
3939
for feed_id in 1u32..=5 {
40-
let data = PriceFeedData {
40+
let data = PriceFeedDataV2 {
4141
price_feed_id: PriceFeedId(feed_id),
4242
source_timestamp_us: TimestampUs::now(),
4343
publisher_timestamp_us: TimestampUs::now(),
44-
price: Some(Price::from_integer(
45-
(feed_id * 10000 + i) as i64,
46-
Price::TMP_EXPONENT,
47-
)?),
48-
best_bid_price: Some(Price::from_integer(
49-
(feed_id * 10000 + i - 1) as i64,
50-
Price::TMP_EXPONENT,
51-
)?),
52-
best_ask_price: Some(Price::from_integer(
53-
(feed_id * 10000 + i + 1) as i64,
54-
Price::TMP_EXPONENT,
55-
)?),
44+
price: Some(Price::from_integer((feed_id * 10000 + i) as i64, 8)?),
45+
best_bid_price: Some(Price::from_integer((feed_id * 10000 + i - 1) as i64, 8)?),
46+
best_ask_price: Some(Price::from_integer((feed_id * 10000 + i + 1) as i64, 8)?),
47+
funding_rate: None,
5648
};
5749
let mut buf = Vec::new();
5850
bincode::serialize_into(&mut buf, &data)?;

0 commit comments

Comments
 (0)