{
  "asyncapi": "3.0.0",
  "info": {
    "title": "Decibel WebSocket API",
    "version": "1.0.0",
    "description": "Real-time WebSocket streaming API for Decibel trading platform. Subscribe to market data, orders, positions, and more.",
    "contact": {
      "name": "Decibel Team",
      "url": "https://decibel.trade/"
    }
  },
  "servers": {
    "testnet": {
      "host": "api.testnet.aptoslabs.com/decibel/ws",
      "protocol": "wss",
      "description": "Devnet Testnet server"
    }
  },
  "channels": {
    "accountPositions": {
      "address": "account_positions:{accountAddr}",
      "messages": {
        "AccountPositionsMessage": {
          "$ref": "#/components/messages/AccountPositionsMessage"
        }
      },
      "description": "Account's open positions with PnL and liquidation prices",
      "parameters": {
        "accountAddr": {
          "$ref": "#/components/parameters/accountAddr"
        }
      }
    },
    "bulkOrders": {
      "address": "bulk_orders:{userAddr}",
      "messages": {
        "BulkOrdersMessage": {
          "$ref": "#/components/messages/BulkOrdersMessage"
        }
      },
      "description": "User's bulk orders (multi-order submissions)",
      "parameters": {
        "userAddr": {
          "$ref": "#/components/parameters/userAddr"
        }
      }
    },
    "marketDepth": {
      "address": "depth:{marketAddr}:{aggregationLevel}",
      "messages": {
        "MarketDepthMessage": {
          "$ref": "#/components/messages/MarketDepthMessage"
        }
      },
      "description": "Market order book depth with aggregated price levels. Optional aggregationLevel parameter (1, 2, 5, 10, 100, or 1000) can be appended to the topic, defaults to 1 if not specified.",
      "parameters": {
        "marketAddr": {
          "$ref": "#/components/parameters/marketAddr"
        },
        "aggregationLevel": {
          "$ref": "#/components/parameters/aggregationLevel"
        }
      }
    },
    "withdraw_queue": {
      "address": "withdraw_queue:{userAddr}",
      "messages": {
        "WithdrawQueueMessage": {
          "$ref": "#/components/messages/WithdrawQueueMessage"
        }
      },
      "description": "Real-time withdrawal queue updates for the user",
      "parameters": {
        "userAddr": {
          "$ref": "#/components/parameters/userAddr"
        }
      }
    },
    "notifications": {
      "address": "notifications:{userAddr}",
      "messages": {
        "NotificationsMessage": {
          "$ref": "#/components/messages/NotificationsMessage"
        }
      },
      "description": "Real-time notifications for the user",
      "parameters": {
        "userAddr": {
          "$ref": "#/components/parameters/userAddr"
        }
      }
    },
    "userActiveTwaps": {
      "address": "user_active_twaps:{userAddr}",
      "messages": {
        "UserActiveTwapsMessage": {
          "$ref": "#/components/messages/UserActiveTwapsMessage"
        }
      },
      "description": "User's active TWAP (Time-Weighted Average Price) orders",
      "parameters": {
        "userAddr": {
          "$ref": "#/components/parameters/userAddr"
        }
      }
    },
    "marketCandlestick": {
      "address": "market_candlestick:{marketAddr}:{interval}",
      "messages": {
        "MarketCandlestickMessage": {
          "$ref": "#/components/messages/MarketCandlestickMessage"
        }
      },
      "description": "Real-time candlestick/OHLCV data for a specific market and interval",
      "parameters": {
        "marketAddr": {
          "$ref": "#/components/parameters/marketAddr"
        },
        "interval": {
          "$ref": "#/components/parameters/interval"
        }
      }
    },
    "userTrades": {
      "address": "user_trades:{userAddr}",
      "messages": {
        "UserTradesMessage": {
          "$ref": "#/components/messages/UserTradesMessage"
        }
      },
      "description": "User's trades",
      "parameters": {
        "userAddr": {
          "$ref": "#/components/parameters/userAddr"
        }
      }
    },
    "orderUpdate": {
      "address": "order_updates:{userAddr}",
      "messages": {
        "OrderUpdateMessage": {
          "$ref": "#/components/messages/OrderUpdateMessage"
        }
      },
      "description": "Order update for a specific user",
      "parameters": {
        "userAddr": {
          "$ref": "#/components/parameters/userAddr"
        }
      }
    },
    "marketTrades": {
      "address": "trades:{marketAddr}",
      "messages": {
        "MarketTradesMessage": {
          "$ref": "#/components/messages/MarketTradesMessage"
        }
      },
      "description": "Real-time trade updates for a specific market (not cached, updates only)",
      "parameters": {
        "marketAddr": {
          "$ref": "#/components/parameters/marketAddr"
        }
      }
    },
    "accountOverview": {
      "address": "account_overview:{userAddr}",
      "messages": {
        "AccountOverviewMessage": {
          "$ref": "#/components/messages/AccountOverviewMessage"
        }
      },
      "description": "User's account overview including equity, margin, and PnL",
      "parameters": {
        "userAddr": {
          "$ref": "#/components/parameters/userAddr"
        }
      }
    },
    "marketPrice": {
      "address": "market_price:{marketAddr}",
      "messages": {
        "MarketPriceMessage": {
          "$ref": "#/components/messages/MarketPriceMessage"
        }
      },
      "description": "Real-time price updates for a specific market (oracle, mark, mid prices)",
      "parameters": {
        "marketAddr": {
          "$ref": "#/components/parameters/marketAddr"
        }
      }
    },
    "allMarketPrices": {
      "address": "all_market_prices",
      "messages": {
        "AllMarketPricesMessage": {
          "$ref": "#/components/messages/AllMarketPricesMessage"
        }
      },
      "description": "Price updates for all markets (global topic)"
    },
    "bulkOrderFills": {
      "address": "bulk_order_fills:{userAddr}",
      "messages": {
        "BulkOrderFillsMessage": {
          "$ref": "#/components/messages/BulkOrderFillsMessage"
        }
      },
      "description": "User's bulk order fill events",
      "parameters": {
        "userAddr": {
          "$ref": "#/components/parameters/userAddr"
        }
      }
    },
    "accountOpenOrders": {
      "address": "account_open_orders:{accountAddr}",
      "messages": {
        "AccountOpenOrdersMessage": {
          "$ref": "#/components/messages/AccountOpenOrdersMessage"
        }
      },
      "description": "Account's currently open orders",
      "parameters": {
        "accountAddr": {
          "$ref": "#/components/parameters/accountAddr"
        }
      }
    }
  },
  "operations": {
    "receiveaccountPositions": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/accountPositions"
      },
      "messages": [
        {
          "$ref": "#/channels/accountPositions/messages/AccountPositionsMessage"
        }
      ],
      "description": "Receive updates for account's open positions with pnl and liquidation prices"
    },
    "receiveuserActiveTwaps": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/userActiveTwaps"
      },
      "messages": [
        {
          "$ref": "#/channels/userActiveTwaps/messages/UserActiveTwapsMessage"
        }
      ],
      "description": "Receive updates for user's active twap (time-weighted average price) orders"
    },
    "receiveorderUpdate": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/orderUpdate"
      },
      "messages": [
        {
          "$ref": "#/channels/orderUpdate/messages/OrderUpdateMessage"
        }
      ],
      "description": "Receive updates for order update for a specific user"
    },
    "receiveuserTrades": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/userTrades"
      },
      "messages": [
        {
          "$ref": "#/channels/userTrades/messages/UserTradesMessage"
        }
      ],
      "description": "Receive updates for user's trades"
    },
    "receivemarketPrice": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/marketPrice"
      },
      "messages": [
        {
          "$ref": "#/channels/marketPrice/messages/MarketPriceMessage"
        }
      ],
      "description": "Receive updates for real-time price updates for a specific market (oracle, mark, mid prices)"
    },
    "receivenotifications": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/notifications"
      },
      "messages": [
        {
          "$ref": "#/channels/notifications/messages/NotificationsMessage"
        }
      ],
      "description": "Receive updates for real-time notifications for the user"
    },
    "receivebulkOrders": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/bulkOrders"
      },
      "messages": [
        {
          "$ref": "#/channels/bulkOrders/messages/BulkOrdersMessage"
        }
      ],
      "description": "Receive updates for user's bulk orders (multi-order submissions)"
    },
    "receivemarketDepth": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/marketDepth"
      },
      "messages": [
        {
          "$ref": "#/channels/marketDepth/messages/MarketDepthMessage"
        }
      ],
      "description": "Receive updates for market order book depth with aggregated price levels. optional aggregationlevel parameter (1, 2, 5, 10, 100, or 1000) can be appended to the topic, defaults to 1 if not specified."
    },
    "receivemarketTrades": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/marketTrades"
      },
      "messages": [
        {
          "$ref": "#/channels/marketTrades/messages/MarketTradesMessage"
        }
      ],
      "description": "Receive updates for real-time trade updates for a specific market (not cached, updates only)"
    },
    "receivemarketCandlestick": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/marketCandlestick"
      },
      "messages": [
        {
          "$ref": "#/channels/marketCandlestick/messages/MarketCandlestickMessage"
        }
      ],
      "description": "Receive updates for real-time candlestick/ohlcv data for a specific market and interval"
    },
    "receiveaccountOverview": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/accountOverview"
      },
      "messages": [
        {
          "$ref": "#/channels/accountOverview/messages/AccountOverviewMessage"
        }
      ],
      "description": "Receive updates for user's account overview including equity, margin, and pnl"
    },
    "receivebulkOrderFills": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/bulkOrderFills"
      },
      "messages": [
        {
          "$ref": "#/channels/bulkOrderFills/messages/BulkOrderFillsMessage"
        }
      ],
      "description": "Receive updates for user's bulk order fill events"
    },
    "receivewithdraw_queue": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/withdraw_queue"
      },
      "messages": [
        {
          "$ref": "#/channels/withdraw_queue/messages/WithdrawQueueMessage"
        }
      ],
      "description": "Receive updates for real-time withdrawal queue updates for the user"
    },
    "receiveaccountOpenOrders": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/accountOpenOrders"
      },
      "messages": [
        {
          "$ref": "#/channels/accountOpenOrders/messages/AccountOpenOrdersMessage"
        }
      ],
      "description": "Receive updates for account's currently open orders"
    },
    "receiveallMarketPrices": {
      "action": "receive",
      "channel": {
        "$ref": "#/channels/allMarketPrices"
      },
      "messages": [
        {
          "$ref": "#/channels/allMarketPrices/messages/AllMarketPricesMessage"
        }
      ],
      "description": "Receive updates for price updates for all markets (global topic)"
    }
  },
  "components": {
    "messages": {
      "MarketCandlestickMessage": {
        "description": "Real-time candlestick/OHLCV data for a specific market and interval",
        "payload": {
          "$ref": "#/components/schemas/MarketCandlestickResponse"
        },
        "examples": [
          {
            "name": "Example",
            "summary": "Example real-time candlestick/ohlcv data for a specific market and interval message",
            "payload": {
              "topic": "market_candlestick:0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890:1h",
              "candle": {
                "t": 1699564800000,
                "T": 1699568400000,
                "o": 49800,
                "h": 50300,
                "l": 49600,
                "c": 50125.75,
                "v": 1250.5,
                "i": "1h"
              }
            }
          }
        ]
      },
      "WithdrawQueueMessage": {
        "description": "Real-time withdrawal queue updates for the user",
        "payload": {
          "$ref": "#/components/schemas/WithdrawQueueUpdateResponse"
        },
        "examples": [
          {
            "name": "Example",
            "summary": "Example real-time withdrawal queue updates for the user message",
            "payload": {
              "topic": "withdraw_queue:0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
              "entries": [
                {
                  "user": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
                  "recipient": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
                  "fungible_amount": 100,
                  "processed_amount": 0,
                  "request_id": "12345",
                  "status": "Queued",
                  "timestamp_ms": 1699564800000,
                  "queued_at_ms": 1699564800000,
                  "transaction_version": 12345678
                }
              ]
            }
          }
        ]
      },
      "AccountOverviewMessage": {
        "description": "User's account overview including equity, margin, and PnL",
        "payload": {
          "$ref": "#/components/schemas/AccountOverviewResponse"
        },
        "examples": [
          {
            "name": "Example",
            "summary": "Example user's account overview including equity, margin, and pnl message",
            "payload": {
              "topic": "account_overview:0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
              "account_overview": {
                "perp_equity_balance": 50250.75,
                "perp_equity_haircutted": 50225.75,
                "unrealized_pnl": 1250.5,
                "realized_pnl": 0,
                "liquidation_fees_paid": 0,
                "liquidation_losses": 0,
                "fee_income": null,
                "unrealized_funding_cost": -125.25,
                "cross_margin_ratio": 0.15,
                "maintenance_margin": 2500,
                "cross_account_leverage_ratio": 500,
                "volume": 125000,
                "net_deposits": null,
                "all_time_return": 0.25,
                "pnl_90d": 5000,
                "sharpe_ratio": 1.8,
                "max_drawdown": -0.08,
                "weekly_win_rate_12w": 0.65,
                "average_cash_position": 45000,
                "average_leverage": 5.5,
                "cross_account_position": 25000,
                "total_margin": 10000,
                "usdc_cross_withdrawable_balance": 7500,
                "usdc_isolated_withdrawable_balance": 2500,
                "margin_deficit": 0,
                "vault_equity": null,
                "free_vault_equity": null,
                "secondary_collateral": [
                  {
                    "asset_type": "0xdlp_asset_address",
                    "amount": 500,
                    "value_in_usdc": 475,
                    "nav_per_unit": 1,
                    "haircut_bps": 500,
                    "withdrawable_amount": 400
                  }
                ],
                "cross_available_to_trade": 7500
              }
            }
          }
        ]
      },
      "AccountOpenOrdersMessage": {
        "description": "Account's currently open orders",
        "payload": {
          "$ref": "#/components/schemas/AccountOpenOrdersResponse"
        },
        "examples": [
          {
            "name": "Example",
            "summary": "Example account's currently open orders message",
            "payload": {
              "topic": "account_open_orders:0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
              "orders": [
                {
                  "parent": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
                  "market": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
                  "client_order_id": "order_123",
                  "order_id": "45678",
                  "status": "Open",
                  "order_type": "Limit",
                  "trigger_condition": "None",
                  "order_direction": "Open Long",
                  "orig_size": 1.5,
                  "remaining_size": 1.5,
                  "size_delta": null,
                  "price": 50000.5,
                  "is_buy": true,
                  "is_reduce_only": false,
                  "details": "",
                  "is_tpsl": false,
                  "tp_trigger_price": null,
                  "tp_limit_price": null,
                  "sl_trigger_price": null,
                  "sl_limit_price": null,
                  "cancellation_reason": "",
                  "transaction_version": 12345678,
                  "unix_ms": 1699564800000
                }
              ]
            }
          }
        ]
      },
      "AllMarketPricesMessage": {
        "description": "Price updates for all markets (global topic)",
        "payload": {
          "$ref": "#/components/schemas/AllMarketPricesResponse"
        },
        "examples": [
          {
            "name": "Example",
            "summary": "Example price updates for all markets (global topic) message",
            "payload": {
              "topic": "all_market_prices",
              "prices": [
                {
                  "market": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
                  "oracle_px": 50125.75,
                  "mark_px": 50120.5,
                  "mid_px": 50122.25,
                  "funding_rate_bps": 5,
                  "is_funding_positive": true,
                  "funding_period_s": 3600,
                  "transaction_unix_ms": 1699564800000,
                  "open_interest": 125000.5
                },
                {
                  "market": "0x1111111111111111111111111111111111111111111111111111111111111111",
                  "oracle_px": 3250,
                  "mark_px": 3248.75,
                  "mid_px": 3249.5,
                  "funding_rate_bps": 3,
                  "is_funding_positive": false,
                  "funding_period_s": 3600,
                  "transaction_unix_ms": 1699564800000,
                  "open_interest": 85000.25
                }
              ]
            }
          }
        ]
      },
      "MarketTradesMessage": {
        "description": "Real-time trade updates for a specific market (not cached, updates only)",
        "payload": {
          "$ref": "#/components/schemas/MarketTradesResponse"
        },
        "examples": [
          {
            "name": "Example",
            "summary": "Example real-time trade updates for a specific market (not cached, updates only) message",
            "payload": {
              "topic": "trades:0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
              "trades": [
                {
                  "account": "0x9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba",
                  "market": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
                  "action": "Open Long",
                  "source": "OrderFill",
                  "trade_id": "3647277",
                  "size": 0.8,
                  "price": 50100,
                  "is_profit": false,
                  "realized_pnl_amount": -45.2,
                  "realized_funding_amount": 5.1,
                  "is_rebate": false,
                  "fee_amount": 20.04,
                  "order_id": "45680",
                  "client_order_id": "order_123",
                  "transaction_unix_ms": 1699564900000,
                  "transaction_version": 3647276286
                }
              ]
            }
          }
        ]
      },
      "MarketPriceMessage": {
        "description": "Real-time price updates for a specific market (oracle, mark, mid prices)",
        "payload": {
          "$ref": "#/components/schemas/MarketPriceResponse"
        },
        "examples": [
          {
            "name": "Example",
            "summary": "Example real-time price updates for a specific market (oracle, mark, mid prices) message",
            "payload": {
              "topic": "market_price:0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
              "price": {
                "market": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
                "oracle_px": 50125.75,
                "mark_px": 50120.5,
                "mid_px": 50122.25,
                "funding_rate_bps": 5,
                "is_funding_positive": true,
                "funding_period_s": 3600,
                "transaction_unix_ms": 1699564800000,
                "open_interest": 125000.5
              }
            }
          }
        ]
      },
      "UnsubscribeMessage": {
        "description": "Unsubscribe from a topic to stop receiving updates",
        "payload": {
          "$ref": "#/components/schemas/Unsubscribe"
        }
      },
      "NotificationsMessage": {
        "description": "Real-time notifications for the user",
        "payload": {
          "$ref": "#/components/schemas/UserNotificationResponse"
        },
        "examples": [
          {
            "name": "Example",
            "summary": "Example real-time notifications for the user message",
            "payload": {
              "topic": "notifications:0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
              "notification": {
                "account": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
                "notification_type": "OrderFilled",
                "order": {
                  "parent": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
                  "market": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
                  "client_order_id": "order_123",
                  "order_id": "45678",
                  "status": "Filled",
                  "order_type": "Limit",
                  "trigger_condition": "None",
                  "order_direction": "Open Long",
                  "orig_size": 1.5,
                  "remaining_size": 0,
                  "size_delta": null,
                  "price": 50000.5,
                  "is_buy": true,
                  "is_reduce_only": false,
                  "details": "",
                  "is_tpsl": false,
                  "tp_trigger_price": null,
                  "tp_limit_price": null,
                  "sl_trigger_price": null,
                  "sl_limit_price": null,
                  "cancellation_reason": "",
                  "transaction_version": 12345678,
                  "unix_ms": 1699564800000
                }
              }
            }
          }
        ]
      },
      "BulkOrderFillsMessage": {
        "description": "User's bulk order fill events",
        "payload": {
          "$ref": "#/components/schemas/BulkOrderFillsResponse"
        },
        "examples": [
          {
            "name": "Example",
            "summary": "Example user's bulk order fill events message",
            "payload": {
              "topic": "bulk_order_fills:0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
              "bulk_order_fills": [
                {
                  "market": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
                  "sequence_number": 100,
                  "user": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
                  "filled_size": 1.5,
                  "price": 50000,
                  "is_bid": true,
                  "trade_id": "3647276",
                  "transaction_unix_ms": 1699564800000,
                  "transaction_version": 12345682,
                  "event_uid": 1.2345678901234568e+35
                }
              ]
            }
          }
        ]
      },
      "SubscribeMessage": {
        "description": "Subscribe to a topic to receive real-time updates",
        "payload": {
          "$ref": "#/components/schemas/Subscribe"
        }
      },
      "UnsubscribeResponseMessage": {
        "description": "Server response to an unsubscription request",
        "payload": {
          "$ref": "#/components/schemas/UnsubscribeResponse"
        }
      },
      "BulkOrdersMessage": {
        "description": "User's bulk orders (multi-order submissions)",
        "payload": {
          "$ref": "#/components/schemas/BulkOrdersResponse"
        },
        "examples": [
          {
            "name": "Example",
            "summary": "Example user's bulk orders (multi-order submissions) message",
            "payload": {
              "topic": "bulk_orders:0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
              "bulk_order": {
                "status": "Placed",
                "details": "",
                "bulk_order": {
                  "market": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
                  "user": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
                  "sequence_number": 100,
                  "previous_seq_num": 99,
                  "bid_prices": [
                    50000,
                    49900
                  ],
                  "bid_sizes": [
                    1,
                    2
                  ],
                  "ask_prices": [
                    50100,
                    50200
                  ],
                  "ask_sizes": [
                    1.5,
                    2.5
                  ],
                  "cancelled_bid_prices": [],
                  "cancelled_bid_sizes": [],
                  "cancelled_ask_prices": [],
                  "cancelled_ask_sizes": [],
                  "cancellation_reason": "",
                  "transaction_version": 12345678,
                  "transaction_unix_ms": 1699564800000,
                  "event_uid": 1.2345678901234568e+35
                }
              }
            }
          }
        ]
      },
      "SubscribeResponseMessage": {
        "description": "Server response to a subscription request",
        "payload": {
          "$ref": "#/components/schemas/SubscribeResponse"
        }
      },
      "MarketDepthMessage": {
        "description": "Market order book depth with aggregated price levels. Optional aggregationLevel parameter (1, 2, 5, 10, 100, or 1000) can be appended to the topic, defaults to 1 if not specified.",
        "payload": {
          "$ref": "#/components/schemas/MarketDepthResponse"
        },
        "examples": [
          {
            "name": "Example",
            "summary": "Example market order book depth with aggregated price levels. optional aggregationlevel parameter (1, 2, 5, 10, 100, or 1000) can be appended to the topic, defaults to 1 if not specified. message",
            "payload": {
              "topic": "depth:0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890:1",
              "market": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
              "bids": [
                {
                  "price": 50000,
                  "size": 10.5
                },
                {
                  "price": 49950,
                  "size": 15.2
                },
                {
                  "price": 49900,
                  "size": 20
                }
              ],
              "asks": [
                {
                  "price": 50050,
                  "size": 8.3
                },
                {
                  "price": 50100,
                  "size": 12.7
                },
                {
                  "price": 50150,
                  "size": 18.5
                }
              ],
              "unix_ms": 1699564800000,
              "best_bid": 50000,
              "best_ask": 50050
            }
          }
        ]
      },
      "OrderUpdateMessage": {
        "description": "Order update for a specific user",
        "payload": {
          "$ref": "#/components/schemas/OrderUpdateResponse"
        },
        "examples": [
          {
            "name": "Example",
            "summary": "Example order update for a specific user message",
            "payload": {
              "topic": "order_updates:0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
              "order": {
                "status": "Filled",
                "details": "",
                "order": {
                  "parent": "0x0000000000000000000000000000000000000000000000000000000000000000",
                  "market": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
                  "client_order_id": "historical_order_456",
                  "order_id": "45679",
                  "status": "Filled",
                  "order_type": "Market",
                  "trigger_condition": "None",
                  "order_direction": "Close Short",
                  "orig_size": 2,
                  "remaining_size": 0,
                  "size_delta": null,
                  "price": 49500,
                  "is_buy": false,
                  "is_reduce_only": false,
                  "details": "",
                  "is_tpsl": false,
                  "tp_trigger_price": null,
                  "tp_limit_price": null,
                  "sl_trigger_price": null,
                  "sl_limit_price": null,
                  "cancellation_reason": "",
                  "transaction_version": 12345680,
                  "unix_ms": 1699565000000
                }
              }
            }
          }
        ]
      },
      "UserTradesMessage": {
        "description": "User's trades",
        "payload": {
          "$ref": "#/components/schemas/UserTradesResponse"
        },
        "examples": [
          {
            "name": "Example",
            "summary": "Example user's trades message",
            "payload": {
              "topic": "user_trades:0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
              "trades": [
                {
                  "account": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
                  "market": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
                  "action": "Open Long",
                  "source": "OrderFill",
                  "trade_id": "3647276",
                  "size": 1.5,
                  "price": 50125.75,
                  "is_profit": true,
                  "realized_pnl_amount": 187.5,
                  "realized_funding_amount": -12.3,
                  "is_rebate": true,
                  "fee_amount": 25.06,
                  "order_id": "45678",
                  "client_order_id": "order_123",
                  "transaction_unix_ms": 1699564800000,
                  "transaction_version": 3647276285
                }
              ]
            }
          }
        ]
      },
      "UserActiveTwapsMessage": {
        "description": "User's active TWAP (Time-Weighted Average Price) orders",
        "payload": {
          "$ref": "#/components/schemas/UserActiveTwapsResponse"
        },
        "examples": [
          {
            "name": "Example",
            "summary": "Example user's active twap (time-weighted average price) orders message",
            "payload": {
              "topic": "user_active_twaps:0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
              "twaps": [
                {
                  "market": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
                  "is_buy": true,
                  "order_id": "78901",
                  "is_reduce_only": false,
                  "start_unix_ms": 1699564800000,
                  "frequency_s": 300,
                  "duration_s": 3600,
                  "orig_size": 100,
                  "remaining_size": 75,
                  "status": "Open",
                  "client_order_id": "client_order_123",
                  "transaction_unix_ms": 1699564800000,
                  "transaction_version": 12345679
                }
              ]
            }
          }
        ]
      },
      "AccountPositionsMessage": {
        "description": "Account's open positions with PnL and liquidation prices",
        "payload": {
          "$ref": "#/components/schemas/AccountPositionsResponse"
        },
        "examples": [
          {
            "name": "Example",
            "summary": "Example account's open positions with pnl and liquidation prices message",
            "payload": {
              "topic": "account_positions:0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
              "positions": [
                {
                  "market": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
                  "user": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
                  "size": 2.5,
                  "user_leverage": 10,
                  "entry_price": 49800,
                  "is_isolated": false,
                  "is_deleted": false,
                  "unrealized_funding": -25.5,
                  "estimated_liquidation_price": 45000,
                  "transaction_version": 12345681,
                  "tp_order_id": "tp_001",
                  "tp_trigger_price": 52000,
                  "tp_limit_price": 51900,
                  "sl_order_id": "sl_001",
                  "sl_trigger_price": 48000,
                  "sl_limit_price": null,
                  "has_fixed_sized_tpsls": false
                }
              ]
            }
          }
        ]
      }
    },
    "schemas": {
      "WithdrawQueueEntryDto": {
        "type": "object",
        "description": "A single withdrawal queue event (Queued, Processed, or Cancelled).\n\nThe underlying table is an append-log: each state transition is a separate row keyed\nby `event_uid`. Unfiltered queries may return multiple rows for the same `request_id`\n(e.g., a Queued row and a Processed row). Clients should deduplicate by `request_id`,\nkeeping the terminal state (Processed or Cancelled) over Queued.",
        "required": [
          "user",
          "fungible_amount",
          "processed_amount",
          "request_id",
          "status",
          "timestamp_ms",
          "transaction_version"
        ],
        "properties": {
          "cancel_reason": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/WithdrawCancelReason",
                "description": "Reason the withdrawal was cancelled. Only present for Cancelled entries."
              }
            ]
          },
          "fungible_amount": {
            "type": "number",
            "format": "double",
            "description": "Requested withdrawal amount, normalized by collateral decimals."
          },
          "market": {
            "type": [
              "string",
              "null"
            ],
            "description": "The market address. Absent for non-market (cross-margin) withdrawals."
          },
          "processed_amount": {
            "type": "number",
            "format": "double",
            "description": "Amount actually withdrawn. Equals `fungible_amount` for Processed entries, 0 otherwise."
          },
          "queued_at_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Timestamp when the withdrawal was originally queued. Always present for Queued\nentries. For Processed/Cancelled entries, enriched from the corresponding Queued\nrow. HTTP responses enrich via same-page lookup + DB backfill; WebSocket updates\nonly enrich from the same batch, so this may be absent."
          },
          "recipient": {
            "type": [
              "string",
              "null"
            ],
            "description": "The intended recipient address. The on-chain CancelledEvent omits this field,\nso it is enriched from the corresponding Queued row. HTTP responses enrich via\nsame-page lookup + DB backfill; WebSocket updates only enrich from the same batch."
          },
          "request_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/WithdrawQueueStatus"
          },
          "timestamp_ms": {
            "type": "integer",
            "format": "int64",
            "description": "Timestamp of this specific event. For Processed entries this is the settlement\ntime; for Cancelled entries the cancellation time. See `queued_at_ms` for the\noriginal queue time."
          },
          "transaction_version": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "user": {
            "type": "string"
          }
        }
      },
      "OrderUpdateResponse": {
        "type": "object",
        "required": [
          "topic",
          "order"
        ],
        "properties": {
          "order": {
            "$ref": "#/components/schemas/OrderUpdate"
          },
          "topic": {
            "type": "string"
          }
        }
      },
      "PriceDto": {
        "type": "object",
        "required": [
          "market",
          "oracle_px",
          "mark_px",
          "mid_px",
          "funding_rate_bps",
          "is_funding_positive",
          "funding_period_s",
          "transaction_unix_ms",
          "open_interest"
        ],
        "properties": {
          "funding_period_s": {
            "type": "integer",
            "format": "int64",
            "description": "Funding period duration in seconds. 0 = continuous funding, >0 = periodic funding.",
            "minimum": 0
          },
          "funding_rate_bps": {
            "type": "number",
            "format": "double",
            "description": "Hourly funding rate in basis points (1 bps = 0.01%).\nOn-chain value uses RATE_SIZE_MULTIPLIER (1,000,000); divided by 100.0\nto convert to basis points while preserving sub-bps precision."
          },
          "is_funding_positive": {
            "type": "boolean"
          },
          "mark_px": {
            "type": "number",
            "format": "double"
          },
          "market": {
            "type": "string",
            "example": "0xmarket123..."
          },
          "mid_px": {
            "type": "number",
            "format": "double"
          },
          "open_interest": {
            "type": "number",
            "format": "double"
          },
          "oracle_px": {
            "type": "number",
            "format": "double"
          },
          "transaction_unix_ms": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "AccountOverviewResponse": {
        "type": "object",
        "required": [
          "topic",
          "account_overview"
        ],
        "properties": {
          "account_overview": {
            "$ref": "#/components/schemas/AccountOverviewDto"
          },
          "topic": {
            "type": "string"
          }
        }
      },
      "AccountPositionsResponse": {
        "type": "object",
        "required": [
          "topic",
          "positions"
        ],
        "properties": {
          "positions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PositionDto"
            }
          },
          "topic": {
            "type": "string"
          }
        }
      },
      "AccountOverviewDto": {
        "type": "object",
        "required": [
          "perp_equity_balance",
          "perp_equity_haircutted",
          "unrealized_pnl",
          "unrealized_funding_cost",
          "cross_margin_ratio",
          "maintenance_margin",
          "cross_account_leverage_ratio",
          "total_margin",
          "usdc_cross_withdrawable_balance",
          "usdc_isolated_withdrawable_balance",
          "margin_deficit",
          "cross_available_to_trade"
        ],
        "properties": {
          "all_time_return": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "average_cash_position": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "average_leverage": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "cross_account_leverage_ratio": {
            "type": "number",
            "format": "double",
            "example": 40.99
          },
          "cross_account_position": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "cross_available_to_trade": {
            "type": "number",
            "format": "double",
            "description": "Total cross-margin buying power across all collateral assets (USDC + secondary).\nFormula: max(0, raw_free_collateral − order_margin)\n       = max(0, cross_margin + secondary_collateral_value + min(0, uPnL − funding) − initial_margin − order_margin)\nUse this for \"Available to Trade\" display. Unlike usdc_cross_withdrawable_balance\n(which is capped at the USDC balance), this reflects the full buying power including\nDLP and other secondary collateral.",
            "example": 4791.47
          },
          "cross_margin_ratio": {
            "type": "number",
            "format": "double",
            "example": 0.01
          },
          "fee_income": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Non-trade fee income (vault/BLP accounts only).\nProtocol fee distributions recorded as CBH Fee entries but not captured in trade fee_amount.\nRegular users: always null (their CBH fee entries exactly match trade fee amounts).",
            "example": 5386
          },
          "free_vault_equity": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "USDC value of vault shares NOT currently pledged as DLP collateral on this\nsubaccount's perp account (\"free\" shares × NAV). This is the additive\ncomplement to `perp_equity_balance`: summing the two gives the subaccount's\ntotal wealth with no double-count of pledged DLP (which `perp_equity_balance`\nalready covers via `secondary_collateral`).\n\nEquals 0.0 for users who pledge all their vault shares as collateral. The\nfull pre-pledge total is still visible in `vault_equity` for display.\n\nNULL when not yet available (e.g., WebSocket updates before real-time vault tracking).",
            "example": 14.65
          },
          "liquidation_fees_paid": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Total fees paid during margin call liquidations (always positive).\nFee rate is configurable per market (default 0.5%, max 2% of notional).\nThis is already included in realized_pnl but shown separately for transparency.\nNull for accounts that have never been margin called.",
            "example": 45.5
          },
          "liquidation_losses": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Net collateral balance changes from liquidations (vault/BLP accounts only).\nRegular users: always null - their liquidation loss is in realized_pnl via BackStopLiquidation trades.\nVault accounts: positive = margin received from liquidated users (profit),\n                negative = bad debt covered when users were underwater (loss).",
            "example": -500
          },
          "maintenance_margin": {
            "type": "number",
            "format": "double",
            "example": 115.29
          },
          "margin_deficit": {
            "type": "number",
            "format": "double",
            "description": "Cross-margin deficit: 0 when healthy, negative when the account has a margin hole.\nWhen negative, new deposits will partially fill this deficit before becoming\navailable to trade. For example, deficit = -12 means a $185 deposit yields\nonly $173 available (the first $12 fills the hole).\nFormula: min(0, margin_balance - margin_for_free_collateral + min(0, unrealized_pnl - funding) - order_margin)",
            "example": -12.06
          },
          "max_drawdown": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "net_deposits": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Net deposits (total deposits - total withdrawals) in USDC.\nUsed to verify all_time_return: all_time_return = ((equity - net_deposits) / net_deposits) * 100",
            "example": 30277044.96
          },
          "perp_equity_balance": {
            "type": "number",
            "format": "double",
            "description": "Perp equity at FULL NAV — DLP / secondary collateral counted at oracle/computed\nprice WITHOUT the haircut discount. Intended for **display** (\"your total\naccount value\"). Do NOT use this as the equity input to client-side liquidation\nprice estimation; use `perp_equity_haircutted` instead so the estimate matches\nthe on-chain liquidation threshold.",
            "example": 10064.88
          },
          "perp_equity_haircutted": {
            "type": "number",
            "format": "double",
            "description": "Perp equity with the haircut applied to secondary collateral. This is the value\nthe on-chain liquidation engine uses to decide whether to liquidate. The order\nform's pre-trade liquidation-price estimate must consume this (not\n`perp_equity_balance`) to match the positions tab.\n\nDifference from `perp_equity_balance`: `perp_equity_balance - perp_equity_haircutted`\nequals the secondary collateral haircut discount (i.e. `sum(amount × NAV × haircut_bps/10000)`).\nFor accounts with no secondary collateral the two fields are equal.",
            "example": 10054.92
          },
          "pnl_90d": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "realized_pnl": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "example": 1250.5
          },
          "secondary_collateral": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/SecondaryCollateralDto"
            },
            "description": "Secondary (non-USDC) collateral held in cross margin.\nNULL when no secondary collateral exists or oracle data is unavailable."
          },
          "sharpe_ratio": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "total_margin": {
            "type": "number",
            "format": "double",
            "example": 9998.72
          },
          "unrealized_funding_cost": {
            "type": "number",
            "format": "double",
            "example": -87.84
          },
          "unrealized_pnl": {
            "type": "number",
            "format": "double",
            "example": 154
          },
          "usdc_cross_withdrawable_balance": {
            "type": "number",
            "format": "double",
            "example": 9843.79
          },
          "usdc_isolated_withdrawable_balance": {
            "type": "number",
            "format": "double",
            "example": 0
          },
          "vault_equity": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Total USDC value of vault shares attributed to this subaccount (free shares\nin the subaccount's primary store **plus** shares pledged as DLP collateral\non its perp account). Intended for direct display (\"your total vault position\nis worth $X\") — answers the question \"what do I own in vaults?\".\n\n**Do not add to `perp_equity_balance` to compute total wealth.** The pledged\nportion is already counted in `perp_equity_balance` via `secondary_collateral`,\nso summing the two double-counts pledged DLP. Use `free_vault_equity` (below)\nas the additive complement instead: `perp_equity_balance + free_vault_equity`\ngives total wealth with no overlap.\n\nNULL when not yet available (e.g., WebSocket updates before real-time vault tracking).",
            "example": 259.73
          },
          "volume": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "weekly_win_rate_12w": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          }
        }
      },
      "FundingRateHistory": {
        "type": "object",
        "required": [
          "market",
          "action",
          "size",
          "realized_funding_amount",
          "is_rebate",
          "fee_amount",
          "transaction_unix_ms"
        ],
        "properties": {
          "action": {
            "type": "string",
            "example": "Close Long"
          },
          "fee_amount": {
            "type": "number",
            "format": "double"
          },
          "is_rebate": {
            "type": "boolean"
          },
          "market": {
            "type": "string",
            "example": "0xmarket123..."
          },
          "realized_funding_amount": {
            "type": "number",
            "format": "double",
            "description": "Realized funding amount in USDC\n- Negative value: trader PAID funding (e.g., long position with positive funding rate)\n- Positive value: trader RECEIVED funding (e.g., short position with positive funding rate)\n- Zero: no funding accrued",
            "example": -15.5
          },
          "size": {
            "type": "number",
            "format": "double",
            "example": 1
          },
          "transaction_unix_ms": {
            "type": "integer",
            "format": "int64",
            "example": 1735758000000
          }
        }
      },
      "AccountOpenOrdersResponse": {
        "type": "object",
        "required": [
          "topic",
          "orders"
        ],
        "properties": {
          "orders": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrderDto"
            }
          },
          "topic": {
            "type": "string"
          }
        }
      },
      "SecondaryCollateralDto": {
        "type": "object",
        "description": "Secondary (non-USDC) collateral held in cross margin.",
        "required": [
          "asset_type",
          "amount",
          "value_in_usdc",
          "nav_per_unit",
          "haircut_bps",
          "withdrawable_amount"
        ],
        "properties": {
          "amount": {
            "type": "number",
            "format": "double",
            "description": "Raw balance normalized to human units (balance / 10^decimals).",
            "example": 150
          },
          "asset_type": {
            "type": "string",
            "description": "On-chain asset type address (e.g., DLP fungible asset address).",
            "example": "0x1234..."
          },
          "haircut_bps": {
            "type": "integer",
            "format": "int64",
            "description": "Haircut applied to the oracle price for margin purposes (in basis points).",
            "example": 500,
            "minimum": 0
          },
          "nav_per_unit": {
            "type": "number",
            "format": "double",
            "description": "NAV per unit in USDC terms (oracle price / 10^collateral_decimals).",
            "example": 1.05
          },
          "value_in_usdc": {
            "type": "number",
            "format": "double",
            "description": "USDC-equivalent value after applying the haircut.\nFormula: amount * (nav_per_unit * (10000 - haircut_bps) / 10000).",
            "example": 142.5
          },
          "withdrawable_amount": {
            "type": "number",
            "format": "double",
            "description": "Maximum amount of this secondary asset that can be withdrawn without\nviolating margin requirements.",
            "example": 100
          }
        }
      },
      "BulkOrdersResponse": {
        "type": "object",
        "required": [
          "topic",
          "bulk_order"
        ],
        "properties": {
          "bulk_order": {
            "$ref": "#/components/schemas/BulkOrderStatusResponse"
          },
          "topic": {
            "type": "string"
          }
        }
      },
      "MarketCandlestickResponse": {
        "type": "object",
        "required": [
          "topic",
          "candle"
        ],
        "properties": {
          "candle": {
            "$ref": "#/components/schemas/CandlestickResponseItemDto"
          },
          "topic": {
            "type": "string"
          }
        }
      },
      "BulkOrderStatusResponse": {
        "type": "object",
        "required": [
          "status",
          "details",
          "bulk_order"
        ],
        "properties": {
          "bulk_order": {
            "$ref": "#/components/schemas/BulkOrderDto"
          },
          "details": {
            "type": "string"
          },
          "status": {
            "type": "string"
          }
        }
      },
      "NotificationType": {
        "type": "string",
        "enum": [
          "MarketOrderPlaced",
          "LimitOrderPlaced",
          "StopMarketOrderPlaced",
          "StopMarketOrderTriggered",
          "StopLimitOrderPlaced",
          "StopLimitOrderTriggered",
          "OrderPartiallyFilled",
          "OrderFilled",
          "OrderSizeReduced",
          "OrderCancelled",
          "OrderRejected",
          "OrderErrored",
          "TwapOrderPlaced",
          "TwapOrderTriggered",
          "TwapOrderCompleted",
          "TwapOrderCancelled",
          "TwapOrderErrored",
          "AccountDeposit",
          "AccountWithdrawal",
          "TpSlSet",
          "TpHit",
          "SlHit",
          "TpCancelled",
          "SlCancelled"
        ]
      },
      "SubscribeResponse": {
        "type": "object",
        "required": [
          "success",
          "message"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the subscription was successful"
          },
          "message": {
            "type": "string",
            "description": "Human-readable message about the subscription result"
          }
        }
      },
      "NotificationDto": {
        "type": "object",
        "required": [
          "account",
          "notification_type"
        ],
        "properties": {
          "account": {
            "type": "string"
          },
          "notification_metadata": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/NotificationMetadata"
              }
            ]
          },
          "notification_type": {
            "$ref": "#/components/schemas/NotificationType"
          },
          "order": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/OrderDto"
              }
            ]
          },
          "twap": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/TwapDto"
              }
            ]
          }
        }
      },
      "Unsubscribe": {
        "type": "object",
        "required": [
          "topic"
        ],
        "properties": {
          "topic": {
            "type": "string",
            "description": "The topic to unsubscribe from"
          }
        }
      },
      "PositionDto": {
        "type": "object",
        "required": [
          "market",
          "user",
          "size",
          "user_leverage",
          "entry_price",
          "is_isolated",
          "is_deleted",
          "unrealized_funding",
          "estimated_liquidation_price",
          "transaction_version",
          "has_fixed_sized_tpsls"
        ],
        "properties": {
          "entry_price": {
            "type": "number",
            "format": "double"
          },
          "estimated_liquidation_price": {
            "type": "number",
            "format": "double"
          },
          "has_fixed_sized_tpsls": {
            "type": "boolean"
          },
          "is_deleted": {
            "type": "boolean"
          },
          "is_isolated": {
            "type": "boolean"
          },
          "market": {
            "type": "string"
          },
          "size": {
            "type": "number",
            "format": "double"
          },
          "sl_limit_price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "sl_order_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "sl_trigger_price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "tp_limit_price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "tp_order_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "tp_trigger_price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "transaction_version": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "unrealized_funding": {
            "type": "number",
            "format": "double"
          },
          "user": {
            "type": "string"
          },
          "user_leverage": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "UserNotificationResponse": {
        "type": "object",
        "required": [
          "topic",
          "notification"
        ],
        "properties": {
          "notification": {
            "$ref": "#/components/schemas/NotificationDto"
          },
          "topic": {
            "type": "string"
          }
        }
      },
      "BulkOrderDto": {
        "type": "object",
        "required": [
          "market",
          "user",
          "sequence_number",
          "bid_prices",
          "bid_sizes",
          "ask_prices",
          "ask_sizes",
          "cancelled_bid_prices",
          "cancelled_bid_sizes",
          "cancelled_ask_prices",
          "cancelled_ask_sizes",
          "cancellation_reason",
          "transaction_version",
          "transaction_unix_ms",
          "event_uid"
        ],
        "properties": {
          "ask_prices": {
            "type": "array",
            "items": {
              "type": "number",
              "format": "double"
            },
            "example": [
              101,
              102,
              103
            ]
          },
          "ask_sizes": {
            "type": "array",
            "items": {
              "type": "number",
              "format": "double"
            },
            "example": [
              1,
              2,
              3
            ]
          },
          "bid_prices": {
            "type": "array",
            "items": {
              "type": "number",
              "format": "double"
            },
            "example": [
              99,
              98,
              97
            ]
          },
          "bid_sizes": {
            "type": "array",
            "items": {
              "type": "number",
              "format": "double"
            },
            "example": [
              1,
              2,
              3
            ]
          },
          "cancellation_reason": {
            "type": "string"
          },
          "cancelled_ask_prices": {
            "type": "array",
            "items": {
              "type": "number",
              "format": "double"
            },
            "example": []
          },
          "cancelled_ask_sizes": {
            "type": "array",
            "items": {
              "type": "number",
              "format": "double"
            },
            "example": []
          },
          "cancelled_bid_prices": {
            "type": "array",
            "items": {
              "type": "number",
              "format": "double"
            },
            "example": [
              100
            ]
          },
          "cancelled_bid_sizes": {
            "type": "array",
            "items": {
              "type": "number",
              "format": "double"
            },
            "example": [
              1
            ]
          },
          "event_uid": {
            "$ref": "#/components/schemas/u128"
          },
          "market": {
            "type": "string",
            "example": "0xmarket123..."
          },
          "previous_seq_num": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "example": 12344,
            "minimum": 0
          },
          "sequence_number": {
            "type": "integer",
            "format": "int64",
            "example": 12345,
            "minimum": 0
          },
          "transaction_unix_ms": {
            "type": "integer",
            "format": "int64",
            "example": 1730841600000
          },
          "transaction_version": {
            "type": "integer",
            "format": "int64",
            "example": 12345,
            "minimum": 0
          },
          "user": {
            "type": "string",
            "example": "0x123..."
          }
        }
      },
      "WithdrawQueueStatus": {
        "type": "string",
        "enum": [
          "Queued",
          "Processed",
          "Cancelled"
        ]
      },
      "BulkOrderFillDto": {
        "type": "object",
        "required": [
          "market",
          "sequence_number",
          "user",
          "filled_size",
          "price",
          "is_bid",
          "trade_id",
          "transaction_unix_ms",
          "transaction_version",
          "event_uid"
        ],
        "properties": {
          "event_uid": {
            "$ref": "#/components/schemas/u128"
          },
          "filled_size": {
            "type": "number",
            "format": "double"
          },
          "is_bid": {
            "type": "boolean"
          },
          "market": {
            "type": "string",
            "example": "0xmarket123..."
          },
          "price": {
            "type": "number",
            "format": "double"
          },
          "sequence_number": {
            "type": "integer",
            "format": "int64",
            "example": 12345,
            "minimum": 0
          },
          "trade_id": {
            "type": "string",
            "example": "3647276"
          },
          "transaction_unix_ms": {
            "type": "integer",
            "format": "int64",
            "example": 1730841600000
          },
          "transaction_version": {
            "type": "integer",
            "format": "int64",
            "example": 12345,
            "minimum": 0
          },
          "user": {
            "type": "string",
            "example": "0x123..."
          }
        }
      },
      "BulkOrderFillsResponse": {
        "type": "object",
        "required": [
          "topic",
          "bulk_order_fills"
        ],
        "properties": {
          "bulk_order_fills": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BulkOrderFillDto"
            }
          },
          "topic": {
            "type": "string"
          }
        }
      },
      "TradeDto": {
        "type": "object",
        "required": [
          "account",
          "market",
          "action",
          "source",
          "trade_id",
          "size",
          "price",
          "is_profit",
          "realized_pnl_amount",
          "realized_funding_amount",
          "is_rebate",
          "fee_amount",
          "order_id",
          "client_order_id",
          "transaction_unix_ms",
          "transaction_version"
        ],
        "properties": {
          "account": {
            "type": "string",
            "description": "User's account address",
            "example": "0x1234567890abcdef1234567890abcdef12345678"
          },
          "action": {
            "type": "string",
            "description": "Trade action type (e.g., \"buy\", \"sell\", \"liquidation\")",
            "example": "buy"
          },
          "client_order_id": {
            "type": "string",
            "description": "Client-specified order ID",
            "example": "client_order_abc"
          },
          "fee_amount": {
            "type": "number",
            "format": "double",
            "description": "Fee amount in raw units"
          },
          "is_profit": {
            "type": "boolean",
            "description": "Whether trade was profitable"
          },
          "is_rebate": {
            "type": "boolean",
            "description": "Whether trade received rebate"
          },
          "market": {
            "type": "string",
            "description": "Market identifier address",
            "example": "0xmarket123456789abcdef"
          },
          "order_id": {
            "type": "string",
            "description": "Order ID associated with trade",
            "example": "12345"
          },
          "price": {
            "type": "number",
            "format": "double",
            "description": "Trade price",
            "example": 50000.25
          },
          "realized_funding_amount": {
            "type": "number",
            "format": "double",
            "description": "Realized funding amount in USDC\n- Negative value: trader PAID funding (e.g., long position with positive funding rate)\n- Positive value: trader RECEIVED funding (e.g., short position with positive funding rate)\n- Zero: no funding accrued",
            "example": -15.5
          },
          "realized_pnl_amount": {
            "type": "number",
            "format": "double",
            "description": "Realized PnL amount"
          },
          "size": {
            "type": "number",
            "format": "double",
            "description": "Trade size",
            "example": 100.5
          },
          "source": {
            "type": "string",
            "description": "Trade source (e.g., \"OrderFill\", \"MarginCall\", \"BackStopLiquidation\", \"ADL\", \"MarketDelisted\")",
            "example": "OrderFill"
          },
          "trade_id": {
            "type": "string",
            "description": "Trade ID",
            "example": "3647276"
          },
          "transaction_unix_ms": {
            "type": "integer",
            "format": "int64",
            "description": "Transaction timestamp in milliseconds",
            "example": 1634567890000
          },
          "transaction_version": {
            "type": "integer",
            "format": "int64",
            "description": "Transaction version",
            "example": 3647276285,
            "minimum": 0
          }
        }
      },
      "CandlestickResponseItemDto": {
        "type": "object",
        "required": [
          "t",
          "T",
          "o",
          "h",
          "l",
          "c",
          "v",
          "i"
        ],
        "properties": {
          "T": {
            "type": "integer",
            "format": "int64",
            "example": 1761591599999
          },
          "c": {
            "type": "number",
            "format": "double",
            "example": 100
          },
          "h": {
            "type": "number",
            "format": "double",
            "example": 102
          },
          "i": {
            "type": "string",
            "example": "1h"
          },
          "l": {
            "type": "number",
            "format": "double",
            "example": 98
          },
          "o": {
            "type": "number",
            "format": "double",
            "example": 100
          },
          "t": {
            "type": "integer",
            "format": "int64",
            "example": 1761588000000
          },
          "v": {
            "type": "number",
            "format": "double",
            "example": 1000
          }
        }
      },
      "Subscribe": {
        "type": "object",
        "required": [
          "topic"
        ],
        "properties": {
          "topic": {
            "type": "string",
            "description": "The topic to subscribe to (e.g., 'account_open_orders:0x123...', 'all_market_prices')"
          }
        }
      },
      "MarketTradesResponse": {
        "type": "object",
        "required": [
          "topic",
          "trades"
        ],
        "properties": {
          "topic": {
            "type": "string"
          },
          "trades": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TradeDto"
            }
          }
        }
      },
      "NotificationMetadata": {
        "type": "object",
        "properties": {
          "amount": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "filled_size": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "trigger_price": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          }
        }
      },
      "AllMarketPricesResponse": {
        "type": "object",
        "required": [
          "topic",
          "prices"
        ],
        "properties": {
          "prices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PriceDto"
            }
          },
          "topic": {
            "type": "string"
          }
        }
      },
      "WithdrawCancelReason": {
        "oneOf": [
          {
            "type": "string",
            "enum": [
              "CancelledByUser"
            ]
          },
          {
            "type": "string",
            "enum": [
              "InsufficientWithdrawableBalance"
            ]
          },
          {
            "type": "string",
            "enum": [
              "DepositCheckFailed"
            ]
          },
          {
            "type": "object",
            "required": [
              "Unknown"
            ],
            "properties": {
              "Unknown": {
                "type": "string"
              }
            }
          }
        ],
        "description": "Cancel reason for a withdrawal request.\n\nSerializes as a flat string for all variants (including Unknown)."
      },
      "UnsubscribeResponse": {
        "type": "object",
        "required": [
          "success",
          "message"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the unsubscription was successful"
          },
          "message": {
            "type": "string",
            "description": "Human-readable message about the unsubscription result"
          }
        }
      },
      "UserTradesResponse": {
        "type": "object",
        "required": [
          "topic",
          "trades"
        ],
        "properties": {
          "topic": {
            "type": "string"
          },
          "trades": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TradeDto"
            }
          }
        }
      },
      "MarketDepthResponse": {
        "type": "object",
        "required": [
          "topic",
          "market",
          "bids",
          "asks",
          "unix_ms"
        ],
        "properties": {
          "asks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NormalizedPriceLevel"
            }
          },
          "best_ask": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "True best ask price (pre-aggregation), useful for accurate spread calculation at higher aggregation levels"
          },
          "best_bid": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "True best bid price (pre-aggregation), useful for accurate spread calculation at higher aggregation levels"
          },
          "bids": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NormalizedPriceLevel"
            }
          },
          "market": {
            "type": "string"
          },
          "topic": {
            "type": "string"
          },
          "unix_ms": {
            "type": "integer",
            "format": "int64",
            "description": "Latest transaction timestamp in milliseconds"
          }
        }
      },
      "NormalizedPriceLevel": {
        "type": "object",
        "required": [
          "price",
          "size"
        ],
        "properties": {
          "price": {
            "type": "number",
            "format": "double"
          },
          "size": {
            "type": "number",
            "format": "double"
          }
        }
      },
      "WithdrawQueueUpdateResponse": {
        "type": "object",
        "description": "Real-time withdrawal queue update pushed over WebSocket.\n\nAll messages are **incremental deltas**, not full snapshots (the topic is\n`STREAMING_ONLY`). Consumers must merge entries by `request_id`, keeping\nthe row with the highest `transaction_version`.\n\nBecause the WS path does not perform DB backfill, `recipient` and\n`queued_at_ms` may be `None` on terminal events (`Processed`/`Cancelled`)\nwhen the corresponding `Queued` event arrived in a prior batch. Use the\nHTTP `GET /api/v1/withdraw_queue` endpoint for fully-enriched data.",
        "required": [
          "topic",
          "entries"
        ],
        "properties": {
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WithdrawQueueEntryDto"
            }
          },
          "topic": {
            "type": "string"
          }
        }
      },
      "OrderDto": {
        "type": "object",
        "required": [
          "parent",
          "market",
          "client_order_id",
          "order_id",
          "status",
          "order_type",
          "trigger_condition",
          "order_direction",
          "is_buy",
          "is_reduce_only",
          "details",
          "is_tpsl",
          "cancellation_reason",
          "transaction_version",
          "unix_ms"
        ],
        "properties": {
          "cancellation_reason": {
            "type": "string"
          },
          "client_order_id": {
            "type": "string"
          },
          "details": {
            "type": "string"
          },
          "is_buy": {
            "type": "boolean"
          },
          "is_reduce_only": {
            "type": "boolean"
          },
          "is_tpsl": {
            "type": "boolean"
          },
          "market": {
            "type": "string"
          },
          "order_direction": {
            "type": "string"
          },
          "order_id": {
            "type": "string"
          },
          "order_type": {
            "type": "string"
          },
          "orig_size": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "parent": {
            "type": "string"
          },
          "price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "remaining_size": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "size_delta": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "sl_limit_price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "sl_trigger_price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "status": {
            "type": "string"
          },
          "tp_limit_price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "tp_trigger_price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "transaction_version": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "trigger_condition": {
            "type": "string"
          },
          "unix_ms": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          }
        }
      },
      "UserActiveTwapsResponse": {
        "type": "object",
        "required": [
          "topic",
          "twaps"
        ],
        "properties": {
          "topic": {
            "type": "string"
          },
          "twaps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TwapDto"
            }
          }
        }
      },
      "OrderUpdate": {
        "type": "object",
        "required": [
          "status",
          "details",
          "order"
        ],
        "properties": {
          "details": {
            "type": "string"
          },
          "order": {
            "$ref": "#/components/schemas/OrderDto"
          },
          "status": {
            "type": "string"
          }
        }
      },
      "TwapDto": {
        "type": "object",
        "required": [
          "market",
          "is_buy",
          "order_id",
          "is_reduce_only",
          "start_unix_ms",
          "frequency_s",
          "duration_s",
          "orig_size",
          "remaining_size",
          "status",
          "client_order_id",
          "transaction_unix_ms",
          "transaction_version"
        ],
        "properties": {
          "client_order_id": {
            "type": "string",
            "example": "client_order_123"
          },
          "duration_s": {
            "type": "integer",
            "format": "int64",
            "example": 300,
            "minimum": 0
          },
          "frequency_s": {
            "type": "integer",
            "format": "int64",
            "example": 30,
            "minimum": 0
          },
          "is_buy": {
            "type": "boolean",
            "example": true
          },
          "is_reduce_only": {
            "type": "boolean"
          },
          "market": {
            "type": "string",
            "example": "0xmarket123..."
          },
          "order_id": {
            "type": "string"
          },
          "orig_size": {
            "type": "number",
            "format": "double"
          },
          "remaining_size": {
            "type": "number",
            "format": "double"
          },
          "start_unix_ms": {
            "type": "integer",
            "format": "int64",
            "example": 1730841600000
          },
          "status": {
            "type": "string"
          },
          "transaction_unix_ms": {
            "type": "integer",
            "format": "int64"
          },
          "transaction_version": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          }
        }
      },
      "u128": {
        "type": "string",
        "description": "128-bit unsigned integer represented as a string (event unique identifier)",
        "pattern": "^[0-9]+$"
      },
      "MarketPriceResponse": {
        "type": "object",
        "required": [
          "topic",
          "price"
        ],
        "properties": {
          "price": {
            "$ref": "#/components/schemas/PriceDto"
          },
          "topic": {
            "type": "string"
          }
        }
      }
    },
    "parameters": {
      "aggregationLevel": {
        "description": "Price aggregation level for order book depth (1, 2, 5, 10, 100, or 1000)",
        "location": "$message.payload#/topic"
      },
      "userAddr": {
        "description": "User wallet address (Aptos address format, e.g. 0x123...)",
        "location": "$message.payload#/topic"
      },
      "interval": {
        "description": "Candlestick interval (1m, 15m, 1h, 4h, or 1d)",
        "location": "$message.payload#/topic"
      },
      "marketAddr": {
        "description": "Market address (Aptos address format, e.g. 0x456...)",
        "location": "$message.payload#/topic"
      },
      "accountAddr": {
        "description": "Account address (Aptos address format, e.g. 0x123...)",
        "location": "$message.payload#/topic"
      }
    }
  }
}