11#[ cfg( feature = "proto" ) ]
22use prost:: Message ;
33
4- use crate :: Pair ;
4+ use crate :: { instrument_type :: InstrumentType , Pair } ;
55#[ cfg( feature = "proto" ) ]
66use crate :: { ProtoDeserialize , ProtoSerialize } ;
77
@@ -17,6 +17,8 @@ pub struct FundingRateEntry {
1717 pub pair : Pair ,
1818 pub annualized_rate : f64 ,
1919 pub timestamp_ms : i64 ,
20+ pub instrument_type : InstrumentType ,
21+ pub received_timestamp_ms : i64 ,
2022}
2123
2224#[ cfg( feature = "proto" ) ]
@@ -30,13 +32,23 @@ impl FundingRateEntry {
3032 } ) ,
3133 annualized_rate : self . annualized_rate ,
3234 timestamp_ms : self . timestamp_ms ,
35+ instrument_type : match self . instrument_type {
36+ InstrumentType :: Spot => crate :: schema:: InstrumentType :: Spot as i32 ,
37+ InstrumentType :: Perp => crate :: schema:: InstrumentType :: Perp as i32 ,
38+ } ,
39+ received_timestamp_ms : self . received_timestamp_ms ,
3340 }
3441 }
3542
3643 fn from_proto ( proto : crate :: schema:: FundingRateEntry ) -> Result < Self , prost:: DecodeError > {
3744 let pair = proto
3845 . pair
3946 . ok_or_else ( || prost:: DecodeError :: new ( "Missing pair field in FundingRateEntry" ) ) ?;
47+ let instrument_type = match proto. instrument_type {
48+ x if x == crate :: schema:: InstrumentType :: Spot as i32 => InstrumentType :: Spot ,
49+ x if x == crate :: schema:: InstrumentType :: Perp as i32 => InstrumentType :: Perp ,
50+ _ => InstrumentType :: Perp , // Default to Perp for funding rates (backwards compat)
51+ } ;
4052 Ok ( FundingRateEntry {
4153 source : proto. source ,
4254 pair : Pair {
@@ -45,6 +57,8 @@ impl FundingRateEntry {
4557 } ,
4658 annualized_rate : proto. annualized_rate ,
4759 timestamp_ms : proto. timestamp_ms ,
60+ instrument_type,
61+ received_timestamp_ms : proto. received_timestamp_ms ,
4862 } )
4963 }
5064}
0 commit comments