---
title: "Plan a token-to-token swap: sell one token for QU, then buy another with that QU"
method: POST
path: "/v1/swap-quote"
---

# Plan a token-to-token swap: sell one token for QU, then buy another with that QU

`POST /v1/swap-quote`

## Request

- Base URL: `https://qmax.exchange/api`
- URL: `https://qmax.exchange/api/v1/swap-quote`
- Auth: none declared

Two trades run one after the other, each on QMax's best route (QX, QSwap or a split). Leg 2 is sized so that its worst case (the QU its signed limits can take) fits the LEAST leg 1 can pay within its limits, less a small safety margin: that size is `minOutQty`. `expectedOutQty` is the size if leg 1 pays what it is expected to. `upfrontQu` must be in the wallet before leg 1: QSwap's flat 100,000 QU per sell call leaves before the proceeds arrive (share-management moves are not included, as the wallet is not known here). Nothing is signed or sent; leg 2 must be sized again from the wallet's real balance after leg 1 settles. Both legs are limit orders: a QX order that does not fill stays on the book.

## Request body

- object
  - `from` string, required: Asset id to sell, from /v1/assets
  - `to` string, required: Asset id to buy, from /v1/assets
  - `qty` integer, required: Units of `from` to sell
  - `slippageBps` integer: Price movement allowed on each leg
  - `compare` boolean: Also plan the same swap forced onto each single market (QX or QSwap for each leg) and say what QMax's route gains over the best of them (`bestDeal`). Slower: several plans.

## Response `200`

The plan: both quotes, expected and guaranteed amounts, QU needed up front, warnings and whether it can be signed

## Other responses

- `400`: Bad body, the same token twice, or QU as either side
- `404`: Unknown asset

---

[API](https://skmtc.dev/qmax/apis/qmax-api.md) · [All operations](https://skmtc.dev/qmax/apis/qmax-api/llms.txt) · [OpenAPI document](https://skmtc.dev/qmax/apis/qmax-api/revisions/af70e2813a7a?raw)
