Xpersona
D

DEX Price Monitor DEX价格监控

CLAWHUB · Unverified

DEX价格监控与差价追踪助手。当用户需要实时监控多个DEX的代币价格、发现套利价差、设置价格预警、分析价格趋势或获取最优交易路径时使用。支持Uniswap、SushiSwap、Curve等主流DEX,涵盖以太坊、Arbitrum、BSC等多链生态的价格监控。

62
Rank
84
Safety
1.1k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s176scxxt9cxw1s0gqyexga8hd83qc4r:shenmeng-dex-price-monitor
  1. Install using `clawhub skill install s176scxxt9cxw1s0gqyexga8hd83qc4r:shenmeng-dex-price-monitor` in an isolated environment before connecting it to live workloads.
  2. No published capability contract is available yet, so validate auth and request/response behavior manually.
  3. Review the upstream CLAWHUB listing at https://clawhub.ai/shenmeng/shenmeng-dex-price-monitor before using production credentials.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-shenmeng-shenmeng-dex-price-monitor/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

148,528 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: dex-price-monitor
description: DEX价格监控与差价追踪助手。当用户需要实时监控多个DEX的代币价格、发现套利价差、设置价格预警、分析价格趋势或获取最优交易路径时使用。支持Uniswap、SushiSwap、Curve等主流DEX,涵盖以太坊、Arbitrum、BSC等多链生态的价格监控。
---

# DEX Price Monitor DEX价格监控

> 💰 **本 Skill 已接入 SkillPay 付费系统**
> - 每次调用费用:**0.01 USDT**
> - 支付方式:BNB Chain USDT
> - 请先确保账户有足够余额

帮助用户实时监控DEX代币价格,发现套利机会,设置价格预警。

## 核心能力

1. **实时价格监控** — 多DEX价格同步追踪
2. **价差发现** — 自动识别套利机会
3. **价格预警** — 目标价提醒、价差阈值通知
4. **历史分析** — 价格走势、波动率统计
5. **最优路径** — 最优交易路径推荐
6. **监控工具** — 脚本模板、配置文件

## 适用场景

| 场景 | 示例 |
|------|------|
| **套利监控** | "监控ETH在Uniswap和SushiSwap的价差" |
| **价格预警** | "ETH涨到4000美元提醒我" |
| **多DEX对比** | "哪个DEX的USDC汇率最好?" |
| **趋势分析** | "过去一周ETH价格波动如何?" |
| **实时追踪** | "实时显示BTC在各大DEX的价格" |
| **最优交易** | "买100个ETH哪里最划算?" |

## 监控框架

### 监控维度

**1. 单代币多DEX监控**
```
代币: ETH
监控DEX:
- Uniswap V3 (以太坊)
- SushiSwap (以太坊)
- Curve (以太坊)
- Uniswap V3 (Arbitrum)
- SushiSwap (Arbitrum)

输出: 实时价格对比表
```

**2. 多代币监控**
```
代币列表:
- ETH/USDC
- WBTC/USDC
- LINK/USDC
- UNI/USDC

输出: 价格矩阵
```

**3. 价差监控**
```
监控条件:
- 价差 > 0.5%
- 价差 > 1%
- 价差 > 2%

通知方式:
- 控制台输出
- 日志记录
- Webhook推送
```

### 监控频率

| 频率 | 适用场景 | 资源消耗 |
|------|----------|----------|
| 实时 (WebSocket) | 高频套利 | 高 |
| 5秒 | 活跃监控 | 中 |
| 30秒 | 一般监控 | 低 |
| 5分钟 | 趋势追踪 | 极低 |

## 价格数据源

### 链上数据源

**1. The Graph (推荐)**
```graphql
# Uniswap V3 查询示例
{
  pools(where: {token0_: {symbol: "ETH"}}) {
    id
    token0Price
    sqrtPriceX96
    volumeUSD
    feeTier
  }
}
```

**2. DEX API**
```
1inch API: https://api.1inch.io/
0x API: https://api.0x.org/
ParaSwap API: https://api.paraswap.io/
```

**3. 聚合器**
```
CoinGecko: https://api.coingecko.com/
CoinMarketCap: https://pro-api.coinmarketcap.com/
CryptoCompare: https://min-api.cryptocompare.com/
```

**4. 直接合约查询**
```solidity
// Uniswap V3 slot0
function getPrice(address pool) view returns (uint256 price) {
    (uint160 sqrtPriceX96,,,,,,) = IUniswapV3Pool(pool).slot0();
    price = uint256(sqrtPriceX96) ** 2 / 2**192;
}
```

