{
  "openapi": "3.1.0",
  "info": {
    "title": "KernelFlow Aggregator API",
    "version": "1.0.0",
    "description": "Quotes, user-signed transaction submission, and cross-chain order tracking. Reviewed November 6, 2026. Amounts are integer strings; timestamps are Unix seconds. API keys must stay server-side. Standard per-key limit: 20 requests/s, burst 40. Request body limit: 1 MiB.",
    "contact": {
      "name": "KernelFlow Developer Support",
      "email": "dev@kernelflow.org"
    }
  },
  "servers": [
    {
      "url": "https://api.kernelflow.org"
    }
  ],
  "security": [
    {
      "ApiKey": []
    }
  ],
  "tags": [
    {
      "name": "Chains"
    },
    {
      "name": "Quotes"
    },
    {
      "name": "Orders"
    }
  ],
  "externalDocs": {
    "url": "https://kernelflow.org/docs/aggregator",
    "description": "Integration guide and API reference"
  },
  "paths": {
    "/v1/chains": {
      "get": {
        "operationId": "listChains",
        "tags": [
          "Chains"
        ],
        "summary": "List enabled chains",
        "security": [],
        "parameters": [
          {
            "name": "X-Request-ID",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional correlation ID echoed in the response."
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect code: 0 is success; nonzero is a business result, not an automatic retry signal.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ChainsDataResponse"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                },
                "example": {
                  "code": 0,
                  "msg": "success",
                  "data": {
                    "chains": [
                      {
                        "name": "BNB",
                        "fullName": "BNB Chain",
                        "chainId": 56,
                        "nativeToken": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
                      }
                    ]
                  }
                }
              }
            }
          },
          "404": {
            "description": "Unknown path.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 1 MiB.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Honor Retry-After.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal or configuration error. Alert; do not automatically retry.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporary failure. Quotes: bounded retry. Order submissions: outcome may be unknown; resend the exact same body or query the existing order.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/quote": {
      "get": {
        "operationId": "getQuote",
        "tags": [
          "Quotes"
        ],
        "summary": "Get the selected route and unsigned transaction",
        "description": "Unknown or repeated query parameters are rejected. Keep token amounts as integer strings. Never modify tx.to, tx.data, or tx.value. channel and route are optional informational fields.",
        "parameters": [
          {
            "name": "X-Request-ID",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional correlation ID echoed in the response."
          },
          {
            "name": "fromChain",
            "in": "query",
            "required": true,
            "description": "Case-sensitive source chain name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "toChain",
            "in": "query",
            "required": true,
            "description": "Case-sensitive destination chain name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fromToken",
            "in": "query",
            "required": true,
            "description": "Token address or nativeToken identifier on the source chain.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "toToken",
            "in": "query",
            "required": true,
            "description": "Token address or nativeToken identifier on the destination chain.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "amount",
            "in": "query",
            "required": true,
            "description": "Positive input amount in smallest units; no decimals or sign.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9]+$",
              "minLength": 1
            }
          },
          {
            "name": "fromAddress",
            "in": "query",
            "required": true,
            "description": "Wallet that signs and pays.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "toAddress",
            "in": "query",
            "required": false,
            "description": "Defaults to fromAddress. Required when chain families differ.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "slippageBps",
            "in": "query",
            "required": false,
            "description": "Slippage tolerance, not a protocol fee or fixed deduction. Default 30 (0.3%) same-chain or 70 (0.7%) cross-chain when omitted; 1 basis point is 0.01%.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 5000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect code: 0 is success; nonzero is a business result, not an automatic retry signal.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/QuoteResponse"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                },
                "example": {
                  "code": 0,
                  "msg": "success",
                  "data": {
                    "toAmount": "1967167",
                    "minToAmount": "1967167",
                    "estimatedSeconds": 30,
                    "expiresAt": 1793943430,
                    "approval": {
                      "token": "0x55d398326f99059fF775485246999027B3197955",
                      "spender": "0xB0E42E806cb213e811A3af3ebbD49A6743712A21",
                      "amount": "2000000000000000000"
                    },
                    "tx": {
                      "kind": "evm",
                      "to": "0xB0E42E806cb213e811A3af3ebbD49A6743712A21",
                      "data": "0x...",
                      "value": "0",
                      "gasLimit": "723070"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or incorrect API key.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Source IP not allowed.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Unknown path.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 1 MiB.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Honor Retry-After.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal or configuration error. Alert; do not automatically retry.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporary failure. Quotes: bounded retry. Order submissions: outcome may be unknown; resend the exact same body or query the existing order.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/order": {
      "post": {
        "operationId": "submitOrder",
        "tags": [
          "Orders"
        ],
        "summary": "Submit a signed transaction or register an EVM hash",
        "description": "Idempotent per (chain, txHash). After timeout/503, resend the exact same body or query existing orders; never sign a replacement trade blindly. For EVM hash-only code 2003, retry registration after a few seconds. TRX submission is currently disabled.",
        "parameters": [
          {
            "name": "X-Request-ID",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional correlation ID echoed in the response."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrderRequest"
              },
              "example": {
                "chain": "BNB",
                "txHash": "0x...",
                "signedTx": "0x...",
                "check": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Inspect code: 0 is success; nonzero is a business result, not an automatic retry signal.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/OrderResponse"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                },
                "example": {
                  "code": 0,
                  "msg": "success",
                  "data": {
                    "orderId": "ord_example",
                    "status": "Pending",
                    "fromTxHash": "0x...",
                    "createdAt": 1793942831,
                    "updatedAt": 1793942831
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or incorrect API key.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Source IP not allowed.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Unknown path.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 1 MiB.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Honor Retry-After.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal or configuration error. Alert; do not automatically retry.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporary failure. Quotes: bounded retry. Order submissions: outcome may be unknown; resend the exact same body or query the existing order.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/order/{orderId}": {
      "get": {
        "operationId": "getOrder",
        "tags": [
          "Orders"
        ],
        "summary": "Get order status",
        "description": "Poll every 3–5 s same-chain or 10–15 s cross-chain. WaitVerify ends automation and requires manual review.",
        "parameters": [
          {
            "name": "X-Request-ID",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional correlation ID echoed in the response."
          },
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect code: 0 is success; nonzero is a business result, not an automatic retry signal.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/OrderResponse"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                },
                "example": {
                  "code": 0,
                  "msg": "success",
                  "data": {
                    "orderId": "ord_example",
                    "status": "Pending",
                    "fromTxHash": "0x...",
                    "createdAt": 1793942831,
                    "updatedAt": 1793942831
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or incorrect API key.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Source IP not allowed.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Unknown path.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 1 MiB.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Honor Retry-After.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal or configuration error. Alert; do not automatically retry.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporary failure. Quotes: bounded retry. Order submissions: outcome may be unknown; resend the exact same body or query the existing order.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/orders": {
      "get": {
        "operationId": "listOrders",
        "tags": [
          "Orders"
        ],
        "summary": "List orders by sender",
        "description": "Sender-scoped across API keys, newest first. Retain the same address and status with the next cursor. Empty nextCursor means end. Do not treat results as a private key-scoped history.",
        "parameters": [
          {
            "name": "X-Request-ID",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional correlation ID echoed in the response."
          },
          {
            "name": "address",
            "in": "query",
            "required": true,
            "description": "Sender address, not recipient.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum page size.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Optional status filter.",
            "schema": {
              "type": "string",
              "enum": [
                "Pending",
                "Succeeded",
                "Failed",
                "Refunded",
                "WaitVerify"
              ]
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque nextCursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect code: 0 is success; nonzero is a business result, not an automatic retry signal.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/OrdersDataResponse"
                    },
                    {
                      "$ref": "#/components/schemas/Error"
                    }
                  ]
                },
                "example": {
                  "code": 0,
                  "msg": "success",
                  "data": {
                    "items": [
                      {
                        "orderId": "ord_example",
                        "status": "Pending",
                        "fromTxHash": "0x...",
                        "createdAt": 1793942831,
                        "updatedAt": 1793942831
                      }
                    ],
                    "nextCursor": ""
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or incorrect API key.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Source IP not allowed.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Unknown path.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 1 MiB.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited. Honor Retry-After.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Internal or configuration error. Alert; do not automatically retry.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporary failure. Quotes: bounded retry. Order submissions: outcome may be unknown; resend the exact same body or query the existing order.",
            "headers": {
              "X-Request-ID": {
                "description": "Request correlation ID.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "enum": [
              1000,
              1001,
              1002,
              1003,
              1004,
              1005,
              2001,
              2002,
              2003,
              2004,
              2005,
              2006,
              2007,
              2008,
              2009,
              2010,
              3000,
              3001,
              3002,
              3003,
              3004,
              3005
            ]
          },
          "msg": {
            "type": "string",
            "description": "Short English reason."
          },
          "data": {
            "type": "null"
          }
        },
        "required": [
          "code",
          "msg",
          "data"
        ]
      },
      "Chain": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Case-sensitive API chain name."
          },
          "fullName": {
            "type": "string"
          },
          "chainId": {
            "type": "integer",
            "description": "EVM chain ID; omitted on SOL/TRX."
          },
          "nativeToken": {
            "type": "string",
            "description": "Identifier for the native gas coin."
          }
        },
        "required": [
          "name",
          "fullName",
          "nativeToken"
        ]
      },
      "ChainsData": {
        "type": "object",
        "properties": {
          "chains": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Chain"
            }
          }
        },
        "required": [
          "chains"
        ]
      },
      "Approval": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string"
          },
          "spender": {
            "type": "string"
          },
          "amount": {
            "type": "string",
            "description": "Required allowance, in smallest units.",
            "pattern": "^[0-9]+$"
          }
        },
        "required": [
          "token",
          "spender",
          "amount"
        ]
      },
      "Transaction": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "evm",
              "solana",
              "tron"
            ]
          },
          "to": {
            "type": "string",
            "description": "Target contract; ApproveManager on EVM contract chains."
          },
          "data": {
            "type": "string",
            "description": "0x hex calldata for EVM/TRON or full serialized transaction for SOL. Preserve unchanged."
          },
          "value": {
            "type": "string",
            "description": "Native amount. Omitted means zero. Preserve unchanged.",
            "pattern": "^[0-9]+$"
          },
          "gasLimit": {
            "type": "string",
            "description": "Use as returned; estimate if absent.",
            "pattern": "^[0-9]+$"
          },
          "gasPrice": {
            "type": "string",
            "description": "Optional; usually absent. Select gas pricing yourself.",
            "pattern": "^[0-9]+$"
          },
          "feeLimit": {
            "type": "string",
            "description": "TRON only.",
            "pattern": "^[0-9]+$"
          }
        },
        "required": [
          "kind",
          "data"
        ]
      },
      "Quote": {
        "type": "object",
        "properties": {
          "channel": {
            "type": "string",
            "description": "Optional, informational only."
          },
          "route": {
            "type": "string",
            "description": "Optional, informational only."
          },
          "toAmount": {
            "type": "string",
            "description": "Expected output after protocol fees.",
            "pattern": "^[0-9]+$"
          },
          "minToAmount": {
            "type": "string",
            "description": "Minimum after slippage.",
            "pattern": "^[0-9]+$"
          },
          "estimatedSeconds": {
            "type": "integer",
            "format": "int64"
          },
          "expiresAt": {
            "type": "integer",
            "format": "int64",
            "description": "Unix seconds. Without this field, treat quote validity as about 60 seconds at most."
          },
          "approval": {
            "$ref": "#/components/schemas/Approval"
          },
          "tx": {
            "$ref": "#/components/schemas/Transaction"
          }
        },
        "required": [
          "toAmount",
          "minToAmount",
          "tx"
        ]
      },
      "OrderRequest": {
        "type": "object",
        "properties": {
          "chain": {
            "type": "string",
            "description": "Source chain. TRX order submission is currently disabled."
          },
          "txHash": {
            "type": "string",
            "description": "Must match signedTx. EVM/TRX hex; SOL first signature in base58.",
            "minLength": 1
          },
          "signedTx": {
            "type": "string",
            "description": "Signed raw transaction as hex. Required on SOL/TRX; omit for EVM hash-only registration. Must not be empty when present.",
            "minLength": 1
          },
          "check": {
            "type": "boolean",
            "default": false,
            "description": "Recommended true. Checks balance, allowance, simulation, and gas before storing or broadcasting."
          }
        },
        "required": [
          "chain",
          "txHash"
        ],
        "additionalProperties": false
      },
      "Order": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "Pending",
              "Succeeded",
              "Failed",
              "Refunded",
              "WaitVerify"
            ]
          },
          "fromTxHash": {
            "type": "string"
          },
          "createdAt": {
            "type": "integer",
            "format": "int64",
            "description": "Unix seconds."
          },
          "updatedAt": {
            "type": "integer",
            "format": "int64",
            "description": "Unix seconds."
          },
          "channel": {
            "type": "string",
            "description": "Optional; omitted when unknown or unavailable for this status."
          },
          "route": {
            "type": "string",
            "description": "Optional; omitted when unknown or unavailable for this status."
          },
          "fromChain": {
            "type": "string",
            "description": "Optional; omitted when unknown or unavailable for this status."
          },
          "fromToken": {
            "type": "string",
            "description": "Optional; omitted when unknown or unavailable for this status."
          },
          "fromAddress": {
            "type": "string",
            "description": "Optional; omitted when unknown or unavailable for this status."
          },
          "toChain": {
            "type": "string",
            "description": "Optional; omitted when unknown or unavailable for this status."
          },
          "toToken": {
            "type": "string",
            "description": "Optional; omitted when unknown or unavailable for this status."
          },
          "toAddress": {
            "type": "string",
            "description": "Optional; omitted when unknown or unavailable for this status."
          },
          "toTxHash": {
            "type": "string",
            "description": "Optional; omitted when unknown or unavailable for this status."
          },
          "errMsg": {
            "type": "string",
            "description": "Optional; omitted when unknown or unavailable for this status."
          },
          "fromAmount": {
            "type": "string",
            "description": "Optional amount in smallest token units; omitted when unknown.",
            "pattern": "^[0-9]+$"
          },
          "toAmount": {
            "type": "string",
            "description": "Optional amount in smallest token units; omitted when unknown.",
            "pattern": "^[0-9]+$"
          },
          "minToAmount": {
            "type": "string",
            "description": "Optional amount in smallest token units; omitted when unknown.",
            "pattern": "^[0-9]+$"
          },
          "realToAmount": {
            "type": "string",
            "description": "Optional amount in smallest token units; omitted when unknown.",
            "pattern": "^[0-9]+$"
          }
        },
        "required": [
          "orderId",
          "status",
          "fromTxHash",
          "createdAt",
          "updatedAt"
        ],
        "description": "Pending/WaitVerify only expose core fields and optional errMsg. Additional fields on Succeeded/Failed/Refunded are optional. WaitVerify requires manual review, not success/failure classification."
      },
      "OrdersData": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Order"
            }
          },
          "nextCursor": {
            "type": "string",
            "description": "Empty when there are no further pages."
          }
        },
        "required": [
          "items",
          "nextCursor"
        ]
      },
      "ChainsDataResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "const": 0
          },
          "msg": {
            "type": "string",
            "const": "success"
          },
          "data": {
            "$ref": "#/components/schemas/ChainsData"
          }
        },
        "required": [
          "code",
          "msg",
          "data"
        ]
      },
      "QuoteResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "const": 0
          },
          "msg": {
            "type": "string",
            "const": "success"
          },
          "data": {
            "$ref": "#/components/schemas/Quote"
          }
        },
        "required": [
          "code",
          "msg",
          "data"
        ]
      },
      "OrderResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "const": 0
          },
          "msg": {
            "type": "string",
            "const": "success"
          },
          "data": {
            "$ref": "#/components/schemas/Order"
          }
        },
        "required": [
          "code",
          "msg",
          "data"
        ]
      },
      "OrdersDataResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "const": 0
          },
          "msg": {
            "type": "string",
            "const": "success"
          },
          "data": {
            "$ref": "#/components/schemas/OrdersData"
          }
        },
        "required": [
          "code",
          "msg",
          "data"
        ]
      }
    }
  },
  "x-error-codes": [
    {
      "code": 1000,
      "httpStatus": 404,
      "meaning": "Unknown path",
      "action": "Correct the endpoint."
    },
    {
      "code": 1001,
      "httpStatus": 413,
      "meaning": "Body too large",
      "action": "Keep request bodies within 1 MiB."
    },
    {
      "code": 1002,
      "httpStatus": 500,
      "meaning": "Internal error",
      "action": "Alert; do not automatically retry."
    },
    {
      "code": 1003,
      "httpStatus": 401,
      "meaning": "Unauthorized",
      "action": "Check the API key."
    },
    {
      "code": 1004,
      "httpStatus": 429,
      "meaning": "Rate limited",
      "action": "Honor Retry-After."
    },
    {
      "code": 1005,
      "httpStatus": 403,
      "meaning": "Forbidden",
      "action": "Check the source IP allowlist."
    },
    {
      "code": 2001,
      "httpStatus": 200,
      "meaning": "Invalid or missing parameter",
      "action": "Fix the parameter named by msg."
    },
    {
      "code": 2002,
      "httpStatus": 200,
      "meaning": "Unsupported or disabled chain",
      "action": "Check chain and operation support."
    },
    {
      "code": 2003,
      "httpStatus": 200,
      "meaning": "Transaction not found",
      "action": "For EVM hash-only registration, retry the same hash after a few seconds."
    },
    {
      "code": 2004,
      "httpStatus": 200,
      "meaning": "Unsupported transaction",
      "action": "Use the returned ApproveManager transaction on contract chains."
    },
    {
      "code": 2005,
      "httpStatus": 200,
      "meaning": "Broadcast definitely rejected",
      "action": "Nothing was stored. Request a new quote."
    },
    {
      "code": 2006,
      "httpStatus": 200,
      "meaning": "Order not found",
      "action": "Check the order ID."
    },
    {
      "code": 2007,
      "httpStatus": 200,
      "meaning": "Insufficient balance",
      "action": "Check token balance and native gas balance."
    },
    {
      "code": 2008,
      "httpStatus": 200,
      "meaning": "Insufficient allowance",
      "action": "Approve the quoted spender and wait for confirmation."
    },
    {
      "code": 2009,
      "httpStatus": 200,
      "meaning": "Simulation reverted",
      "action": "Inspect msg for the known revert reason."
    },
    {
      "code": 2010,
      "httpStatus": 200,
      "meaning": "Signed gas limit too low",
      "action": "Use the quoted gas limit or estimate when absent."
    },
    {
      "code": 3000,
      "httpStatus": 200,
      "meaning": "No route available",
      "action": "Do not automatically retry the same quote."
    },
    {
      "code": 3001,
      "httpStatus": 503,
      "meaning": "Quote timed out",
      "action": "Retry quotes with bounded backoff."
    },
    {
      "code": 3002,
      "httpStatus": 503,
      "meaning": "Provider unavailable, contract read failed, or contract paused",
      "action": "Retry quotes with bounded backoff."
    },
    {
      "code": 3003,
      "httpStatus": 503,
      "meaning": "Chain node unavailable",
      "action": "Retry quotes with bounded backoff."
    },
    {
      "code": 3004,
      "httpStatus": 429,
      "meaning": "Providers rate limited",
      "action": "Honor Retry-After."
    },
    {
      "code": 3005,
      "httpStatus": 500,
      "meaning": "Service misconfigured",
      "action": "Alert; do not automatically retry."
    }
  ]
}
