Jupiter Object
The Jupiter Aggregator global object and methods.
Jupiter Object Documentation
The Jupiter
class provides methods to interact with the Jupiter decentralized exchange aggregator on the Solana blockchain. It supports watching swap events, fetching quotes, and executing swaps. This class extends the Subscribable
class, enabling subscription to Jupiter-related events.
Methods
watchSwaps
Description Watches for swap events executed via Jupiter and invokes a callback when a swap occurs.
Signature
Parameters
callback
((event: JupiterSwap) => void
): The callback function to handle swap events.
Returns
Promise<SubscriptionResult>
: The result of the subscription operation.
Example Usage
quote
Description Fetches a swap quote based on the specified parameters, including input and output tokens, amounts, and slippage tolerance.
Signature
Parameters
request
(JupiterQuoteRequest
): An object containing the quote request details, such as:inputMint
(string
): The mint address of the input token.outputMint
(string
): The mint address of the output token.amount
(number | string
): The amount of the input token.slippageBps
(number
): The slippage tolerance in basis points.Other optional fields from
QuoteGetRequest
.
Returns
Promise<QuoteResponse>
: A quote response object containing swap details, such as routes, estimated amounts, and fees.
Example Usage
swap
Description Performs a swap using Jupiter, executing the transaction with the specified parameters.
Signature
Parameters
request
(JupiterSwapRequest
): An object containing the swap request details, including:routePlan
(any
): The swap route plan.wrapAndUnwrapSol
(boolean
): Whether to wrap/unwrap SOL during the swap.prioritizationFeeLamports
(number | string
): Optional. The prioritization fee in lamports for faster confirmation.
Returns
Promise<JupiterSwapResponse>
: An object containing:transaction
(Transaction | VersionedTransaction
): The swap transaction.lastValidBlockHeight
(number
): The last valid block height for the transaction.prioritizationFeeLamports
(number
): Optional. The prioritization fee in lamports.
Example Usage
Types
JupiterSwap
Represents a Jupiter swap event.
JupiterQuoteRequest
Request type for fetching a quote.
JupiterSwapRequest
Request type for performing a swap.
RoboqoJupiterSwapResponse
Internal response type for a swap operation.
JupiterSwapResponse
Response type for a swap operation.
Last updated