### 数据质量对比

| 数据源 | 实时性 | 准确性 | 成本 | 稳定性 |
|--------|--------|--------|------|--------|
| The Graph | ⭐⭐⭐ | ⭐⭐⭐⭐ | 免费 | 高 |
| 1inch API | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | 免费/付费 | 高 |
| CoinGecko | ⭐⭐ | ⭐⭐⭐ | 免费/付费 | 中 |
| 直接合约 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | Gas | 极高 |

## 价格预警系统

### 预警类型

**1. 目标价预警**
```
条件: ETH > $4,000
通知: "ETH突破4000美元!"

适用: 买入/卖出决策
```

**2. 价差预警**
```
条件: Uniswap vs SushiSwap 价差 > 1%
通知: "发现套利机会!"

适用: 搬砖套利
```

**3. 波动率预警**
```
条件: 1小时波动 > 5%
通知: "ETH剧烈波动!"

适用: 风险管理
```

**4. 异常检测**
```
条件: 某DEX价格偏离 > 3%
通知: "可能存在异常!"

适用: 发现bug/攻击
```

### 通知渠道

```
✓ 控制台输出
✓ 本地日志
✓ Telegram Bot
✓ Discord Webhook
✓ 邮件通知
✓ 短信(严重预警)
```

## 价差分析

### 价差计算

```
绝对价差 = Price_A - Price_B
相对价差 = (Price_A - Price_B) / Price_B * 100%

示例:
Uniswap: $3,500
SushiSwap: $3,520

绝对价差: $20
相对价差: 0.57%
```

### 价差趋势

```
监控指标:
- 当前价差
- 1小时平均价差
- 24小时最大价差
- 价差标准差(波动率)
```

### 盈亏平衡点

```
最小可套利价差 = Gas成本/本金 + 协议费 + 滑点

示例($10K本金,以太坊):
= $50/$10000 + 0.6% + 0.3%
= 0.5% + 0.6% + 0.3%
= 1.4%

结论: 价差需 > 1.4% 才有利可图
```

## 历史分析

### 价格统计

```
时间范围: 24h / 7d / 30d

指标:
- 最高价 / 最低

_meta.json

{
  "ownerId": "kn71568gr0p3240v36pag6f7rx83qbb2",
  "slug": "shenmeng-dex-price-monitor",
  "version": "2025.4.12",
  "publishedAt": 1775974371528
}

references/alert-configuration.md

# 预警配置指南

## 预警类型

### 1. 价格阈值预警

**目标价突破**:
```python
alert_config = {
    'type': 'price_threshold',
    'token': 'ETH/USDC',
    'condition': 'above',  # above / below
    'price': 4000,
    'message': 'ETH突破$4000!'
}
```

**使用场景**:
- 达到目标买入价
- 达到目标卖出价
- 突破关键支撑/阻力位

### 2. 价差预警

**DEX价差**:
```python
alert_config = {
    'type': 'spread_threshold',
    'token': 'ETH/USDC',
    'dex1': 'Uniswap V3',
    'dex2': 'SushiSwap',
    'threshold': 0.8,  # 0.8%
    'message': '发现套利机会!'
}
```

**使用场景**:
- 搬砖套利
- 发现定价错误
- 流动性异常

### 3. 波动率预警

**价格剧烈波动**:
```python
alert_config = {
    'type': 'volatility',
    'token': 'ETH/USDC',
    'timeframe': '1h',  # 1h / 24h
    'threshold': 5,  # 5%
    'message': 'ETH剧烈波动!'
}
```

**使用场景**:
- 市场异常
- 重大新闻
- 风险提示

### 4. 异常检测预警

**价格偏离**:
```python
alert_config = {
    'type': 'anomaly',
    'token': 'ETH/USDC',
    'baseline': 'median',  # median / mean / vwap
    'deviation': 3,  # 3%
    'message': 'ETH价格异常!'
}
```

**使用场景**:
- 数据源错误
- 合约被攻击
- 大额操纵

## 通知渠道配置

### Telegram

**创建Bot**:
1. 找 @BotFather
2. 发送 `/newbot`
3. 命名你的bot
4. 获取token

**获取Chat ID**:
```python
# 给bot发消息后访问
url = f"https://api.telegram.org/bot{TOKEN}/getUpdates"
response = requests.get(url)
chat_id = response.json()['result'][0]['message']['chat']['id']
```

**发送消息**:
```python
import requests

