jeremylongshore/tons-of-skills-marketplace / plugins/crypto/flash-loan-simulator/skills/simulating-flash-loans
simulating-flash-loans
VerifiedSimulate 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".
| File | Kind | Size |
|---|---|---|
| ARD.md | markdown | 21.4 KB |
| PRD.md | markdown | 8.7 KB |
| SKILL.md | skill md | 4.5 KB |
| config/settings.yaml | config | 9.4 KB |
| references/errors.md | markdown | 6.5 KB |
| references/examples.md | markdown | 15.0 KB |
| references/implementation.md | markdown | 2.9 KB |
| scripts/flash_simulator.py | script | 14.6 KB |
| scripts/formatters.py | script | 17.4 KB |
| scripts/profit_calculator.py | script | 9.1 KB |
| scripts/protocol_adapters.py | script | 11.9 KB |
| scripts/risk_assessor.py | script | 12.9 KB |
| scripts/strategy_engine.py | script | 18.8 KB |
references/implementation.md
View on GitHub# Implementation Details
## Flash Loan Provider Comparison
| Provider | Fee | Best For | Chains |
|----------|-----|----------|--------|
| dYdX | 0% | Maximum profit | Ethereum |
| Balancer | 0.01% | Pool tokens | ETH, Polygon, Arbitrum |
| Aave V3 | 0.09% | Any token | ETH, Polygon, Arbitrum, Optimism |
| Uniswap V3 | ~0.3% | Specific pairs | ETH, Polygon, Arbitrum |
## Supported Strategies
1. **Simple Arbitrage**: Buy on DEX A, sell on DEX B. Requires price discrepancy > fees + gas.
2. **Triangular Arbitrage**: A->B->C->A circular path. More complex but finds hidden opportunities.
3. **Liquidation**: Repay underwater debt, claim collateral bonus (typically 5-15% on Aave).
4. **Collateral Swap**: Replace collateral without closing position. Useful for risk rotation.
5. **Self-Liquidation**: Efficiently close own position when health factor is low.
6. **Debt Refinancing**: Move debt to better rates across protocols.
## Triangular Arbitrage Output Breakdown
```
Path: ETH -> USDC -> WBTC -> ETH
Gross: +0.15 ETH
Fees: -0.045 ETH (3 swaps)
Loan: -0.045 ETH (Aave fee)
Gas: -0.02 ETH
---------------------
Net: +0.04 ETH ($101.73)
```
## Risk Analysis Scoring
When `--risk-analysis` is enabled, four risk factors are scored 0-100:
- **MEV Competition** (0-100): Measures bot activity on the token pair. Score > 70 means heavy competition from established searchers.
- **Execution Risk** (0-100): Slippage sensitivity and timing requirements. Higher scores mean tighter execution windows.
- **Protocol Risk** (0-100): Smart contract maturity, audit status, oracle reliability. Lower is safer.
- **Liquidity Risk** (0-100): Whether pool depth supports the trade size. Score > 80 means trade may move price significantly.
Overall viability grades:
- **A**: All risks low, high confidence
- **B**: Moderate risks, proceed with caution
- **C**: High risks, likely unprofitable
- **F**: Do not attempt
## Output Modes
**Quick Mode** (default):
- Net profit/loss, provider recommendation, Go/No-Go verdict
**Breakdown Mode** (`--breakdown`):
- Step-by-step transaction flow, individual cost components, slippage estimates
**Comparison Mode** (`--compare-providers`):
- All providers ranked by net profit, fee differences, liquidity availability
**Risk Analysis** (`--risk-analysis`):
- Competition score, execution probability, protocol safety, overall viability grade
## Educational Disclaimer
**FOR EDUCATIONAL PURPOSES ONLY.** Flash loan strategies involve significant risks:
- Smart contract bugs can cause total loss of borrowed funds
- MEV bots compete for the same opportunities with faster infrastructure
- Gas costs can exceed profits, especially during network congestion
- Protocol exploits may have legal implications
Never deploy unaudited code. Start with testnets. Consult legal counsel for compliance.
---
*[Tons of Skills](https://tonsofskills.com) by [Intent Solutions](https://intentsolutions.io) | [jeremylongshore.com](https://jeremylongshore.com)*
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |