Slippage logo

Slippage

CommunityPopular
alsk1992
slippage

Slippage estimation, optimization, and protection for trade execution

Overview

Publisheralsk1992
RepositoryCloddsBot
Skill nameslippage
Stars
3K
Forks
353
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by alsk1992 on GitHub. Read the source before you install it.

Installation

Install the Slippage AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/alsk1992/CloddsBot/tree/main/src/skills/bundled/slippage
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/alsk1992/CloddsBot.git /tmp/CloddsBot
mkdir -p .claude/skills
cp -r /tmp/CloddsBot/src/skills/bundled/slippage .claude/skills/slippage
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Slippage in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Slippage on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Slippage is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Slippage - Complete API Reference

Estimate, minimize, and protect against slippage across all trading platforms.


Chat Commands

Estimate Slippage

/slippage estimate "Trump" YES 5000    Estimate for $5000 order
/slippage BTCUSDT 1.5 BTC              Estimate for futures
/slippage ETH 50 --dex uniswap         Estimate DEX slippage

Analyze Orderbook

/slippage depth "Trump"                Show orderbook depth
/slippage impact 10000                 Price impact for size
/slippage levels "Trump"               Show slippage at sizes

Optimize Execution

/slippage optimize "Trump" YES 10000   Find best execution
/slippage split 50000                  Optimal order splitting
/slippage timing "Trump"               Best times for low slippage

Protection Settings

/slippage max 1%                       Set max slippage tolerance
/slippage protect on                   Enable slippage protection
/slippage revert-threshold 2%          Cancel if slippage exceeds

TypeScript API Reference

Create Slippage Manager

typescript
import { createSlippageManager } from 'clodds/slippage';

const slippage = createSlippageManager({
  // Default tolerance
  defaultMaxSlippage: 0.01,  // 1%

  // Protection
  enableProtection: true,
  revertThreshold: 0.02,  // Cancel if > 2%

  // Data sources
  orderbookDepth: 20,  // Levels to analyze
  refreshInterval: 1000,  // ms
});

Estimate Slippage

typescript
const estimate = await slippage.estimate({
  platform: 'polymarket',
  market: 'trump-win-2028',
  side: 'YES',
  size: 5000,
});

console.log(`Expected slippage: ${estimate.slippage}%`);
console.log(`Price impact: ${estimate.priceImpact}%`);
console.log(`Effective price: ${estimate.effectivePrice}`);
console.log(`Best price: ${estimate.bestPrice}`);
console.log(`Worst price: ${estimate.worstPrice}`);
console.log(`Confidence: ${estimate.confidence}%`);

Analyze Orderbook Depth

typescript
const depth = await slippage.analyzeDepth({
  platform: 'polymarket',
  market: 'trump-win-2028',
  side: 'YES',
});

console.log('Orderbook Depth:');
console.log(`  Liquidity at 0.5%: $${depth.liquidityAt05Pct}`);
console.log(`  Liquidity at 1%: $${depth.liquidityAt1Pct}`);
console.log(`  Liquidity at 2%: $${depth.liquidityAt2Pct}`);
console.log(`  Total depth: $${depth.totalDepth}`);

console.log('\nSlippage by Size:');
for (const level of depth.slippageLevels) {
  console.log(`  $${level.size}: ${level.slippage}% slippage`);
}

Price Impact Analysis

typescript
const impact = await slippage.priceImpact({
  platform: 'polymarket',
  market: 'trump-win-2028',
  side: 'YES',
  sizes: [1000, 5000, 10000, 25000, 50000],
});

console.log('Price Impact Analysis:');
for (const level of impact.levels) {
  console.log(`  $${level.size}:`);
  console.log(`    Slippage: ${level.slippage}%`);
  console.log(`    Impact: ${level.impact}%`);
  console.log(`    Effective: ${level.effectivePrice}`);
}

Optimize Execution

typescript
const optimized = await slippage.optimize({
  platform: 'polymarket',
  market: 'trump-win-2028',
  side: 'YES',
  size: 25000,
  maxSlippage: 0.01,
});

console.log('Optimized Execution:');
console.log(`  Strategy: ${optimized.strategy}`);  // 'single' | 'split' | 'twap'
console.log(`  Expected slippage: ${optimized.expectedSlippage}%`);
console.log(`  vs naive: ${optimized.naiveSlippage}%`);
console.log(`  Savings: $${optimized.savings}`);

if (optimized.strategy === 'split') {
  console.log('\nOrder Split:');
  for (const order of optimized.orders) {
    console.log(`  ${order.size} @ ${order.limitPrice} (${order.delay}s delay)`);
  }
}

Order Splitting

