# PayAI DeFi Math Helper

> PayAI DeFi Math Helper is a paid API for AI agents from payai.agentstools.dev, paid per call via x402, $0.002/call, status unknown (last checked 2026-10-11).

Performs pure DeFi financial computations including APR/APY conversion, funding rate annualization, impermanent loss, liquidation price, leverage, and LP value calculations.

## Facts

- Endpoint: GET https://payai.agentstools.dev/quant/defi?utm_source=zero.xyz
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-11
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/payai-defi-math-helper-7c7afaba
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_T_DWkjB7XFL5pBmYH4GYs

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 payai-defi-math-helper-7c7afaba
```

Example prompt: What's the liquidation price for a long position entered at $2,500 with 10x leverage? Also, what's the APY on a 15% APR compounded daily (365 periods)?

## When to prefer this

Use this endpoint when you need precise, formula-based DeFi math without building the formulas yourself — especially for APR/APY conversion, impermanent loss estimation for LP positions, liquidation price calculation for leveraged trades, or funding rate annualization for perpetual futures. Prefer this over generic calculators when the agent needs structured JSON output for downstream processing.

## Known failure modes

- Missing required query parameter for the selected op (e.g. no apr provided for apr_to_apy) returns a validation error
- Invalid op enum value returns a 400 bad request
- Non-numeric values for numeric fields cause a parse error
- Missing required op parameter entirely causes a 400 error

## How this service works

DeFi math helper: APR and APY conversion, funding annualization, impermanent loss, liquidation price, and leverage. Pure computation over your inputs.

## Output

Returns the computed DeFi metric for the requested operation — e.g. a numeric APY, APR, annualized funding rate, impermanent loss percentage, liquidation price, leverage ratio, or LP value — as a JSON object containing the result and relevant formula parameters.

## Request schema (JSON Schema)

```json
{
 "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",
      "HEAD",
      "DELETE"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "op"
     ],
     "properties": {
      "n": {
       "type": "number",
       "description": "Compounding periods per year for the rate conversions"
      },
      "op": {
       "enum": [
        "apr_to_apy",
        "apy_to_apr",
        "funding_annualized",
        "impermanent_loss",
        "liquidation_price",
        "leverage",
        "lp_value"
       ],
       "type": "string",
       "description": "Which DeFi formula to evaluate"
      },
      "apr": {
       "type": "number",
       "description": "APR as a decimal for op=apr_to_apy"
      },
      "apy": {
       "type": "number",
       "description": "APY as a decimal for op=apy_to_apr"
      },
      "rate": {
       "type": "number",
       "description": "Per-period funding rate for op=funding_annualized"
      },
      "side": {
       "enum": [
        "long",
        "short"
       ],
       "type": "string",
       "description": "Position side for op=liquidation_price"
      },
      "equity": {
       "type": "number",
       "description": "Equity for op=leverage"
      },
      "leverage": {
       "type": "number",
       "description": "Leverage for op=liquidation_price and op=leverage"
      },
      "notional": {
       "type": "number",
       "description": "Notional for op=leverage"
      },
      "entry_price": {
       "type": "number",
       "description": "Entry price for op=liquidation_price"
      },
      "price_ratio": {
       "type": "number",
       "description": "Price ratio k for impermanent loss and LP value"
      },
      "initial_value": {
       "type": "number",
       "description": "Optional initial value for op=lp_value"
      },
      "periods_per_year": {
       "type": "number",
       "description": "Funding periods per year, default 1095"
      },
      "maintenance_margin": {
       "type": "number",
       "description": "Maintenance margin as a decimal, default 0.005"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "req
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/payai-defi-math-helper-7c7afaba/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from payai.agentstools.dev](https://www.zero.xyz/host/payai.agentstools.dev/llms.txt)
