{
  "openapi": "3.1.0",
  "info": {
    "title": "Stablecoin Peg Monitor",
    "version": "1.0.0",
    "description": "Real-time peg status, deviation, volatility and stability scoring for major USD stablecoins. Pay-per-call over MPP on Tempo (USDC.e, gas-abstracted)."
  },
  "servers": [{ "url": "https://peg.ivan-tempo.xyz" }],
  "paths": {
    "/api/peg": {
      "get": {
        "operationId": "pegStatus",
        "summary": "Single stablecoin peg status",
        "description": "Price, signed deviation from $1, and status (ok/watch/depegged) for one stablecoin.",
        "parameters": [
          { "name": "token", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Symbol (USDC), lowercase, or CoinGecko id (usd-coin)." }
        ],
        "x-payment-info": {
          "authMode": "paid",
          "protocols": ["mpp"],
          "price": "0.01",
          "currency": "USDC.e",
          "currencyAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "network": "tempo",
          "chainId": 4217,
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "feePayer": true,
          "gasAbstracted": true
        },
        "x-mpp": {
          "price": 10000,
          "token": "USDC.e",
          "tokenAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "network": "tempo",
          "feePayer": true
        },
        "responses": {
          "200": { "description": "Peg snapshot for the token." },
          "402": { "description": "Payment required." }
        }
      }
    },
    "/api/peg/all": {
      "get": {
        "operationId": "pegAll",
        "summary": "Peg status for all monitored stablecoins",
        "description": "Price, deviation and status for every monitored stablecoin plus an ok/watch/depegged summary.",
        "x-payment-info": {
          "authMode": "paid",
          "protocols": ["mpp"],
          "price": "0.01",
          "currency": "USDC.e",
          "currencyAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "network": "tempo",
          "chainId": 4217,
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "feePayer": true,
          "gasAbstracted": true
        },
        "x-mpp": {
          "price": 10000,
          "token": "USDC.e",
          "tokenAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "network": "tempo",
          "feePayer": true
        },
        "responses": {
          "200": { "description": "Peg snapshots for all monitored stablecoins." },
          "402": { "description": "Payment required." }
        }
      }
    },
    "/api/peg/deep": {
      "get": {
        "operationId": "pegDeep",
        "summary": "Deep peg analysis for one stablecoin",
        "description": "Price, market cap, 24h volume, 24h volatility (high/low range) and a source comparison.",
        "parameters": [
          { "name": "token", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Symbol (USDT), lowercase, or CoinGecko id." }
        ],
        "x-payment-info": {
          "authMode": "paid",
          "protocols": ["mpp"],
          "price": "0.02",
          "currency": "USDC.e",
          "currencyAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "network": "tempo",
          "chainId": 4217,
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "feePayer": true,
          "gasAbstracted": true
        },
        "x-mpp": {
          "price": 20000,
          "token": "USDC.e",
          "tokenAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "network": "tempo",
          "feePayer": true
        },
        "responses": {
          "200": { "description": "Deep analysis for the token." },
          "402": { "description": "Payment required." }
        }
      }
    },
    "/api/peg/alerts": {
      "get": {
        "operationId": "pegAlerts",
        "summary": "Stablecoins off peg beyond a threshold",
        "description": "List of monitored stablecoins whose absolute deviation from $1 exceeds the threshold (%), sorted worst first.",
        "parameters": [
          { "name": "threshold", "in": "query", "required": false, "schema": { "type": "number", "default": 0.5 }, "description": "Deviation threshold in % off peg (default 0.5)." }
        ],
        "x-payment-info": {
          "authMode": "paid",
          "protocols": ["mpp"],
          "price": "0.02",
          "currency": "USDC.e",
          "currencyAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "network": "tempo",
          "chainId": 4217,
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "feePayer": true,
          "gasAbstracted": true
        },
        "x-mpp": {
          "price": 20000,
          "token": "USDC.e",
          "tokenAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "network": "tempo",
          "feePayer": true
        },
        "responses": {
          "200": { "description": "Triggered alerts." },
          "402": { "description": "Payment required." }
        }
      }
    },
    "/api/peg/history": {
      "get": {
        "operationId": "pegHistory",
        "summary": "Historical peg dynamics",
        "description": "Historical price and deviation points over the last N hours, with min/max and worst deviation stats.",
        "parameters": [
          { "name": "token", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Symbol (USDT), lowercase, or CoinGecko id." },
          { "name": "hours", "in": "query", "required": false, "schema": { "type": "number", "default": 24 }, "description": "Lookback window in hours (1..2160, default 24)." }
        ],
        "x-payment-info": {
          "authMode": "paid",
          "protocols": ["mpp"],
          "price": "0.02",
          "currency": "USDC.e",
          "currencyAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "network": "tempo",
          "chainId": 4217,
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "feePayer": true,
          "gasAbstracted": true
        },
        "x-mpp": {
          "price": 20000,
          "token": "USDC.e",
          "tokenAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "network": "tempo",
          "feePayer": true
        },
        "responses": {
          "200": { "description": "Historical peg series." },
          "402": { "description": "Payment required." }
        }
      }
    },
    "/api/peg/score": {
      "get": {
        "operationId": "pegScore",
        "summary": "Stablecoin trust/stability score",
        "description": "Overall 0-100 stability score (with letter grade) from peg deviation, 24h volatility and market cap.",
        "parameters": [
          { "name": "token", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Symbol (USDT), lowercase, or CoinGecko id." }
        ],
        "x-payment-info": {
          "authMode": "paid",
          "protocols": ["mpp"],
          "price": "0.01",
          "currency": "USDC.e",
          "currencyAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "network": "tempo",
          "chainId": 4217,
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "feePayer": true,
          "gasAbstracted": true
        },
        "x-mpp": {
          "price": 10000,
          "token": "USDC.e",
          "tokenAddress": "0x20C000000000000000000000b9537d11c60E8b50",
          "recipient": "0x0d509f743bc6fc907d5f63d8b0dae1fca8d80897",
          "network": "tempo",
          "feePayer": true
        },
        "responses": {
          "200": { "description": "Stability score for the token." },
          "402": { "description": "Payment required." }
        }
      }
    }
  }
}
