{"openapi":"3.0.3","info":{"title":"ChainBridge Trading API","version":"1.0.0","description":"DEX Aggregator with Cross-Chain Bridge, Fiat On-Ramp, Pool Management, and Staking. Queries 7 aggregators for best swap execution across 4+ chains.","contact":{"name":"ChainBridge Trading"}},"servers":[{"url":"/api","description":"Local API"}],"tags":[{"name":"SOR","description":"Smart Order Router — swap quotes and execution"},{"name":"Bridge","description":"Cross-chain bridge quotes, transactions, and status"},{"name":"Fiat","description":"Fiat on-ramp/off-ramp quotes and transactions"},{"name":"Price","description":"Token USD pricing via CoinGecko"},{"name":"Gasless","description":"Gasless swap submission and status (0x, UniswapX)"},{"name":"Simulation","description":"Pre-swap transaction simulation (Tenderly)"},{"name":"SSE","description":"Server-Sent Events for real-time data"},{"name":"Legacy","description":"Legacy 0x swap endpoints (deprecated)"}],"paths":{"/sor/quotes":{"get":{"tags":["SOR"],"summary":"Get swap quotes from all aggregators","description":"Queries up to 7 DEX aggregators and returns sorted quotes with the best price.","parameters":[{"name":"chainId","in":"query","required":true,"schema":{"type":"integer","enum":[1,10,42161,8453]},"description":"Chain ID"},{"name":"sellToken","in":"query","required":true,"schema":{"type":"string"},"description":"Sell token address (0x...)"},{"name":"buyToken","in":"query","required":true,"schema":{"type":"string"},"description":"Buy token address (0x...)"},{"name":"sellAmount","in":"query","required":true,"schema":{"type":"string"},"description":"Sell amount in wei"},{"name":"takerAddress","in":"query","schema":{"type":"string"},"description":"Taker wallet address"},{"name":"slippageBps","in":"query","schema":{"type":"integer","default":100},"description":"Slippage in basis points (100 = 1%)"},{"name":"aggregators","in":"query","schema":{"type":"string"},"description":"Comma-separated aggregator IDs to query"}],"responses":{"200":{"description":"Quotes retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SORQuotesResponse"}}}},"400":{"description":"Validation error"},"500":{"description":"Server error"}}}},"/sor/swap":{"post":{"tags":["SOR"],"summary":"Get swap transaction data","description":"Returns calldata for executing a swap via a specific aggregator.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["aggregatorId","sellToken","buyToken","sellAmount","chainId"],"properties":{"aggregatorId":{"type":"string","enum":["0x","1inch","paraswap","kyber","uniswapx","balancer","thorchain"]},"sellToken":{"type":"string"},"buyToken":{"type":"string"},"sellAmount":{"type":"string"},"chainId":{"type":"integer"},"slippageBps":{"type":"integer","default":100}}}}}},"responses":{"200":{"description":"Swap transaction data"},"400":{"description":"Validation error"}}}},"/sor/aggregators":{"get":{"tags":["SOR"],"summary":"List available aggregators","parameters":[{"name":"chainId","in":"query","schema":{"type":"integer"},"description":"Filter by chain ID"}],"responses":{"200":{"description":"List of aggregator configurations"}}}},"/sor/order-status":{"get":{"tags":["SOR"],"summary":"Check UniswapX order fill status","parameters":[{"name":"orderHash","in":"query","required":true,"schema":{"type":"string"}},{"name":"chainId","in":"query","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Order status"}}}},"/bridge/quote":{"get":{"tags":["Bridge"],"summary":"Get cross-chain bridge quotes","parameters":[{"name":"fromChainId","in":"query","required":true,"schema":{"type":"integer"}},{"name":"toChainId","in":"query","required":true,"schema":{"type":"integer"}},{"name":"fromToken","in":"query","required":true,"schema":{"type":"string"}},{"name":"toToken","in":"query","required":true,"schema":{"type":"string"}},{"name":"fromAmount","in":"query","required":true,"schema":{"type":"string"}},{"name":"fromAddress","in":"query","required":true,"schema":{"type":"string"}},{"name":"slippageBps","in":"query","schema":{"type":"integer","default":100}},{"name":"providers","in":"query","schema":{"type":"string"},"description":"Comma-separated: lifi,socket"},{"name":"sortBy","in":"query","schema":{"type":"string","enum":["output","time","fees"]}}],"responses":{"200":{"description":"Bridge routes and best route"},"400":{"description":"Validation error"}}}},"/bridge/transaction":{"post":{"tags":["Bridge"],"summary":"Get bridge transaction data","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["provider","routeId","fromAddress"],"properties":{"provider":{"type":"string","enum":["lifi","socket"]},"routeId":{"type":"string"},"fromAddress":{"type":"string"}}}}}},"responses":{"200":{"description":"Transaction data for bridge"}}}},"/bridge/status":{"get":{"tags":["Bridge"],"summary":"Check bridge transaction status","parameters":[{"name":"provider","in":"query","required":true,"schema":{"type":"string"}},{"name":"txHash","in":"query","required":true,"schema":{"type":"string"}},{"name":"fromChainId","in":"query","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Bridge status (pending, completed, failed)"}}}},"/bridge/chains":{"get":{"tags":["Bridge"],"summary":"List supported bridge chains","responses":{"200":{"description":"Supported chains with metadata"}}}},"/price":{"get":{"tags":["Price"],"summary":"Get USD prices for tokens","parameters":[{"name":"chainId","in":"query","required":true,"schema":{"type":"integer"}},{"name":"tokens","in":"query","required":true,"schema":{"type":"string"},"description":"Comma-separated token addresses (max 50)"}],"responses":{"200":{"description":"Token prices in USD"},"400":{"description":"Validation error"}}}},"/gasless/submit":{"post":{"tags":["Gasless"],"summary":"Submit gasless swap order","description":"Submits a signed gasless order (0x or UniswapX) for execution.","responses":{"200":{"description":"Order submitted"}}}},"/gasless/status":{"get":{"tags":["Gasless"],"summary":"Check gasless order status","parameters":[{"name":"tradeHash","in":"query","required":true,"schema":{"type":"string"}},{"name":"chainId","in":"query","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Gasless order status"}}}},"/simulation":{"post":{"tags":["Simulation"],"summary":"Simulate swap transaction","description":"Uses Tenderly to simulate a transaction before execution. Detects reverts and shows expected balance changes.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["chainId","from","to","data"],"properties":{"chainId":{"type":"integer"},"from":{"type":"string"},"to":{"type":"string"},"data":{"type":"string"},"value":{"type":"string","default":"0"},"gas":{"type":"integer"}}}}}},"responses":{"200":{"description":"Simulation result with balance changes"},"400":{"description":"Validation error"}}}},"/price/stream":{"get":{"tags":["SSE"],"summary":"Real-time price stream (SSE)","description":"Server-Sent Events endpoint for live token price updates.","parameters":[{"name":"chainId","in":"query","required":true,"schema":{"type":"integer"}},{"name":"tokens","in":"query","required":true,"schema":{"type":"string"},"description":"Comma-separated (max 20)"},{"name":"interval","in":"query","schema":{"type":"integer","default":5000},"description":"Update interval in ms (min 2000)"}],"responses":{"200":{"description":"SSE stream (text/event-stream)"}}}},"/bridge/status/stream":{"get":{"tags":["SSE"],"summary":"Bridge status stream (SSE)","parameters":[{"name":"provider","in":"query","required":true,"schema":{"type":"string"}},{"name":"txHash","in":"query","required":true,"schema":{"type":"string"}},{"name":"fromChainId","in":"query","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"SSE stream with bridge status updates"}}}},"/gasless/status/stream":{"get":{"tags":["SSE"],"summary":"Gasless order status stream (SSE)","parameters":[{"name":"tradeHash","in":"query","required":true,"schema":{"type":"string"}},{"name":"chainId","in":"query","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"SSE stream with order status updates"}}}},"/swap/price":{"get":{"tags":["Legacy"],"summary":"[Deprecated] Get 0x swap price","deprecated":true,"responses":{"200":{"description":"Price quote"}}}},"/swap/quote":{"get":{"tags":["Legacy"],"summary":"[Deprecated] Get 0x swap quote","deprecated":true,"responses":{"200":{"description":"Swap quote"}}}},"/trade/recent-swaps":{"get":{"tags":["SOR"],"summary":"Get recent swaps for a pair","responses":{"200":{"description":"Recent swap trades"}}}}},"components":{"schemas":{"SORQuotesResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"request":{"type":"object"},"quotes":{"type":"array","items":{"$ref":"#/components/schemas/AggregatorQuote"}},"bestQuote":{"$ref":"#/components/schemas/AggregatorQuote"},"stats":{"type":"object","properties":{"totalAggregators":{"type":"integer"},"successfulQuotes":{"type":"integer"},"timestamp":{"type":"integer"}}}}}}},"AggregatorQuote":{"type":"object","properties":{"aggregatorId":{"type":"string"},"buyAmount":{"type":"string"},"sellAmount":{"type":"string"},"price":{"type":"string"},"gasCostUSD":{"type":"string"},"error":{"type":"string","nullable":true}}},"ErrorResponse":{"type":"object","properties":{"success":{"type":"boolean","example":false},"error":{"type":"string"},"code":{"type":"string"}}}}}}