{"uid":"cap_Mt6hBar5lOHizaSVS1DWx","slug":"stealthmark-amm-constant-product-invariant-verifier-8759142e","name":"StealthMark AMM Constant-Product Invariant Verifier","description":"Autonomous Z3 Formal Invariant Prover (ERC-4626 Vaults, Polymarket Baskets, ZK Circuits, Differential Consensus) &amp; 100-Point Perimeter Security Gateway on Base Mainnet (x402 v2).","url":"https://gateway.stealthmark.io/x402/verify-amm-constant-product?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"fee_bps":{"type":"integer","default":30},"amount_in":{"type":"integer"},"reserve_x":{"type":"integer"},"reserve_y":{"type":"integer"},"amount_out":{"type":"integer"},"rounding_direction":{"enum":["down","up"],"type":"string","default":"down"}}},"responseSchema":{"type":"json","example":{"k_after":{"type":"integer"},"message":{"type":"string"},"k_before":{"type":"integer"},"verified":{"type":"boolean"},"check_type":{"type":"string"},"solver_mode":{"type":"string"},"counterexample":{"type":["object","null"]},"invariant_violated":{"type":"boolean"},"max_valid_amount_out":{"type":"integer"}}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.03","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.03/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.03","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.03","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_-9SwWLYaH6wngwxRRAz1h","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.03","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Formally verifies that an AMM swap preserves the constant-product (x*y=k) invariant using Z3, returning proof status, k values, and any counterexample.","exampleAgentPrompt":"Can you formally verify this AMM swap: reserve_x is 1000000, reserve_y is 2000000, amount_in is 5000, amount_out is 9900, with a 30 bps fee and rounding down — does it satisfy the constant-product invariant?","exampleUseCases":[{"title":"Pre-trade invariant check for DEX aggregator","prompt":"Before I route this swap through the pool, verify it's safe: reserve_x is 500000, reserve_y is 800000, I'm putting in 10000 tokens and expecting 15800 out, with a 30 bps fee rounding down — does x*y=k still hold?"},{"title":"Detect potential AMM drain exploit","prompt":"I think this trade might violate the constant-product rule — can you formally prove or disprove it? reserve_x=100000, reserve_y=100000, amount_in=99000, amount_out=99000, fee is 0 bps, rounding down."},{"title":"Find max valid output for a pool trade","prompt":"What's the maximum amount_out I can claim from this pool without breaking the invariant? reserve_x is 2000000, reserve_y is 3000000, amount_in is 20000, fee is 30 bps, rounding down."}],"resultDescription":"Returns a JSON object with: a boolean 'verified' indicating if the invariant holds, 'invariant_violated' flag, 'k_before' and 'k_after' integer values, 'max_valid_amount_out' for the trade, a 'counterexample' object (or null) if the invariant is violated, 'solver_mode' indicating Z3 usage, 'check_type' describing the verification performed, and a human-readable 'message'.","failureModes":["Missing required fields (amount_in, reserve_x, reserve_y, amount_out) returns a 400 error","Negative or zero reserve values may cause solver rejection or undefined behavior","Extremely large integers may exceed Z3 solver time limits","Invalid rounding_direction enum value returns a schema validation error","Payment not provided or insufficient USDC results in 402 Payment Required"],"whenToPreferThis":"Use this endpoint when you need cryptographic-grade formal proof (via Z3 SMT solver) that an AMM swap satisfies x*y=k — not just a numeric check. Prefer it over off-chain arithmetic checks when auditing for exploits, validating DeFi protocol logic, or preparing security reports that require formal verification provenance.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-11-19T18:31:06.232Z","isFirstParty":false,"canonicalSlug":"stealthmark-amm-constant-product-invariant-verifier-8759142e"}