{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://lopw.com/docs/schemas/terms-evm.json",
  "title": "Terms (EVM binding)",
  "description": "A service's registered warranty terms on an EVM network (Solidity: Terms). termsHash = keccak256(abi.encode(terms)); field order is normative because it defines the ABI. Same semantics as the Stellar Terms; only the carriers differ.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "predicates",
    "claim_window",
    "max_data_age",
    "allowed_status",
    "max_response_bytes",
    "has_oracle",
    "oracle"
  ],
  "properties": {
    "predicates": {
      "type": "array",
      "items": {
        "type": "integer",
        "minimum": 1,
        "maximum": 6
      },
      "minItems": 1,
      "uniqueItems": true,
      "description": "uint8[]: predicate IDs, strictly increasing, no duplicates"
    },
    "claim_window": {
      "type": "integer",
      "minimum": 0,
      "maximum": 18446744073709551615,
      "description": "Seconds after servedAt during which a claim may be filed; checked against block.timestamp"
    },
    "max_data_age": {
      "type": "integer",
      "minimum": 0,
      "maximum": 18446744073709551615,
      "description": "P3: most seconds allowed between dataAsOf and servedAt"
    },
    "allowed_status": {
      "type": "array",
      "items": {
        "type": "integer",
        "minimum": 0,
        "maximum": 65535,
        "description": "uint16"
      },
      "description": "uint16[]: HTTP statuses the seller may charge for (P4)"
    },
    "max_response_bytes": {
      "type": "integer",
      "minimum": 0,
      "maximum": 4294967295,
      "description": "P5: largest response body in bytes"
    },
    "has_oracle": {
      "type": "boolean",
      "description": "true when predicate 6 is listed; oracle is zeroed when false"
    },
    "oracle": {
      "$ref": "#/$defs/OracleTerms"
    }
  },
  "$defs": {
    "OracleTerms": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "feed",
        "asset",
        "max_deviation_bps",
        "max_oracle_age"
      ],
      "description": "Solidity: OracleTerms { address feed; bytes32 asset; uint32 maxDeviationBps; uint64 maxOracleAge }",
      "properties": {
        "feed": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "Chainlink AggregatorV3Interface the warranty is measured against"
        },
        "asset": {
          "type": "string",
          "pattern": "^0x[0-9a-f]{64}$",
          "description": "Pair label as bytes32, for example bytes32(\"EUR/USD\")"
        },
        "max_deviation_bps": {
          "type": "integer",
          "minimum": 0,
          "maximum": 4294967295,
          "description": "Allowed difference in basis points of the feed answer (exact test: |reportedValue - answer| * 10000 > maxDeviationBps * answer proves a breach)"
        },
        "max_oracle_age": {
          "type": "integer",
          "minimum": 0,
          "maximum": 18446744073709551615,
          "description": "Most seconds allowed between the round's updatedAt and servedAt"
        }
      }
    }
  }
}
