# Ingravity DeFi Math Guard — AMM & Leverage Risk Calculator

> Ingravity DeFi Math Guard — AMM & Leverage Risk Calculator is a paid API for AI agents from red-shape-1b3b.daviddelmoral79.workers.dev, paid per call via x402, $0.1/call, status unknown (last checked 2026-11-23).

Performs deterministic BigInt AMM swap math (price impact, MEV risk, slippage) and leveraged position liquidation analysis for EVM DeFi protocols.

## Facts

- Endpoint: GET https://red-shape-1b3b.daviddelmoral79.workers.dev/api/v1/defi-math-guard?utm_source=zero.xyz
- Price: $0.1/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-23
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/ingravity-defi-math-guard-amm-leverage-risk-calculator-253fb0b8
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_AtxGWqGhFiAP8AujMCKlr

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability ingravity-defi-math-guard-amm-leverage-risk-calculator-253fb0b8
```

Example prompt: Before I sign this Uniswap swap, check the AMM math: reserve in is 50000000000, reserve out is 300000000000, I'm putting in 2000000000 atomic units, the pool fee is 30 bps, and my slippage tolerance is 100 bps — tell me the exact output, price impact, and whether there's a critical MEV risk.

## When to prefer this

Use this endpoint when an AI agent needs deterministic, BigInt-precise DeFi math before signing or submitting an EVM transaction — specifically for AMM swap output calculation, price impact assessment, MEV sandwich risk scoring, recommended slippage, and leveraged position liquidation thresholds. Prefer this over general LLM math when exact atomic-unit precision is required and financial safety is at stake.

## Known failure modes

- Missing required AMM fields (reserveIn, reserveOut, amountIn) returns 400 validation error
- String BigInt values that cannot be parsed cause computation failure
- Zero reserve values trigger division-by-zero guard and error response
- Payment not included or insufficient USDC causes 402 Payment Required response
- Leverage side enum not LONG or SHORT causes schema validation failure

## How this service works

v3.13.0 Multichain (5 EVM: Base, Arbitrum, Optimism, Polygon, Ethereum) Autonomous Security Swarm via x402 v2: $0.01 binary Fast-Ping + Services 2-7 ($0.10-$45.00 floor plus +0.15% Pre-Flight SLA & 5%-10% Whitehat Safe-Harbor Rescue Bounty on saved capital with Anti-Bypass Seal).

## Output

Returns a JSON object with AMM sub-object containing exactAmountOut (atomic units), purePriceImpactBps (integer basis points), mevRisk (enum: LOW/MEDIUM/HIGH/CRITICAL), and recommendedSlippageBps; optionally includes leverage liquidation price and margin breach data when leverage parameters are provided.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET",
      "POST"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "properties": {
      "amm": {
       "type": "object",
       "required": [
        "reserveIn",
        "reserveOut",
        "amountIn"
       ],
       "properties": {
        "feeBps": {
         "type": "integer",
         "default": 30,
         "maximum": 9999,
         "minimum": 0
        },
        "amountIn": {
         "type": "string"
        },
        "reserveIn": {
         "type": "string"
        },
        "reserveOut": {
         "type": "string"
        },
        "userSlippageBps": {
         "type": "integer",
         "default": 100,
         "maximum": 9999,
         "minimum": 0
        },
        "estimatedSandwichGasInTokenIn": {
         "type": "string",
         "default": "0"
        }
       }
      },
      "tier": {
       "enum": [
        "FULL",
        "ESSENTIAL"
       ],
       "type": "string",
       "default": "FULL"
      },
      "leverage": {
       "type": "object",
       "required": [
        "entryPrice"
       ],
       "properties": {
        "side": {
         "enum": [
          "LONG",
          "SHORT"
         ],
         "type": "string",
         "default": "LONG"
        },
        "leverage": {
         "type": "string",
         "default": "1"
        },
        "entryPrice": {
         "type": "string"
        },
        "feeBufferBps": {
         "type": "integer",
         "default": 10,
         "maximum": 9999,
         "minimum": 0
        },
        "maintenanceMarginBps": {
         "type": "integer",
         "default": 50,
         "maximum": 9999,
         "minimum": 0
        }
       }
      }
     }
    }
   }
  },
  "output": {
   "type": "object",
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "amm": {
   "mevRisk": "CRITICAL",
   "exactAmountOut": "59362905626",
   "purePriceImpactBps": 473,
   "recommendedSlippageBps": 25
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/ingravity-defi-math-guard-amm-leverage-risk-calculator-253fb0b8/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from red-shape-1b3b.daviddelmoral79.workers.dev](https://www.zero.xyz/host/red-shape-1b3b.daviddelmoral79.workers.dev/llms.txt)
