메인 콘텐츠로 건너뛰기
POST
/
trade
/
swap
Execute trade via aggregator (EVM + Solana)
curl --request POST \
  --url https://api.afkcrypto.com/v1/trade/swap \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: <idempotency-key>' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "chain": "<string>",
  "fromToken": "<string>",
  "toToken": "<string>",
  "amount": "<string>",
  "from": "<string>",
  "slippage": 1,
  "includeGas": true,
  "protocols": "<string>",
  "excludeProtocols": "<string>"
}
'
{ "id": "tx_...", "status": "SUBMITTED", "hash": "0x...", "explorerUrl": "https://solscan.io/tx/...", "chainName": "Solana" }
네이티브 자산(ETH, SOL 등) 스왑 시 fromToken/toTokenNATIVE 키워드를 사용하세요. Idempotency-Key 헤더가 필요합니다. Solana 메인넷만 지원. EVM의 경우 허용량 오류로 스왑이 실패하면 먼저 토큰을 승인하세요.
{ "id": "tx_...", "status": "SUBMITTED", "hash": "0x...", "explorerUrl": "https://solscan.io/tx/...", "chainName": "Solana" }

인증

x-api-key
string
header
필수

헤더

Idempotency-Key
string<uuid>
필수

Provide a unique Idempotency-Key per user to ensure single submission.

본문

application/json
chain
string
필수

EVM chain slug.

fromToken
string
필수

Token or native address (0xEeee... for native)

toToken
string
필수

Output token address (0x...).

amount
string
필수

Amount in wei (decimal or 0x-hex supported for EVM).

from
string | null

Optional sender wallet; defaults to user's default wallet for the chain.

slippage
number
기본값:1

Percentage (e.g., 1 = 1%). Optional; defaults to 1%.

includeGas
boolean | null

Include gas estimates in the build (optional).

protocols
string | null

Comma-separated allowlist of protocols (optional).

excludeProtocols
string | null

Comma-separated blocklist of protocols (optional).

응답

Submission accepted

id
string
필수

AFK transaction id for the submitted action.

status
enum<string>
필수

Submission status.

사용 가능한 옵션:
SUBMITTED
hash
string | null
필수

On-chain transaction hash/signature (may be null at submission time).

explorerUrl
string | null
필수

Direct link to the transaction on a chain explorer. Null until a hash/signature exists.

chainName
string
필수

Human-readable chain name for display (e.g., Base, Ethereum, Solana).