uniswap-pool-analysis
Analyze Uniswap pool data including liquidity distribution, fee tiers, tick ranges, and TVL. Use when the user asks about pool metrics, liquidity analysis, or wants to query on-chain pool state.
- License 许可
- AGPL-3.0
- 最近更新
- 2026-11-12
- Stars
- ★ 81
- Forks
- 17
01 前言 Front Matter
- name
- uniswap-pool-analysis
- description
- Analyze Uniswap pool data including liquidity distribution, fee tiers, tick ranges, and TVL. Use when the user asks about pool metrics, liquidity analysis, or wants to query on-chain pool state.
02 资源文件 5
- 参考文档_meta.json140 B
- 参考文档README.md1.0 KB
- 参考文档skill-card.md2.0 KB
- 参考文档SOURCE.md260 B
- 参考文档TRUST.auto.yaml2.0 KB
03 SKILL.md 正文
Uniswap Pool Analysis
Overview
This skill covers querying and analyzing Uniswap v3/v4 pool state on-chain using viem.
Key Concepts
- sqrtPriceX96: Encoded price format used by Uniswap v3/v4. Convert with
price = (sqrtPriceX96 / 2^96)^2 - Ticks: Discrete price points defining liquidity ranges. Tick spacing depends on fee tier.
- Liquidity: The
Lvalue representing active liquidity at the current tick.
Fee Tiers (v3)
| Fee (bps) | Tick Spacing | Typical Use |
|---|---|---|
| 1 (0.01%) | 1 | Stablecoin pairs |
| 5 (0.05%) | 10 | Correlated pairs |
| 30 (0.30%) | 60 | Standard pairs |
| 100 (1.00%) | 200 | Exotic pairs |
Querying Pool State
Use the Uniswap v3 Pool ABI to read on-chain state:
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
const client = createPublicClient({
chain: mainnet,
transport: http(process.env.ETHEREUM_RPC_URL),
});
// Read slot0 for current price and tick
const [
sqrtPriceX96,
tick,
observationIndex,
observationCardinality,
observationCardinalityNext,
feeProtocol,
unlocked,
] = await client.readContract({
address: poolAddress,
abi: poolAbi,
functionName: "slot0",
});
// Read liquidity
const liquidity = await client.readContract({
address: poolAddress,
abi: poolAbi,
functionName: "liquidity",
});
Price Conversion
function sqrtPriceX96ToPrice(
sqrtPriceX96: bigint,
decimals0: number,
decimals1: number,
): number {
const price = Number(sqrtPriceX96) / 2 ** 96;
return (price * price * 10 ** decimals0) / 10 ** decimals1;
}
function tickToPrice(
tick: number,
decimals0: number,
decimals1: number,
): number {
return (1.0001 ** tick * 10 ** decimals0) / 10 ** decimals1;
}
Liquidity Distribution
To analyze liquidity distribution across ticks:
- Query
tickBitmapto find initialized ticks - For each initialized tick, read
ticks(tickIndex)to getliquidityNet - Walk from
MIN_TICKtoMAX_TICK, accumulating net liquidity changes - Plot cumulative liquidity vs price for the distribution
Multi-chain Support
Always accept a chainId parameter. Use the shared chain config from packages/common/ to resolve:
- RPC URL
- Pool factory address
- Quoter address
- Subgraph endpoint (if available)
04 同仓库更多 Skills
recipe-performance
Diagnose a specific MetaMask user flow's real-app performance and Sentry critical-user-flow telemetry with deterministic mm-harness recipes. Use for CUF boundaries, cold/warm/background-resume behavior, latency regressions, lifecycle tags, duplicate or blocking network requests, long tasks, layout/paint cost, screen redraws, React rerenders, or browser trace analysis where tests alone cannot prove the real app.
mexc-spot-websocket
MEXC Spot WebSocket workflows for public streams, protobuf handling, depth maintenance, listen keys, and private streams without exposing API keys.
mexc-spot-rest
MEXC Spot REST workflows for public data, signed account requests, orders, wallet/admin actions, and secure signing without exposing API keys.
mexc-futures-websocket
MEXC Futures WebSocket workflows for public streams, private account/order/position streams, ping/pong, subscriptions, and depth maintenance.
0xklen-version-and-refresh-sanctions-lists
暂无简介
verify-tests-cover-changed-lines
Use when a PR adds code that the existing suite may not exercise. Measures patch coverage — the share of newly changed lines hit by tests — before approving.