> 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/additional-documents/meta-sdk.md).

# Meta SDK

MetaAggregatorSDK is a unified quoting and transaction builder for Sui-based DEX aggregators. It allows you to fetch the best swap route across multiple exchanges and build transactions for optimal trading.

### Features

* Aggregates quotes from multiple supported exchanges (Cetus, Bluefin, Aftermath, FlowX, etc.)
* Returns the best route based on output amount
* Supports custom exchange selection and slippage configuration
* **Flexible exchange selection:** Use `includeExchanges` option to specify which exchanges to use for quoting and routing

### Example

```typescript
import { MetaAgQuoter, Exchange } from '@flowx-finance/sdk';

// Use all supported exchanges
const quoter = new MetaAgQuoter('mainnet');

// Or specify only certain exchanges
const quoterCetusOnly = new MetaAgQuoter('mainnet', [Exchange.CETUS]);

const params = {
  tokenIn: '0x2::sui::SUI',
  tokenOut: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC',
  amountIn: '10000000000',
};

const quote = await quoter.getBestRoute(params);
const txb = new Transaction()
const { coinOut, tx } = await quoter.buildTransaction(txb, quote, sender, 0.01); //slippage 1%, 1/100 = 0.01
tx.transferObjects([coinOut], '0xAddesss');
```

### Methods

#### `getBestRoute(params: QuoteQueryParams): Promise<QuoteResult | null>`

Fetches the best swap route from all enabled exchanges.

* `params`: Object containing swap parameters:
  * `tokenIn`: Input token address.
  * `tokenOut`: Output token address.
  * `amountIn`: Amount to swap.
  * ...other query options.

**Returns:**\
A `QuoteResult` object with the best route, or `null` if no route is found.

***

#### `buildTransaction(tx: Transaction, quote: QuoteResult, sender: string, slippage: number, coinIn?: TransactionObjectArgument): Promise<any>`

Builds a Sui transaction for the given quote.

* `tx`: The transaction object to build on.
* `quote`: The best route quote returned from `getBestRoute`.
* `sender`: The sender address.
* `slippage`: Slippage in basis points.
* `coinIn` (optional): The input coin object. If not provided, it will be auto-selected except for Aftermath exchange.

**Returns:**\
An object containing the output coin and, for Aftermath, the updated transaction.

###


---

# 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/additional-documents/meta-sdk.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.
