defi-trading-systems

Designs DeFi trading systems for perpetual futures, AMM liquidity, and MEV protection.

Updated May 16, 2026
One-click install
npx skills add https://github.com/organvm-i-theoria/_agent-ontology --skill defi-trading-systems-organvm-i-theoria
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: defi-trading-systems
Source: https://github.com/organvm-i-theoria/_agent-ontology/tree/main/.agents/skills/defi-trading-systems
Command: npx skills add https://github.com/organvm-i-theoria/_agent-ontology --skill defi-trading-systems-organvm-i-theoria

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires web3, numpy, requests, eth-account, and includes references (resource) components.

What problem does it solve? Building decentralized finance trading systems requires deep knowledge of perpetual futures mechanics, AMM mathematics, liquidation logic, and MEV attack vectors, which are easy to get wrong and costly when mishandled. ## Core Features & Use Cases - Perpetual Futures Modeling: Calculate funding rates, liquidation prices, margin ratios, and position sizing with risk-based leverage limits. - AMM & Liquidity Analysis: Compute impermanent loss, concentrated liquidity positions (Uniswap V3 style), and LP returns versus holding. - MEV Protection: Apply slippage limits, order chunking, TWAP schedules, and Flashbots private mempool submission to mitigate sandwich attacks. - Use Case: A quant developer building a funding-rate arbitrage bot can use the position sizing, liquidation monitoring, and cross-exchange funding spread logic to structure trades with defined risk limits. ## Quick Start Ask the agent to design a perpetual futures position sizing strategy with liquidation monitoring and MEV protection for a given account balance and risk tolerance.

Frequently Asked Questions about defi-trading-systems

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I calculate the liquidation price for a perpetual futures position?▼

For a long position, liquidation price equals entry price times (1 minus 1/leverage plus maintenance margin rate). For a short, it is entry times (1 plus 1/leverage minus the maintenance margin rate). The skill includes a Position class implementing both formulas.

How is impermanent loss calculated for a Uniswap liquidity position?▼

Impermanent loss for a constant product AMM equals 2 times the square root of the price ratio divided by (1 plus the price ratio), minus 1. A 2x price move produces roughly 5.7% loss versus holding, and the skill provides calculators for both V2 and concentrated V3 positions.

What strategies protect trades from MEV sandwich attacks?▼

Key protections include setting tight slippage limits, submitting transactions through private mempools like Flashbots, splitting large orders into smaller chunks, using TWAP execution schedules, and routing through batch auction protocols such as CoW Protocol.

How does funding rate arbitrage work across exchanges?▼

Funding arbitrage captures the spread between the highest and lowest funding rates for the same symbol by going long on the low-rate exchange and short on the high-rate exchange. A spot-perp basis trade variant shorts the perpetual and holds spot when funding is positive.

When should I use a private mempool instead of the public mempool?▼

Use a private mempool when trade size and gas conditions make the transaction attractive to MEV bots. The skill scores risk as trade size in USD divided by 10,000 multiplied by gas price divided by 50, recommending private submission when the score exceeds 1.0.