/api/v1/router/swap/generate
user
User's public key
input
Input can be either token address or pool address. If token address is provided then the best pool will be selected. If pool address is provided then that pool will be used
2kmgscz3mCNgBxWX1Ck4pBmRcXpf5iV8umK417wRpump
direction
Direction of the trade. Buy = stablecoin -> shitcoin. Sell = shitcoin -> stablecoin. Stablecoin is SOL, USDC, USDT, USD1
TRADE_DIRECTION_BUY
amount
Amount is the trade amount. It can be specific amount: e.g. "10" (10 USDC or 10 SHITCOIN), "0.5" (0.5 SOL). Or percentage of the user's balance: e.g. "10%" (10 percent of user's balance). If percentage input is used then the input MUST contain '%' at the end. If trade direction is BUY then the amount is in stablecoin. If trade direction is SELL then the amount is in shitcoin
0.1 / 100%
settings
Swap settings for the transaction. Fee is the priority fee of the transaction in SOL. Tip is the tip of the transaction in SOL. Slippage is the maximum slippage percentage allowed for the trade
nonceAccount
Nonce Account is the optional nonce account address to use for the transaction. Even if its optional - this is the best way to ensure maximum transaction reliability. If not provided then recent blockhash will be used
unsignedTransactions
Transactions is the list of unsigned transactions (base64) to be signed and submitted by the user. If nonce account is used it is safe to sign and submit all transactions using SwapSubmit. If recent blockhash is used then only 1 transaction can be submitted (otherwise you can risk all of them successfully being processed)
TRADE_DIRECTION_UNSPECIFIEDPossible values: A successful response.
An unexpected error response.
POST /api/v1/router/swap/generate HTTP/1.1
Host:
Content-Type: application/json
Accept: */*
Content-Length: 152
{
"user": "text",
"input": "text",
"direction": "TRADE_DIRECTION_UNSPECIFIED",
"amount": "text",
"settings": {
"fee": 1,
"tip": 1,
"slippage": 1
},
"nonceAccount": "text"
}{
"transactions": [
{
"unsignedTransaction": "text"
}
]
}Last updated

