{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/signo-fi/json-schema/signo-fi-simulate-response-schema.json",
  "title": "SimulateResponse",
  "description": "The LIVE response contract as returned by the simulation engine (documented from real responses, 2026-07-15 — earlier spec versions published a smaller shape that never matched the wire).",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/signo-fi-openapi.yaml#/components/schemas/SimulateResponse",
  "type": "object",
  "required": [
    "success",
    "steps"
  ],
  "properties": {
    "success": {
      "type": "boolean",
      "description": "True when every step simulated successfully."
    },
    "gas_used": {
      "type": "string",
      "description": "Total gas across steps, comma-formatted (e.g. \"608,282\")."
    },
    "gas_price": {
      "type": "string",
      "description": "Gas price used for the $ estimate (e.g. \"0.02 gwei\")."
    },
    "gas_price_source": {
      "type": "string",
      "description": "\"rpc\" when the price came from a live per-chain RPC read; \"fallback\" when the hardcoded last-resort price was used ($ figures are approximate in that case).",
      "enum": [
        "rpc",
        "fallback"
      ]
    },
    "total_cost": {
      "type": "string",
      "description": "Estimated total fee in USD (e.g. \"$0.02\")."
    },
    "error": {
      "type": [
        "string",
        "null"
      ],
      "description": "Human-readable revert reason when the batch failed (e.g. \"Return amount is not enough\", \"ERC20: transfer amount exceeds balance\") — safe to show directly in a UI. When the only failures are unverified steps (see `simulated_as`), this says so instead of quoting one of them."
    },
    "simulated_as": {
      "type": "string",
      "enum": [
        "bundle",
        "steps"
      ],
      "description": "For plans of two or more steps. \"bundle\": the steps ran in order, each on the state the step before it left. \"steps\": the bundle call did not answer, so each step ran alone on current chain state; a later step that fails there is reported with status \"unverified\", because it may only lack an earlier step's approval or balance."
    },
    "steps": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/SimulateStepResult"
      }
    }
  },
  "additionalProperties": true,
  "$defs": {
    "SimulateStepResult": {
      "type": "object",
      "required": [
        "success"
      ],
      "properties": {
        "success": {
          "type": "boolean"
        },
        "status": {
          "type": "string",
          "description": "Display status: \"succeeded\", \"failed\", or \"unverified\". \"failed\" means the simulation ran this step and it reverted. \"unverified\" means the step was not checked, so nothing is confirmed about it; `success` is false and `cause` says why. Branch on `success` and `status`, and do not show an \"unverified\" step as a failure."
        },
        "cause": {
          "type": "string",
          "enum": [
            "revert",
            "timeout",
            "provider-error",
            "precondition",
            "isolated"
          ],
          "description": "Why the step did not pass. Absent on a step that passed. \"revert\": the step ran and reverted; it is the only cause of \"failed\". The others come with \"unverified\": \"timeout\" and \"provider-error\" (the simulation provider gave no result), \"precondition\" (the wallet cannot fund or approve the step yet), \"isolated\" (simulated alone, without the steps before it)."
        },
        "status_code": {
          "type": "integer"
        },
        "action": {
          "type": "string",
          "description": "Human label for the step (e.g. \"Approve USDC for Kyberswap\")."
        },
        "action_type": {
          "type": "string",
          "description": "Step category (e.g. \"Approve\", \"Transfer\", \"Swap\")."
        },
        "protocol": {
          "type": "string"
        },
        "asset": {
          "type": "string"
        },
        "gas": {
          "type": "string",
          "description": "Per-step gas, comma-formatted string."
        },
        "error": {
          "type": [
            "string",
            "null"
          ],
          "description": "Human-readable revert reason for THIS step — show it in the chat card before opening the wallet."
        },
        "asset_changes": {
          "type": "array",
          "description": "Balance changes observed in the fork (may be empty).",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "additionalProperties": true
    }
  }
}