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

# Pool spot price

> A pool's current price: from a concentrated-liquidity pool's square-root price (Uniswap v3 and v4, Slipstream, Whirlpool, Raydium CLMM), a Meteora DLMM pair's active bin, or a v2-style pool's reserves, adjusted for both tokens' decimals.

**Returns:** quote-token units per one base token, 18 decimals; the base is token0 (token A, currency0) unless inverted

- A spot price moves within a block and can be pushed by a single trade; use dex.pool.twap or a liquidity floor for settlement. A v2-style pool's price is its reserve ratio, the cheapest of all to move: set minReserve.

- The price names its quote token. There is no USD conversion; Uniswap v4's native currency (address 0) is the chain's native token, 18 decimals.

- Uniswap v4: the pool id is checked against the key the PositionManager stored for it, so a pool no position was ever opened in is refused. Pools whose hook may return a swap delta (beforeSwapReturnDelta or afterSwapReturnDelta, i.e. a custom curve) are refused: their square-root price need not be the price a swap gets. Dynamic-fee hooks are accepted. v4 pools have no TWAP oracle.

- Aerodrome stable pools (x^3y + y^3x) are refused: their price is not the reserve ratio.

- Solana pools are written every slot, so the Solana form runs in tolerance mode (median of node reads). Every Solana source asserts the pool's owner program (Whirlpool, Raydium CLMM or DLMM).

- Prices below 1e-18 of the quote token round to zero; use invert.

- A Meteora DLMM pair is priced at its active bin, (1 + binStep/10000)^activeId, computed to 36 places with each step rounded down: it agrees with the program's Q64.64 price to about 12 significant digits.

- Version 1 did not assert the owner of Whirlpool and Raydium pools and read only Uniswap v3-style pools on EVM; it is no longer served.

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

Template `dex.pool.price@2` · DEX · spot price as a decimal · reads EVM, Solana

| Route | Answer | Cost |
| - | - | - |
| `GET /v1/data/dex/pool/price` | 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/dex/pool/price/source` | The source and its `sourceId` | Free |
| `GET /v1/data/dex/pool/price/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/dex/pool/price/source?chain=ethereum&pool=0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640"

# 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/dex/pool/price?chain=ethereum&pool=0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640"
```


## OpenAPI

````yaml data-openapi.json GET /v1/data/dex/pool/price
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/dex/pool/price:
    get:
      tags:
        - DEX
      summary: Pool spot price
      description: >-
        A pool's current price: from a concentrated-liquidity pool's square-root
        price (Uniswap v3 and v4, Slipstream, Whirlpool, Raydium CLMM), a
        Meteora DLMM pair's active bin, or a v2-style pool's reserves, adjusted
        for both tokens' decimals.


        **Returns:** quote-token units per one base token, 18 decimals; the base
        is token0 (token A, currency0) unless inverted


        - A spot price moves within a block and can be pushed by a single trade;
        use dex.pool.twap or a liquidity floor for settlement. A v2-style pool's
        price is its reserve ratio, the cheapest of all to move: set minReserve.


        - The price names its quote token. There is no USD conversion; Uniswap
        v4's native currency (address 0) is the chain's native token, 18
        decimals.


        - Uniswap v4: the pool id is checked against the key the PositionManager
        stored for it, so a pool no position was ever opened in is refused.
        Pools whose hook may return a swap delta (beforeSwapReturnDelta or
        afterSwapReturnDelta, i.e. a custom curve) are refused: their
        square-root price need not be the price a swap gets. Dynamic-fee hooks
        are accepted. v4 pools have no TWAP oracle.


        - Aerodrome stable pools (x^3y + y^3x) are refused: their price is not
        the reserve ratio.


        - Solana pools are written every slot, so the Solana form runs in
        tolerance mode (median of node reads). Every Solana source asserts the
        pool's owner program (Whirlpool, Raydium CLMM or DLMM).


        - Prices below 1e-18 of the quote token round to zero; use invert.


        - A Meteora DLMM pair is priced at its active bin, (1 +
        binStep/10000)^activeId, computed to 36 places with each step rounded
        down: it agrees with the program's Q64.64 price to about 12 significant
        digits.


        - Version 1 did not assert the owner of Whirlpool and Raydium pools and
        read only Uniswap v3-style pools on EVM; it is no longer served.


        A signed round on the derived source: see the document's description for
        paying with a session or x402.
      operationId: dex.pool.price
      parameters:
        - description: CAIP-2 id or alias (EVM, Solana chains)
          example: ethereum
          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
              - solana
              - solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
              - solana-devnet
              - solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1
            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: >-
            a Uniswap v3-style pool (Uniswap, PancakeSwap, Sushi v3, Aerodrome
            Slipstream), a v2-style pool (Uniswap v2, Sushi, Aerodrome
            volatile), an Orca Whirlpool, a Raydium CLMM pool or a Meteora DLMM
            pair; give pool or poolId
          example: '0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640'
          in: query
          name: pool
          required: false
          schema:
            type: string
          x-molpha-type: address
        - description: a Uniswap v4 pool id (EVM); give pool or poolId
          in: query
          name: poolId
          required: false
          schema:
            pattern: ^0x[0-9a-fA-F]{64}$
            type: string
          x-molpha-type: bytes32
        - description: 'false: token1 per token0 (token B per token A); true: the inverse'
          in: query
          name: invert
          required: false
          schema:
            default: 'false'
            enum:
              - 'false'
              - 'true'
            type: string
          x-molpha-type: enum
        - description: >-
            v2-style pools only: refuse when the quote token's reserve is below
            this many whole tokens
          in: query
          name: minReserve
          required: false
          schema:
            pattern: ^(0|[1-9][0-9]*)$
            type: string
          x-molpha-type: uint
        - 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.