Skip to content

PumpSwap Swap Endpoint

POST /api/v1/pumpswap/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, you want to sell. Required for sells only.
solThresholdnumberThe SOL amount you willing to spend on a buy. Required for buys only.
isBuybooleanWhether this is a buy (true) or sell (false) operation
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.

For prices, API fetches them from pools, aiming for the first found pool. If you would like to have a specific price, please contact us, we will add an option for you.

Examples

js
const swapData = {
    userAddress: "dafs3GGvJoUYjTmxRXhkqCj3ULa9bvKmX7EDDMTwVFE",
    tokenAddress: "7dppjqtFi5Qfy4BRKJ6khN3yxDbvQhgNJbAoeh13pump",
    creatorAddress: "4Gi5aJKNTbK9e72Ch4FZc5aDsnLkChuYudunNnpySzBi",
    solThreshold: 0.1,
    isBuy: true
};

async function getSwapTX() {
    try {
        const response = await fetch('https://api.degen.ing/api/v1/pumpswap/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/pumpswap/swap' \
  -d '{
    "userAddress": "dafs3GGvJoUYjTmxRXhkqCj3ULa9bvKmX7EDDMTwVFE",
    "tokenAddress": "7dppjqtFi5Qfy4BRKJ6khN3yxDbvQhgNJbAoeh13pump",
    "creatorAddress": "4Gi5aJKNTbK9e72Ch4FZc5aDsnLkChuYudunNnpySzBi",
    "solThreshold": 0.1,
    "isBuy": true
}'

Response

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

Implementation Notes

  • It uses the same WSol account for a given token
  • It closes the WSol account after each swap, so if you already have some WSol, the tx will exchange them back to Sol
  • It gets the price of the token from pools, aiming for the best price. That's why on buy you do not need to provide tokenAmount parameter. Contact the dev if you need it, we can add an option for you.