simulating-flash-loans
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".
What this skill does
# Simulating Flash Loans
## Contents
[Overview](#overview) | [Prerequisites](#prerequisites) | [Instructions](#instructions) | [Output](#output) | [Error Handling](#error-handling) | [Examples](#examples) | [Resources](#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:
```bash
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:
```bash
python ${CLAUDE_SKILL_DIR}/scripts/flash_simulator.py arbitrage ETH USDC 100 --compare-providers
```
3. Analyze liquidation profitability on lending protocols:
```bash
python ${CLAUDE_SKILL_DIR}/scripts/flash_simulator.py liquidation \
--protocol aave --health-factor 0.95
```
4. Simulate triangular arbitrage with multi-hop circular paths:
```bash
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:
```bash
python ${CLAUDE_SKILL_DIR}/scripts/flash_simulator.py arbitrage ETH USDC 100 --risk-analysis
```
6. Run full analysis combining all features:
```bash
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:**
```bash
python ${CLAUDE_SKILL_DIR}/scripts/flash_simulator.py arbitrage ETH USDC 100 \
--dex-buy uniswap --dex-sell sushiswap
```
**Find cheapest provider:**
```bash
python ${CLAUDE_SKILL_DIR}/scripts/flash_simulator.py arbitrage ETH USDC 100 --compare-providers
```
**Liquidation opportunity scan:**
```bash
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
- `${CLAUDE_SKILL_DIR}/references/implementation.md` - Provider comparison, strategy details, risk scoring, output modes
- [Aave V3 Flash Loans](https://docs.aave.com/developers/guides/flash-loans)
- dYdX Flash Loans
- Balancer Flash Loans
- [Flashbots Protect](https://docs.flashbots.net/flashbots-protect/overview)
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.