Skip to content

Commit a31a7a6

Browse files
committed
fix: priority fee lamports struct
1 parent e23b6e4 commit a31a7a6

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

jup-ag-sdk/src/types/swap_transaction.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,11 @@ pub struct SwapRequest {
8484
#[derive(Debug, Serialize, Deserialize)]
8585
#[serde(rename_all = "camelCase")]
8686
pub struct PrioritizationFeeLamports {
87+
#[serde(skip_serializing_if = "Option::is_none")]
8788
pub jito_tip_lamports: Option<u64>,
88-
pub priority_level_with_max_lamports: PriorityLevelWithMaxLamports,
89+
90+
#[serde(skip_serializing_if = "Option::is_none")]
91+
pub priority_level_with_max_lamports: Option<PriorityLevelWithMaxLamports>,
8992
}
9093

9194
#[derive(Debug, Serialize, Deserialize)]
@@ -184,30 +187,36 @@ impl SwapRequest {
184187
}
185188

186189
/// Set prioritization fee lamports
190+
///
191+
/// Note:
192+
/// - Cannot be combined with `priority_level_with_max_lamports`.
187193
pub fn prioritization_fee_jito_tip(mut self, fee: u64) -> Self {
188194
self.prioritization_fee_lamports = Some(PrioritizationFeeLamports {
189195
jito_tip_lamports: Some(fee),
190-
priority_level_with_max_lamports: PriorityLevelWithMaxLamports {
191-
max_lamports: 0,
192-
priority_level: PriorityLevel::Medium,
193-
},
196+
priority_level_with_max_lamports: None,
194197
});
195198
self
196199
}
197200

198-
/// set prioritization config
201+
/// Sets a priority fee configuration based on estimated network congestion
202+
///
203+
/// Allows specifying both:
204+
/// - Priority level (e.g., `medium`, `high`)
205+
/// - Maximum cap on lamports paid
206+
///
207+
/// Note:
208+
/// - Cannot be combined with `jito_tip_lamports`.
199209
pub fn prioritization_fee_config(
200210
mut self,
201-
jito_tip: Option<u64>,
202211
max_lamports: u32,
203212
priority_level: PriorityLevel,
204213
) -> Self {
205214
self.prioritization_fee_lamports = Some(PrioritizationFeeLamports {
206-
jito_tip_lamports: jito_tip,
207-
priority_level_with_max_lamports: PriorityLevelWithMaxLamports {
215+
jito_tip_lamports: None,
216+
priority_level_with_max_lamports: Some(PriorityLevelWithMaxLamports {
208217
max_lamports,
209218
priority_level,
210-
},
219+
}),
211220
});
212221
self
213222
}

0 commit comments

Comments
 (0)