Skip to content

Commit f3f6da5

Browse files
authored
refactor(lazer): add exponent to AggregatedPriceFeedData (#3193)
1 parent 8cc8430 commit f3f6da5

File tree

8 files changed

+20
-16
lines changed

8 files changed

+20
-16
lines changed

Cargo.lock

Lines changed: 5 additions & 5 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.20.0" }
22+
pyth-lazer-protocol = { path = "../../../../sdk/rust/protocol", version = "0.21.0" }
2323

2424
anchor-lang = "0.31.1"
2525
bytemuck = { version = "1.20.0", features = ["derive"] }

lazer/publisher_sdk/proto/state.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ message FeedAggregateData {
195195
// [optional] Confidence interval for the `price` field. Can be absent if no data is available.
196196
// Never present for funding rate feeds.
197197
optional int64 confidence = 8;
198+
// [required] Exponent applied to all price and rate values for this feed.
199+
// Actual value is `mantissa * 10 ^ exponent`.
200+
// Restricted to int16.
201+
optional int32 exponent = 9;
198202
}
199203

200204
// An item of the state describing an asset.

lazer/publisher_sdk/rust/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
22
name = "pyth-lazer-publisher-sdk"
3-
version = "0.20.1"
3+
version = "0.21.0"
44
edition = "2021"
55
description = "Pyth Lazer Publisher SDK types."
66
license = "Apache-2.0"
77
repository = "https://github.com/pyth-network/pyth-crosschain"
88

99
[dependencies]
10-
pyth-lazer-protocol = { version = "0.20.1", path = "../../sdk/rust/protocol" }
10+
pyth-lazer-protocol = { version = "0.21.0", path = "../../sdk/rust/protocol" }
1111
anyhow = "1.0.98"
1212
protobuf = "3.7.2"
1313
serde_json = "1.0.140"

lazer/sdk/rust/client/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ description = "A Rust client for Pyth Lazer"
66
license = "Apache-2.0"
77

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

1212
tokio = { version = "1", features = ["full"] }
1313
tokio-stream = "0.1.17"

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

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,6 @@ pub struct ParsedFeedPayload {
434434
impl ParsedFeedPayload {
435435
pub fn new(
436436
price_feed_id: PriceFeedId,
437-
exponent: Option<i16>,
438437
data: &AggregatedPriceFeedData,
439438
properties: &[PriceFeedProperty],
440439
) -> Self {
@@ -465,7 +464,7 @@ impl ParsedFeedPayload {
465464
output.publisher_count = Some(data.publisher_count);
466465
}
467466
PriceFeedProperty::Exponent => {
468-
output.exponent = exponent;
467+
output.exponent = Some(data.exponent);
469468
}
470469
PriceFeedProperty::Confidence => {
471470
output.confidence = data.confidence;

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub struct AggregatedPriceFeedData {
4949
pub best_bid_price: Option<Price>,
5050
pub best_ask_price: Option<Price>,
5151
pub publisher_count: u16,
52+
pub exponent: i16,
5253
pub confidence: Option<Price>,
5354
pub funding_rate: Option<Rate>,
5455
pub funding_timestamp: Option<TimestampUs>,
@@ -63,15 +64,15 @@ impl PayloadData {
6364
pub fn new(
6465
timestamp_us: TimestampUs,
6566
channel_id: ChannelId,
66-
feeds: &[(PriceFeedId, i16, AggregatedPriceFeedData)],
67+
feeds: &[(PriceFeedId, AggregatedPriceFeedData)],
6768
requested_properties: &[PriceFeedProperty],
6869
) -> Self {
6970
Self {
7071
timestamp_us,
7172
channel_id,
7273
feeds: feeds
7374
.iter()
74-
.map(|(feed_id, exponent, feed)| PayloadFeedData {
75+
.map(|(feed_id, feed)| PayloadFeedData {
7576
feed_id: *feed_id,
7677
properties: requested_properties
7778
.iter()
@@ -87,7 +88,7 @@ impl PayloadData {
8788
PayloadPropertyValue::PublisherCount(feed.publisher_count)
8889
}
8990
PriceFeedProperty::Exponent => {
90-
PayloadPropertyValue::Exponent(*exponent)
91+
PayloadPropertyValue::Exponent(feed.exponent)
9192
}
9293
PriceFeedProperty::Confidence => {
9394
PayloadPropertyValue::Confidence(feed.confidence)

0 commit comments

Comments
 (0)