> For the complete documentation index, see [llms.txt](https://docs.chainbot.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chainbot.io/basic-usage/bots/dex-bot.md).

# DEX Bot Monitoring

### What is DEX Bot Monitoring?

DEX Bot Monitoring is a type of monitoring designed for DEX scenarios. Its main function is to monitor relevant events on decentralized exchanges (DEX).

### Typical Scenarios for DEX Bot Monitoring

1. Monitoring high-value transactions on a DEX
2. Monitoring significant liquidity removals on a DEX
3. Monitoring significant percentage changes in liquidity on a DEX
4. Monitoring liquidity thresholds on a DEX
5. Monitoring price fluctuations on a DEX

#### Supported Data Sources

| Data Source | Type     | Stability |
| ----------- | -------- | --------- |
| Ethereum    | on chain | Very High |
| BSC         | on chain | High      |
| Avalanche   | on chain | High      |
| Polygon PoS | on chain | High      |
| Arbitrum    | on chain | High      |
| Optimism    | on chain | High      |
| Base        | on chain | High      |
| ZKFair      | on chain | High      |
| Blast       | on chain | High      |

#### Supported Swaps

| Chain       | Dex                                  |
| ----------- | ------------------------------------ |
| Ethereum    | UniswapV2, UniswapV3, Sushiswap      |
| BSC         | Pancakeswap V2                       |
| Avalanche   | TraderJoe, Pangolin                  |
| Polygon PoS | UniswapV2, UniswapV3, MMF, Quickswap |
| Arbitrum    | UniswapV3, Sushiswap, Chronos        |
| Optimism    | UniswapV3                            |
| Base        | UniswapV3                            |
| ZKFair      | SideSwap                             |
| Blast       | Thruster                             |

### How to Configure DEX Bot Monitoring?

After logging in to the ChainBot platform, go to the upper right corner and select "Create Bot" -> "Dex Monitor".

<figure><img src="/files/AbwdEHbTQNpgOVBYs1Go" alt=""><figcaption><p>Create Dex Monitor</p></figcaption></figure>

**Info Description**

| Field Name | Description                             | Required |
| ---------- | --------------------------------------- | -------- |
| Name       | Bot monitoring name                     | Yes      |
| Chain      | Selected Chain                          | Yes      |
| Contract   | Selected smart contract address         | Yes      |
| Function   | Selected smart contract method          | Yes      |
| Tags       | Bot monitoring tags, helpful for search | Yes      |

#### Conditions Description

| Price     | Below                | Price of specified token in the dex is below the set threshold                                  |
| --------- | -------------------- | ----------------------------------------------------------------------------------------------- |
|           | Above                | Price of specified token in the dex is above the set threshold                                  |
|           | ChangeRisesRate      | Percentage increase in the price of the specified token in the dex                              |
|           | ChangeDropsRate      | Percentage decrease in the price of the specified token in the dex                              |
|           | ChangeRisesDropsRate | Percentage increase or decrease in the price of the specified token in the dex, monitoring both |
| Liquidity | Below                | Liquidity is below the set threshold                                                            |
|           | Above                | Liquidity is above the set threshold                                                            |
|           | ChangeRisesRate      | Percentage increase in liquidity of the specified pair in the dex                               |
|           | ChangeDropsRate      | Percentage decrease in liquidity of the specified pair in the dex                               |
|           | ChangeRisesDropsRate | Percentage increase or decrease in the liquidity of the specified pair in the dex               |
|           | WhaleAdd             | Large liquidity addition                                                                        |
|           | WhaleRemove          | Large liquidity removal                                                                         |
|           | WhaleAddRemove       | Large liquidity addition or removal                                                             |
| Swap      | WhaleSell            | Large sell                                                                                      |
|           | WhaleBuy             | Large buy                                                                                       |
|           | WhaleBuySell         | Large buy and sell                                                                              |

**Template Variables Description**

| $tokenBase.symbol    | Symbol of tokenBase, e.g., WBTC                                                       |
| -------------------- | ------------------------------------------------------------------------------------- |
| $tokenBase.decimals  | Decimals of tokenBase, e.g., 18                                                       |
| $tokenBase.address   | On-chain address of tokenBase                                                         |
| $tokenQuote.symbol   | Symbol of tokenQuote, e.g., WETH                                                      |
| $tokenQuote.decimals | Decimals of tokenQuote, e.g., 18                                                      |
| $tokenQuote.address  | On-chain address of tokenQuote                                                        |
| $tokenQuote.balance  | Balance of tokenQuote (only supported during liquidity changes)                       |
| $tokenIn.symbol      | Symbol of tokenIn, e.g., WBTC                                                         |
| $tokenIn.decimals    | Decimals of tokenIn, e.g., 18                                                         |
| $tokenIn.address     | On-chain address of tokenIn                                                           |
| $tokenOut.symbol     | Symbol of tokenOut, e.g., WETH                                                        |
| $tokenOut.decimals   | Decimals of tokenOut, e.g., 18                                                        |
| $tokenOut.address    | On-chain address of tokenOut                                                          |
| $dex.name            | Name of the DEX, e.g., Uniswap                                                        |
| $value               | Amount of target token exchanged in the dex                                           |
| $price               | Exchange price of the target token, valued in base token wei units                    |
| $priceUSD            | Exchange price of the target token, valued in USD                                     |
| $changed.duration    | Time range of the indicator change                                                    |
| $changed.rate        | Percentage rate of the indicator change                                               |
| $action              | Behaviour of the monitoring indicator, add (addition) / remove (removal) / buy / sell |

#### Terminology Description

1. tokenBase: The base token, e.g., in a WBTC/WETH trading pair, WBTC is the tokenBase.
2. tokenQuote: The token that prices the base token, e.g., in a WBTC/WETH trading pair, WETH is the tokenQuote.
3. tokenIn: In the dex, when using the swap function, swapping a for b, a is tokenIn and b is tokenOut. That is, putting token a into the liquidity pool and taking token b out of the liquidity pool. For example, when swapping WBTC/WETH, WBTC is tokenIn and WETH is tokenOut.
4. tokenBase, tokenQuote, tokenIn, tokenOut are all ERC20 tokens, therefore, they all have standard ERC20 methods like name, symbol, decimals, address.

#### Default Alert Templates

High-Value Swap - WhaleSwap

{% code overflow="wrap" lineNumbers="true" %}

```shell
[ 🐳 {$bot.name} ]
Pair: {$dex.tokenBase.symbol}/{$dex.tokenQuote.symbol} on {$dex.name}
Value: {$dex.value} USD
Action: {$dex.tokenIn.amount} {$dex.tokenIn.symbol} -> {$dex.tokenOut.amount} {$dex.tokenOut.symbol} at price {$dex.price} USD
Explore: {$chain.explore}/tx/{$tx.hash}
```

{% endcode %}

Large Liquidity - WhaleAdd/WhaleRemove/WhaleAdRemove

{% code overflow="wrap" lineNumbers="true" %}

```shell
[ 🐳 {$bot.name} ]
Pair: {$dex.tokenBase.symbol}/{$dex.tokenQuote.symbol} on {$dex.name}
Value: {$dex.value} USD
Action: {$dex.tokenIn.amount} {$dex.tokenIn.symbol} -> {$dex.tokenOut.amount} {$dex.tokenOut.symbol} at price {$dex.price} USD
Explore: {$chain.explore}/tx/{$tx.hash}
Created By ChainBot.org
```

{% endcode %}

Large Percentage Liquidity - WhaleAddPercent/WhaleRemovePercent/WhaleAddRemovePercent

{% code overflow="wrap" lineNumbers="true" %}

```shell
[ 🐳 {$bot.name} ]
Pair: {$dex.tokenBase.symbol}/{$dex.tokenQuote.symbol} on {$dex.name}
Value: {$dex.value} USD
Action: {$dex.action} more than {$dex.changed.rate}% liquidity to pool
Explore: {$chain.explore}/tx/{$tx.hash}
Created By ChainBot.org
```

{% endcode %}

Liquidity Threshold - Above/Below

{% code overflow="wrap" lineNumbers="true" %}

```shell
[ {$bot.name}  ]
📉📈 {$dex.tokenBase.symbol}/{$dex.tokenQuote.symbol} liquidity on {$dex.name} above/below {$dex.changed.rate} in the past {$dex.changed.duration}
current liquidity is {$dex.tokenQuote.balance} {$dex.tokenQuote.symbol}
```

{% endcode %}

Liquidity Fluctuation Ratio - ChangeRisesRate/ChangeDropsRate/ChangeRisesDropsRate

{% code overflow="wrap" lineNumbers="true" %}

```shell
[ {$bot.name}  ]
📉📈 {$dex.tokenBase.symbol}/{$dex.tokenQuote.symbol} liquidity on {$dex.name} {$dex.direction} {$dex.changed.rate} in the past {$dex.changed.duration}
current liquidity is {$dex.tokenQuote.balance} {$dex.tokenQuote.symbol}
```

{% endcode %}

Price Fluctuation - ChangeRisesRate/ChangeDropsRate/ChangeRisesDropsRate

{% code overflow="wrap" lineNumbers="true" %}

```shell
[ {$bot.name} ]
📉📈 {$dex.tokenBase.symbol}/{$dex.tokenQuote.symbol} price on {$dex.name} {$dex.direction} {$dex.changed.rate} in the past {$dex.changed.duration}
current price is {$dex.price} {$dex.tokenQuote.symbol}
```

{% endcode %}

Price Threshold Monitoring - Above/Below

{% code overflow="wrap" lineNumbers="true" %}

```shell
[ {$bot.name} ]
📉📈 {$dex.tokenBase.symbol}/{$dex.tokenQuote.symbol} price on {$dex.name} {$dex.direction} {$dex.setPrice}. 
current price {$dex.price} USD.
```

{% endcode %}

[Learn about alert notification templates?](https://github.com/ChainbotAI/doc-en/blob/master/advanced-features/alarm-notification-template/README.md)

#### Notification Message Example

> \[ 🐳 Whale swap on Uniswap ETH/USDT pool ]\
> Pair: WETH/USDT on UniswapV3\
> Value: 51.237884 USD\
> Action: 0.0404716445741972 WETH -> 51.237884 USDT at price 1266.019321405753878 USD\
> Explore: <https://etherscan.io/tx/0xef1cd8f1edfbfa7fc2efe74b814c3535c333921cedae9aaad66a9d969ab885b8>\
> Created By [ChainBot.io](https://www.chainbot.io)

#### Dex Bot Monitoring Cases

[Dex Bot Example](/bot-case/dex-bot-demo.md)
