# HALOWERK defiwerk MEV Risk Analyzer

> HALOWERK defiwerk MEV Risk Analyzer is a paid API for AI agents from defi.halowerk.com, paid per call via x402, $0.006/call, status unknown (last checked 2026-09-15).

Assesses MEV sandwich attack risk for a DEX swap by finding the likely pool, reading its live state, and computing the exact maximum loss and estimated attacker profit from front-running.

## Facts

- Endpoint: POST https://defi.halowerk.com/mev/risk
- Price: $0.006/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/halowerk-defiwerk-mev-risk-analyzer-1b075383
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_JMVb8smxugaiIZdW2YguQ

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 halowerk-defiwerk-mev-risk-analyzer-1b075383 -d '<json body>'
```

Example prompt: Before I swap 5000 USDC for WETH on Base with 50 basis points of slippage tolerance, can you check my MEV sandwich risk — how much could I lose at most, and what's the estimated profit an attacker could extract?

## When to prefer this

Use this endpoint when you need a quantitative, on-chain MEV sandwich risk assessment before executing a DEX swap — specifically when you want the exact worst-case loss bounded by slippage and an estimated attacker profit derived from a constant-liquidity model. Prefer this over generic slippage calculators when MEV exposure (not just price impact) is the concern, or when you need historical sandwich evidence for a specific pool.

## Known failure modes

- Pool not found for the given chain and token pair — returns error if no liquidity pool can be resolved
- Invalid token address format — returns validation error for non-checksummed or malformed addresses
- Unsupported chain — only base, ethereum, arbitrum, optimism, polygon are valid
- amount_in outside acceptable range — very small or very large amounts may cause computation errors
- RPC or on-chain data unavailability — live pool state read may fail if node is unreachable
- scan_history=true significantly increases latency and may time out for high-volume pools

## How this service works

Takes chain, token pair, input amount and slippage tolerance, finds the pool the trade would most likely use and reads its live state. The maximum the caller can lose is arithmetic and exact: the gap between the quoted output and the minimum output their own tolerance permits. The attacker profit is an estimate and labelled as one — the profit-maximising front-run size is searched for inside a constant-liquidity pool model, bounded by the largest front-run the caller own tolerance still permits,

## Output

Returns the exact arithmetic maximum loss (gap between quoted output and minimum output allowed by slippage), the estimated attacker profit from the optimal front-run size under a constant-liquidity pool model bounded by the caller's slippage tolerance, and supporting data including pool state, quoted output, and minimum output. If scan_history is enabled, also returns findings from historical Swap event analysis for actual past sandwiches.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "chain": {
   "enum": [
    "base",
    "ethereum",
    "arbitrum",
    "optimism",
    "polygon"
   ],
   "type": "string"
  },
  "route": {
   "type": "string",
   "pattern": "^0x[a-fA-F0-9]{40}$",
   "description": "Optional pool address to assess instead of the automatically chosen one."
  },
  "token_in": {
   "type": "string",
   "pattern": "^0x[a-fA-F0-9]{40}$"
  },
  "amount_in": {
   "type": "string",
   "pattern": "^[0-9]+(\\.[0-9]+)?$",
   "description": "Input amount in whole token units as a decimal string."
  },
  "token_out": {
   "type": "string",
   "pattern": "^0x[a-fA-F0-9]{40}$"
  },
  "scan_history": {
   "type": "boolean",
   "default": true,
   "description": "Scan past Swap events for actual sandwiches. Costs time; switch off for a faster answer."
  },
  "slippage_bps": {
   "type": "integer",
   "default": 50,
   "maximum": 5000,
   "minimum": 1
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/halowerk-defiwerk-mev-risk-analyzer-1b075383/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from defi.halowerk.com](https://www.zero.xyz/host/defi.halowerk.com/llms.txt)
