# Fee

## How to calculate fee rate?

Fee means the coin used to pay the protocol fee rate during the transaction differs from the gas consumed by the execution of the smart contract. Different pools has different fee rate. Each tick spacing corresponds to a specific fee rate.

| tick spacing | fee rate |
| ------------ | -------- |
| 2            | 0.0001   |
| 10           | 0.0005   |
| 60           | 0.0025   |
| 200          | 0.01     |

1. For a single pathway, the fee is equal to the input amount multiplied by the fee rate.
2. In the case of multiple pathways or paths involving intermediary coins, we need to calculate the input amount multiplied by the fee rate for each individual swap. Then, convert all these amounts to the corresponding quantity in the input coin and sum them up.

In SDK, we provide `sdk.Swap.calculateSwapFee()` method.

#### Example

```ts
    const res = await sdk.RouterV2.getBestRouter(USDT, USDC, 100000000, true, 5, '', undefined, true, false)

    const fee =  sdk.Swap.calculateSwapFee(res.result.splitPaths)
    console.log('fee: ', fee)
```


---

# 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/via-sdk/features-available/fee.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.
