Polymarket.Activity.Event (Polymarket v0.2.0)

Copy Markdown View Source

Typed struct for a single normalized Polymarket activity event.

Produced by Polymarket.Activity.normalize/1. Each event corresponds to one row from Polymarket's public Data API /activity endpoint and represents either a trade fill (type: :trade with side: :buy | :sell) or a market redemption (type: :redeem).

The original raw map is preserved under the :raw field so callers can recover any field this struct does not normalize without re-parsing.

Fields

  • :type:trade, :redeem, or :unknown.
  • :side:buy, :sell, or nil (always nil for :redeem).
  • :tx_hash — on-chain transaction hash (used to join activity ↔ fills).
  • :condition_id — the market condition id this event belongs to.
  • :token_id — outcome token id (asset id).
  • :usdc_size — fee-inclusive USDC amount. For BUYs this is the wallet debit including taker fee; for SELLs it is the credit. For REDEEMs it is the payout.
  • :shares — number of outcome tokens involved (Polymarket sends this as size on the wire).
  • :price — execution price per share (TRADE only).
  • :timestamp — Unix-seconds timestamp.
  • :raw — the raw map this struct was normalized from.

Summary

Types

side()

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

t()

@type t() :: %Polymarket.Activity.Event{
  condition_id: String.t() | nil,
  price: float() | nil,
  raw: map(),
  shares: float() | nil,
  side: side(),
  timestamp: integer() | nil,
  token_id: String.t() | nil,
  tx_hash: String.t() | nil,
  type: type(),
  usdc_size: float() | nil
}

type()

@type type() :: :trade | :redeem | :unknown