lightspeed_sdk/types.rs
1// src/types.rs
2use solana_sdk::signature::Signature;
3
4/// Priority levels for transaction processing
5///
6/// Determines the tip amount attached to transactions, which affects
7/// their processing priority in the Lightspeed service.
8///
9/// ## Example
10///
11/// ```rust
12/// use lightspeed_sdk::Priority;
13///
14/// let minimum = Priority::Minimum; // 0.0001 SOL
15/// let standard = Priority::Standard; // 0.001 SOL
16/// let rush = Priority::Rush; // 0.005 SOL
17/// let custom = Priority::Custom(10_000_000); // 0.01 SOL
18/// ```
19#[derive(Debug, Clone, Copy)]
20pub enum Priority {
21 /// Minimum priority (0.0001 SOL tip)
22 ///
23 /// Suitable for many transactions.
24 Minimum,
25
26 /// Standard priority (0.001 SOL tip)
27 ///
28 /// Suitable for most time-sensitive transactions.
29 Standard,
30
31 /// Rush priority (0.005 SOL tip)
32 ///
33 /// For extremely time-sensitive transactions requiring faster processing.
34 Rush,
35
36 /// Custom tip amount in lamports
37 ///
38 /// Allows fine-grained control over the tip amount.
39 /// Minimum: 1,000,000 lamports (0.001 SOL).
40 Custom(u64),
41}
42
43impl Priority {
44 /// Converts the priority level to lamports
45 ///
46 /// ## Returns
47 ///
48 /// The tip amount in lamports corresponding to this priority level.
49 pub fn to_lamports(&self) -> u64 {
50 match self {
51 Priority::Minimum => 100_000, // 0.0001 SOL
52 Priority::Standard => 1_000_000, // 0.001 SOL
53 Priority::Rush => 5_000_000, // 0.005 SOL
54 Priority::Custom(lamports) => *lamports,
55 }
56 }
57}
58
59/// Result of a successful transaction submission
60///
61/// Contains the transaction signature and metadata about the transaction,
62/// including the tip amount that was paid for prioritization.
63#[derive(Debug)]
64pub struct TransactionResult {
65 /// Transaction signature
66 ///
67 /// Can be used to track the transaction on Solana explorers.
68 pub signature: Signature,
69
70 /// Tip amount paid in lamports
71 ///
72 /// The amount transferred to the Lightspeed tip address for prioritization.
73 pub tip_amount: u64,
74}