> ## Documentation Index
> Fetch the complete documentation index at: https://xoxno.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Routing algorithms

> How XOXNO allocates swap amounts across candidate DEX paths for MultiversX and Stellar quotes.

Use routing controls to cap path search, split count, and response size for swap quotes.

## Definition

The Aggregator builds candidate paths from the current pool snapshot, scores output for each path, and allocates the requested amount across one or more paths. The quote response reports the amount, price impact, and optional path breakdown.

## Decision Table

| Need                             | Parameter           | Use                                                           |
| -------------------------------- | ------------------- | ------------------------------------------------------------- |
| Fewer paths in the response      | `maxSplits`         | Lower it to reduce split count                                |
| Fewer hops per route             | `maxHops`           | Lower it when routes become too complex                       |
| Path details for UI or debugging | `includePaths=true` | Enable only when you need `paths[]`                           |
| MultiversX algorithm override    | `algorithm`         | Use `greedy`, `lagrangian`, or `hybrid`                       |
| Stellar direct-user comparison   | `platform=all`      | Compare Soroban and Classic planes; returns one winning quote |

## Algorithm Choices

| Algorithm    | Mechanics                                                                           | Use when                                                                   |
| ------------ | ----------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| `greedy`     | Allocates chunks to the highest-rate candidate path until marginal output declines. | You need bounded compute and can accept a local allocation result.         |
| `lagrangian` | Searches for a marginal-rate balance across active AMM paths.                       | You need a split allocation for a larger trade and can allow more compute. |
| `hybrid`     | Runs both paths and returns the larger output.                                      | You want the server default on MultiversX.                                 |

The Stellar Aggregator selects routing internally. Use `maxSplits`, `maxHops`, `platform`, and `includePaths` instead of an algorithm parameter.

## Worked Example

```bash theme={"system"}
curl "https://swap.xoxno.com/api/v1/quote?\
from=WEGLD-bd4d79&\
to=USDC-c76f1f&\
amountIn=1000000000000000000&\
maxSplits=3&\
maxHops=4&\
includePaths=true"
```

Verify the result:

* `amountOut` is present and non-zero.
* `paths` is present when `includePaths=true`.
* Each `paths[].splitPpm` value adds up to `1000000` across active paths.

## Edge Cases

| Case                             | Behavior                                                                   | Fix                                                                     |
| -------------------------------- | -------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| Quote exceeds transaction budget | The service may fail or degrade the route, depending on product.           | Lower `maxSplits` or `maxHops`.                                         |
| Reverse quote                    | Split support is product-specific; Stellar reverse quotes are single-path. | Keep `maxSplits=1` unless the endpoint documents split reverse support. |
| Missing path details             | `includePaths` defaults to `false` on quote endpoints.                     | Pass `includePaths=true`.                                               |

## Related Endpoints

* [MultiversX quote](/aggregator/quote)
* [Stellar quote](/stellar-aggregator/quote)
* [Quote freshness](/resources/quote-freshness)
