# StealthMark AMM Constant-Product Invariant Verifier

> StealthMark AMM Constant-Product Invariant Verifier is a paid API for AI agents from gateway.stealthmark.io, paid per call via x402, $0.03/call, status unknown (last checked 2026-11-19).

Formally verifies that an AMM swap preserves the constant-product (x*y=k) invariant using Z3, returning proof status, k values, and any counterexample.

## Facts

- Endpoint: POST https://gateway.stealthmark.io/x402/verify-amm-constant-product?utm_source=zero.xyz
- Price: $0.03/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-19
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/stealthmark-amm-constant-product-invariant-verifier-8759142e
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_Mt6hBar5lOHizaSVS1DWx

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 stealthmark-amm-constant-product-invariant-verifier-8759142e -d '<json body>'
```

Example prompt: 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?

## When to prefer this

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.

## Known failure modes

- 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

## How this service works

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).

## Output

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'.

## Request schema (JSON Schema)

```json
{
 "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"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "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"
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/stealthmark-amm-constant-product-invariant-verifier-8759142e/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from gateway.stealthmark.io](https://www.zero.xyz/host/gateway.stealthmark.io/llms.txt)
