Skip to content

Commit 5aababc

Browse files
feat(lazer-sdk): add conf (#2403)
* feat(pyth-lazer-protocol): add confidence * update ts sdk * increase package versions
1 parent 1d8f91e commit 5aababc

File tree

7 files changed

+36
-15
lines changed

7 files changed

+36
-15
lines changed

lazer/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/sdk/js/examples/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ await client.subscribe({
6262
type: "subscribe",
6363
subscriptionId: 2,
6464
priceFeedIds: [1, 2, 3, 4, 5],
65-
properties: ["price", "exponent", "publisherCount"],
65+
properties: ["price", "exponent", "publisherCount", "confidence"],
6666
chains: ["evm"],
6767
deliveryFormat: "json",
6868
channel: "fixed_rate@200ms",

lazer/sdk/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/pyth-lazer-sdk",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"description": "Pyth Lazer SDK",
55
"publishConfig": {
66
"access": "public"

lazer/sdk/js/src/protocol.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export type PriceFeedProperty =
66
| "bestBidPrice"
77
| "bestAskPrice"
88
| "exponent"
9-
| "publisherCount";
9+
| "publisherCount"
10+
| "confidence";
1011
export type Channel = "real_time" | "fixed_rate@50ms" | "fixed_rate@200ms";
1112

1213
export type Request =
@@ -33,6 +34,7 @@ export type ParsedFeedPayload = {
3334
bestAskPrice?: string | undefined;
3435
publisherCount?: number | undefined;
3536
exponent?: number | undefined;
37+
confidence?: string | undefined;
3638
};
3739

3840
export type ParsedPayload = {

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.5.0"
3+
version = "0.5.1"
44
edition = "2021"
55
description = "Pyth Lazer SDK - protocol types."
66
license = "Apache-2.0"

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub enum PayloadPropertyValue {
3535
BestAskPrice(Option<Price>),
3636
PublisherCount(Option<u16>),
3737
Exponent(i16),
38+
Confidence(Option<Price>),
3839
}
3940

4041
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
@@ -78,6 +79,9 @@ impl PayloadData {
7879
PriceFeedProperty::Exponent => {
7980
PayloadPropertyValue::Exponent(*exponent)
8081
}
82+
PriceFeedProperty::Confidence => {
83+
PayloadPropertyValue::Confidence(feed.confidence)
84+
}
8185
})
8286
.collect(),
8387
})
@@ -115,6 +119,10 @@ impl PayloadData {
115119
writer.write_u8(PriceFeedProperty::Exponent as u8)?;
116120
writer.write_i16::<BO>(*exponent)?;
117121
}
122+
PayloadPropertyValue::Confidence(confidence) => {
123+
writer.write_u8(PriceFeedProperty::Confidence as u8)?;
124+
write_option_price::<BO>(&mut writer, *confidence)?;
125+
}
118126
}
119127
}
120128
}
@@ -157,6 +165,8 @@ impl PayloadData {
157165
PayloadPropertyValue::PublisherCount(read_option_u16::<BO>(&mut reader)?)
158166
} else if property == PriceFeedProperty::Exponent as u8 {
159167
PayloadPropertyValue::Exponent(reader.read_i16::<BO>()?)
168+
} else if property == PriceFeedProperty::Confidence as u8 {
169+
PayloadPropertyValue::Confidence(read_option_price::<BO>(&mut reader)?)
160170
} else {
161171
bail!("unknown property");
162172
};

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ pub enum PriceFeedProperty {
141141
BestAskPrice,
142142
PublisherCount,
143143
Exponent,
144+
Confidence,
144145
// More fields may be added later.
145146
}
146147

@@ -409,6 +410,9 @@ pub struct ParsedFeedPayload {
409410
#[serde(skip_serializing_if = "Option::is_none")]
410411
#[serde(default)]
411412
pub exponent: Option<i16>,
413+
#[serde(skip_serializing_if = "Option::is_none")]
414+
#[serde(default)]
415+
pub confidence: Option<Price>,
412416
// More fields may be added later.
413417
}
414418

@@ -426,6 +430,7 @@ impl ParsedFeedPayload {
426430
best_ask_price: None,
427431
publisher_count: None,
428432
exponent: None,
433+
confidence: None,
429434
};
430435
for &property in properties {
431436
match property {
@@ -444,6 +449,9 @@ impl ParsedFeedPayload {
444449
PriceFeedProperty::Exponent => {
445450
output.exponent = exponent;
446451
}
452+
PriceFeedProperty::Confidence => {
453+
output.confidence = data.confidence;
454+
}
447455
}
448456
}
449457
output
@@ -461,6 +469,7 @@ impl ParsedFeedPayload {
461469
best_ask_price: data.best_ask_price,
462470
publisher_count: data.publisher_count,
463471
exponent,
472+
confidence: data.confidence,
464473
}
465474
}
466475
}

0 commit comments

Comments
 (0)