Skip to content
Agentmart
Submit a tool

defi-trading-systems

Designs DeFi trading systems for perpetual futures, liquidity provision, and automated strategies with risk management and MEV protection.

Skill by 4444J99

IndexedMIT★ 17
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/4444j99-defi-trading-systems

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Designs DeFi trading systems for perpetual futures, liquidity provision, and automated strategies with risk management and MEV protection.

Use cases: finance

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/defi-trading-systems

What's inside

Skill name
defi-trading-systems
Description
Designs DeFi trading systems for perpetual futures, liquidity provision, and automated strategies with risk management and MEV protection.
License
MIT
Instructions
659 lines in SKILL.md · view on GitHub

Before installing

  • Instructions call the network

Agent Skills spec issues

  • body: 659 lines (spec recommends under 500)

Files (4)

  • SKILL.md
  • amm-formulas.md · references/
  • mev-protection.md · references/
  • perpetual-mechanics.md · references/

SKILL.md (first lines)

# DeFi Trading Systems

This skill provides guidance for building decentralized finance trading systems, with focus on perpetual futures, automated market makers, and risk management.

## Core Competencies

- **Perpetual Futures**: Funding rates, leverage, liquidation mechanics
- **Automated Market Makers**: Liquidity provision, impermanent loss
- **Risk Management**: Position sizing, stop losses, portfolio hedging
- **MEV Protection**: Sandwich attacks, frontrunning mitigation

## DeFi Trading Fundamentals

### Perpetual Futures Mechanics

```
Traditional Futures:              Perpetual Futures:
┌─────────────────┐              ┌─────────────────┐
│   Expiry Date   │              │   No Expiry     │
│   Settlement    │              │   Funding Rate  │
│   Roll Cost     │              │   Continuous    │
└─────────────────┘              └─────────────────┘

Funding Rate = (Mark Price - Index Price) / Index Price × Interval

If funding > 0: Longs pay Shorts
If funding < 0: Shorts pay Longs
```

### Key Concepts

| Term | Definition |
|------|------------|
| Mark Price | Fair value used for liquidation |
| Index Price | Spot price from exchanges |
| Funding Rate | Periodic payment between longs/shorts |
| Maintenance Margin | Minimum equity to avoid liquidation |
| Liquidation Price | Price at which position is forcibly closed |

## Position Management

### Position Sizing

```python
from dataclasses import dataclass
from decimal import Decimal

@dataclass
class Position:
    symbol: str
    side: str  # 'long' or 'short'
    size: Decimal
    entry_price: Decimal
    leverage: int
    margin: Decimal

    @property
    def notional_value(self) -> Decimal:
        return self.size * self.entry_price

    @property
    def liquidation_price(self) -> Decimal:
        """Calculate liquidation price"""
        maintenance_margin_rate = Decimal('0.005')  # 0.5%

        if self.side == 'long':
            # Liq price = Entry × (1 - Initial Margin + Maintenance Margin)
            return self.entry_price * (
                1 - (1 / self.leverage) + maintenance_margin_rate
            )
        else:
            return self.entry_price * (
                1 + (1 / self.leverage) - maintenance_margin_rate
            )

    def unrealized_pnl(self, current_price: Decimal) -> Decimal:
        """Calculate unrealized P&L"""
        if self.side == 'long':
            return self.size * (current_price - self.entry_price)
        else:
            return self.size * (self.entry_price - current_price)

    def roi_percent(self, current_price: Decimal) -> Decimal:
        """Return on investment percentage"""
        pnl = self.unrealized_pnl(current_price)
        return (pnl / self.margin) * 100


class PositionSizer:
    """Calculate position sizes based on risk parameters"""

    def __init__(self, account_balance: Decimal):
        self.balance = account_balance
        self.max_risk_per_trade = Decimal('0.02')  # 2% of account
        self.max_leverage = 10

    def calculate_size(
        self,
        entry_price: Decimal,
        stop_loss_price: Decimal,
        leverage: int
    ) -> dict:
        """Calculate position size for given risk parameters"""
        # Limit leverage
        leverage = min(leverage, self.max_leverage)

        # Risk amount
        risk_amount = self.balance * self.max_risk_per_trade

        # Price distance to stop
        price_distance = abs(entry_price - stop_loss_price)
        price_distance_pct = price_distance / entry_price

        # Position size based on risk
        # size × price_distance = risk_amount
        size = risk_amount / price_distance

        # Check margin requirements
        required_margin = (size * entry_price) / leverage

From 4444J99/a-i--skills, MIT.

More from 4444J99/a-i--skills

Signals

Stars
17
Forks
9
Open issues
6
Last commit (this folder)
Apr 18, 2026 (6 months ago)
Last release
Feb 6, 2026 (8 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from 4444J99

Cite this page

defi-trading-systems skill. Agent Mart. https://agentmart.dev/skills/4444j99-defi-trading-systems (last updated 2026-10-24)