{"uid":"cap_AtxGWqGhFiAP8AujMCKlr","slug":"ingravity-defi-math-guard-amm-leverage-risk-calculator-253fb0b8","name":"Ingravity DeFi Math Guard — AMM & Leverage Risk Calculator","description":"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).","url":"https://red-shape-1b3b.daviddelmoral79.workers.dev/api/v1/defi-math-guard?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"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"}}}}},"responseSchema":{"type":"json","example":{"amm":{"mevRisk":"CRITICAL","exactAmountOut":"59362905626","purePriceImpactBps":473,"recommendedSlippageBps":25}}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.04","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.1/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.1","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.1","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_6tT5srNPjC34RZjk7TBkU","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.1","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Performs deterministic BigInt AMM swap math (price impact, MEV risk, slippage) and leveraged position liquidation analysis for EVM DeFi protocols.","exampleAgentPrompt":"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.","exampleUseCases":[{"title":"Pre-swap MEV and slippage sanity check","prompt":"I'm about to swap on a Uniswap V2 pool with reserveIn of 80000000000, reserveOut of 500000000000, and an amountIn of 5000000000, pool fee 30 bps and my slippage set to 200 bps — run the AMM math and tell me if my slippage is dangerously high and what the MEV risk looks like."},{"title":"Leveraged long liquidation threshold","prompt":"I'm opening a 10x LONG at an entry price of 2500.00 — can you compute my liquidation price and check if my position is at risk given a maintenance margin of 50 bps?"},{"title":"Optimal slippage recommendation for large trade","prompt":"I want to do a big AMM swap: reserveIn is 10000000000, reserveOut is 60000000000, amountIn is 8000000000 at a 30 bps fee — what's the actual price impact and what slippage tolerance should I set to avoid getting sandwiched?"}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-11-23T12:36:13.085Z","isFirstParty":false,"canonicalSlug":"ingravity-defi-math-guard-amm-leverage-risk-calculator-253fb0b8"}