> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agg.market/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> To integrate AGG, start with Quickstart: REST (https://docs.agg.market/quickstart/rest), then Order lifecycle & statuses (https://docs.agg.market/concepts/order-lifecycle).
> Track every trade until it reaches a terminal status. Before retrying a failed or timed-out call, read Errors, retries & idempotency (https://docs.agg.market/concepts/errors).
> The API reference is generated from https://docs.agg.market/openapi/openapi.json.

# Get a quote (smart route)

> Computes a fill quote across available venues for a specific venue market outcome and returns the suggested fills. When a user JWT is supplied the quote is scoped to the user's wallet balances and may be executed; without a JWT the response is a preview-only quote. ProphetX prices are computed from AGG's orderbook without a synchronous account-readiness request. Account identity and readiness are validated when a live fill is submitted, before funding or execution is queued. ProphetX quotes apply no execution reserve, settlement surcharge, or speculative venue commission. ProphetX live buys use fixed-input FOK execution and a maximum $500 per-order input cap.



## OpenAPI

````yaml /openapi/openapi.json get /orderbook/{venueMarketOutcomeId}/route
openapi: 3.0.2
info:
  title: AGG API
  version: 1.0.0
  description: >-
    Prediction market aggregator REST API — authentication, users, venue events,
    venue markets, orderbooks, charts, and execution workflows.
servers:
  - url: https://api.agg.market
    description: Production
security: []
tags:
  - name: Authentication
    description: Sign users in and manage their session tokens.
  - name: Markets
    description: Find events, markets and outcomes to trade.
  - name: Market Data
    description: Live orderbooks, prices, charts and scores for those markets.
  - name: Trading
    description: Quote, place, sign, track and cancel orders.
  - name: Portfolio
    description: A user's orders, positions, balances and activity.
  - name: Funding
    description: Deposit addresses, withdrawals, balance refills and fiat on-ramp.
  - name: Users
    description: The signed-in user's profile, linked accounts, KYC and venue keys.
  - name: Hosted Venue Accounts
    description: Provision, fund and withdraw from venue accounts hosted for the user.
  - name: Webhooks
    description: Configure and operate webhook delivery to your server.
  - name: Partner Admin
    description: Server-side reads across your app's users, orders and analytics.
  - name: Paper Trading
    description: Simulated accounts and orders for testing without real funds.
  - name: News
    description: News feeds linked to markets.
  - name: Correlated Markets
    description: Markets related to a given market and the effect of its resolution.
paths:
  /orderbook/{venueMarketOutcomeId}/route:
    get:
      tags:
        - Trading
      summary: Get a quote (smart route)
      description: >-
        Computes a fill quote across available venues for a specific venue
        market outcome and returns the suggested fills. When a user JWT is
        supplied the quote is scoped to the user's wallet balances and may be
        executed; without a JWT the response is a preview-only quote. ProphetX
        prices are computed from AGG's orderbook without a synchronous
        account-readiness request. Account identity and readiness are validated
        when a live fill is submitted, before funding or execution is queued.
        ProphetX quotes apply no execution reserve, settlement surcharge, or
        speculative venue commission. ProphetX live buys use fixed-input FOK
        execution and a maximum $500 per-order input cap.
      operationId: getSmartRoute
      parameters:
        - name: venueMarketOutcomeId
          in: path
          required: true
          schema:
            type: string
        - name: mode
          in: query
          required: false
          schema:
            type: string
            enum:
              - live
              - paper
        - name: chainBalances
          in: query
          required: false
          schema:
            type: string
        - name: slipCapBps
          in: query
          required: false
          schema:
            minimum: 0
            type: number
        - name: maxSpend
          in: query
          required: false
          schema:
            exclusiveMinimum: true
            type: number
            minimum: 0
        - name: sellShares
          in: query
          required: false
          schema:
            exclusiveMinimum: true
            type: number
            minimum: 0
        - name: compareVenues
          in: query
          required: false
          schema:
            type: string
            enum:
              - 'true'
              - 'false'
        - name: allowedVenues
          in: query
          required: false
          schema:
            anyOf:
              - type: array
                items:
                  $ref: '#/components/schemas/Venue'
              - $ref: '#/components/schemas/Venue'
        - name: side
          in: query
          required: false
          schema:
            type: string
            enum:
              - buy
              - sell
        - name: deepEstimate
          in: query
          required: false
          schema:
            type: string
            enum:
              - 'true'
              - 'false'
        - name: signingAddress
          in: query
          required: false
          schema:
            minLength: 42
            maxLength: 42
            type: string
        - name: fundingAddresses
          in: query
          required: false
          schema:
            anyOf:
              - type: array
                items:
                  minLength: 42
                  maxLength: 42
                  type: string
              - minLength: 42
                maxLength: 42
                type: string
        - name: appFeeBips
          in: query
          required: false
          schema:
            minimum: 0
            maximum: 10000
            multipleOf: 1
            type: number
        - name: referrer
          in: query
          required: false
          schema:
            minLength: 42
            maxLength: 42
            description: >-
              Referral: the EVM address that receives the referral fee. Requires
              referrerFeeBips. Honoured only when the request carries
              x-app-api-key; a JWT-only request that sends it is rejected with
              400 referral_requires_api_key. Buy only.
            type: string
        - name: referrerFeeBips
          in: query
          required: false
          schema:
            minimum: 1
            maximum: 10000
            multipleOf: 1
            description: >-
              Referral fee in basis points of the routed notional, 1..10000. AGG
              takes no share of it. With referralPayer "user" it is reserved
              from maxSpend next to the app fee; with "app" the user pays
              nothing.
            type: number
        - name: referralPayer
          in: query
          required: false
          schema:
            description: Who funds the referral. Default "user".
            type: string
            enum:
              - user
              - app
        - name: referralPayerAddress
          in: query
          required: false
          schema:
            minLength: 42
            maxLength: 42
            description: >-
              Required when referralPayer is "app": the wallet that settles the
              payout. After the fill, a pendingSignatures entry appears with
              signerAddress set to this address and purpose "referral_payout";
              answer it on POST /execution/fill/:quoteId/signatures. Read its
              type: on an EVM chain it is a `transaction` to broadcast (post the
              hash), on HyperCore an `eip712` to sign (post the signature).
            type: string
        - name: referralPayoutChainId
          in: query
          required: false
          schema:
            minimum: 1
            multipleOf: 1
            description: >-
              Optional, and only with referralPayer "app": the chain the
              referrer is paid on. Must carry USDC. On an EVM chain the payout
              is an ERC-20 transfer the partner's wallet broadcasts, needing
              USDC plus native gas there; on HyperCore (1337) it is a
              user-signed sendAsset from the partner's HyperCore spot balance —
              a signature, nothing to broadcast — and the referrer receives spot
              USDC on Hyperliquid. A first payout to a referrer with no
              Hyperliquid account costs the partner an extra 1 USDC that
              Hyperliquid charges to create it; later payouts to the same
              referrer cost nothing. Solana does not support app-paid payouts
              and is refused. Defaults to the trade's fee chain, or Polygon when
              that chain is not EVM. Sending it with a user-paid referral is
              rejected with 400 referral_invalid.
            type: number
      responses:
        '200':
          description: '200'
          content:
            application/json:
              schema:
                type: object
                required:
                  - quoteId
                  - venueMarketOutcomeId
                  - venueMarketId
                  - estimatedCostRaw
                  - expiresAt
                  - refreshAt
                  - status
                  - fills
                  - totalFilled
                  - rawExecCost
                  - solveTimeMs
                  - verifyTimeMs
                  - matchedMarkets
                properties:
                  quoteRefreshNotBefore:
                    format: date-time
                    description: >-
                      Earliest time to request a new quote (rate-limited venues
                      only).
                    type: string
                  quoteFailure:
                    $ref: '#/components/schemas/QuoteFailure'
                  quoteId:
                    description: Pass to POST /execution/fill to trade this quote.
                    type: string
                  venueMarketOutcomeId:
                    description: The outcome requested.
                    type: string
                  venueMarketId:
                    description: Market of that outcome.
                    type: string
                  estimatedCostRaw:
                    description: >-
                      Price × shares before fees (proceeds on a sell). USD in
                      6-decimal atomic units, as an integer string (1000000 =
                      $1.00).
                    type: string
                  expiresAt:
                    description: ISO-8601. After this the quote cannot be filled.
                    type: string
                  refreshAt:
                    description: >-
                      ISO-8601, earlier than `expiresAt`: fetch a new quote from
                      here on, though this one stays fillable until `expiresAt`.
                    type: string
                  status:
                    description: >-
                      `ok` when the quote can be filled; anything else means it
                      cannot (see `error`). `insufficient_balance`: not enough
                      funds. `insufficient_position`: not enough shares to sell
                      (see `positionAvailability`). `insufficient_depth` /
                      `no_orderbooks` / `no_bids_above_min_price`: not enough
                      liquidity. `min_order_size_violated` /
                      `insufficient_input_amount`: the amount is too small.
                      `infeasible`, `checker_rejected`, `solver_error`,
                      `invalid_input`, `engine_unavailable`: no valid route
                      could be built.
                    type: string
                    enum:
                      - ok
                      - infeasible
                      - checker_rejected
                      - solver_error
                      - invalid_input
                      - no_orderbooks
                      - insufficient_input_amount
                      - engine_unavailable
                      - min_order_size_violated
                      - insufficient_balance
                      - insufficient_position
                      - insufficient_depth
                      - no_bids_above_min_price
                  fills:
                    description: Where the trade executes, one entry per venue market.
                    type: array
                    items:
                      $ref: '#/components/schemas/SmartRouteFill'
                  totalFilled:
                    description: Total shares bought (or sold), as a float.
                    type: number
                  rawExecCost:
                    description: >-
                      Price × shares across all fills, before fees (proceeds on
                      a sell). USD, as a float.
                    type: number
                  solveTimeMs:
                    description: Time to compute the route, in milliseconds.
                    type: number
                  verifyTimeMs:
                    description: Time to verify the route, in milliseconds.
                    type: number
                  matchedMarkets:
                    description: The same market on other venues. Empty on sells.
                    type: array
                    items:
                      type: object
                      required:
                        - venue
                        - venueMarketId
                      properties:
                        venue:
                          allOf:
                            - $ref: '#/components/schemas/Venue'
                          description: A venue listing the same market.
                        venueMarketId:
                          description: That venue's market id.
                          type: string
                  error:
                    description: Readable reason when `status` is not `ok`.
                    type: string
                  venueSoloQuotes:
                    description: >-
                      With `compareVenues=true`: the same trade priced on each
                      venue alone, for comparison.
                    type: array
                    items:
                      $ref: '#/components/schemas/SmartRouteSoloQuote'
                  allocations:
                    description: How the trade is funded, per source and venue.
                    type: array
                    items:
                      $ref: '#/components/schemas/SmartRouteAllocation'
                  bridgeSteps:
                    description: Cross-chain transfers needed.
                    type: array
                    items:
                      $ref: '#/components/schemas/SmartRouteBridgeStep'
                  feeBreakdown:
                    description: Cost of the trade, line by line.
                    type: object
                    required:
                      - rawExecCost
                      - venueFees
                      - bridgeFees
                      - executionGas
                      - totalCost
                    properties:
                      rawExecCost:
                        description: >-
                          Price × shares, before any fee (proceeds on a sell).
                          USD, as a float.
                        type: number
                      venueFees:
                        description: >-
                          Venue trading fees, excluding reserves and the builder
                          fee. USD, as a float.
                        type: number
                      builderFee:
                        description: >-
                          Builder-code fee: your own rate if you have a builder
                          code, otherwise the platform default. Not in
                          `venueFees`; included in `totalCost`. USD, as a float.
                        type: number
                      executionReserve:
                        minimum: 0
                        description: >-
                          Additional buy-side clearing-house funding held for
                          slippage or possible venue charges, not a confirmed
                          fee. Excluded from venueFees and totalCost; funding
                          allocations include it. Unused funds are released
                          after execution.
                        type: number
                      bridgeFees:
                        description: >-
                          Expected cross-chain transfer fees, including any
                          funding fee. USD, as a float.
                        type: number
                      executionGas:
                        description: Estimated network gas for execution. USD, as a float.
                        type: number
                      totalCost:
                        description: >-
                          `rawExecCost` + `venueFees` + `builderFee` +
                          `bridgeFees` + `executionGas`. Excludes the app and
                          referral fees; see `totalCostIncFees`. USD, as a
                          float.
                        type: number
                      appFee:
                        description: >-
                          Maximum app fee on this buy, if it fills in full;
                          collected after the fill on the amount actually
                          filled. Present only when above 0. USD, as a float.
                        type: number
                      appFeeBips:
                        description: App fee rate, in basis points. Present with `appFee`.
                        type: number
                      appFeeCategory:
                        description: >-
                          Which of your fee rules matched: `all`, `override` (a
                          per-trade `appFeeBips`), or one of your category
                          names.
                        type: string
                      referralFee:
                        description: >-
                          Referral fee the user pays. Present only when above 0
                          and `referralPayer` is `user`; an app-paid referral
                          never appears here. USD, as a float.
                        type: number
                      setupCosts:
                        description: >-
                          One-time setup costs, only with `deepEstimate=true`.
                          Items the user already paid have `alreadyPaid: true`.
                        type: array
                        items:
                          $ref: '#/components/schemas/SmartRouteSetupCost'
                      setupCostsTotal:
                        description: Sum of the setup costs not yet paid. USD, as a float.
                        type: number
                      gasReimbursement:
                        description: >-
                          Part of `executionGas` collected together with the app
                          fee. Already inside `totalCost`, not an extra charge.
                          Present only when above 0. USD, as a float.
                        type: number
                  appFee:
                    description: >-
                      App fee settings frozen at quote time, for reconciliation.
                      `null` when the app charges no fee. For display use
                      `feeBreakdown.appFee`.
                    type: object
                    required:
                      - bips
                      - categoryKey
                      - quotedAppFeeRaw
                    properties:
                      bips:
                        description: App fee rate at quote time, in basis points.
                        type: number
                      categoryKey:
                        description: >-
                          Fee rule matched (same values as
                          `feeBreakdown.appFeeCategory`).
                        type: string
                      quotedAppFeeRaw:
                        description: >-
                          Maximum app fee, for reconciliation. USD in 6-decimal
                          atomic units, as an integer string (1000000 = $1.00).
                        type: string
                    nullable: true
                  referral:
                    description: >-
                      The referral this quote pays; absent or `null` without a
                      referrer.
                    type: object
                    required:
                      - referrer
                      - feeBips
                      - payer
                      - quotedFeeUsd
                    properties:
                      referrer:
                        description: Referrer address.
                        type: string
                      feeBips:
                        description: Referral fee rate, in basis points.
                        type: number
                      payer:
                        description: >-
                          Who pays the referral fee: the trading `user` or the
                          `app`.
                        type: string
                        enum:
                          - user
                          - app
                      payerAddress:
                        description: Paying wallet, when the app pays.
                        type: string
                      quotedFeeUsd:
                        description: Maximum referral fee. USD, as a float.
                        type: number
                    nullable: true
                  slippage:
                    description: Price impact of the route.
                    type: object
                    required:
                      - vwap
                      - refMidpoint
                      - slippage
                      - slippageBps
                    properties:
                      vwap:
                        description: Volume-weighted average price, 0 to 1.
                        type: number
                      refMidpoint:
                        description: Reference midpoint price, 0 to 1.
                        type: number
                      slippage:
                        description: '`vwap` minus `refMidpoint` per share, never below 0.'
                        type: number
                      slippageBps:
                        description: Slippage relative to the midpoint, in bps.
                        type: number
                  optima:
                    description: >-
                      Best values each objective could reach on its own, for
                      comparison.
                    type: object
                    required:
                      - maxFilledQty
                      - minSlippage
                      - minCost
                      - minRisk
                      - minBridges
                      - minVenues
                    properties:
                      maxFilledQty:
                        description: Most shares reachable within budget.
                        type: number
                      minSlippage:
                        description: Lowest slippage cost reachable. USD, as a float.
                        type: number
                      minCost:
                        description: Lowest total cost reachable. USD, as a float.
                        type: number
                      minRisk:
                        description: Lowest execution-delay risk score (unitless).
                        type: number
                      minBridges:
                        description: Fewest cross-chain transfers possible.
                        type: number
                      minVenues:
                        description: Fewest venues possible.
                        type: number
                  warnings:
                    description: >-
                      Venues left out of the route or flagged, without blocking
                      the quote.
                    type: array
                    items:
                      type: object
                      required:
                        - venue
                        - venueMarketOutcomeId
                        - reason
                      properties:
                        venue:
                          allOf:
                            - $ref: '#/components/schemas/Venue'
                          description: Venue skipped or flagged.
                        venueMarketOutcomeId:
                          description: Outcome skipped or flagged.
                          type: string
                        reason:
                          description: >-
                            Why. Open set, may include readable text and
                            upstream codes. Known values: `low_liquidity`,
                            `low_balance`, `stale_orderbook`,
                            `orderbook_clock_skew`, `invalid_prices`,
                            `invalid_fee_metadata`, `empty_book`,
                            `crossed_book`, `endpoint_stub`, `stub_orderbook`,
                            `bid_only_no_asks`, `ask_only_no_bids`,
                            `no_orderbook`, `hosted_cash_unavailable`,
                            `app_fee_unsupported`, `referral_unpaid_on_solana`,
                            `referrer_not_activated_on_hypercore`, and "Venue
                            not available in your region (XX)".
                          type: string
                  custodyWarnings:
                    description: >-
                      Self-custody quotes only: the quote is valid but the fill
                      from this wallet would be refused. Absent on managed
                      quotes.
                    type: array
                    items:
                      type: object
                      required:
                        - reason
                        - message
                      properties:
                        reason:
                          description: >-
                            Why the quote cannot be filled from
                            `signingAddress`: `self_custody_app_fee` or
                            `self_custody_redeem_unsupported`.
                          type: string
                        message:
                          description: Readable explanation.
                          type: string
                  message:
                    description: Informational note, e.g. on redemption.
                    type: string
                  settlementPlan:
                    description: >-
                      Sell quotes on resolved markets only: winning shares are
                      redeemed for their payout instead of sold.
                    type: object
                    required:
                      - redeemId
                      - status
                      - message
                      - totalRedeemableShares
                      - totalRedeemShares
                      - totalSellShares
                      - redeemLegs
                    properties:
                      redeemId:
                        description: Id of the redemption (equals the quote id).
                        type: string
                      status:
                        description: >-
                          `redeem_only`: every share is redeemed, nothing is
                          sold. `partial_redeem`: some shares are redeemed and
                          the rest are sold on the market.
                        type: string
                        enum:
                          - redeem_only
                          - partial_redeem
                      message:
                        description: Readable summary.
                        type: string
                      totalRedeemableShares:
                        description: Resolved shares the user could redeem, as a float.
                        type: number
                      totalRedeemShares:
                        description: Shares this quote redeems, as a float.
                        type: number
                      totalSellShares:
                        description: Shares still sold on the market, as a float.
                        type: number
                      redeemLegs:
                        description: The positions redeemed.
                        type: array
                        items:
                          type: object
                          required:
                            - action
                            - venue
                            - venueMarketId
                            - venueMarketOutcomeId
                            - positionId
                            - size
                            - redeemPath
                          properties:
                            action:
                              description: Always `redeem`.
                              type: string
                              enum:
                                - redeem
                            venue:
                              allOf:
                                - $ref: '#/components/schemas/Venue'
                              description: Venue holding the resolved position.
                            venueMarketId:
                              description: Market id.
                              type: string
                            venueMarketOutcomeId:
                              description: Outcome id.
                              type: string
                            positionId:
                              description: Position being redeemed.
                              type: string
                            size:
                              description: >-
                                Shares redeemed on this leg, as a decimal string
                                (e.g. "12.5").
                              type: string
                            redeemPath:
                              description: >-
                                Chain family the redemption runs on; currently
                                always `evm`.
                              type: string
                              enum:
                                - evm
                                - svm
                  estimatedPayout:
                    description: >-
                      Payout if the outcome wins, after settlement fees. USD, as
                      a float.
                    type: number
                  totalCostIncFees:
                    description: >-
                      All-in cost: `feeBreakdown.totalCost` + app fee +
                      user-paid referral fee + any funding fee. USD, as a float.
                    type: number
                  estimatedProfit:
                    description: '`estimatedPayout` minus cost. USD, as a float.'
                    type: number
                  returnPct:
                    description: Profit as a percentage of cost (25 = 25%).
                    type: number
                  positionAvailability:
                    description: Only when `status` is `insufficient_position`.
                    type: object
                    required:
                      - totalSellableShares
                      - venueMarketOutcomes
                    properties:
                      totalSellableShares:
                        description: Shares the user can sell, as a float.
                        type: number
                      venueMarketOutcomes:
                        description: Where the sellable shares are.
                        type: array
                        items:
                          type: object
                          required:
                            - id
                            - venue
                            - venueMarketId
                            - availableShares
                          properties:
                            id:
                              description: Outcome id.
                              type: string
                            venue:
                              allOf:
                                - $ref: '#/components/schemas/Venue'
                              description: Venue holding the shares.
                            venueMarketId:
                              description: Market id.
                              type: string
                            availableShares:
                              description: Shares sellable there, as a float.
                              type: number
              example:
                quoteId: k2r8v5n1x7c4m9t3b6q0w2za
                venueMarketOutcomeId: cmf3q8z1k00a2mw0l7xg4v9rt
                venueMarketId: cmf3q8yzt009xmw0lh2c5d8kn
                estimatedCostRaw: '25000000'
                expiresAt: '2026-09-29T15:04:30.000Z'
                refreshAt: '2026-09-29T15:04:20.000Z'
                status: ok
                fills:
                  - venue: polymarket
                    venueMarketId: cmf3q8z0a009zmw0l3w8n6jbd
                    venueMarketOutcomeId: cmf3q8z2m00a4mw0lr5t1k7yc
                    chain: '137'
                    avgPrice: 0.51
                    yesPrice: 0.51
                    noPrice: 0.5
                    fills:
                      - price: 0.51
                        size: 30
                        fill: 30
                    venueQty: 30
                    venueFee: 0
                  - venue: limitless
                    venueMarketId: cmf3q8z0x00a0mw0lc1v7q3mf
                    venueMarketOutcomeId: cmf3q8z3p00a6mw0l9e4h2sxa
                    chain: '8453'
                    avgPrice: 0.535
                    yesPrice: 0.535
                    noPrice: 0.475
                    fills:
                      - price: 0.535
                        size: 18
                        fill: 18
                    venueQty: 18
                    venueFee: 0.05
                totalFilled: 48
                rawExecCost: 24.93
                solveTimeMs: 42
                verifyTimeMs: 6
                matchedMarkets:
                  - venue: polymarket
                    venueMarketId: cmf3q8z0a009zmw0l3w8n6jbd
                  - venue: limitless
                    venueMarketId: cmf3q8z0x00a0mw0lc1v7q3mf
                allocations:
                  - sourceChainId: '137'
                    venue: polymarket
                    amount: 15.3
                  - sourceChainId: '8453'
                    venue: limitless
                    amount: 9.68
                bridgeSteps: []
                feeBreakdown:
                  rawExecCost: 24.93
                  venueFees: 0.05
                  bridgeFees: 0
                  executionGas: 0.02
                  totalCost: 25
                appFee: null
                referral: null
                slippage:
                  vwap: 0.5194
                  refMidpoint: 0.515
                  slippage: 0.0044
                  slippageBps: 85
                warnings: []
                estimatedPayout: 48
                totalCostIncFees: 25
                estimatedProfit: 23
                returnPct: 92
        '400':
          description: '400'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QuoteError'
        '401':
          description: '401'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '403':
          description: '403'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '404':
          description: '404'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '503':
          description: '503'
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                  - retryable
                properties:
                  code:
                    type: string
                    enum:
                      - orderbook_service_unavailable
                  message:
                    type: string
                  retryable:
                    type: boolean
      security:
        - appId: []
components:
  schemas:
    Venue:
      type: string
      enum:
        - kalshi
        - polymarket
        - limitless
        - opinion
        - predict
        - pred
        - tiprun
        - probable
        - myriad
        - hyperliquid
        - novig
        - prophetx
        - betdex
    QuoteFailure:
      description: A venue that could not be priced live; the quote excludes it.
      type: object
      required:
        - venue
        - code
      properties:
        venue:
          allOf:
            - $ref: '#/components/schemas/Venue'
          description: Venue whose live price request failed (ProphetX).
        code:
          description: >-
            Error code from the venue's quoting service. Open set: passes
            through upstream codes. Known values include
            `INSUFFICIENT_LIQUIDITY`, `MARKET_NOT_ACTIVE`,
            `EXTERNAL_MARKET_CLOSED`, `UNSUPPORTED_MARKET`, `RATE_LIMITED`,
            `PROVIDER_RATE_LIMITED`, `VENUE_DATA_STALE`, `KYC_REQUIRED`,
            `PREVIEW_ONLY`, `MARKET_MOVED`, `VENUE_UNAVAILABLE` (the fallback),
            and `HTTP_<status>`.
          type: string
        retryAt:
          format: date-time
          description: When quoting on that venue can resume.
          type: string
    SmartRouteFill:
      type: object
      required:
        - venue
        - venueMarketId
        - venueMarketOutcomeId
        - chain
        - avgPrice
        - yesPrice
        - noPrice
        - fills
        - venueQty
      properties:
        venue:
          allOf:
            - $ref: '#/components/schemas/Venue'
          description: Venue this part of the trade executes on.
        venueMarketId:
          description: Market id on that venue.
          type: string
        venueMarketOutcomeId:
          description: Outcome id on that venue.
          type: string
        chain:
          description: >-
            Where this part settles: a chain id as a decimal string (e.g.
            `137`), or `venue-cash` for cash held at the venue.
          type: string
        inAmount:
          pattern: ^[0-9]+$
          description: >-
            Exact amount paid in, for venues priced live at quote time: USD on a
            buy, shares on a sell, both in 6-decimal atomic units as an integer
            string (1000000 = $1 or 1 share).
          type: string
        outAmount:
          pattern: ^[0-9]+$
          description: >-
            Exact amount received, for venues priced live at quote time: shares
            on a buy, USD on a sell, both in 6-decimal atomic units as an
            integer string.
          type: string
        limitPriceMicroUsdc:
          pattern: ^[0-9]+$
          description: >-
            Worst price per share the order will accept. Price per share scaled
            by 1e6, as an integer string (530000 = 0.53).
          type: string
        avgPrice:
          description: Average price per share paid (received on a sell), 0 to 1.
          type: number
        yesPrice:
          description: The price expressed for the YES side, 0 to 1.
          type: number
        noPrice:
          description: The price expressed for the NO side, 0 to 1.
          type: number
        fills:
          description: Order book levels consumed.
          type: array
          items:
            type: object
            required:
              - price
              - size
              - fill
            properties:
              price:
                description: Price of this book level, 0 to 1.
                type: number
              size:
                description: Shares available at this level, as a float.
                type: number
              fill:
                description: Shares taken at this level, as a float.
                type: number
        executionBackend:
          description: >-
            ProphetX only. `direct`: executes in the user's own ProphetX
            account. `clearinghouse`: executes through AGG's ProphetX account.
          type: string
          enum:
            - clearinghouse
            - direct
        venueAccountId:
          description: The user's venue account used, for `direct` execution.
          type: string
        venueQty:
          description: Shares bought or sold on this venue, as a float.
          type: number
        venueFee:
          description: >-
            Venue fee budget for this part, including any reserve held for price
            movement (see `feeBreakdown.executionReserve`). USD, as a float.
          type: number
        builderFee:
          description: >-
            Builder-code fee for this part; not included in `venueFee`. USD, as
            a float.
          type: number
        settlementFee:
          description: >-
            What the venue deducts from this part's payout if the outcome wins
            (Hyperliquid); 0 elsewhere. Not charged at fill, and already taken
            out of `estimatedPayout`. USD, as a float.
          type: number
    SmartRouteSoloQuote:
      type: object
      required:
        - quoteId
        - venue
        - avgPrice
        - filledQty
        - rawExecCost
        - estimatedPayout
        - estimatedProfit
        - returnPct
        - status
        - fills
      properties:
        quoteFailure:
          $ref: '#/components/schemas/QuoteFailure'
        quoteId:
          description: >-
            Quote id to fill on this venue alone; `null` when it is
            display-only.
          type: string
          nullable: true
        unavailableReason:
          description: >-
            Why this venue cannot be filled alone. Open set: known values
            include `geo_blocked`, `insufficient_depth`, `insufficient_balance`,
            `unsupported_venue`, `authentication_required`, `kyc_required`,
            `infeasible`, `min_notional`, `lot_too_small`, `min_quantity`,
            `bridge_amount_too_small`, `unsupported_bridge`,
            `venue_unavailable`.
          type: string
        venue:
          allOf:
            - $ref: '#/components/schemas/Venue'
          description: The venue this option trades on.
        venueMarketOutcomeId:
          description: >-
            Outcome this option trades. One venue can list the same outcome
            twice, so key on `venue` plus this.
          type: string
        avgPrice:
          description: Average price per share on this venue alone, 0 to 1.
          type: number
          nullable: true
        filledQty:
          description: Shares fillable on this venue alone, as a float.
          type: number
        rawExecCost:
          description: Price × shares on this venue alone. USD, as a float.
          type: number
        estimatedPayout:
          description: Payout if the outcome wins, after settlement fees. USD, as a float.
          type: number
        estimatedProfit:
          description: '`estimatedPayout` minus cost. USD, as a float.'
          type: number
        returnPct:
          description: Profit as a percentage of cost (25 = 25%).
          type: number
        totalCostIncFees:
          description: >-
            feeBreakdown.totalCost plus this solo's own user-paid app fee and
            referral — same composition as the primary route's totalCostIncFees.
            estimatedProfit/returnPct stay router values, unaffected. Absent
            when the router sent no feeBreakdown for this solo.
          type: number
        status:
          description: >-
            Result of pricing this venue alone. `ok` when fillable; otherwise a
            reason. Open set: the top-level `status` values plus
            `authentication_required`, or a readable message from the venue.
          type: string
        fills:
          description: Parts of the trade on this venue.
          type: array
          items:
            $ref: '#/components/schemas/SmartRouteFill'
        allocations:
          description: How the trade is funded.
          type: array
          items:
            $ref: '#/components/schemas/SmartRouteAllocation'
        bridgeSteps:
          description: Cross-chain transfers needed.
          type: array
          items:
            $ref: '#/components/schemas/SmartRouteBridgeStep'
        setupCosts:
          description: >-
            One-time setup costs for this venue. Only with `deepEstimate=true`;
            `estimatedProfit` and `returnPct` then include them.
          type: array
          items:
            $ref: '#/components/schemas/SmartRouteSetupCost'
        setupCostsTotal:
          description: Sum of the setup costs not yet paid. USD, as a float.
          type: number
        feeBreakdown:
          description: >-
            Costs of trading on this venue alone, when `status` is `ok`. Use
            this, not the top-level `feeBreakdown`, for a per-venue fee display.
          type: object
          required:
            - rawExecCost
            - venueFees
            - bridgeFees
            - executionGas
            - totalCost
          properties:
            rawExecCost:
              description: >-
                Price × shares, before any fee (proceeds on a sell). USD, as a
                float.
              type: number
            venueFees:
              description: >-
                Venue trading fees, excluding reserves and the builder fee. USD,
                as a float.
              type: number
            builderFee:
              description: >-
                Builder-code fee: your own rate if you have a builder code,
                otherwise the platform default. Not in `venueFees`; included in
                `totalCost`. USD, as a float.
              type: number
            executionReserve:
              minimum: 0
              description: >-
                Additional buy-side clearing-house funding held for slippage or
                possible venue charges, not a confirmed fee. Excluded from
                venueFees and totalCost; funding allocations include it. Unused
                funds are released after execution.
              type: number
            bridgeFees:
              description: >-
                Expected cross-chain transfer fees, including any funding fee.
                USD, as a float.
              type: number
            executionGas:
              description: Estimated network gas for execution. USD, as a float.
              type: number
            totalCost:
              description: >-
                `rawExecCost` + `venueFees` + `builderFee` + `bridgeFees` +
                `executionGas`. Excludes the app and referral fees; see
                `totalCostIncFees`. USD, as a float.
              type: number
            appFee:
              description: >-
                Maximum app fee on this buy, if it fills in full; collected
                after the fill on the amount actually filled. Present only when
                above 0. USD, as a float.
              type: number
            appFeeBips:
              description: App fee rate, in basis points. Present with `appFee`.
              type: number
            appFeeCategory:
              description: >-
                Which of your fee rules matched: `all`, `override` (a per-trade
                `appFeeBips`), or one of your category names.
              type: string
            referralFee:
              description: >-
                Referral fee the user pays. Present only when above 0 and
                `referralPayer` is `user`; an app-paid referral never appears
                here. USD, as a float.
              type: number
    SmartRouteAllocation:
      type: object
      required:
        - sourceChainId
        - venue
        - amount
      properties:
        sourceChainId:
          description: Chain the funds come from, as a decimal chain id string.
          type: string
        venue:
          allOf:
            - $ref: '#/components/schemas/Venue'
          description: Venue these funds pay for.
        amount:
          description: Amount delivered to that venue. USD, as a float.
          type: number
        sourceTokenAddress:
          description: Token contract the funds are drawn from.
          type: string
        custodyKind:
          description: >-
            What holds the funds: `EOA` a wallet, `DEPOSIT_WALLET` a Polymarket
            deposit wallet, `POLYMARKET_LEGACY` a pre-existing Polymarket
            wallet, `VENUE_ACCOUNT` cash at a venue.
          type: string
          enum:
            - EOA
            - DEPOSIT_WALLET
            - POLYMARKET_LEGACY
            - VENUE_ACCOUNT
        custodyAddress:
          description: 'Deposit wallet address, with `custodyKind: DEPOSIT_WALLET`.'
          type: string
        sourceVenueAccountId:
          description: 'With `VENUE_ACCOUNT`: AGG id of the venue account.'
          type: string
        sourceExternalAccountId:
          description: 'With `VENUE_ACCOUNT`: the venue''s own account id.'
          type: string
        sourceAddress:
          description: >-
            Address the funds sit at. Absent on older quotes, where it is the
            signing wallet.
          type: string
        exactToken:
          description: '`true` when this exact token balance is spent.'
          type: boolean
    SmartRouteBridgeStep:
      type: object
      required:
        - sourceChainId
        - destChainId
        - amount
        - cost
      properties:
        sourceChainId:
          description: Chain bridged from, as a decimal string.
          type: string
        destChainId:
          description: Chain bridged to, as a decimal string.
          type: string
        amount:
          description: >-
            Source-side amount sent into the bridge, in USD: the allocations
            this bridge funds plus cost.
          type: number
        cost:
          description: >-
            Delivery margin, in USD, sent on top of the allocations so the
            destination still receives them in full after the bridge takes its
            fee. A planning reserve, not the expected fee: excluded from
            feeBreakdown.bridgeFees and totalCost, and whatever the bridge does
            not charge arrives at the destination as the user's balance. Read
            feeBreakdown.bridgeFees for the expected bridge fee.
          type: number
        sourceTokenAddress:
          description: Token sent.
          type: string
        destTokenAddress:
          description: Token received.
          type: string
    SmartRouteSetupCost:
      type: object
      required:
        - kind
        - venue
        - costUsd
        - alreadyPaid
      properties:
        kind:
          description: >-
            `chainApproval`: a one-time token approval on a chain.
            `venueMarketAta`: a one-time Solana token account for a market.
            `hyperliquidActivation`: Hyperliquid's one-time account activation
            fee.
          type: string
          enum:
            - chainApproval
            - venueMarketAta
            - hyperliquidActivation
        venue:
          allOf:
            - $ref: '#/components/schemas/Venue'
          description: Venue that needs the setup.
        chainId:
          description: Chain of the approval.
          type: number
        venueMarketId:
          description: Market that needs the account.
          type: string
        costUsd:
          description: One-time cost. USD, as a float.
          type: number
        alreadyPaid:
          description: '`true` when the user already did this setup; not charged again.'
          type: boolean
    QuoteError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
        code:
          type: string
          enum:
            - quote_not_found
            - quote_expired
            - quote_already_executed
            - quote_cancelled
            - quote_user_mismatch
            - quote_app_blocked
            - quote_unfillable
            - quote_min_order_size
            - quote_stale_status
            - quote_stale_price
            - quote_insufficient_balance
            - quote_market_inactive
            - quote_self_custody_unsupported_venue
            - quote_self_custody_app_fee
            - quote_self_custody_redeem_unsupported
            - venue_not_executable
            - outcome_ambiguous
    ErrorMessage:
      type: object
      required:
        - message
      properties:
        message:
          type: string
  securitySchemes:
    appId:
      type: apiKey
      in: header
      name: x-app-id
      description: Your application ID. Required for all app-tier and user-tier routes.

````