File tree Expand file tree Collapse file tree 2 files changed +16
-15
lines changed Expand file tree Collapse file tree 2 files changed +16
-15
lines changed Original file line number Diff line number Diff line change @@ -565,7 +565,7 @@ pub struct FeePoliciesConfig {
565565
566566 /// Volume fee policies that will become effective at a future timestamp.
567567 #[ clap( flatten) ]
568- pub upcoming_fee_policies : Option < UpcomingFeePolicies > ,
568+ pub upcoming_fee_policies : UpcomingFeePolicies ,
569569}
570570
571571/// A fee policy to be used for orders base on it's class.
@@ -602,7 +602,7 @@ pub struct UpcomingFeePolicies {
602602 long = "upcoming-fee-policies-timestamp" ,
603603 env = "UPCOMING_FEE_POLICIES_TIMESTAMP"
604604 ) ]
605- pub effective_from_timestamp : DateTime < Utc > ,
605+ pub effective_from_timestamp : Option < DateTime < Utc > > ,
606606}
607607
608608#[ derive( clap:: Parser , Debug , Clone ) ]
Original file line number Diff line number Diff line change @@ -57,16 +57,20 @@ pub struct UpcomingProtocolFees {
5757 effective_from_timestamp : DateTime < Utc > ,
5858}
5959
60- impl From < arguments:: UpcomingFeePolicies > for UpcomingProtocolFees {
60+ impl From < arguments:: UpcomingFeePolicies > for Option < UpcomingProtocolFees > {
6161 fn from ( value : arguments:: UpcomingFeePolicies ) -> Self {
62- Self {
63- fee_policies : value
64- . fee_policies
65- . into_iter ( )
66- . map ( ProtocolFee :: from)
67- . collect :: < Vec < _ > > ( ) ,
68- effective_from_timestamp : value. effective_from_timestamp ,
69- }
62+ value
63+ // both config fields must be non-empty
64+ . effective_from_timestamp
65+ . filter ( |_| !value. fee_policies . is_empty ( ) )
66+ . map ( |effective_from_timestamp| UpcomingProtocolFees {
67+ fee_policies : value
68+ . fee_policies
69+ . into_iter ( )
70+ . map ( ProtocolFee :: from)
71+ . collect :: < Vec < _ > > ( ) ,
72+ effective_from_timestamp,
73+ } )
7074 }
7175}
7276
@@ -88,10 +92,7 @@ impl ProtocolFees {
8892 . map ( ProtocolFee :: from)
8993 . collect ( ) ,
9094 max_partner_fee : config. fee_policy_max_partner_fee ,
91- upcoming_fee_policies : config
92- . upcoming_fee_policies
93- . clone ( )
94- . map ( UpcomingProtocolFees :: from) ,
95+ upcoming_fee_policies : config. upcoming_fee_policies . clone ( ) . into ( ) ,
9596 }
9697 }
9798
You can’t perform that action at this time.
0 commit comments