typescript
const split = await slippage.splitOrder({
  platform: 'polymarket',
  market: 'trump-win-2028',
  side: 'YES',
  totalSize: 50000,
  maxSlippagePerOrder: 0.005,  // 0.5% max per order
  minOrderSize: 1000,
});

console.log(`Split into ${split.orders.length} orders:`);
for (const order of split.orders) {
  console.log(`  $${order.size} - expected ${order.expectedSlippage}%`);
}
console.log(`Total expected slippage: ${split.totalSlippage}%`);
console.log(`Execution time: ${split.estimatedTime}s`);

TWAP Execution

typescript
const twap = await slippage.twapSchedule({
  platform: 'polymarket',
  market: 'trump-win-2028',
  side: 'YES',
  totalSize: 100000,
  duration: 3600,  // 1 hour
  intervals: 12,   // 12 orders
});

console.log('TWAP Schedule:');
for (const order of twap.orders) {
  console.log(`  ${order.time}: $${order.size}`);
}
console.log(`Expected avg slippage: ${twap.expectedSlippage}%`);

Best Timing Analysis

typescript
const timing = await slippage.analyzeTiming({
  platform: 'polymarket',
  market: 'trump-win-2028',
  side: 'YES',
  size: 10000,
});

console.log('Best Times for Low Slippage:');
for (const window of timing.bestWindows) {
  console.log(`  ${window.time}: avg ${window.avgSlippage}% slippage`);
  console.log(`    Liquidity: $${window.avgLiquidity}`);
}

console.log('\nWorst Times:');
for (const window of timing.worstWindows) {
  console.log(`  ${window.time}: avg ${window.avgSlippage}% slippage`);
}

Slippage Protection

typescript
// Set protection parameters
slippage.setProtection({
  maxSlippage: 0.01,           // 1% max
  revertThreshold: 0.02,       // Cancel if > 2%
  notifyThreshold: 0.005,      // Alert at 0.5%
  retryOnRevert: true,         // Retry with lower size
  retryReductionPct: 50,       // Reduce size by 50%
});

// Execute with protection
const result = await slippage.executeProtected({
  platform: 'polymarket',
  market: 'trump-win-2028',
  side: 'YES',
  size: 10000,
});

console.log(`Executed: ${result.executed}`);
console.log(`Actual slippage: ${result.actualSlippage}%`);
console.log(`Protected: ${result.protected}`);
if (result.reverted) {
  console.log(`Reverted: ${result.revertReason}`);
}

DEX Slippage (Crypto)

typescript
const dexSlippage = await slippage.estimateDex({
  chain: 'ethereum',
  dex: 'uniswap',
  tokenIn: 'USDC',
  tokenOut: 'ETH',
  amountIn: 50000,
});

console.log('DEX Slippage Estimate:');
console.log(`  Expected out: ${dexSlippage.expectedOut}`);
console.log(`  Min out (1% slip): ${dexSlippage.minOut1Pct}`);
console.log(`  Price impact: ${dexSlippage.priceImpact}%`);
console.log(`  Route: ${dexSlippage.route.join(' → ')}`);

Historical Slippage

typescript
const history = await slippage.getHistory({
  platform: 'polymarket',
  period: '30d',
});

console.log('Historical Slippage:');
console.log(`  Avg slippage: ${history.avgSlippage}%`);
console.log(`  Max slippage: ${history.maxSlippage}%`);
console.log(`  Trades with > 1%: ${history.tradesOver1Pct}`);
console.log(`  Total slippage cost: $${history.totalCost}`);

Slippage Factors

FactorImpactMitigation
Order sizeLarger = more slipSplit orders
LiquidityThin = more slipCheck depth first
VolatilityHigh = more slipUse limit orders
Time of dayOff-hours = more slipTrade peak hours
Market typeNew = more slipAvoid illiquid markets

Protection Modes

ModeBehavior
warnAlert but execute
confirmRequire confirmation
blockCancel if exceeds
retryRetry with smaller size

Best Practices

  1. Always estimate first — Check slippage before trading
  2. Split large orders — Reduce impact on thin orderbooks
  3. Use limit orders — Protect against unexpected slippage
  4. Trade liquid markets — Higher volume = lower slippage
  5. Monitor execution — Track actual vs expected slippage

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Slippage AI skill do?

Slippage estimation, optimization, and protection for trade execution

Why use Slippage on TypingMind?

Because you install it once and use it with any model. Slippage is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Slippage in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/alsk1992/CloddsBot/tree/main/src/skills/bundled/slippage. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Slippage?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Slippage?

As many as you like. As long as a model supports skills, you can use Slippage with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Slippage AI skill free?

Yes. It is published on GitHub by alsk1992 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