> ## 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.

# Get service metadata

> Call once at startup. Returns everything a client needs to encode and sign correctly without hard-coding anything: chainId, contract addresses, both EIP-712 signing domains (trading and referral), enum mappings, unit conventions (which fields are seconds vs milliseconds, on-chain scaling), and service defaults.



## OpenAPI

````yaml https://tx-builder-testnet.avantisfi.com/openapi.json get /v2/meta
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/meta:
    get:
      tags:
        - meta
      summary: Get service metadata
      description: >-
        Call once at startup. Returns everything a client needs to encode and
        sign correctly without hard-coding anything: chainId, contract
        addresses, both EIP-712 signing domains (trading and referral), enum
        mappings, unit conventions (which fields are seconds vs milliseconds,
        on-chain scaling), and service defaults.
      operationId: getV2Meta
      parameters: []
      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: >-
                      Everything a client needs to encode and sign correctly
                      without hard-coding.
                    properties:
                      chainId:
                        type: integer
                        description: The chain this deployment targets.
                      addresses:
                        type: object
                        description: >-
                          Avantis contract addresses keyed by name
                          (tradingRouter, tradingStorage, multicall, usdc,
                          tranche, referral, …).
                        properties: {}
                        additionalProperties:
                          type: string
                          description: Contract address.
                          example: '0x0000000000000000000000000000000000000000'
                      eip712:
                        type: object
                        description: Signing domains and signature format.
                        properties:
                          trading:
                            type: object
                            description: >-
                              Domain for trading intents (verifies against the
                              TradingRouter proxy).
                            properties:
                              name:
                                type: string
                                description: Domain name.
                              version:
                                type: string
                                description: Domain version.
                              chainId:
                                type: integer
                                description: Chain id.
                              verifyingContract:
                                type: string
                                description: TradingRouter proxy.
                                example: '0x0000000000000000000000000000000000000000'
                          referral:
                            type: object
                            description: >-
                              Domain for referral intents (verifies against the
                              Referral contract; separate nonce space).
                            properties:
                              name:
                                type: string
                                description: Domain name.
                              version:
                                type: string
                                description: Domain version.
                              chainId:
                                type: integer
                                description: Chain id.
                              verifyingContract:
                                type: string
                                description: Referral contract.
                                example: '0x0000000000000000000000000000000000000000'
                          signatureFormat:
                            type: string
                            description: >-
                              Always `rsv-65-bytes`: contracts require 65-byte
                              r||s||v signatures (EIP-2098 compact signatures
                              revert).
                      enums:
                        type: object
                        description: On-chain enum mappings (name → code).
                        properties:
                          openOrderType:
                            type: object
                            description: Open order types.
                            properties: {}
                            additionalProperties: true
                          marginUpdateType:
                            type: object
                            description: Margin update types.
                            properties: {}
                            additionalProperties: true
                          priceSourcing:
                            type: object
                            description: Price sourcing modes.
                            properties: {}
                            additionalProperties: true
                          limitOrderType:
                            type: object
                            description: Limit order types.
                            properties: {}
                            additionalProperties: true
                          triggerType:
                            type: object
                            description: Partial TP/SL trigger types.
                            properties: {}
                            additionalProperties: true
                      units:
                        type: object
                        description: >-
                          Unit conventions: on-chain scaling factors and time
                          units per field family.
                        properties:
                          price:
                            type: string
                            description: Price scaling, e.g. `1e10`.
                          leverage:
                            type: string
                            description: Leverage scaling.
                          slippagePercent:
                            type: string
                            description: Slippage scaling.
                          coinExposure:
                            type: string
                            description: Coin exposure scaling.
                          usdc:
                            type: string
                            description: USDC scaling.
                          intentDeadline:
                            type: string
                            description: '`milliseconds` — intent deadlines are unix ms.'
                          delegateExpiry:
                            type: string
                            description: '`seconds` — delegate expiries are unix seconds.'
                      defaults:
                        type: object
                        description: >-
                          Service defaults applied when a request omits the
                          field.
                        properties:
                          executionFeeWei:
                            type: string
                            description: Default operator execution fee, wei.
                          intentDeadlineMs:
                            type: number
                            description: Default intent time-to-live, milliseconds.
                          slippagePercent:
                            type: string
                            description: Default slippage percent.
                      glossary:
                        type: object
                        description: >-
                          Contract-field glossary: maps the on-chain vocabulary
                          used in intent messages back to the request
                          parameters.
                        properties: {}
                        additionalProperties:
                          type: string
                          description: Explanation of the on-chain field.
                    required:
                      - chainId
                      - addresses
                      - eip712
                      - enums
                      - units
                      - defaults
        '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.

````