Skip to main content

POST /trading/swap

Execute a buy or sell on every wallet in the list.

Fan-out swap: each wallet signs its own tx. Per-wallet failures don't abort the batch — check aResults[].success per row. Auto-resolves pool + DEX from sTokenAddress.

Use case​

Manual trading action from the UI — e.g. "sell 50% of holdings across all sniper wallets" or "buy 0.1 SOL each from 20 wallets".

Body​

FieldTypeRequiredDescription
sTokenAddressstringyesToken mint.
aWalletAddressesstring[]yes1–50 pubkeys, each user-owned. Duplicates rejected.
eSwapTypeBUY | SELLyesDirection.
eSwapValueTypeEXACT | PERCENTAGEyesHow to interpret nValue.
nValuenumberyes> 0. Must be <= 100 when PERCENTAGE.

Semantics​

eSwapTypeeSwapValueTypeMeaning
BUYEXACTnValue SOL spent by each wallet.
BUYPERCENTAGEnValue% of each wallet's SOL balance.
SELLEXACTnValue token units (UI) sold by each wallet.
SELLPERCENTAGEnValue% of each wallet's token balance.

Response 200​

{
"success": true,
"eSwapType": "BUY",
"eSwapValueType": "PERCENTAGE",
"nValue": 10,
"sTokenAddress": "…",
"aResults": [
{ "sWalletAddress": "wallet1", "signature": "3k…", "success": true },
{
"sWalletAddress": "wallet2",
"signature": null,
"success": false,
"reason": "insufficient SOL",
"required": 5050000,
"current": 0
}
],
"stats": { "requested": 2, "eligible": 1, "succeeded": 1, "failed": 1 }
}

reason values​

ReasonMeaning
swap failed on-chainTx submitted, rejected by network.
insufficient SOLBuy-side wallet didn't have enough SOL.
insufficient SOL for tx feesSell-side wallet can't cover fees.
insufficient token balanceSell-side wallet doesn't hold enough of the token.
wallet dropped during prepare stepDefensive fallback.

Top-level success is true when at least one wallet landed.

Errors​

StatusMeaning
400No wallet had enough balance to prepare the swap at all. Payload includes insufficientWallets, insufficientTokenWallets, and stats.
404One or more wallets not owned. Response includes missing.

Example​

curl -X POST "$BASE_URL/trading/swap" \
-H "Authorization: Bearer $ACCESS" \
-H "x-user-id: $USER_ID" \
-H "Content-Type: application/json" \
-d '{
"sTokenAddress": "…",
"aWalletAddresses": ["wallet1", "wallet2"],
"eSwapType": "BUY",
"eSwapValueType": "EXACT",
"nValue": 0.1
}'