Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ no-log-ix-name = []
idl-build = ["anchor-lang/idl-build"]

[dependencies]
pyth-lazer-protocol = { path = "../../../../sdk/rust/protocol", version = "0.20.0" }
pyth-lazer-protocol = { path = "../../../../sdk/rust/protocol", version = "0.21.0" }

anchor-lang = "0.31.1"
bytemuck = { version = "1.20.0", features = ["derive"] }
Expand Down
4 changes: 4 additions & 0 deletions lazer/publisher_sdk/proto/state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ message FeedAggregateData {
// [optional] Confidence interval for the `price` field. Can be absent if no data is available.
// Never present for funding rate feeds.
optional int64 confidence = 8;
// [required] Exponent applied to all price and rate values for this feed.
// Actual value is `mantissa * 10 ^ exponent`.
// Restricted to int16.
optional int32 exponent = 9;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it backward compatible?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to release this in 2 stages for backward compatibility.
first write this data to state, and then read it from state.
right @Riateche ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a field is backwards compatible.

No, 2 stages are not needed. I made it so that if there is no value in the snapshot, it will fill exponent from static data.

}

// An item of the state describing an asset.
Expand Down
4 changes: 2 additions & 2 deletions lazer/publisher_sdk/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "pyth-lazer-publisher-sdk"
version = "0.20.1"
version = "0.21.0"
edition = "2021"
description = "Pyth Lazer Publisher SDK types."
license = "Apache-2.0"
repository = "https://github.com/pyth-network/pyth-crosschain"

[dependencies]
pyth-lazer-protocol = { version = "0.20.1", path = "../../sdk/rust/protocol" }
pyth-lazer-protocol = { version = "0.21.0", path = "../../sdk/rust/protocol" }
anyhow = "1.0.98"
protobuf = "3.7.2"
serde_json = "1.0.140"
Expand Down
4 changes: 2 additions & 2 deletions lazer/sdk/rust/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ description = "A Rust client for Pyth Lazer"
license = "Apache-2.0"

[dependencies]
pyth-lazer-protocol = { path = "../protocol", version = "0.20.1" }
pyth-lazer-publisher-sdk = { path = "../../../publisher_sdk/rust", version = "0.20.1" }
pyth-lazer-protocol = { path = "../protocol", version = "0.21.0" }
pyth-lazer-publisher-sdk = { path = "../../../publisher_sdk/rust", version = "0.21.0" }

tokio = { version = "1", features = ["full"] }
tokio-stream = "0.1.17"
Expand Down
2 changes: 1 addition & 1 deletion lazer/sdk/rust/protocol/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyth-lazer-protocol"
version = "0.20.2"
version = "0.21.0"
edition = "2021"
description = "Pyth Lazer SDK - protocol types."
license = "Apache-2.0"
Expand Down
3 changes: 1 addition & 2 deletions lazer/sdk/rust/protocol/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ pub struct ParsedFeedPayload {
impl ParsedFeedPayload {
pub fn new(
price_feed_id: PriceFeedId,
exponent: Option<i16>,
data: &AggregatedPriceFeedData,
properties: &[PriceFeedProperty],
) -> Self {
Expand Down Expand Up @@ -465,7 +464,7 @@ impl ParsedFeedPayload {
output.publisher_count = Some(data.publisher_count);
}
PriceFeedProperty::Exponent => {
output.exponent = exponent;
output.exponent = Some(data.exponent);
}
PriceFeedProperty::Confidence => {
output.confidence = data.confidence;
Expand Down
7 changes: 4 additions & 3 deletions lazer/sdk/rust/protocol/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub struct AggregatedPriceFeedData {
pub best_bid_price: Option<Price>,
pub best_ask_price: Option<Price>,
pub publisher_count: u16,
pub exponent: i16,
pub confidence: Option<Price>,
pub funding_rate: Option<Rate>,
pub funding_timestamp: Option<TimestampUs>,
Expand All @@ -63,15 +64,15 @@ impl PayloadData {
pub fn new(
timestamp_us: TimestampUs,
channel_id: ChannelId,
feeds: &[(PriceFeedId, i16, AggregatedPriceFeedData)],
feeds: &[(PriceFeedId, AggregatedPriceFeedData)],
requested_properties: &[PriceFeedProperty],
) -> Self {
Self {
timestamp_us,
channel_id,
feeds: feeds
.iter()
.map(|(feed_id, exponent, feed)| PayloadFeedData {
.map(|(feed_id, feed)| PayloadFeedData {
feed_id: *feed_id,
properties: requested_properties
.iter()
Expand All @@ -87,7 +88,7 @@ impl PayloadData {
PayloadPropertyValue::PublisherCount(feed.publisher_count)
}
PriceFeedProperty::Exponent => {
PayloadPropertyValue::Exponent(*exponent)
PayloadPropertyValue::Exponent(feed.exponent)
}
PriceFeedProperty::Confidence => {
PayloadPropertyValue::Confidence(feed.confidence)
Expand Down