You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EpochMillisecondsToIsoDateTimeStringSchema is an alias for DateLikeToIsoDateTimeStringSchema, which converts a numeric string via transform(Number) and passes the result to new Date(value) — treating it as milliseconds.
Reproduction
The CLOB REST endpoint /data/trades returns these fields as epoch-seconds strings, e.g. "1710000000". Parsing that value through the current schema:
The correct schema — EpochSecondsStringToIsoDateTimeStringSchema (which multiplies by 1000 before constructing the Date) — is already used for the identical fields in the WebSocket subscription schema at packages/bindings/src/subscriptions/clob.ts:473-475:
ClobTradesPageSchema is consumed by packages/client/src/actions/account.ts:303 against the live /data/trades endpoint. Every caller of listAccountTrades() receives a wrong matchedAt and updatedAt on every trade — off by ~54 years. Any downstream logic that sorts trades by time, displays timestamps, or computes age/TTL will silently produce garbage.
Suggested fix
Replace both occurrences in ClobTradeSchema with EpochSecondsStringToIsoDateTimeStringSchema (already imported/used in subscriptions/clob.ts), or apply the same heuristic guard introduced elsewhere:
The WebSocket path (subscriptions/clob.ts:473-475) already uses the correct seconds schema for these same fields — making the REST and WS schemas asymmetric for match_time and last_update.
Current code
packages/bindings/src/clob/account.ts:128-132EpochMillisecondsToIsoDateTimeStringSchemais an alias forDateLikeToIsoDateTimeStringSchema, which converts a numeric string viatransform(Number)and passes the result tonew Date(value)— treating it as milliseconds.Reproduction
The CLOB REST endpoint
/data/tradesreturns these fields as epoch-seconds strings, e.g."1710000000". Parsing that value through the current schema:The correct schema —
EpochSecondsStringToIsoDateTimeStringSchema(which multiplies by 1000 before constructing theDate) — is already used for the identical fields in the WebSocket subscription schema atpackages/bindings/src/subscriptions/clob.ts:473-475:Impact
ClobTradesPageSchemais consumed bypackages/client/src/actions/account.ts:303against the live/data/tradesendpoint. Every caller oflistAccountTrades()receives a wrongmatchedAtandupdatedAton every trade — off by ~54 years. Any downstream logic that sorts trades by time, displays timestamps, or computes age/TTL will silently produce garbage.Suggested fix
Replace both occurrences in
ClobTradeSchemawithEpochSecondsStringToIsoDateTimeStringSchema(already imported/used insubscriptions/clob.ts), or apply the same heuristic guard introduced elsewhere:Alternatively, mirroring the guard from
BuilderTradeMatchTimeSchema:Either approach fixes the 54-year offset without breaking the schema contract.
Related
74c2cf7) fixed the identical root cause inBuilderTradeSchema.matchTimebut did not updateClobTradeSchema.subscriptions/clob.ts:473-475) already uses the correct seconds schema for these same fields — making the REST and WS schemas asymmetric formatch_timeandlast_update.