Simulating Flash Loans

VerifiedCaution

Simulate flash loan strategies with profitability calculations and risk assessment across Aave, dYdX, and Balancer.

Sby Skills Guide Bot
Data & AIAdvanced
7/27/2026
Claude CodeCodex
#defi#flash-loans#arbitrage#risk-analysis#simulation

Recommended for

Automated summary

This skill simulates flash loan strategies across Aave V3, dYdX, and Balancer, calculating profitability, fees, gas costs, and risk assessment.

Strengths

  • Supports two-DEX arbitrage, liquidations, and triangular arbitrage with automatic fee and gas calculations.
  • Compares flash loan providers to identify the lowest net cost for a given strategy.
  • Includes risk scoring and a viability grade, with machine-readable JSON output.
  • Produces a quick Go/No-Go verdict and provider recommendation.

Limitations

  • It does not execute real transactions; it is a simulation-only tool.
  • Accuracy depends on RPC access, price freshness, and available gas estimates.
  • Coverage is limited to the platforms and routes described by the simulator, not all possible DeFi protocols.
When to use it

Use it to quickly assess whether a flash loan strategy is viable before implementation or on-chain execution.

When not to use it

Do not use it to execute real transactions or when you need regulated, comprehensive financial analysis.

Security analysis

Caution
Quality score80/100

The SKILL.md contains no destructive, obfuscated, or exfiltrating instructions: no curl|sh, no rm -rf, no base64 payloads, no attempts to disable safety. Bash usage is scoped to a specific command prefix and the stated purpose is local simulation. The main residual risk is that the actual Python scripts are not shown here and make network calls while potentially handling an RPC/Etherscan key, so a reviewer should confirm the bundled code before publication.

Findings
  • •Invokes bundled Python scripts via Bash(crypto:flashloan-*), whose contents are not included in SKILL.md and cannot be audited from this file alone
  • •Scripts make outbound network calls to RPC endpoints and optionally Etherscan, with credentials referenced via config/settings.yaml and ETH_RPC_URL env var
  • •Uses powerful tools (Bash, Write, file edits) for legitimate DeFi simulation purposes; no destructive or exfiltrating commands present in the instructions
  • •DeFi/financial domain context means output could inform real capital deployment, though the skill is explicitly simulation-only and executes no on-chain transactions
How this analysis is made

Examples

Basic arbitrage simulation
Simulate a flash loan arbitrage for 100 ETH/USDC buying on Uniswap and selling on Sushiswap, and tell me the net profit and Go/No-Go verdict.
Provider comparison
Compare Aave, dYdX, and Balancer flash loan providers for a 100 ETH/USDC arbitrage strategy and recommend the cheapest option.
Liquidation risk scan
Analyze Aave liquidation profitability at a 0.95 health factor and include competition, execution, protocol, and liquidity risk scores.

name: simulating-flash-loans description: | Simulate flash loan strategies with profitability calculations and risk assessment across Aave, dYdX, and Balancer. Use when simulating flash loans, analyzing arbitrage profitability, evaluating liquidation opportunities, or comparing flash loan providers. Trigger with phrases like "simulate flash loan", "flash loan arbitrage", "liquidation profit", "compare Aave dYdX", "flash loan strategy", or "DeFi arbitrage simulation".

allowed-tools: Read, Write, Edit, Grep, Glob, Bash(crypto:flashloan-*) version: 1.0.0 author: Jeremy Longshore jeremy@intentsolutions.io license: MIT compatible-with: claude-code, codex, openclaw

Simulating Flash Loans

Contents

Overview | Prerequisites | Instructions | Output | Error Handling | Examples | Resources

Overview

Simulate flash loan strategies across Aave V3, dYdX, and Balancer with profitability calculations, gas cost estimation, and risk assessment. Evaluate flash loan opportunities without executing real transactions.

