PumpFun Swap Endpoint
POST /api/v1/pumpfun/swap
Request Body
Parameter | Type | Description |
---|---|---|
userAddress | string | The Solana wallet address of the user executing the swap |
bondingCurveAddress | string | The address of the PumpFun Bonding Curve of the token |
tokenAddress | string | The address of the token to swap (also called mint or CA) |
tokenAmount | number | The amount of tokens to buy |
solThreshold | number | The 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? |
isBuy | boolean | Whether this is a buy (true ) or sell (false ) operation |
skipAccountCheck | boolean | Optional, 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. |
computePrice | number | Optional. Sets total compute limit to be allocated for all instructions within the created tx. |
computeLimit | number | Optional. 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>" } }