Create Swap Transaction CPMM

Creates an unsigned transaction for the best possible swap through the Raydium CPMM pool.

This endpoint does not submit the transaction to the network.

The endpoint allows you to specify priority fees and tips to later control the transaction inclusion and propagation. Refer to the Transaction Submission & Front-Running Protection & Transaction Bundle page for additional information about these parameters.

This swap is using CPMM Pools on Raydium. All of these swaps are using program ID

CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C

Request

Method:

POST ./api/v2/raydium/cpmm-swap

Parameters:

ParameterTypeDescription

ownerAddress

string

Solana address which is placing swap.

inToken

string

Symbol or token program address of the swap-in token for the current step.

outToken

string

Symbol or token program address of the swap-out token.

inAmount

double

The amount of swap-in token to be converted to the swap-out token.

slippage

double

The maximum slippage tolerance in percentage.

tradeFeeRate

uint64

tradeFeeRate of the pool you are trading on

poolAddress

string

poolID of the pool you are trading on

computeLimit

uint32

OPTIONAL. Specifies total compute limit to be allocated for all instructions within the created tx

computePrice

uint64

OPTIONAL. Specifies compute price in Lamport (0.000001 SOL = 1,000 Lamport) to be included as a part of instruction, known as priority fee.

tip

unit64

Request example:

curl -X 'POST' \
  -H "Authorization: $AUTH_HEADER" \
  -H 'Content-Type: application/json' \
  'https://ny.solana.dex.blxrbdn.com/api/v2/raydium/cpmm-swap' \
  -d '{
  "ownerAddress": "AFT8V...DfQ",
  "inToken": "SOL",
  "outToken": "USDC",
  "inAmount": 0.1,
  "slippage": 0.001
}'

Response:

Fields:

FieldTypeDescription

transaction

TransactionMessage

See TransactionMessage below for details

outAmount

double

Amount of tokens expected from the swap

outAmountMin

double

Minimum amount of tokens allowed from swap given slippage

TransactionMessage

ParameterDescription

content

string

Raw bytes of signed transaction (should be in base64)

Example:

{
    "transactions":[
      {
        "content": "AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAg1Lo4g1hEH0nZ/T5G7nTAttcpmpseiXTXm0014hV7EHwEHh2GMqr0U7fdu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AAKUAAAAAAAAABt324ddloZPZy+FGzut5rBy0he1fWzeROoz1hX7/AKkQBAEOAA8BARUSEAIRAwQFBhIHCAkKCwwTAQ0AEQkA4fUFAAAAAMaAAAAAAAAAEAMBAAABCRYAH1Bvd2VyZWQgYnkgYmxvWHJvdXRlIFRyYWRlciBBcGk=",
        "isCleanup": false
      }
    ],
    "outAmount":3.296703,
    "outAmountMin":0.032966,
    "priceImpact":{
        "percent":4.5386233671508175e-7,
        "infinity":"INF_NOT"
    },
    "fee":[{
        "amount":0.00025,
        "mint":"",
        "percent":0
    }]
}

Last updated