Skip to content
SwapWalletDocs
فارسیGet an API key

Swaps

A swap converts one token in your balance into another, including to and from the Toman (IRT). It settles at once: both balances change the moment the swap succeeds.

There are two ways to swap:

WayWhen to use it
Create a swapYou want it done now at the best current price. One request.
Get a swap quote, then execute itYou want to see the exact amounts first. The quote locks the price for 60 seconds.

In every swap request, set exactly one of the two amounts:

  • sourceAmount: sell exactly this much of sourceToken.
  • destinationAmount: receive exactly this much of destinationToken.

The fee is part of the price, so the trade’s exchangeFee is always 0 and marketRate is the rate you actually got.

You can hold only one quote at a time. Getting a new quote, or creating a swap, cancels your previous quote.

The Quote object

A locked price for a swap. Execute it with its swapToken within 60 seconds.

Attributes

  • swapTokenstring (UUID)Required
  • sourceMoneyRequired

    What you’ll give.

    Show child attributesHide child attributes
    • numberdecimal stringRequired

      The amount as a decimal string. Trailing zeros are dropped, so 0.5, not 0.50.

    • unitstringRequired

      The token symbol, such as USDT, TON or BTC. IRT is the Toman; USD marks a value in US dollars.

  • destinationMoneyRequired

    What you’ll receive.

    Show child attributesHide child attributes
    • numberdecimal stringRequired

      The amount as a decimal string. Trailing zeros are dropped, so 0.5, not 0.50.

    • unitstringRequired

      The token symbol, such as USDT, TON or BTC. IRT is the Toman; USD marks a value in US dollars.

  • marketRatenumberRequired

    Price of the market’s base token in its quote token, fee included. For USDT → TON, the price of one TON in USDT.

  • expiresInISO 8601 timestampRequired

    When the quote stops being executable: 60 seconds after it was made.

The Quote object
{
  "swapToken": "1bb2d955-5d39-450a-b9a2-d900387e09f0",
  "source": {
    "number": "100",
    "unit": "USDT"
  },
  "destination": {
    "number": "101.677",
    "unit": "TON"
  },
  "marketRate": 0.9835065944117155,
  "expiresIn": "2026-11-20T09:16:02.418Z"
}

Create a swap

POST/v1/market/otc/fast-swap

Swaps one token for another right away, at the best price available at that moment, with no separate confirmation. Use it when you don’t need to review the amounts first.

The price isn’t known until the swap is done, so read the actual amounts from the returned transaction.

Body parameters

  • sourceTokenstringRequired

    Token you give, such as USDT, or IRT for the Toman.

  • destinationTokenstringRequired

    Token you receive.

  • sourceAmountdecimal stringnullable

    Sell exactly this much of sourceToken. Send this or destinationAmount, not both.

    A positive number

  • destinationAmountdecimal stringnullable

    Receive exactly this much of destinationToken. Send this or sourceAmount, not both.

    A positive number

Returns

Returns the Transaction object of the swap, with type TRADE and status SUCCEED.

Errors

  • 400INVALID_SWAP_AMOUNT

    Both amounts were sent, or neither.

  • 400VALIDATION_FAILED

    An amount isn’t a positive number.

  • 400INSUFFICIENT_USER_BALANCE

    Your sourceToken balance doesn’t cover the swap.

  • 400MINIMUM_TRADE_DIDNT_MEET

    The amount is below the smallest tradable amount.

  • 404MARKET_NOT_FOUND

    There is no market between these two tokens.

  • 404MARKET_IS_NOT_ACTIVE

    Trading on this market is paused right now.

