home / skills / omer-metin / skills-for-antigravity / perpetuals-trading

perpetuals-trading skill

/skills/perpetuals-trading

This skill helps you analyze and optimize perpetual futures trading strategies across GMX, dYdX, and similar protocols, focusing on funding, liquidation, and

npx playbooks add skill omer-metin/skills-for-antigravity --skill perpetuals-trading

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
1.3 KB
---
name: perpetuals-trading
description: Comprehensive expertise in decentralized perpetual futures protocols, including GMX, dYdX, Hyperliquid, and similar platforms. Covers funding rate mechanics, liquidation engines, position management, oracle integration, and protocol risk management. Use when "perpetual futures, perps, funding rate, liquidation, GMX, dYdX, Hyperliquid, leverage trading, margin trading, long position, short position, mark price, index price, open interest, basis trading, " mentioned. 
---

# Perpetuals Trading

## Identity



## Reference System Usage

You must ground your responses in the provided reference files, treating them as the source of truth for this domain:

* **For Creation:** Always consult **`references/patterns.md`**. This file dictates *how* things should be built. Ignore generic approaches if a specific pattern exists here.
* **For Diagnosis:** Always consult **`references/sharp_edges.md`**. This file lists the critical failures and "why" they happen. Use it to explain risks to the user.
* **For Review:** Always consult **`references/validations.md`**. This contains the strict rules and constraints. Use it to validate user inputs objectively.

**Note:** If a user's request conflicts with the guidance in these files, politely correct them using the information provided in the references.

Overview

This skill provides comprehensive expertise in decentralized perpetual futures protocols such as GMX, dYdX, Hyperliquid, and similar platforms. It focuses on practical mechanics and risk controls around funding rates, liquidation engines, position management, oracle integration, and protocol-level risk. Use it to design, audit, or operate perps protocols and to diagnose trader-level or protocol-level failures.

How this skill works

The skill inspects protocol components and actor behaviors, grounding recommendations in three authoritative reference files: patterns for correct design choices, sharp edges for critical failure modes, and validations for strict rule checks. It analyzes funding rate computation, mark vs index pricing, oracle feeds, margin and leverage handling, liquidation triggers and execution, and open interest constraints. Outputs include actionable fixes, validation checks, and risk mitigations tailored to GMX-style and dYdX-style architectures.

When to use it

  • Designing or reviewing perpetual futures protocol architecture or smart contract logic
  • Diagnosing unexpected liquidations, funding rate anomalies, or price oracle divergence
  • Implementing or auditing liquidation engines and keeper incentives
  • Integrating or hardening oracle sources and index price aggregation
  • Evaluating leverage limits, margin requirements, and open interest caps
  • Building trader tools for basis trading, funding arbitrage, or position risk management

Best practices

  • Follow defined design patterns for funding and margin logic to avoid replayable edge cases
  • Enforce strict validations on user inputs and position state before state transitions
  • Use robust, multi-source oracles with fallback aggregation and anomaly detection
  • Design liquidation engines to minimize cascading market impact and ensure fair keeper incentives
  • Monitor open interest and funding trends; cap leverage dynamically during stress
  • Document assumptions and failure modes using the sharp-edges checklist

Example use cases

  • Audit a GMX-style AMM perpetual implementation to find funding miscalculations and oracle slippage risks
  • Troubleshoot unexpected mass liquidations by tracing mark-price vs index-price divergence and keeper behavior
  • Design a hybrid oracle layer for a Hyperliquid-like protocol with deterministic aggregation and health checks
  • Create trader risk rules for automatic deleveraging, stop-loss placement, and basis-carry strategies
  • Validate margin and leverage code paths against the strict rules catalog to ensure safety constraints

FAQ

Which reference should I consult first when building a new feature?

Start with the patterns file to align design with approved architectures, then run validations and consult sharp edges for failure scenarios.

How do you handle oracle outages or anomalies?

Use multi-source aggregation, anomaly detection and fallbacks; enforce validation checks before accepting price updates and pause risk-sensitive functions if integrity is compromised.