openapi: 3.1.0
info:
  title: Wallet Portfolio Risk MCP (x402)
  version: 0.1.0
  description: |
    Pay-per-call EVM wallet portfolio-risk service. Composes Aave V3 health factor +
    Compound III debt/liquidation status + Uniswap V3 LP position count +
    top-N ERC-20 holdings concentration + GoPlus token-security flags into a
    0–100 risk score with itemized reasons. Settle USDC on Base via x402.
servers:
  - url: https://wallet-portfolio-risk-mcp.mtree.workers.dev
x-pricing:
  - path: /v1/wallet/portfolio_risk
    method: POST
    price: $0.30
    amount: "0.30"
    asset: USDC
    network: base
  - path: /v1/wallet/liquidation_alert_threshold
    method: POST
    price: $0.10
    amount: "0.10"
    asset: USDC
    network: base
paths:
  /healthz:
    get:
      summary: Service health
      responses:
        "200":
          description: OK
  /v1/wallet/portfolio_risk:
    post:
      summary: Composite EVM wallet portfolio risk (5 sources fused)
      description: |
        $0.30 USDC on Base via x402. Composes Aave V3 health factor + Compound III
        debt/liquidation status + Uniswap V3 LP NFT count + top-N ERC-20 holdings
        concentration + GoPlus token-security flags into a 0–100 risk score.
        Multichain — defaults to ethereum + base; opt-in arbitrum/optimism/polygon
        via the `chains` field.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [address]
              properties:
                address:
                  type: string
                  description: EVM address (0x… 20 bytes)
                chains:
                  type: array
                  items: { type: string, enum: [ethereum, base, arbitrum, optimism, polygon] }
                  description: Chains to scan. Default ['ethereum','base']
      responses:
        "402":
          description: Payment required (x402 envelope returned)
        "200":
          description: Composite portfolio-risk view
  /v1/wallet/liquidation_alert_threshold:
    post:
      summary: Lightweight liquidation-alert slice (Aave V3 + Compound III)
      description: |
        $0.10 USDC on Base via x402. Single-chain Aave V3 health factor + Compound III
        isLiquidatable, returning urgency level (none/watch/elevated/high/critical),
        per-protocol alert payloads, and approximate collateral-price drop tolerance.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [address]
              properties:
                address:
                  type: string
                  description: EVM address (0x… 20 bytes)
                chain:
                  type: string
                  enum: [ethereum, base, arbitrum, optimism, polygon]
                  default: ethereum
      responses:
        "402":
          description: Payment required (x402 envelope returned)
        "200":
          description: Liquidation alert payload
