diff --git a/src/Solana.Unity.Dex/Jupiter/Core/Types/Http/SwapRequest.cs b/src/Solana.Unity.Dex/Jupiter/Core/Types/Http/SwapRequest.cs index 8891dc34..33224f62 100644 --- a/src/Solana.Unity.Dex/Jupiter/Core/Types/Http/SwapRequest.cs +++ b/src/Solana.Unity.Dex/Jupiter/Core/Types/Http/SwapRequest.cs @@ -53,4 +53,42 @@ public class SwapRequest /// Is this a legacy transaction /// public bool AsLegacyTransaction { get; set; } + + /// + /// To specify a level or amount of additional fees to prioritize the transaction + /// It can be used for both priority fee and jito tip + /// + public PrioritizationFeeLamportsContainer PrioritizationFeeLamports { get; set; } +} + +/// +/// Represents prioritization fee settings +/// +public class PrioritizationFeeLamportsContainer +{ + /// + /// Represents the max Lamports and priority level + /// + public PriorityLevelWithMaxLamports PriorityLevelWithMaxLamports { get; set; } + /// + /// Exact amount of tip to use in a tip instruction + /// Estimate how much to set using Jito tip endpoint, see https://docs.jito.wtf/ + /// + public int JitoTipLamports { get; set; } +} + +/// +/// Represents the max Lamports and priority level +/// +public class PriorityLevelWithMaxLamports +{ + /// + /// Maximum lamports to cap the priority fee estimation, to prevent overpaying + /// + public ulong MaxLamports { get; set; } + + /// + /// Either medium, high or veryHigh + /// + public string PriorityLevel { get; set; } // Example: "veryHigh" } \ No newline at end of file diff --git a/src/Solana.Unity.Dex/Jupiter/JupiterDex.cs b/src/Solana.Unity.Dex/Jupiter/JupiterDex.cs index 50b83eba..3c6f7abb 100644 --- a/src/Solana.Unity.Dex/Jupiter/JupiterDex.cs +++ b/src/Solana.Unity.Dex/Jupiter/JupiterDex.cs @@ -136,13 +136,29 @@ public async Task Swap( bool useSharedAccounts = true, PublicKey feeAccount = null, BigInteger? computeUnitPriceMicroLamports = null, - bool useTokenLedger = false) + bool useTokenLedger = false, + ulong maxLamports = 1_400_000, + string priorityLevel = "medium", + int jitoTipLamports = 0 + ) { userPublicKey ??= _account; // Construct the request URL var apiUrl = _endpoint + "/swap"; + var priorityLevelObject = new PriorityLevelWithMaxLamports() + { + MaxLamports = maxLamports, + PriorityLevel = priorityLevel + } + + var prioritizationFeePart = new PrioritizationFeeLamportsContainer() + { + PriorityLevelWithMaxLamports = priorityLevelObject, + JitoTipLamports = jitoTipLamports + } + var req = new SwapRequest() { QuoteResponse = quoteResponse, @@ -153,7 +169,8 @@ public async Task Swap( FeeAccount = feeAccount, ComputeUnitPriceMicroLamports = computeUnitPriceMicroLamports, UseTokenLedger = useTokenLedger, - AsLegacyTransaction = false + AsLegacyTransaction = false, + PrioritizationFeeLamports = prioritizationFeePart }; var requestJson = JsonConvert.SerializeObject(req, _serializerOptions);