Polymarket.Schemas.Order (Polymarket v0.1.1)

Copy Markdown View Source

A Polymarket CLOB V2 order — the value that gets EIP-712 signed and posted to POST /order.

Unlike the response schemas in this namespace (which are parsed from JSON), an order is an outbound, caller-constructed value. Its fields mirror the on-chain CTF Exchange V2 order struct.

The eleven signed fields — salt, maker, signer, token_id, maker_amount, taker_amount, side, signature_type, timestamp, metadata, builder — are hashed and signed by Polymarket.Clob.OrderSigner. expiration is not part of the V2 signed struct (it travels on the outer JSON payload), and is carried here only for that later use.

Representation:

  • amounts (maker_amount, taker_amount), salt, token_id, timestamp and expiration are non-negative integers in base units — USDC has 6 decimals, so 1 USDC is 1_000_000;
  • maker and signer are raw 20-byte address binaries;
  • metadata and builder are raw 32-byte binaries (default all-zero);
  • side and signature_type are atoms, mapped to their on-chain integer values by side_value/1 and signature_type_value/1.

Summary

Types

Order direction: :buy (0) or :sell (1).

How the order is authorised on-chain.

t()

Functions

The on-chain uint8 value for a side/0.

The on-chain uint8 value for a signature_type/0.

Types

side()

@type side() :: :buy | :sell

Order direction: :buy (0) or :sell (1).

signature_type()

@type signature_type() :: :eoa | :proxy | :gnosis_safe | :poly1271

How the order is authorised on-chain.

t()

@type t() :: %Polymarket.Schemas.Order{
  builder: <<_::256>>,
  expiration: non_neg_integer(),
  maker: <<_::160>>,
  maker_amount: non_neg_integer(),
  metadata: <<_::256>>,
  salt: non_neg_integer(),
  side: side(),
  signature_type: signature_type(),
  signer: <<_::160>>,
  taker_amount: non_neg_integer(),
  timestamp: non_neg_integer(),
  token_id: non_neg_integer()
}

Functions

side_value(atom)

@spec side_value(side()) :: 0..1

The on-chain uint8 value for a side/0.

signature_type_value(atom)

@spec signature_type_value(signature_type()) :: 0..3

The on-chain uint8 value for a signature_type/0.