Skip to content

Quote a direct swap

Compare complete ExactIn and ExactOut trades across supported pools.

Call GET /v1/swap/quote with inputMint, outputMint and amount. The API discovers indexed pools for that direct pair and compares native quotes. A pool address is returned in data.pool; it is not a request parameter. Both mints are required because an input mint alone cannot identify which asset you want to receive.

What makes a pool the best choice?

The engine evaluates the complete requested swap against each supported pool's current state. It accounts for the effective trade fee, available token reserves, price movement, active liquidity and tick crossings. It does not rank pools by their nominal fee or their raw liquidity field.

  • ExactIn: fix input atoms and choose the largest output after trade fees.
  • ExactOut: fix output atoms and choose the smallest gross input, including trade fees.
  • Ties: use the lexically smallest pool address for deterministic selection.
  • Incomplete fills: exclude a candidate that cannot fill the entire amount. Never return a partial quote as a complete swap.

A shallow 0.3% pool can beat a deeper 0.9% pool for a small order. For a larger order, price impact can make the deeper pool better even while both can fill it. At a still larger size, the shallow pool may no longer have enough liquidity. The preferred pool can therefore change with the amount and direction.

Selection currently uses one direct pool. It does not split an order across pools, route through intermediate mints or discover unrelated DEX programs.

Quote parameters

ParameterMeaning
inputMintBase58 SPL mint to sell.
outputMintBase58 SPL mint to receive; distinct from the input mint.
amountPositive u64 decimal string in token atoms. ExactIn uses input atoms; ExactOut uses output atoms.
swapModeExactIn by default, or ExactOut.
slippageBpsInteger basis points, 0–10000; defaults to 50 (0.5%).
takerOptional wallet context. An address is not proof that the caller controls it.

For example, with a six-decimal input token, amount=1000000&swapMode=ExactIn means one input token. With ExactOut, the same amount refers to the output token's decimals.

otherAmountThreshold is rounded down for minimum output in ExactIn and rounded up for maximum input in ExactOut. Financial quantities remain integer strings. fees[].kind=trade reports the total input trade fee, not an extra fee and not a breakdown between LPs and protocol beneficiaries. priceImpactPct is currently null; this does not mean zero price impact. Price movement is included in the native quote itself.

Freshness and supported policies

The indexer supplies candidate addresses. Pricing independently reloads each candidate from confirmed RPC accounts, including its pool, mints, vaults, tick directory and required tick pages. Account dependencies are rediscovered and fetched together before evaluation. The RPC genesis must match the configured chain.

Candidates can be evaluated at different slots. contextSlot belongs to the selected candidate; this is not a simultaneous market-wide snapshot. expiresAt is 10 seconds after selection starts; an expired comparison fails instead of returning an old quote. It is a short validity hint, not a reservation or settlement guarantee. Requote before execution if the state or amount has changed.

The native API bridge currently quotes unhooked pools. Hook pools stay discoverable, but do not participate until their policy adapter is wired into this bridge. The underlying Metis adapter interface supports injected hook adapters; this HTTP bridge does not yet install them. A hook is never silently ignored.

Build, order and submit have documented contracts but still return 503 TRADING_NOT_CONFIGURED until the execution bridge is connected. A successful quote does not imply a transaction was built, signed or sent.

Errors

Status and codeMeaning
400 VALIDATIONInvalid or unknown parameters, identical mints or an invalid amount.
404 NO_POOLSThe indexed catalog contains no direct pool for the pair.
422 NO_QUOTABLE_POOLNo supported candidate can fill the complete requested amount.
422 TOO_MANY_POOLSMore than 50 indexed candidates; the API rejects instead of claiming an arbitrary truncated subset is best.
422 AMOUNT_OVERFLOWThe slippage-adjusted input threshold exceeds u64.
429 QUOTA_EXCEEDEDThe team request budget is exhausted.
503Required configuration, RPC, coherent snapshot or worker is unavailable. No partial candidate ranking is returned after a provider failure.

An empty discovery list is a successful 200 response. A quote for that same absent pair returns 404 NO_POOLS.

See API Reference for the generated request and response contract.