# 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
