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

# List open positions and pending limit orders

> Reads all open positions (with liquidation price, exposure, and the open timestamp needed for close intents) and pending limit orders for a trader, directly from chain via the Multicall aggregator. All numeric values are decimal strings in on-chain units (USDC 1e6, prices/leverage 1e10).



## OpenAPI

````yaml https://tx-builder-testnet.avantisfi.com/openapi.json get /v2/positions
openapi: 3.0.3
info:
  title: Avantis v2 API
  version: 2.0.0
  description: >-
    Calldata builders, EIP-712 intent builders, signed-tx relay, and on-chain
    reads for the Avantis v2 perp protocol.


    **Conventions**

    - Every build/read endpoint accepts both GET (query string) and POST (JSON
    body) with the same fields; POST /v2/relay is POST-only.

    - All amounts are human units: `collateralUsdc: 100` = 100 USDC, `leverage:
    10` = 10x, prices are plain USD decimals. The API does all on-chain scaling.

    - Responses use the `{ ok: true, data }` / `{ ok: false, error: { code,
    message, details } }` envelope.

    - Calldata responses (`to`, `from`, `data`, `value`) are unsigned — the
    caller signs and broadcasts (or submits via POST /v2/relay). `from` is who
    must sign; `value` is hex wei.

    - Intent responses (`domain`, `types`, `primaryType`, `message`) feed
    directly into EIP-712 signTypedData; the Avantis operator executes them
    gas-free for the signer.

    - Trading endpoints are rate-limited per IP.


    Start with GET /v2/meta (addresses, enums, units, defaults) and GET
    /v2/pairs (market catalog).
servers:
  - url: https://tx-builder-testnet.avantisfi.com
security: []
tags:
  - name: meta
    description: Service metadata, pair catalog, health and metrics.
  - name: trading
    description: >-
      Build unsigned transactions for market/limit opens and closes, margin
      changes, and position increases (the direct, self-broadcast route).
  - name: delegate
    description: >-
      Authorize or revoke a delegate key that can trade on behalf of a trader
      (never move funds).
  - name: token
    description: >-
      USDC approval transactions — the one-time prerequisite before trading or
      LP deposits.
  - name: intents
    description: >-
      Build EIP-712 typed-data payloads to sign; the Avantis operator submits
      them on-chain so the signer pays no gas (the relayer route).
  - name: relay
    description: >-
      Submit an already-signed transaction through Avantis-operated RPCs:
      whitelist check, simulation with decoded revert reasons, then broadcast.
  - name: twap
    description: >-
      Time-weighted orders, filled in slices by the operator over a chosen
      duration.
  - name: referral
    description: >-
      Referral code registration, assignment, ownership transfer, and rebate
      claims.
  - name: lp
    description: >-
      Liquidity-provider flows on the Avantis USDC vault (ERC-4626 avUSDC
      tranche).
  - name: misc
    description: Keeper reward claims, vault buffer top-ups, and builder-code registration.
  - name: reads
    description: >-
      On-chain lookups the SDK needs for signing correctness: nonces, positions,
      delegation state, allowances.
