> For the complete documentation index, see [llms.txt](https://docs.flowx.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flowx.finance/developer/flowx-sdk/multiple-swap-aggregator.md).

# Multiple Swap Aggregator

### Get Multiple Swap Router

To find best route for swap

```javascript
const quoter = new AggregatorQuoter('mainnet');
const singleQuoteQueryParams: SingleQuoteQueryParams = {
  tokenIn: '0x2::sui::SUI',
  tokenOut: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN',
  amountIn: '1000000000',
  includeSources: null, //optional
  excludeSources: null, //optional
  commission: null, //optional, and will be explain later
  maxHops: null, //optional: default and max is 3
  splitDistributionPercent: null, //optional: default 1 and max 100
  excludePools: null, //optional: list pool you want excude example: 0xpool1,0xpool2 
};

const multipleQuoteQueryParams: SingleQuoteQueryParams[] = [singleQuoteQueryParams, singleQuoteQueryParams2]

const routes = await quoter.getMultipleRoutes(multipleQuoteQueryParams);
```

{% hint style="info" %}
**Only support maximum 5 coin**
{% endhint %}

### Build Transaction for multiple aggregator swap

#### Normal case if you want fast swap

```javascript
const tradeBuilder = MultiTradesBuilder.fromRoutesGroups(
  routes.map((r) => r.routes)
);

const tx = tradeBuilder
  .sender('0xSenderAddress') //Optional if you want pass coin later
  .slippage((1 / 100) * 1e6) // Slippage 1%
  .commission(null) // Optional: commission will be explain later
  .build()
  .buildTransaction({ client });
```

#### Return coin for later use

```javascript
const tradeBuilder = MultiTradesBuilder.fromRoutesGroups(
  routes.map((r) => r.routes)
);
const tx = new Transaction();
const trade = tradeBuilder
  .sender('0xSenderAddress') //Optional if you want pass coin later
  .slippage((1 / 100) * 1e6) // Slippage 1%
  .commission(null) // Optional: commission will be explain later
  .build();
const coinOut = trade.swap({ client, tx }) 
```

#### Commission

[Swap Aggregator](/developer/flowx-sdk/swap-aggregator.md#commission)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flowx.finance/developer/flowx-sdk/multiple-swap-aggregator.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
