SolanaPortal
  • ✨Welcome to SolanaPortal
  • Getting Started
    • ⭐Why SolanaPortal?
    • 📖Guide
    • 🗺️Best Practices
    • ❓FAQ
  • API Documentation
    • Swapping
      • Swapping with Node.js
      • Swapping with Python
      • Swapping with Rust
    • Token Creation
      • Pump.fun Token
      • Standard Token
  • Market Creation
  • ‼️Troubleshooting
  • Support
Powered by GitBook
On this page
  • Introduction
  • API Endpoints
  • Core Parameters for Swapping
  • Parameter Explanations
  • Standard Token Swaps
  • Jito Bundle Swap
  1. API Documentation

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.

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

  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

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:

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

Use trusted platforms like Solscan or CoinGecko to verify mint addresses.

action

Specifies the trade type.

  • buy: Purchase the specified token.

  • sell: Exchange the specified token for another.

Example:

action: "buy"

Double-check the trade type to avoid unintended token transactions.

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

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:

slippage: 90

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:

tip: 0.001

Use a competitive tip value during high network activity to prioritize your transaction.

type

Specifies the transaction type.

  • Supported values: jito (default), bloxroute.

Example:

type: "jito"

Use jito for priority execution.


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:

{
  "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.

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.

[
  {
    "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:

PreviousFAQNextSwapping with Node.js

Last updated 3 months ago

Swapping with Node.js
Swapping with Python
Swapping with Rust