uniswap-v4Swap tokens and read pool state on Uniswap V4 (Base, Ethereum). Use when the agent needs to: (1) swap ERC20 tokens or ETH via Uniswap V4, (2) get pool info (price, tick, liquidity, fees), (3) find the best pool for a token pair, (4) quote expected swap output via the on-chain V4Quoter, (5) set up Permit2 approvals for the Universal Router, or (6) execute exact-input swaps with proper slippage protection. Supports Base and Ethereum mainnet, plus Base Sepolia testnet. TypeScript with strict types. Write operations need a private key via env var.
Install via ClawdBot CLI:
clawdbot install openclaw-consensus-bot/uniswap-v4Swap tokens and read pool state on Uniswap V4 via the Universal Router.
Chains: Base (8453), Ethereum (1), Base Sepolia (84532)
| Contract | Base | Ethereum |
|------------------|----------------------------------------------|----------------------------------------------|
| PoolManager | 0x498581fF718922c3f8e6A244956aF099B2652b2b | 0x000000000004444c5dc75cB358380D2e3dE08A90 |
| UniversalRouter | 0x6ff5693b99212da76ad316178a184ab56d299b43 | 0x66a9893cC07D91D95644AEDD05D03f95e1dBA8Af |
| Permit2 | 0x000000000022D473030F116dDEE9F6B43aC78BA3 | 0x000000000022D473030F116dDEE9F6B43aC78BA3 |
| StateView | 0xa3c0c9b65bad0b08107aa264b0f3db444b867a71 | 0x7ffe42c4a5deea5b0fec41c94c136cf115597227 |
| V4Quoter | 0x0d5e0f971ed27fbff6c2837bf31316121532048d | 0x52f0e24d1c21c8a0cb1e5a5dd6198556bd9e1203 |
Addresses from docs.uniswap.org/contracts/v4/deployments, verified 2026-02-08.
src/pool-info.ts (free, no gas, no key)src/quote.ts (free, uses on-chain V4Quoter)src/approve.ts (write, ~100K gas, needs PRIVATE_KEY)src/swap.ts (write, ~300-350K gas, needs PRIVATE_KEY)--auto-approve on swapAll scripts in src/. Run with npx tsx. Pass --help for usage.
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)
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
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
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 (default 50 = 0.5%), --recipient , --auto-approve, --json
Env: PRIVATE_KEY (required), BASE_RPC_URL
ETH or eth → native ETH (address(0) in V4)0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913, WETH 0x4200000000000000000000000000000000000006| Variable | Used By | Required | Description |
|-----------------------|----------------|----------|---------------------------------|
| PRIVATE_KEY | approve, swap | Yes* | Wallet private key (never CLI!) |
| BASE_RPC_URL | all (Base) | No | Base mainnet RPC URL |
| ETH_RPC_URL | all (Ethereum) | No | Ethereum mainnet RPC URL |
| BASE_SEPOLIA_RPC_URL| all (testnet) | No | Base Sepolia RPC URL |
\* Only required for write operations. Read operations (pool-info, quote) don't need a key.
keccak256(abi.encode(currency0, currency1, fee, tickSpacing, hooks))currency0 < currency1 by numeric value. ETH = address(0)references/v4-encoding.md for full encoding reference| Error | Cause | Fix |
|------------------------------|--------------------------------------------|------------------------------------|
| No V4 pool found | Pair not listed on V4 for this chain | Check token addresses |
| Quote failed | Pool exists but can't simulate swap | Check amount, pool may lack liq |
| PRIVATE_KEY required | Missing env var for write operation | export PRIVATE_KEY=0x... |
| No RPC URL | Missing RPC config | Pass --rpc or set env var |
| Tx reverts | Insufficient balance, expired, slippage | Check balance, increase slippage |
| uint128 max | Amount too large for V4 | Use smaller amount |
PRIVATE_KEY must be provided via an environment variable or secret manager only.PRIVATE_KEY in chat.PRIVATE_KEY (or .env files) to git.PRIVATE_KEY value is never printed.PRIVATE_KEY env var onlyeval(), no exec(), no shell commands — pure TypeScriptnpm 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.mdreferences/addresses.mdreferences/v4-architecture.mdGenerated Mar 1, 2026
A bot uses this skill to monitor price differences across Uniswap V4 pools on Base and Ethereum, executing profitable swaps automatically. It reads pool state for real-time prices and executes swaps with slippage protection to minimize losses. This enables high-frequency trading strategies in decentralized finance.
A dashboard integrates this skill to provide users with live pool information, swap quotes, and token approvals for managing their crypto portfolios. Investors can view liquidity, fees, and execute swaps directly from the interface, streamlining asset rebalancing across multiple chains like Base and Ethereum.
An e-commerce platform uses this skill to accept payments in various tokens by swapping them to a stablecoin like USDC on Uniswap V4. It quotes swap outputs and handles approvals via Permit2, ensuring fast, low-cost transactions on Base for customer purchases with automated settlement.
A tool leverages this skill to analyze pool data such as liquidity, ticks, and fees on Uniswap V4, helping liquidity providers optimize their positions. It finds the best pools for token pairs and simulates swaps to assess potential returns, supporting informed decision-making in yield farming.
A platform for launching new tokens integrates this skill to enable immediate trading on Uniswap V4. It sets up approvals and executes initial swaps for liquidity, using quotes to manage slippage and pool info to monitor market conditions, facilitating smooth token distribution on Base or Ethereum.
Charge users a small percentage fee on each swap executed through the skill, leveraging the Universal Router for efficient transactions. Revenue scales with swap volume, especially on high-traffic chains like Base, while offering value through automated approvals and slippage protection.
Offer a subscription service that provides enhanced pool state data, custom swap quotes, and predictive analytics using this skill. Target institutional clients who need in-depth insights for trading or liquidity management, with tiered plans based on data access and frequency.
License this skill as a white-label solution for other businesses, such as wallets or exchanges, to embed Uniswap V4 functionality. Revenue comes from setup fees and ongoing support, enabling partners to offer token swaps and pool info without developing the infrastructure themselves.
💬 Integration Tip
Ensure PRIVATE_KEY is securely stored in environment variables, not in code, and use auto-approve flags to streamline token approvals for ERC20 swaps.
Connect Claude to Clawdbot instantly and keep it connected 24/7. Run after setup to link your subscription, then auto-refreshes tokens forever.
ERC-8004 Trustless Agents - Register, discover, and build reputation for AI agents on Ethereum. Use when registering agents on-chain, querying agent registries, giving/receiving reputation feedback, or interacting with the AI agent trust layer.
Autonomous crypto trading on Base via Bankr. Use for trading tokens, monitoring launches, executing strategies, or managing a trading portfolio. Triggers on "trade", "buy", "sell", "launch", "snipe", "profit", "PnL", "portfolio balance", or any crypto trading task on Base.
Deploy ERC20 tokens on Base using Clanker SDK. Create tokens with built-in Uniswap V4 liquidity pools. Supports Base mainnet and Sepolia testnet. Requires PRIVATE_KEY in config.
Query DeFi portfolio data across 50+ chains via Zapper's GraphQL API. Use when the user wants to check wallet balances, DeFi positions, NFT holdings, token prices, or transaction history. Supports Base, Ethereum, Polygon, Arbitrum, Optimism, and more. Requires ZAPPER_API_KEY.
Interact with Solana blockchain via Helius APIs. Create/manage wallets, check balances (SOL + tokens), send transactions, swap tokens via Jupiter, and monitor addresses. Use for any Solana blockchain operation, crypto wallet management, token transfers, DeFi swaps, or portfolio tracking.