# Generated by scripts/build_openapi.py from the service specs in this
# directory and shared.yaml. Edit those files, then rerun the script.
openapi: 3.1.0
info:
  title: Fairground.Fi API
  description: |-
    API for perpetual futures trading, built with ConnectRPC.
    Every endpoint is an HTTP POST with a JSON body at `/package.ServiceName/MethodName`.
    Requests authenticate with a bearer API key.
  version: 1.0.0
  contact:
    name: Forte Service Company
    url: https://github.com/Forte-Service-Company-Ltd/perpetuals-api-server
  license:
    name: Proprietary
    identifier: UNLICENSED
servers:
  - url: https://api.fairground.fi
    description: Production API server
security:
  - bearerAuth: []
tags:
  - name: Trades
    description: Wallet trade/fill history
  - name: Markets
    description: Market configuration and summary endpoints
  - name: Orderbook
    description: Orderbook data retrieval
  - name: Orders
    description: Order management operations
  - name: Permissions
    description: API key management operations
  - name: Portfolio
    description: Aggregated per-wallet portfolio data
  - name: Positions
    description: Position management operations
  - name: Prices
    description: Oracle price and historical price data
paths:
  /fill_history_service.v1.FillHistoryService/GetUserFills:
    post:
      tags:
        - Trades
      summary: GetUserFills
      description: |-
        Returns individual trade-history records (fills) for one wallet,
         optionally scoped to a time range. Results are ordered oldest first
         (ascending by block time).

         `limit` defaults to 100 and is capped at 500.
      operationId: fill_history_service.v1.FillHistoryService.GetUserFills
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/fill_history_service.v1.GetUserFillsRequest'
        required: true
      responses:
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/fill_history_service.v1.GetUserFillsResponse'
              example:
                fills:
                  - fillId: "0x-abc123...-2"
                    sequenceId: "48213002"
                    timestamp: "2026-07-11T14:32:07Z"
                    txHash: "0x-abc123..."
                    marketId: "12942289985198375563"
                    market: "BTC-USD"
                    tradeType: "EXECUTION_TYPE_TRADE"
                    side: "SIDE_LONG"
                    owner: "0x71c7656ec7ab88b098defb751b7401b5f6d8976"
                    orderId: "48213"
                    positionId: "48213"
                    reduceOnly: false
                    size: "0.061500"
                    price: "65000.500000"
                    quoteNotional: "3997.780750"
                    fees:
                      amount: "1.80"
                      asset: "USDC"
                    rebates:
                      amount: "0.00"
                      asset: "USDC"
                    positionSizeBefore: "0.000000"
                    positionSizeAfter: "0.061500"

  /market_service.v1.MarketService/GetMarketConfigs:
    post:
      tags:
        - Markets
      summary: GetMarketConfigs
      description: |-
        Returns the full configuration for one market, resolved by numeric
         `market_id` or by `market_symbol`.
      operationId: market_service.v1.MarketService.GetMarketConfigs
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/market_service.v1.GetMarketconfigRequest'
        required: true
      responses:
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/market_service.v1.GetMarketconfigResponse'
              example:
                marketConfig:
                  marketId: "12942289985198375563"
                  marketName: "BTC-USD"
                  minLeverage: 1
                  maxLeverage: 20
                  minTradeSize: 10
                  maxTradeSize: 500000
                  tickDecimals: 1
                  lotSize: 0.0001
                  sizeDecimals: 8
                  creator: "0x71c7656ec7ab88b098defb751b7401b5f6d8976"
                  feeConfig:
                    marketId: "12942289985198375563"
                    tradeFeePct: 45
                    maxEntitlement: 500
                    insuranceFundEntitlementPct: 20
                    maxImbalance: 100000
                  adlConfig:
                    maintenanceMarginRatio: 50
                    seizureThreshold: 66
                    adlThreshold: 10
                    shockFactor: 1
                    maxIfFractionAllowed: 10
                  maintenanceMarginRate: "50"
                  tradeFeePct: 45
                  longRevenue: 1234.5
                  shortRevenue: 987.6

  /market_service.v1.MarketService/GetMarketIdByName:
    post:
      tags:
        - Markets
      summary: GetMarketIdByName
      description: "Returns the numeric `market_id` for a market, looked up by `asset_symbol` and optional
        `quote_symbol` (for example `BTC`). Use it to turn a market name into the id that other endpoints
        accept."
      operationId: market_service.v1.MarketService.GetMarketIdByName
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/market_service.v1.GetMarketIdByNameRequest'
        required: true
      responses:
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/market_service.v1.GetMarketIdByNameResponse'
  /market_service.v2.MarketService/GetMarketSummary:
    post:
      tags:
        - Markets
      summary: GetMarketSummary
      description: |-
        Returns a live trading summary for one market: open interest, 24h
         price change and volume, executable order-book depth at the
         current price, rebate indicators, and whether the market is
         currently open for trading.
         
         If computing executable depth fails internally, the
         request still succeeds with `executableDepth` left at zero rather
         than failing outright.
      operationId: market_service.v2.MarketService.GetMarketSummary
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/market_service.v2.GetMarketSummaryRequest'
        required: true
      responses:
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/market_service.v2.GetMarketSummaryResponse'
              example:
                timestamp: "2026-07-11T14:32:07Z"
                priceTimestamp: "2026-07-11T14:32:06Z"
                marketSummary:
                  marketId: "12942289985198375563"
                  marketName: "BTC-USD"
                  openInterest: 42.75
                  priceChange24h: 2.35
                  volume24h: 8500000
                  executableDepth:
                    short: 120000
                    long: 95000
                    shortDouble: 120000.5
                    longDouble: 95250.25
                  marketType: "crypto"
                  price: 65420.0
                  rebateIndicatorLong: 310.5
                  rebateIndicatorShort: 275.2
                  isOpen: true

  /market_service.v2.MarketService/GetMarkets:
    post:
      tags:
        - Markets
      summary: GetMarkets
      description: |-
        Returns the full configuration for every active market, ordered by
         `market_id` ascending.
      operationId: market_service.v2.MarketService.GetMarkets
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/market_service.v2.GetMarketsRequest'
            example:
              status: "MARKET_STATUS_ACTIVE"
        required: true
      responses:
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/market_service.v2.GetMarketsResponse'
              example:
                timestamp: "2026-07-11T14:32:07Z"
                markets:
                  - marketId: "12942289985198375563"
                    marketName: "BTC-USD"
                    minLeverage: 1
                    maxLeverage: 20
                    minTradeSize: 10
                    maxTradeSize: 500000
                    tickDecimals: 1
                    sizeDecimals: 8
                    creator: "0x71c7656ec7ab88b098defb751b7401b5f6d8976"
                    feeConfig:
                      marketId: "12942289985198375563"
                      tradeFeePct: 45
                      maxEntitlement: 500
                      insuranceFundEntitlementPct: 20
                      maxImbalance: 100000
                    adlConfig:
                      maintenanceMarginRatio: 50
                      seizureThreshold: 66
                      adlThreshold: 10
                      shockFactor: 1
                      maxIfFractionAllowed: 10
                    status: "MARKET_STATUS_ACTIVE"
                    updatedAt: "2026-07-01T12:00:00Z"

  /orderbook_service.v1.OrderBookService/GetOrderBook:
    post:
      tags:
        - Orderbook
      summary: GetOrderBook
      description: |-
        Returns a simulated aggregated order-book depth for one market: bid and ask
        price levels, each bucketed by `tickSize` and sorted toward the best
        price. Resolved by `market_id` or `market_symbol`.
      operationId: orderbook_service.v1.OrderBookService.GetOrderBook
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/orderbook_service.v1.GetOrderBookRequest'
        required: true
      responses:
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/orderbook_service.v1.GetOrderBookResponse'
              example:
                orderBook:
                  marketId: "12942289985198375563"
                  timestamp: "2026-07-11T14:32:07Z"
                  pageSize: 50
                  offset: 0
                  totalOrderCount: 214
                  levels: 10
                  tickSize: 10
                  sizeInUsd: true
                  book:
                    bids:
                      - price: 65400
                        size: 120000
                        orderCount: 6
                        cumulativeTotal: 120000
                      - price: 65390
                        size: 85000
                        orderCount: 4
                        cumulativeTotal: 205000
                    asks:
                      - price: 65430
                        size: 95000
                        orderCount: 5
                        cumulativeTotal: 95000
                      - price: 65440
                        size: 60000
                        orderCount: 3
                        cumulativeTotal: 155000

  /order_service.v1.OrderService/GetOrder:
    post:
      tags:
        - Orders
      summary: GetOrder
      description: |-
        Returns the current stored state of one order, identified by the
         composite key `order_id` + `market` + `reduce_only`. Order IDs are not
         globally unique: the same numeric ID can exist as both a
         position-opening order and a reduce-only order in the same market, so
         `reduce_only` must match the kind of order you're looking up.
      operationId: order_service.v1.OrderService.GetOrder
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/order_service.v1.GetOrderRequest'
        required: true
      responses:
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/order_service.v1.GetOrderResponse'
  /order_service.v1.OrderService/GetOrders:
    post:
      tags:
        - Orders
      summary: GetOrders
      description: |-
        Returns the latest stored state of each order associated with `address`,
         optionally filtered to one market. Results include position-opening and
         reduce-only orders across active and terminal statuses. This endpoint
         does not return order lifecycle events or individual fills.
      operationId: order_service.v1.OrderService.GetOrders
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/order_service.v1.GetOrdersRequest'
        required: true
      responses:
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/order_service.v1.GetOrdersResponse'
  /permissions.v1.PermissionService/DeleteApiKey:
    post:
      tags:
        - Permissions
      summary: DeleteApiKey
      description: "Deletes the API key with the given `id` for `user_address`. Use `ListApiKeys` to find
        the id."
      operationId: permissions.v1.PermissionService.DeleteApiKey
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/permissions.v1.DeleteApiKeyRequest'
        required: true
      responses:
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/permissions.v1.DeleteApiKeyResponse'
  /permissions.v1.PermissionService/GenerateApiKey:
    post:
      tags:
        - Permissions
      summary: GenerateApiKey
      description: "Creates a new API key for `user_address`, with an optional `label`. The key value
        is returned only in this response, so store it securely: `ListApiKeys` returns key ids and labels,
        not key values."
      operationId: permissions.v1.PermissionService.GenerateApiKey
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/permissions.v1.GenerateApiKeyRequest'
        required: true
      responses:
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/permissions.v1.GenerateApiKeyResponse'
  /permissions.v1.PermissionService/ListApiKeys:
    post:
      tags:
        - Permissions
      summary: ListApiKeys
      description: "Lists the API keys for `user_address`: each key's `id`, `label`, and creation time.
        Key values are not returned."
      operationId: permissions.v1.PermissionService.ListApiKeys
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/permissions.v1.ListApiKeysRequest'
        required: true
      responses:
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/permissions.v1.ListApiKeysResponse'
  /portfolio.v1.PortfolioService/GetPortfolio:
    post:
      tags:
        - Portfolio
      summary: GetPortfolio
      description: |-
        Returns an aggregated portfolio snapshot for one wallet: margin,
        PnL, volume, fee, and equity totals, plus the wallet's currently
        open positions and open orders.

        NOTE: `positions` and `orders` are open-only — closed positions and
        terminal-status orders are folded into the aggregate totals but are
        not listed individually here. All totals are recomputed fresh on
        every request (not cached), so this endpoint is heavier than a
        single-position or single-order lookup.
      operationId: portfolio.v1.PortfolioService.GetPortfolio
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/portfolio.v1.GetPortfolioRequest'
        required: true
      responses:
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/portfolio.v1.GetPortfolioResponse'
  /position_service.v1.PositionService/GetOpenPositions:
    post:
      tags:
        - Positions
      summary: GetOpenPositions
      description: |-
        Returns all currently open positions for one wallet, across all
         markets. `address` is required (matched trimmed and
         case-insensitively). Results are ordered by timestamp descending,
         most recent first.

         Unlike the portfolio path, associated orders are loaded as
         lightweight references only — see `associatedOrderIds` on the
         `Position` schema, not `associatedOrders`.
      operationId: position_service.v1.PositionService.GetOpenPositions
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/position_service.v1.GetOpenPositionsRequest'
        required: true
      responses:
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/position_service.v1.GetOpenPositionsResponse'
              example:
                positions:
                  - owner: "0x71c7656ec7ab88b098defb751b7401b5f6d8976"
                    positionId: "48213"
                    marketId: "12942289985198375563"
                    timestamp: "2026-07-11T14:32:07Z"
                    market: "BTC-USD"
                    side: "SIDE_LONG"
                    marginType: "MARGIN_TYPE_ISOLATED"
                    nominalSize: 0.1538
                    entryPrice: 65000.5
                    markPrice: 65420.0
                    liquidationPrice: 54200.0
                    allocatedMargin: 2000
                    leverage: 5
                    unrealizedPnl: 64.6
                    reduceOnly: false
                    associatedOrders: []
                    associatedOrderIds:
                      - orderId: "50501"
                        marketId: "12942289985198375563"
                        reduceOnly: true
                    tickDecimals: 1
                    revenueSpent: 12.5
                    effectiveSize: 0.1538
                    estimatedRebate: 3.2
                    stopLossPrice: 60000
                    takeProfitPrice: 72000

  /price_service.v2.PriceService/GetHistoricalPrices:
    post:
      tags:
        - Prices
      summary: GetHistoricalPrices
      description: "Returns oracle-price OHLC candles for one market from `start_time` (inclusive) to
        `end_time` (exclusive). `interval` sets the candle width and defaults to 1 hour. Supports `limit`/`offset`
        pagination. Only the `market_id` form of the market selector is supported."
      operationId: price_service.v2.PriceService.GetHistoricalPrices
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/price_service.v2.GetHistoricalPricesRequest'
        required: true
      responses:
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/price_service.v2.GetHistoricalPricesResponse'
  /price_service.v2.PriceService/GetPrice:
    post:
      tags:
        - Prices
      summary: GetPrice
      description: "Returns the current oracle price for one market, with its `market_id`, canonical name
        (for example \"BTC-USD\"), and the time the price was printed. Resolved by `market_id` or `market_symbol`."
      operationId: price_service.v2.PriceService.GetPrice
      parameters:
        - name: Connect-Protocol-Version
          in: header
          description: Define the version of the Connect protocol
          schema:
            $ref: '#/components/schemas/connect-protocol-version'
          example: 1
        - name: Connect-Timeout-Ms
          in: header
          description: Define the timeout, in ms
          schema:
            $ref: '#/components/schemas/connect-timeout-header'
          example: 1000
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/price_service.v2.GetPriceRequest'
        required: true
      responses:
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/connect.error'
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/price_service.v2.GetPriceResponse'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    connect-protocol-version:
      type: number
      title: Connect-Protocol-Version
      enum:
        - 1
      description: Define the version of the Connect protocol. If omitted, use 1.
      const: 1
      default: 1
    connect-timeout-header:
      type: number
      examples:
        - 1000
      title: Connect-Timeout-Ms
      description: Define the timeout, in ms
    connect.error:
      type: object
      properties:
        code:
          type: string
          examples:
            - not_found
          enum:
            - canceled
            - unknown
            - invalid_argument
            - deadline_exceeded
            - not_found
            - already_exists
            - permission_denied
            - resource_exhausted
            - failed_precondition
            - aborted
            - out_of_range
            - unimplemented
            - internal
            - unavailable
            - data_loss
            - unauthenticated
          description: The status code, which should be an enum value of 
            [google.rpc.Code][google.rpc.Code].
        message:
          type: string
          description: A developer-facing error message, which should be in English. Any user-facing
            error message should be localized and sent in the 
            [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the 
            client.
        details:
          type: array
          items:
            $ref: '#/components/schemas/connect.error_details.Any'
          description: A list of messages that carry the error details. There is no limit on the 
            number of messages.
      title: Connect Error
      additionalProperties: true
      description: 'Error type returned by Connect: https://connectrpc.com/docs/go/errors/#http-representation'
    connect.error_details.Any:
      type: object
      properties:
        type:
          type: string
          description: 'A URL that acts as a globally unique identifier for the type of the serialized
            message. For example: `type.googleapis.com/google.rpc.ErrorInfo`.'
        value:
          type: string
          format: byte
          description: The Protobuf message, serialized as bytes and base64-encoded. The specific 
            message type is identified by the `type` field.
        debug:
          type: object
          title: Debug
          additionalProperties: true
          description: Deserialized error detail payload. The 'type' field indicates the schema. 
            This field is for easier debugging and should not be relied upon for application logic.
      additionalProperties: true
      description: Contains an arbitrary serialized message along with a @type that describes the 
        type of the serialized message, with an additional debug field for ConnectRPC error details.
    google.protobuf.Timestamp:
      type: string
      examples:
        - "2023-01-15T01:30:15.01Z"
        - "2024-12-25T12:00:00Z"
      format: date-time
    base_objects.v1.MarginType:
      type: string
      title: MarginType
      enum:
        - MARGIN_TYPE_ISOLATED
    base_objects.v1.MarketSelector:
      type: object
      oneOf:
        - type: object
          properties:
            marketId:
              type: string
              format: int64
              title: market_id
          title: market_id
          required:
            - marketId
        - type: object
          properties:
            marketSymbol:
              "$ref": "#/components/schemas/base_objects.v1.MarketSymbol"
              title: market_symbol
          title: market_symbol
          required:
            - marketSymbol
      title: MarketSelector
      additionalProperties: false
    base_objects.v1.MarketSymbol:
      type: object
      properties:
        assetSymbol:
          type: string
          title: asset_symbol
        quoteSymbol:
          type: string
          title: quote_symbol
      title: MarketSymbol
      additionalProperties: false
    base_objects.v1.Order:
      type: object
      properties:
        owner:
          type: string
          title: owner
          description: trader address
          example: "0xAbcd1234...."
        orderId:
          type: string
          title: order_id
          format: int64
          description: uint40 on-chain, using uint64 to safely accommodate full range
          example: "85"
        timestamp:
          title: timestamp
          "$ref": "#/components/schemas/google.protobuf.Timestamp"
          example: "2026-08-24T16:21:01.188705915Z"
        marketId:
          type: string
          title: market_id
          format: int64
          description: uint16 on-chain, using uint32 for protobuf compatibility
          example: "12942289985198375563"
        market:
          type: string
          title: market
          example: "BTC-USD"
        type:
          title: type
          "$ref": "#/components/schemas/base_objects.v1.OrderType"
          example: "ORDER_TYPE_MARKET"
        side:
          title: side
          "$ref": "#/components/schemas/base_objects.v1.Side"
          example: "SIDE_LONG"
        thresholdPrice:
          type: number
          title: threshold_price
          format: float
          description: priceThreshold from event, needs tick_decimals for conversion
          example: 79716.71
        size:
          type: number
          title: size
          format: float
          description: 'Calculated: initialMargin * leverage, or from fill events'
          example: 995.52015
        leverage:
          type: number
          title: leverage
          format: float
          description: |-
            TimeInForce timeInForce CURRENTLY UNSUPPORTED
             string orderExpiration CURRENTLY UNSUPPORTED
          example: 10
        status:
          title: status
          "$ref": "#/components/schemas/base_objects.v1.OrderStatus"
          example: "ORDER_STATUS_FULLY_FILLED"
        filledSize:
          type: number
          title: filled_size
          format: float
          description: From fill events
          example: 995.52015
        unfilledSize:
          type: number
          title: unfilled_size
          format: float
          description: From partial fill events
          example: 0
        reduceOnly:
          type: boolean
          title: reduce_only
          example: false
        canceled:
          type: boolean
          title: canceled
        initialMargin:
          type: number
          title: initial_margin
          format: float
          description: initialMargin from OpenOrderSubmitted event (uint56 on-chain, in collateral 
            token units)
        tickDecimals:
          type: integer
          title: tick_decimals
          description: uint8 on-chain - critical for price conversion
        fees:
          type: number
          title: fees
          format: float
          example: 0.311272
        rebates:
          type: number
          title: rebates
          format: float
          example: 0
      title: Order
      additionalProperties: false
    base_objects.v1.OrderStatus:
      type: string
      title: OrderStatus
      enum:
        - ORDER_STATUS_PENDING
        - ORDER_STATUS_PARTIALLY_FILLED
        - ORDER_STATUS_FULLY_FILLED
        - ORDER_STATUS_CLOSED
        - ORDER_STATUS_CANCELLED
        - ORDER_STATUS_MERGED
        - ORDER_STATUS_PARTIALLY_MERGED
    base_objects.v1.OrderType:
      type: string
      title: OrderType
      enum:
        - ORDER_TYPE_MARKET
    base_objects.v1.Position:
      type: object
      properties:
        owner:
          type: string
          title: owner
          description: trader address
          example: "0xAbcd1234...."
        positionId:
          type: string
          title: position_id
          format: int64
          description: uint40 on-chain (same as opening orderId), using uint64 to safely accommodate
            full range
          example: "85"
        marketId:
          type: string
          title: market_id
          format: int64
          description: uint16 on-chain, using uint32 for protobuf compatibility
          example: "12942289985198375563"
        timestamp:
          title: timestamp
          "$ref": "#/components/schemas/google.protobuf.Timestamp"
          example: "2026-08-24T15:49:13Z"
        market:
          type: string
          title: market
          example: "BTC-USD"
        side:
          title: side
          description: isLong from events
          "$ref": "#/components/schemas/base_objects.v1.Side"
          example: "SIDE_LONG"
        marginType:
          title: margin_type
          description: All positions are isolated on-chain currently
          "$ref": "#/components/schemas/base_objects.v1.MarginType"
          example: "MARGIN_TYPE_ISOLATED"
        nominalSize:
          type: number
          title: nominalSize
          format: float
          description: uint56 on-chain
          example: 0.01255516
        entryPrice:
          type: number
          title: entry_price
          format: float
          description: uint32 on-chain, needs tick_decimals for conversion
          example: 79287.34
        markPrice:
          type: number
          title: mark_price
          format: float
          description: Dynamic - not from events
          example: 79023.94
        liquidationPrice:
          type: number
          title: liquidation_price
          format: float
          description: uint32 on-chain, needs tick_decimals for conversion
          example: 73192.328047563
        allocatedMargin:
          type: number
          title: allocated_margin
          format: float
          description: initialMargin from PositionOpened event (uint48 on-chain)
          example: 99.497385
        leverage:
          type: number
          title: leverage
          format: float
          description: uint16 on-chain
          example: 10
        unrealizedPnl:
          type: number
          title: unrealized_pnl
          format: float
          description: Dynamic - calculated off-chain
          example: 65.80959585600007
        reduceOnly:
          type: boolean
          title: reduce_only
          description: from PositionOpened/Updated events
          example: false
        associatedOrders:
          type: array
          items:
            "$ref": "#/components/schemas/base_objects.v1.Order"
          title: associated_orders
        tickDecimals:
          type: integer
          title: tick_decimals
          description: uint8 on-chain - critical for price conversion
          example: 2
        revenueSpent:
          type: number
          title: revenue_spent
          format: float
          description: the total revenue per position will be market_revenue - revenue_spent at 
            position closing time
          example: 5.2866936
        effectiveSize:
          type: number
          title: effectiveSize
          format: float
          description: between 0 and 1e18. The effective size of the position will be position.size 
            * (position.adl_scale_factor / market.adl_scale_factor)
          example: 0.01255516
      title: Position
      additionalProperties: false
    base_objects.v1.Side:
      type: string
      title: Side
      enum:
        - SIDE_LONG
        - SIDE_SHORT
    base_objects.v1.AssetAmount:
      type: object
      properties:
        amount:
          type: string
          title: amount
          description: Decimal string
        asset:
          type: string
          title: asset
          description: Asset symbol or asset id
      title: AssetAmount
      additionalProperties: false
      description: Amount + asset pair for fees / rebates.
    base_objects.v1.ExecutionType:
      type: string
      title: ExecutionType
      enum:
        - EXECUTION_TYPE_UNSPECIFIED
        - EXECUTION_TYPE_TRADE
        - EXECUTION_TYPE_LIQUIDATION
        - EXECUTION_TYPE_ADL
      description: Type of execution for the trade record.
    base_objects.v1.FillInstance:
      type: object
      properties:
        fillId:
          type: string
          title: fill_id
          description: 'Required: deterministic unique id'
        sequenceId:
          type: string
          title: sequence_id
          format: int64
          description: 'Required: deterministic ordering key'
        timestamp:
          allOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: timestamp
          description: 'Required: unix timestamp'
        txHash:
          type: string
          title: tx_hash
          description: Required
        marketId:
          type: string
          title: market_id
          format: int64
          description: Required
        market:
          type: string
          title: market
          description: Required human-readable symbol/name
        tradeType:
          allOf:
            - $ref: '#/components/schemas/base_objects.v1.ExecutionType'
          title: trade_type
          description: Required
        side:
          allOf:
            - $ref: '#/components/schemas/base_objects.v1.Side'
          title: side
        owner:
          type: string
          title: owner
        orderId:
          type: string
          title: order_id
          format: int64
        positionId:
          type: string
          title: position_id
          format: int64
        reduceOnly:
          type: boolean
          title: reduce_only
        size:
          type: string
          title: size
          description: Required decimal string
        price:
          type: string
          title: price
          description: Required decimal string
        quoteNotional:
          type: string
          title: quote_notional
          description: Required decimal string
        fees:
          oneOf:
            - $ref: '#/components/schemas/base_objects.v1.AssetAmount'
            - type: "null"
          title: fees
          description: Optional
        rebates:
          oneOf:
            - $ref: '#/components/schemas/base_objects.v1.AssetAmount'
            - type: "null"
          title: rebates
          description: Optional
        positionSizeBefore:
          type: string
          title: position_size_before
          description: Optional, signed decimal string
        positionSizeAfter:
          type: string
          title: position_size_after
          description: Optional, signed decimal string
      title: FillInstance
      additionalProperties: false
      description: Main trade history record.
    fill_history_service.v1.GetUserFillsRequest:
      type: object
      properties:
        address:
          type:
            - string
            - "null"
          title: address
        startTime:
          oneOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
            - type: "null"
          title: start_time
          description: Optional inclusive lower bound on fill time. Omit to start from the earliest 
            fill.
        endTime:
          oneOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
            - type: "null"
          title: end_time
          description: Optional exclusive upper bound on fill time. Omit to include up to the most 
            recent fill.
        limit:
          type:
            - integer
            - "null"
          title: limit
          description: Pagination params
        offset:
          type:
            - integer
            - "null"
          title: offset
        chainId:
          type:
            - string
            - "null"
          title: chain_id
          format: int64
          description: "Optional chain identifier for the market. During testnet, Fairground runs on Arbitrum
            Sepolia (`421614`)."
      title: GetUserFillsRequest
      required:
        - address
      additionalProperties: false
    fill_history_service.v1.GetUserFillsResponse:
      type: object
      properties:
        fills:
          type: array
          items:
            $ref: '#/components/schemas/base_objects.v1.FillInstance'
          title: fills
      title: GetUserFillsResponse
      additionalProperties: false
    base_objects.v1.ADLConfig:
      type: object
      properties:
        maintenanceMarginRatio:
          type: number
          title: maintenance_margin_ratio
          format: float
          description: value between 0 and 1
        seizureThreshold:
          type: number
          title: seizure_threshold
          format: float
          description: value between 0 and 1
        adlThreshold:
          type: number
          title: adl_threshold
          format: float
          description: value between 0 and 1
        shockFactor:
          type: number
          title: shock_factor
          format: float
          description: value between 0 and 1
        maxIfFractionAllowed:
          type: number
          title: max_if_fraction_allowed
          format: float
          description: value between 0 and 1
      title: ADLConfig
      additionalProperties: false
    base_objects.v1.ExecutableDepth:
      type: object
      properties:
        short:
          type: number
          title: short
          format: double
        long:
          type: number
          title: long
          format: double
      title: ExecutableDepth
      additionalProperties: false
    base_objects.v1.FeeConfig:
      type: object
      properties:
        marketId:
          type: string
          title: market_id
          format: int64
          description: uint16 on-chain, using uint64 for protobuf compatibility
        tradeFeePct:
          type: number
          title: tradeFeePct
          format: float
          description: percentage with 3 decimals, 5 = 0.005%; 5000 = 5%. Max bound is 65.535%
        maxEntitlement:
          type: number
          title: maxEntitlement
          format: float
          description: percentage with 2 decimals, 5 = 0.05%; 500 = 5%
        insuranceFundEntitlementPct:
          type: number
          title: insuranceFundEntitlementPct
          format: float
          description: percentage with 2 decimals, 5 = 0.05%; 500 = 5%
        maxImbalance:
          type: number
          title: maxImbalance
          format: float
          description: in USD with collateral
      title: FeeConfig
      additionalProperties: false
    base_objects.v1.MarketConfig:
      type: object
      properties:
        marketId:
          type: string
          title: market_id
          format: int64
          description: uint16 on-chain, using uint32 for protobuf compatibility
        marketName:
          type: string
          title: market_name
          description: bytes32 on-chain, converted to string
        minLeverage:
          type: number
          title: min_leverage
          format: float
          description: uint16 on-chain
        maxLeverage:
          type: number
          title: max_leverage
          format: float
          description: uint16 on-chain
        minTradeSize:
          type: number
          title: min_trade_size
          format: float
          description: uint48 on-chain, in USD Units
        maxTradeSize:
          type: number
          title: max_trade_size
          format: float
          description: uint48 on-chain, in USD Units
        tickDecimals:
          type: integer
          title: tick_decimals
          description: uint8 on-chain - replaces tick_exponent, critical for price conversion
        lotSize:
          type: number
          title: lot_size
          format: float
          description: uint24 on-chain
        sizeDecimals:
          type: integer
          title: size_decimals
          description: uint8 on-chain - critical for position size conversion
        creator:
          type: string
          title: creator
          description: address of market creator
        feeConfig:
          title: fee_config
          "$ref": "#/components/schemas/base_objects.v1.FeeConfig"
        adlConfig:
          title: adl_config
          "$ref": "#/components/schemas/base_objects.v1.ADLConfig"
        tradeFeePct:
          type:
            - integer
            - 'null'
          title: trade_fee_pct
        longRevenue:
          type:
            - number
            - 'null'
          title: long_revenue
          format: float
        shortRevenue:
          type:
            - number
            - 'null'
          title: short_revenue
          format: float
      title: MarketConfig
      additionalProperties: false
    base_objects.v1.MarketSummary:
      type: object
      properties:
        marketId:
          type: string
          title: market_id
          format: int64
        marketName:
          type: string
          title: market_name
        openInterest:
          type: number
          title: open_interest
          format: float
          description: in underlying asset units
        priceChange24h:
          type: number
          title: price_change_24h
          format: float
          description: in percentage
        volume24h:
          type: number
          title: volume_24h
          format: float
          description: in USD Units
        executableDepth:
          title: executable_depth
          "$ref": "#/components/schemas/base_objects.v1.ExecutableDepth"
      title: MarketSummary
      additionalProperties: false
    market_service.v1.GetMarketIdByNameRequest:
      type: object
      properties:
        assetSymbol:
          type: string
          title: asset_symbol
        quoteSymbol:
          type:
            - string
            - "null"
          title: quote_symbol
        chainId:
          type:
            - string
            - "null"
          title: chain_id
          format: int64
          description: "Optional chain identifier for the market. During testnet, Fairground runs on Arbitrum
            Sepolia (`421614`)."
      title: GetMarketIdByNameRequest
      additionalProperties: false
    market_service.v1.GetMarketIdByNameResponse:
      type: object
      properties:
        marketId:
          type: string
          title: market_id
          format: int64
      title: GetMarketIdByNameResponse
      additionalProperties: false
    market_service.v1.GetMarketconfigRequest:
      type: object
      properties:
        market:
          allOf:
            - $ref: '#/components/schemas/base_objects.v1.MarketSelector'
          title: market
        chainId:
          type:
            - string
            - "null"
          title: chain_id
          format: int64
          description: "Optional chain identifier for the market. During testnet, Fairground runs on Arbitrum
            Sepolia (`421614`)."
      title: GetMarketconfigRequest
      required:
        - market
      additionalProperties: false
    market_service.v1.GetMarketconfigResponse:
      type: object
      properties:
        marketConfig:
          allOf:
            - $ref: '#/components/schemas/base_objects.v1.MarketConfig'
          title: market_config
      title: GetMarketconfigResponse
      additionalProperties: false
    base_objects.v2.MarketConfig:
      type: object
      properties:
        marketId:
          type: string
          title: market_id
          format: int64
          description: uint16 on-chain, using uint32 for protobuf compatibility
        marketName:
          type: string
          title: market_name
          description: bytes32 on-chain, converted to string
        minLeverage:
          type: number
          title: min_leverage
          format: float
          description: uint16 on-chain
        maxLeverage:
          type: number
          title: max_leverage
          format: float
          description: uint16 on-chain
        minTradeSize:
          type: number
          title: min_trade_size
          format: double
          description: uint48 on-chain, in USD Units
        maxTradeSize:
          type: number
          title: max_trade_size
          format: double
          description: uint48 on-chain, in USD Units
        tickDecimals:
          type: integer
          title: tick_decimals
          description: uint8 on-chain - replaces tick_exponent, critical for price conversion
        sizeDecimals:
          type: integer
          title: size_decimals
          description: uint8 on-chain - critical for position size conversion
        creator:
          type: string
          title: creator
          description: address of market creator
        feeConfig:
          allOf:
            - $ref: '#/components/schemas/base_objects.v1.FeeConfig'
          title: fee_config
        adlConfig:
          allOf:
            - $ref: '#/components/schemas/base_objects.v1.ADLConfig'
          title: adl_config
        status:
          allOf:
            - $ref: '#/components/schemas/base_objects.v2.MarketStatus'
          title: status
        updatedAt:
          allOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: updated_at
      title: MarketConfig
      additionalProperties: false
    base_objects.v2.MarketStatus:
      type: string
      title: MarketStatus
      enum:
        - MARKET_STATUS_ACTIVE
        - MARKET_STATUS_PAUSED
        - MARKET_STATUS_CLOSING
        - MARKET_STATUS_CLOSED
        - MARKET_STATUS_ALL
    market_service.v2.GetMarketSummaryRequest:
      type: object
      properties:
        market:
          allOf:
            - $ref: '#/components/schemas/base_objects.v1.MarketSelector'
          title: market
        chainId:
          type:
            - string
            - "null"
          title: chain_id
          format: int64
          description: "Optional chain identifier for the market. During testnet, Fairground runs on Arbitrum
            Sepolia (`421614`)."
      title: GetMarketSummaryRequest
      additionalProperties: false
    market_service.v2.GetMarketSummaryResponse:
      type: object
      properties:
        timestamp:
          allOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: timestamp
        priceTimestamp:
          allOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: price_timestamp
        marketSummary:
          allOf:
            - $ref: '#/components/schemas/base_objects.v1.MarketSummary'
          title: market_summary
      title: GetMarketSummaryResponse
      additionalProperties: false
    market_service.v2.GetMarketsRequest:
      type: object
      properties:
        market:
          oneOf:
            - $ref: '#/components/schemas/base_objects.v1.MarketSelector'
            - type: "null"
          title: market
        status:
          oneOf:
            - $ref: '#/components/schemas/base_objects.v2.MarketStatus'
            - type: "null"
          title: status
        chainId:
          type:
            - string
            - "null"
          title: chain_id
          format: int64
          description: "Optional chain identifier for the market. During testnet, Fairground runs on Arbitrum
            Sepolia (`421614`)."
      title: GetMarketsRequest
      additionalProperties: false
    market_service.v2.GetMarketsResponse:
      type: object
      properties:
        timestamp:
          allOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: timestamp
        markets:
          type: array
          items:
            $ref: '#/components/schemas/base_objects.v2.MarketConfig'
          title: markets
      title: GetMarketsResponse
      additionalProperties: false
    base_objects.v1.OrderBook:
      type: object
      properties:
        marketId:
          type: string
          title: market_id
          format: int64
        timestamp:
          title: timestamp
          "$ref": "#/components/schemas/google.protobuf.Timestamp"
        longs:
          type: array
          items:
            "$ref": "#/components/schemas/base_objects.v1.Tick"
          title: longs
          description: descending order by price
        shorts:
          type: array
          items:
            "$ref": "#/components/schemas/base_objects.v1.Tick"
          title: shorts
          description: ascending order by price
      title: OrderBook
      additionalProperties: false
    base_objects.v1.Tick:
      type: object
      properties:
        price:
          type: number
          title: price
          format: float
          description: USD Units
        size:
          type: number
          title: size
          format: float
          description: volume of orders exclusively at this price level in USD Units
        total:
          type: number
          title: total
          format: float
          description: cumulative volume of orders up to and including this price level in USD Units
        currency:
          type: string
          title: currency
          description: quote currency (USD)
      title: Tick
      additionalProperties: false
    orderbook_service.v1.GetOrderBookRequest:
      type: object
      properties:
        market:
          allOf:
            - $ref: '#/components/schemas/base_objects.v1.MarketSelector'
          title: market
        tickSize:
          type: number
          title: tickSize
          format: float
        sizeInUsd:
          type: boolean
          title: size_in_usd
        levels:
          type: integer
          title: levels
          format: int32
        limit:
          type:
            - integer
            - "null"
          title: limit
          description: Number of results returned
        offset:
          type:
            - integer
            - "null"
          title: offset
          description: Starting position
        totalOrderCount:
          type:
            - integer
            - "null"
          title: total_order_count
        chainId:
          type:
            - string
            - "null"
          title: chain_id
          format: int64
          description: "Optional chain identifier for the market. During testnet, Fairground runs on Arbitrum
            Sepolia (`421614`)."
      title: GetOrderBookRequest
      required:
        - market
      additionalProperties: false
    orderbook_service.v1.GetOrderBookResponse:
      type: object
      properties:
        orderBook:
          allOf:
            - $ref: '#/components/schemas/base_objects.v1.OrderBook'
          title: order_book
      title: GetOrderBookResponse
      additionalProperties: false
    order_service.v1.GetOrderRequest:
      type: object
      properties:
        orderId:
          type: string
          title: order_id
          format: int64
          description: uint40 on-chain, using uint64 to safely accommodate full range
        market:
          title: market
          description: uint16 on-chain, using uint64 for protobuf compatibility
          "$ref": "#/components/schemas/base_objects.v1.MarketSelector"
        reduceOnly:
          type: boolean
          title: reduce_only
      title: GetOrderRequest
      required:
        - orderId
        - market
      additionalProperties: false
    order_service.v1.GetOrderResponse:
      type: object
      properties:
        order:
          allOf:
            - $ref: '#/components/schemas/base_objects.v1.Order'
          title: order
      title: GetOrderResponse
      additionalProperties: false
    order_service.v1.GetOrdersRequest:
      type: object
      properties:
        address:
          type: string
          title: address
        market:
          oneOf:
            - $ref: '#/components/schemas/base_objects.v1.MarketSelector'
            - type: "null"
          title: market
        chainId:
          type:
            - string
            - "null"
          title: chain_id
          format: int64
          description: "Optional chain identifier for the market. During testnet, Fairground runs on Arbitrum
            Sepolia (`421614`)."
        limit:
          type: integer
          title: limit
          description: 'Maximum number of results (default: 50, max: 1000)'
        offset:
          type: integer
          title: offset
          description: 'Number of results to skip (default: 0)'
      title: GetOrdersRequest
      additionalProperties: false
    order_service.v1.GetOrdersResponse:
      type: object
      properties:
        orders:
          type: array
          items:
            $ref: '#/components/schemas/base_objects.v1.Order'
          title: orders
        pagination:
          allOf:
            - $ref: '#/components/schemas/order_service.v1.PaginationInfo'
          title: pagination
          description: Pagination metadata
      title: GetOrdersResponse
      additionalProperties: false
    order_service.v1.PaginationInfo:
      type: object
      properties:
        limit:
          type: integer
          title: limit
          description: Number of results returned
        offset:
          type: integer
          title: offset
          description: Starting position
        totalCount:
          type: integer
          title: total_count
          description: Total number of orders available
        hasMore:
          type: boolean
          title: has_more
          description: Authoritative end-of-data indicator; true when more records follow this page
      title: PaginationInfo
      additionalProperties: false
      description: Pagination metadata for list responses
    permissions.v1.ApiKeyInfo:
      type: object
      properties:
        id:
          type: string
          title: id
          format: int64
        label:
          type: string
          title: label
        createdAt:
          type: string
          title: created_at
          format: int64
      title: ApiKeyInfo
      additionalProperties: false
    permissions.v1.DeleteApiKeyRequest:
      type: object
      properties:
        userAddress:
          type: string
          title: user_address
        id:
          type: string
          title: id
          format: int64
      title: DeleteApiKeyRequest
      additionalProperties: false
    permissions.v1.DeleteApiKeyResponse:
      type: object
      title: DeleteApiKeyResponse
      additionalProperties: false
    permissions.v1.GenerateApiKeyRequest:
      type: object
      properties:
        userAddress:
          type: string
          title: user_address
        label:
          type: string
          title: label
      title: GenerateApiKeyRequest
      additionalProperties: false
    permissions.v1.GenerateApiKeyResponse:
      type: object
      properties:
        apiKey:
          type: string
          title: api_key
      title: GenerateApiKeyResponse
      additionalProperties: false
    permissions.v1.ListApiKeysRequest:
      type: object
      properties:
        userAddress:
          type: string
          title: user_address
      title: ListApiKeysRequest
      additionalProperties: false
    permissions.v1.ListApiKeysResponse:
      type: object
      properties:
        keys:
          type: array
          items:
            $ref: '#/components/schemas/permissions.v1.ApiKeyInfo'
          title: keys
      title: ListApiKeysResponse
      additionalProperties: false
    base_objects.v1.Portfolio:
      type: object
      properties:
        owner:
          type: string
          title: owner
          description: Core Identification The wallet owning the portfolio
          example: "0xAbcd1234...."
        timestamp:
          title: timestamp
          description: The last known blocktime when this portfolio snapshot was computed
          "$ref": "#/components/schemas/google.protobuf.Timestamp"
          example: "2026-08-24T16:54:23.236685739Z"
        totalMargin:
          type: number
          title: total_margin
          format: float
          description: Margin & PnL Sum of margin in all open positions (USDC, 6 decimals)
          example: 149.26143
        totalUnrealizedPnl:
          type: number
          title: total_unrealized_pnl
          format: float
          description: Sum of unrealized PnL from all open positions (USDC, 6 decimals) [Dynamic]
          example: 7.10187794241007
        totalRealizedPnl:
          type: number
          title: total_realized_pnl
          format: float
          description: |-
            Formula: sum(positionUnrealizedPnL) where:
             - For Longs: (markPrice - entryPrice) * size
             - For Shorts: (entryPrice - markPrice) * size Sum of realized PnL from all closed positions net of fees (USDC, 6 decimals) [Calculated on-demand]
          example: 0.4408130000000001
        totalVolume:
          type: number
          title: total_volume
          format: float
          description: Trading Statistics Cumulative notional value of all executed trades (USD)
          example: 156520757.2626406
        totalFees:
          type: number
          title: total_fees
          format: float
          description: 'Formula: sum(tradeSize * tradePrice) for all executed trades Cumulative fees paid
            across all trades (USDC, 6 decimals)'
          example: 0.8953679999999999
        totalProfit:
          type: number
          title: total_profit
          format: float
          description: Calculation TBD once fee structure is defined Sum of gross profits from all 
            profitable closes and partial closes, excludes fees (USDC, 6 decimals)
          example: 1.336181
        totalLoss:
          type: number
          title: total_loss
          format: float
          description: 'Formula: sum(tradePnl for all closes where tradePnl > 0) Sum of gross losses from
            all closes, partial closes, and liquidations (USDC, 6 decimals, stored as positive value,
            excludes fees)'
          example: 0
        totalTrades:
          type: string
          title: total_trades
          format: int64
          description: 'Formula: sum(abs(tradePnl) for all closes where tradePnl < 0) Count of executed
            trades (fills) including both entries and exits'
          example: "7"
        totalEquity:
          type: number
          title: total_equity
          format: float
          description: Account Metrics Current total value of the portfolio - the liquidation value 
            (USDC, 6 decimals) [Dynamic]
          example: 156.36330794241007
        maxDrawdown:
          type: number
          title: max_drawdown
          format: float
          description: |-
            Formula: totalMargin + totalUnrealizedPnl
             Alternative: initialDeposits - withdrawals + totalRealizedPnl + totalUnrealizedPnl Maximum observed percentage decline in portfolio equity from any peak to subsequent trough (percentage)
          example: 0.10608023388454796
        positions:
          type: array
          items:
            "$ref": "#/components/schemas/base_objects.v1.Position"
          title: positions
          description: Related Objects All positions (both open and closed)
        orders:
          type: array
          items:
            "$ref": "#/components/schemas/base_objects.v1.Order"
          title: orders
          description: All orders (historical and active)
      title: Portfolio
      additionalProperties: false
    portfolio.v1.GetPortfolioRequest:
      type: object
      properties:
        owner:
          type: string
          title: owner
          description: Wallet address
        chainId:
          type:
            - string
            - "null"
          title: chain_id
          format: int64
          description: "Optional chain identifier for the market. During testnet, Fairground runs on Arbitrum
            Sepolia (`421614`)."
      title: GetPortfolioRequest
      required:
        - owner
      additionalProperties: false
    portfolio.v1.GetPortfolioResponse:
      type: object
      properties:
        portfolio:
          allOf:
            - $ref: '#/components/schemas/base_objects.v1.Portfolio'
          title: portfolio
      title: GetPortfolioResponse
      additionalProperties: false
    position_service.v1.GetOpenPositionsRequest:
      type: object
      properties:
        address:
          type: string
          title: address
        chainId:
          type:
            - string
            - "null"
          title: chain_id
          format: int64
          description: "Optional chain identifier for the market. During testnet, Fairground runs on Arbitrum
            Sepolia (`421614`)."
      title: GetOpenPositionsRequest
      required:
        - address
      additionalProperties: false
    position_service.v1.GetOpenPositionsResponse:
      type: object
      properties:
        positions:
          type: array
          items:
            $ref: '#/components/schemas/base_objects.v1.Position'
          title: positions
      title: GetOpenPositionsResponse
      additionalProperties: false
    base_objects.v2.CandleInterval:
      type: string
      title: CandleInterval
      enum:
        - CANDLE_INTERVAL_UNSPECIFIED
        - CANDLE_INTERVAL_1_MINUTE
        - CANDLE_INTERVAL_3_MINUTES
        - CANDLE_INTERVAL_5_MINUTES
        - CANDLE_INTERVAL_15_MINUTES
        - CANDLE_INTERVAL_30_MINUTES
        - CANDLE_INTERVAL_1_HOUR
        - CANDLE_INTERVAL_2_HOURS
        - CANDLE_INTERVAL_4_HOURS
        - CANDLE_INTERVAL_8_HOURS
        - CANDLE_INTERVAL_12_HOURS
        - CANDLE_INTERVAL_1_DAY
        - CANDLE_INTERVAL_3_DAYS
        - CANDLE_INTERVAL_1_WEEK
        - CANDLE_INTERVAL_1_MONTH
      description: |-
        Width of a CandleStick bucket. The supported set is the same for every
         market. Trailing comments give the value each entry maps to on the upstream
         pricing service, where bare numbers are minutes and D/W/M are calendar
         buckets — the ambiguity this enum exists to remove.
    base_objects.v2.CandleStick:
      type: object
      properties:
        timestamp:
          allOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: timestamp
          description: Bucket start time
        open:
          type: number
          title: open
          format: float
        high:
          type: number
          title: high
          format: float
        low:
          type: number
          title: low
          format: float
        close:
          type: number
          title: close
          format: float
      title: CandleStick
      additionalProperties: false
      description: Oracle-price OHLC candle. No mid or volume, unlike base_objects.v1.CandleStick.
    base_objects.v2.Price:
      type: object
      properties:
        marketId:
          type: string
          title: market_id
          format: int64
          description: On-chain market identifier.
        marketName:
          type: string
          title: market_name
          description: Canonical market name, e.g. "BTC-USD".
        symbol:
          type: string
          title: symbol
          description: Market symbol. Always identical to market_name.
        price:
          type: number
          title: price
          format: float
          description: Current oracle price in quote asset units.
        priceTimestamp:
          allOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: price_timestamp
          description: The time the price point was printed.
      title: Price
      additionalProperties: false
      description: |-
        Price is the price shape served by price_service.v2.GetPrice.
         It carries only the oracle reading for a single market. Unlike
         base_objects.v1.Price it does not include volume, price change, or source.
    price_service.v2.GetHistoricalPricesRequest:
      type: object
      properties:
        market:
          allOf:
            - $ref: '#/components/schemas/base_objects.v1.MarketSelector'
          title: market
          description: Required
        startTime:
          allOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: start_time
          description: Inclusive
        endTime:
          allOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: end_time
          description: Exclusive
        interval:
          allOf:
            - $ref: '#/components/schemas/base_objects.v2.CandleInterval'
          title: interval
          description: Candle bucket width. Omitted (UNSPECIFIED) defaults to 1 hour.
        limit:
          type: integer
          title: limit
        offset:
          type: integer
          title: offset
        chainId:
          type:
            - string
            - "null"
          title: chain_id
          format: int64
          description: "Optional chain identifier for the market. During testnet, Fairground runs on Arbitrum
            Sepolia (`421614`)."
      title: GetHistoricalPricesRequest
      additionalProperties: false
    price_service.v2.GetHistoricalPricesResponse:
      type: object
      properties:
        marketId:
          type: string
          title: market_id
          format: int64
        market:
          type: string
          title: market
          description: Canonical name, e.g. "BTC-USD"
        priceCandleSticks:
          type: array
          items:
            $ref: '#/components/schemas/base_objects.v2.CandleStick'
          title: price_candle_sticks
          description: Timestamp descending
        pagination:
          allOf:
            - $ref: '#/components/schemas/price_service.v2.PaginationInfo'
          title: pagination
      title: GetHistoricalPricesResponse
      additionalProperties: false
    price_service.v2.GetPriceRequest:
      type: object
      properties:
        market:
          allOf:
            - $ref: '#/components/schemas/base_objects.v1.MarketSelector'
          title: market
        chainId:
          type:
            - string
            - "null"
          title: chain_id
          format: int64
          description: "Optional chain identifier for the market. During testnet, Fairground runs on Arbitrum
            Sepolia (`421614`)."
      title: GetPriceRequest
      additionalProperties: false
    price_service.v2.GetPriceResponse:
      type: object
      properties:
        timestamp:
          allOf:
            - $ref: '#/components/schemas/google.protobuf.Timestamp'
          title: timestamp
        price:
          allOf:
            - $ref: '#/components/schemas/base_objects.v2.Price'
          title: price
        signedPricePayload:
          type: string
          title: signed_price_payload
      title: GetPriceResponse
      additionalProperties: false
    price_service.v2.PaginationInfo:
      type: object
      properties:
        limit:
          type: integer
          title: limit
        offset:
          type: integer
          title: offset
        totalCount:
          type: integer
          title: total_count
          description: Total matches, ignoring limit/offset
        hasMore:
          type: boolean
          title: has_more
      title: PaginationInfo
      additionalProperties: false
