Documentation
¶
Overview ¶
Package clob provides a Go client for the Polymarket CLOB v2 API.
Overview ¶
The CLOB (Central Limit Order Book) v2 API is the primary trading interface for Polymarket. It supports market data queries, order management, position tracking, and RFQ (Request for Quote) workflows.
Authentication Levels ¶
Endpoints require one of three authentication levels:
AuthNone (0) — Public endpoints (market data, orderbook, prices) AuthL1 (1) — EIP-712 wallet signature (CreateAPIKey, DeriveAPIKey) AuthL2 (2) — API key + HMAC secret + wallet signature (orders, trades, positions)
Creating a Client ¶
Read-only (public data):
client := clob.NewClient("")
client := clob.NewClient(clob.V2Host)
With full trading access:
client := clob.NewClient("",
clob.WithCredentials(clob.Credentials{
Key: "your-api-key",
Secret: "your-api-secret",
Passphrase: "your-passphrase",
}),
clob.WithSigner(polyauth.NewSigner(privateKey)),
clob.WithChainID(clob.PolygonChainID),
)
Market Data (No Auth Required) ¶
market := clob.ClobMarketInfo{ConditionID: "0xabc123"}
client.GetClobMarketInfo(ctx, &market)
book := clob.OrderBookSummary{AssetID: "token-id"}
client.GetOrderBook(ctx, &book)
var mid clob.MidpointResponse
client.GetMidpoint(ctx, "token-id", &mid)
var price clob.PriceResponse
client.GetPrice(ctx, "token-id", clob.Buy, &price)
var tick clob.TickSizeResponse
client.GetTickSize(ctx, "token-id", &tick)
Orders & Trading (AuthL2 Required) ¶
client.PostOrder(ctx, clob.PostOrderRequest{...})
client.PostOrders(ctx, []clob.PostOrderRequest{...}, false, false)
client.CancelOrder(ctx, "order-id")
client.GetOpenOrders(ctx, clob.OpenOrderParams{Market: "0x..."})
client.GetTrades(ctx, clob.TradeParams{...})
RFQ (Request for Quote) ¶
client.CreateRFQRequest(ctx, clob.CreateRFQRequest{...})
client.CreateRFQQuote(ctx, clob.CreateRFQQuoteRequest{...})
client.AcceptRFQRequest(ctx, "request-id")
Rewards & Builder APIs ¶
client.GetEarningsForUserForDay(ctx, date, sigType, "") client.GetCurrentRewards(ctx, "") client.GetBuilderFeeRate(ctx, "builder-code")
See README.md for the full endpoint reference.
Index ¶
- Constants
- func BinaryPartition() []*big.Int
- func BuildHMACSignature(secret string, timestamp int64, method, requestPath string, body []byte) (string, error)
- func CollectionID(parentCollectionID common.Hash, conditionID common.Hash, indexSet *big.Int) common.Hash
- func ConditionID(oracle common.Address, questionID common.Hash, outcomeSlotCount uint) common.Hash
- func GenerateKey() (string, error)
- func ParsePrivateKey(raw string) (*polyauth.Signer, error)
- func PositionID(collateralToken common.Address, collectionID common.Hash) *big.Int
- type APIError
- type AssetType
- type Auth
- type BalanceAllowanceParams
- type BalanceAllowanceResponse
- type BanStatus
- type BatchPriceHistoryParams
- type BatchPriceHistoryResponse
- type BookParams
- type BuilderAPIKey
- type BuilderFeeRate
- type BuilderTrade
- type BuilderTradeParams
- type CTFTransaction
- type CancelOrdersResponse
- type CancelRFQQuoteRequest
- type CancelRFQRequest
- type Client
- func (c *Client) AcceptRFQRequest(ctx context.Context, requestID string) error
- func (c *Client) ApproveRFQQuote(ctx context.Context, quoteID string) (map[string]any, error)
- func (c *Client) AreOrdersScoring(ctx context.Context, orderIDs []string) (map[string]bool, error)
- func (c *Client) BuildMergePositionsTx(req MergePositionsRequest, out *CTFTransaction) error
- func (c *Client) BuildRedeemNegRiskTx(req RedeemNegRiskRequest, out *CTFTransaction) error
- func (c *Client) BuildRedeemPositionsTx(req RedeemPositionsRequest, out *CTFTransaction) error
- func (c *Client) BuildSplitPositionTx(req SplitPositionRequest, out *CTFTransaction) error
- func (c *Client) CancelAll(ctx context.Context, out *CancelOrdersResponse) error
- func (c *Client) CancelMarketOrders(ctx context.Context, params OrderMarketCancelParams, out *CancelOrdersResponse) error
- func (c *Client) CancelOrder(ctx context.Context, orderID string, out *CancelOrdersResponse) error
- func (c *Client) CancelOrders(ctx context.Context, orderIDs []string, out *CancelOrdersResponse) error
- func (c *Client) CancelRFQQuote(ctx context.Context, quoteID string) error
- func (c *Client) CancelRFQRequest(ctx context.Context, requestID string) error
- func (c *Client) CreateAPIKey(ctx context.Context, nonce int64, out *Credentials) error
- func (c *Client) CreateBuilderAPIKey(ctx context.Context, out *Credentials) error
- func (c *Client) CreateRFQQuote(ctx context.Context, req CreateRFQQuoteRequest) (map[string]any, error)
- func (c *Client) CreateRFQRequest(ctx context.Context, req CreateRFQRequest) (map[string]any, error)
- func (c *Client) CreateReadonlyAPIKey(ctx context.Context, out *ReadonlyAPIKey) error
- func (c *Client) DeleteAPIKey(ctx context.Context) error
- func (c *Client) DeleteReadonlyAPIKey(ctx context.Context, key string) error
- func (c *Client) DeriveAPIKey(ctx context.Context, nonce int64, out *Credentials) error
- func (c *Client) DropNotifications(ctx context.Context, params DropNotificationParams) error
- func (c *Client) GetAPIKeys(ctx context.Context) ([]Credentials, error)
- func (c *Client) GetBalanceAllowance(ctx context.Context, params BalanceAllowanceParams, ...) error
- func (c *Client) GetBatchPricesHistory(ctx context.Context, params BatchPriceHistoryParams, ...) error
- func (c *Client) GetBuilderAPIKeys(ctx context.Context) ([]BuilderAPIKey, error)
- func (c *Client) GetBuilderFeeRate(ctx context.Context, builderCode string, out *BuilderFeeRate) error
- func (c *Client) GetBuilderTrades(ctx context.Context, params BuilderTradeParams, out *Page[BuilderTrade]) error
- func (c *Client) GetClobMarketInfo(ctx context.Context, out *ClobMarketInfo) error
- func (c *Client) GetClosedOnlyMode(ctx context.Context, out *BanStatus) error
- func (c *Client) GetCurrentRebates(ctx context.Context, params RebateParams) ([]Rebate, error)
- func (c *Client) GetCurrentRewards(ctx context.Context, cursor string, out *Page[CurrentReward]) error
- func (c *Client) GetEarningsForUserForDay(ctx context.Context, date string, signatureType SignatureType, cursor string, ...) error
- func (c *Client) GetFeeRate(ctx context.Context, tokenID string, out *FeeRateResponse) error
- func (c *Client) GetFeeRateByTokenID(ctx context.Context, tokenID string, out *FeeRateResponse) error
- func (c *Client) GetLastTradePrice(ctx context.Context, tokenID string, out *LastTradePriceResponse) error
- func (c *Client) GetLastTradesPrices(ctx context.Context, books []BookParams) ([]LastTradesPricesResponse, error)
- func (c *Client) GetMarket(ctx context.Context, out *Market) error
- func (c *Client) GetMarketByToken(ctx context.Context, out *MarketByToken) error
- func (c *Client) GetMarketTradesEvents(ctx context.Context, conditionID string) ([]Trade, error)
- func (c *Client) GetMarkets(ctx context.Context, cursor string, out *Page[Market]) error
- func (c *Client) GetMidpoint(ctx context.Context, tokenID string, out *MidpointResponse) error
- func (c *Client) GetMidpoints(ctx context.Context, books []BookParams) (map[string]Float64, error)
- func (c *Client) GetNegRisk(ctx context.Context, tokenID string, out *NegRiskResponse) error
- func (c *Client) GetNotifications(ctx context.Context) ([]Notification, error)
- func (c *Client) GetOk(ctx context.Context) (string, error)
- func (c *Client) GetOpenOrders(ctx context.Context, params OpenOrderParams) ([]OpenOrder, error)
- func (c *Client) GetOrder(ctx context.Context, out *OpenOrder) error
- func (c *Client) GetOrderBook(ctx context.Context, out *OrderBookSummary) error
- func (c *Client) GetOrderBooks(ctx context.Context, books []BookParams) ([]OrderBookSummary, error)
- func (c *Client) GetPreMigrationOrders(ctx context.Context, params OpenOrderParams) ([]OpenOrder, error)
- func (c *Client) GetPrice(ctx context.Context, tokenID string, side Side, out *PriceResponse) error
- func (c *Client) GetPrices(ctx context.Context, books []BookParams) (map[string]map[Side]Float64, error)
- func (c *Client) GetPricesHistory(ctx context.Context, params PriceHistoryParams, out *PriceHistoryResponse) error
- func (c *Client) GetRFQBestQuote(ctx context.Context, params RFQListParams, out *RfqQuote) error
- func (c *Client) GetRFQConfig(ctx context.Context) (map[string]any, error)
- func (c *Client) GetRFQQuoterQuotes(ctx context.Context, params RFQListParams, out *Page[RfqQuote]) error
- func (c *Client) GetRFQRequesterQuotes(ctx context.Context, params RFQListParams, out *Page[RfqQuote]) error
- func (c *Client) GetRFQRequests(ctx context.Context, params RFQListParams, out *Page[RfqRequest]) error
- func (c *Client) GetReadonlyAPIKeys(ctx context.Context) ([]ReadonlyAPIKey, error)
- func (c *Client) GetRewardPercentages(ctx context.Context, signatureType SignatureType) (map[string]Float64, error)
- func (c *Client) GetRewardsForMarket(ctx context.Context, conditionID, cursor string, out *Page[MarketReward]) error
- func (c *Client) GetSamplingMarkets(ctx context.Context, cursor string, out *Page[Market]) error
- func (c *Client) GetSamplingSimplifiedMarkets(ctx context.Context, cursor string, out *Page[SimplifiedMarket]) error
- func (c *Client) GetServerTime(ctx context.Context) (int64, error)
- func (c *Client) GetSimplifiedMarkets(ctx context.Context, cursor string, out *Page[SimplifiedMarket]) error
- func (c *Client) GetSpread(ctx context.Context, tokenID string, out *SpreadResponse) error
- func (c *Client) GetSpreads(ctx context.Context, books []BookParams) (map[string]Float64, error)
- func (c *Client) GetTickSize(ctx context.Context, tokenID string, out *TickSizeResponse) error
- func (c *Client) GetTickSizeByTokenID(ctx context.Context, tokenID string, out *TickSizeResponse) error
- func (c *Client) GetTotalEarningsForUserForDay(ctx context.Context, date string, signatureType SignatureType, ...) error
- func (c *Client) GetTrades(ctx context.Context, params TradeParams) ([]Trade, error)
- func (c *Client) GetUserEarningsAndMarketsConfig(ctx context.Context, params EarningsParams, signatureType SignatureType, ...) error
- func (c *Client) GetVersion(ctx context.Context) (int, error)
- func (c *Client) Host() string
- func (c *Client) IsOrderScoring(ctx context.Context, orderID string, out *OrderScoring) error
- func (c *Client) MergePositions(ctx context.Context, req MergePositionsRequest, out *TxReceipt) error
- func (c *Client) PostHeartbeat(ctx context.Context, heartbeatID string, out *HeartbeatResponse) error
- func (c *Client) PostOrder(ctx context.Context, req PostOrderRequest, out *PostOrderResponse) error
- func (c *Client) PostOrders(ctx context.Context, reqs []PostOrderRequest, postOnly, deferExec bool) ([]PostOrderResponse, error)
- func (c *Client) RedeemNegRisk(ctx context.Context, req RedeemNegRiskRequest, out *TxReceipt) error
- func (c *Client) RedeemPositions(ctx context.Context, req RedeemPositionsRequest, out *TxReceipt) error
- func (c *Client) RevokeBuilderAPIKey(ctx context.Context) error
- func (c *Client) SplitPosition(ctx context.Context, req SplitPositionRequest, out *TxReceipt) error
- func (c *Client) SubmitCTFRelayerTransaction(ctx context.Context, tx *CTFTransaction, req RelayerCTFRequest, ...) error
- func (c *Client) SubmitRelayerTransaction(ctx context.Context, req relayer.SubmitTransactionRequest, ...) error
- func (c *Client) UpdateBalanceAllowance(ctx context.Context, params BalanceAllowanceParams, ...) error
- type ClobMarketInfo
- type ClobMarketToken
- type ContractConfig
- type CreateRFQQuoteRequest
- type CreateRFQRequest
- type Credentials
- type CurrentReward
- type Date
- type DropNotificationParams
- type Earning
- type EarningsParams
- type FeeInfo
- type FeeRateResponse
- type Float64
- type GeoblockResponse
- type HeartbeatResponse
- type Int
- type Int64
- type LastTradePriceResponse
- type LastTradesPricesResponse
- type MakerOrder
- type Market
- type MarketByToken
- type MarketOrderArgsV2
- type MarketReward
- type MarketRewardsConfig
- type MergePositionsRequest
- type MidpointResponse
- type NegRiskResponse
- type Notification
- type OpenOrder
- type OpenOrderParams
- type Option
- func WithChainID(chainID int64) Option
- func WithCredentials(creds Credentials) Option
- func WithGeoblockHost(host string) Option
- func WithHTTPClient(h *http.Client) Option
- func WithRPCURL(rpcURL string) Option
- func WithRelayerClient(client *relayer.Client) Option
- func WithRelayerSubmitter(submitter RelayerSubmitter) Option
- func WithServerTime(enabled bool) Option
- func WithSigner(signer *polyauth.Signer) Option
- type OrderArgsV2
- type OrderBookSummary
- type OrderMarketCancelParams
- type OrderScoring
- type OrderSummary
- type OrderType
- type Page
- type PostOrderRequest
- type PostOrderResponse
- type PriceHistoryParams
- type PriceHistoryResponse
- type PricePoint
- type PriceResponse
- type RFQListParams
- type ReadonlyAPIKey
- type Rebate
- type RebateParams
- type RedeemNegRiskRequest
- type RedeemPositionsRequest
- type RelayerCTFRequest
- type RelayerSubmitter
- type RewardRate
- type Rewards
- type RewardsConfig
- type RewardsMarketsParams
- type RfqQuote
- type RfqRequest
- type Side
- type SignatureType
- type SignedOrder
- type SimplifiedMarket
- type SplitPositionRequest
- type SpreadResponse
- type String
- type TickSize
- type TickSizeResponse
- type Time
- type Token
- type Trade
- type TradeParams
- type TxReceipt
- type Uint64
- type UserEarning
- type UserRewardsEarning
- type WSAuth
Constants ¶
const ( MainnetHost = "https://clob.polymarket.com" V2Host = "https://clob-v2.polymarket.com" AmoyHost = "https://clob-v2.polymarket.com" PolygonChainID = 137 AmoyChainID = 80002 ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000" ZeroAddress = "0x0000000000000000000000000000000000000000" )
Variables ¶
This section is empty.
Functions ¶
func BinaryPartition ¶
BinaryPartition returns the standard CTF partition for binary Polymarket markets.
The official CTF docs define index set 1 as the first outcome and index set 2 as the second outcome, so split and merge calls for binary markets use [1, 2].
func BuildHMACSignature ¶
func BuildHMACSignature(secret string, timestamp int64, method, requestPath string, body []byte) (string, error)
BuildHMACSignature returns the Polymarket L2 HMAC signature for a request.
func CollectionID ¶
func CollectionID(parentCollectionID common.Hash, conditionID common.Hash, indexSet *big.Int) common.Hash
CollectionID computes the CTF collection ID for a condition and index set.
func ConditionID ¶
ConditionID computes the CTF condition ID for oracle, question ID, and slot count.
func GenerateKey ¶
GenerateKey creates a new hex-encoded Ethereum private key.
func ParsePrivateKey ¶
ParsePrivateKey parses a hex-encoded Ethereum private key into a Polymarket signer.
Types ¶
type Auth ¶
type Auth struct {
Signer *polyauth.Signer
ChainID int64
Credentials *Credentials
UseServerTime bool
}
Auth stores the signer and API credentials used for authenticated CLOB requests.
type BalanceAllowanceParams ¶
type BalanceAllowanceParams struct {
// AssetType specifies collateral or conditional.
AssetType AssetType `json:"asset_type" url:"asset_type"`
// TokenID is the conditional token (required for conditional assets).
TokenID string `json:"token_id,omitempty" url:"token_id,omitempty"`
// SignatureType identifies the signature method.
SignatureType SignatureType `json:"signature_type,omitempty" url:"signature_type,omitempty"`
}
BalanceAllowanceParams filters balance and allowance queries.
type BalanceAllowanceResponse ¶
type BalanceAllowanceResponse struct {
// Balance is the current token balance.
Balance Float64 `json:"balance"`
// Allowance is the approved amount for the exchange contract.
Allowance Float64 `json:"allowance,omitempty"`
// Allowances maps spender addresses to approved amounts.
Allowances map[string]string `json:"allowances,omitempty"`
}
BalanceAllowanceResponse contains user balance and allowance info.
type BanStatus ¶
type BanStatus struct {
// ClosedOnly is true when the account can only reduce positions.
ClosedOnly bool `json:"closed_only"`
}
BanStatus reports whether a user is in closed-only mode.
type BatchPriceHistoryParams ¶
type BatchPriceHistoryParams struct {
// Markets lists the condition IDs to query.
Markets []string `json:"markets"`
// StartTS is the start Unix timestamp.
StartTS int64 `json:"start_ts,omitempty"`
// EndTS is the end Unix timestamp.
EndTS int64 `json:"end_ts,omitempty"`
// Fidelity controls the data point density.
Fidelity int `json:"fidelity,omitempty"`
// Interval sets the bucket size (e.g. "5m", "1h").
Interval string `json:"interval,omitempty"`
}
BatchPriceHistoryParams is the request body for POST /batch-prices-history.
type BatchPriceHistoryResponse ¶
type BatchPriceHistoryResponse struct {
History map[string][]PricePoint `json:"history"`
}
BatchPriceHistoryResponse contains historical price points keyed by market asset ID.
type BookParams ¶
type BookParams struct {
// TokenID is the conditional token identifier.
TokenID string `json:"token_id" url:"token_id"`
// Side filters by buy or sell, empty means both.
Side Side `json:"side,omitempty" url:"side,omitempty"`
}
BookParams identifies a token/side combination for bulk price queries.
type BuilderAPIKey ¶
type BuilderAPIKey struct {
// Key is the API key value.
Key string `json:"key"`
// CreatedAt is when the key was created.
CreatedAt Time `json:"createdAt"`
// RevokedAt is when the key was revoked, zero if active.
RevokedAt Time `json:"revokedAt"`
}
BuilderAPIKey describes a builder API key.
type BuilderFeeRate ¶
type BuilderFeeRate struct {
// BuilderMakerFeeRateBps is the maker fee in basis points.
BuilderMakerFeeRateBps Int `json:"builderMakerFeeRateBps"`
// BuilderTakerFeeRateBps is the taker fee in basis points.
BuilderTakerFeeRateBps Int `json:"builderTakerFeeRateBps"`
}
BuilderFeeRate contains the fee rates for a builder.
type BuilderTrade ¶
type BuilderTrade struct {
// ID is the trade identifier.
ID string `json:"id"`
// TradeType identifies the trade category.
TradeType string `json:"tradeType"`
// TakerOrderHash is the taker order hash.
TakerOrderHash string `json:"takerOrderHash"`
// Builder is the builder code.
Builder string `json:"builder"`
// Market is the condition ID.
Market string `json:"market"`
// AssetID is the conditional token identifier.
AssetID String `json:"assetId"`
// Side is the trade direction.
Side Side `json:"side"`
// Size is the matched quantity.
Size Float64 `json:"size"`
// SizeUSDC is the quantity in USDC.
SizeUSDC Float64 `json:"sizeUsdc"`
// Price is the execution price.
Price Float64 `json:"price"`
// Status is the trade processing status.
Status string `json:"status"`
// Outcome is the outcome label.
Outcome string `json:"outcome"`
// OutcomeIndex is the 0-based index of the outcome.
OutcomeIndex Int `json:"outcomeIndex"`
// Owner is the trade owner address.
Owner string `json:"owner"`
// Maker is the maker wallet address.
Maker string `json:"maker"`
// TransactionHash is the on-chain transaction hash.
TransactionHash string `json:"transactionHash"`
// MatchTime is when the trade was matched.
MatchTime Time `json:"matchTime"`
// BucketIndex is the price bucket index.
BucketIndex Int `json:"bucketIndex"`
// Fee is the fee amount.
Fee Float64 `json:"fee"`
// FeeUSDC is the fee in USDC.
FeeUSDC Float64 `json:"feeUsdc"`
// ErrMsg contains error details on failure.
ErrMsg string `json:"errMsg"`
// CreatedAt is when the trade record was created.
CreatedAt Time `json:"createdAt"`
// UpdatedAt is the last record update.
UpdatedAt Time `json:"updatedAt"`
}
BuilderTrade represents a trade attributed to a builder.
type BuilderTradeParams ¶
type BuilderTradeParams struct {
// ID filters by trade identifier.
ID string `url:"id,omitempty"`
// MakerAddress filters by maker wallet address.
MakerAddress string `url:"maker,omitempty"`
// Market filters by condition ID.
Market string `url:"market,omitempty"`
// AssetID filters by conditional token identifier.
AssetID string `url:"asset_id,omitempty"`
// Before filters trades before this Unix timestamp.
Before int64 `url:"before,omitempty"`
// After filters trades after this Unix timestamp.
After int64 `url:"after,omitempty"`
// BuilderCode filters by builder attribution code.
BuilderCode string `url:"builder_code,omitempty"`
// NextCursor is the pagination cursor.
NextCursor string `url:"next_cursor,omitempty"`
}
BuilderTradeParams filters GET /builder/trades requests.
type CTFTransaction ¶
type CTFTransaction struct {
// To is the contract address that should receive the transaction.
To common.Address
// Data is the ABI-encoded calldata.
Data []byte
}
CTFTransaction contains the destination contract and calldata for a CTF operation.
type CancelOrdersResponse ¶
type CancelOrdersResponse struct {
// Canceled lists successfully canceled order IDs.
Canceled []string `json:"canceled"`
// NotCanceled maps failed order IDs to error messages.
NotCanceled map[string]string `json:"not_canceled"`
}
CancelOrdersResponse reports cancellation results.
type CancelRFQQuoteRequest ¶
type CancelRFQQuoteRequest struct {
// QuoteID identifies the quote to cancel.
QuoteID string `json:"quoteId"`
}
CancelRFQQuoteRequest is the body for DELETE /rfq/quote.
type CancelRFQRequest ¶
type CancelRFQRequest struct {
// RequestID identifies the RFQ to cancel.
RequestID string `json:"requestId"`
}
CancelRFQRequest is the body for DELETE /rfq/request.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AcceptRFQRequest ¶
func (*Client) ApproveRFQQuote ¶
func (*Client) AreOrdersScoring ¶
func (*Client) BuildMergePositionsTx ¶
func (c *Client) BuildMergePositionsTx(req MergePositionsRequest, out *CTFTransaction) error
BuildMergePositionsTx writes the destination and calldata for mergePositions into out.
func (*Client) BuildRedeemNegRiskTx ¶
func (c *Client) BuildRedeemNegRiskTx(req RedeemNegRiskRequest, out *CTFTransaction) error
BuildRedeemNegRiskTx writes the destination and calldata for neg-risk adapter redemption into out.
func (*Client) BuildRedeemPositionsTx ¶
func (c *Client) BuildRedeemPositionsTx(req RedeemPositionsRequest, out *CTFTransaction) error
BuildRedeemPositionsTx writes the destination and calldata for redeemPositions into out.
func (*Client) BuildSplitPositionTx ¶
func (c *Client) BuildSplitPositionTx(req SplitPositionRequest, out *CTFTransaction) error
BuildSplitPositionTx writes the destination and calldata for splitPosition into out.
func (*Client) CancelAll ¶
func (c *Client) CancelAll(ctx context.Context, out *CancelOrdersResponse) error
func (*Client) CancelMarketOrders ¶
func (c *Client) CancelMarketOrders(ctx context.Context, params OrderMarketCancelParams, out *CancelOrdersResponse) error
func (*Client) CancelOrder ¶
func (*Client) CancelOrders ¶
func (*Client) CancelRFQQuote ¶
func (*Client) CancelRFQRequest ¶
func (*Client) CreateAPIKey ¶
func (*Client) CreateBuilderAPIKey ¶
func (c *Client) CreateBuilderAPIKey(ctx context.Context, out *Credentials) error
func (*Client) CreateRFQQuote ¶
func (*Client) CreateRFQRequest ¶
func (*Client) CreateReadonlyAPIKey ¶
func (c *Client) CreateReadonlyAPIKey(ctx context.Context, out *ReadonlyAPIKey) error
func (*Client) DeleteReadonlyAPIKey ¶
func (*Client) DeriveAPIKey ¶
func (*Client) DropNotifications ¶
func (c *Client) DropNotifications(ctx context.Context, params DropNotificationParams) error
func (*Client) GetAPIKeys ¶
func (c *Client) GetAPIKeys(ctx context.Context) ([]Credentials, error)
func (*Client) GetBalanceAllowance ¶
func (c *Client) GetBalanceAllowance(ctx context.Context, params BalanceAllowanceParams, out *BalanceAllowanceResponse) error
func (*Client) GetBatchPricesHistory ¶
func (c *Client) GetBatchPricesHistory(ctx context.Context, params BatchPriceHistoryParams, out *BatchPriceHistoryResponse) error
func (*Client) GetBuilderAPIKeys ¶
func (c *Client) GetBuilderAPIKeys(ctx context.Context) ([]BuilderAPIKey, error)
func (*Client) GetBuilderFeeRate ¶
func (*Client) GetBuilderTrades ¶
func (c *Client) GetBuilderTrades(ctx context.Context, params BuilderTradeParams, out *Page[BuilderTrade]) error
func (*Client) GetClobMarketInfo ¶
func (c *Client) GetClobMarketInfo(ctx context.Context, out *ClobMarketInfo) error
func (*Client) GetClosedOnlyMode ¶
func (*Client) GetCurrentRebates ¶
func (*Client) GetCurrentRewards ¶
func (*Client) GetEarningsForUserForDay ¶
func (c *Client) GetEarningsForUserForDay(ctx context.Context, date string, signatureType SignatureType, cursor string, out *Page[UserEarning]) error
func (*Client) GetFeeRate ¶
func (*Client) GetFeeRateByTokenID ¶
func (*Client) GetLastTradePrice ¶
func (*Client) GetLastTradesPrices ¶
func (c *Client) GetLastTradesPrices(ctx context.Context, books []BookParams) ([]LastTradesPricesResponse, error)
func (*Client) GetMarketByToken ¶
func (c *Client) GetMarketByToken(ctx context.Context, out *MarketByToken) error
func (*Client) GetMarketTradesEvents ¶
func (*Client) GetMarkets ¶
func (*Client) GetMidpoint ¶
func (*Client) GetMidpoints ¶
func (*Client) GetNegRisk ¶
func (*Client) GetNotifications ¶
func (c *Client) GetNotifications(ctx context.Context) ([]Notification, error)
func (*Client) GetOpenOrders ¶
func (*Client) GetOrderBook ¶
func (c *Client) GetOrderBook(ctx context.Context, out *OrderBookSummary) error
func (*Client) GetOrderBooks ¶
func (c *Client) GetOrderBooks(ctx context.Context, books []BookParams) ([]OrderBookSummary, error)
func (*Client) GetPreMigrationOrders ¶
func (*Client) GetPricesHistory ¶
func (c *Client) GetPricesHistory(ctx context.Context, params PriceHistoryParams, out *PriceHistoryResponse) error
func (*Client) GetRFQBestQuote ¶
func (*Client) GetRFQConfig ¶
func (*Client) GetRFQQuoterQuotes ¶
func (*Client) GetRFQRequesterQuotes ¶
func (*Client) GetRFQRequests ¶
func (c *Client) GetRFQRequests(ctx context.Context, params RFQListParams, out *Page[RfqRequest]) error
func (*Client) GetReadonlyAPIKeys ¶
func (c *Client) GetReadonlyAPIKeys(ctx context.Context) ([]ReadonlyAPIKey, error)
func (*Client) GetRewardPercentages ¶
func (*Client) GetRewardsForMarket ¶
func (*Client) GetSamplingMarkets ¶
func (*Client) GetSamplingSimplifiedMarkets ¶
func (*Client) GetSimplifiedMarkets ¶
func (*Client) GetSpreads ¶
func (*Client) GetTickSize ¶
func (*Client) GetTickSizeByTokenID ¶
func (*Client) GetTotalEarningsForUserForDay ¶
func (c *Client) GetTotalEarningsForUserForDay(ctx context.Context, date string, signatureType SignatureType, out *UserEarning) error
func (*Client) GetUserEarningsAndMarketsConfig ¶
func (c *Client) GetUserEarningsAndMarketsConfig(ctx context.Context, params EarningsParams, signatureType SignatureType, out *Page[UserRewardsEarning]) error
func (*Client) IsOrderScoring ¶
func (*Client) MergePositions ¶
func (c *Client) MergePositions(ctx context.Context, req MergePositionsRequest, out *TxReceipt) error
MergePositions submits a mergePositions transaction and writes its receipt into out.
func (*Client) PostHeartbeat ¶
func (*Client) PostOrder ¶
func (c *Client) PostOrder(ctx context.Context, req PostOrderRequest, out *PostOrderResponse) error
func (*Client) PostOrders ¶
func (c *Client) PostOrders(ctx context.Context, reqs []PostOrderRequest, postOnly, deferExec bool) ([]PostOrderResponse, error)
func (*Client) RedeemNegRisk ¶
RedeemNegRisk submits a neg-risk adapter redemption transaction and writes its receipt into out.
func (*Client) RedeemPositions ¶
func (c *Client) RedeemPositions(ctx context.Context, req RedeemPositionsRequest, out *TxReceipt) error
RedeemPositions submits a redeemPositions transaction and writes its receipt into out.
func (*Client) RevokeBuilderAPIKey ¶
func (*Client) SplitPosition ¶
SplitPosition submits a splitPosition transaction and writes its receipt into out.
func (*Client) SubmitCTFRelayerTransaction ¶
func (c *Client) SubmitCTFRelayerTransaction(ctx context.Context, tx *CTFTransaction, req RelayerCTFRequest, out *relayer.SubmitTransactionResponse) error
SubmitCTFRelayerTransaction submits built CTF calldata through the configured relayer.
func (*Client) SubmitRelayerTransaction ¶
func (c *Client) SubmitRelayerTransaction(ctx context.Context, req relayer.SubmitTransactionRequest, out *relayer.SubmitTransactionResponse) error
SubmitRelayerTransaction submits a pre-signed transaction through the configured relayer.
func (*Client) UpdateBalanceAllowance ¶
func (c *Client) UpdateBalanceAllowance(ctx context.Context, params BalanceAllowanceParams, out *BalanceAllowanceResponse) error
type ClobMarketInfo ¶
type ClobMarketInfo struct {
// ConditionID is the CTF condition identifier.
ConditionID string `json:"c"`
// MinimumTickSize is the price increment granularity.
MinimumTickSize Float64 `json:"mts"`
// MinimumOrderSize is the smallest allowed order.
MinimumOrderSize Float64 `json:"mos"`
// NegRisk indicates a negative-risk market resolution.
NegRisk bool `json:"nr"`
// FeeDetails describes the fee structure.
FeeDetails FeeInfo `json:"fd"`
// Tokens lists the conditional outcome tokens.
Tokens []ClobMarketToken `json:"t"`
// RFQEnabled indicates request-for-quote is active.
RFQEnabled bool `json:"rfqe"`
// MakerBaseFee is the maker fee rate.
MakerBaseFee Float64 `json:"mbf"`
// TakerBaseFee is the taker fee rate.
TakerBaseFee Float64 `json:"tbf"`
}
ClobMarketInfo is the compact market info from GET /clob-markets.
type ClobMarketToken ¶
type ClobMarketToken struct {
// TokenID is the conditional token identifier.
TokenID String `json:"t"`
// Outcome is the outcome label.
Outcome string `json:"o"`
}
ClobMarketToken is a lightweight token in ClobMarketInfo.
type ContractConfig ¶
type ContractConfig struct {
// Exchange is the CTF Exchange V2 contract used for standard market settlement.
Exchange common.Address
// NegRiskExchange is the CTF Exchange V2 contract used for neg-risk market settlement.
NegRiskExchange common.Address
// NegRiskAdapter is the adapter used for neg-risk conversion and redemption flows.
NegRiskAdapter common.Address
// Collateral is the pUSD collateral token used by CTF split, merge, and redeem calls.
Collateral common.Address
// ConditionalTokens is the Gnosis Conditional Tokens contract used by Polymarket.
ConditionalTokens common.Address
// UMAAdapter is the oracle address used when deriving condition IDs from question IDs.
UMAAdapter common.Address
}
ContractConfig contains the on-chain contract addresses used by Polymarket on a chain.
func Contracts ¶
func Contracts(chainID int64) (ContractConfig, error)
Contracts returns the known Polymarket contract addresses for chainID.
type CreateRFQQuoteRequest ¶
type CreateRFQQuoteRequest struct {
// RequestID references the original RFQ request.
RequestID string `json:"requestId"`
// AssetIn is the ERC-20 address being sent.
AssetIn string `json:"assetIn"`
// AssetOut is the ERC-20 address being received.
AssetOut string `json:"assetOut"`
// AmountIn is the input quantity.
AmountIn Float64 `json:"amountIn"`
// AmountOut is the quoted output quantity.
AmountOut Float64 `json:"amountOut"`
// UserType identifies the signature method.
UserType SignatureType `json:"userType"`
}
CreateRFQQuoteRequest is the body for POST /rfq/quote.
type CreateRFQRequest ¶
type CreateRFQRequest struct {
// AssetIn is the ERC-20 address of the asset being sent.
AssetIn string `json:"assetIn"`
// AssetOut is the ERC-20 address of the asset being received.
AssetOut string `json:"assetOut"`
// AmountIn is the input quantity.
AmountIn Float64 `json:"amountIn"`
// AmountOut is the desired output quantity.
AmountOut Float64 `json:"amountOut"`
// UserType identifies the signature method.
UserType SignatureType `json:"userType"`
}
CreateRFQRequest is the body for POST /rfq/request.
type Credentials ¶
type Credentials struct {
// Key is the API key identifier.
Key string `json:"apiKey"`
// Secret is the HMAC secret used to sign requests.
Secret string `json:"secret"`
// Passphrase protects the API key secret.
Passphrase string `json:"passphrase"`
}
Credentials holds Polymarket API authentication material returned by CreateAPIKey.
type CurrentReward ¶
type CurrentReward struct {
// ConditionID is the market condition identifier.
ConditionID string `json:"condition_id"`
// RewardsConfig lists the active reward periods.
RewardsConfig []RewardsConfig `json:"rewards_config"`
// RewardsMaxSpread is the max spread to qualify for rewards.
RewardsMaxSpread Float64 `json:"rewards_max_spread"`
// RewardsMinSize is the minimum order size to qualify.
RewardsMinSize Float64 `json:"rewards_min_size"`
}
CurrentReward describes active reward configuration for a market.
type DropNotificationParams ¶
type DropNotificationParams struct {
// IDs is the list of notification identifiers to drop.
IDs []string `url:"ids,omitempty"`
}
DropNotificationParams identifies notifications to dismiss.
type Earning ¶
type Earning struct {
// AssetAddress is the reward asset contract address.
AssetAddress string `json:"asset_address"`
// Earnings is the total reward amount.
Earnings Float64 `json:"earnings"`
// AssetRate is the reward asset exchange rate.
AssetRate Float64 `json:"asset_rate"`
}
Earning records a single reward earning entry.
type EarningsParams ¶
type EarningsParams struct {
// Date filters by reward date.
Date string `url:"date,omitempty"`
// OrderBy sets the sort field.
OrderBy string `url:"order_by,omitempty"`
// Position sets the result offset.
Position string `url:"position,omitempty"`
// NoCompetition skips low-competition markets.
NoCompetition bool `url:"no_competition,omitempty"`
// NextCursor is the pagination cursor.
NextCursor string `url:"next_cursor,omitempty"`
}
EarningsParams filters GET /rewards/user/markets requests.
type FeeInfo ¶
type FeeInfo struct {
// Rate is the fee rate.
Rate Float64 `json:"r"`
// Exponent is the fee exponent.
Exponent Float64 `json:"e"`
// TakerOnly is true when fees apply only to takers.
TakerOnly bool `json:"to"`
}
FeeInfo describes the fee structure for a CLOB market.
type FeeRateResponse ¶
type FeeRateResponse struct {
// BaseFee is the base fee in basis points.
BaseFee Int `json:"base_fee"`
}
FeeRateResponse contains the base fee rate for a market.
type GeoblockResponse ¶
type GeoblockResponse struct {
// Blocked is true when the IP is in a restricted jurisdiction.
Blocked bool `json:"blocked"`
// IP is the detected client IP.
IP string `json:"ip"`
// Country is the ISO country code.
Country string `json:"country"`
// Region is the geographic region.
Region string `json:"region"`
}
GeoblockResponse reports geographic access restrictions.
type HeartbeatResponse ¶
type HeartbeatResponse struct {
// HeartbeatID is the unique heartbeat identifier.
HeartbeatID string `json:"heartbeat_id"`
// Error contains error details on failure.
Error string `json:"error"`
}
HeartbeatResponse is returned by the heartbeat endpoint.
type LastTradePriceResponse ¶
type LastTradePriceResponse struct {
// Price is the trade price.
Price Float64 `json:"price"`
// Side is the trade direction.
Side Side `json:"side"`
}
LastTradePriceResponse contains the most recent trade price.
type LastTradesPricesResponse ¶
type LastTradesPricesResponse struct {
// TokenID is the conditional token identifier.
TokenID String `json:"token_id"`
// Price is the last trade price.
Price Float64 `json:"price"`
// Side is the trade direction.
Side Side `json:"side"`
}
LastTradesPricesResponse contains per-token last trade prices.
type MakerOrder ¶
type MakerOrder struct {
// OrderID is the order that was filled.
OrderID string `json:"order_id"`
// Owner is the order owner address.
Owner string `json:"owner"`
// MakerAddress is the maker wallet address.
MakerAddress string `json:"maker_address"`
// MatchedAmount is the quantity matched.
MatchedAmount Float64 `json:"matched_amount"`
// Price is the fill price.
Price Float64 `json:"price"`
// FeeRateBps is the fee rate in basis points.
FeeRateBps Float64 `json:"fee_rate_bps"`
// AssetID is the conditional token identifier.
AssetID String `json:"asset_id"`
// Outcome is the outcome label.
Outcome string `json:"outcome"`
// Side is the order direction.
Side Side `json:"side"`
}
MakerOrder represents a single maker fill in a trade.
type Market ¶
type Market struct {
// EnableOrderBook indicates order book functionality is available.
EnableOrderBook bool `json:"enable_order_book"`
// Active is true when the market is accepting trades.
Active bool `json:"active"`
// Closed is true when the market has closed.
Closed bool `json:"closed"`
// Archived is true when the market is archived.
Archived bool `json:"archived"`
// AcceptingOrders indicates the order book is accepting new orders.
AcceptingOrders bool `json:"accepting_orders"`
// AcceptingOrderTimestamp is when the market started accepting orders.
AcceptingOrderTimestamp Time `json:"accepting_order_timestamp"`
// MinimumOrderSize is the smallest allowed order.
MinimumOrderSize Float64 `json:"minimum_order_size"`
// MinimumTickSize is the price increment granularity.
MinimumTickSize Float64 `json:"minimum_tick_size"`
// ConditionID is the CTF condition identifier.
ConditionID string `json:"condition_id"`
// QuestionID identifies the underlying Polymarket question.
QuestionID string `json:"question_id"`
// Question is the market question text.
Question string `json:"question"`
// Description is the market description.
Description string `json:"description"`
// MarketSlug is the URL-friendly market slug.
MarketSlug string `json:"market_slug"`
// EndDateISO is the market resolution date.
EndDateISO Time `json:"end_date_iso"`
// GameStartTime is the event start time.
GameStartTime Time `json:"game_start_time"`
// SecondsDelay is the delay period before order book acceptance.
SecondsDelay Uint64 `json:"seconds_delay"`
// FPMM is the Fixed Product Market Maker address.
FPMM string `json:"fpmm"`
// MakerBaseFee is the maker fee rate.
MakerBaseFee Float64 `json:"maker_base_fee"`
// TakerBaseFee is the taker fee rate.
TakerBaseFee Float64 `json:"taker_base_fee"`
// NotificationsEnabled indicates push notifications are active.
NotificationsEnabled bool `json:"notifications_enabled"`
// NegRisk indicates a negative-risk market resolution.
NegRisk bool `json:"neg_risk"`
// NegRiskMarketID identifies the neg-risk grouping.
NegRiskMarketID string `json:"neg_risk_market_id"`
// NegRiskRequestID is the original request identifier.
NegRiskRequestID string `json:"neg_risk_request_id"`
// Icon is the market icon URL.
Icon string `json:"icon"`
// Image is the market banner image URL.
Image string `json:"image"`
// Rewards contains reward parameters.
Rewards Rewards `json:"rewards"`
// Is5050Outcome is true for binary 50/50 markets.
Is5050Outcome bool `json:"is_50_50_outcome"`
// Tokens lists the conditional outcome tokens.
Tokens []Token `json:"tokens"`
// Tags categorize the market.
Tags []string `json:"tags"`
}
Market is the full CLOB market data structure.
type MarketByToken ¶
type MarketByToken struct {
// ConditionID is the CTF condition identifier.
ConditionID string `json:"condition_id"`
// PrimaryTokenID is the winning outcome token ID.
PrimaryTokenID String `json:"primary_token_id"`
// SecondaryTokenID is the losing outcome token ID.
SecondaryTokenID String `json:"secondary_token_id"`
}
MarketByToken maps a primary and secondary token to a condition.
type MarketOrderArgsV2 ¶
type MarketOrderArgsV2 struct {
// TokenID is the conditional token identifier.
TokenID string `json:"token_id"`
// Amount is the market order quantity.
Amount float64 `json:"amount"`
// Side is the order direction.
Side Side `json:"side"`
// Price is the slippage protection limit price.
Price float64 `json:"price,omitempty"`
// OrderType is the execution type.
OrderType OrderType `json:"order_type,omitempty"`
// UserUSDCBalance is the user's current balance.
UserUSDCBalance float64 `json:"user_usdc_balance,omitempty"`
// BuilderCode is the builder fee split code.
BuilderCode string `json:"builder_code,omitempty"`
Metadata string `json:"metadata,omitempty"`
}
MarketOrderArgsV2 contains arguments for creating a market order.
type MarketReward ¶
type MarketReward struct {
// ConditionID is the market condition identifier.
ConditionID string `json:"condition_id"`
// Question is the market question text.
Question string `json:"question"`
// MarketSlug is the URL-friendly market slug.
MarketSlug string `json:"market_slug"`
// EventSlug is the parent event slug.
EventSlug string `json:"event_slug"`
// Image is the market banner image URL.
Image string `json:"image"`
// RewardsMaxSpread is the max spread to qualify.
RewardsMaxSpread Float64 `json:"rewards_max_spread"`
// RewardsMinSize is the minimum order size to qualify.
RewardsMinSize Float64 `json:"rewards_min_size"`
// MarketCompetitiveness indicates market saturation.
MarketCompetitiveness Float64 `json:"market_competitiveness"`
// Tokens lists the conditional outcome tokens.
Tokens []Token `json:"tokens"`
// RewardsConfig lists the active reward periods.
RewardsConfig []MarketRewardsConfig `json:"rewards_config"`
}
MarketReward describes reward eligibility for a specific market.
type MarketRewardsConfig ¶
type MarketRewardsConfig struct {
// ID is the config identifier.
ID String `json:"id"`
// AssetAddress is the reward asset contract address.
AssetAddress string `json:"asset_address"`
// StartDate is the reward start date.
StartDate Date `json:"start_date"`
// EndDate is the reward end date.
EndDate Date `json:"end_date"`
// RatePerDay is the daily reward rate.
RatePerDay Float64 `json:"rate_per_day"`
// TotalRewards is the total reward pool.
TotalRewards Float64 `json:"total_rewards"`
// TotalDays is the duration in days.
TotalDays Float64 `json:"total_days"`
}
MarketRewardsConfig describes the reward period for one market asset.
type MergePositionsRequest ¶
type MergePositionsRequest struct {
// CollateralToken is the pUSD token address received after merging a full set.
CollateralToken common.Address
// ParentCollectionID is zero for top-level Polymarket markets.
ParentCollectionID common.Hash
// ConditionID is the market condition ID.
ConditionID common.Hash
// Partition is the list of index sets to burn; binary markets use [1, 2].
Partition []*big.Int
// Amount is the number of full outcome sets to merge, in base units.
Amount *big.Int
}
MergePositionsRequest describes a ConditionalTokens mergePositions call.
func MergeBinary ¶
func MergeBinary(collateral common.Address, conditionID common.Hash, amount *big.Int) MergePositionsRequest
MergeBinary returns a mergePositions request for a standard binary Polymarket market.
type MidpointResponse ¶
type MidpointResponse struct {
// Mid is the midpoint between best bid and best ask.
Mid Float64 `json:"mid"`
}
MidpointResponse contains the order book midpoint price.
type NegRiskResponse ¶
type NegRiskResponse struct {
// NegRisk is true for neg-risk markets.
NegRisk bool `json:"neg_risk"`
}
NegRiskResponse indicates whether a market uses neg-risk resolution.
type Notification ¶
type Notification struct {
// Type identifies the notification category.
Type Int `json:"type"`
// Owner is the recipient address.
Owner string `json:"owner"`
// Payload contains the notification data.
Payload jsonRawObject `json:"payload"`
}
Notification is a user notification from the CLOB.
type OpenOrder ¶
type OpenOrder struct {
// ID is the order identifier.
ID string `json:"id"`
// Status is the current order status.
Status string `json:"status"`
// Owner is the order owner address.
Owner string `json:"owner"`
// MakerAddress is the maker wallet address.
MakerAddress string `json:"maker_address"`
// Market is the condition ID the order belongs to.
Market string `json:"market"`
// AssetID is the conditional token identifier.
AssetID String `json:"asset_id"`
// Side is the order direction.
Side Side `json:"side"`
// OriginalSize is the initial order quantity.
OriginalSize Float64 `json:"original_size"`
// SizeMatched is the quantity already filled.
SizeMatched Float64 `json:"size_matched"`
// Price is the limit price.
Price Float64 `json:"price"`
// AssociateTrades lists the trade IDs from fills.
AssociateTrades []string `json:"associate_trades"`
// Outcome is the outcome label.
Outcome string `json:"outcome"`
// CreatedAt is when the order was placed.
CreatedAt Time `json:"created_at"`
// Expiration is the order expiry time.
Expiration Time `json:"expiration"`
// OrderType is the execution type.
OrderType OrderType `json:"order_type"`
}
OpenOrder represents an active order returned by GET /data/orders.
type OpenOrderParams ¶
type OpenOrderParams struct {
// ID filters by order identifier.
ID string `url:"id,omitempty"`
// Market filters by condition ID.
Market string `url:"market,omitempty"`
// AssetID filters by conditional token identifier.
AssetID string `url:"asset_id,omitempty"`
}
OpenOrderParams filters GET /data/orders requests.
type Option ¶
type Option func(*Client)
Option customizes a CLOB client created by NewClient.
func WithChainID ¶
WithChainID sets the EVM chain ID used for auth signatures and CTF transactions.
func WithCredentials ¶
func WithCredentials(creds Credentials) Option
WithCredentials sets Polymarket API credentials for L2-authenticated requests.
func WithGeoblockHost ¶
WithGeoblockHost sets the host used by geoblock-related requests.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client used for REST requests.
func WithRPCURL ¶
WithRPCURL sets the Polygon JSON-RPC endpoint used by on-chain CTF helpers.
func WithRelayerClient ¶
WithRelayerClient sets the Polymarket Relayer API client used by CTF helpers.
func WithRelayerSubmitter ¶
func WithRelayerSubmitter(submitter RelayerSubmitter) Option
WithRelayerSubmitter sets the relayer used by SubmitRelayerTransaction helpers.
func WithServerTime ¶
WithServerTime makes authenticated requests use the CLOB server timestamp.
func WithSigner ¶
WithSigner sets the signer used for L1 and L2 authenticated requests.
type OrderArgsV2 ¶
type OrderArgsV2 struct {
// TokenID is the conditional token identifier.
TokenID string `json:"token_id"`
// Price is the limit price.
Price float64 `json:"price"`
// Size is the order quantity.
Size float64 `json:"size"`
// Side is the order direction.
Side Side `json:"side"`
// Expiration is the order expiry Unix timestamp (0 = GTC).
Expiration int64 `json:"expiration,omitempty"`
// BuilderCode is the builder fee split code.
BuilderCode string `json:"builder_code,omitempty"`
// Metadata is optional caller-provided metadata.
Metadata string `json:"metadata,omitempty"`
}
OrderArgsV2 contains arguments for creating a limit order.
type OrderBookSummary ¶
type OrderBookSummary struct {
// Market is the condition ID.
Market string `json:"market"`
// AssetID is the token ID.
AssetID String `json:"asset_id"`
// Timestamp is when the snapshot was taken.
Timestamp Time `json:"timestamp"`
// Bids are buy orders sorted best-first.
Bids []OrderSummary `json:"bids"`
// Asks are sell orders sorted best-first.
Asks []OrderSummary `json:"asks"`
// MinOrderSize is the minimum order quantity.
MinOrderSize Float64 `json:"min_order_size"`
// NegRisk indicates a negative-risk market.
NegRisk bool `json:"neg_risk"`
// TickSize is the minimum price increment.
TickSize Float64 `json:"tick_size"`
// LastTradePrice is the price of the most recent trade.
LastTradePrice Float64 `json:"last_trade_price"`
// Hash is the order book snapshot hash.
Hash string `json:"hash"`
}
OrderBookSummary is a snapshot of the order book for a single asset.
type OrderMarketCancelParams ¶
type OrderMarketCancelParams struct {
// Market is the condition ID to cancel orders for.
Market string `json:"market,omitempty"`
// AssetID is the conditional token to cancel.
AssetID string `json:"asset_id,omitempty"`
}
OrderMarketCancelParams targets orders for partial cancellation.
type OrderScoring ¶
type OrderScoring struct {
// Scoring is true when the order is in the scoring queue.
Scoring bool `json:"scoring"`
}
OrderScoring reports whether an order is actively scoring.
type OrderSummary ¶
type OrderSummary struct {
// Price is the limit order price.
Price Float64 `json:"price"`
// Size is the available quantity at this price.
Size Float64 `json:"size"`
}
OrderSummary represents a single price/size level in an order book.
type Page ¶
type Page[T any] struct { // Limit is the requested page size. Limit Int `json:"limit"` // Count is the number of results on this page. Count Int `json:"count"` // NextCursor is the pagination cursor for the next page, empty when exhausted. NextCursor string `json:"next_cursor"` // Data contains the page results. Data []T `json:"data"` }
Page wraps a paginated CLOB API response.
type PostOrderRequest ¶
type PostOrderRequest struct {
// Order is the signed order payload.
Order SignedOrder `json:"order"`
// Owner is the order owner address.
Owner string `json:"owner"`
// OrderType is the execution type (GTC, FOK, GTD).
OrderType OrderType `json:"orderType"`
}
PostOrderRequest wraps a SignedOrder for POST /order.
type PostOrderResponse ¶
type PostOrderResponse struct {
// Success is true when the order was accepted.
Success bool `json:"success"`
// ErrorMsg contains the error description on failure.
ErrorMsg string `json:"errorMsg"`
// OrderID is the assigned order identifier.
OrderID string `json:"orderID"`
// TransactionHashes lists on-chain transaction hashes.
TransactionHashes []string `json:"transactionsHashes"`
// Status is the order processing status.
Status string `json:"status"`
// TakingAmount is the amount filled from the order.
TakingAmount Float64 `json:"takingAmount"`
// MakingAmount is the remaining order amount.
MakingAmount Float64 `json:"makingAmount"`
// TradeIDs lists the resulting trade identifiers.
TradeIDs []string `json:"trade_ids"`
}
PostOrderResponse is returned after order submission.
type PriceHistoryParams ¶
type PriceHistoryParams struct {
// Market is the condition ID.
Market string `url:"market,omitempty"`
// StartTS is the start Unix timestamp.
StartTS int64 `url:"startTs,omitempty"`
// EndTS is the end Unix timestamp.
EndTS int64 `url:"endTs,omitempty"`
// Fidelity controls the data point density.
Fidelity int `url:"fidelity,omitempty"`
// Interval sets the bucket size (e.g. "5m", "1h").
Interval string `url:"interval,omitempty"`
}
PriceHistoryParams filters GET /prices-history requests.
type PriceHistoryResponse ¶
type PriceHistoryResponse struct {
// History is the ordered list of price points.
History []PricePoint `json:"history"`
}
PriceHistoryResponse contains a time series of price points.
type PricePoint ¶
type PricePoint struct {
// T is the Unix timestamp.
T Int64 `json:"t"`
// P is the price at time T.
P Float64 `json:"p"`
}
PricePoint is a single timestamped price record.
type PriceResponse ¶
type PriceResponse struct {
// Price is the current price.
Price Float64 `json:"price"`
}
PriceResponse contains the current price for a token/side.
type RFQListParams ¶
type RFQListParams struct {
// Offset is the start index.
Offset string `url:"offset,omitempty"`
// Limit sets the maximum returned results.
Limit int `url:"limit,omitempty"`
// State filters by quote/request state.
State string `url:"state,omitempty"`
// RequestIDs filters by request IDs.
RequestIDs []string `url:"requestIds,omitempty"`
// QuoteIDs filters by quote IDs.
QuoteIDs []string `url:"quoteIds,omitempty"`
// Markets filters by condition IDs.
Markets []string `url:"markets,omitempty"`
// SizeMin filters by minimum trade size.
SizeMin Float64 `url:"sizeMin,omitempty"`
// SizeMax filters by maximum trade size.
SizeMax Float64 `url:"sizeMax,omitempty"`
// SizeUSDCMin filters by minimum USDC value.
SizeUSDCMin Float64 `url:"sizeUsdcMin,omitempty"`
// SizeUSDCMax filters by maximum USDC value.
SizeUSDCMax Float64 `url:"sizeUsdcMax,omitempty"`
// PriceMin filters by minimum price.
PriceMin Float64 `url:"priceMin,omitempty"`
// PriceMax filters by maximum price.
PriceMax Float64 `url:"priceMax,omitempty"`
// SortBy sets the sort field.
SortBy string `url:"sortBy,omitempty"`
// SortDir sets the sort direction (asc/desc).
SortDir string `url:"sortDir,omitempty"`
}
RFQListParams filters GET /rfq/data/* listing endpoints.
type ReadonlyAPIKey ¶
type ReadonlyAPIKey struct {
// APIKey is the read-only key value.
APIKey string `json:"apiKey"`
}
ReadonlyAPIKey describes a read-only API key.
type Rebate ¶
type Rebate struct {
// Date is the rebate date.
Date Date `json:"date"`
// ConditionID is the market condition identifier.
ConditionID string `json:"condition_id"`
// AssetAddress is the reward asset contract address.
AssetAddress string `json:"asset_address"`
// MakerAddress is the maker wallet address.
MakerAddress string `json:"maker_address"`
// RebatedFeesUSDC is the total rebated fee in USDC.
RebatedFeesUSDC Float64 `json:"rebated_fees_usdc"`
}
Rebate documents current rebated fees for a maker on one market asset.
type RebateParams ¶
type RebateParams struct {
// Date filters by reward date.
Date string `url:"date,omitempty"`
// MakerAddress filters by maker wallet address.
MakerAddress string `url:"maker_address,omitempty"`
}
RebateParams filters current maker rebate requests.
type RedeemNegRiskRequest ¶
type RedeemNegRiskRequest struct {
// ConditionID is the resolved neg-risk condition ID.
ConditionID common.Hash
// Amounts contains the per-index-set amounts expected by the neg-risk adapter.
Amounts []*big.Int
}
RedeemNegRiskRequest describes a neg-risk adapter redemption call.
type RedeemPositionsRequest ¶
type RedeemPositionsRequest struct {
// CollateralToken is the pUSD token address redeemed after market resolution.
CollateralToken common.Address
// ParentCollectionID is zero for top-level Polymarket markets.
ParentCollectionID common.Hash
// ConditionID is the resolved market condition ID.
ConditionID common.Hash
// IndexSets are the outcome index sets to redeem; binary markets use [1, 2].
IndexSets []*big.Int
}
RedeemPositionsRequest describes a ConditionalTokens redeemPositions call.
func RedeemBinary ¶
func RedeemBinary(collateral common.Address, conditionID common.Hash) RedeemPositionsRequest
RedeemBinary returns a redeemPositions request for a resolved binary Polymarket market.
type RelayerCTFRequest ¶
type RelayerCTFRequest struct {
// From is the signer address.
From string
// ProxyWallet is the user's Polymarket proxy wallet.
ProxyWallet string
// Nonce is the relayer transaction nonce.
Nonce string
// Signature is the 0x-prefixed Safe or proxy transaction signature.
Signature string
// SignatureParams are Safe transaction parameters.
SignatureParams relayer.SignatureParams
// Type is the relayer transaction type, typically SAFE or PROXY.
Type string
// Metadata is optional caller-provided transaction metadata.
Metadata string
// Value is the native token value for the call when required.
Value string
}
RelayerCTFRequest contains the relayer metadata needed to submit CTF calldata.
type RelayerSubmitter ¶
type RelayerSubmitter interface {
SubmitTransaction(context.Context, relayer.SubmitTransactionRequest, *relayer.SubmitTransactionResponse) error
}
RelayerSubmitter is the relayer capability used by CLOB CTF helpers.
type RewardRate ¶
type RewardRate struct {
// AssetAddress is the reward asset contract address.
AssetAddress string `json:"asset_address"`
// RewardsDailyRate is the daily reward amount.
RewardsDailyRate Float64 `json:"rewards_daily_rate"`
}
RewardRate describes daily rewards for a specific asset.
type Rewards ¶
type Rewards struct {
// Rates is the list of asset-specific reward rates.
Rates []RewardRate `json:"rates"`
// MinSize is the minimum order size to qualify for rewards.
MinSize Float64 `json:"min_size"`
// MaxSpread is the maximum bid-ask spread to qualify for rewards.
MaxSpread Float64 `json:"max_spread"`
}
Rewards contains reward parameters for a market.
type RewardsConfig ¶
type RewardsMarketsParams ¶
type RewardsMarketsParams struct {
// ConditionID filters by market ID.
ConditionID string `url:"condition_id,omitempty"`
// Date filters by reward date.
Date string `url:"date,omitempty"`
// NextCursor is the pagination cursor.
NextCursor string `url:"next_cursor,omitempty"`
}
RewardsMarketsParams filters GET /rewards/markets requests.
type RfqQuote ¶
type RfqQuote struct {
// QuoteID is the unique quote identifier.
QuoteID string `json:"quoteId"`
// RequestID references the original RFQ request.
RequestID string `json:"requestId"`
// UserAddress is the requester wallet address.
UserAddress string `json:"userAddress"`
// ProxyAddress is the proxy wallet address.
ProxyAddress string `json:"proxyAddress"`
// Condition is the condition the quote applies to.
Condition string `json:"condition"`
// Token is the asset being offered.
Token String `json:"token"`
// Complement is the complementary asset.
Complement String `json:"complement"`
// Side is the trade direction.
Side Side `json:"side"`
// SizeIn is the input quantity.
SizeIn Float64 `json:"sizeIn"`
// SizeOut is the output quantity.
SizeOut Float64 `json:"sizeOut"`
// Price is the quoted price.
Price Float64 `json:"price"`
}
RfqQuote represents a quote generated in response to an RFQ.
type RfqRequest ¶
type RfqRequest struct {
// RequestID is the unique request identifier.
RequestID string `json:"requestId"`
// UserAddress is the requester wallet address.
UserAddress string `json:"userAddress"`
// ProxyAddress is the proxy wallet address.
ProxyAddress string `json:"proxyAddress"`
// Condition is the condition the request applies to.
Condition string `json:"condition"`
// Token is the asset being offered.
Token String `json:"token"`
// Complement is the complementary asset.
Complement String `json:"complement"`
// Side is the requested trade direction.
Side Side `json:"side"`
// SizeIn is the input quantity.
SizeIn Float64 `json:"sizeIn"`
// SizeOut is the output quantity.
SizeOut Float64 `json:"sizeOut"`
// Price is the requested price.
Price Float64 `json:"price"`
// Expiry is the request expiry Unix timestamp.
Expiry Int64 `json:"expiry"`
}
RfqRequest represents an RFQ (request for quote) submission.
type SignatureType ¶
type SignatureType int
const ( SignatureTypeEOA SignatureType = iota SignatureTypeProxy SignatureTypeGnosisSafe )
type SignedOrder ¶
type SignedOrder struct {
// Salt is the order uniqueness salt.
Salt String `json:"salt"`
// Maker is the order creator address.
Maker string `json:"maker"`
// Signer is the signing authority address.
Signer string `json:"signer"`
// Taker is the order taker address (empty for any).
Taker string `json:"taker,omitempty"`
// TokenID is the conditional token identifier.
TokenID String `json:"tokenId"`
// MakerAmount is the amount the maker offers.
MakerAmount String `json:"makerAmount"`
// TakerAmount is the amount the maker wants.
TakerAmount String `json:"takerAmount"`
// Expiration is the order expiry timestamp.
Expiration String `json:"expiration,omitempty"`
// Nonce is the order nonce.
Nonce String `json:"nonce,omitempty"`
// FeeRateBps is the fee rate in basis points.
FeeRateBps String `json:"feeRateBps,omitempty"`
// Side is the order direction.
Side Side `json:"side"`
// SignatureType identifies the signature method.
SignatureType SignatureType `json:"signatureType"`
// Timestamp is when the order was created.
Timestamp String `json:"timestamp"`
// Metadata is optional order metadata.
Metadata string `json:"metadata"`
// Builder is the builder code for fee splits.
Builder string `json:"builder"`
// Signature is the EIP-712 signature bytes.
Signature string `json:"signature"`
}
SignedOrder is an EIP-712 signed order ready for submission.
type SimplifiedMarket ¶
type SimplifiedMarket struct {
// ConditionID is the CTF condition identifier.
ConditionID string `json:"condition_id"`
// Tokens lists the conditional outcome tokens.
Tokens []Token `json:"tokens"`
// Rewards contains reward parameters.
Rewards Rewards `json:"rewards"`
// Active is true when the market is accepting trades.
Active bool `json:"active"`
// Closed is true when the market has closed.
Closed bool `json:"closed"`
// Archived is true when the market is archived.
Archived bool `json:"archived"`
// AcceptingOrders indicates the order book is accepting new orders.
AcceptingOrders bool `json:"accepting_orders"`
}
SimplifiedMarket is a lightweight market record.
type SplitPositionRequest ¶
type SplitPositionRequest struct {
// CollateralToken is the pUSD token address supplied as collateral.
CollateralToken common.Address
// ParentCollectionID is zero for top-level Polymarket markets.
ParentCollectionID common.Hash
// ConditionID is the market condition ID.
ConditionID common.Hash
// Partition is the list of index sets to mint; binary markets use [1, 2].
Partition []*big.Int
// Amount is the pUSD amount, in base units, to split into a full outcome set.
Amount *big.Int
}
SplitPositionRequest describes a ConditionalTokens splitPosition call.
func SplitBinary ¶
func SplitBinary(collateral common.Address, conditionID common.Hash, amount *big.Int) SplitPositionRequest
SplitBinary returns a splitPosition request for a standard binary Polymarket market.
type SpreadResponse ¶
type SpreadResponse struct {
// Spread is the difference between best ask and best bid.
Spread Float64 `json:"spread"`
}
SpreadResponse contains the current bid-ask spread.
type TickSizeResponse ¶
type TickSizeResponse struct {
// MinimumTickSize is the minimum price increment.
MinimumTickSize TickSize `json:"minimum_tick_size"`
}
TickSizeResponse contains the minimum price increment.
type Token ¶
type Token struct {
// TokenID is the ERC-1155 token identifier.
TokenID String `json:"token_id"`
// Outcome is the outcome label (e.g. "Yes", "No").
Outcome string `json:"outcome"`
// Price is the current market price.
Price Float64 `json:"price"`
// Winner is true when this outcome has been resolved as correct.
Winner bool `json:"winner,omitempty"`
}
Token represents a conditional outcome token.
type Trade ¶
type Trade struct {
// ID is the trade identifier.
ID string `json:"id"`
// TakerOrderID is the taker's order ID.
TakerOrderID string `json:"taker_order_id"`
// Market is the condition ID.
Market string `json:"market"`
// AssetID is the conditional token identifier.
AssetID String `json:"asset_id"`
// Side is the trade direction.
Side Side `json:"side"`
// Size is the matched quantity.
Size Float64 `json:"size"`
// FeeRateBps is the fee rate in basis points.
FeeRateBps Float64 `json:"fee_rate_bps"`
// Price is the execution price.
Price Float64 `json:"price"`
// Status is the trade processing status.
Status string `json:"status"`
// MatchTime is when the trade was matched.
MatchTime Time `json:"match_time"`
// LastUpdate is the last status change.
LastUpdate Time `json:"last_update"`
// Outcome is the outcome label.
Outcome string `json:"outcome"`
// BucketIndex is the price bucket index.
BucketIndex Int `json:"bucket_index"`
// Owner is the trade owner address.
Owner string `json:"owner"`
// MakerAddress is the maker wallet address.
MakerAddress string `json:"maker_address"`
// MakerOrders lists the maker orders that were filled.
MakerOrders []MakerOrder `json:"maker_orders"`
// TransactionHash is the on-chain transaction hash.
TransactionHash string `json:"transaction_hash"`
// TraderSide identifies taker or maker role.
TraderSide string `json:"trader_side"`
// ErrorMsg contains error details on failure.
ErrorMsg string `json:"error_msg"`
}
Trade represents a matched fill between maker and taker.
type TradeParams ¶
type TradeParams struct {
// ID filters by trade identifier.
ID string `url:"id,omitempty"`
// TakerAddress filters by taker wallet address.
TakerAddress string `url:"taker,omitempty"`
// MakerAddress filters by maker wallet address.
MakerAddress string `url:"maker,omitempty"`
// Market filters by condition ID.
Market string `url:"market,omitempty"`
// AssetID filters by conditional token identifier.
AssetID string `url:"asset_id,omitempty"`
// Before filters trades before this Unix timestamp.
Before int64 `url:"before,omitempty"`
// After filters trades after this Unix timestamp.
After int64 `url:"after,omitempty"`
}
TradeParams filters GET /data/trades requests.
type TxReceipt ¶
type TxReceipt struct {
// Hash is the transaction hash.
Hash common.Hash
// BlockNumber is the block that included the transaction.
BlockNumber uint64
}
TxReceipt is the minimal transaction receipt returned by CTF helpers.
type UserEarning ¶
type UserEarning struct {
// Date is the earning date.
Date Date `json:"date"`
// ConditionID is the market condition identifier.
ConditionID string `json:"condition_id"`
// AssetAddress is the reward asset contract address.
AssetAddress string `json:"asset_address"`
// MakerAddress is the maker wallet address.
MakerAddress string `json:"maker_address"`
// Earnings is the total reward earned in USDC.
Earnings Float64 `json:"earnings"`
// AssetRate is the reward asset exchange rate.
AssetRate Float64 `json:"asset_rate"`
}
UserEarning records a maker's reward earning for one market asset.
type UserRewardsEarning ¶
type UserRewardsEarning struct {
ConditionID string `json:"condition_id"`
Question string `json:"question"`
MarketSlug string `json:"market_slug"`
EventSlug string `json:"event_slug"`
Image string `json:"image"`
RewardsMaxSpread Float64 `json:"rewards_max_spread"`
RewardsMinSize Float64 `json:"rewards_min_size"`
MarketCompetitiveness Float64 `json:"market_competitiveness"`
Tokens []Token `json:"tokens"`
RewardsConfig []RewardsConfig `json:"rewards_config"`
MakerAddress string `json:"maker_address"`
EarningPercentage Float64 `json:"earning_percentage"`
Earnings []Earning `json:"earnings"`
}
type WSAuth ¶
type WSAuth struct {
// APIKey is the WebSocket API key.
APIKey string `json:"apiKey"`
// Secret is the WebSocket HMAC secret.
Secret string `json:"secret"`
// Passphrase protects the WebSocket API key.
Passphrase string `json:"passphrase"`
}
WSAuth holds WebSocket authentication material.