# Old swap params - V1

> **TIP**
>
> We have maintained compatibility with the old swap parameters in the new version of the SDK. This means that even if you make no changes to your code, simply upgrading the SDK version will allow it to function properly.

## 1. Build fast swap transaction.

This method will send swaped coins to user directly.. Here are two type fast swap params:&#x20;

**Params**

* **routers**(Router Object): The result from findRouter(), representing the path chosen for the swap.
* **byAmountIn**(boolean): The input params as the same as request in findRouter().
* **txb**(Transaction): The programmable transaction builder.
* **slippage:**(number): A value between 0 and 1, representing the maximum allowed price slippage as a percentage. A value of 0.01 allows up to 1% price slippage. This parameter is crucial for protecting your assets in a rapidly changing market.
* **isMergeTragetCoin**(boolean): If set to true, the output coins are merged into the existing coin object to prevent an indefinite increase in the number of coin types held.
* **refreshAllCoins**(Option(boolean)): If true, retrieves all coin types when setting up the swap; if false, uses the existing coins.
* **partner**(Option(string)): The partner address. [Details about partner can be found here.](/cetus-developer-docs/developer/via-sdk/features-available/partner-swap.md#partner)

**Example**

```typescript
import { AggregatorClient } from "@cetusprotocol/aggregator-sdk"
import { Transaction } from '@mysten/sui/transactions';
import BN from "bn.js"

const client = new AggregatorClient()

const amount = new BN(1000000)
const from = "0x2::sui::SUI"
const target = "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS"

const routers = await client.findRouters({
  from,
  target,
  amount,
  byAmountIn: true, // `true` means fix input amount, `false` means fix output amount
})

const txb = new Transaction()

await client.fastRouterSwap({
  routers: routerRes.routes,
  byAmountIn,
  txb,
  slippage: 0.01,
  isMergeTragetCoin: true,
  refreshAllCoins: true,
})
```

## 2. Build swap transaction and return target coin object.&#x20;

This method will build transaction and return coin objects, used to build ptb.&#x20;

**Params**&#x20;

* **routers**(Router Object): The result from findRouter(), representing the path chosen for the swap.
* **byAmountIn**(boolean): The input params as the same as request in findRouter().
* **inputCoin**(TransactionObjectArgument): This represents the input coin object. If you only support swaps with a fixed input, simply extract a fixed amount from the coin object. If you support fixed output, you need to extract an amount limited by the specified constraints from the coin object.&#x20;
* **txb**(Transaction): The programmable transaction builder.&#x20;
* **slippage**:(number): A value between 0 and 1, representing the maximum allowed price slippage as a percentage. A value of 0.01 allows up to 1% price slippage. This parameter is crucial for protecting your assets in a rapidly changing market.&#x20;
* **partner**(Option(string)): The partner address. Details about partner can be found here.

**Example**

```typescript
import { AggregatorClient } from "@cetusprotocol/aggregator-sdk"
import { Transaction } from '@mysten/sui/transactions';
​import BN from "bn.js"

const client = new AggregatorClient()
​
const amount = new BN(1000000)
const from = "0x2::sui::SUI"
const target = "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS"
​
const routers = await client.findRouters({
  from,
  target,
  amount,
  byAmountIn: true, // `true` means fix input amount, `false` means fix output amount
})
​
const txb = new Transaction()
​
const targetCoin = await client.routerSwap({
  routers: routerRes.routes,
  byAmountIn: true,
  txb,
  inputCoin,
  slippage: 0.01,
})
​
// you can use this target coin object argument to build your ptb.
client.transferOrDestoryCoin(
    txb,
    targetCoin,
    target
)
```


---

# 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://cetus-1.gitbook.io/cetus-developer-docs/developer/cetus-aggregator/features-available/old-swap-params-v1.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.
