swap

Create Swap

Execute a token swap.

Fully gasless — the user never needs the source chain's native gas token. One unified call handles same-chain swaps, cross-chain swaps, and EVM↔Solana bridges, with bridging built in.

Use ?wait=true&timeout=60 to block until the swap completes instead of receiving a task_id.

Pass agent_id to trade from one of your own strategy wallets instead of the main one. To sell a position, set token_out to the chain's stablecoin. Selling the whole position (99.9% or more of the balance) removes that coin's stop-loss/take-profit orders automatically; a partial sell keeps them on the remaining amount. cancel_conditional_orders acts on token_out's orders, so it does not clear the sold coin's orders.

post/v1/swap

Request

  • Base URL
    https://api.fereai.xyz
  • URL
    https://api.fereai.xyz/v1/swap
  • Auth
    none declared

Query parameters

waitboolean

Block until task completes

timeoutinteger

Seconds to block when wait=true (max 90; the ~100s edge cuts longer waits — use wait=false + poll for longer).

Request body

agent_idstring nullable

Optional: one of your own agents (e.g. a strategy wallet) to trade from. Defaults to your main agent. An agent you don't own returns 404.

chain_id_ininteger required

Source chain ID.

chain_id_outinteger required

Destination chain ID. Same as chain_id_in for same-chain swaps.

token_instring required

Input token contract address.

token_outstring required

Output token contract address.

amountstring required

Amount in smallest unit (wei for EVM, lamports for Solana).

slippage_bpsinteger nullable

Slippage tolerance in basis points (50 = 0.5%).

dryrunboolean

Simulate the swap without executing on-chain.

cancel_conditional_ordersboolean nullable

Cancel existing stop-loss/take-profit orders for this token pair.

Example request

{
  "amount": "1000000000000000000",
  "chain_id_in": 8453,
  "chain_id_out": 8453,
  "dryrun": false,
  "slippage_bps": 50,
  "token_in": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
  "token_out": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
}

Response

Successful Response

task_idstring required

Celery task ID for the swap operation.

statusstring

Current task status.

messagestring

Human-readable status message.

poll_urlstring nullable

Relative URL to poll for task status.

resultunknown
notification_streamstring

SSE stream URL for real-time updates.

Example response

{
  "message": "Swap task queued successfully",
  "notification_stream": "/v1/notifications/stream",
  "poll_url": "/v1/tasks/d290f1ee-...",
  "status": "queued",
  "task_id": "d290f1ee-6c54-4b01-90e6-d701748f0851"
}

Changes

No recorded changes to this operation across all 1 revision of this API.