openapi: 3.1.0
info:
  title: Liquidation Risk MCP (x402)
  version: 0.1.0
  description: |
    Pay-per-call Aave V3 + Compound III liquidation-risk service. Two primitives:
    (1) aave_v3_liquidation_risk reads Pool.getUserAccountData and returns
    collateral, debt, healthFactor, LTV, liquidationThreshold,
    priceDropToLiquidation, and a categorical risk band;
    (2) compound_v3_liquidation_risk reads the Comet borrow + per-collateral
    state on a given market (USDC | WETH).
    Multichain (base/ethereum/arbitrum/optimism/polygon). Settle USDC on Base
    via x402. No signup, no API key.
servers:
  - url: https://liquidation-risk-mcp.mtree.workers.dev
x-pricing:
  - path: /v1/risk/aave_v3
    method: POST
    price: $0.03
    amount: "0.03"
    asset: USDC
    network: base
  - path: /v1/risk/compound_v3
    method: POST
    price: $0.03
    amount: "0.03"
    asset: USDC
    network: base
paths:
  /healthz:
    get:
      summary: Service health
      responses:
        "200":
          description: OK
  /v1/risk/aave_v3:
    post:
      summary: Aave V3 liquidation-risk check
      description: |
        $0.03 USDC on Base via x402. Reads Pool.getUserAccountData on the
        chain's Aave V3 Pool. Returns totalCollateralUSD, totalDebtUSD,
        healthFactor (raw 1e18-scaled + float), ltv, liquidationThreshold,
        priceDropToLiquidation (1 - 1/HF), and a categorical risk label
        (safe/warning/danger).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [address]
              properties:
                chain:
                  type: string
                  enum: [base, ethereum, arbitrum, optimism, polygon]
                  default: base
                address:
                  type: string
                  description: EVM address (0x… 20 bytes)
      responses:
        "402":
          description: Payment required (x402 envelope returned)
        "200":
          description: Aave V3 liquidation-risk payload
  /v1/risk/compound_v3:
    post:
      summary: Compound III liquidation-risk check
      description: |
        $0.03 USDC on Base via x402. Reads Compound III Comet
        (USDC or WETH market) state for the address. Returns the base-asset
        borrow balance, per-collateral breakdown (numAssets / getAssetInfo /
        collateralBalanceOf), isLiquidatable flag, and a categorical risk
        label (safe/warning/danger).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [address]
              properties:
                chain:
                  type: string
                  enum: [base, ethereum, arbitrum, optimism, polygon]
                  default: base
                address:
                  type: string
                  description: EVM address (0x… 20 bytes)
                market:
                  type: string
                  enum: [USDC, WETH]
                  default: USDC
                  description: Compound III comet market. WETH not available on polygon.
      responses:
        "402":
          description: Payment required (x402 envelope returned)
        "200":
          description: Compound III liquidation-risk payload
