uniswap-swap-simulation
Simulate and analyze Uniswap swaps including price impact, slippage, optimal routing, and gas estimation. Use when the user asks about swap execution, routing, price impact, or MEV considerations.
Best use case
uniswap-swap-simulation is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Simulate and analyze Uniswap swaps including price impact, slippage, optimal routing, and gas estimation. Use when the user asks about swap execution, routing, price impact, or MEV considerations.
Teams using uniswap-swap-simulation should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/uniswap-swap-simulation/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How uniswap-swap-simulation Compares
| Feature / Agent | uniswap-swap-simulation | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Simulate and analyze Uniswap swaps including price impact, slippage, optimal routing, and gas estimation. Use when the user asks about swap execution, routing, price impact, or MEV considerations.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Uniswap Swap Simulation
## Overview
This skill covers simulating Uniswap swaps, calculating price impact, and analyzing routing decisions.
## Key Concepts
- **Price Impact**: The change in pool price caused by a swap. Larger swaps have higher impact.
- **Slippage**: Difference between expected and executed price, including price movement between submission and execution.
- **Routing**: Finding the optimal path across pools and protocols for best execution.
## Simulating a Swap
Use the Quoter contract to simulate swaps without executing:
```typescript
import { createPublicClient, http, encodeFunctionData } from "viem";
// QuoterV2 for v3 pools
const quote = await client.readContract({
address: quoterV2Address,
abi: quoterV2Abi,
functionName: "quoteExactInputSingle",
args: [
{
tokenIn,
tokenOut,
amountIn,
fee,
sqrtPriceLimitX96: 0n,
},
],
});
// Returns: [amountOut, sqrtPriceX96After, initializedTicksCrossed, gasEstimate]
```
## Price Impact Calculation
```typescript
function calculatePriceImpact(
amountIn: bigint,
amountOut: bigint,
marketPrice: number, // token1/token0
decimals0: number,
decimals1: number,
): number {
const executionPrice =
Number(amountOut) / 10 ** decimals1 / (Number(amountIn) / 10 ** decimals0);
return Math.abs(1 - executionPrice / marketPrice);
}
```
## Slippage Tolerance
- **Stablecoin pairs**: 0.01% - 0.05%
- **Major pairs** (ETH/USDC): 0.1% - 0.5%
- **Volatile pairs**: 0.5% - 1.0%
- **Low liquidity**: 1% - 5%
Calculate minimum amount out:
```typescript
const minAmountOut = (amountOut * (10000n - BigInt(slippageBps))) / 10000n;
```
## Multi-hop Routing
For tokens without direct pools, route through intermediary tokens:
```typescript
// ETH -> USDC -> DAI (two hops)
const path = encodePacked(
["address", "uint24", "address", "uint24", "address"],
[WETH, 3000, USDC, 100, DAI],
);
const quote = await client.readContract({
address: quoterV2Address,
abi: quoterV2Abi,
functionName: "quoteExactInput",
args: [path, amountIn],
});
```
## Gas Estimation
Typical gas costs by swap complexity:
- Single hop: ~130,000 gas
- Two hops: ~200,000 gas
- Three hops: ~270,000 gas
Always add a 15-20% buffer to gas estimates.
## MEV Considerations
When building swap tools:
- Recommend private RPCs (Flashbots Protect) for large swaps
- Warn users about sandwich attack risk for high-impact swaps
- Suggest using deadline parameters to limit exposureRelated Skills
okx-dex-swap
Use this skill to 'swap tokens', 'trade OKB for USDC', 'buy tokens', 'sell tokens', 'exchange crypto', 'convert tokens', 'swap SOL for USDC', 'get a swap quote', 'execute a trade', 'find the best swap route', 'cheapest way to swap', 'optimal swap', 'compare swap rates', '换币', '买币', '卖币', '兑换', '交易', '代币兑换', '最优路径', '滑点', or mentions swapping, trading, buying, selling, or exchanging tokens on XLayer, Solana, Ethereum, Base, BSC, Arbitrum, Polygon, or any of 20+ supported chains. Aggregates liquidity from 500+ DEX sources for optimal routing and price. Supports slippage control, price impact protection, and cross-DEX route optimization. Do NOT use for questions about HOW TO implement, code, or integrate swaps into an application — only for actually executing swap operations. Do NOT use for analytical questions about historical swap volume. Do NOT use when the user says only a single word like 'swap' or 'trade' without specifying tokens, amounts, or any other context.
ethy-swap-agent
Intelligent on-chain swap and trade execution agent optimized for the most reliable and smoothest swapping experience on Base.
uniswap-v4
Swap 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.
uniswap-v4-tools
Tools for querying V4 pools, swap quotes, and hook-enabled liquidity pools.
uniswap-v4-pools
Query and execute swaps on Uniswap V4 pools with hook-enabled custom logic and advanced pool configurations.
uniswap-v4-hooks
Query and execute swaps on Uniswap V4 pools with custom hooks architecture.
uniswap-v4-agent
Execute swaps and query pool info on Uniswap V4 with hooks support across Ethereum, Base, Arbitrum, and Optimism.
uniswap-v4-agent-hooks
Toolkit for AI agents to interact with Uniswap V4 hooks and custom pool configurations.
uniswap-poolspy
Track newly created Uniswap liquidity pools across 9 networks. Monitor new token listings and early liquidity events in real-time.
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.
swap-planner
This skill should be used when the user asks to "swap tokens", "trade ETH for USDC", "exchange tokens on Uniswap", "buy tokens", "sell tokens", "convert ETH to stablecoins", "find memecoins", "discover tokens", "research tokens", "tokens to buy", "find tokens to swap", "what should I buy", or mentions swapping, trading, researching, discovering, buying, or exchanging tokens on any Uniswap-supported chain. Supports both known token swaps and token discovery workflows (discovery uses keyword search and web search — there is no live "trending" feed). Generates deep links to execute swaps in the Uniswap interface.
swap-integration
Integrate Uniswap swaps into applications. Use when user says "integrate swaps", "uniswap", "trading api", "add swap functionality", "build a swap frontend", "create a swap script", "smart contract swap integration", "use Universal Router", "Trading API", or mentions swapping tokens via Uniswap.