Polymarket.Schemas.MarketByToken (Polymarket v0.1.1)

Copy Markdown View Source

The parent market for a given token ID, as returned by the CLOB API GET /markets-by-token/:token_id.

Resolves a token ID to its market's condition_id and both the primary (Yes) and secondary (No) token IDs. The CLOB API already delivers snake_case keys, so from_attrs/1 normalisation is a no-op here but kept for consistency with the other schemas.

Summary

Functions

Builds a MarketByToken from the raw (JSON-decoded) CLOB attributes. Keys may be in camelCase (atom or string); they are normalised to the snake_case fields. Returns {:error, {:missing_fields, fields}} when a required field is absent.

Types

t()

@type t() :: %Polymarket.Schemas.MarketByToken{
  condition_id: String.t() | nil,
  primary_token_id: String.t() | nil,
  secondary_token_id: String.t() | nil
}

Functions

from_attrs(attrs)

@spec from_attrs(map()) :: {:ok, t()} | {:error, {:missing_fields, [atom()]}}

Builds a MarketByToken from the raw (JSON-decoded) CLOB attributes. Keys may be in camelCase (atom or string); they are normalised to the snake_case fields. Returns {:error, {:missing_fields, fields}} when a required field is absent.