Grimoire Uniswap

作者 franalgaba2cca3994a288无许可证6 个星标收录于 2026年10月8日更新于 2026年10月8日仓库5个月前更新

Retrieves Uniswap router metadata using the Grimoire venue CLI. Use when you need router addresses, adapter information, or Uniswap V3/V4 details.

仅含说明Business & Finance
AI 生成的概览

通过 Grimoire venue CLI 获取 Uniswap 路由器、代币和资金池元数据,并生成 spell 参数块。

功能
该技能说明如何使用 Grimoire venue CLI 查询 Uniswap 元数据:适配器信息、各链路由器地址、代币列表以及代币对的资金池。它可通过仅限代理的 snapshot 命令为代币和资金池生成 spell 的 params: 块,并说明 Uniswap V3/V4 spell 的指标选择器和交换约束。输出为 JSON 或表格格式,代币和资金池还支持 --format spell。
适用场景
当你需要 Uniswap 路由器地址、适配器详情、代币或资金池查询,或编写 spell 所需的 Uniswap V3/V4 元数据时使用。也适用于为 spell 输入生成代币或资金池参数块。
运行要求
需要 Grimoire venue CLI,可通过 grimoire、npx -y @grimoirelabs/cli、仓库本地 Bun 命令或 grimoire-uniswap 二进制运行。资金池查询需要 GRAPH_API_KEY 以访问 The Graph 子图,或通过 --rpc-url/RPC_URL 提供 RPC 端点进行链上工厂查询,因此需要网络访问。该技能不附带脚本,仅为说明文档。

Grimoire Uniswap Skill

Use this skill to inspect Uniswap metadata and produce token/pool snapshots for spells.

Preferred invocations:

  • grimoire venue uniswap ...
  • npx -y @grimoirelabs/cli venue uniswap ... (no-install)
  • bun run packages/cli/src/index.ts venue uniswap ... (repo-local)
  • grimoire-uniswap ... (direct binary from @grimoirelabs/venues)

Recommended preflight:

  • grimoire venue doctor --adapter uniswap --chain 1 --rpc-url <rpc> --json

Commands

  • grimoire venue uniswap info — adapter metadata
  • grimoire venue uniswap routers [--chain <id>] — router addresses per chain
  • grimoire venue uniswap tokens [--chain <id>] [--symbol <sym>] [--address <addr>] [--source <url>] — token list lookup
  • grimoire venue uniswap tokens-snapshot [--chain <id>] [--symbol <sym>] [--address <addr>] [--source <url>] — generate spell params: block for tokens (agent-only)
  • grimoire venue uniswap pools --token0 <address|symbol> --token1 <address|symbol> [--chain <id>] [--fee <bps>] [--limit <n>] [--source <url>] [--endpoint <url>] [--graph-key <key>] [--subgraph-id <id>] [--rpc-url <url>] [--factory <address>] — find pools for a token pair
  • grimoire venue uniswap pools-snapshot --token0 <address|symbol> --token1 <address|symbol> [--chain <id>] [--fee <bps>] [--limit <n>] [--source <url>] [--endpoint <url>] [--graph-key <key>] [--subgraph-id <id>] [--rpc-url <url>] [--factory <address>] — generate spell params: block for pools (agent-only)

Pool Data Sources

Pools can be fetched from The Graph (subgraph) or directly from on-chain factory contracts:

  • Subgraph (default when GRAPH_API_KEY is set): queries The Graph decentralized network. Built-in subgraph IDs for Ethereum, Optimism, Polygon, Base, Arbitrum.
  • RPC (fallback): if no usable graph config is present, pools uses on-chain factory lookups (with --rpc-url/RPC_URL when provided, otherwise chain default RPC where available).
  • To force RPC mode: provide --rpc-url and omit --graph-key.

Environment Variables

VariableDescription
GRAPH_API_KEYThe Graph API key for subgraph queries (get one at https://thegraph.com/studio/apikeys/)
RPC_URLFallback RPC URL for on-chain pool lookups

Examples

bash
grimoire venue uniswap info --format tablegrimoire venue uniswap routersgrimoire venue uniswap routers --chain 1grimoire venue uniswap tokens --chain 1 --symbol USDC --format spellgrimoire venue uniswap pools --chain 1 --token0 USDC --token1 WETH --fee 3000 --format spellgrimoire venue uniswap pools --chain 8453 --token0 USDC --token1 WETH --fee 500 --rpc-url $RPC_URL --format tablegrimoire venue uniswap pools --chain 8453 --token0 USDC --token1 WETH --fee 500 --graph-key $GRAPH_API_KEY --subgraph-id <id>grimoire venue uniswap tokens-snapshot --chain 1 --symbol USDCgrimoire venue uniswap pools-snapshot --chain 1 --token0 USDC --token1 WETH --rpc-url $RPC_URL

Use tokens-snapshot or pools-snapshot to emit a params: block for spell inputs. These are agent-only commands (output suppressed in interactive mode).

Metric Surface (Spell Comparisons)

Uniswap V3 and V4 expose quote_out for protocol comparison:

spell
v3_out = metric("quote_out", uni_v3, USDC, "asset_out=WETH,amount=1000000,fee_tier=3000")v4_out = metric("quote_out", uni_v4, USDC, "asset_out=WETH,amount=1000000,fee_tier=3000,tick_spacing=60")

Selector fields:

  • required: asset_out
  • optional: amount (defaults to 1 unit of input asset), fee_tier
  • V4 optional: tick_spacing

Spell Constraints

When writing swap actions in .spell files targeting Uniswap, use with clauses to set constraints:

spell
uniswap_v3.swap(USDC, WETH, params.amount) with (  fee_tier=3000,  max_slippage=50,  min_output=900000000000000,  deadline=300,)

fee_tier is required. The adapter throws if fee_tier is not specified. It is an action parameter (not a constraint) and is extracted from the with() clause.

Common fee tiers: 500 (0.05%), 3000 (0.3%), 10000 (1%).

ParameterTypeDescription
fee_tierinteger (bps)Required. Uniswap pool fee tier (e.g. 500, 3000, 10000)
ConstraintTypeDescription
max_slippageinteger (bps)Maximum slippage in basis points (e.g. 50 = 0.5%)
min_outputinteger (wei)Minimum output amount floor
max_inputinteger (wei)Maximum input amount cap
deadlineinteger (seconds)Transaction deadline from now
require_quotebooleanFail if on-chain quote fetch fails
require_simulationbooleanFail if simulation unavailable
max_gasinteger (wei)Gas estimate cap

Always set both max_slippage and min_output for swaps to prevent unexpected losses.

Supported Adapters

AdapterRouterApproval Flow
@uniswap_v3SwapRouter02Standard ERC20 approve
@uniswap_v4Universal RouterPermit2

Notes

  • CLI currently exposes V3 metadata. V4 adapter is available programmatically via createUniswapV4Adapter().
  • For metadata lookups (tokens, pools), use grimoire venue uniswap ... even when your spell venue is uniswap_v4.
  • Outputs JSON/table; tokens and pools also support --format spell.
  • Prefer --format json for automation and reproducible snapshots.
  • Only metadata is exposed (no on-chain quote endpoints).

来源与署名

来源:franalgaba/grimoire位于skills/grimoire-uniswap提交2cca399

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架