def send_telegram_message(token, chat_id, message):
    url = f"https://api.telegram.org/bot{token}/sendMessage"
    payload = {
        'chat_id': chat_id,
        'text': message,
        'parse_mode': 'Markdown',
        'disable_web_page_preview': True
    }
    response = requests.post(url, json=payload)
    return response.json()

# 使用
token = 'YOUR_BOT_TOKEN'
chat_id = 'YOUR_CHAT_ID'
message = '''
🚨 *价格预警*

ETH突破 $4,000!
当前价格: $4,050
24h涨幅: +5.2%

[查看图表](https://dexscreener.com/ethereum/0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8)
'''
send_telegram_message(token, chat_id, message)
```

### Discord

**创建Webhook**:
1. 进入Discord服务器设置
2. 集成 → Webhook
3. 创建Webhook
4. 复制URL

**发送消息**:
```python
import requests

def send_discord_webhook(webhook_url, content, embeds=None):
    payload = {
        'content': content,
        'username': 'DEX Monitor',
        'avatar_url': 'https://example.com/icon.png'
    }
    if embeds:
        payload['embeds'] = embeds
    
    response = requests.post(webhook_url, json=payload)
    return response.status_code == 204

# 使用
webhook_url = 'YOUR_WEBHOOK_URL'

embed = {
    'title': '价格预警',
    'description': 'ETH突破$4000',
    'color': 0x00ff00,
    'fields': [
        {'name': '当前价格', 'value': '$4,050', 'inline': True},
        {'name': '24h涨幅', 'value': '+5.2%', 'inline': True}
    ],
    'timestamp': datetime.utcnow().isoformat()
}

send_discord_webhook(webhook_url, '@everyone 价格预警!', [embed])
```

### 邮件通知

```python
import smtplib
from email.mime.text import MIMEText

def send_email_alert(smtp_server, port, username, password, to_email, subject, body):
    msg = MIMEText(body, 'html')
    msg['Subject'] = subject
 

references/api-documentation.md

# API文档速查

## The Graph API

### 基础查询

#### 获取池子价格

```graphql
query GetPoolPrice($poolAddress: ID!) {
  pool(id: $poolAddress) {
    id
    token0 {
      symbol
      decimals
    }
    token1 {
      symbol
      decimals
    }
    token0Price
    token1Price
    sqrtPriceX96
    liquidity
    volumeUSD
    feesUSD
    tick
    observationIndex
  }
}
```

**变量**:
```json
{
  "poolAddress": "0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8"
}
```

#### 获取多个池子

```graphql
query GetMultiplePools($first: Int!) {
  pools(first: $first, orderBy: volumeUSD, orderDirection: desc) {
    id
    token0 {
      symbol
    }
    token1 {
      symbol
    }
    token0Price
    feeTier
    volumeUSD
    liquidity
  }
}
```

#### 按代币搜索池子

```graphql
query GetPoolsByToken($tokenAddress: String!) {
  pools(where: { 
    or: [
      {token0: $tokenAddress},
      {token1: $tokenAddress}
    ]
  }) {
    id
    token0 {
      symbol
    }
    token1 {
      symbol
    }
    token0Price
    volumeUSD
  }
}
```

### 历史数据查询

#### 最近24小时数据

```graphql
query GetRecentData($poolAddress: String!) {
  poolDayDatas(
    where: { pool: $poolAddress }
    first: 1
    orderBy: date
    orderDirection: desc
  ) {
    date
    open
    high
    low
    close
    volumeUSD
    feesUSD
  }
}
```

####  Swap事件

```graphql
query GetRecentSwaps($poolAddress: String!, $first: Int!) {
  swaps(
    where: { pool: $poolAddress }
    first: $first
    orderBy: timestamp
    orderDirection: desc
  ) {
    id
    timestamp
    amount0
    amount1
    amountUSD
    sqrtPriceX96
    tick
  }
}
```

### 价格计算

```python
def calculate_price_from_sqrt(sqrt_price_x96, token0_decimals, token1_decimals):
    """从sqrtPriceX96计算价格"""
    price = (sqrt_price_x96 ** 2) / (2 ** 192)
    
    # 调整精度
    decimals_diff = token1_decimals - token0_decimals
    price = price * (10 ** decimals_diff)
    
    return price
```

## Web3 合约调用

### Uniswap V3 Pool

#### ABI片段

