> For the complete documentation index, see [llms.txt](https://cetus-1.gitbook.io/cetus-developer-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cetus-1.gitbook.io/cetus-developer-docs/developer/cetus-aggregator/features-available/old-swap-params-v2.md).

# Old swap params - V2

## 1. Build fast swap transaction

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

### BuildFastRouterSwapParamsV2

**Required** **Params**

<table><thead><tr><th width="146">Name</th><th width="176">Type</th><th>Details</th></tr></thead><tbody><tr><td><strong>routers</strong></td><td>RouterData Object</td><td>returned by find router method</td></tr><tr><td><strong>slippage</strong></td><td>Number</td><td>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.</td></tr><tr><td><strong>txb</strong></td><td>Transaction</td><td>The programmable transaction builder.</td></tr></tbody></table>

#### Optional parameters

<table><thead><tr><th width="204">Name</th><th width="121">Type</th><th width="422">Details</th></tr></thead><tbody><tr><td><strong>partner</strong></td><td>String</td><td>The partner address. <a href="/pages/5SzKTKu59rHqAp9sMYWL#partner">Details about partner can be found here.</a><br>You can now set the partner directly during client initialization. This parameter will soon be deprecated; please migrate your configuration.</td></tr><tr><td><strong>refreshAllCoins</strong></td><td>Boolean</td><td> If true, retrieves all coin types when setting up the swap; if false, uses the existing coins.</td></tr><tr><td><strong>payDeepFeeAmount</strong></td><td>Number</td><td>The deep amount for pay deep fee in deepbookv3 path. Currently, all pools that charge a swap fee are covered by Cetus.</td></tr></tbody></table>

### Example

<pre class="language-typescript"><code class="lang-typescript">import { AggregatorClient } from "@cetusprotocol/aggregator-sdk"
import { Transaction } from '@mysten/sui/transactions';
<strong>
</strong>const client = new AggregatorClient({})
<strong>
</strong><strong>const amount = new BN(1000000)
</strong>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,
  txb,
  slippage: 0.01,
})
</code></pre>

## 2. Build swap transaction and return target coin object

This method will build transaction and return coin objects, used to build ptb.

### **BuildRouterSwapParamsV2**

**Required** **Params**

<table><thead><tr><th width="146">Name</th><th width="176">Type</th><th>Details</th></tr></thead><tbody><tr><td><strong>routers</strong></td><td>RouterData Object</td><td>Returned by find router method</td></tr><tr><td><strong>inputCoin</strong></td><td>TransactionObjectArgument</td><td>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.</td></tr><tr><td><strong>slippage</strong></td><td>Number</td><td>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.</td></tr><tr><td><strong>txb</strong></td><td>Transaction</td><td>The programmable transaction builder.</td></tr></tbody></table>

#### Optional parameters

<table><thead><tr><th width="211">Name</th><th width="125">Type</th><th width="422">Details</th></tr></thead><tbody><tr><td><strong>partner</strong></td><td>String</td><td>The partner address. <a href="/pages/5SzKTKu59rHqAp9sMYWL#partner">Details about partner can be found here.</a><br>You can now set the partner directly during client initialization. This parameter will soon be deprecated; please migrate your configuration.</td></tr><tr><td><strong>refreshAllCoins</strong></td><td>Boolean</td><td> If true, retrieves all coin types when setting up the swap; if false, uses the existing coins.</td></tr><tr><td><strong>deepbookv3DeepFee</strong></td><td>TransactionObjectArgument</td><td>The deep fee obejct argument for pay deep fee in deepbookv3 path. Currently, all pools that charge a swap fee are covered by Cetus.</td></tr></tbody></table>

### Example

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

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,
  txb,
  inputCoin,
  slippage: 0.01,
})

// you can use this target coin object argument to build your ptb.
client.transferOrDestoryCoin(
    txb,
    targetCoin,
    target
)
```
