Skip to content

Protocol Types (polytypes)

The internal/polytypes package defines protocol-level types shared across polygolem clients. Gamma market-discovery DTOs now live publicly in pkg/types and are aliased here for internal callers. Public SDK users should import pkg/types for Gamma, Data API, and read-only CLOB contracts, pkg/clob for authenticated CLOB account/trading contracts, and pkg/stream for public market WebSocket contracts. Enrichment, rewards, and authenticated user-stream contracts still use internal protocol types until their public SDK slices are promoted.

Markets

type Market struct {
ID string `json:"id"`
ConditionID string `json:"conditionId"`
Question string `json:"question"`
Slug string `json:"slug"`
Outcomes StringOrArray `json:"outcomes"`
OutcomePrices StringOrArray `json:"outcomePrices"`
ClobTokenIDs string `json:"clobTokenIds"` // JSON array string
Active bool `json:"active"`
Closed bool `json:"closed"`
AcceptingOrders bool `json:"acceptingOrders"`
EnableOrderBook bool `json:"enableOrderBook"`
OrderPriceMinTickSize float64 `json:"orderPriceMinTickSize"`
OrderMinSize float64 `json:"orderMinSize"`
Events []Event `json:"events,omitempty"`
LastTradePrice float64 `json:"lastTradePrice"`
BestBid float64 `json:"bestBid"`
BestAsk float64 `json:"bestAsk"`
}

Events

type Event struct {
ID string `json:"id"`
Title string `json:"title"`
Slug string `json:"slug"`
Description string `json:"description"`
Markets []Market `json:"markets"`
EnableOrderBook bool `json:"enableOrderBook"`
ParentEvent string `json:"parentEvent"`
SubEvents []string `json:"subEvents,omitempty"`
Active bool `json:"active"`
Closed bool `json:"closed"`
EventDate NormalizedTime `json:"eventDate"`
EventWeek int `json:"eventWeek"`
EventCreators []EventCreator `json:"eventCreators,omitempty"`
Tags []Tag `json:"tags,omitempty"`
}

CLOB — Order Books

type OrderBook struct {
Market string `json:"market"` // conditionID
AssetID string `json:"asset_id"` // tokenID
Bids []OrderBookLevel `json:"bids"`
Asks []OrderBookLevel `json:"asks"`
}
type OrderBookLevel struct {
Price string `json:"price"`
Size string `json:"size"`
}

CLOB — V2 Order Envelope

type signedOrderPayload struct {
Salt uint64 `json:"salt"`
Maker string `json:"maker"` // deposit wallet address
Signer string `json:"signer"` // deposit wallet address
TokenID string `json:"tokenId"`
MakerAmount string `json:"makerAmount"`
TakerAmount string `json:"takerAmount"`
Side string `json:"side"`
Expiration string `json:"expiration"`
SignatureType int `json:"signatureType"` // 3 = POLY_1271
Timestamp string `json:"timestamp"`
Metadata string `json:"metadata"` // V2: bytes32
Builder string `json:"builder"` // V2: bytes32 builder code
Signature string `json:"signature"` // POLY_1271: 0x + 634 hex chars
}

This payload is the posted order object. The V2 signed struct omits expiration; it signs salt, maker, signer, tokenId, makerAmount, takerAmount, side, signatureType, timestamp, metadata, and builder. Polygolem emits builder = bytes32(0) by default. Set a non-zero code with pkg/clob.Config.BuilderCode, pkg/universal.Config.BuilderCode, CLI --builder-code, or POLYMARKET_BUILDER_CODE.

CLOB — Market Data

type CLOBFeeDetails struct {
Rate float64 `json:"rate,omitempty"`
Exponent float64 `json:"exponent,omitempty"`
TakerOnly bool `json:"taker_only,omitempty"`
}
type CLOBMarket struct {
ConditionID string `json:"condition_id"`
QuestionID string `json:"question_id"`
GameStartTime string `json:"game_start_time,omitempty"`
Tokens []Token `json:"tokens"`
OrderPriceMinTickSize float64 `json:"order_price_min_tick_size"`
OrderMinSize float64 `json:"order_min_size"`
MakerBaseFee int `json:"maker_base_fee"`
TakerBaseFee int `json:"taker_base_fee"`
RFQEnabled bool `json:"rfq_enabled,omitempty"`
FeeDetails CLOBFeeDetails `json:"fee_details,omitempty"`
// ...additional fields
}
type CLOBPaginatedMarkets struct {
Data []CLOBMarket `json:"data"`
NextCursor string `json:"next_cursor"`
Limit int `json:"limit"`
}
type PriceHistory struct {
History []PricePoint `json:"history"`
}
type PricePoint struct {
T time.Time `json:"t"`
P float64 `json:"p"`
}

