# Send Uniswap V4 to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "uniswap-v4",
    "name": "Uniswap V4",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/openclaw-consensus-bot/uniswap-v4",
    "canonicalUrl": "https://clawhub.ai/openclaw-consensus-bot/uniswap-v4",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/uniswap-v4",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=uniswap-v4",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "CHANGELOG.md",
      "README.md",
      "SKILL.md",
      "package-lock.json",
      "package.json",
      "references/addresses.md"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-07T17:22:31.273Z",
      "expiresAt": "2026-05-14T17:22:31.273Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=afrexai-annual-report",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=afrexai-annual-report",
        "contentDisposition": "attachment; filename=\"afrexai-annual-report-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/uniswap-v4"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/uniswap-v4",
    "downloadUrl": "https://openagent3.xyz/downloads/uniswap-v4",
    "agentUrl": "https://openagent3.xyz/skills/uniswap-v4/agent",
    "manifestUrl": "https://openagent3.xyz/skills/uniswap-v4/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/uniswap-v4/agent.md"
  }
}
```
## Documentation

### Uniswap V4 🦄

Swap tokens and read pool state on Uniswap V4 via the Universal Router.

Chains: Base (8453), Ethereum (1), Base Sepolia (84532)

ContractBaseEthereumPoolManager0x498581fF718922c3f8e6A244956aF099B2652b2b0x000000000004444c5dc75cB358380D2e3dE08A90UniversalRouter0x6ff5693b99212da76ad316178a184ab56d299b430x66a9893cC07D91D95644AEDD05D03f95e1dBA8AfPermit20x000000000022D473030F116dDEE9F6B43aC78BA30x000000000022D473030F116dDEE9F6B43aC78BA3StateView0xa3c0c9b65bad0b08107aa264b0f3db444b867a710x7ffe42c4a5deea5b0fec41c94c136cf115597227V4Quoter0x0d5e0f971ed27fbff6c2837bf31316121532048d0x52f0e24d1c21c8a0cb1e5a5dd6198556bd9e1203

Addresses from docs.uniswap.org/contracts/v4/deployments, verified 2026-02-08.

### Decision Tree

Read pool state? → src/pool-info.ts (free, no gas, no key)
Get swap quote? → src/quote.ts (free, uses on-chain V4Quoter)
Approve tokens? → src/approve.ts (write, ~100K gas, needs PRIVATE_KEY)
Execute swap? → src/swap.ts (write, ~300-350K gas, needs PRIVATE_KEY)
First time with an ERC20? → Run approve first, or use --auto-approve on swap

### Scripts Reference

All scripts in src/. Run with npx tsx. Pass --help for usage.

### pool-info.ts — Read Pool State (free)

Returns pool ID, sqrtPriceX96, tick, liquidity, fees, token symbols/decimals.
Auto-detects the best pool by liquidity (or specify --fee/--tick-spacing).

npx tsx src/pool-info.ts --token0 ETH --token1 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 --chain base --rpc $BASE_RPC_URL

Env: BASE_RPC_URL or ETH_RPC_URL (or pass --rpc)

### quote.ts — Quote Swap Amounts (free)

Quotes exact input amounts via the on-chain V4Quoter contract (simulation, no tx).
Returns expected output amount and gas estimate.

npx tsx src/quote.ts \\
  --token-in ETH \\
  --token-out 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \\
  --amount 10000000000000000 \\
  --chain base \\
  --rpc $BASE_RPC_URL

Env: BASE_RPC_URL or ETH_RPC_URL

### approve.ts — Set Up Token Approvals (write)

Two-step Permit2 flow: ERC20 → Permit2, then Permit2 → Universal Router.
Skips if already approved. Only needed for ERC20 tokens (not ETH).

PRIVATE_KEY=0x... npx tsx src/approve.ts \\
  --token 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \\
  --chain base \\
  --rpc $BASE_RPC_URL \\
  --json

Env: PRIVATE_KEY (required), BASE_RPC_URL

### swap.ts — Execute Swap (write)

Exact-input swap via Universal Router. Quotes expected output first, applies slippage,
then sends the transaction.

PRIVATE_KEY=0x... npx tsx src/swap.ts \\
  --token-in ETH \\
  --token-out 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \\
  --amount 10000000000000000 \\
  --slippage 50 \\
  --chain base \\
  --rpc $BASE_RPC_URL \\
  --json

With auto-approval (sets up Permit2 if needed):

PRIVATE_KEY=0x... npx tsx src/swap.ts \\
  --token-in 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \\
  --token-out ETH \\
  --amount 25000000 \\
  --slippage 100 \\
  --auto-approve \\
  --chain base \\
  --rpc $BASE_RPC_URL

Options: --slippage <bps> (default 50 = 0.5%), --recipient <addr>, --auto-approve, --json
Env: PRIVATE_KEY (required), BASE_RPC_URL

### Token Input

ETH or eth → native ETH (address(0) in V4)
Contract address → ERC20 token
Common Base tokens: USDC 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913, WETH 0x4200000000000000000000000000000000000006

### Environment Variables

VariableUsed ByRequiredDescriptionPRIVATE_KEYapprove, swapYes*Wallet private key (never CLI!)BASE_RPC_URLall (Base)NoBase mainnet RPC URLETH_RPC_URLall (Ethereum)NoEthereum mainnet RPC URLBASE_SEPOLIA_RPC_URLall (testnet)NoBase Sepolia RPC URL

* Only required for write operations. Read operations (pool-info, quote) don't need a key.

### V4 Architecture Notes

Singleton PoolManager holds all pools in one contract
State read via StateView contract (wraps PoolManager storage)
Swaps: Universal Router → PoolManager via V4_SWAP command
Approvals: ERC20 → Permit2 → Universal Router (two-step)
Pool ID: keccak256(abi.encode(currency0, currency1, fee, tickSpacing, hooks))
Currency ordering: currency0 < currency1 by numeric value. ETH = address(0)
Action sequence: SWAP_EXACT_IN_SINGLE (0x06) + SETTLE_ALL (0x0c) + TAKE_ALL (0x0f)
See references/v4-encoding.md for full encoding reference

### Error Handling

ErrorCauseFixNo V4 pool foundPair not listed on V4 for this chainCheck token addressesQuote failedPool exists but can't simulate swapCheck amount, pool may lack liqPRIVATE_KEY requiredMissing env var for write operationexport PRIVATE_KEY=0x...No RPC URLMissing RPC configPass --rpc or set env varTx revertsInsufficient balance, expired, slippageCheck balance, increase slippageuint128 maxAmount too large for V4Use smaller amount

### SECURITY

PRIVATE_KEY must be provided via an environment variable or secret manager only.


NEVER paste or send PRIVATE_KEY in chat.


NEVER commit PRIVATE_KEY (or .env files) to git.


Treat stdout/stderr as public logs (CI, terminals, chat). CI tests ensure the PRIVATE_KEY value is never printed.


NEVER pass private keys as CLI arguments (rejected by all scripts)


Private keys accepted via PRIVATE_KEY env var only


All inputs validated: addresses (format), amounts (BigInt bounds), slippage (0-10000)


No eval(), no exec(), no shell commands — pure TypeScript


BigInt used everywhere for token amounts (no floating point, no overflow)

### Testing

npm run test:unit      # Unit tests (no network)
npm run test:fork      # Fork tests (needs: anvil --fork-url https://mainnet.base.org)
npm run test:testnet   # Testnet reads (Base Sepolia)
npm run test:mainnet   # Mainnet smoke tests (read-only)
npm run security       # Security scan

### References

V4 encoding reference: references/v4-encoding.md
Contract addresses: references/addresses.md
V4 architecture: references/v4-architecture.md
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: openclaw-consensus-bot
- Version: 2.0.4
## Source health
- Status: healthy
- Source download looks usable.
- Yavira can redirect you to the upstream package for this source.
- Health scope: source
- Reason: direct_download_ok
- Checked at: 2026-05-07T17:22:31.273Z
- Expires at: 2026-05-14T17:22:31.273Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/uniswap-v4)
- [Send to Agent page](https://openagent3.xyz/skills/uniswap-v4/agent)
- [JSON manifest](https://openagent3.xyz/skills/uniswap-v4/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/uniswap-v4/agent.md)
- [Download page](https://openagent3.xyz/downloads/uniswap-v4)