paths:
  /v2/positions:
    get:
      tags:
        - reads
      summary: List open positions and pending limit orders
      description: >-
        Reads all open positions (with liquidation price, exposure, and the open
        timestamp needed for close intents) and pending limit orders for a
        trader, directly from chain via the Multicall aggregator. All numeric
        values are decimal strings in on-chain units (USDC 1e6, prices/leverage
        1e10).
      operationId: getV2Positions
      parameters:
        - name: trader
          in: query
          required: true
          description: The trader whose positions and orders are listed.
          schema:
            type: string
            description: The trader whose positions and orders are listed.
      responses:
        '200':
          description: >-
            Success envelope: `ok` is `true` and `data` carries the payload
            documented below.
          content:
            application/json:
              schema:
                type: object
                required:
                  - ok
                  - data
                properties:
                  ok:
                    type: boolean
                    enum:
                      - true
                    description: Always `true` on success.
                  data:
                    type: object
                    description: >-
                      All open positions and pending limit orders for the
                      trader, read from chain.
                    properties:
                      trader:
                        type: string
                        description: The trader queried.
                        example: '0x0000000000000000000000000000000000000000'
                      trades:
                        type: array
                        description: Open positions (empty slots already filtered out).
                        items:
                          type: object
                          description: An aggregated open position.
                          properties:
                            trade:
                              type: object
                              description: >-
                                The on-chain Trade struct. Values are decimal
                                strings in on-chain units (USDC 1e6,
                                prices/leverage 1e10).
                              properties:
                                trader:
                                  type: string
                                  description: Position owner.
                                  example: '0x0000000000000000000000000000000000000000'
                                pairIndex:
                                  type: string
                                  description: Pair index. Decimal string (JSON-safe uint).
                                index:
                                  type: string
                                  description: >-
                                    Per-pair trade slot index — use it in
                                    close/update requests. Decimal string
                                    (JSON-safe uint).
                                initialPosToken:
                                  type: string
                                  description: >-
                                    Internal accounting field. Decimal string
                                    (JSON-safe uint).
                                positionSizeUSDC:
                                  type: string
                                  description: >-
                                    Collateral, USDC 1e6 (misleading on-chain
                                    name — NOT the leveraged size). Decimal
                                    string (JSON-safe uint).
                                openPrice:
                                  type: string
                                  description: >-
                                    Entry price, 1e10-scaled. Decimal string
                                    (JSON-safe uint).
                                buy:
                                  type: boolean
                                  description: '`true` = long, `false` = short.'
                                leverage:
                                  type: string
                                  description: >-
                                    Leverage, 1e10-scaled. Decimal string
                                    (JSON-safe uint).
                                tp:
                                  type: string
                                  description: >-
                                    Take-profit price, 1e10-scaled; 0 = not set.
                                    Decimal string (JSON-safe uint).
                                sl:
                                  type: string
                                  description: >-
                                    Stop-loss price, 1e10-scaled; 0 = not set.
                                    Decimal string (JSON-safe uint).
                                timestamp:
                                  type: string
                                  description: >-
                                    On-chain open timestamp — pass as
                                    `openTimestamp` when building close intents
                                    (it changes on margin updates and partial
                                    closes). Decimal string (JSON-safe uint).
                            tradeInfo:
                              type: object
                              description: Live position bookkeeping.
                              properties:
                                openInterestUSDC:
                                  type: string
                                  description: >-
                                    Position open interest, USDC 1e6. Decimal
                                    string (JSON-safe uint).
                                tpLastUpdated:
                                  type: string
                                  description: >-
                                    Block of the last TP update. Decimal string
                                    (JSON-safe uint).
                                slLastUpdated:
                                  type: string
                                  description: >-
                                    Block of the last SL update. Decimal string
                                    (JSON-safe uint).
                                beingMarketClosed:
                                  type: boolean
                                  description: '`true` while a market close is in flight.'
                                lossProtection:
                                  type: string
                                  description: >-
                                    Loss-protection tier applied at open.
                                    Decimal string (JSON-safe uint).
                            rolloverFee:
                              type: string
                              description: >-
                                Accrued rollover fee, USDC 1e6. Decimal string
                                (JSON-safe uint).
                            liquidationPrice:
                              type: string
                              description: >-
                                Current liquidation price, 1e10-scaled (funding
                                included). Decimal string (JSON-safe uint).
                            isPnl:
                              type: boolean
                              description: >-
                                `true` if opened on the PnL-fee (`market_pnl`)
                                path.
                            coinExposure:
                              type: string
                              description: >-
                                Position exposure in base-asset units,
                                1e10-scaled. Decimal string (JSON-safe uint).
                      orders:
                        type: array
                        description: >-
                          Pending limit / stop-limit orders (empty slots already
                          filtered out).
                        items:
                          type: object
                          description: An aggregated pending order.
                          properties:
                            order:
                              type: object
                              description: >-
                                The on-chain OpenLimitOrder struct (decimal
                                strings, on-chain units).
                              properties:
                                trader:
                                  type: string
                                  description: Order owner.
                                  example: '0x0000000000000000000000000000000000000000'
                                pairIndex:
                                  type: string
                                  description: Pair index. Decimal string (JSON-safe uint).
                                index:
                                  type: string
                                  description: >-
                                    Per-pair order slot index — use it in limit
                                    update/cancel requests. Decimal string
                                    (JSON-safe uint).
                                positionSize:
                                  type: string
                                  description: >-
                                    Collateral, USDC 1e6. Decimal string
                                    (JSON-safe uint).
                                buy:
                                  type: boolean
                                  description: '`true` = long, `false` = short.'
                                leverage:
                                  type: string
                                  description: >-
                                    Leverage, 1e10-scaled. Decimal string
                                    (JSON-safe uint).
                                tp:
                                  type: string
                                  description: >-
                                    Take-profit price, 1e10-scaled; 0 = not set.
                                    Decimal string (JSON-safe uint).
                                sl:
                                  type: string
                                  description: >-
                                    Stop-loss price, 1e10-scaled; 0 = not set.
                                    Decimal string (JSON-safe uint).
                                price:
                                  type: string
                                  description: >-
                                    Trigger price, 1e10-scaled. Decimal string
                                    (JSON-safe uint).
                                slippageP:
                                  type: string
                                  description: >-
                                    Max slippage percent, 1e10-scaled. Decimal
                                    string (JSON-safe uint).
                                block:
                                  type: string
                                  description: >-
                                    Block the order was placed in. Decimal
                                    string (JSON-safe uint).
                                executionFee:
                                  type: string
                                  description: >-
                                    Escrowed execution fee, wei. Decimal string
                                    (JSON-safe uint).
                            liquidationPrice:
                              type: string
                              description: >-
                                Projected liquidation price if filled,
                                1e10-scaled. Decimal string (JSON-safe uint).
                            orderType:
                              type: integer
                              description: >-
                                Limit order type enum (see
                                `enums.limitOrderType` in GET /v2/meta).
                            coinExposure:
                              type: string
                              description: >-
                                Order exposure in base-asset units, 1e10-scaled.
                                Decimal string (JSON-safe uint).
                    required:
                      - trader
                      - trades
                      - orders
        '400':
          description: >-
            Invalid input (failed schema validation or pre-trade checks like
            liquidity, leverage bounds, min position size, or market hours).
          content:
            application/json:
              schema:
                type: object
                required:
                  - ok
                  - error
                properties:
                  ok:
                    type: boolean
                    enum:
                      - false
                    description: Always `false` on errors.
                  error:
                    type: object
                    required:
                      - code
                      - message
                    description: Machine-readable error.
                    properties:
                      code:
                        type: string
                        enum:
                          - BAD_REQUEST
                        description: Stable error code for programmatic handling.
                      message:
                        type: string
                        description: Human-readable explanation of what went wrong.
                      details:
                        description: >-
                          Optional structured context — e.g. Zod validation
                          issues on BAD_REQUEST, or `{ target, revertData,
                          decodedError }` on SIMULATION_FAILED.

````