Skip to content

Added Jupiter PrioritieFees parameter and MaxLamports configuration. #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/Solana.Unity.Dex/Jupiter/Core/Types/Http/SwapRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,37 @@ public class SwapRequest
/// Is this a legacy transaction
/// </summary>
public bool AsLegacyTransaction { get; set; }

/// <summary>
/// To specify a level or amount of additional fees to prioritize the transaction
/// It can be used for both priority fee and jito tip
/// </summary>
public PrioritizationFeeLamportsContainer PrioritizationFeeLamports { get; set; }
}

/// <summary>
/// Represents prioritization fee settings
/// </summary>
public class PrioritizationFeeLamportsContainer
{
/// <summary>
/// Represents the max Lamports and priority level
/// </summary>
public PriorityLevelWithMaxLamports PriorityLevelWithMaxLamports { get; set; }
}

/// <summary>
/// Represents the max Lamports and priority level
/// </summary>
public class PriorityLevelWithMaxLamports
{
/// <summary>
/// Maximum lamports to cap the priority fee estimation, to prevent overpaying
/// </summary>
public ulong MaxLamports { get; set; }

/// <summary>
/// Either medium, high or veryHigh
/// </summary>
public string PriorityLevel { get; set; } // Example: "veryHigh"
}
19 changes: 17 additions & 2 deletions src/Solana.Unity.Dex/Jupiter/JupiterDex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/// <summary>
/// Concrete implementation of IDexAggregator for Jupiter Aggregator.
/// </summary>
public class JupiterDexAg: IDexAggregator

Check failure on line 26 in src/Solana.Unity.Dex/Jupiter/JupiterDex.cs

View workflow job for this annotation

GitHub Actions / build

'JupiterDexAg' does not implement interface member 'IDexAggregator.Swap(SwapQuoteAg, PublicKey, PublicKey, bool, bool, PublicKey, BigInteger?, bool)'

Check failure on line 26 in src/Solana.Unity.Dex/Jupiter/JupiterDex.cs

View workflow job for this annotation

GitHub Actions / build

'JupiterDexAg' does not implement interface member 'IDexAggregator.Swap(SwapQuoteAg, PublicKey, PublicKey, bool, bool, PublicKey, BigInteger?, bool)'
{
private readonly PublicKey _account;
private readonly string _endpoint;
Expand Down Expand Up @@ -136,13 +136,27 @@
bool useSharedAccounts = true,
PublicKey feeAccount = null,
BigInteger? computeUnitPriceMicroLamports = null,
bool useTokenLedger = false)
bool useTokenLedger = false,
ulong maxLamports = 1_400_000,
string priorityLevel = "medium"
)
{
userPublicKey ??= _account;

// Construct the request URL
var apiUrl = _endpoint + "/swap";

var priorityLevelObject = new PriorityLevelWithMaxLamports()
{
MaxLamports = maxLamports,
PriorityLevel = priorityLevel
};

var prioritizationFeePart = new PrioritizationFeeLamportsContainer()
{
PriorityLevelWithMaxLamports = priorityLevelObject
};

var req = new SwapRequest()
{
QuoteResponse = quoteResponse,
Expand All @@ -153,7 +167,8 @@
FeeAccount = feeAccount,
ComputeUnitPriceMicroLamports = computeUnitPriceMicroLamports,
UseTokenLedger = useTokenLedger,
AsLegacyTransaction = false
AsLegacyTransaction = false,
PrioritizationFeeLamports = prioritizationFeePart
};

var requestJson = JsonConvert.SerializeObject(req, _serializerOptions);
Expand Down
Loading