> For the complete documentation index, see [llms.txt](https://docs.solanaportal.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.solanaportal.io/api-documentation/swapping.md).

# 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:

1. Standard Token Swaps: A straightforward swap involving a single token and wallet.
2. 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.

{% hint style="danger" %}
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
{% endhint %}

Both methods are built on SolanaPortal’s robust API endpoints, ensuring reliability and speed regardless of blockchain congestion.

***

### API Endpoints

1. **Standard Swap Endpoint**: For executing individual token swaps.

   ```
   https://api.solanaportal.io/api/trading
   ```
2. **Jito Bundle Endpoint**: For batching multiple swaps into one transaction.

   ```
   https://api.solanaportal.io/api/jito-bundle
   ```

### Core Parameters for Swapping

<table data-header-hidden><thead><tr><th width="162"></th><th width="100"></th><th width="103"></th><th width="384"></th></tr></thead><tbody><tr><td><strong>Parameter</strong></td><td><strong>Type</strong></td><td><strong>Required</strong></td><td><strong>Description</strong></td></tr><tr><td>wallet_address</td><td>string</td><td>Yes</td><td>The public address of the wallet initiating the transaction.</td></tr><tr><td>mint</td><td>string</td><td>Yes</td><td>The unique identifier (mint address) of the token you want to trade.</td></tr><tr><td>action</td><td>string</td><td>Yes</td><td>Defines the trade type: <code>buy</code> (purchase the token) or <code>sell</code> (exchange it for another).</td></tr><tr><td>dex</td><td>string</td><td>Yes</td><td>Specifies the decentralized exchange to execute the swap. Supported values: <code>raydium</code>, <code>jupiter</code>, <code>pumpfun</code>, <code>moonshot</code>.</td></tr><tr><td>amount</td><td>number</td><td>Yes</td><td>The amount of the token you want to trade.</td></tr><tr><td>slippage</td><td>number</td><td>Yes</td><td>The maximum price variation you are willing to tolerate during the swap, expressed as a percentage.</td></tr><tr><td>tip</td><td>number</td><td>Yes</td><td>A priority fee to ensure faster processing of your transaction, especially during network congestion.</td></tr><tr><td>type</td><td>string</td><td>Yes</td><td>Specifies the transaction type. Supported values: <code>jito</code> (preferred) or <code>bloxroute</code>.</td></tr></tbody></table>

***

### 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**:

```
wallet_address: "4XsW7fg4rRVKbKHZjqXVZL..."
```

#### 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...`

{% hint style="info" %}
Use trusted platforms like **Solscan** or **CoinGecko** to verify mint addresses.
{% endhint %}

#### action

&#x20;Specifies the trade type.

* `buy`: Purchase the specified token.
* `sell`: Exchange the specified token for another.

**Example**:

```
action: "buy"
```

{% hint style="info" %}
Double-check the trade type to avoid unintended token transactions.
{% endhint %}

#### dex

The decentralized exchange platform to execute the swap.

* Supported values: `raydium`, `jupiter`, `pump`, `moonshot`.

**Example**:

```
dex: "raydium"
```

#### **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` or `5090.25`).

**Example**:

```
amount: 0.01
```

{% hint style="danger" %}
Ensure you have enough tokens in your wallet to avoid insufficient balance errors.
{% endhint %}

#### slippage

The maximum price variation you are willing to tolerate during the swap, expressed as a percentage.

**Example**:

```
slippage: 90
```

{% hint style="warning" %}
Higher slippage tolerances prevent failed transactions in volatile markets
{% endhint %}

#### tip

A priority fee to ensure faster processing of your transaction, especially during network congestion.

**Example**:

```
tip: 0.001
```

{% hint style="info" %}
Use a competitive tip value during high network activity to prioritize your transaction.
{% endhint %}

#### type

Specifies the transaction type.

* Supported values: `jito` (default), `bloxroute`.

**Example**:

```
type: "jito"
```

{% hint style="info" %}
Use jito for priority execution.
{% endhint %}

***

### 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:

```json
{
  "wallet_address": "4XsW7fg4rRVKbKHZjqXVZL...",
  "mint": "GAT41Hbuq2QVFKJZZGrALegyU2UKsPApkNGSoS2TjTGR",
  "action": "buy",
  "dex": "raydium",
  "amount": 0.0001,
  "slippage": 100,
  "tip": 0.0001,
  "type": "jito"
}
```

***

### 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.

{% hint style="danger" %}
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
{% endhint %}

**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.

```json
[
  {
    "wallet_address": "4XsW7fg4rR...",
    "mint": "GAT41Hbuq2QVFKJZZGrALegyU2UKsPApkNGSoS2TjTGR",
    "action": "buy",
    "dex": "jupiter",
    "amount": 0.00001,
    "tip": 0.002
  },
  {
    "wallet_address": "6YsQ1fg5yH...",
    "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "action": "sell",
    "dex": "raydium",
    "amount": 0.0001
  }
]
...
```

***

#### **Next Steps**

To learn how to implement swaps programmatically, visit the language-specific guides:

{% content-ref url="/pages/qJih6lGQhbEMPpvdqGDb" %}
[Swapping with Node.js](/api-documentation/swapping/swapping-with-node.js.md)
{% endcontent-ref %}

{% content-ref url="/pages/gcuTee6hEfRuJkrrc9vR" %}
[Swapping with Python](/api-documentation/swapping/swapping-with-python.md)
{% endcontent-ref %}

{% content-ref url="/pages/dh9M8QBq33l6SJQDL2K5" %}
[Swapping with Rust](/api-documentation/swapping/swapping-with-rust.md)
{% endcontent-ref %}
