Plan a token-to-token swap
qmax_swap_quotePlans swapping one token for another as two linked trades: sell 'from' for QU (leg 1), then buy 'to' with the QU (leg 2), each routed across QX and QSwap by the best route. Read-only: nothing is signed.
Returns both quotes, 'upfrontQu' (QU the wallet must hold BEFORE leg 1 for its flat fees), 'expectedOutQty' (what you should get) and 'minOutQty' (guaranteed by the limits only if neither price moves past the slippage limit), plus warnings. Leg 2 can only be sized exactly after leg 1 settles, from the wallet's real balance, so a swap is never one atomic transaction: if leg 1 completes and leg 2 cannot proceed you are left holding QU. Both tokens must trade on QX or QSwap; QU itself is not a swap leg (use qmax_get_quote).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | Token to buy | |
| qty | Yes | How many units of 'from' to sell | |
| from | Yes | Token to sell | |
| compare | No | Also plan the same swap forced onto each single market (QX or QSwap per leg) and say what QMax's route is worth against them (bestDeal). Slower. | |
| slippage_bps | No |