Skip to content

PublicNode

Public node reads exposed by the dYdX node client wrapper.

connect

Source code in pkg/src/dydx/node/core.py
@classmethod
async def connect(
  cls, *, url: str = OEGS_GRPC_URL,
  rest_indexer: str = INDEXER_HTTP_URL,
  websocket_indexer: str = INDEXER_WS_URL,
):
  config = make_mainnet( 
    node_url=url,
    rest_indexer=rest_indexer, 
    websocket_indexer=websocket_indexer, 
  ).node
  node: NodeClient = await NodeClient.connect(config)
  return cls(node_client=node)

get_clob_pair

Fetches the order book pair identified by a given ID, allowing users to retrieve detailed information about a specific trading pair within a Central Limit Order Book (CLOB) system.

  • id: The id of the CLOB pair.

dYdX API docs

Source code in pkg/src/dydx/node/public/get_clob_pair.py
async def get_clob_pair(self, id: int) -> ClobPair:
  """
  Fetches the order book pair identified by a given ID, allowing users to retrieve detailed information about a specific trading pair within a Central Limit Order Book (CLOB) system.

  - `id`: The id of the CLOB pair.

  > [dYdX API docs](https://docs.dydx.xyz/node-client/public#get-clob-pair)
  """
  try:
    return await self.node_client.get_clob_pair(id)
  except _InactiveRpcError as e:
    raise ApiError(e._state.code, e._state.details)

get_price

Retrieve the current market price for a specified market, identified by its market ID.

  • id: The id of the CLOB pair.

dYdX API docs

Source code in pkg/src/dydx/node/public/get_price.py
async def get_price(self, id: int):
  """
  Retrieve the current market price for a specified market, identified by its market ID.

  - `id`: The id of the CLOB pair.

  > [dYdX API docs](https://docs.dydx.xyz/node-client/public#get-price)
  """
  try:
    r = await self.node_client.get_price(id)
    return Decimal(r.price) * Decimal(f'1e{r.exponent}')
  except _InactiveRpcError as e:
    raise ApiError(e._state.code, e._state.details)

get_user_fee_tier

Retrieves the perpetual fee tier associated with a specific wallet address, providing information on the user's current fee structure.

  • address: The wallet address that owns the account.

dYdX API docs

Source code in pkg/src/dydx/node/public/get_user_fee_tier.py
async def get_user_fee_tier(self, address: str) -> FeeTier:
  """
  Retrieves the perpetual fee tier associated with a specific wallet address, providing information on the user's current fee structure.

  - `address`: The wallet address that owns the account.

  > [dYdX API docs](https://docs.dydx.xyz/node-client/public#get-fee-tiers)
  """
  try:
    r = await self.node_client.get_user_fee_tier(address)
    return FeeTier(
      maker=Decimal(r.tier.maker_fee_ppm) / Decimal('1e6'),
      taker=Decimal(r.tier.taker_fee_ppm) / Decimal('1e6'),
    )
  except _InactiveRpcError as e:
    raise ApiError(e._state.code, e._state.details)