Skip to content

PumpFun Swap Endpoint

POST /api/v1/pumpfun/swap

Request Body

ParameterTypeDescription
userAddressstringThe Solana wallet address of the user executing the swap.
tokenAddressstringThe address of the token to swap (also called mint or CA)
creatorAddressstringThe address of the creator of the token. From bonding curve account data, or (with 99.9% chance) - the signer of the mint tx.
tokenAmountnumberThe amount of tokens to buy.
solThresholdnumberThe maximum Sol amount threshold for the swap, needed for buys only. Multiply by a coefficient to make it work as a slippage tolerance. Sells use minimal threshold of 1 lamport, which means that a sell tx will not fail due to price slippage.
isBuybooleanWhether this is a buy (true) or sell (false) operation
skipAccountCheckbooleanOptional, default: false. Whether to skip the account existence check for the user.
computePricenumberOptional. Sets total compute limit to be allocated for all instructions within the created tx.
computeLimitnumberOptional. Sets compute price in Lamports to be included as a part of the tx, known as priority fee.

Examples

js
const swapData = {
    userAddress: "dafs3GGvJoUYjTmxRXhkqCj3ULa9bvKmX7EDDMTwVFE",
    tokenAddress: "D7oBwaR4qmvTv5sS9oxcBoxPawTuviNNVN9yXbakpump",
    creatorAddress: '7RcPz6R9myjoFmfANPnhEQKvKwrsEnxA5UMwoEKrHnvG',
    solThreshold: 0.1,
    tokenAmount: 100000,
    isBuy: false,
    skipAccountCheck: true
};

async function getSwapTX() {
    try {
        const response = await fetch('https://api.degen.ing/api/v1/pumpfun/swap', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
            },
            body: JSON.stringify(swapData)
        });

        const result = await response.json();
        console.log('Swap tx base64:', result.transaction.content);
    } catch (error) {
        console.error('Error requesting swap tx:', error);
    }
}
bash
curl -X 'POST' \
  -H 'Content-Type: application/json' \
  'https://api.degen.ing/api/v1/pumpfun/swap' \
  -d '{
    "userAddress": "dafs3GGvJoUYjTmxRXhkqCj3ULa9bvKmX7EDDMTwVFE",
    "tokenAddress": "D7oBwaR4qmvTv5sS9oxcBoxPawTuviNNVN9yXbakpump",
    "creatorAddress": "7RcPz6R9myjoFmfANPnhEQKvKwrsEnxA5UMwoEKrHnvG",
    "tokenAmount": 100000,
    "solThreshold": 0.1,
    "isBuy": true
}'

Response

json
{"transaction": { "content": "<base64 encoded transaction>" } }