Swapping
Introduction
Swapping is the process of exchanging one token for another on the Solana blockchain. With SolanaPortal, you can perform two types of swaps on supported platforms Raydium, Jupiter, Pump.fun and Moonshot:
Standard Token Swaps: A straightforward swap involving a single token and wallet.
Jito Bundles Swaps: Advanced transactions that allow multiple token swaps to be grouped into a single transaction. This can involve a single wallet or multiple wallets, making it highly efficient for complex trading scenarios.
A single failed transaction in a Jito bundle swap
will cause the entire bundle to fail. Ensure all parameters and wallets are correctly configured to avoid issues
Both methods are built on SolanaPortal’s robust API endpoints, ensuring reliability and speed regardless of blockchain congestion.
API Endpoints
Standard Swap Endpoint: For executing individual token swaps.
Jito Bundle Endpoint: For batching multiple swaps into one transaction.
Core Parameters for Swapping
Parameter
Type
Required
Description
wallet_address
string
Yes
The public address of the wallet initiating the transaction.
mint
string
Yes
The unique identifier (mint address) of the token you want to trade.
action
string
Yes
Defines the trade type: buy
(purchase the token) or sell
(exchange it for another).
dex
string
Yes
Specifies the decentralized exchange to execute the swap. Supported values: raydium
, jupiter
, pumpfun
, moonshot
.
amount
number
Yes
The amount of the token you want to trade.
slippage
number
Yes
The maximum price variation you are willing to tolerate during the swap, expressed as a percentage.
tip
number
Yes
A priority fee to ensure faster processing of your transaction, especially during network congestion.
type
string
Yes
Specifies the transaction type. Supported values: jito
(preferred) or bloxroute
.
Parameter Explanations
wallet_address
The public address of the wallet initiating the transaction, required for signing and executing the swap. It can also be derived from the private key as explained in the implementation.
Example:
mint
The unique identifier (mint address) of the token you want to trade. Every token on Solana has a distinct mint address.
Example:
So11111111111111111111111111111111111111112
USDC:
EPjFWdd5AufqSSqarwM2Lb8...
action
Specifies the trade type.
buy
: Purchase the specified token.sell
: Exchange the specified token for another.
Example:
dex
The decentralized exchange platform to execute the swap.
Supported values:
raydium
,jupiter
,pump
,moonshot
.
Example:
amount
The quantity of tokens involved in the trade.
For
buy
: The value should be specified in SOL (e.g.,0.01
) since you're purchasing tokens using SOL.For
sell
: The value should be the number of tokens you want to sell (e.g.,1550
or5090.25
).
Example:
Ensure you have enough tokens in your wallet to avoid insufficient balance errors.
slippage
The maximum price variation you are willing to tolerate during the swap, expressed as a percentage.
Example:
Higher slippage tolerances prevent failed transactions in volatile markets
tip
A priority fee to ensure faster processing of your transaction, especially during network congestion.
Example:
type
Specifies the transaction type.
Supported values:
jito
(default),bloxroute
.
Example:
Standard Token Swaps
Standard token swaps are the simplest way to trade tokens using SolanaPortal. These swaps involve a single wallet and one token pair, processed through the trading endpoint.
Example:
The parameters for a standard token swap should look like this:
Jito Bundle Swap
Jito bundle transactions provide an efficient method for executing multiple swaps within a single transaction. The parameters for these transactions are similar to those used in standard token swaps, with two exceptions: the type
and slippage
parameters are not required.
You can use multiple wallets for different swaps.
Alternatively, execute multiple token trades using a single wallet.
A single failed transaction in a Jito bundle swap
will cause the entire bundle to fail. Ensure all parameters and wallets are correctly configured to avoid issues
Example:
Each swap has its own parameters with tip
only in first swap. Implementation details and examples will be provided in the respective programming language subpages.
Next Steps
To learn how to implement swaps programmatically, visit the language-specific guides:
Last updated