{
  "openapi": "3.1.0",
  "info": {
    "title": "TronBid API MarketPlace",
    "version": "2.1.0",
    "description": "独立 Marketplace API：共用余额、买单、卖家报价及已确认交易。",
    "contact": {
      "name": "TronBid Support",
      "email": "support@tronbid.com",
      "url": "https://t.me/tronbid"
    }
  },
  "servers": [
    {
      "url": "https://tronbid.com/api/v2/marketplace"
    }
  ],
  "security": [
    {
      "MarketplaceKey": []
    }
  ],
  "paths": {
    "/resources": {
      "get": {
        "operationId": "get_resources",
        "summary": "卖家可用资源",
        "description": "Scope: read",
        "tags": [
          "resources"
        ],
        "parameters": [
          {
            "name": "resource_type",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "energy",
                "bandwidth"
              ]
            }
          },
          {
            "name": "duration_type",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "minutes",
                "hours",
                "days"
              ]
            }
          },
          {
            "name": "duration_value",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "min_price_sun",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "max_price_sun",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "min_amount",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ResourceAvailability"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/price": {
      "get": {
        "operationId": "get_price",
        "summary": "只读价格预览",
        "description": "Scope: read",
        "tags": [
          "price"
        ],
        "parameters": [
          {
            "name": "resource_amount",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "resource_type",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "energy",
                "bandwidth"
              ],
              "default": "energy"
            }
          },
          {
            "name": "duration_type",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "minutes",
                "hours",
                "days"
              ],
              "default": "minutes"
            }
          },
          {
            "name": "duration_value",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 15
            }
          },
          {
            "name": "recipient_address",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offer_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "max_price_sun",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "max_total_trx",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^\\d+(\\.\\d{1,6})?$",
              "example": "2.620000"
            }
          },
          {
            "name": "allow_partial",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/PricePreview"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/estimate-energy": {
      "get": {
        "operationId": "get_estimate_energy",
        "summary": "估算代币转账 Energy",
        "description": "Scope: read",
        "tags": [
          "estimate-energy"
        ],
        "parameters": [
          {
            "name": "from_address",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to_address",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "contract_address",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
            }
          },
          {
            "name": "amount",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]{0,77}$",
              "default": "1000000"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/EnergyEstimate"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ENERGY_ESTIMATE_UNAVAILABLE",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/account/recharge": {
      "get": {
        "operationId": "get_account_recharge",
        "summary": "余额充值信息",
        "description": "Scope: read",
        "tags": [
          "account"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Recharge"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/account/deposits": {
      "get": {
        "operationId": "get_account_deposits",
        "summary": "充值记录",
        "description": "Scope: read",
        "tags": [
          "account"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000,
              "default": 0
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/orders/queue": {
      "get": {
        "operationId": "get_orders_queue",
        "summary": "当前订单队列",
        "description": "Scope: read",
        "tags": [
          "orders"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000,
              "default": 0
            }
          },
          {
            "name": "resource_type",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "energy",
                "bandwidth"
              ]
            }
          },
          {
            "name": "mode",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "bid",
                "offer",
                "best"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "awaiting_payment",
                "waiting",
                "partially_delegated",
                "delegated",
                "cancelling",
                "cancelled",
                "expired",
                "filled"
              ]
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "until",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "newest",
                "oldest"
              ],
              "default": "newest"
            }
          },
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Order"
                          }
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "offset": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        },
                        "sort": {
                          "type": "string"
                        }
                      },
                      "required": [],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/orders/instant": {
      "post": {
        "operationId": "post_orders_instant",
        "summary": "一条请求创建订单",
        "description": "Scope: buy",
        "tags": [
          "orders"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InstantOrder"
              }
            }
          }
        }
      }
    },
    "/wallets/{id}": {
      "get": {
        "operationId": "get_wallets_id",
        "summary": "钱包与资源快照",
        "description": "Scope: read",
        "tags": [
          "wallets"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Wallet"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patch_wallets_id",
        "summary": "启用或禁用钱包",
        "description": "Scope: wallets",
        "tags": [
          "wallets"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Wallet"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "enabled"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/wallets/{id}/prepare-permission": {
      "post": {
        "operationId": "post_wallets_id_prepare_permission",
        "summary": "准备卖家权限交易",
        "description": "Scope: wallets",
        "tags": [
          "wallets"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/PreparedPermission"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "required": [],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/offers/{id}/reservations": {
      "get": {
        "operationId": "get_offers_id_reservations",
        "summary": "履约、结算与资源回收",
        "description": "Scope: read",
        "tags": [
          "offers"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/capabilities": {
      "get": {
        "operationId": "get_capabilities",
        "summary": "Marketplace 能力",
        "description": "Scope: read",
        "tags": [
          "capabilities"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/account": {
      "get": {
        "operationId": "get_account",
        "summary": "账户、余额与用量",
        "description": "Scope: read",
        "tags": [
          "account"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/market": {
      "get": {
        "operationId": "get_market",
        "summary": "市场买单与卖单",
        "description": "Scope: read",
        "tags": [
          "market"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000,
              "default": 0
            }
          },
          {
            "name": "side",
            "in": "query",
            "schema": {
              "enum": [
                "offers",
                "bids"
              ],
              "default": "offers"
            }
          },
          {
            "name": "resource_type",
            "in": "query",
            "schema": {
              "enum": [
                "energy",
                "bandwidth"
              ]
            }
          },
          {
            "name": "duration_type",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "minutes",
                "hours",
                "days"
              ]
            }
          },
          {
            "name": "duration_value",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "min_price_sun",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "max_price_sun",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "min_amount",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "price_asc",
                "price_desc",
                "income_desc",
                "amount_desc",
                "newest",
                "oldest"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/quotes": {
      "post": {
        "operationId": "post_quotes",
        "summary": "创建购买报价",
        "description": "Scope: buy",
        "tags": [
          "quotes"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Quote"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PurchaseQuote"
              }
            }
          }
        }
      }
    },
    "/orders": {
      "post": {
        "operationId": "post_orders",
        "summary": "按报价创建订单",
        "description": "Scope: buy",
        "tags": [
          "orders"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlaceOrder"
              }
            }
          }
        }
      },
      "get": {
        "operationId": "get_orders",
        "summary": "订单记录与查询",
        "description": "Scope: read",
        "tags": [
          "orders"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000,
              "default": 0
            }
          },
          {
            "name": "external_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "resource_type",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "energy",
                "bandwidth"
              ]
            }
          },
          {
            "name": "mode",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "bid",
                "offer",
                "best"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "awaiting_payment",
                "waiting",
                "partially_delegated",
                "delegated",
                "cancelling",
                "cancelled",
                "expired",
                "filled"
              ]
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "until",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "newest",
                "oldest"
              ],
              "default": "newest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Order"
                          }
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "offset": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        },
                        "sort": {
                          "type": "string"
                        }
                      },
                      "required": [],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/orders/batch": {
      "post": {
        "operationId": "post_orders_batch",
        "summary": "原子创建最多 20 个订单",
        "description": "Scope: buy",
        "tags": [
          "orders"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orders": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/PlaceOrder"
                    },
                    "minItems": 1,
                    "maxItems": 20
                  }
                },
                "required": [
                  "orders"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/orders/{id}": {
      "get": {
        "operationId": "get_orders_id",
        "summary": "订单、履约和 TXID",
        "description": "Scope: read",
        "tags": [
          "orders"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}/payment": {
      "post": {
        "operationId": "post_orders_id_payment",
        "summary": "订单支付信息",
        "description": "Scope: buy",
        "tags": [
          "orders"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "required": [],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/orders/{id}/cancel": {
      "post": {
        "operationId": "post_orders_id_cancel",
        "summary": "取消未履约部分",
        "description": "Scope: buy",
        "tags": [
          "orders"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "required": [],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/wallet-challenges": {
      "post": {
        "operationId": "post_wallet_challenges",
        "summary": "获取所有权签名消息",
        "description": "Scope: wallets",
        "tags": [
          "wallet-challenges"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "address": {
                    "type": "string"
                  }
                },
                "required": [
                  "address"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/wallets": {
      "post": {
        "operationId": "post_wallets",
        "summary": "验证并注册钱包",
        "description": "Scope: wallets",
        "tags": [
          "wallets"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "challenge_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "signatures": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "minItems": 1,
                    "maxItems": 32
                  },
                  "automatic": {
                    "type": "boolean",
                    "default": false
                  }
                },
                "required": [
                  "challenge_id",
                  "signatures"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      },
      "get": {
        "operationId": "get_wallets",
        "summary": "已注册钱包",
        "description": "Scope: read",
        "tags": [
          "wallets"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Wallet"
                      }
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/offers": {
      "post": {
        "operationId": "post_offers",
        "summary": "创建卖家报价",
        "description": "Scope: offers",
        "tags": [
          "offers"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Offer"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateOffer"
              }
            }
          }
        }
      },
      "get": {
        "operationId": "get_offers",
        "summary": "我的卖家报价",
        "description": "Scope: read",
        "tags": [
          "offers"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000,
              "default": 0
            }
          },
          {
            "name": "wallet_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "draft",
                "active",
                "pending_match",
                "filled",
                "cancelled",
                "expired",
                "paused_no_energy",
                "paused_no_bandwidth",
                "paused_permission",
                "paused_fee_resource"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Offer"
                          }
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "offset": {
                          "type": "integer"
                        }
                      },
                      "required": [],
                      "additionalProperties": false
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/offers/{id}": {
      "get": {
        "operationId": "get_offers_id",
        "summary": "报价与剩余数量",
        "description": "Scope: read",
        "tags": [
          "offers"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Offer"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patch_offers_id",
        "summary": "价格、数量、期限、暂停与重复",
        "description": "Scope: offers",
        "tags": [
          "offers"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Offer"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EditOffer"
              }
            }
          }
        }
      }
    },
    "/trades": {
      "post": {
        "operationId": "post_trades",
        "summary": "接受买家订单",
        "description": "Scope: sell",
        "tags": [
          "trades"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Trade"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "order_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "wallet_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "resource_amount": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 500000000
                  }
                },
                "required": [
                  "order_id",
                  "wallet_id",
                  "resource_amount"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      },
      "get": {
        "operationId": "get_trades",
        "summary": "我的手动交易",
        "description": "Scope: read",
        "tags": [
          "trades"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/trades/{id}": {
      "get": {
        "operationId": "get_trades_id",
        "summary": "卖家交易状态",
        "description": "Scope: read",
        "tags": [
          "trades"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Trade"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/trades/{id}/delegate": {
      "post": {
        "operationId": "post_trades_id_delegate",
        "summary": "提交已签名委托",
        "description": "Scope: sell",
        "tags": [
          "trades"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Trade"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "signed_transaction": {
                    "type": "object",
                    "additionalProperties": true
                  }
                },
                "required": [
                  "signed_transaction"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/trades/{id}/cancel": {
      "post": {
        "operationId": "post_trades_id_cancel",
        "summary": "释放尚未执行的接单",
        "description": "Scope: sell",
        "tags": [
          "trades"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Trade"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "required": [],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/events": {
      "get": {
        "operationId": "get_events",
        "summary": "游标事件记录",
        "description": "Scope: read",
        "tags": [
          "events"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "after",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{1,18}$",
              "default": "0"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/statistics": {
      "get": {
        "operationId": "get_statistics",
        "summary": "购买、销售和收益统计",
        "description": "Scope: read",
        "tags": [
          "statistics"
        ],
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 3660,
              "default": 30
            }
          },
          {
            "name": "period",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "rolling",
                "today",
                "yesterday",
                "week",
                "month",
                "all"
              ],
              "default": "rolling"
            }
          },
          {
            "name": "timezone",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "Europe/Moscow",
                "UTC"
              ],
              "default": "Europe/Moscow"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhook": {
      "get": {
        "operationId": "get_webhook",
        "summary": "当前 webhook 地址",
        "description": "Scope: webhooks",
        "tags": [
          "webhook"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "put_webhook",
        "summary": "配置或关闭 webhook",
        "description": "Scope: webhooks",
        "tags": [
          "webhook"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    },
                    "request_id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "VALIDATION_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "UNAUTHORIZED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "SCOPE_REQUIRED / IP_NOT_ALLOWED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "uri",
                    "maxLength": 2048
                  }
                },
                "required": [
                  "url"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "MarketplaceKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "tbm_"
      }
    },
    "schemas": {
      "Duration": {
        "type": "object",
        "properties": {
          "type": {
            "enum": [
              "minutes",
              "hours",
              "days"
            ]
          },
          "value": {
            "type": "integer",
            "minimum": 1,
            "maximum": 30
          }
        },
        "required": [
          "type",
          "value"
        ],
        "additionalProperties": false
      },
      "PurchaseQuote": {
        "type": "object",
        "properties": {
          "mode": {
            "enum": [
              "bid",
              "offer",
              "best"
            ]
          },
          "resource_type": {
            "enum": [
              "energy",
              "bandwidth"
            ]
          },
          "resource_amount": {
            "type": "integer",
            "minimum": 1,
            "maximum": 500000000
          },
          "duration": {
            "$ref": "#/components/schemas/Duration"
          },
          "recipient_address": {
            "type": "string"
          },
          "offer_id": {
            "type": "string",
            "format": "uuid"
          },
          "price_sun": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          },
          "max_price_sun": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          },
          "max_total_trx": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d{1,6})?$",
            "example": "2.620000"
          },
          "allow_partial": {
            "type": "boolean",
            "default": true
          },
          "wait_seconds": {
            "type": "integer",
            "minimum": 30,
            "maximum": 2592000,
            "default": 900
          }
        },
        "required": [
          "mode",
          "resource_type",
          "resource_amount",
          "duration",
          "recipient_address"
        ],
        "additionalProperties": false
      },
      "PlaceOrder": {
        "type": "object",
        "properties": {
          "quote_id": {
            "type": "string",
            "format": "uuid"
          },
          "payment_mode": {
            "enum": [
              "balance",
              "onchain"
            ],
            "default": "balance"
          },
          "external_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          }
        },
        "required": [
          "quote_id"
        ],
        "additionalProperties": false
      },
      "CreateOffer": {
        "type": "object",
        "properties": {
          "wallet_id": {
            "type": "string",
            "format": "uuid"
          },
          "resource_type": {
            "enum": [
              "energy",
              "bandwidth"
            ]
          },
          "resource_amount": {
            "type": "integer",
            "minimum": 1,
            "maximum": 500000000
          },
          "duration": {
            "$ref": "#/components/schemas/Duration"
          },
          "price_sun": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          },
          "auto_repeat": {
            "type": "boolean"
          },
          "paused": {
            "type": "boolean"
          }
        },
        "required": [
          "wallet_id",
          "resource_type",
          "resource_amount",
          "duration",
          "price_sun"
        ],
        "additionalProperties": false
      },
      "EditOffer": {
        "type": "object",
        "properties": {
          "price_sun": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          },
          "free_amount": {
            "type": "integer",
            "minimum": 0,
            "maximum": 500000000
          },
          "duration": {
            "$ref": "#/components/schemas/Duration"
          },
          "paused": {
            "type": "boolean"
          },
          "auto_repeat": {
            "type": "boolean"
          },
          "cancel": {
            "type": "boolean"
          }
        },
        "required": [],
        "additionalProperties": false,
        "minProperties": 1
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "details": {}
            },
            "required": [
              "code"
            ],
            "additionalProperties": false
          },
          "request_id": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "error",
          "request_id"
        ],
        "additionalProperties": false
      },
      "Order": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "mode": {
            "enum": [
              "bid",
              "offer",
              "best"
            ]
          },
          "status": {
            "type": "string"
          },
          "resource_type": {
            "enum": [
              "energy",
              "bandwidth"
            ]
          },
          "resource_amount": {
            "type": "integer"
          },
          "delivered_amount": {
            "type": "integer"
          },
          "remaining_amount": {
            "type": "integer"
          },
          "duration": {
            "$ref": "#/components/schemas/Duration"
          },
          "recipient_address": {
            "type": "string"
          },
          "payment_mode": {
            "enum": [
              "balance",
              "onchain"
            ]
          },
          "max_price_sun": {
            "type": "integer"
          },
          "max_total_trx": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d{1,6})?$",
            "example": "2.620000"
          },
          "paid_trx": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d{1,6})?$",
            "example": "2.620000"
          },
          "reserved_trx": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d{1,6})?$",
            "example": "2.620000"
          },
          "refunded_trx": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d{1,6})?$",
            "example": "2.620000"
          },
          "payment_txid": {
            "type": [
              "string",
              "null"
            ]
          },
          "allow_partial": {
            "type": "boolean"
          },
          "delivery_complete": {
            "type": "boolean"
          },
          "deadline": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "txid_delegate": {
            "type": [
              "string",
              "null"
            ]
          },
          "txids_delegate": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "fulfillments": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "trades": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "closed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "Quote": {
        "type": "object",
        "properties": {
          "quote_id": {
            "type": "string",
            "format": "uuid"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "price_sun": {
            "type": "integer"
          },
          "max_total_trx": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d{1,6})?$",
            "example": "2.620000"
          },
          "reserve_trx": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d{1,6})?$",
            "example": "2.620000"
          },
          "buyer_fee_trx": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d{1,6})?$",
            "example": "2.620000"
          },
          "estimated_total_trx": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d{1,6})?$",
            "example": "2.620000"
          },
          "available_amount": {
            "type": "integer"
          },
          "fully_available": {
            "type": "boolean"
          },
          "availability_is_reservation": {
            "const": false
          },
          "allocations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "offer_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "resource_amount": {
                  "type": "integer"
                },
                "total_trx": {
                  "type": "string",
                  "pattern": "^\\d+(\\.\\d{1,6})?$",
                  "example": "2.620000"
                },
                "commission_trx": {
                  "type": "string",
                  "pattern": "^\\d+(\\.\\d{1,6})?$",
                  "example": "2.620000"
                },
                "seller_net_trx": {
                  "type": "string",
                  "pattern": "^\\d+(\\.\\d{1,6})?$",
                  "example": "2.620000"
                }
              },
              "required": [],
              "additionalProperties": false
            }
          }
        }
      },
      "Trade": {
        "type": "object",
        "properties": {
          "trade_id": {
            "type": "string",
            "format": "uuid"
          },
          "order_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string"
          },
          "resource_type": {
            "type": "string"
          },
          "resource_amount": {
            "type": "integer"
          },
          "source_address": {
            "type": "string"
          },
          "recipient_address": {
            "type": "string"
          },
          "delegate_balance_sun": {
            "type": "integer"
          },
          "lock_period_blocks": {
            "type": "integer"
          },
          "gross_trx": {
            "type": "number"
          },
          "commission_trx": {
            "type": "number"
          },
          "payout_trx": {
            "type": "number"
          },
          "payout_currency": {
            "type": "string"
          },
          "payout_address": {
            "type": "string"
          },
          "delegate_txid": {
            "type": [
              "string",
              "null"
            ]
          },
          "payout_txid": {
            "type": [
              "string",
              "null"
            ]
          },
          "claim_expires_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PricePreview": {
        "type": "object",
        "properties": {
          "quote_id": {
            "type": "null"
          },
          "expires_at": {
            "type": "null"
          },
          "price_sun": {
            "type": "integer"
          },
          "max_total_trx": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d{1,6})?$",
            "example": "2.620000"
          },
          "reserve_trx": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d{1,6})?$",
            "example": "2.620000"
          },
          "buyer_fee_trx": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d{1,6})?$",
            "example": "2.620000"
          },
          "estimated_total_trx": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d{1,6})?$",
            "example": "2.620000"
          },
          "available_amount": {
            "type": "integer"
          },
          "fully_available": {
            "type": "boolean"
          },
          "availability_is_reservation": {
            "const": false
          },
          "allocations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "offer_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "resource_amount": {
                  "type": "integer"
                },
                "total_trx": {
                  "type": "string",
                  "pattern": "^\\d+(\\.\\d{1,6})?$",
                  "example": "2.620000"
                },
                "commission_trx": {
                  "type": "string",
                  "pattern": "^\\d+(\\.\\d{1,6})?$",
                  "example": "2.620000"
                },
                "seller_net_trx": {
                  "type": "string",
                  "pattern": "^\\d+(\\.\\d{1,6})?$",
                  "example": "2.620000"
                }
              },
              "required": [],
              "additionalProperties": false
            }
          }
        }
      },
      "InstantOrder": {
        "type": "object",
        "properties": {
          "purchase": {
            "$ref": "#/components/schemas/PurchaseQuote"
          },
          "payment_mode": {
            "enum": [
              "balance",
              "onchain"
            ],
            "default": "balance"
          },
          "external_id": {
            "type": "string",
            "maxLength": 128
          }
        },
        "required": [
          "purchase"
        ],
        "additionalProperties": false
      },
      "Offer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "wallet_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "resource_wallet_id": {
            "type": "string",
            "format": "uuid"
          },
          "owner_address": {
            "type": "string"
          },
          "resource_type": {
            "enum": [
              "energy",
              "bandwidth"
            ]
          },
          "resource_amount": {
            "type": "integer"
          },
          "free_amount": {
            "type": "integer"
          },
          "fulfilled_amount": {
            "type": "integer"
          },
          "reserved_amount": {
            "type": "integer"
          },
          "duration": {
            "$ref": "#/components/schemas/Duration"
          },
          "price_sun": {
            "type": "integer"
          },
          "status": {
            "type": "string"
          },
          "paused": {
            "type": "boolean"
          },
          "auto_repeat": {
            "type": "boolean"
          },
          "replaced_by": {
            "type": [
              "string",
              "null"
            ]
          },
          "repeat_source_offer_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Wallet": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "address": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "resource_wallet_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "permission_id": {
            "type": "integer"
          },
          "permission_status": {
            "type": "string"
          },
          "energy_available": {
            "type": "string"
          },
          "bandwidth_available": {
            "type": "string"
          },
          "resources_checked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "ResourceAvailability": {
        "type": "object",
        "properties": {
          "energy": {
            "type": "integer"
          },
          "bandwidth": {
            "type": "integer"
          },
          "resources": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "as_of": {
            "type": "string",
            "format": "date-time"
          },
          "snapshot_max_age_seconds": {
            "type": "integer"
          },
          "availability_is_reservation": {
            "const": false
          },
          "unique_wallet_capacity": {
            "const": true
          }
        }
      },
      "EnergyEstimate": {
        "type": "object",
        "properties": {
          "from_address": {
            "type": "string"
          },
          "to_address": {
            "type": "string"
          },
          "contract_address": {
            "type": "string"
          },
          "amount": {
            "type": "string"
          },
          "energy_used": {
            "type": "integer"
          },
          "recommended_energy": {
            "type": "integer"
          },
          "energy_fee_sun": {
            "type": "integer"
          },
          "fee_sun": {
            "type": "string"
          },
          "fee_trx": {
            "type": "string",
            "pattern": "^\\d+(\\.\\d{1,6})?$",
            "example": "2.620000"
          },
          "source": {
            "const": "chain_simulation"
          },
          "estimated_at": {
            "type": "string",
            "format": "date-time"
          },
          "cache_ttl_seconds": {
            "const": 15
          },
          "cached": {
            "type": "boolean"
          }
        }
      },
      "Recharge": {
        "type": "object",
        "properties": {
          "asset": {
            "const": "TRX"
          },
          "network": {
            "const": "TRON"
          },
          "payer_address": {
            "type": "string"
          },
          "recharge_address": {
            "type": "string"
          },
          "balance": {
            "const": "shared"
          },
          "memo_required": {
            "const": false
          },
          "can_recharge": {
            "type": "boolean"
          },
          "blocked_reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "instructions": {
            "type": "string"
          }
        },
        "required": [],
        "additionalProperties": false
      },
      "PreparedPermission": {
        "type": "object",
        "properties": {
          "wallet_id": {
            "type": "string",
            "format": "uuid"
          },
          "owner_address": {
            "type": "string"
          },
          "signer_address": {
            "type": "string"
          },
          "permission_name": {
            "type": "string"
          },
          "operations_hex": {
            "type": "string"
          },
          "transaction": {
            "type": "object",
            "additionalProperties": true
          },
          "broadcast": {
            "const": false
          },
          "requires_owner_signature": {
            "const": true
          },
          "network_fee_paid_by": {
            "const": "owner"
          }
        },
        "required": [],
        "additionalProperties": false
      }
    }
  },
  "externalDocs": {
    "url": "https://tronbid.com/zh/tron-energy-marketplace-api"
  }
}
