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

# Hyperliquid-shaped /exchange

> Accepts the Hyperliquid `POST /exchange` envelope `{action, nonce, signature, vaultAddress?, expiresAfter?}` with Hyperliquid's exact signing (msgpack action hash, phantom agent EIP-712 on chain id 1337; user-signed actions on the `HyperliquidSignTransaction` domain). The signing agent must be a Gains agent: one `approveAgent` plus one `setTradingDelegate` transaction by the master wallet. Custody actions (`usdSend`, `withdraw3`, `spotSend`, vaults, sub-accounts) return an `err` envelope: funds never leave the wallet.



## OpenAPI

````yaml /developer/trading-api/openapi.json post /hl/{chain}/exchange
openapi: 3.1.0
info:
  title: Gains Trading API
  version: 1.0.0
  description: >-
    Native REST and WebSocket API for trading on Gains Network.
    Resource-oriented, JSON in and out, decimal strings for every price and
    size, one EIP-712 signing scheme, and an order lifecycle that hides the
    oracle two-step.
servers:
  - url: https://api.gains.trade
security: []
tags:
  - name: Markets
    description: Public market data
  - name: Account
    description: 'Private reads: balances, positions, orders, fills'
  - name: Orders
    description: Place, update and cancel orders
  - name: Positions
    description: Close and manage open positions
  - name: Agents
    description: Non-custodial agent authorisation
  - name: System
    description: Health
paths:
  /hl/{chain}/exchange:
    post:
      tags:
        - Hyperliquid compatibility
      summary: Hyperliquid-shaped /exchange
      description: >-
        Accepts the Hyperliquid `POST /exchange` envelope `{action, nonce,
        signature, vaultAddress?, expiresAfter?}` with Hyperliquid's exact
        signing (msgpack action hash, phantom agent EIP-712 on chain id 1337;
        user-signed actions on the `HyperliquidSignTransaction` domain). The
        signing agent must be a Gains agent: one `approveAgent` plus one
        `setTradingDelegate` transaction by the master wallet. Custody actions
        (`usdSend`, `withdraw3`, `spotSend`, vaults, sub-accounts) return an
        `err` envelope: funds never leave the wallet.
      operationId: hlExchange
      parameters:
        - schema:
            type: string
            enum:
              - arbitrum
              - base
              - polygon
              - megaeth
              - arbitrum-sepolia
            example: arbitrum
          required: true
          name: chain
          in: path
      requestBody:
        description: Hyperliquid exchange envelope
        content:
          application/json:
            schema:
              type: object
              additionalProperties: {}
      responses:
        '200':
          description: >-
            `{status: "ok" | "err", response}`; order statuses add `{pending:
            {oid, txHash}}` for the oracle step
          content:
            application/json:
              schema: {}
        '422':
          description: Malformed envelope
          content:
            text/plain:
              schema:
                type: string

````