Skip to main content
Subscriptions use the WebSocket endpoint wss://api.mobula.io/graphql/subscriptions with the graphql-transport-ws protocol.

Returns

onPricesUpdated
Price!
Price update payload (one push per matching swap). See Price.

Arguments

input
[OnPricesUpdatedInput!]!
required
List of tokens to subscribe to. See OnPricesUpdatedInput.
useWeightedPrices
Boolean
When true, subscribe to liquidity-weighted token prices aggregated across all of the token’s pools instead of pair-derived prices. Not supported when any input item provides sourcePairAddress.

Behavior

  • One subscription, many tokens. Events from different tokens in the batch are interleaved.
  • Each matching swap produces one push (per token).
  • The useWeightedPrices flag applies uniformly to all tokens in the batch.

Example — batch of tokens, pair-derived

subscription {
  onPricesUpdated(
    input: [
      { address: "0x6982508145454ce325ddbe47a25d4ec3d2311933", networkId: 1 },
      { address: "So11111111111111111111111111111111111111112", networkId: 1399811149 }
    ]
  ) {
    address
    networkId
    priceUsd
    timestamp
    blockNumber
  }
}

Example — batch with weighted prices

subscription {
  onPricesUpdated(
    input: [
      { address: "0x6982508145454ce325ddbe47a25d4ec3d2311933", networkId: 1 },
      { address: "So11111111111111111111111111111111111111112", networkId: 1399811149 }
    ]
    useWeightedPrices: true
  ) {
    address
    priceUsd
    timestamp
  }
}

Example — mixed pair-pinned and default

subscription {
  onPricesUpdated(
    input: [
      { address: "0x6982508145454ce325ddbe47a25d4ec3d2311933", networkId: 1 },
      {
        address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        networkId: 1,
        sourcePairAddress: "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640"
      }
    ]
  ) {
    address
    priceUsd
    timestamp
  }
}