Skip to content

fix(types): OrderBookSummary.tick_size should be TickSize, not string#53

Open
MackDing wants to merge 1 commit intoPolymarket:mainfrom
MackDing:fix/orderbook-tick-size-type
Open

fix(types): OrderBookSummary.tick_size should be TickSize, not string#53
MackDing wants to merge 1 commit intoPolymarket:mainfrom
MackDing:fix/orderbook-tick-size-type

Conversation

@MackDing
Copy link
Copy Markdown

@MackDing MackDing commented Apr 30, 2026

Closes #50

Problem

OrderBookSummary.tick_size was typed as string, but the TickSize literal union already exists in the same file:

export type TickSize = "0.1" | "0.01" | "0.001" | "0.0001";

Consumers who want to feed an order book's tick size back into anything that expects TickSize (CreateOrderOptions.tickSize, isTickSizeSmaller, priceValid, the TickSizes map) have to cast or re-validate — which is exactly what #50 reports.

Change

One-line tightening of the type in OrderBookSummary:

- tick_size: string;
+ tick_size: TickSize;

No runtime change, no API contract change. Just restores end-to-end type safety.

Why this is safe

  • The API only ever returns one of those four values. If it ever returns something else, that would already be a backend bug.
  • Every other surface in this package treats tick size as TickSize; this aligns OrderBookSummary with the rest of the codebase.
  • No test changes needed (the value literal still serializes/deserializes as a string at runtime).

Note

Low Risk
Low risk: this is a TypeScript type tightening only (no runtime/codepath changes) and may only surface compile-time errors for consumers previously treating tick_size as an arbitrary string.

Overview
Updates OrderBookSummary.tick_size in src/types/clob.ts from string to the existing TickSize literal union, aligning order book responses with the rest of the tick-size-typed API surfaces and improving end-to-end type safety for consumers.

Reviewed by Cursor Bugbot for commit 8e5a349. Bugbot is set up for automated code reviews on this repo. Configure here.

Closes Polymarket#50

The OrderBookSummary interface declared tick_size as string, but the
TickSize literal union ('0.1' | '0.01' | '0.001' | '0.0001') already
exists and is used consistently elsewhere (CreateOrderOptions.tickSize,
TickSizes map, isTickSizeSmaller/priceValid helpers).

Returning string forces consumers to cast or re-validate before feeding
the value back into any API that expects TickSize. Tightening the type
restores type-safety end-to-end; the API contract itself is unchanged.
@MackDing MackDing requested a review from a team as a code owner April 30, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Isn't getOrderBook's return type supposed to have tick_size: TickSize?

1 participant