{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/coinrithm-com/json-schema/coinrithm-com-spot-quote-response-schema.json",
  "title": "SpotQuoteResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/coinrithm-com-spot-api-openapi.yml#/components/schemas/SpotQuoteResponse",
  "type": "object",
  "properties": {
    "eligible": {
      "type": "boolean"
    },
    "blockReasons": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "e.g. price_unavailable, insufficient_usdt_balance,\ninsufficient_coin_balance, wallet_not_found.\n"
    },
    "coin": {
      "type": "object",
      "properties": {
        "ucid": {
          "type": "string"
        },
        "symbol": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      }
    },
    "side": {
      "type": "string",
      "enum": [
        "buy",
        "sell"
      ]
    },
    "quantity": {
      "type": "number"
    },
    "orderType": {
      "type": "string",
      "const": "market"
    },
    "executionPrice": {
      "type": [
        "number",
        "null"
      ],
      "description": "Estimated fill price — live mid adjusted for spread+slippage; null when unavailable."
    },
    "estimatedCostMusd": {
      "type": [
        "number",
        "null"
      ],
      "description": "Gross notional (price × quantity). BUY = cash debited; SELL = proceeds."
    },
    "estimatedFeeMusd": {
      "type": [
        "number",
        "null"
      ],
      "description": "Estimated taker fee for this trade (mUSD), included in the affordability check."
    },
    "executionModel": {
      "$ref": "#/$defs/ExecutionModel"
    },
    "available": {
      "type": "object",
      "properties": {
        "usdtAvailableMusd": {
          "type": "number",
          "description": "spendable cash for a BUY"
        },
        "coinAvailable": {
          "type": "number",
          "description": "coin units held for a SELL"
        }
      }
    },
    "freshness": {
      "$ref": "#/$defs/Freshness"
    },
    "priceTiming": {
      "$ref": "#/$defs/SpotPriceTiming"
    },
    "asOf": {
      "type": "string",
      "format": "date-time"
    },
    "observation": {
      "$ref": "#/$defs/AgentObservation"
    }
  },
  "$defs": {
    "AgentObservation": {
      "type": "object",
      "description": "Compact provenance block for an agent-facing market observation. It is\nalso stored in the private ledger responseSummary when the request uses\nagentTrace/run headers, giving run exports a verifiable snapshot of what\nthe agent observed without creating a full market archive.\n",
      "properties": {
        "schema": {
          "type": "string"
        },
        "endpoint": {
          "type": "string"
        },
        "source": {
          "type": "string"
        },
        "observedAt": {
          "type": "string",
          "format": "date-time"
        },
        "sourceAsOf": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "freshness": {
          "anyOf": [
            {
              "$ref": "#/$defs/Freshness"
            },
            {
              "type": "null"
            }
          ]
        },
        "inputs": {
          "type": "object",
          "additionalProperties": true
        },
        "dataset": {
          "type": "object",
          "additionalProperties": true
        },
        "rowCount": {
          "type": [
            "integer",
            "null"
          ]
        },
        "hash": {
          "type": "string",
          "description": "Short SHA-256 digest of the observed payload metadata."
        }
      }
    },
    "ExecutionModel": {
      "type": "object",
      "description": "Paper Execution Realism v1 cost disclosure. Paper fills apply a\ndeterministic, fully-disclosed cost so simulated PnL reflects real\ntrading friction (a flat round-trip is a small loss, not a free\nbreakeven). This is a rehearsal cost model, NOT an exchange fill\nguarantee. Per venue:\n    - spot: a taker fee (`feeBps`) on notional, with market orders also\n      filling at an adverse price (half-spread + slippage). Futures use\n      the default-off legacy mark fill unless `futures_fill_v1` is\n      pinned; that model applies deterministic half-spread, slippage,\n      and square-root size-scaled impact, with adverse cost embedded in\n      the executed price.\n  - PM: fills at the ask (mid + half the ingested bid-ask spread) with\n    size/liquidity-based slippage and a Polymarket-shaped taker fee\n    (~1.8% near 50%, ~0 at the extremes), folded into `sharesMusd`.\n    `feeBps`/`spreadBps` are positive and `slippageBps` scales with\n    order size; `entryProbability` stays the mid for calibration.\nFutures quote funding is estimated from the latest venue rate when\navailable and may change before settlement. Covered futures charges are\napplied from recorded settled venue history; `fundingMode` is a\nvenue-specific mode such as `binance_perp_rate_v1`,\n`bybit_perp_rate_v1`, or `gateio_perp_rate_v1`, and is\n`not_modeled` when no latest rate is available. Funding does not apply\nto spot or PM. Futures liquidation forfeits margin without adverse fill\ncost, and fixed-price SL/TP triggers fill at their set price. Order-book\ndepth, latency, and partial fills are not modeled.\n",
      "properties": {
        "version": {
          "type": "string"
        },
        "feeBps": {
          "type": "number",
          "description": "taker fee, basis points of notional"
        },
        "spreadBps": {
          "type": "number",
          "description": "modeled bid/ask spread (bps)"
        },
        "slippageBps": {
          "type": "number",
          "description": "modeled slippage (bps)"
        },
        "fillModel": {
          "type": [
            "string",
            "null"
          ],
          "description": "Futures fill model pinned for this execution, or null for legacy mark fills."
        },
        "estimatedFeeMusd": {
          "type": "number",
          "description": "estimated fee for this trade (mUSD)"
        },
        "estimatedSlippageMusd": {
          "type": "number",
          "description": "estimated slippage cost for this trade (mUSD)"
        },
        "fundingMode": {
          "type": "string",
          "description": "Venue-specific current funding reference mode, or not_modeled when no latest rate is available."
        },
        "assumptions": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "human-readable list of what is and isn't modeled"
        }
      }
    },
    "Freshness": {
      "type": "object",
      "description": "Data-freshness descriptor. Futures + spot use ageSeconds; PM uses\nageMinutes. `status` is a freshness label; `basis` (PM only) names which\ntimestamp the age was measured against.\n",
      "properties": {
        "asOf": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "ageSeconds": {
          "type": [
            "number",
            "null"
          ],
          "description": "futures / spot"
        },
        "ageMinutes": {
          "type": [
            "number",
            "null"
          ],
          "description": "PM"
        },
        "status": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "fresh",
            "lagging",
            "stale",
            "unknown",
            null
          ],
          "description": "fresh | lagging (PM only) | stale | unknown. PM lagging>=45m &\nstale>=2h; spot/futures stale>120s.\n"
        },
        "basis": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "latest_snapshot",
            "source_update",
            "processed",
            "event_update",
            "unknown"
          ],
          "description": "PM only — which timestamp the age was measured against.\n"
        }
      }
    },
    "SpotPriceTiming": {
      "type": "object",
      "description": "Source-vs-row timing of the spot price (optional: absent on older API\nversions). Informational only: `freshness`, `eligible` and the write\npath's mark guard still measure the row WRITE time and are unchanged.\n`sourceObservedAt` is a venue snapshot/ticker time, NOT a last-trade\ntime and NOT a per-fill receipt.\n",
      "required": [
        "rowWrittenAt",
        "sourceObservedAt",
        "sourceAgeSeconds",
        "writeLagSeconds",
        "coverage",
        "basis"
      ],
      "properties": {
        "rowWrittenAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "When CoinRithm wrote the price row; the same instant as freshness.asOf. null when there is no row."
        },
        "sourceObservedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "The OLDEST venue snapshot time among the winning price cluster's\nmembers that carry one. null when no member carries one.\n"
        },
        "sourceAgeSeconds": {
          "type": [
            "number",
            "null"
          ],
          "description": "max(0, now - sourceObservedAt), the same clamp as freshness.ageSeconds."
        },
        "writeLagSeconds": {
          "type": [
            "number",
            "null"
          ],
          "description": "rowWrittenAt - sourceObservedAt in seconds, SIGNED. Negative means\nthe venue's clock ran ahead of CoinRithm's (the writer admits up to\n5 minutes); it is never clamped.\n"
        },
        "coverage": {
          "type": "string",
          "enum": [
            "recorded",
            "not_recorded",
            "no_row"
          ],
          "description": "recorded: at least one cluster member carried a source time. It may\nbe PARTIAL: members without a stamp (e.g. Kraken, Gate.io) are not\nrepresented. not_recorded: the row has no source time (unknown,\nnever fresh). no_row: there is no price row.\n"
        },
        "basis": {
          "type": "string",
          "const": "venue_snapshot_time"
        }
      }
    }
  }
}