# Value Bot 监控

### Value Bot 监控是什么？

Value Bot 监控是针对数值变化而设计的一种监控类型。主要功能是监控某个对象的数值变化，当数值变化达到预设的阈值时，将会触发报警。

### Value Bot 监控典型场景

1. 监控 Token 余额变化
2. 监控 Curve 稳定币占比百分比的变化

#### 支持的数据源

| 数据源           | 类型       | 稳定性 |
| ------------- | -------- | --- |
| Ethereum      | on chain | 极高  |
| BSC           | on chain | 高   |
| Avalanche     | on chain | 高   |
| Polygon Pos   | on chain | 高   |
| Arbitrum      | on chain | 高   |
| Optimism      | on chain | 高   |
| Polygon zkEVM | on chain | 高   |
| ZkSync Era    | on chain | 高   |
| Base          | on chain | 高   |
| Scroll        | on chain | 高   |
| Manta         | on chain | 高   |
| ZKFair        | on chain | 高   |
| Blast         | on chain | 高   |
| Linea         | on chain | 高   |
| B2            | on chain | 高   |
| Merlin        | on chain | 高   |

### 如何配置 Value Bot 监控？

登录 ChainBot 平台后，右上角 "Create Bot" -> "Value Monitor"。

<figure><img src="/files/5VVNTNsyXkImUhtne8wV" alt=""><figcaption><p>Create a Value Bot</p></figcaption></figure>

**Info 说明**

<table><thead><tr><th width="183.33333333333331">字段名</th><th width="280">说明</th><th>是否必填</th></tr></thead><tbody><tr><td>Name</td><td>Bot 监控名</td><td>是</td></tr><tr><td>Chain</td><td>选定的 Chain</td><td>是</td></tr><tr><td>Contract</td><td>选定的智能合约地址</td><td>是</td></tr><tr><td>Function</td><td>选定的智能合约的方法</td><td>是</td></tr><tr><td>Interval</td><td>数据打点间隔，即每隔 interval 的时间，拉取一次配置的数据源的数据</td><td>是</td></tr><tr><td>Baseline Trigger</td><td>若勾选此项，则触发条件作为基线，当数值达到基线，后续满足条件也不会重复触发。只有离开基线后再次回归，才会再次触发。</td><td>是</td></tr><tr><td>Fields</td><td>需要处理的数值字段</td><td>是</td></tr><tr><td>Tags</td><td>Bot 监控 tags，利于搜索</td><td>是</td></tr></tbody></table>

#### Fields 说明

> 由多个 Field 字段组成，单独的 Field 是个对象，包含 field, formater 的类型。其中 formater 是
>
> 一段 js 代码，用户需要自己定义格式化最终数值的代码。

#### 内置的函数

<table><thead><tr><th width="305">Function Name</th><th>说明</th></tr></thead><tbody><tr><td>tokenPrice(symbol)</td><td>获取 token 的U本位价格，例如 tokenPrice('weth')</td></tr><tr><td>bot(botId)</td><td>引用特定的 Bot 的内容，例如 bot('1')</td></tr><tr><td>add(x,y)</td><td>x+y</td></tr><tr><td>sub(x,y)</td><td>x-y</td></tr><tr><td>mul(x,y)</td><td>x*y</td></tr><tr><td>div(x,y)</td><td>x/y &#x26;&#x26; y != 0</td></tr><tr><td>pow(x,y)</td><td>x^y</td></tr></tbody></table>

#### 支持的 U 计价的币种

> 自动获取 token U 本位价格，数据源来自链上流动性最高的交易对，后续将会支持更多的Token。

| Token  | Pool                                                                                      |
| ------ | ----------------------------------------------------------------------------------------- |
| WBTC   | [WBTC/BUSD](https://bscscan.com/address/0xF45cd219aEF8618A92BAa7aD848364a158a24F33)       |
| WETH   | [WETH/USDT](https://etherscan.io/address/0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852)      |
| WBNB   | [WBNB/BUSD](https://bscscan.com/address/0x58F876857a02D6762E0101bb5C46A8c1ED44Dc16)       |
| WMATIC | [WMATIC/USDC](https://polygonscan.com/address/0x6e7a5FAFcec6BB1e78bAE2A1F0B612012BF14827) |
| WAVAX  | [WAVAX/USDC](https://snowtrace.io/address/0xf4003F4efBE8691B60249E6afbD307aBE7758adb)     |
| WFTM   | [WFTM/USDC](https://ftmscan.com/address/0x2b4c76d0dc16be1c31d4c1dc53bf9b45987fc75c)       |
| CAKE   | [CAKE/USDC](https://bscscan.com/address/0xa39af17ce4a8eb807e076805da1e2b8ea7d0755b)       |

**Conditions 说明**

conditions 中的字段解析是动态的，会跟随配置的 Fields 的内容变化。其中 Condition 的 Key 为 Field 的内容，二者保持一致。condition 中的 value 为用户设置的阈值，最后比较的时候会使用 Field formater 后的 value 和 condition 中的 value 比较，因此用户在配置时，需要注意单位换算。

**模板变量说明**

| $subscription.name | 订阅名称，一般和 Bot 监控同名                     |
| ------------------ | ------------------------------------- |
| $block.height      | 区块高度                                  |
| $value.{}          | formater 后的数值，为动态解析，比如 $value.balance |
| $condition         | 所有 condition 内容专为字符串                  |
| $alert.time        | 区块时间                                  |

#### 默认告警模板

```
[{$bot.name}]
Block: {$block.height}
Values:{$value.values.ltv}
Condition: {$value.condition}
Time: {$alert.time}
```

[了解告警通知模板？](/zh/advanced-features/alarm-notification-template.md)

#### 通知消息示例

> \[ENS Governance ETH Balance > 35000 ETH]
>
> Block: 16046035
>
> Balance: 35335.915888
>
> Condition: (5m) balance last > 35000
>
> Time: 2022-11-25T17:14:30+08:00
>
> Created By [ChainBot.io](https://www.chainbot.io)

#### Value Bot 监控案例

[Value Bot 案例](/zh/bot-case/value-bot-demo.md)


---

# 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://docs.chainbot.io/zh/basic-usage/bots/value-bot.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.
