Skip to content

PumpFun Swap Endpoint

POST /api/v1/pumpfun/swap

Request Body

ParameterTypeDescription
userAddressstringThe Solana wallet address of the user executing the swap
bondingCurveAddressstringThe address of the PumpFun Bonding Curve of the token
tokenAddressstringThe address of the token to swap (also called mint or CA)
tokenAmountnumberThe amount of tokens to buy
solThresholdnumberThe maximum Sol amount threshold for the swap, needed for buys only. Sells assume this value as 1 lamport, because... who cares about threshold on sells?
isBuybooleanWhether this is a buy (true) or sell (false) operation
skipAccountCheckbooleanOptional, default: false. Whether to skip the account existence check for the user. It will make any copies of modified transaction fail after the first one lands on chain, because will try to create the same account again. Used only for buys.
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",
    bondingCurveAddress: "7BcRpqUC7AF5Xsc3QEpCb8xmoi2X1LpwjUBNThbjWvyo",
    tokenAddress: "BAHY8ocERNc5j6LqkYav1Prr8GBGsHvBV5X3dWPhsgXw",
    solThreshold: 1.5,
    tokenAmount: 100000,
    isBuy: false
};

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",
    "bondingCurveAddress": "7BcRpqUC7AF5Xsc3QEpCb8xmoi2X1LpwjUBNThbjWvyo",
    "tokenAddress": "BAHY8ocERNc5j6LqkYav1Prr8GBGsHvBV5X3dWPhsgXw",
    "tokenAmount": 1000000,
    "solThreshold": 1.5,
    "isBuy": true
}'

Response

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