# Processor Swap Cetus

This Processor enables token swaps from a Cetus pool. The swap is executed using the [Cetus SDK](https://cetus-1.gitbook.io/cetus-developer-docs/developer/via-sdk/getting-started).

Libraries used in the swap Processor code:

| Library name                                                                                         | Version |
| ---------------------------------------------------------------------------------------------------- | ------- |
| [@cetusprotocol/cetus-sui-clmm-sdk](https://www.npmjs.com/package/@cetusprotocol/cetus-sui-clmm-sdk) | 5.1.10  |
| [@mysten/sui](https://www.npmjs.com/package/@mysten/sui)                                             | 1.2.1   |

{% hint style="info" %}
Note: This Processor only swaps within a single pool and does not use an aggregator to swap across multiple pools. Therefore, you must configure the pool address for the swap.
{% endhint %}

<figure><img src="https://content.gitbook.com/content/56Mr5hKBuQpU8OOb4JWG/blobs/24ztQ1DqU9A9UroHlHiO/swap_cetus.png" alt="" width="375"><figcaption><p>Example: Swapping HIPPO tokens to SUI</p></figcaption></figure>

In the example above, the configuration swaps HIPPO tokens to SUI using the [HIPPO/SUI](https://dexscreener.com/sui/0xb785e6eed355c1f8367c06d2b0cb9303ab167f8359a129bb003891ee54c6fce0) pool on the Sui network.

Configuration meanings:

<table><thead><tr><th width="233.84375">Field name</th><th width="119.68359375"> Required?</th><th>Detail</th></tr></thead><tbody><tr><td>Variable name for storing result</td><td>Yes</td><td>This Processor will output the transaction hash of the swap. You can choose a variable name to store the transaction hash. For example: <code>TX_HASH_SWAP_TOKEN_EVMN_CETUS</code></td></tr><tr><td>Private key</td><td>Yes</td><td>This is the private key of the wallet performing the transaction. Each Profile has a default variable for storing the private key, so you can use the default variable <code>WALLET_PRIVATE_KEY</code></td></tr><tr><td>Node endpoint group</td><td>Yes</td><td>Select the node provider to interact with the blockchain</td></tr><tr><td>Pool address</td><td>Yes</td><td>The address of the pool you want to swap</td></tr><tr><td>Input token address</td><td>Yes</td><td>A pool contains two tokens. Here, you enter the address of the token you want to swap from. For example, if you want to swap HIPPO for SUI (sell HIPPO), input the address of the HIPPO token in this field</td></tr><tr><td>Output token address</td><td>Yes</td><td>Enter the address of the token you want to receive after the swap. For example, if you are swapping HIPPO for SUI (selling HIPPO), input the address of the SUI token here</td></tr><tr><td>Input token amount</td><td>Yes</td><td>Enter the amount of tokens you want to sell. For example, if you want to sell 1,000 HIPPO for SUI, enter <code>1000</code></td></tr><tr><td>Slippage tolerance (%)</td><td>Yes</td><td>Maximum slippage for swaps. For pools with low price volatility, you should set this value low (e.g., 0.3%, 0.5%). For pools with high price volatility over short periods, set a higher value to increase the likelihood of a successful swap</td></tr><tr><td>Max price impact (%)</td><td>Yes</td><td>Maximum price impact for swaps. For pools with high liquidity, you should set this value low (e.g., 0.3%, 0.5%). For pools with low liquidity, you may choose a higher value</td></tr><tr><td>Gas price (MIST)</td><td>No</td><td>Gas price for executing the transaction. If you do not specify a value, the gas price will default to the current average on the chain. For best results, it is recommended to set the gas price to increase the likelihood of a successful swap transaction</td></tr><tr><td>Total number of transaction</td><td>Yes</td><td>The minimum value is 1. If you enter a value greater than 1, such as <code>10</code>, this Processor will execute 10 swap transactions in a single batch. Unlike EVM or Solana, transactions interacting with the same token on Sui are processed sequentially—each transaction must be confirmed before the next one is executed</td></tr><tr><td>Wait for the transaction to be confirmed?</td><td>No</td><td>If you enable this option, the Processor will wait for the swap transaction to be confirmed before proceeding to the next Processor. If you leave it unchecked, the Processor will broadcast the swap transaction without waiting for confirmation and immediately move on to the next Processor</td></tr></tbody></table>

#### How to select the Gas Price (MIST) for the Processor <a href="#cach-chon-gas-limit-gas-price" id="cach-chon-gas-limit-gas-price"></a>

If you want your transaction to be mined faster by competing on gas, you can manually set the `Gas Price (MIST)` for the Processor.

For example, if you want to swap tokens in the [HIPPO/SUI](https://dexscreener.com/sui/0xb785e6eed355c1f8367c06d2b0cb9303ab167f8359a129bb003891ee54c6fce0) pool, review several recent transactions to see their Gas Price (in MIST). This will help you select an appropriate value for the Processor.

Using the following transaction as a reference: <https://suivision.xyz/txblock/9DMcpyu7WrHBQiRiBNEHNgAVfKVCDzehqSFbHEDiCrTu>, navigate to the Gas Price section to see the value used. Based on this, you can set the Gas Price (in MIST) to 750 for the Processor.

<figure><img src="https://content.gitbook.com/content/56Mr5hKBuQpU8OOb4JWG/blobs/KFXOh59cv4I79GDCUYOa/sui_gas_price.png" alt=""><figcaption><p>Ví dụ lấy Gas price</p></figcaption></figure>
