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

# GMX v2 open interest

> The open interest of one GMX v2 market on Arbitrum, long, short or both, in units of the index token.

**Returns:** open interest in units of the index token (BTC, ETH, ...), 18 decimals (uint256). Exact at the pinned block

- In units of the index token, not USD: GMX shows these times its current price, and keeps no price on chain. Multiply by a price yourself.

- Read from GMX's DataStore (immutable since 2023), one key per collateral token of the side.

A signed round on the derived source: see the document's description for paying with a session or x402.

Template `perp.gmx.openInterest@1` · Perps · GMX · reads EVM

| Route | Answer | Cost |
| - | - | - |
| `GET /v1/data/perp/gmx/openInterest` | The threshold-signed value ([Signed reads](https://docs.molpha.io/data/signed-reads.md)) | One round: x402 or one unit of your plan |
| `GET /v1/data/perp/gmx/openInterest/source` | The source and its `sourceId` | Free |
| `GET /v1/data/perp/gmx/openInterest/dry-run` | A status-only run on one node, no value | Free |

```bash theme={null}
# The source these parameters build, and its sourceId (free)
curl "https://gateway.molpha.io/v1/data/perp/gmx/openInterest/source?chain=arbitrum&market=btc-usdc"

# The signed value with a sign-in session (without one, the answer is the x402 quote)
curl -H "Authorization: Bearer $MOLPHA_SESSION" "https://gateway.molpha.io/v1/data/perp/gmx/openInterest?chain=arbitrum&market=btc-usdc"
```


## OpenAPI

````yaml data-openapi.json GET /v1/data/perp/gmx/openInterest
openapi: 3.1.0
info:
  description: >-
    Every Molpha Data template has its own routes on the gateway. `GET
    /v1/data/<template>` (the template ID with each dot a slash, e.g.
    `token.supply` is `/v1/data/token/supply`) returns the threshold-signed
    value: the template's parameters are query parameters, the gateway derives
    the source and runs a round on it. Pay with a sign-in session
    (`Authorization: Bearer`, one unit of your plan's quota) or with x402:
    without a session the first answer is `402` with the quote in
    `PAYMENT-REQUIRED`; send the same request again with `PAYMENT-SIGNATURE`.
    The value's answer is the execute routes' own (`AttestationResponse`, errors
    as `{status, error}`); failures before the round (a wrong parameter, an
    unknown chain) use the data error body. `/source` and `/dry-run` under each
    template are free and rate-limited per address. To sign with RequestAuth
    instead of a session, take the source from `/source` and post it to `POST
    /v1/round/execute`.
  title: Molpha Data
  version: '1'
servers:
  - url: https://gateway.molpha.io
    description: Molpha gateway (Solana devnet release)
security: []
tags:
  - name: Catalog and sources
  - name: Wallet
  - name: Chain
  - name: DEX
  - name: Derived
  - name: Reference data
  - name: Yield
  - name: Raw state
  - name: Lending
  - name: Oracle
  - name: Perps
  - name: Position
  - name: Token
paths:
  /v1/data/perp/gmx/openInterest:
    get:
      tags:
        - Perps
      summary: GMX v2 open interest
      description: >-
        The open interest of one GMX v2 market on Arbitrum, long, short or both,
        in units of the index token.


        **Returns:** open interest in units of the index token (BTC, ETH, ...),
        18 decimals (uint256). Exact at the pinned block


        - In units of the index token, not USD: GMX shows these times its
        current price, and keeps no price on chain. Multiply by a price
        yourself.


        - Read from GMX's DataStore (immutable since 2023), one key per
        collateral token of the side.


        A signed round on the derived source: see the document's description for
        paying with a session or x402.
      operationId: perp.gmx.openInterest
      parameters:
        - description: CAIP-2 id or alias (Arbitrum chains)
          example: arbitrum
          in: query
          name: chain
          required: true
          schema:
            enum:
              - ethereum
              - eip155:1
              - sepolia
              - eip155:11155111
              - eip155:137
              - eip155:143
              - arbitrum
              - eip155:42161
              - bnb
              - eip155:56
              - base
              - eip155:8453
              - base-sepolia
              - eip155:84532
              - hyperevm
              - eip155:999
            type: string
          x-molpha-type: chain
        - description: >-
            "final" or "fast", or a raw mode: "finalized", "safe",
            "confirmations:<n>" (EVM, Starknet), "confirmed" (Solana)
          in: query
          name: finality
          required: false
          schema:
            default: final
            type: string
          x-molpha-type: finality
        - description: >-
            the market as <index>-<pool>: btc-usdc, btc-btc, eth-usdc, eth-eth,
            sol-usdc, link-usdc, zec-usdg
          example: btc-usdc
          in: query
          name: market
          required: true
          schema:
            enum:
              - btc-btc
              - btc-usdc
              - eth-eth
              - eth-usdc
              - link-usdc
              - sol-usdc
              - zec-usdg
            type: string
          x-molpha-type: enum
        - description: total (long plus short), long or short
          in: query
          name: side
          required: false
          schema:
            default: total
            enum:
              - total
              - long
              - short
            type: string
          x-molpha-type: enum
        - description: >-
            Signatures the round needs (default 3). Tolerance-mode sources need
            at least 3; the gateway bounds it by the protocol minimum, your plan
            and the live nodes.
          in: query
          name: signaturesRequired
          required: false
          schema:
            default: 3
            maximum: 255
            minimum: 1
            type: integer
      responses:
        '200':
          $ref: '#/components/responses/ValueOK'
        '400':
          $ref: '#/components/responses/Value400'
        '401':
          $ref: '#/components/responses/Value401'
        '402':
          $ref: '#/components/responses/Value402'
        '403':
          $ref: '#/components/responses/Value403'
        '409':
          $ref: '#/components/responses/Value409'
        '422':
          $ref: '#/components/responses/Value422'
        '429':
          $ref: '#/components/responses/Value429'
        '503':
          $ref: '#/components/responses/Value503'
        default:
          $ref: '#/components/responses/ValueDefault'
      security:
        - BearerAuth: []
        - X402Payment: []
components:
  responses:
    ValueOK:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AttestationResponse'
      description: >-
        The threshold-signed value (`data.attestation`) and its rendering
        (`data.value`); `Molpha-Source-Id` names the derived source.
    Value400:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: >-
        The round request was refused (for example `signaturesRequired` below
        the protocol minimum); a malformed query is the data error body
    Value401:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: The session token is unknown, expired or revoked
    Value402:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/payment.Required'
      description: >-
        No session and no payment: the x402 quote. Pay it and send the same
        request with `PAYMENT-SIGNATURE`
      headers:
        PAYMENT-REQUIRED:
          description: Base64 x402 v2 payment requirements
          schema:
            type: string
    Value403:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: >-
        The subscription is inactive, the delegate is not authorized, or the
        term's quota is spent
    Value409:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: >-
        You already have a round for this source and quorum in this 100 ms tick;
        retry one tick later
    Value422:
      description: A parameter is wrong, or the chain shows it names something else
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/DataErrorResponse'
    Value429:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/DataErrorResponse'
      description: >-
        Too many new derivations from this address, or too many rounds for this
        consumer; retry after Retry-After
    Value503:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: >-
        No quorum could form now, the gateway is at capacity, or a fact could
        not be read; retry after Retry-After
    ValueDefault:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/DataErrorResponse'
      description: Data error body
  schemas:
    AttestationResponse:
      properties:
        data:
          $ref: '#/components/schemas/AttestationData'
        status:
          example: completed
          type: string
      type: object
    ErrorResponse:
      properties:
        error:
          example: validation failed
          type: string
      type: object
    payment.Required:
      properties:
        accepts:
          items:
            $ref: '#/components/schemas/payment.Requirements'
          type: array
        error:
          type: string
        extensions:
          allOf:
            - $ref: '#/components/schemas/payment.Extensions'
          description: |-
            Extensions carries non-Molpha payment terms, currently the relayed
            upstream-source quote. It never affects the accepted-requirements
            byte comparison performed by Decode.
        resource:
          $ref: '#/components/schemas/payment.Resource'
        x402Version:
          type: integer
      type: object
    DataErrorResponse:
      properties:
        error:
          properties:
            code:
              example: PARAM_INVALID
              type: string
            input:
              type: string
            message:
              type: string
            stage:
              type: string
          type: object
      type: object
    AttestationData:
      properties:
        attestation:
          $ref: '#/components/schemas/Attestation'
        fresh:
          example: true
          type: boolean
        outcome:
          description: >-
            Outcome is present for a source with a policy (node-client
            docs/policy.md): conclusive, the

            value is the source's result; or fallback, the policy concluded
            INCONCLUSIVE (reason) and the

            value is its declared fallback. Both are signed under the source's
            ID. The label is the nodes'

            word: what a consumer can rely on is the signed value compared with
            the declared fallback.
          example: fallback
          type: string
        reason:
          example: '0x01'
          type: string
        roundId:
          description: >-
            RoundID is the round's ID: requests for one feed in one 100 ms tick
            share it. The read service

            serves the round's archive record, and for a source with a policy
            each node's receipt, under it

            (GET /v1/rounds/{roundId}).
          example: 5f1c...
          type: string
        value:
          description: >-
            Value is the decimal rendering of payload.value (trailing zeros
            trimmed), not signed.
          example: '42150125000000'
          type: string
        valuePreimage:
          description: >-
            ValuePreimage is the 0x-prefixed hex of the bytes the source's
            keccak256 output hashed to

            payload.value. It is present only for such a source, and the
            response is its only copy: the

            signed value is the hash. Hash it to check, and pass it as the raw
            value when submitting the

            attestation to Solana.
          example: '0x68656c6c6f'
          type: string
      type: object
    payment.Requirements:
      properties:
        amount:
          type: string
        asset:
          type: string
        extra:
          additionalProperties:
            type: string
          type: object
        maxTimeoutSeconds:
          type: integer
        network:
          type: string
        payTo:
          type: string
        scheme:
          type: string
      type: object
    payment.Extensions:
      properties:
        upstream:
          $ref: '#/components/schemas/payment.UpstreamQuote'
      type: object
    payment.Resource:
      properties:
        description:
          type: string
        mimeType:
          type: string
        url:
          type: string
      type: object
    Attestation:
      properties:
        payload:
          $ref: '#/components/schemas/AttestationPayload'
        signature:
          $ref: '#/components/schemas/SchnorrSignature'
      type: object
    payment.UpstreamQuote:
      properties:
        eligibleSetSize:
          type: integer
        error:
          type: string
        nodeCount:
          type: integer
        provider:
          description: >-
            Provider names the integrated provider whose paid host this is, when
            it is one.
          type: string
        redundancyBuffer:
          type: integer
        resource:
          type: string
        signaturesRequired:
          type: integer
        supportedX402Versions:
          items:
            type: integer
          type: array
      type: object
    AttestationPayload:
      properties:
        registryVersion:
          example: 42
          type: integer
        signaturesRequired:
          example: 18
          type: integer
        sourceId:
          example: 0xabc123...
          type: string
        timestamp:
          description: >-
            Gateway-assigned round time in unix milliseconds: the start of the
            round's 100 ms tick.
          example: 1700100000000
          type: integer
        value:
          description: >-
            Value is the fixed 32-byte packed attestation value (exact uint256
            or tolerance int256).
          example: 42150125000000...
          type: string
      type: object
    SchnorrSignature:
      properties:
        commitment:
          example: 02...
          type: string
        signature:
          example: 01...
          type: string
        signersBitmap:
          type: string
      type: object
  securitySchemes:
    BearerAuth:
      description: >-
        Session token from `POST /v1/session` (sign in with the subscription
        owner's or a delegate's wallet). Each value uses one round of the plan's
        quota.
      scheme: bearer
      type: http
    X402Payment:
      description: >-
        Base64 x402 v2 payment payload for the quote a request without it
        receives (`402`, `PAYMENT-REQUIRED`).
      in: header
      name: PAYMENT-SIGNATURE
      type: apiKey

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.