From 4302a041e5ec8a404170bec3a4aad6d780c968e9 Mon Sep 17 00:00:00 2001 From: Bart Platak Date: Thu, 24 Jul 2025 15:29:48 +0100 Subject: [PATCH 01/11] feat(pyth-lazer) Add support for FundingRateInterval in updates --- Cargo.lock | 13 +++---- .../proto/publisher_update.proto | 9 +++++ lazer/publisher_sdk/rust/Cargo.toml | 7 +--- lazer/publisher_sdk/rust/src/lib.rs | 36 +++++++++++++++---- lazer/sdk/rust/protocol/Cargo.toml | 2 +- lazer/sdk/rust/protocol/src/jrpc.rs | 13 +++++-- lazer/sdk/rust/protocol/src/router.rs | 10 ++++++ 7 files changed, 65 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4b5784394d..3803f81bb8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5659,7 +5659,7 @@ dependencies = [ "futures-util", "hex", "libsecp256k1 0.7.2", - "pyth-lazer-protocol 0.9.1", + "pyth-lazer-protocol 0.9.2", "serde", "serde_json", "tokio", @@ -5687,7 +5687,7 @@ dependencies = [ [[package]] name = "pyth-lazer-protocol" -version = "0.9.1" +version = "0.9.2" dependencies = [ "alloy-primitives 0.8.25", "anyhow", @@ -5727,19 +5727,14 @@ dependencies = [ [[package]] name = "pyth-lazer-publisher-sdk" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", - "derive_more 2.0.1", "fs-err", - "hex", - "humantime", "protobuf", "protobuf-codegen", - "pyth-lazer-protocol 0.9.1", - "serde", + "pyth-lazer-protocol 0.9.2", "serde_json", - "tracing", ] [[package]] diff --git a/lazer/publisher_sdk/proto/publisher_update.proto b/lazer/publisher_sdk/proto/publisher_update.proto index 6bf249ce8d..d7df5a514c 100644 --- a/lazer/publisher_sdk/proto/publisher_update.proto +++ b/lazer/publisher_sdk/proto/publisher_update.proto @@ -54,9 +54,18 @@ message PriceUpdate { // feed update containing data relating to funding rate message FundingRateUpdate { + enum FundingRateInterval { + INTERVAL_1H = 0; + INTERVAL_4H = 1; + INTERVAL_8H = 2; + } + // [optional] price for which the funding rate applies to optional int64 price = 1; // [optional] perpetual future funding rate optional int64 rate = 2; + + // [optional] funding rate update + optional FundingRateInterval funding_rate_interval = 3; } diff --git a/lazer/publisher_sdk/rust/Cargo.toml b/lazer/publisher_sdk/rust/Cargo.toml index 2aad9db22c..49e8f0fa61 100644 --- a/lazer/publisher_sdk/rust/Cargo.toml +++ b/lazer/publisher_sdk/rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyth-lazer-publisher-sdk" -version = "0.2.0" +version = "0.3.0" edition = "2021" description = "Pyth Lazer Publisher SDK types." license = "Apache-2.0" @@ -10,12 +10,7 @@ repository = "https://github.com/pyth-network/pyth-crosschain" pyth-lazer-protocol = { version = "0.9.1", path = "../../sdk/rust/protocol" } anyhow = "1.0.98" protobuf = "3.7.2" -humantime = "2.2.0" -tracing = "0.1.41" -serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.140" -derive_more = { version = "2.0.1", features = ["from"] } -hex = "0.4.3" [build-dependencies] fs-err = "3.1.0" diff --git a/lazer/publisher_sdk/rust/src/lib.rs b/lazer/publisher_sdk/rust/src/lib.rs index 81ac139ed0..8054e87e3c 100644 --- a/lazer/publisher_sdk/rust/src/lib.rs +++ b/lazer/publisher_sdk/rust/src/lib.rs @@ -1,6 +1,7 @@ use crate::publisher_update::feed_update::Update; use crate::publisher_update::{FeedUpdate, FundingRateUpdate, PriceUpdate}; use crate::state::FeedState; +use ::protobuf::EnumOrUnknown; use pyth_lazer_protocol::jrpc::{FeedUpdateParams, UpdateParams}; use pyth_lazer_protocol::symbol_state::SymbolState; use pyth_lazer_protocol::FeedKind; @@ -60,12 +61,35 @@ impl From for Update { best_ask_price: best_ask_price.map(|p| p.0.into()), special_fields: Default::default(), }), - UpdateParams::FundingRateUpdate { price, rate } => { - Update::FundingRateUpdate(FundingRateUpdate { - price: price.map(|p| p.0.into()), - rate: Some(rate.0), - special_fields: Default::default(), - }) + UpdateParams::FundingRateUpdate { + price, + rate, + funding_rate_interval, + } => Update::FundingRateUpdate(FundingRateUpdate { + price: price.map(|p| p.0.into()), + rate: Some(rate.0), + funding_rate_interval: funding_rate_interval + .map(From::from) + .map(EnumOrUnknown::new), + special_fields: Default::default(), + }), + } + } +} + +impl From + for publisher_update::funding_rate_update::FundingRateInterval +{ + fn from(value: pyth_lazer_protocol::router::FundingRateInterval) -> Self { + match value { + pyth_lazer_protocol::router::FundingRateInterval::Interval1Hour => { + publisher_update::funding_rate_update::FundingRateInterval::INTERVAL_1H + } + pyth_lazer_protocol::router::FundingRateInterval::Interval4Hours => { + publisher_update::funding_rate_update::FundingRateInterval::INTERVAL_4H + } + pyth_lazer_protocol::router::FundingRateInterval::Interval8Hours => { + publisher_update::funding_rate_update::FundingRateInterval::INTERVAL_8H } } } diff --git a/lazer/sdk/rust/protocol/Cargo.toml b/lazer/sdk/rust/protocol/Cargo.toml index 537dfed2a5..9d9e212d47 100644 --- a/lazer/sdk/rust/protocol/Cargo.toml +++ b/lazer/sdk/rust/protocol/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyth-lazer-protocol" -version = "0.9.1" +version = "0.9.2" edition = "2021" description = "Pyth Lazer SDK - protocol types." license = "Apache-2.0" diff --git a/lazer/sdk/rust/protocol/src/jrpc.rs b/lazer/sdk/rust/protocol/src/jrpc.rs index 5dca3e6362..596c3885d1 100644 --- a/lazer/sdk/rust/protocol/src/jrpc.rs +++ b/lazer/sdk/rust/protocol/src/jrpc.rs @@ -1,4 +1,4 @@ -use crate::router::{Channel, Price, PriceFeedId, Rate}; +use crate::router::{Channel, FundingRateInterval, Price, PriceFeedId, Rate}; use crate::symbol_state::SymbolState; use crate::time::TimestampUs; use serde::{Deserialize, Serialize}; @@ -37,7 +37,11 @@ pub enum UpdateParams { best_ask_price: Option, }, #[serde(rename = "funding_rate")] - FundingRateUpdate { price: Option, rate: Rate }, + FundingRateUpdate { + price: Option, + rate: Rate, + funding_rate_interval: Option, + }, } #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] @@ -226,7 +230,8 @@ mod tests { "update": { "type": "funding_rate", "price": 1234567890, - "rate": 1234567891 + "rate": 1234567891, + "funding_rate_interval": "8h" } }, "id": 1 @@ -241,6 +246,7 @@ mod tests { update: UpdateParams::FundingRateUpdate { price: Some(Price::from_integer(1234567890, 0).unwrap()), rate: Rate::from_integer(1234567891, 0).unwrap(), + funding_rate_interval: Some(FundingRateInterval::Interval8Hours), }, }), id: 1, @@ -278,6 +284,7 @@ mod tests { update: UpdateParams::FundingRateUpdate { price: None, rate: Rate::from_integer(1234567891, 0).unwrap(), + funding_rate_interval: None, }, }), id: 1, diff --git a/lazer/sdk/rust/protocol/src/router.rs b/lazer/sdk/rust/protocol/src/router.rs index dd0decb0a7..f54bebd05e 100644 --- a/lazer/sdk/rust/protocol/src/router.rs +++ b/lazer/sdk/rust/protocol/src/router.rs @@ -261,6 +261,16 @@ impl Channel { } } +#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] +pub enum FundingRateInterval { + #[serde(rename = "1h")] + Interval1Hour, + #[serde(rename = "4h")] + Interval4Hours, + #[serde(rename = "8h")] + Interval8Hours, +} + #[test] fn id_supports_all_fixed_rates() { for rate in FixedRate::ALL { From b6b8e24d0749e4873258b11abc9743d139ad30a4 Mon Sep 17 00:00:00 2001 From: Bart Platak Date: Thu, 24 Jul 2025 22:26:27 +0100 Subject: [PATCH 02/11] add untagged to jrpc response serde to simplify parsing --- lazer/sdk/rust/protocol/src/jrpc.rs | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/lazer/sdk/rust/protocol/src/jrpc.rs b/lazer/sdk/rust/protocol/src/jrpc.rs index 596c3885d1..f764441cfa 100644 --- a/lazer/sdk/rust/protocol/src/jrpc.rs +++ b/lazer/sdk/rust/protocol/src/jrpc.rs @@ -63,6 +63,7 @@ pub enum JsonRpcVersion { } #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] +#[serde(untagged)] pub enum JrpcResponse { Success(JrpcSuccessResponse), Error(JrpcErrorResponse), @@ -403,4 +404,54 @@ mod tests { } ); } + + #[test] + pub fn test_parse_response() { + let success_response = serde_json::from_str::>( + r#" + { + "jsonrpc": "2.0", + "id": 2, + "result": "success" + } + "#, + ) + .unwrap(); + + assert_eq!( + success_response, + JrpcResponse::Success(JrpcSuccessResponse:: { + jsonrpc: JsonRpcVersion::V2, + result: "success".to_string(), + id: 2, + }) + ); + + let error_response = serde_json::from_str::>( + r#" + { + "jsonrpc": "2.0", + "id": 3, + "error": { + "code": -32603, + "message": "Internal error" + } + } + "#, + ) + .unwrap(); + + assert_eq!( + error_response, + JrpcResponse::Error(JrpcErrorResponse { + jsonrpc: JsonRpcVersion::V2, + error: JrpcErrorObject { + code: -32603, + message: "Internal error".to_string(), + data: None, + }, + id: Some(3), + }) + ); + } } From 531de8144e2b36b6d777de895a9b9442204838cb Mon Sep 17 00:00:00 2001 From: Bart Platak Date: Mon, 28 Jul 2025 16:22:27 +0100 Subject: [PATCH 03/11] review improvements --- .../proto/publisher_update.proto | 11 ++---- lazer/publisher_sdk/rust/src/lib.rs | 38 +++++-------------- lazer/sdk/rust/protocol/src/jrpc.rs | 11 ++++-- lazer/sdk/rust/protocol/src/router.rs | 10 ----- 4 files changed, 19 insertions(+), 51 deletions(-) diff --git a/lazer/publisher_sdk/proto/publisher_update.proto b/lazer/publisher_sdk/proto/publisher_update.proto index d7df5a514c..8c752c17aa 100644 --- a/lazer/publisher_sdk/proto/publisher_update.proto +++ b/lazer/publisher_sdk/proto/publisher_update.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package pyth_lazer; +import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; // if any fields marked as [required] are missing, feed/publisher update will be rejected @@ -54,18 +55,12 @@ message PriceUpdate { // feed update containing data relating to funding rate message FundingRateUpdate { - enum FundingRateInterval { - INTERVAL_1H = 0; - INTERVAL_4H = 1; - INTERVAL_8H = 2; - } - // [optional] price for which the funding rate applies to optional int64 price = 1; // [optional] perpetual future funding rate optional int64 rate = 2; - // [optional] funding rate update - optional FundingRateInterval funding_rate_interval = 3; + // [optional] funding rate update interval + optional google.protobuf.Duration funding_rate_interval = 3; } diff --git a/lazer/publisher_sdk/rust/src/lib.rs b/lazer/publisher_sdk/rust/src/lib.rs index 8054e87e3c..6fc6e6f625 100644 --- a/lazer/publisher_sdk/rust/src/lib.rs +++ b/lazer/publisher_sdk/rust/src/lib.rs @@ -1,7 +1,7 @@ +use ::protobuf::MessageField; use crate::publisher_update::feed_update::Update; use crate::publisher_update::{FeedUpdate, FundingRateUpdate, PriceUpdate}; use crate::state::FeedState; -use ::protobuf::EnumOrUnknown; use pyth_lazer_protocol::jrpc::{FeedUpdateParams, UpdateParams}; use pyth_lazer_protocol::symbol_state::SymbolState; use pyth_lazer_protocol::FeedKind; @@ -68,33 +68,13 @@ impl From for Update { } => Update::FundingRateUpdate(FundingRateUpdate { price: price.map(|p| p.0.into()), rate: Some(rate.0), - funding_rate_interval: funding_rate_interval - .map(From::from) - .map(EnumOrUnknown::new), + funding_rate_interval: MessageField::from_option(funding_rate_interval.map(|i| i.into())), special_fields: Default::default(), }), } } } -impl From - for publisher_update::funding_rate_update::FundingRateInterval -{ - fn from(value: pyth_lazer_protocol::router::FundingRateInterval) -> Self { - match value { - pyth_lazer_protocol::router::FundingRateInterval::Interval1Hour => { - publisher_update::funding_rate_update::FundingRateInterval::INTERVAL_1H - } - pyth_lazer_protocol::router::FundingRateInterval::Interval4Hours => { - publisher_update::funding_rate_update::FundingRateInterval::INTERVAL_4H - } - pyth_lazer_protocol::router::FundingRateInterval::Interval8Hours => { - publisher_update::funding_rate_update::FundingRateInterval::INTERVAL_8H - } - } - } -} - impl From for SymbolState { fn from(value: FeedState) -> Self { match value { @@ -115,20 +95,20 @@ impl From for FeedState { } } -impl From for protobuf::state::FeedKind { +impl From for state::FeedKind { fn from(value: FeedKind) -> Self { match value { - FeedKind::Price => protobuf::state::FeedKind::PRICE, - FeedKind::FundingRate => protobuf::state::FeedKind::FUNDING_RATE, + FeedKind::Price => state::FeedKind::PRICE, + FeedKind::FundingRate => state::FeedKind::FUNDING_RATE, } } } -impl From for FeedKind { - fn from(value: protobuf::state::FeedKind) -> Self { +impl From for FeedKind { + fn from(value: state::FeedKind) -> Self { match value { - protobuf::state::FeedKind::PRICE => FeedKind::Price, - protobuf::state::FeedKind::FUNDING_RATE => FeedKind::FundingRate, + state::FeedKind::PRICE => FeedKind::Price, + state::FeedKind::FUNDING_RATE => FeedKind::FundingRate, } } } diff --git a/lazer/sdk/rust/protocol/src/jrpc.rs b/lazer/sdk/rust/protocol/src/jrpc.rs index f764441cfa..f09e7324d6 100644 --- a/lazer/sdk/rust/protocol/src/jrpc.rs +++ b/lazer/sdk/rust/protocol/src/jrpc.rs @@ -1,4 +1,4 @@ -use crate::router::{Channel, FundingRateInterval, Price, PriceFeedId, Rate}; +use crate::router::{Channel, Price, PriceFeedId, Rate}; use crate::symbol_state::SymbolState; use crate::time::TimestampUs; use serde::{Deserialize, Serialize}; @@ -40,7 +40,7 @@ pub enum UpdateParams { FundingRateUpdate { price: Option, rate: Rate, - funding_rate_interval: Option, + funding_rate_interval: Option, }, } @@ -232,7 +232,10 @@ mod tests { "type": "funding_rate", "price": 1234567890, "rate": 1234567891, - "funding_rate_interval": "8h" + "funding_rate_interval": { + "secs": 28800, + "nanos": 0 + } } }, "id": 1 @@ -247,7 +250,7 @@ mod tests { update: UpdateParams::FundingRateUpdate { price: Some(Price::from_integer(1234567890, 0).unwrap()), rate: Rate::from_integer(1234567891, 0).unwrap(), - funding_rate_interval: Some(FundingRateInterval::Interval8Hours), + funding_rate_interval: Some(Duration::from_secs(28800)), }, }), id: 1, diff --git a/lazer/sdk/rust/protocol/src/router.rs b/lazer/sdk/rust/protocol/src/router.rs index f54bebd05e..dd0decb0a7 100644 --- a/lazer/sdk/rust/protocol/src/router.rs +++ b/lazer/sdk/rust/protocol/src/router.rs @@ -261,16 +261,6 @@ impl Channel { } } -#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] -pub enum FundingRateInterval { - #[serde(rename = "1h")] - Interval1Hour, - #[serde(rename = "4h")] - Interval4Hours, - #[serde(rename = "8h")] - Interval8Hours, -} - #[test] fn id_supports_all_fixed_rates() { for rate in FixedRate::ALL { From a307a2fc02090f84c8dc459c0839566a541f22b0 Mon Sep 17 00:00:00 2001 From: Bart Platak Date: Mon, 28 Jul 2025 16:44:35 +0100 Subject: [PATCH 04/11] linter fixes --- lazer/sdk/rust/protocol/src/jrpc.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lazer/sdk/rust/protocol/src/jrpc.rs b/lazer/sdk/rust/protocol/src/jrpc.rs index f09e7324d6..a37d70bc1b 100644 --- a/lazer/sdk/rust/protocol/src/jrpc.rs +++ b/lazer/sdk/rust/protocol/src/jrpc.rs @@ -419,7 +419,7 @@ mod tests { } "#, ) - .unwrap(); + .unwrap(); assert_eq!( success_response, @@ -442,7 +442,7 @@ mod tests { } "#, ) - .unwrap(); + .unwrap(); assert_eq!( error_response, From cde7a82b2c72d2d73e715c7986ecd0f33379129b Mon Sep 17 00:00:00 2001 From: Bart Platak Date: Mon, 28 Jul 2025 16:44:40 +0100 Subject: [PATCH 05/11] linter fixes --- lazer/publisher_sdk/rust/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lazer/publisher_sdk/rust/src/lib.rs b/lazer/publisher_sdk/rust/src/lib.rs index 6fc6e6f625..ae98a79c39 100644 --- a/lazer/publisher_sdk/rust/src/lib.rs +++ b/lazer/publisher_sdk/rust/src/lib.rs @@ -1,7 +1,7 @@ -use ::protobuf::MessageField; use crate::publisher_update::feed_update::Update; use crate::publisher_update::{FeedUpdate, FundingRateUpdate, PriceUpdate}; use crate::state::FeedState; +use ::protobuf::MessageField; use pyth_lazer_protocol::jrpc::{FeedUpdateParams, UpdateParams}; use pyth_lazer_protocol::symbol_state::SymbolState; use pyth_lazer_protocol::FeedKind; @@ -68,7 +68,9 @@ impl From for Update { } => Update::FundingRateUpdate(FundingRateUpdate { price: price.map(|p| p.0.into()), rate: Some(rate.0), - funding_rate_interval: MessageField::from_option(funding_rate_interval.map(|i| i.into())), + funding_rate_interval: MessageField::from_option( + funding_rate_interval.map(|i| i.into()), + ), special_fields: Default::default(), }), } From 849738f752cfebffc398ffe531e2e80588a0b49a Mon Sep 17 00:00:00 2001 From: Bart Platak Date: Mon, 28 Jul 2025 21:42:15 +0100 Subject: [PATCH 06/11] add interval to FeedUpdate proto --- lazer/publisher_sdk/proto/state.proto | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lazer/publisher_sdk/proto/state.proto b/lazer/publisher_sdk/proto/state.proto index b13569e211..2cd512c749 100644 --- a/lazer/publisher_sdk/proto/state.proto +++ b/lazer/publisher_sdk/proto/state.proto @@ -152,4 +152,6 @@ message FeedData { optional int64 best_ask_price = 5; // [optional] Funding rate. Can be absent if no data is available. Can only be present for funding rate feeds. optional int64 funding_rate = 6; + // [optional] Funding rate interval. Can be absent if no data is available. Can only be present for funding rate feeds. + optional google.protobuf.Duration funding_rate_interval = 7; } From 9dedddf4a378b64275f3f97ee5e426517f28ee9c Mon Sep 17 00:00:00 2001 From: Bart Platak Date: Mon, 28 Jul 2025 22:52:41 +0100 Subject: [PATCH 07/11] add the interval to jrpc proto --- Cargo.lock | 6 +++--- lazer/sdk/rust/protocol/Cargo.toml | 2 +- lazer/sdk/rust/protocol/src/jrpc.rs | 11 +++++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f83ddcd94..92da28cdb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5666,7 +5666,7 @@ dependencies = [ "futures-util", "hex", "libsecp256k1 0.7.2", - "pyth-lazer-protocol 0.10.0", + "pyth-lazer-protocol 0.10.1", "serde", "serde_json", "tokio", @@ -5696,7 +5696,7 @@ dependencies = [ [[package]] name = "pyth-lazer-protocol" -version = "0.10.0" +version = "0.10.1" dependencies = [ "alloy-primitives 0.8.25", "anyhow", @@ -5742,7 +5742,7 @@ dependencies = [ "fs-err", "protobuf", "protobuf-codegen", - "pyth-lazer-protocol 0.10.0", + "pyth-lazer-protocol 0.10.1", "serde_json", ] diff --git a/lazer/sdk/rust/protocol/Cargo.toml b/lazer/sdk/rust/protocol/Cargo.toml index 2ba075e1a6..52cce03af0 100644 --- a/lazer/sdk/rust/protocol/Cargo.toml +++ b/lazer/sdk/rust/protocol/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyth-lazer-protocol" -version = "0.10.0" +version = "0.10.1" edition = "2021" description = "Pyth Lazer SDK - protocol types." license = "Apache-2.0" diff --git a/lazer/sdk/rust/protocol/src/jrpc.rs b/lazer/sdk/rust/protocol/src/jrpc.rs index ff01907535..28ac449e79 100644 --- a/lazer/sdk/rust/protocol/src/jrpc.rs +++ b/lazer/sdk/rust/protocol/src/jrpc.rs @@ -37,7 +37,11 @@ pub enum UpdateParams { best_ask_price: Option, }, #[serde(rename = "funding_rate")] - FundingRateUpdate { price: Option, rate: Rate }, + FundingRateUpdate { + price: Option, + rate: Rate, + funding_rate_interval: Option, + }, } #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] @@ -273,7 +277,8 @@ mod tests { "update": { "type": "funding_rate", "price": 1234567890, - "rate": 1234567891 + "rate": 1234567891, + "funding_rate_interval": 28800 } }, "id": 1 @@ -288,6 +293,7 @@ mod tests { update: UpdateParams::FundingRateUpdate { price: Some(Price::from_integer(1234567890, 0).unwrap()), rate: Rate::from_integer(1234567891, 0).unwrap(), + funding_rate_interval: Duration::from_secs(28800).into(), }, }), id: Some(1), @@ -325,6 +331,7 @@ mod tests { update: UpdateParams::FundingRateUpdate { price: None, rate: Rate::from_integer(1234567891, 0).unwrap(), + funding_rate_interval: None, }, }), id: Some(1), From 0e9475e2e1899c8c31980281442a8de485b0445e Mon Sep 17 00:00:00 2001 From: Bart Platak Date: Mon, 28 Jul 2025 23:33:26 +0100 Subject: [PATCH 08/11] fix test --- lazer/sdk/rust/protocol/src/jrpc.rs | 5 ++++- lazer/sdk/rust/protocol/src/payload.rs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lazer/sdk/rust/protocol/src/jrpc.rs b/lazer/sdk/rust/protocol/src/jrpc.rs index 28ac449e79..5ca259b20b 100644 --- a/lazer/sdk/rust/protocol/src/jrpc.rs +++ b/lazer/sdk/rust/protocol/src/jrpc.rs @@ -278,7 +278,10 @@ mod tests { "type": "funding_rate", "price": 1234567890, "rate": 1234567891, - "funding_rate_interval": 28800 + "funding_rate_interval": { + "secs": 28800, + "nanos": 0 + } } }, "id": 1 diff --git a/lazer/sdk/rust/protocol/src/payload.rs b/lazer/sdk/rust/protocol/src/payload.rs index fbe622b902..85226f5043 100644 --- a/lazer/sdk/rust/protocol/src/payload.rs +++ b/lazer/sdk/rust/protocol/src/payload.rs @@ -52,6 +52,7 @@ pub struct AggregatedPriceFeedData { pub confidence: Option, pub funding_rate: Option, pub funding_timestamp: Option, + pub funding_rate_interval: Option, } /// First bytes of a payload's encoding From bfffe233542f20fc0388f34d5246101f90be08b9 Mon Sep 17 00:00:00 2001 From: Bart Platak Date: Mon, 28 Jul 2025 23:50:43 +0100 Subject: [PATCH 09/11] use humantime for interval serde --- lazer/sdk/rust/protocol/src/jrpc.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lazer/sdk/rust/protocol/src/jrpc.rs b/lazer/sdk/rust/protocol/src/jrpc.rs index 5ca259b20b..ceb7704f22 100644 --- a/lazer/sdk/rust/protocol/src/jrpc.rs +++ b/lazer/sdk/rust/protocol/src/jrpc.rs @@ -40,10 +40,15 @@ pub enum UpdateParams { FundingRateUpdate { price: Option, rate: Rate, + #[serde(default = "default_funding_rate_interval", with = "humantime_serde")] funding_rate_interval: Option, }, } +fn default_funding_rate_interval() -> Option { + None +} + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] pub struct Filter { pub name: Option, @@ -278,10 +283,7 @@ mod tests { "type": "funding_rate", "price": 1234567890, "rate": 1234567891, - "funding_rate_interval": { - "secs": 28800, - "nanos": 0 - } + "funding_rate_interval": "8h" } }, "id": 1 From 60d8161aebbc870b06de254f29c614c401f0e11e Mon Sep 17 00:00:00 2001 From: Bart Platak Date: Tue, 29 Jul 2025 14:35:28 +0100 Subject: [PATCH 10/11] update type in paylaoddata --- lazer/sdk/rust/protocol/src/payload.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lazer/sdk/rust/protocol/src/payload.rs b/lazer/sdk/rust/protocol/src/payload.rs index 85226f5043..d5b67f2086 100644 --- a/lazer/sdk/rust/protocol/src/payload.rs +++ b/lazer/sdk/rust/protocol/src/payload.rs @@ -14,6 +14,7 @@ use { num::NonZeroI64, }, }; +use crate::time::DurationUs; /// Data contained within a signable payload. #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -52,7 +53,7 @@ pub struct AggregatedPriceFeedData { pub confidence: Option, pub funding_rate: Option, pub funding_timestamp: Option, - pub funding_rate_interval: Option, + pub funding_rate_interval: Option, } /// First bytes of a payload's encoding From 306af223e10ec49e77a6775fb32c152ab1edf56f Mon Sep 17 00:00:00 2001 From: Bart Platak Date: Tue, 29 Jul 2025 14:38:39 +0100 Subject: [PATCH 11/11] fix lint --- lazer/sdk/rust/protocol/src/payload.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lazer/sdk/rust/protocol/src/payload.rs b/lazer/sdk/rust/protocol/src/payload.rs index d5b67f2086..8506183995 100644 --- a/lazer/sdk/rust/protocol/src/payload.rs +++ b/lazer/sdk/rust/protocol/src/payload.rs @@ -1,5 +1,6 @@ //! Types representing binary encoding of signable payloads and signature envelopes. +use crate::time::DurationUs; use { super::router::{PriceFeedId, PriceFeedProperty}, crate::{ @@ -14,7 +15,6 @@ use { num::NonZeroI64, }, }; -use crate::time::DurationUs; /// Data contained within a signable payload. #[derive(Debug, Clone, PartialEq, Eq, Hash)]