Skip to content

Commit 8baf980

Browse files
authored
Merge pull request #19 from thrishank/main
fix: PrioritizationFeeLamports struct and jitotip added
2 parents bebdc6a + d1ad3ba commit 8baf980

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub struct SwapRequest {
6868
/// When enabled, it estimates slippage and apply it in the swap transaction directly, overwriting the slippageBps parameter in the quote response.
6969
/// Used together with dynamicSlippage in /quote, otherwise the slippage used will be the one in the /quote's slippageBps
7070
#[serde(skip_serializing_if = "Option::is_none")]
71-
pub dyanmic_slippage: Option<bool>,
71+
pub dynamic_slippage: Option<bool>,
7272

7373
/// To use an exact compute unit price to calculate priority fee
7474
/// computeUnitLimit (1400000) * computeUnitPriceMicroLamports
@@ -81,11 +81,16 @@ pub struct SwapRequest {
8181
pub quote_response: QuoteResponse,
8282
}
8383

84+
/// Only one of these fields should be set at a time.
85+
/// Use either `jito_tip_lamports` or `priority_level_with_max_lamports`, not both.
8486
#[derive(Debug, Serialize, Deserialize)]
8587
#[serde(rename_all = "camelCase")]
8688
pub struct PrioritizationFeeLamports {
89+
#[serde(skip_serializing_if = "Option::is_none")]
8790
pub jito_tip_lamports: Option<u64>,
88-
pub priority_level_with_max_lamports: PriorityLevelWithMaxLamports,
91+
92+
#[serde(skip_serializing_if = "Option::is_none")]
93+
pub priority_level_with_max_lamports: Option<PriorityLevelWithMaxLamports>,
8994
}
9095

9196
#[derive(Debug, Serialize, Deserialize)]
@@ -143,7 +148,7 @@ impl SwapRequest {
143148
destination_token_account: None,
144149
dynamic_compute_unit_limit: None,
145150
skip_user_account_rpc_calls: None,
146-
dyanmic_slippage: None,
151+
dynamic_slippage: None,
147152
compute_unit_price_micro_lamports: None,
148153
blockhash_slots_to_expiry: None,
149154
quote_response: quote,
@@ -187,27 +192,27 @@ impl SwapRequest {
187192
pub fn prioritization_fee_jito_tip(mut self, fee: u64) -> Self {
188193
self.prioritization_fee_lamports = Some(PrioritizationFeeLamports {
189194
jito_tip_lamports: Some(fee),
190-
priority_level_with_max_lamports: PriorityLevelWithMaxLamports {
191-
max_lamports: 0,
192-
priority_level: PriorityLevel::Medium,
193-
},
195+
priority_level_with_max_lamports: None,
194196
});
195197
self
196198
}
197199

198-
/// set prioritization config
200+
/// Sets a priority fee configuration based on estimated network congestion
201+
///
202+
/// Allows specifying both:
203+
/// - Priority level (e.g., `medium`, `high`)
204+
/// - Maximum cap on lamports paid
199205
pub fn prioritization_fee_config(
200206
mut self,
201-
jito_tip: Option<u64>,
202207
max_lamports: u32,
203208
priority_level: PriorityLevel,
204209
) -> Self {
205210
self.prioritization_fee_lamports = Some(PrioritizationFeeLamports {
206-
jito_tip_lamports: jito_tip,
207-
priority_level_with_max_lamports: PriorityLevelWithMaxLamports {
211+
jito_tip_lamports: None,
212+
priority_level_with_max_lamports: Some(PriorityLevelWithMaxLamports {
208213
max_lamports,
209214
priority_level,
210-
},
215+
}),
211216
});
212217
self
213218
}
@@ -245,8 +250,8 @@ impl SwapRequest {
245250
/// Enables dynamic slippage estimation.
246251
///
247252
/// If enabled, slippage will be recalculated at swap-time instead of using a fixed value.
248-
pub fn dyanmic_slippage(mut self, dynamic: bool) -> Self {
249-
self.dyanmic_slippage = Some(dynamic);
253+
pub fn dynamic_slippage(mut self, dynamic: bool) -> Self {
254+
self.dynamic_slippage = Some(dynamic);
250255
self
251256
}
252257

0 commit comments

Comments
 (0)