Prerequisites

  1. Install Python 3.9+ with web3, httpx, and rich packages
  2. Configure RPC endpoint access (free public RPCs via https://chainlist.org work fine)
  3. Optionally add Etherscan API key for better gas estimates
  4. Set RPC in ${CLAUDE_SKILL_DIR}/config/settings.yaml or use ETH_RPC_URL env var

Instructions

  1. Simulate a two-DEX arbitrage with automatic fee and gas calculation:
    python ${CLAUDE_SKILL_DIR}/scripts/flash_simulator.py arbitrage ETH USDC 100 \
      --dex-buy uniswap --dex-sell sushiswap
    
  2. Compare flash loan providers to find the cheapest for your strategy:
    python ${CLAUDE_SKILL_DIR}/scripts/flash_simulator.py arbitrage ETH USDC 100 --compare-providers
    
  3. Analyze liquidation profitability on lending protocols:
    python ${CLAUDE_SKILL_DIR}/scripts/flash_simulator.py liquidation \
      --protocol aave --health-factor 0.95
    
  4. Simulate triangular arbitrage with multi-hop circular paths:
    python ${CLAUDE_SKILL_DIR}/scripts/flash_simulator.py triangular \
      ETH USDC WBTC ETH --amount 50
    
  5. Add risk assessment (MEV competition, execution, protocol, liquidity) to any simulation:
    python ${CLAUDE_SKILL_DIR}/scripts/flash_simulator.py arbitrage ETH USDC 100 --risk-analysis
    
  6. Run full analysis combining all features:
    python ${CLAUDE_SKILL_DIR}/scripts/flash_simulator.py arbitrage ETH USDC 100 \
      --full --output json > simulation.json
    

Output

  • Quick Mode: Net profit/loss, provider recommendation, Go/No-Go verdict
  • Breakdown Mode: Step-by-step transaction flow with individual cost components
  • Comparison Mode: All providers ranked by net profit with fee differences
  • Risk Analysis: Competition, execution, protocol, and liquidity scores (0-100) with viability grade (A-F)

See ${CLAUDE_SKILL_DIR}/references/implementation.md for detailed output examples and risk scoring methodology.

Error Handling

| Error | Cause | Solution | |-------|-------|----------| | RPC Rate Limit | Too many requests | Switch to backup endpoint or wait | | Stale Prices | Data older than 30s | Auto-refreshes with warning | | No Profitable Route | All routes lose after costs | Try different pairs or amounts | | Insufficient Liquidity | Trade exceeds pool depth | Reduce amount or split across pools |

See ${CLAUDE_SKILL_DIR}/references/errors.md for comprehensive error handling.

Examples

Basic arbitrage simulation:

python ${CLAUDE_SKILL_DIR}/scripts/flash_simulator.py arbitrage ETH USDC 100 \
  --dex-buy uniswap --dex-sell sushiswap

Find cheapest provider:

python ${CLAUDE_SKILL_DIR}/scripts/flash_simulator.py arbitrage ETH USDC 100 --compare-providers

Liquidation opportunity scan:

python ${CLAUDE_SKILL_DIR}/scripts/flash_simulator.py liquidation --protocol aave --health-factor 0.95

See ${CLAUDE_SKILL_DIR}/references/examples.md for multi-provider comparison and backtesting examples.

Resources

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/simulating-flash-loans-ms2s7d3p/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/simulating-flash-loans-ms2s7d3p' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/simulating-flash-loans-ms2s7d3p/download' --output '.skill-downloads/simulating-flash-loans-ms2s7d3p/SKILL.md.part' && mv '.skill-downloads/simulating-flash-loans-ms2s7d3p/SKILL.md.part' '.skill-downloads/simulating-flash-loans-ms2s7d3p/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Read, Write, Edit, Grep, Glob, Bash(crypto:flashloan-*)

Original excerpt: Prerequisites
  1. Install Python 3.9+ with web3, httpx, and rich packages
  2. Configure RPC endpoint access (free public RPCs via https://chainlist.org work fine)
  3. Optionally add Etherscan API key for better gas estimates
  4. Set RPC in ${CLAUDE_SKILL_DIR}/config/settings.yaml or use ETH_RPC_URL env var

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/simulating-flash-loans-ms2s7d3p/SKILL.md' && test -s '.skill-downloads/simulating-flash-loans-ms2s7d3p/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/simulating-flash-loans' && cp -R '.skill-downloads/simulating-flash-loans-ms2s7d3p' '.claude/skills/simulating-flash-loans'

Codex
test -f '.skill-downloads/simulating-flash-loans-ms2s7d3p/SKILL.md' && test -s '.skill-downloads/simulating-flash-loans-ms2s7d3p/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/simulating-flash-loans' && cp -R '.skill-downloads/simulating-flash-loans-ms2s7d3p' '.agents/skills/simulating-flash-loans'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/simulating-flash-loans-ms2s7d3p'

openskills read 'simulating-flash-loans-ms2s7d3p'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/simulating-flash-loans-ms2s7d3p/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills