Polymarket.Clob.OrderPayload (Polymarket v0.1.1)

Copy Markdown View Source

Serialises signed Polymarket.Schemas.Orders into the JSON wire body the CLOB expects — a single SendOrder object for POST /order, or a JSON array of them for the batch POST /orders.

The body is produced once, as a string, so the L2 HMAC can sign exactly the bytes that go on the wire. Field formats mirror the reference client: salt is a JSON number; tokenId, makerAmount, takerAmount, expiration and timestamp are decimal strings; maker/signer are lowercase 0x hex; metadata/builder are 0x+64 hex; side is "BUY"/"SELL"; signatureType is a number. expiration rides on the wire body (for GTD/expiry) even though it is not part of the signed V2 struct.

Summary

Functions

Builds the JSON SendOrder body string for a caller-constructed Polymarket.Schemas.SendOrder (signed order + owner + time-in-force + flags).

Builds the JSON array body string for the batch POST /orders from a list of caller-constructed Polymarket.Schemas.SendOrders.

Functions

serialize(send_order)

@spec serialize(Polymarket.Schemas.SendOrder.t()) :: String.t()

Builds the JSON SendOrder body string for a caller-constructed Polymarket.Schemas.SendOrder (signed order + owner + time-in-force + flags).

post_only/defer_exec are omitted from the body when nil, matching the reference client.

serialize_many(send_orders)

@spec serialize_many([Polymarket.Schemas.SendOrder.t()]) :: String.t()

Builds the JSON array body string for the batch POST /orders from a list of caller-constructed Polymarket.Schemas.SendOrders.

Each element is the identical object serialize/1 produces for a single order, in the given order. The CLOB caps a batch at 15 orders; this only serialises, so the server enforces that limit.