CLOB — Responses

type TickSize struct {
MinimumTickSize string `json:"minimum_tick_size"`
MinimumOrderSize string `json:"minimum_order_size"`
TickSize string `json:"tick_size"`
}
type NegRiskInfo struct {
NegRisk bool `json:"neg_risk"`
}
type ServerTime struct {
Timestamp string `json:"timestamp"`
ISO string `json:"iso"`
}

CLOB — Trades & Orders (V2)

type OrderRecord struct {
ID string `json:"id"`
Status string `json:"status"`
Market string `json:"market"`
AssetID string `json:"asset_id"`
Side string `json:"side"`
OriginalSize string `json:"original_size"`
SizeMatched string `json:"size_matched"`
Price string `json:"price"`
Outcome string `json:"outcome"`
Type string `json:"type"`
SignatureType int `json:"signature_type"`
CreatedAt string `json:"created_at"`
Expiration string `json:"expiration"`
MakerAddress string `json:"maker_address"`
AssociateTrades []string `json:"associate_trades,omitempty"`
}
type TradeRecord struct {
ID string `json:"id"`
Status string `json:"status"`
Market string `json:"market"`
AssetID string `json:"asset_id"`
Side string `json:"side"`
Price string `json:"price"`
Size string `json:"size"`
FeeRateBps string `json:"fee_rate_bps"`
Outcome string `json:"outcome"`
Owner string `json:"owner"`
Builder string `json:"builder"`
TransactionHash string `json:"transaction_hash"`
CreatedAt string `json:"created_at"`
}
type CancelOrdersResponse struct {
Canceled []string `json:"canceled"`
NotCanceled map[string]string `json:"not_canceled"`
}

Discovery — Enriched Market

type EnrichedMarket struct {
Market Market `json:"market"`
TickSize TickSize `json:"tick_size"`
NegRisk bool `json:"neg_risk"`
FeeRateBps int `json:"fee_rate_bps"`
OrderBook *OrderBook `json:"order_book,omitempty"`
LastPrice string `json:"last_price,omitempty"`
Midpoint string `json:"midpoint,omitempty"`
Spread string `json:"spread,omitempty"`
}

Query Parameters

type GetMarketsParams struct {
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
Order string `json:"order,omitempty"`
Ascending *bool `json:"ascending,omitempty"`
Slug []string `json:"slug,omitempty"`
ConditionIDs []string `json:"condition_ids,omitempty"`
TagID *int `json:"tag_id,omitempty"`
RelatedTags *bool `json:"related_tags,omitempty"`
Closed *bool `json:"closed,omitempty"`
Active *bool `json:"active,omitempty"`
}
type GetEventsParams struct {
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
Order string `json:"order,omitempty"`
Ascending *bool `json:"ascending,omitempty"`
Slug []string `json:"slug,omitempty"`
TagID *int `json:"tag_id,omitempty"`
RelatedTags *bool `json:"related_tags,omitempty"`
Featured *bool `json:"featured,omitempty"`
Closed *bool `json:"closed,omitempty"`
Recurrence string `json:"recurrence,omitempty"`
}
type SearchParams struct {
Q string `json:"q"`
LimitPerType *int `json:"limit_per_type,omitempty"`
Page *int `json:"page,omitempty"`
EventsTag []string `json:"events_tag,omitempty"`
EventsStatus string `json:"events_status,omitempty"`
Ascending *bool `json:"ascending,omitempty"`
Sort string `json:"sort,omitempty"`
SearchProfiles *bool `json:"search_profiles,omitempty"`
}
type KeysetParams struct {
Limit int `json:"limit,omitempty"`
KeysetID string `json:"keyset_id,omitempty"`
Ascending *bool `json:"ascending,omitempty"`
Active *bool `json:"active,omitempty"`
Closed *bool `json:"closed,omitempty"`
Order string `json:"order,omitempty"`
}

See Also