```json
[
  {
    "inputs": [],
    "name": "slot0",
    "outputs": [
      {"internalType": "uint160", "name": "sqrtPriceX96", "type": "uint160"},
      {"internalType": "int24", "name": "tick", "type": "int24"},
      {"internalType": "uint16", "name": "observationIndex", "type": "uint16"},
      {"internalType": "uint16", "name": "observationCardinality", "type": "uint16"},
      {"internalType": "uint16", "name": "observationCardinalityNext", "type": "uint16"},
      {"internalType": "uint8", "name": "feeProtocol", "type": "uint8"},
      {"internalType": "bool", "name": "unlocked", "type": "bool"}
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "liquidity",
    "outputs": [{"internalType": "uint128", "name": "", "type": "uint128"}],
    "stateMutability": "view",
    "type": "function"
  }
]
```

#### Python调用

```python
from web3 import Web3

class UniswapV3Pool:
    def __init__(self, provider_url, pool_address):
        self.w3 = Web3(Web3.HTTPProvider(provider_url))
        
        sel

references/data-sources.md

# 价格数据源指南

## 数据源分类

### 1. 链上数据源(最准确)

#### The Graph

**优势**:
- 直接从链上索引数据
- 实时性高
- 免费使用

**Uniswap V3子图**:
```graphql
query GetPoolPrice($poolAddress: ID!) {
  pool(id: $poolAddress) {
    id
    token0 {
      symbol
      decimals
    }
    token1 {
      symbol
      decimals
    }
    token0Price
    token1Price
    sqrtPriceX96
    liquidity
    volumeUSD
    feesUSD
  }
}
```

**常用子图地址**:
```
Uniswap V3: https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3
SushiSwap: https://api.thegraph.com/subgraphs/name/sushiswap/exchange
Curve: https://api.thegraph.com/subgraphs/name/curvefi/curve
Balancer: https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-v2
```

**Python调用**:
```python
import requests

def query_thegraph(subgraph_url, query, variables=None):
    response = requests.post(
        subgraph_url,
        json={'query': query, 'variables': variables or {}},
        headers={'Content-Type': 'application/json'}
    )
    return response.json()

# 示例:获取ETH/USDC价格
query = """
{
  pools(where: {token0_: {symbol: "ETH"}, token1_: {symbol: "USDC"}}, first: 5) {
    id
    token0Price
    feeTier
  }
}
"""

result = query_thegraph(
    'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3',
    query
)
```

#### 直接合约调用

**优势**:
- 最实时
- 无需第三方
- 100%准确

**Uniswap V3 slot0**:
```python
from web3 import Web3

w3 = Web3(Web3.HTTPProvider('https://eth.llamarpc.com'))

# Uniswap V3 Pool ABI (简化)
pool_abi = [
    {
        "inputs": [],
        "name": "slot0",
        "outputs": [
            {"internalType": "uint160", "name": "sqrtPriceX96", "type": "uint160"},
            {"internalType": "int24", "name": "tick", "type": "int24"},
            {"internalType": "uint16", "name": "observationIndex", "type": "uint16"},
            {"internalType": "uint16", "name": "observationCardinality", "type": "uint16"},
            {"internalType": "uint16", "name": "observationCardinalityNext", "type": "uint16"},
            {"internalType": "uint8", "name": "feeProtocol", "type": "uint8"},
            {"internalType": "bool", "name": "unlocked", "type": "bool"}
        ],
        "stateMutability": "view",
        "type": "function"
    }
]

# ETH/USDC 0.3%池子
pool_address = '0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8'
pool = w3.eth.contract(address=pool_address, abi=pool_abi)

sqrtPriceX96, *_ = pool.functions.slot0().call()

# 计算价格
price = (sqrtPriceX96 ** 2) / (2 ** 192)
print(f"ETH/USDC价格: {price}")
```

### 2. DEX聚合器API

#### 1inch API

**特点**:
- 多DEX聚合价格
- 最优路径计算
- 免费额度充足

**基础用法**:
```python
import requests

def get_1inch_price(chain_id, from_token, to_token, amount):
    url = f"https://api.1inch.dev/swap/v5.2/{chain_id}/quote"
    params = {
        'src': from_token,
        'dst': to_token,
        'amount': amount
    }
    headers = {
        'Authorization': 'Bearer YOUR_API_KEY'
    }
    response = requests.get(url, params=params, headers=headers)
    return response.json()

# 获取ETH价格
result = get_1inch_price(
    1,  # 以太

Sponsored

Ads related to DEX Price Monitor DEX价格监控 and adjacent AI workflows.