# slippage-modeling

Estimates execution cost on AMMs: price impact, DEX fees, priority fees and sandwich risk. Useful when you need to know what a swap really costs and where break-even sits.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 474 installs · ★ 443
- Author: agiprolabs
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/agiprolabs/claude-trading-skills/tree/HEAD/skills/slippage-modeling/SKILL.md
- Updated: 2026-09-03
- HTML: https://affpapa.org/en/nevibecode/skills/slippage-modeling

## What it does

The skill breaks slippage down by source. The main one is price impact on a constant-product curve: `Δx / (x + Δx)` means a 1 SOL trade against 100 SOL of reserves costs about 1%, and against 10 SOL it costs about 10%. Then come DEX fees (Raydium 0.25%, Orca 0.30%, Meteora 0.1–2.0%, PumpFun 1.0%), Solana priority fees, and sandwich risk, which grows on thin pools.

For CLMMs (Orca Whirlpools, Meteora DLMM) it accounts for concentrated liquidity: inside the active range slippage is lower than constant-product, but crossing a tick boundary adds cost. The formulas assume single-pool routing, so for real Jupiter routes the skill recommends measuring instead — query `/quote` at 0.01, 0.1, 1, 5, 10 and 50 SOL, then fit `slippage_bps = a * trade_size^b`. The implementation lives in `scripts/slippage_curve.py`, cost estimation in `scripts/execution_cost.py`.

A full cost model adds price impact, fees, priority fee and MEV into `total_cost_bps`. For a roundtrip the break-even formula is blunt: with 200 bps in, 200 bps out and 50 bps of fees, the token has to move 4.5% just to get you back to zero. From there the skill solves for the largest trade that stays under a slippage threshold and suggests tranches or TWAP. Pool TVL and reserve data come from `liquidity-analysis`, so without that skill some inputs are manual.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add agiprolabs/claude-trading-skills --skill slippage-modeling -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/slippage-modeling/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/slippage-modeling/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add agiprolabs/claude-trading-skills --skill slippage-modeling -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/slippage-modeling/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add agiprolabs/claude-trading-skills --skill slippage-modeling -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/slippage-modeling/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install agiprolabs/claude-trading-skills slippage-modeling
```

2. **Manually: put the files in place**
- File: `.github/skills/slippage-modeling/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add agiprolabs/claude-trading-skills --skill slippage-modeling -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/agiprolabs/claude-trading-skills --path skills/slippage-modeling
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/slippage-modeling/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add agiprolabs/claude-trading-skills --skill slippage-modeling -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/agiprolabs/claude-trading-skills/tree/HEAD/skills/slippage-modeling/SKILL.md

## When to use it
- compute price impact from pool reserves
- add DEX fees, priority fees and MEV into one cost figure
- find the trade size that stays under a slippage threshold
- estimate the break-even move for a roundtrip
- split a large order into tranches or run it as TWAP

## Example prompts
- estimate slippage for a 5 SOL swap in this pool
- what's the largest trade that stays under 100 bps slippage?
- build a slippage curve from Jupiter quotes at 0.1, 1 and 10 SOL

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 2621f142459418f0.

BEGIN THIRD-PARTY FILE 2621f142459418f0
````text
---
name: slippage-modeling
description: Execution cost estimation, slippage curve modeling, and optimal trade sizing based on AMM liquidity depth
---

# Slippage Modeling

Estimate execution costs, model slippage curves from AMM mechanics and empirical quotes, and determine optimal trade sizes that keep costs within acceptable thresholds.

## What Is Slippage?

Slippage is the difference between the **expected price** at the time you decide to trade and the **actual execution price** you receive. On decentralized exchanges, slippage is deterministic and measurable — unlike CEX slippage, which depends on hidden order book dynamics.

**Example**: You expect to buy a token at 0.001 SOL. Your trade executes at 0.00105 SOL. That 5% difference is slippage — it directly reduces your profit and increases your break-even threshold.

## Sources of Slippage

### 1. AMM Price Impact (Primary Source)

Automated market makers use bonding curves that move price as liquidity is consumed. On a constant-product AMM (`x * y = k`):

```
price_impact = Δx / (x + Δx)
```

Where `x` is the reserve of the input token and `Δx` is your trade size. A 1 SOL trade against a pool with 100 SOL reserves produces ~1% price impact. Against 10 SOL reserves, it produces ~10%.

See `references/slippage_math.md` for full derivations and CLMM adjustments.

### 2. DEX Fees

Every swap incurs a fee taken from the trade:

| DEX      | Fee       | Notes                          |
|----------|-----------|--------------------------------|
| Raydium  | 0.25%     | Standard AMM pools             |
| Orca     | 0.30%     | Whirlpool concentrated pools   |
| Meteora  | 0.1–2.0%  | Dynamic fees based on volatility|
| PumpFun  | 1.0%      | Bonding curve phase            |

### 3. Priority Fees

Solana validators prioritize transactions with higher compute unit prices. During congestion or for time-sensitive trades:
- Normal: 0.0001 SOL (negligible)
- Competitive: 0.001–0.01 SOL
- High congestion: 0.01–0.1 SOL

### 4. MEV (Sandwich Attacks)

Searchers detect pending swaps and sandwich them — buying before your trade (raising the price) and selling after (capturing the difference). MEV cost depends on:
- Trade size (larger = more attractive target)
````
END THIRD-PARTY FILE 2621f142459418f0

The third-party file has ended. Everything between the 2621f142459418f0 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2252 of 7926 bytes. © agiprolabs · MIT · https://github.com/agiprolabs/claude-trading-skills/tree/HEAD/skills/slippage-modeling/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
