Skip to main content
The Soroswap API can route a swap through the Stellar classic DEX (SDEX, the order book and classic liquidity pools) as well as through the Soroban venues the aggregator executes. SDEX works differently from the other venues in three ways, and an integration has to handle all three.
  1. SDEX is opt-in. It is quoted only when "sdex" is in protocols.
  2. An SDEX quote is not an aggregator call. It comes back with "platform": "sdex" and is executed as a classic path payment.
  3. A contract cannot execute it. A path payment is a classic operation signed by a G... account. It cannot run inside a Soroban contract call.

SDEX is quoted only when you ask for it

/quote looks at the venues listed in protocols and nothing else. If "sdex" is not in the list, the API never asks SDEX for a price, and no quote will ever come back with "platform": "sdex".
When "sdex" is present together with Soroban venues, the API prices both in parallel and returns one of them: the one with the higher amountOut for EXACT_IN, or the lower amountIn for EXACT_OUT. A single quote never mixes SDEX and Soroban hops. To compare them yourself, send two quotes, one with ["sdex"] and one without it. GET /protocols?network=mainnet returns every value protocols accepts.
SDEX trades classic Stellar assets only. A token that exists only as a Soroban contract, with no classic issuer behind it, has no SDEX market, and a quote with ["sdex"] alone returns 400 for it. Keep the Soroban venues in protocols so those pairs still route.

Read platform before you execute

Every quote carries platform, and rawTrade has a different shape on each. An SDEX quote looks like this:
The top-level amountIn and amountOut are stroops, as on every quote. The amounts inside an SDEX rawTrade are decimal strings, the way Horizon returns them. source_amount is already net of the fee, which is charged on the input asset. An SDEX rawTrade has no distribution, so code that expects one will fail on it.

Executing an SDEX quote

Send the quote to /quote/build with a G... account as from. The API returns a classic transaction XDR with the path payment and, on mainnet, one extra payment operation carrying the fee. Sign it with from and submit it to the Stellar network.
SDEX swaps pay the same fee as aggregated swaps, partner fee included. See Fees and revenue share. Building the SDEX transaction through /quote/build is what puts the fee operation in it.

If your integration calls the aggregator from a contract

Integrations that take rawTrade.distribution from /quote and pass it to the aggregator from their own router contract, or that swap for a smart wallet (C... address), can only execute aggregator quotes. You have two options:
  • Leave "sdex" out of protocols. Every quote is then a Soroban route your contract can run. You lose the pairs where SDEX gives the better price.
  • Ask for "sdex" and branch on platform. When the quote is sdex, execute it as a separate classic transaction from a G... account through /quote/build, outside your contract. When it is aggregator, keep your current path.
/quote/build and /swap drop sdex automatically when from or to is a contract address, and return 400 if no other venue is left.

Checklist when you never see SDEX routes

  • "sdex" is in the protocols you send to /quote.
  • You read platform on the response, not only rawTrade.distribution.
  • Both assets are classic Stellar assets.
  • The from and to you pass to /quote/build are G... accounts.