- SDEX is opt-in. It is quoted only when
"sdex"is inprotocols. - An SDEX quote is not an aggregator call. It comes back with
"platform": "sdex"and is executed as a classic path payment. - 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".
"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:
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.
/quote/build is
what puts the fee operation in it.
If your integration calls the aggregator from a contract
Integrations that takerawTrade.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 ofprotocols. 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 onplatform. When the quote issdex, execute it as a separate classic transaction from aG...account through/quote/build, outside your contract. When it isaggregator, 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 theprotocolsyou send to/quote.- You read
platformon the response, not onlyrawTrade.distribution. - Both assets are classic Stellar assets.
- The
fromandtoyou pass to/quote/buildareG...accounts.