{
  "openapi": "3.1.0",
  "info": {
    "title": "CZR Trade API",
    "version": "2.0.0",
    "description": "CZR Trade API for Ethereum swap transactions and receipts, native BTC ↔ ETH estimates, and USDC bridge estimates and status."
  },
  "servers": [
    {
      "url": "https://czrtrade.com"
    }
  ],
  "paths": {
    "/api/v1/network": {
      "get": {
        "operationId": "getNetwork",
        "summary": "Get supported network and fee details",
        "responses": {
          "200": {
            "description": "Ethereum configuration",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Network"
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/quote": {
      "post": {
        "operationId": "createQuote",
        "summary": "Get an unsigned Ethereum swap transaction",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Timed quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quote"
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/receipt": {
      "get": {
        "operationId": "getReceipt",
        "summary": "Check on-chain swap status and treasury fee",
        "parameters": [
          {
            "name": "hash",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{64}$"
            }
          },
          {
            "name": "taker",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{40}$"
            }
          },
          {
            "name": "feeAsset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "ETH",
                "USDC"
              ]
            }
          },
          {
            "name": "feeToken",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{40}$"
            },
            "description": "Sell token for treasury transfer lookup"
          }
        ],
        "responses": {
          "200": {
            "description": "Settled transaction",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "202": {
            "description": "Transaction receipt is pending",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "state": {
                      "const": "pending"
                    },
                    "hash": {
                      "type": "string",
                      "pattern": "^0x[0-9a-fA-F]{64}$"
                    },
                    "provider": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "state",
                    "hash",
                    "provider"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bridge/estimate": {
      "get": {
        "operationId": "getBridgeEstimate",
        "summary": "Get a USDC bridge estimate without signing or broadcasting",
        "parameters": [
          {
            "name": "originChain",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "enum": [
                1,
                8453,
                42161
              ]
            }
          },
          {
            "name": "destinationChain",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "enum": [
                1,
                8453,
                42161
              ]
            }
          },
          {
            "name": "originAddress",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{40}$"
            }
          },
          {
            "name": "sellAmount",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]+$",
              "description": "Amount in base units"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pricing estimate",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "provider": {
                      "const": "CZR Trade"
                    },
                    "mode": {
                      "const": "estimate"
                    },
                    "originChainId": {
                      "type": "integer"
                    },
                    "destinationChainId": {
                      "type": "integer"
                    },
                    "sellToken": {
                      "type": "string",
                      "pattern": "^0x[0-9a-fA-F]{40}$"
                    },
                    "buyToken": {
                      "type": "string",
                      "pattern": "^0x[0-9a-fA-F]{40}$"
                    },
                    "sellAmount": {
                      "type": "string",
                      "pattern": "^[0-9]+$",
                      "description": "Amount in base units"
                    },
                    "buyAmount": {
                      "type": "string",
                      "pattern": "^[0-9]+$",
                      "description": "Amount in base units"
                    },
                    "minBuyAmount": {
                      "type": "string",
                      "pattern": "^[0-9]+$",
                      "description": "Amount in base units"
                    },
                    "estimatedTimeSeconds": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Invalid request or bridge pricing unavailable"
          }
        }
      }
    },
    "/api/v2/capabilities": {
      "get": {
        "operationId": "getTradeCapabilities",
        "summary": "List live products, networks, and execution modes",
        "responses": {
          "200": {
            "description": "Current capabilities",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "provider",
                    "capabilities"
                  ],
                  "properties": {
                    "provider": {
                      "const": "CZR Trade"
                    },
                    "capabilities": {
                      "type": "object",
                      "required": [
                        "sameChain",
                        "crossChain",
                        "bitcoin",
                        "fiatBuy",
                        "fiatSell"
                      ],
                      "properties": {
                        "bitcoin": {
                          "type": "object",
                          "required": [
                            "mode",
                            "executionEnabled",
                            "directions",
                            "fees"
                          ],
                          "properties": {
                            "mode": {
                              "const": "estimates"
                            },
                            "executionEnabled": {
                              "const": false
                            },
                            "directions": {
                              "type": "array",
                              "items": {
                                "enum": [
                                  "btc-to-eth",
                                  "eth-to-btc"
                                ]
                              }
                            },
                            "fees": {
                              "type": "object",
                              "properties": {
                                "bps": {
                                  "const": 15
                                },
                                "btcRecipient": {
                                  "type": "string"
                                },
                                "ethRecipient": {
                                  "type": "string"
                                },
                                "btcDustSats": {
                                  "type": "integer"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Structured service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/quote": {
      "post": {
        "operationId": "getUnifiedTradeQuote",
        "summary": "Request an Ethereum swap quote, USDC bridge estimate, or native Bitcoin estimate",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/V2QuoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Quote or bridge estimate",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/Quote"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "product": {
                              "const": "same-chain"
                            }
                          },
                          "required": [
                            "product"
                          ]
                        }
                      ]
                    },
                    {
                      "type": "object",
                      "required": [
                        "product",
                        "mode",
                        "originChainId",
                        "destinationChainId",
                        "sellAmount",
                        "buyAmount",
                        "minBuyAmount"
                      ],
                      "properties": {
                        "product": {
                          "const": "cross-chain"
                        },
                        "mode": {
                          "const": "estimate"
                        },
                        "originChainId": {
                          "type": "integer",
                          "enum": [
                            1,
                            8453,
                            42161
                          ]
                        },
                        "destinationChainId": {
                          "type": "integer",
                          "enum": [
                            1,
                            8453,
                            42161
                          ]
                        },
                        "sellAmount": {
                          "type": "string",
                          "pattern": "^[0-9]+$"
                        },
                        "buyAmount": {
                          "type": "string",
                          "pattern": "^[0-9]+$"
                        },
                        "minBuyAmount": {
                          "type": "string",
                          "pattern": "^[0-9]+$"
                        },
                        "bridgeProviders": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "Provider names reported by 0x for this quote. Empty when unavailable."
                        }
                      }
                    },
                    {
                      "$ref": "#/components/schemas/BitcoinEstimate"
                    },
                    {
                      "$ref": "#/components/schemas/BitcoinExecution"
                    }
                  ]
                }
              }
            }
          },
          "501": {
            "description": "Structured service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Structured service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "description": "Only same-chain quotes can contain wallet transaction data. Native BTC and USDC bridge responses are estimates."
      }
    },
    "/api/v2/status": {
      "get": {
        "operationId": "getUnifiedTradeStatus",
        "summary": "Track Ethereum settlement or a supported bridge transaction",
        "parameters": [
          {
            "name": "product",
            "in": "query",
            "required": true,
            "schema": {
              "enum": [
                "same-chain",
                "cross-chain",
                "bitcoin"
              ]
            }
          },
          {
            "name": "hash",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{64}$"
            }
          },
          {
            "name": "originChain",
            "in": "query",
            "schema": {
              "type": "integer",
              "enum": [
                1,
                8453,
                42161
              ]
            },
            "description": "Required for cross-chain tracking."
          },
          {
            "name": "quoteId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "taker",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{40}$"
            }
          },
          {
            "name": "feeToken",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{40}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transaction state",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "product",
                    "state",
                    "hash"
                  ],
                  "properties": {
                    "product": {
                      "enum": [
                        "same-chain",
                        "cross-chain"
                      ]
                    },
                    "state": {
                      "type": "string"
                    },
                    "hash": {
                      "type": "string"
                    },
                    "terminal": {
                      "type": "boolean"
                    },
                    "recoveryState": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "settledBuyAmount": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Ethereum receipt pending",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "product",
                    "state",
                    "hash"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Structured service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/partner/quotes": {
      "post": {
        "summary": "Create an Ethereum partner quote",
        "security": [
          {
            "PartnerBearer": [],
            "PartnerId": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "taker",
                  "sellToken",
                  "buyToken",
                  "sellAmount"
                ],
                "properties": {
                  "chainId": {
                    "const": 1
                  },
                  "taker": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  },
                  "sellToken": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  },
                  "buyToken": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  },
                  "sellAmount": {
                    "type": "string",
                    "pattern": "^[0-9]+$"
                  },
                  "slippagePpm": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 50000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replay of an unexpired quote",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Quote"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "quoteId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "partnerId": {
                          "type": "string"
                        },
                        "settlementPath": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            },
            "headers": {
              "Idempotency-Replayed": {
                "schema": {
                  "const": "true"
                }
              }
            }
          },
          "201": {
            "description": "Persisted quote and wallet transaction",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Quote"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "quoteId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "partnerId": {
                          "type": "string"
                        },
                        "settlementPath": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid partner credentials"
          },
          "403": {
            "description": "Server-side calls required"
          },
          "409": {
            "description": "Idempotency key conflict or expired quote"
          },
          "422": {
            "description": "Route unsupported or unavailable"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Service unavailable"
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._-]{8,96}$"
            }
          }
        ]
      }
    },
    "/api/v2/partner/settlements/{quoteId}": {
      "parameters": [
        {
          "in": "path",
          "name": "quoteId",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "summary": "Read and refresh a settlement",
        "security": [
          {
            "PartnerBearer": [],
            "PartnerId": []
          }
        ],
        "responses": {
          "200": {
            "description": "Settlement record",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerSettlement"
                }
              }
            }
          },
          "202": {
            "description": "Transaction indexing, confirmation, or fee verification is pending"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid partner credentials"
          },
          "403": {
            "description": "Server-side calls required"
          },
          "404": {
            "description": "Quote not found for this partner"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Service unavailable"
          }
        }
      },
      "post": {
        "summary": "Link the broadcast swap transaction",
        "security": [
          {
            "PartnerBearer": [],
            "PartnerId": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "transactionHash"
                ],
                "properties": {
                  "transactionHash": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{64}$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Settlement record",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerSettlement"
                }
              }
            }
          },
          "202": {
            "description": "Transaction indexing, confirmation, or fee verification is pending"
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid partner credentials"
          },
          "403": {
            "description": "Server-side calls required"
          },
          "404": {
            "description": "Quote not found for this partner"
          },
          "409": {
            "description": "Quote or transaction already linked"
          },
          "422": {
            "description": "Transaction does not match the quote"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Service unavailable"
          }
        }
      }
    },
    "/api/v2/partner/settlements": {
      "get": {
        "summary": "List the partner settlement ledger",
        "security": [
          {
            "PartnerBearer": [],
            "PartnerId": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Partner ledger page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "partnerId": {
                      "type": "string",
                      "enum": [
                        "czr-wallet",
                        "czr-exchange"
                      ]
                    },
                    "records": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PartnerSettlement"
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "401": {
            "description": "Invalid partner credentials"
          },
          "403": {
            "description": "Server-side calls required"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Service unavailable"
          }
        }
      }
    },
    "/api/v2/partner/webhooks/dispatch": {
      "post": {
        "summary": "Dispatch due CZRS settlement webhooks",
        "description": "Use the CZRS partner credential from a backend scheduler. A receiver URL and signing secret are required.",
        "security": [
          {
            "PartnerBearer": [],
            "PartnerId": []
          }
        ],
        "responses": {
          "200": {
            "description": "Attempt totals"
          },
          "401": {
            "description": "Invalid credential"
          },
          "503": {
            "description": "Receiver is not configured or storage is unavailable"
          }
        }
      }
    },
    "/api/v2/readiness": {
      "get": {
        "summary": "Check CZR Trade service readiness",
        "description": "Point-in-time infrastructure checks. These checks do not execute a swap.",
        "responses": {
          "200": {
            "description": "Current component readiness",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "checkedAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "scope": {
                      "type": "string"
                    },
                    "components": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "state": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/api/v2/partner/profile": {
      "get": {
        "summary": "Read authenticated partner configuration",
        "security": [
          {
            "PartnerBearer": [],
            "PartnerId": []
          }
        ],
        "responses": {
          "200": {
            "description": "Partner network, router, fees and settlement capabilities"
          },
          "401": {
            "description": "Invalid credentials"
          }
        }
      }
    },
    "/api/v2/partner/settlements/export": {
      "get": {
        "summary": "Export the latest 250 partner settlement records",
        "security": [
          {
            "PartnerBearer": [],
            "PartnerId": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "state",
            "schema": {
              "enum": [
                "all",
                "settled",
                "reverted",
                "fee_mismatch",
                "receipt_mismatch"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Partner-specific CSV",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Invalid credentials"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "Network": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string"
          },
          "chainId": {
            "type": "integer"
          },
          "network": {
            "type": "string"
          },
          "router": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "address": {
                "type": "string",
                "pattern": "^0x[0-9a-fA-F]{40}$"
              },
              "explorerUrl": {
                "type": "string",
                "format": "uri"
              }
            },
            "required": [
              "name",
              "address",
              "explorerUrl"
            ]
          },
          "fee": {
            "type": "object",
            "properties": {
              "bps": {
                "type": "integer"
              },
              "asset": {
                "const": "sellToken"
              },
              "recipient": {
                "type": "string",
                "pattern": "^0x[0-9a-fA-F]{40}$"
              }
            },
            "required": [
              "bps",
              "asset",
              "recipient"
            ]
          },
          "sellAssets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "symbol": {
                  "type": "string"
                },
                "address": {
                  "type": "string",
                  "pattern": "^0x[0-9a-fA-F]{40}$"
                },
                "decimals": {
                  "type": "integer"
                }
              },
              "required": [
                "symbol",
                "address",
                "decimals"
              ]
            }
          },
          "supportsCustomSellToken": {
            "type": "boolean"
          }
        },
        "required": [
          "provider",
          "chainId",
          "network",
          "router",
          "fee",
          "sellAssets"
        ]
      },
      "QuoteRequest": {
        "type": "object",
        "properties": {
          "taker": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{40}$"
          },
          "sellToken": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{40}$",
            "description": "ETH sentinel or a supported Ethereum ERC-20 contract. Defaults to USDC."
          },
          "buyToken": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{40}$",
            "description": "ETH sentinel or a supported ERC-20 address. Defaults to ETH."
          },
          "sellAmount": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Integer in token base units"
          },
          "execution": {
            "const": "czr-router",
            "description": "Require CZR Trade Router execution, with no fallback."
          }
        },
        "required": [
          "taker",
          "sellAmount"
        ]
      },
      "Quote": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string"
          },
          "execution": {
            "type": "string",
            "enum": [
              "czr-router",
              "0x-direct"
            ]
          },
          "executionLabel": {
            "type": "string"
          },
          "chainId": {
            "type": "integer"
          },
          "taker": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{40}$"
          },
          "sellToken": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{40}$"
          },
          "buyToken": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{40}$"
          },
          "sellAmount": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Integer in token base units"
          },
          "buyAmount": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Integer in token base units"
          },
          "minBuyAmount": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Integer in token base units"
          },
          "expiresAt": {
            "type": "integer"
          },
          "fee": {
            "type": "object",
            "properties": {
              "amount": {
                "type": "string",
                "pattern": "^[0-9]+$",
                "description": "Integer in token base units"
              },
              "token": {
                "type": "string",
                "pattern": "^0x[0-9a-fA-F]{40}$"
              },
              "bps": {
                "type": "integer"
              },
              "recipient": {
                "type": "string",
                "pattern": "^0x[0-9a-fA-F]{40}$"
              }
            },
            "required": [
              "amount",
              "token",
              "bps",
              "recipient"
            ]
          },
          "providerFee": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "amount": {
                    "type": "string",
                    "pattern": "^[0-9]+$",
                    "description": "Integer in token base units"
                  },
                  "token": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  }
                },
                "required": [
                  "amount",
                  "token"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "gasCostWei": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[0-9]+$",
                "description": "Integer in token base units"
              },
              {
                "type": "null"
              }
            ]
          },
          "approval": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  },
                  "spender": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  }
                },
                "required": [
                  "token",
                  "spender"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "transaction": {
            "type": "object",
            "properties": {
              "from": {
                "type": "string",
                "pattern": "^0x[0-9a-fA-F]{40}$"
              },
              "to": {
                "type": "string",
                "pattern": "^0x[0-9a-fA-F]{40}$"
              },
              "data": {
                "type": "string",
                "pattern": "^0x[0-9a-f]+$"
              },
              "value": {
                "type": "string",
                "pattern": "^0x[0-9a-f]+$"
              }
            },
            "required": [
              "from",
              "to",
              "data",
              "value"
            ]
          },
          "liquiditySources": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Provider names reported by 0x for this quote. Empty when unavailable."
          },
          "slippagePpm": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 50000,
                "description": "Maximum slippage in parts per million. 5000 = 0.50%."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "provider",
          "execution",
          "executionLabel",
          "chainId",
          "taker",
          "sellToken",
          "buyToken",
          "sellAmount",
          "buyAmount",
          "minBuyAmount",
          "expiresAt",
          "fee",
          "providerFee",
          "gasCostWei",
          "approval",
          "transaction"
        ]
      },
      "Receipt": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "confirmed",
              "reverted"
            ]
          },
          "hash": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{64}$"
          },
          "from": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{40}$"
          },
          "provider": {
            "type": "string"
          },
          "execution": {
            "type": "string",
            "enum": [
              "czr-router",
              "0x-direct"
            ]
          },
          "executionLabel": {
            "type": "string"
          },
          "treasuryUsdcBaseUnits": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Integer in token base units"
          },
          "treasuryEthWei": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[0-9]+$",
                "description": "Integer in token base units"
              },
              {
                "type": "null"
              }
            ]
          },
          "fee": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  },
                  "amount": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^[0-9]+$",
                        "description": "Amount in base units"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "token",
                  "amount"
                ]
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "state",
          "hash",
          "from",
          "provider",
          "treasuryUsdcBaseUnits"
        ]
      },
      "V2QuoteRequest": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "product",
              "taker",
              "sellAmount"
            ],
            "properties": {
              "product": {
                "const": "same-chain"
              },
              "chainId": {
                "const": 1
              },
              "taker": {
                "type": "string",
                "pattern": "^0x[0-9a-fA-F]{40}$"
              },
              "sellToken": {
                "type": "string",
                "pattern": "^0x[0-9a-fA-F]{40}$"
              },
              "buyToken": {
                "type": "string",
                "pattern": "^0x[0-9a-fA-F]{40}$"
              },
              "sellAmount": {
                "type": "string",
                "pattern": "^[0-9]+$"
              },
              "execution": {
                "const": "czr-router"
              },
              "slippagePpm": {
                "type": "integer",
                "minimum": 0,
                "maximum": 50000,
                "description": "Maximum slippage in parts per million. 5000 = 0.50%."
              }
            }
          },
          {
            "type": "object",
            "required": [
              "product",
              "originChain",
              "destinationChain",
              "originAddress",
              "sellAmount"
            ],
            "properties": {
              "product": {
                "const": "cross-chain"
              },
              "originChain": {
                "type": "integer",
                "enum": [
                  1,
                  8453,
                  42161
                ]
              },
              "destinationChain": {
                "type": "integer",
                "enum": [
                  1,
                  8453,
                  42161
                ]
              },
              "originAddress": {
                "type": "string",
                "pattern": "^0x[0-9a-fA-F]{40}$"
              },
              "sellAmount": {
                "type": "string",
                "pattern": "^[0-9]+$"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "product",
              "direction",
              "originAddress",
              "destinationAddress",
              "sellAmount"
            ],
            "properties": {
              "product": {
                "const": "bitcoin"
              },
              "direction": {
                "enum": [
                  "eth-to-btc",
                  "btc-to-eth"
                ]
              },
              "originAddress": {
                "type": "string"
              },
              "destinationAddress": {
                "type": "string"
              },
              "sellAmount": {
                "type": "string",
                "pattern": "^[1-9][0-9]*$",
                "description": "Wei for ETH or satoshis for BTC"
              },
              "execution": {
                "const": "0x-direct",
                "description": "For eth-to-btc only. Omit to request an estimate."
              },
              "sellAsset": {
                "enum": [
                  "ETH",
                  "USDC",
                  "USDT"
                ],
                "default": "ETH",
                "description": "Ethereum source asset for eth-to-btc."
              }
            },
            "description": "Estimates in both directions. ETH to BTC wallet execution is available with 0x-direct."
          },
          {
            "type": "object",
            "required": [
              "product",
              "amount",
              "asset",
              "currency",
              "country",
              "chainId"
            ],
            "description": "Fiat order intent. The API returns 501 PRODUCT_UNAVAILABLE until a provider is connected.",
            "properties": {
              "product": {
                "enum": [
                  "fiat-buy",
                  "fiat-sell"
                ]
              },
              "amount": {
                "type": "string",
                "pattern": "^[0-9]+(\\.[0-9]+)?$"
              },
              "asset": {
                "enum": [
                  "ETH",
                  "USDC"
                ]
              },
              "currency": {
                "enum": [
                  "USD",
                  "EUR",
                  "GBP"
                ]
              },
              "country": {
                "type": "string",
                "pattern": "^[A-Z]{2}$"
              },
              "chainId": {
                "const": 1
              }
            }
          }
        ]
      },
      "BitcoinEstimate": {
        "type": "object",
        "required": [
          "provider",
          "product",
          "mode",
          "direction",
          "sellAsset",
          "buyAsset",
          "sellAmount",
          "buyAmount",
          "minBuyAmount",
          "fee",
          "feeStatus",
          "estimatedTimeSeconds"
        ],
        "properties": {
          "provider": {
            "const": "CZR Trade"
          },
          "product": {
            "const": "bitcoin"
          },
          "mode": {
            "const": "estimate"
          },
          "direction": {
            "enum": [
              "btc-to-eth",
              "eth-to-btc"
            ]
          },
          "sellAsset": {
            "enum": [
              "ETH",
              "BTC",
              "USDC",
              "USDT"
            ]
          },
          "buyAsset": {
            "enum": [
              "BTC",
              "ETH"
            ]
          },
          "sellAmount": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Integer string in base units for the relevant asset"
          },
          "buyAmount": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Integer string in base units for the relevant asset"
          },
          "minBuyAmount": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Integer string in base units for the relevant asset"
          },
          "fee": {
            "anyOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "required": [
                  "amount",
                  "asset",
                  "recipient",
                  "bps"
                ],
                "properties": {
                  "amount": {
                    "type": "string",
                    "pattern": "^[0-9]+$",
                    "description": "Integer string in base units for the relevant asset"
                  },
                  "asset": {
                    "enum": [
                      "ETH",
                      "BTC",
                      "USDC",
                      "USDT"
                    ]
                  },
                  "recipient": {
                    "type": "string",
                    "description": "CZR fee recipient on the source chain"
                  },
                  "bps": {
                    "const": 15
                  }
                }
              }
            ]
          },
          "feeStatus": {
            "enum": [
              "quoted",
              "below_minimum",
              "not_returned"
            ]
          },
          "estimatedTimeSeconds": {
            "type": [
              "integer",
              "null"
            ]
          },
          "bridgeProviders": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Provider names reported by 0x for this quote. Empty when unavailable."
          },
          "routes": {
            "type": "array",
            "maxItems": 3,
            "description": "Route objects for Ethereum-origin quotes. Each route has the same quote fields, excluding the API envelope and routes array.",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "BitcoinExecution": {
        "type": "object",
        "required": [
          "provider",
          "product",
          "mode",
          "direction",
          "sellAsset",
          "buyAsset",
          "sellAmount",
          "buyAmount",
          "minBuyAmount",
          "fee",
          "feeStatus",
          "estimatedTimeSeconds",
          "execution",
          "chainId",
          "originAddress",
          "destinationAddress",
          "quoteId",
          "expiresAt",
          "transaction"
        ],
        "properties": {
          "provider": {
            "const": "CZR Trade"
          },
          "product": {
            "const": "bitcoin"
          },
          "mode": {
            "const": "wallet_execution"
          },
          "direction": {
            "const": "eth-to-btc"
          },
          "sellAsset": {
            "enum": [
              "ETH",
              "BTC",
              "USDC",
              "USDT"
            ]
          },
          "buyAsset": {
            "enum": [
              "BTC",
              "ETH"
            ]
          },
          "sellAmount": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Integer string in base units for the relevant asset"
          },
          "buyAmount": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Integer string in base units for the relevant asset"
          },
          "minBuyAmount": {
            "type": "string",
            "pattern": "^[0-9]+$",
            "description": "Integer string in base units for the relevant asset"
          },
          "fee": {
            "anyOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "required": [
                  "amount",
                  "asset",
                  "recipient",
                  "bps"
                ],
                "properties": {
                  "amount": {
                    "type": "string",
                    "pattern": "^[0-9]+$",
                    "description": "Integer string in base units for the relevant asset"
                  },
                  "asset": {
                    "enum": [
                      "ETH",
                      "BTC",
                      "USDC",
                      "USDT"
                    ]
                  },
                  "recipient": {
                    "type": "string",
                    "description": "CZR fee recipient on the source chain"
                  },
                  "bps": {
                    "const": 15
                  }
                }
              }
            ]
          },
          "feeStatus": {
            "enum": [
              "quoted",
              "below_minimum",
              "not_returned"
            ]
          },
          "estimatedTimeSeconds": {
            "type": [
              "integer",
              "null"
            ]
          },
          "bridgeProviders": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Provider names reported by 0x for this quote. Empty when unavailable."
          },
          "execution": {
            "const": "0x-direct"
          },
          "chainId": {
            "const": 1
          },
          "originAddress": {
            "type": "string"
          },
          "destinationAddress": {
            "type": "string"
          },
          "quoteId": {
            "type": "string"
          },
          "expiresAt": {
            "type": "integer",
            "description": "Unix milliseconds"
          },
          "transaction": {
            "type": "object",
            "required": [
              "from",
              "to",
              "data",
              "value"
            ],
            "properties": {
              "from": {
                "type": "string"
              },
              "to": {
                "type": "string"
              },
              "data": {
                "type": "string"
              },
              "value": {
                "type": "string"
              }
            }
          },
          "routes": {
            "type": "array",
            "maxItems": 3,
            "description": "Route objects for Ethereum-origin quotes. Each route has the same quote fields, excluding the API envelope and routes array.",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "PartnerSettlement": {
        "type": "object",
        "properties": {
          "quoteId": {
            "type": "string",
            "format": "uuid"
          },
          "partnerId": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$"
          },
          "chainId": {
            "const": 1
          },
          "execution": {
            "const": "czr-router"
          },
          "taker": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{40}$"
          },
          "sellToken": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{40}$"
          },
          "buyToken": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{40}$"
          },
          "sellAmount": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "minBuyAmount": {
            "type": "string",
            "pattern": "^[0-9]+$"
          },
          "outputAmount": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[0-9]+$"
              },
              {
                "type": "null"
              }
            ]
          },
          "blockNumber": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[0-9]+$"
              },
              {
                "type": "null"
              }
            ]
          },
          "transactionHash": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^0x[0-9a-fA-F]{64}$"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "integer"
          },
          "expiresAt": {
            "type": "integer"
          },
          "reconciledAt": {
            "type": [
              "integer",
              "null"
            ]
          },
          "state": {
            "enum": [
              "quoted",
              "expired",
              "submitted",
              "confirming",
              "verification_pending",
              "settled",
              "reverted",
              "fee_mismatch",
              "receipt_mismatch"
            ]
          },
          "fee": {
            "type": "object",
            "properties": {
              "basisPoints": {
                "const": 15
              },
              "token": {
                "type": "string",
                "pattern": "^0x[0-9a-fA-F]{40}$"
              },
              "recipient": {
                "type": "string",
                "pattern": "^0x[0-9a-fA-F]{40}$"
              },
              "expectedAmount": {
                "type": "string",
                "pattern": "^[0-9]+$"
              },
              "observedAmount": {
                "anyOf": [
                  {
                    "type": "string",
                    "pattern": "^[0-9]+$"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "verified": {
                "type": "boolean"
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "PartnerBearer": {
        "type": "http",
        "scheme": "bearer"
      },
      "PartnerId": {
        "type": "apiKey",
        "in": "header",
        "name": "X-CZR-Partner"
      }
    }
  }
}
