# finmath – Financial & DeFi Math Engine

> finmath – Financial & DeFi Math Engine is a paid API for AI agents from finmath.qzqh5rrbkz.workers.dev, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-13).

Computes deterministic financial and DeFi calculations (NPV, IRR, Black-Scholes, impermanent loss, Uniswap v3, VaR, health factor, etc.) with base64-encoded input, billed per call in USDC

## Facts

- Endpoint: POST https://finmath.qzqh5rrbkz.workers.dev/v1/base64
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/finmath-financial-defi-math-engine-a5d4d00c
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_hRxQEtOBwmjGoovDJvaS0

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 finmath-financial-defi-math-engine-a5d4d00c -d '<json body>'
```

Example prompt: Can you calculate the Black-Scholes price and delta for a call option with spot price $150, strike $160, 30-day expiry, 20% implied volatility, and 5% risk-free rate?

## When to prefer this

Choose this endpoint when you need exact, reproducible financial arithmetic that LLMs cannot reliably compute themselves — especially for Black-Scholes pricing, Greeks, IRR/XIRR, bond math, DeFi impermanent loss, Uniswap v3 range math, or perp liquidation levels. Prefer it over asking the LLM directly any time precision matters or the calculation is model-free by definition.

## Known failure modes

- Missing or malformed base64-encoded input returns an error
- Invalid or unsupported mode string results in an error response
- Mathematically undefined inputs (e.g. negative time to expiry, zero volatility) may return NaN or an error
- Payment failure (insufficient USDC balance) blocks the call with a 402 response
- Malformed JSON inside the base64 payload causes a parsing error

## How this service works

Deterministic finance and crypto math for AI agents: TradFi (NPV, IRR, XIRR, Black-Scholes + Greeks, bonds, VaR, Sharpe) and DeFi (impermanent loss, perp liquidation, funding, Uniswap v3, health factor, cost basis). Exact, model-free arithmetic that LLMs get wrong — priced per call in USDC.

## Output

Returns a result object containing the computed financial value(s) (e.g. NPV amount, option premium, Greeks, impermanent loss percentage, liquidation price) alongside a meta object with call metadata. The exact shape of result depends on the mode used.

## Example request

```json
{
 "mode": "npv",
 "input": "eyJkaXNjb3VudF9yYXRlIjogMC4xLCAiY2FzaF9mbG93cyI6IFstMTAwMDAsIDMwMDAsIDMwMDAsIDMwMDAsIDMwMDBdLCAicGVyaW9kcyI6IFswLCAxLCAyLCAzLCA0XX0="
}
```

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "input"
 ],
 "properties": {
  "mode": {
   "type": "string",
   "description": "mode"
  },
  "input": {
   "type": "string",
   "description": "input"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "result",
  "meta"
 ],
 "properties": {
  "meta": {
   "type": "object"
  },
  "result": {}
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/finmath-financial-defi-math-engine-a5d4d00c/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from finmath.qzqh5rrbkz.workers.dev](https://www.zero.xyz/host/finmath.qzqh5rrbkz.workers.dev/llms.txt)
