$npx -y skills add franalgaba/grimoire --skill grimoire-uniswapRetrieves Uniswap router metadata using the Grimoire venue CLI. Use when you need router addresses, adapter information, or Uniswap V3/V4 details.
| 1 | # Grimoire Uniswap Skill |
| 2 | |
| 3 | Use this skill to inspect Uniswap metadata and produce token/pool snapshots for spells. |
| 4 | |
| 5 | Preferred invocations: |
| 6 | |
| 7 | - `grimoire venue uniswap ...` |
| 8 | - `npx -y @grimoirelabs/cli venue uniswap ...` (no-install) |
| 9 | - `bun run packages/cli/src/index.ts venue uniswap ...` (repo-local) |
| 10 | - `grimoire-uniswap ...` (direct binary from `@grimoirelabs/venues`) |
| 11 | |
| 12 | Recommended preflight: |
| 13 | |
| 14 | - `grimoire venue doctor --adapter uniswap --chain 1 --rpc-url <rpc> --json` |
| 15 | |
| 16 | ## Commands |
| 17 | |
| 18 | - `grimoire venue uniswap info` — adapter metadata |
| 19 | - `grimoire venue uniswap routers [--chain <id>]` — router addresses per chain |
| 20 | - `grimoire venue uniswap tokens [--chain <id>] [--symbol <sym>] [--address <addr>] [--source <url>]` — token list lookup |
| 21 | - `grimoire venue uniswap tokens-snapshot [--chain <id>] [--symbol <sym>] [--address <addr>] [--source <url>]` — generate spell `params:` block for tokens (agent-only) |
| 22 | - `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 |
| 23 | - `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) |
| 24 | |
| 25 | ## Pool Data Sources |
| 26 | |
| 27 | Pools can be fetched from The Graph (subgraph) or directly from on-chain factory contracts: |
| 28 | |
| 29 | - **Subgraph** (default when `GRAPH_API_KEY` is set): queries The Graph decentralized network. Built-in subgraph IDs for Ethereum, Optimism, Polygon, Base, Arbitrum. |
| 30 | - **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). |
| 31 | - To force RPC mode: provide `--rpc-url` and omit `--graph-key`. |
| 32 | |
| 33 | ## Environment Variables |
| 34 | |
| 35 | | Variable | Description | |
| 36 | |----------|-------------| |
| 37 | | `GRAPH_API_KEY` | The Graph API key for subgraph queries (get one at https://thegraph.com/studio/apikeys/) | |
| 38 | | `RPC_URL` | Fallback RPC URL for on-chain pool lookups | |
| 39 | |
| 40 | ## Examples |
| 41 | |
| 42 | ```bash |
| 43 | grimoire venue uniswap info --format table |
| 44 | grimoire venue uniswap routers |
| 45 | grimoire venue uniswap routers --chain 1 |
| 46 | grimoire venue uniswap tokens --chain 1 --symbol USDC --format spell |
| 47 | grimoire venue uniswap pools --chain 1 --token0 USDC --token1 WETH --fee 3000 --format spell |
| 48 | grimoire venue uniswap pools --chain 8453 --token0 USDC --token1 WETH --fee 500 --rpc-url $RPC_URL --format table |
| 49 | grimoire venue uniswap pools --chain 8453 --token0 USDC --token1 WETH --fee 500 --graph-key $GRAPH_API_KEY --subgraph-id <id> |
| 50 | grimoire venue uniswap tokens-snapshot --chain 1 --symbol USDC |
| 51 | grimoire venue uniswap pools-snapshot --chain 1 --token0 USDC --token1 WETH --rpc-url $RPC_URL |
| 52 | ``` |
| 53 | |
| 54 | Use `tokens-snapshot` or `pools-snapshot` to emit a `params:` block for spell inputs. These are agent-only commands (output suppressed in interactive mode). |
| 55 | |
| 56 | ## Metric Surface (Spell Comparisons) |
| 57 | |
| 58 | Uniswap V3 and V4 expose `quote_out` for protocol comparison: |
| 59 | |
| 60 | ```spell |
| 61 | v3_out = metric("quote_out", uni_v3, USDC, "asset_out=WETH,amount=1000000,fee_tier=3000") |
| 62 | v4_out = metric("quote_out", uni_v4, USDC, "asset_out=WETH,amount=1000000,fee_tier=3000,tick_spacing=60") |
| 63 | ``` |
| 64 | |
| 65 | Selector fields: |
| 66 | |
| 67 | - required: `asset_out` |
| 68 | - optional: `amount` (defaults to 1 unit of input asset), `fee_tier` |
| 69 | - V4 optional: `tick_spacing` |
| 70 | |
| 71 | ## Spell Constraints |
| 72 | |
| 73 | When writing swap actions in `.spell` files targeting Uniswap, use `with` clauses to set constraints: |
| 74 | |
| 75 | ```spell |
| 76 | uniswap_v3.swap(USDC, WETH, params.amount) with ( |
| 77 | fee_tier=3000, |
| 78 | max_slippage=50, |
| 79 | min_output=900000000000000, |
| 80 | deadline=300, |
| 81 | ) |
| 82 | ``` |
| 83 | |
| 84 | **`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. |
| 85 | |
| 86 | Common fee tiers: `500` (0.05%), `3000` (0.3%), `10000` (1%). |
| 87 | |
| 88 | | Parameter | Type | Description | |
| 89 | |-----------|------|-------------| |
| 90 | | `fee_tier` | integer (bps) | **Required.** Uniswap pool fee tier (e.g. `500`, `3000`, `10000`) | |
| 91 | |
| 92 | | Constraint | Type | Description | |
| 93 | |-----------|------|-------------| |
| 94 | | `max_slippage` | integer (bps) | Maximum slippage in basis points (e.g. `50` = 0.5%) | |
| 95 | | `min_output` | integer (wei) | Minimum output amount floor | |
| 96 | | `max_input` | integer (wei) | Maximum input amount cap | |
| 97 | | `deadline` | integer (seconds) | Transaction deadline from now | |
| 98 | | `require_quote` | boolean | Fail if on-chain quote fetch fails | |
| 99 | | `require_simulation` | boolean | Fail if simulation unavailable | |
| 100 | | `max_gas` | integer (wei) | Gas estimate cap | |
| 101 | |
| 102 | Always set bot |