@keystrokehq/polymarket 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,69 @@
1
+ import { D as createPolymarketClient, E as polymarketOperation, l as marketSchema, s as listMarketsParamsSchema, w as tagSchema } from "./schemas-C6SqZjA-.mjs";
2
+ import { z } from "zod";
3
+
4
+ //#region src/markets.ts
5
+ /**
6
+ * polymarket/markets.ts
7
+ *
8
+ * Steps for listing, getting, and querying Polymarket markets via the Gamma API.
9
+ */
10
+ const listMarkets = polymarketOperation({
11
+ id: "list_polymarket_markets",
12
+ name: "List Polymarket Markets",
13
+ description: "List and filter markets with extensive query params via the Gamma API",
14
+ input: listMarketsParamsSchema,
15
+ output: z.array(marketSchema),
16
+ run: async (input, credentials) => {
17
+ return createPolymarketClient(credentials).request({
18
+ host: "gamma",
19
+ method: "GET",
20
+ path: "/markets",
21
+ query: input
22
+ });
23
+ }
24
+ });
25
+ const getMarket = polymarketOperation({
26
+ id: "get_polymarket_market",
27
+ name: "Get Polymarket Market",
28
+ description: "Get a single market by ID from the Gamma API",
29
+ input: z.object({ id: z.string() }),
30
+ output: marketSchema,
31
+ run: async (input, credentials) => {
32
+ return createPolymarketClient(credentials).request({
33
+ host: "gamma",
34
+ method: "GET",
35
+ path: `/markets/${input.id}`
36
+ });
37
+ }
38
+ });
39
+ const getMarketBySlug = polymarketOperation({
40
+ id: "get_polymarket_market_by_slug",
41
+ name: "Get Polymarket Market by Slug",
42
+ description: "Get a single market by slug from the Gamma API",
43
+ input: z.object({ slug: z.string() }),
44
+ output: marketSchema,
45
+ run: async (input, credentials) => {
46
+ return createPolymarketClient(credentials).request({
47
+ host: "gamma",
48
+ method: "GET",
49
+ path: `/markets/slug/${input.slug}`
50
+ });
51
+ }
52
+ });
53
+ const getMarketTags = polymarketOperation({
54
+ id: "get_polymarket_market_tags",
55
+ name: "Get Polymarket Market Tags",
56
+ description: "Get tags for a market by market ID from the Gamma API",
57
+ input: z.object({ id: z.string() }),
58
+ output: z.array(tagSchema),
59
+ run: async (input, credentials) => {
60
+ return createPolymarketClient(credentials).request({
61
+ host: "gamma",
62
+ method: "GET",
63
+ path: `/markets/${input.id}/tags`
64
+ });
65
+ }
66
+ });
67
+
68
+ //#endregion
69
+ export { getMarket, getMarketBySlug, getMarketTags, listMarkets };
@@ -0,0 +1,65 @@
1
+ import { z } from "zod";
2
+ import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
3
+ import * as _keystrokehq_core0 from "@keystrokehq/core";
4
+
5
+ //#region src/orderbook.d.ts
6
+ declare const getOrderBook: _keystrokehq_core0.Operation<z.ZodObject<{
7
+ tokenID: z.ZodString;
8
+ }, z.core.$strip>, z.ZodObject<{
9
+ market: z.ZodOptional<z.ZodString>;
10
+ asset_id: z.ZodString;
11
+ timestamp: z.ZodOptional<z.ZodString>;
12
+ hash: z.ZodOptional<z.ZodString>;
13
+ bids: z.ZodArray<z.ZodObject<{
14
+ price: z.ZodString;
15
+ size: z.ZodString;
16
+ }, z.core.$strip>>;
17
+ asks: z.ZodArray<z.ZodObject<{
18
+ price: z.ZodString;
19
+ size: z.ZodString;
20
+ }, z.core.$strip>>;
21
+ min_order_size: z.ZodOptional<z.ZodString>;
22
+ tick_size: z.ZodOptional<z.ZodString>;
23
+ neg_risk: z.ZodOptional<z.ZodBoolean>;
24
+ }, z.core.$loose>, readonly [_keystrokehq_core0.CredentialSet<"polymarket", z.ZodObject<{
25
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
26
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
27
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
28
+ }, z.core.$strip>>[] | undefined>], undefined>;
29
+ declare const batchGetOrderBooks: _keystrokehq_core0.Operation<z.ZodObject<{
30
+ tokenIDs: z.ZodArray<z.ZodString>;
31
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
32
+ market: z.ZodOptional<z.ZodString>;
33
+ asset_id: z.ZodString;
34
+ timestamp: z.ZodOptional<z.ZodString>;
35
+ hash: z.ZodOptional<z.ZodString>;
36
+ bids: z.ZodArray<z.ZodObject<{
37
+ price: z.ZodString;
38
+ size: z.ZodString;
39
+ }, z.core.$strip>>;
40
+ asks: z.ZodArray<z.ZodObject<{
41
+ price: z.ZodString;
42
+ size: z.ZodString;
43
+ }, z.core.$strip>>;
44
+ min_order_size: z.ZodOptional<z.ZodString>;
45
+ tick_size: z.ZodOptional<z.ZodString>;
46
+ neg_risk: z.ZodOptional<z.ZodBoolean>;
47
+ }, z.core.$loose>>, readonly [_keystrokehq_core0.CredentialSet<"polymarket", z.ZodObject<{
48
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
49
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
50
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
51
+ }, z.core.$strip>>[] | undefined>], undefined>;
52
+ declare const batchGetSpreads: _keystrokehq_core0.Operation<z.ZodObject<{
53
+ tokenIDs: z.ZodArray<z.ZodString>;
54
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
55
+ asset_id: z.ZodString;
56
+ spread: z.ZodString;
57
+ bid: z.ZodOptional<z.ZodString>;
58
+ ask: z.ZodOptional<z.ZodString>;
59
+ }, z.core.$loose>>, readonly [_keystrokehq_core0.CredentialSet<"polymarket", z.ZodObject<{
60
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
61
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
62
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
63
+ }, z.core.$strip>>[] | undefined>], undefined>;
64
+ //#endregion
65
+ export { batchGetOrderBooks, batchGetSpreads, getOrderBook };
@@ -0,0 +1,58 @@
1
+ import { C as spreadSchema, D as createPolymarketClient, E as polymarketOperation, f as orderBookSummarySchema } from "./schemas-C6SqZjA-.mjs";
2
+ import { z } from "zod";
3
+
4
+ //#region src/orderbook.ts
5
+ /**
6
+ * polymarket/orderbook.ts
7
+ *
8
+ * Steps for order book data via the CLOB API.
9
+ * Prices and sizes are returned as strings.
10
+ */
11
+ const getOrderBook = polymarketOperation({
12
+ id: "get_polymarket_order_book",
13
+ name: "Get Polymarket Order Book",
14
+ description: "Get order book (bids/asks) for a token via the CLOB API",
15
+ input: z.object({ tokenID: z.string() }),
16
+ output: orderBookSummarySchema,
17
+ run: async (input, credentials) => {
18
+ return createPolymarketClient(credentials).request({
19
+ host: "clob",
20
+ method: "GET",
21
+ path: "/book",
22
+ query: { token_id: input.tokenID }
23
+ });
24
+ }
25
+ });
26
+ const batchGetOrderBooks = polymarketOperation({
27
+ id: "batch_get_polymarket_order_books",
28
+ name: "Batch Get Polymarket Order Books",
29
+ description: "Get order books for multiple tokens (max 500) via the CLOB API",
30
+ input: z.object({ tokenIDs: z.array(z.string()).max(500) }),
31
+ output: z.array(orderBookSummarySchema),
32
+ run: async (input, credentials) => {
33
+ return createPolymarketClient(credentials).request({
34
+ host: "clob",
35
+ method: "POST",
36
+ path: "/books",
37
+ body: input.tokenIDs
38
+ });
39
+ }
40
+ });
41
+ const batchGetSpreads = polymarketOperation({
42
+ id: "batch_get_polymarket_spreads",
43
+ name: "Batch Get Polymarket Spreads",
44
+ description: "Get spreads for multiple tokens (max 500) via the CLOB API",
45
+ input: z.object({ tokenIDs: z.array(z.string()).max(500) }),
46
+ output: z.array(spreadSchema),
47
+ run: async (input, credentials) => {
48
+ return createPolymarketClient(credentials).request({
49
+ host: "clob",
50
+ method: "POST",
51
+ path: "/spreads",
52
+ body: input.tokenIDs
53
+ });
54
+ }
55
+ });
56
+
57
+ //#endregion
58
+ export { batchGetOrderBooks, batchGetSpreads, getOrderBook };
@@ -0,0 +1,63 @@
1
+ import { z } from "zod";
2
+ import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
3
+ import * as _keystrokehq_core0 from "@keystrokehq/core";
4
+
5
+ //#region src/pricing.d.ts
6
+ declare const getPrice: _keystrokehq_core0.Operation<z.ZodObject<{
7
+ tokenID: z.ZodString;
8
+ side: z.ZodEnum<{
9
+ BUY: "BUY";
10
+ SELL: "SELL";
11
+ }>;
12
+ }, z.core.$strip>, z.ZodObject<{
13
+ price: z.ZodString;
14
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"polymarket", z.ZodObject<{
15
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
16
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
17
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
18
+ }, z.core.$strip>>[] | undefined>], undefined>;
19
+ declare const getMidpoint: _keystrokehq_core0.Operation<z.ZodObject<{
20
+ tokenID: z.ZodString;
21
+ }, z.core.$strip>, z.ZodObject<{
22
+ mid: z.ZodString;
23
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"polymarket", z.ZodObject<{
24
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
25
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
26
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
27
+ }, z.core.$strip>>[] | undefined>], undefined>;
28
+ declare const listPrices: _keystrokehq_core0.Operation<z.ZodObject<{}, z.core.$strip>, z.ZodRecord<z.ZodString, z.ZodObject<{
29
+ BUY: z.ZodString;
30
+ SELL: z.ZodString;
31
+ }, z.core.$strip>>, readonly [_keystrokehq_core0.CredentialSet<"polymarket", z.ZodObject<{
32
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
33
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
34
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
35
+ }, z.core.$strip>>[] | undefined>], undefined>;
36
+ declare const batchGetPrices: _keystrokehq_core0.Operation<z.ZodObject<{
37
+ tokenIDs: z.ZodArray<z.ZodString>;
38
+ }, z.core.$strip>, z.ZodRecord<z.ZodString, z.ZodObject<{
39
+ BUY: z.ZodString;
40
+ SELL: z.ZodString;
41
+ }, z.core.$strip>>, readonly [_keystrokehq_core0.CredentialSet<"polymarket", z.ZodObject<{
42
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
43
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
44
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
45
+ }, z.core.$strip>>[] | undefined>], undefined>;
46
+ declare const getPriceHistory: _keystrokehq_core0.Operation<z.ZodObject<{
47
+ tokenID: z.ZodString;
48
+ interval: z.ZodOptional<z.ZodString>;
49
+ fidelity: z.ZodOptional<z.ZodNumber>;
50
+ startTs: z.ZodOptional<z.ZodNumber>;
51
+ endTs: z.ZodOptional<z.ZodNumber>;
52
+ }, z.core.$strip>, z.ZodObject<{
53
+ history: z.ZodArray<z.ZodObject<{
54
+ t: z.ZodNumber;
55
+ p: z.ZodNumber;
56
+ }, z.core.$strip>>;
57
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"polymarket", z.ZodObject<{
58
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
59
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
60
+ POLYMARKET_API_KEY: z.ZodOptional<z.ZodString>;
61
+ }, z.core.$strip>>[] | undefined>], undefined>;
62
+ //#endregion
63
+ export { batchGetPrices, getMidpoint, getPrice, getPriceHistory, listPrices };
@@ -0,0 +1,105 @@
1
+ import { D as createPolymarketClient, E as polymarketOperation, g as priceHistoryResponseSchema, n as clobPriceSchema, r as clobPricesMapSchema, t as clobMidpointSchema } from "./schemas-C6SqZjA-.mjs";
2
+ import { z } from "zod";
3
+
4
+ //#region src/pricing.ts
5
+ /**
6
+ * polymarket/pricing.ts
7
+ *
8
+ * Steps for pricing data via the CLOB API.
9
+ * Note: CLOB API returns prices as strings, not numbers.
10
+ */
11
+ const getPrice = polymarketOperation({
12
+ id: "get_polymarket_price",
13
+ name: "Get Polymarket Price",
14
+ description: "Get price for a token and side (BUY/SELL) via the CLOB API",
15
+ input: z.object({
16
+ tokenID: z.string(),
17
+ side: z.enum(["BUY", "SELL"])
18
+ }),
19
+ output: clobPriceSchema,
20
+ run: async (input, credentials) => {
21
+ return createPolymarketClient(credentials).request({
22
+ host: "clob",
23
+ method: "GET",
24
+ path: "/price",
25
+ query: {
26
+ token_id: input.tokenID,
27
+ side: input.side
28
+ }
29
+ });
30
+ }
31
+ });
32
+ const getMidpoint = polymarketOperation({
33
+ id: "get_polymarket_midpoint",
34
+ name: "Get Polymarket Midpoint",
35
+ description: "Get midpoint price for a token via the CLOB API",
36
+ input: z.object({ tokenID: z.string() }),
37
+ output: clobMidpointSchema,
38
+ run: async (input, credentials) => {
39
+ return createPolymarketClient(credentials).request({
40
+ host: "clob",
41
+ method: "GET",
42
+ path: "/midpoint",
43
+ query: { token_id: input.tokenID }
44
+ });
45
+ }
46
+ });
47
+ const listPrices = polymarketOperation({
48
+ id: "list_polymarket_prices",
49
+ name: "List Polymarket Prices",
50
+ description: "Get all current prices via the CLOB API",
51
+ input: z.object({}),
52
+ output: clobPricesMapSchema,
53
+ run: async (_input, credentials) => {
54
+ return createPolymarketClient(credentials).request({
55
+ host: "clob",
56
+ method: "GET",
57
+ path: "/prices"
58
+ });
59
+ }
60
+ });
61
+ const batchGetPrices = polymarketOperation({
62
+ id: "batch_get_polymarket_prices",
63
+ name: "Batch Get Polymarket Prices",
64
+ description: "Get prices for multiple tokens (max 500) via the CLOB API",
65
+ input: z.object({ tokenIDs: z.array(z.string()).max(500) }),
66
+ output: clobPricesMapSchema,
67
+ run: async (input, credentials) => {
68
+ return createPolymarketClient(credentials).request({
69
+ host: "clob",
70
+ method: "POST",
71
+ path: "/prices",
72
+ body: input.tokenIDs
73
+ });
74
+ }
75
+ });
76
+ const getPriceHistory = polymarketOperation({
77
+ id: "get_polymarket_price_history",
78
+ name: "Get Polymarket Price History",
79
+ description: "Get historical prices with interval/fidelity via the CLOB API",
80
+ input: z.object({
81
+ tokenID: z.string(),
82
+ interval: z.string().optional(),
83
+ fidelity: z.number().optional(),
84
+ startTs: z.number().optional(),
85
+ endTs: z.number().optional()
86
+ }),
87
+ output: priceHistoryResponseSchema,
88
+ run: async (input, credentials) => {
89
+ return createPolymarketClient(credentials).request({
90
+ host: "clob",
91
+ method: "GET",
92
+ path: "/prices-history",
93
+ query: {
94
+ market: input.tokenID,
95
+ interval: input.interval,
96
+ fidelity: input.fidelity,
97
+ startTs: input.startTs,
98
+ endTs: input.endTs
99
+ }
100
+ });
101
+ }
102
+ });
103
+
104
+ //#endregion
105
+ export { batchGetPrices, getMidpoint, getPrice, getPriceHistory, listPrices };
@@ -0,0 +1,337 @@
1
+ import { t as polymarket } from "./integration-KDxC97JC.mjs";
2
+ import { z } from "zod";
3
+ import { createOfficialOperationFactory } from "@keystrokehq/integration-authoring/official";
4
+
5
+ //#region src/client.ts
6
+ const POLYMARKET_HOSTS = {
7
+ gamma: "https://gamma-api.polymarket.com",
8
+ clob: "https://clob.polymarket.com",
9
+ data: "https://data-api.polymarket.com"
10
+ };
11
+ /**
12
+ * Create a Polymarket API client from resolved credentials.
13
+ *
14
+ * @param credentials - Resolved credentials containing the API key
15
+ * @returns A client with a typed `request` method
16
+ */
17
+ function createPolymarketClient(credentials) {
18
+ const request = async (options) => {
19
+ const { host, method, path, body, query } = options;
20
+ let url = `${POLYMARKET_HOSTS[host]}${path}`;
21
+ if (query) {
22
+ const params = new URLSearchParams();
23
+ for (const [key, value] of Object.entries(query)) if (value !== void 0) params.set(key, String(value));
24
+ const qs = params.toString();
25
+ if (qs) url = `${url}?${qs}`;
26
+ }
27
+ const headers = { Accept: "application/json" };
28
+ if (credentials.POLYMARKET_API_KEY) headers.Authorization = `Bearer ${credentials.POLYMARKET_API_KEY}`;
29
+ if (body !== void 0) headers["Content-Type"] = "application/json";
30
+ const response = await fetch(url, {
31
+ method,
32
+ headers,
33
+ body: body !== void 0 ? JSON.stringify(body) : void 0
34
+ });
35
+ if (!response.ok) {
36
+ const errorBody = await response.text().catch(() => "");
37
+ throw new Error(`Polymarket API error (${host}): ${response.status} ${response.statusText}${errorBody ? ` — ${errorBody}` : ""}`);
38
+ }
39
+ const data = await response.json();
40
+ if (data === null || data === void 0) throw new Error(`Polymarket API returned empty response for ${method} ${url} (status ${response.status})`);
41
+ return data;
42
+ };
43
+ return { request };
44
+ }
45
+
46
+ //#endregion
47
+ //#region src/factory.ts
48
+ const polymarketOperation = createOfficialOperationFactory(polymarket);
49
+
50
+ //#endregion
51
+ //#region src/schemas.ts
52
+ /**
53
+ * polymarket/schemas.ts
54
+ *
55
+ * All Zod schemas for Polymarket API objects.
56
+ *
57
+ * Three APIs with different conventions:
58
+ * - Gamma API: Standard JSON types, camelCase fields
59
+ * - CLOB API: String-typed numbers (e.g., { price: "0.54" })
60
+ * - Data API: Polymarket-specific field names (proxyWallet, conditionId, etc.)
61
+ *
62
+ * Types are inferred from schemas — never defined separately.
63
+ */
64
+ /**
65
+ * Pagination params used by all list endpoints (offset-based).
66
+ */
67
+ const paginationParamsSchema = z.object({
68
+ limit: z.number().optional(),
69
+ offset: z.number().optional()
70
+ });
71
+ const tagSchema = z.object({
72
+ id: z.string(),
73
+ label: z.string(),
74
+ slug: z.string().optional()
75
+ }).passthrough();
76
+ /**
77
+ * Market object from Gamma API.
78
+ * Has 100+ fields — key fields are modeled explicitly with .passthrough() for the rest.
79
+ */
80
+ const marketSchema = z.object({
81
+ id: z.string(),
82
+ question: z.string(),
83
+ conditionId: z.string(),
84
+ slug: z.string(),
85
+ endDate: z.string().optional(),
86
+ startDate: z.string().optional(),
87
+ description: z.string().optional(),
88
+ outcomes: z.string().optional(),
89
+ outcomePrices: z.string().optional(),
90
+ volume: z.string().optional(),
91
+ volumeNum: z.number().optional(),
92
+ liquidity: z.string().optional(),
93
+ liquidityNum: z.number().optional(),
94
+ bestBid: z.number().optional(),
95
+ bestAsk: z.number().optional(),
96
+ lastTradePrice: z.number().optional(),
97
+ active: z.boolean().optional(),
98
+ closed: z.boolean().optional(),
99
+ archived: z.boolean().optional(),
100
+ acceptingOrders: z.boolean().optional(),
101
+ clobTokenIds: z.string().optional(),
102
+ image: z.string().optional(),
103
+ icon: z.string().optional(),
104
+ groupItemTitle: z.string().optional(),
105
+ groupItemThreshold: z.string().optional(),
106
+ enableOrderBook: z.boolean().optional(),
107
+ createdAt: z.string().optional(),
108
+ updatedAt: z.string().optional()
109
+ }).passthrough();
110
+ /**
111
+ * Valid order fields for Gamma API /markets endpoint.
112
+ * Must match Market object property names (camelCase).
113
+ * See: https://docs.polymarket.com/api-reference/markets/list-markets
114
+ */
115
+ const listMarketsOrderSchema = z.enum([
116
+ "volume24hr",
117
+ "volumeNum",
118
+ "liquidityNum",
119
+ "startDate",
120
+ "endDate",
121
+ "competitive",
122
+ "closedTime"
123
+ ]).optional();
124
+ /**
125
+ * List markets query params.
126
+ */
127
+ const listMarketsParamsSchema = z.object({
128
+ limit: z.number().optional(),
129
+ offset: z.number().optional(),
130
+ order: listMarketsOrderSchema,
131
+ ascending: z.boolean().optional(),
132
+ id: z.string().optional(),
133
+ slug: z.string().optional(),
134
+ clob_token_ids: z.string().optional(),
135
+ condition_ids: z.string().optional(),
136
+ liquidity_num_min: z.number().optional(),
137
+ liquidity_num_max: z.number().optional(),
138
+ volume_num_min: z.number().optional(),
139
+ volume_num_max: z.number().optional(),
140
+ start_date_min: z.string().optional(),
141
+ start_date_max: z.string().optional(),
142
+ end_date_min: z.string().optional(),
143
+ end_date_max: z.string().optional(),
144
+ tag_id: z.number().optional(),
145
+ closed: z.boolean().optional(),
146
+ active: z.boolean().optional()
147
+ });
148
+ /**
149
+ * Event object from Gamma API.
150
+ * Rich nested structure with markets[], tags[], categories[].
151
+ */
152
+ const eventSchema = z.object({
153
+ id: z.string(),
154
+ title: z.string(),
155
+ slug: z.string(),
156
+ description: z.string().optional(),
157
+ startDate: z.string().optional(),
158
+ endDate: z.string().optional(),
159
+ active: z.boolean().optional(),
160
+ closed: z.boolean().optional(),
161
+ archived: z.boolean().optional(),
162
+ featured: z.boolean().optional(),
163
+ liquidity: z.number().optional(),
164
+ volume: z.number().optional(),
165
+ createdAt: z.string().optional(),
166
+ updatedAt: z.string().optional(),
167
+ markets: z.array(marketSchema).optional(),
168
+ tags: z.array(tagSchema).optional(),
169
+ categories: z.array(z.unknown()).optional()
170
+ }).passthrough();
171
+ /**
172
+ * List events query params.
173
+ */
174
+ const listEventsParamsSchema = z.object({
175
+ limit: z.number().optional(),
176
+ offset: z.number().optional(),
177
+ order: z.string().optional(),
178
+ ascending: z.boolean().optional(),
179
+ id: z.string().optional(),
180
+ slug: z.string().optional(),
181
+ tag_id: z.number().optional(),
182
+ tag_slug: z.string().optional(),
183
+ active: z.boolean().optional(),
184
+ archived: z.boolean().optional(),
185
+ featured: z.boolean().optional(),
186
+ closed: z.boolean().optional(),
187
+ liquidity_min: z.number().optional(),
188
+ liquidity_max: z.number().optional(),
189
+ volume_min: z.number().optional(),
190
+ volume_max: z.number().optional(),
191
+ start_date_min: z.string().optional(),
192
+ start_date_max: z.string().optional(),
193
+ end_date_min: z.string().optional(),
194
+ end_date_max: z.string().optional()
195
+ });
196
+ const seriesSchema = z.object({
197
+ id: z.string(),
198
+ title: z.string(),
199
+ slug: z.string().optional(),
200
+ description: z.string().optional()
201
+ }).passthrough();
202
+ const searchResultSchema = z.object({
203
+ events: z.array(z.unknown()).optional(),
204
+ tags: z.array(z.unknown()).optional(),
205
+ profiles: z.array(z.unknown()).optional(),
206
+ pagination: z.object({
207
+ hasMore: z.boolean().optional(),
208
+ totalResults: z.number().optional()
209
+ }).optional()
210
+ });
211
+ const profileSchema = z.object({
212
+ address: z.string(),
213
+ pseudonym: z.string().optional(),
214
+ bio: z.string().optional(),
215
+ profileImage: z.string().optional(),
216
+ displayUsernamePublic: z.boolean().optional()
217
+ }).passthrough();
218
+ const sportsMetadataSchema = z.unknown();
219
+ const sportsMarketTypeSchema = z.unknown();
220
+ const sportsTeamSchema = z.unknown();
221
+ /**
222
+ * CLOB price response — prices are strings, not numbers.
223
+ */
224
+ const clobPriceSchema = z.object({ price: z.string() });
225
+ /**
226
+ * CLOB midpoint response.
227
+ */
228
+ const clobMidpointSchema = z.object({ mid: z.string() });
229
+ /**
230
+ * CLOB /prices response — Record<token_id, { BUY: string, SELL: string }>
231
+ */
232
+ const clobPricesMapSchema = z.record(z.string(), z.object({
233
+ BUY: z.string(),
234
+ SELL: z.string()
235
+ }));
236
+ /**
237
+ * CLOB price history point.
238
+ */
239
+ const priceHistoryPointSchema = z.object({
240
+ t: z.number(),
241
+ p: z.number()
242
+ });
243
+ /**
244
+ * CLOB /prices-history response.
245
+ */
246
+ const priceHistoryResponseSchema = z.object({ history: z.array(priceHistoryPointSchema) });
247
+ /**
248
+ * Order book entry (bid or ask) — prices and sizes are strings.
249
+ */
250
+ const orderBookEntrySchema = z.object({
251
+ price: z.string(),
252
+ size: z.string()
253
+ });
254
+ /**
255
+ * Order book summary for a token.
256
+ */
257
+ const orderBookSummarySchema = z.object({
258
+ market: z.string().optional(),
259
+ asset_id: z.string(),
260
+ timestamp: z.string().optional(),
261
+ hash: z.string().optional(),
262
+ bids: z.array(orderBookEntrySchema),
263
+ asks: z.array(orderBookEntrySchema),
264
+ min_order_size: z.string().optional(),
265
+ tick_size: z.string().optional(),
266
+ neg_risk: z.boolean().optional()
267
+ }).passthrough();
268
+ /**
269
+ * Spread for a token.
270
+ */
271
+ const spreadSchema = z.object({
272
+ asset_id: z.string(),
273
+ spread: z.string(),
274
+ bid: z.string().optional(),
275
+ ask: z.string().optional()
276
+ }).passthrough();
277
+ const tradeSchema = z.object({
278
+ id: z.string().optional(),
279
+ taker_order_id: z.string().optional(),
280
+ market: z.string().optional(),
281
+ asset_id: z.string().optional(),
282
+ side: z.string().optional(),
283
+ size: z.union([z.string(), z.number()]).transform(String).optional(),
284
+ fee_rate_bps: z.union([z.string(), z.number()]).transform(String).optional(),
285
+ price: z.union([z.string(), z.number()]).transform(String).optional(),
286
+ status: z.string().optional(),
287
+ match_time: z.string().optional(),
288
+ last_update: z.string().optional(),
289
+ outcome: z.string().optional(),
290
+ maker_address: z.string().optional(),
291
+ trader_side: z.string().optional(),
292
+ transaction_hash: z.string().optional(),
293
+ bucket_index: z.number().optional(),
294
+ owner: z.string().optional(),
295
+ type: z.string().optional()
296
+ }).passthrough();
297
+ const positionSchema = z.object({
298
+ asset: z.string().optional(),
299
+ conditionId: z.string().optional(),
300
+ proxyWallet: z.string().optional(),
301
+ size: z.number().optional(),
302
+ avgPrice: z.number().optional(),
303
+ initialValue: z.number().optional(),
304
+ currentValue: z.number().optional(),
305
+ cashPnl: z.number().optional(),
306
+ percentPnl: z.number().optional(),
307
+ totalBought: z.number().optional(),
308
+ totalSold: z.number().optional(),
309
+ realizedPnl: z.number().optional(),
310
+ curPrice: z.number().optional(),
311
+ redeemed: z.boolean().optional(),
312
+ mergeable: z.boolean().optional(),
313
+ outcome: z.string().optional(),
314
+ title: z.string().optional(),
315
+ slug: z.string().optional(),
316
+ icon: z.string().optional(),
317
+ eventSlug: z.string().optional(),
318
+ eventTitle: z.string().optional()
319
+ }).passthrough();
320
+ const holderSchema = z.object({
321
+ address: z.string().optional(),
322
+ proxyWallet: z.string().optional(),
323
+ amount: z.number().optional(),
324
+ value: z.number().optional(),
325
+ position: z.string().optional()
326
+ }).passthrough();
327
+ const openInterestSchema = z.object({
328
+ conditionId: z.string().optional(),
329
+ openInterest: z.number().optional()
330
+ }).passthrough();
331
+ const liveVolumeSchema = z.object({
332
+ volume: z.number().optional(),
333
+ volume24hr: z.number().optional()
334
+ }).passthrough();
335
+
336
+ //#endregion
337
+ export { spreadSchema as C, createPolymarketClient as D, polymarketOperation as E, sportsTeamSchema as S, tradeSchema as T, profileSchema as _, holderSchema as a, sportsMarketTypeSchema as b, liveVolumeSchema as c, orderBookEntrySchema as d, orderBookSummarySchema as f, priceHistoryResponseSchema as g, priceHistoryPointSchema as h, eventSchema as i, marketSchema as l, positionSchema as m, clobPriceSchema as n, listEventsParamsSchema as o, paginationParamsSchema as p, clobPricesMapSchema as r, listMarketsParamsSchema as s, clobMidpointSchema as t, openInterestSchema as u, searchResultSchema as v, tagSchema as w, sportsMetadataSchema as x, seriesSchema as y };