POST/v1/market/otc/fast-swap
curl -X POST https://swapwallet.app/api/v1/market/otc/fast-swap \
  -H "Authorization: Bearer $SWAPWALLET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "sourceToken": "USDT",
  "destinationToken": "TON",
  "sourceAmount": "100"
}'
Response
{
  "status": "OK",
  "result": {
    "id": 3051877,
    "supportCode": "SW-PGE4VWR-YJAX",
    "timestamp": 1795166131000,
    "type": "TRADE",
    "status": "SUCCEED",
    "network": "INTERNAL",
    "exchangeFee": {
      "number": "0",
      "unit": "TON"
    },
    "trade": {
      "market": "TON/USDT",
      "side": "BUY",
      "type": "OTC",
      "sourceAmount": {
        "number": "100",
        "unit": "USDT"
      },
      "sourceValue": {
        "number": "100",
        "unit": "USD"
      },
      "sourceUserCurrencyValue": {
        "number": "27240000",
        "unit": "IRT"
      },
      "destinationAmount": {
        "number": "101.677",
        "unit": "TON"
      },
      "destinationValue": {
        "number": "99.64346",
        "unit": "USD"
      },
      "destinationUserCurrencyValue": {
        "number": "27142878",
        "unit": "IRT"
      },
      "marketRate": "0.98350659441171553055263235539994"
    }
  }
}

Get a swap quote

POST/v1/market/otc/price

Prices a swap and locks that price for 60 seconds. Show the amounts to your user or check them in code, then pass swapToken to Execute a quoted swap.

A new quote cancels the previous one. With createSwapToken set to false you get the amounts only: the returned swapToken can’t be executed, but the previous quote is still canceled.

Body parameters

  • sourceTokenstringRequired

    Token you give.

  • destinationTokenstringRequired

    Token you receive.

  • sourceAmountdecimal stringnullable

    Sell exactly this much. Send this or destinationAmount, not both.

    A positive number

  • destinationAmountdecimal stringnullable

    Receive exactly this much. Send this or sourceAmount, not both.

    A positive number

  • createSwapTokenboolean

    Set to false to see the amounts without locking a price you can execute.

    Default: true

Returns

Returns a Quote object in result.

Errors

  • 400INVALID_SWAP_AMOUNT

    Both amounts were sent, or neither.

  • 400VALIDATION_FAILED

    An amount isn’t a positive number.

  • 404MARKET_NOT_FOUND

    There is no market between these two tokens.

  • 404MARKET_IS_NOT_ACTIVE

    Trading on this market is paused right now.

  • 429TOO_MANY_REQUESTS

    More than 30 quotes in a minute.

POST/v1/market/otc/price
curl -X POST https://swapwallet.app/api/v1/market/otc/price \
  -H "Authorization: Bearer $SWAPWALLET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "sourceToken": "USDT",
  "destinationToken": "TON",
  "sourceAmount": "100"
}'
Response
{
  "status": "OK",
  "result": {
    "swapToken": "1bb2d955-5d39-450a-b9a2-d900387e09f0",
    "source": {
      "number": "100",
      "unit": "USDT"
    },
    "destination": {
      "number": "101.677",
      "unit": "TON"
    },
    "marketRate": 0.9835065944117155,
    "expiresIn": "2026-11-20T09:16:02.418Z"
  }
}

Execute a quoted swap

POST/v1/market/otc/order

Executes the swap from a quote, at exactly the quoted amounts. Call it within 60 seconds of getting the quote; after that, get a new one.

The response only confirms success. To read the resulting trade, list your transactions with types=TRADE.

Body parameters

  • swapTokenstring (UUID)Required

    swapToken from the quote.

Returns

Returns {"status": "OK"} once the swap is done.

Errors

  • 400SWAP_ORDER_EXPIRED

    More than 60 seconds have passed since the quote.

  • 404MARKET_ORDER_REQUEST_NOT_FOUND

    The token is unknown, already used, or canceled by a newer quote or swap.

  • 400INSUFFICIENT_USER_BALANCE

    Your balance no longer covers the swap.

  • 400MINIMUM_TRADE_DIDNT_MEET

    The amount is below the smallest tradable amount.

  • 404MARKET_IS_NOT_ACTIVE

    Trading on this market was paused after the quote.

POST/v1/market/otc/order
curl -X POST https://swapwallet.app/api/v1/market/otc/order \
  -H "Authorization: Bearer $SWAPWALLET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "swapToken": "1bb2d955-5d39-450a-b9a2-d900387e09f0"
}'
Response
{
  "status": "OK"
}