@vesper85/strategy-sdk 0.1.9 → 0.1.11

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.
@@ -1,4 +1,4 @@
1
- import { GammaMarket, type Event as GammaEvent, type Tag, type Team, type Sport, type Series, type Comment as GammaComment, type SearchResults, type PaginatedResponse, type MarketFilters, type EventFilters, type EventPaginationFilters, type PaginationParams, type SearchParams } from "polymarket-gamma";
1
+ import { GammaMarket, type Event as GammaEvent, type Tag, type Team, type Sport, type Series, type Comment as GammaComment, type SearchResults, type PaginatedResponse, type MarketFilters, type EventFilters, type EventPaginationFilters, type PaginationParams, type SearchParams } from "../gamma";
2
2
  import type { PolymarketAPI, PolymarketClientOptions, PolymarketLimitOrderParams, PolymarketMarketOrderParams, PolymarketOrderResponse, PolymarketOpenOrder, PolymarketCancelResponse, PolymarketOrderBook, PolymarketApprovalResult, SignerAPI } from "../types/osiris";
3
3
  import type { Logger } from "../utils/logger";
4
4
  export declare class PolymarketClient implements PolymarketAPI {
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Polymarket Gamma API Client
3
+ * Inlined from polymarket-gamma package to avoid dependency issues
4
+ */
5
+ import type { Comment, Event, EventFilters, EventPaginationFilters, GammaMarket, MarketFilters, PaginatedResponse, PaginationParams, SearchParams, SearchResults, Series, Sport, Tag, Team } from './types';
6
+ /**
7
+ * Configuration options for the Gamma client
8
+ */
9
+ export interface GammaClientConfig {
10
+ baseUrl?: string;
11
+ timeout?: number;
12
+ fetch?: typeof fetch;
13
+ headers?: Record<string, string>;
14
+ enableCache?: boolean;
15
+ }
16
+ /**
17
+ * Polymarket Gamma API Client
18
+ * Provides methods to access prediction markets, events, tags, and related data
19
+ */
20
+ export declare class PolymarketGammaClient {
21
+ private readonly baseUrl;
22
+ private readonly timeout;
23
+ private readonly fetchFn;
24
+ private readonly customHeaders;
25
+ private readonly enableCache;
26
+ private readonly requestCache;
27
+ /**
28
+ * Creates a new Polymarket Gamma API client
29
+ * @param config - Optional configuration
30
+ */
31
+ constructor(config?: GammaClientConfig);
32
+ /**
33
+ * Parse JSON string fields that the API returns as strings instead of arrays/objects
34
+ */
35
+ private parseJsonFields;
36
+ /**
37
+ * Validate API response to ensure it's a valid object
38
+ */
39
+ private validateResponse;
40
+ /**
41
+ * Internal method to make HTTP requests with deduplication
42
+ */
43
+ private request;
44
+ /**
45
+ * Perform the actual HTTP request
46
+ */
47
+ private doRequest;
48
+ /**
49
+ * Internal method to make POST requests
50
+ */
51
+ private post;
52
+ /**
53
+ * Search across events, tags, and profiles
54
+ * @param params - Search parameters
55
+ * @returns Search results
56
+ */
57
+ search(params: SearchParams): Promise<SearchResults>;
58
+ /**
59
+ * Get a market by ID or slug
60
+ * @param idOrSlug - Market ID or slug
61
+ * @returns Market details
62
+ */
63
+ getMarket(idOrSlug: string): Promise<GammaMarket>;
64
+ /**
65
+ * Get markets with optional filtering and pagination
66
+ * @param filters - Filter and pagination parameters
67
+ * @returns Array of markets
68
+ */
69
+ getMarkets(filters?: MarketFilters): Promise<GammaMarket[]>;
70
+ /**
71
+ * Get tags for a specific market
72
+ * @param marketId - Market ID
73
+ * @returns Array of tags
74
+ */
75
+ getMarketTags(marketId: string): Promise<Tag[]>;
76
+ /**
77
+ * Get an event by ID or slug
78
+ * @param idOrSlug - Event ID or slug
79
+ * @returns Event details
80
+ */
81
+ getEvent(idOrSlug: string): Promise<Event>;
82
+ /**
83
+ * Get events with optional filtering and pagination
84
+ * @param filters - Filter and pagination parameters
85
+ * @returns Array of events
86
+ */
87
+ getEvents(filters?: EventFilters): Promise<Event[]>;
88
+ /**
89
+ * Get tags for a specific event
90
+ * @param eventId - Event ID
91
+ * @returns Array of tags
92
+ */
93
+ getEventTags(eventId: string): Promise<Tag[]>;
94
+ /**
95
+ * Get events with pagination metadata
96
+ * @param filters - Filter and pagination parameters
97
+ * @returns Paginated response with events and metadata
98
+ */
99
+ getEventsPaginated(filters?: EventPaginationFilters): Promise<PaginatedResponse<Event>>;
100
+ /**
101
+ * Get all tags
102
+ * @param params - Optional pagination parameters
103
+ * @returns Array of tags
104
+ */
105
+ getTags(params?: PaginationParams): Promise<Tag[]>;
106
+ /**
107
+ * Get a specific tag by ID or slug
108
+ * @param idOrSlug - Tag ID or slug
109
+ * @returns Tag details
110
+ */
111
+ getTag(idOrSlug: string): Promise<Tag>;
112
+ /**
113
+ * Get related tags for a specific tag
114
+ * @param idOrSlug - Tag ID or slug
115
+ * @returns Array of related tags
116
+ */
117
+ getRelatedTags(idOrSlug: string): Promise<Tag[]>;
118
+ /**
119
+ * Get all tags related to a specific tag
120
+ * @param idOrSlug - Tag ID or slug
121
+ * @returns Array of tags
122
+ */
123
+ getRelatedTagsTags(idOrSlug: string): Promise<Tag[]>;
124
+ /**
125
+ * Get all teams
126
+ * @param params - Optional pagination parameters
127
+ * @returns Array of teams
128
+ */
129
+ getTeams(params?: PaginationParams): Promise<Team[]>;
130
+ /**
131
+ * Get all sports
132
+ * @param params - Optional pagination parameters
133
+ * @returns Array of sports
134
+ */
135
+ getSports(params?: PaginationParams): Promise<Sport[]>;
136
+ /**
137
+ * Get all series
138
+ * @param params - Optional pagination parameters
139
+ * @returns Array of series
140
+ */
141
+ getSeries(params?: PaginationParams): Promise<Series[]>;
142
+ /**
143
+ * Get a specific series by ID
144
+ * @param seriesId - Series ID
145
+ * @returns Series details
146
+ */
147
+ getSeriesById(seriesId: string): Promise<Series>;
148
+ /**
149
+ * Get comments with optional filtering
150
+ * @param params - Optional pagination and filter parameters
151
+ * @returns Array of comments
152
+ */
153
+ getComments(params?: PaginationParams): Promise<Comment[]>;
154
+ /**
155
+ * Get a specific comment by ID
156
+ * @param commentId - Comment ID
157
+ * @returns Comment details
158
+ */
159
+ getComment(commentId: string): Promise<Comment>;
160
+ /**
161
+ * Get comments by user address
162
+ * @param userAddress - User's Ethereum address
163
+ * @param params - Optional pagination parameters
164
+ * @returns Array of comments
165
+ */
166
+ getCommentsByUser(userAddress: string, params?: PaginationParams): Promise<Comment[]>;
167
+ /**
168
+ * Get Grok AI-powered event summary
169
+ * @param eventSlug - Event slug
170
+ * @returns Event summary text
171
+ */
172
+ grokEventSummary(eventSlug: string): Promise<string>;
173
+ /**
174
+ * Get Grok AI-powered election market explanation
175
+ * @param marketSlug - Market slug
176
+ * @returns Market explanation text
177
+ */
178
+ grokElectionMarketExplanation(marketSlug: string): Promise<string>;
179
+ }
180
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Polymarket Gamma API - Inlined
3
+ * Re-exports types and client for internal use
4
+ */
5
+ export { PolymarketGammaClient } from './client';
6
+ export type { GammaClientConfig } from './client';
7
+ export type { Category, ClobReward, Collection, Comment, Creator, Event, EventFilters, EventPaginationFilters, GammaMarket, MarketFilters, PaginatedResponse, PaginationMetadata, PaginationParams, Profile, Reaction, SearchParams, SearchResults, Series, Sport, Tag, Team, } from './types';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,339 @@
1
+ /**
2
+ * TypeScript type definitions for Polymarket Gamma API
3
+ * Inlined from polymarket-gamma package to avoid dependency issues
4
+ */
5
+ /**
6
+ * Represents a prediction market on Polymarket
7
+ */
8
+ export interface GammaMarket {
9
+ id?: string;
10
+ condition_id?: string;
11
+ question_id?: string;
12
+ slug?: string;
13
+ question?: string;
14
+ twitter_card_image?: string;
15
+ resolution_source?: string;
16
+ end_date?: string;
17
+ category?: string;
18
+ amm_type?: string;
19
+ liquidity?: number;
20
+ sponsor_name?: string;
21
+ sponsor_image?: string;
22
+ start_date?: string;
23
+ x_axis_value?: string;
24
+ y_axis_value?: string;
25
+ denomination_token?: string;
26
+ fee?: string;
27
+ image?: string;
28
+ icon?: string;
29
+ lower_bound?: string;
30
+ upper_bound?: string;
31
+ description?: string;
32
+ outcomes?: string[];
33
+ outcome_prices?: string[];
34
+ outcomePrices?: string[];
35
+ volume?: string;
36
+ active?: boolean;
37
+ market_type?: string;
38
+ format_type?: string;
39
+ lower_bound_date?: string;
40
+ upper_bound_date?: string;
41
+ closed?: boolean;
42
+ market_maker_address?: string;
43
+ created_by?: number;
44
+ updated_by?: number;
45
+ created_at?: string;
46
+ updated_at?: string;
47
+ closed_time?: string;
48
+ wide_format?: boolean;
49
+ new?: boolean;
50
+ mailchimp_tag?: string;
51
+ featured?: boolean;
52
+ archived?: boolean;
53
+ resolved_by?: string;
54
+ restricted?: boolean;
55
+ market_group?: number;
56
+ group_item_title?: string;
57
+ group_item_threshold?: string;
58
+ uma_end_date?: string;
59
+ seconds_delay?: number;
60
+ notification_policy?: number;
61
+ pager_duty_notification_enabled?: boolean;
62
+ reward_pool?: number;
63
+ reward_epoch?: number;
64
+ reward_multiplier?: number;
65
+ reward_min_size?: number;
66
+ reward_max_spread?: number;
67
+ ready?: boolean;
68
+ enable_order_book?: boolean;
69
+ notification_type?: string;
70
+ uma_reward?: string;
71
+ uma_resolution_statuses?: string[];
72
+ umaResolutionStatuses?: string[];
73
+ question_title?: string;
74
+ enable_ask?: boolean;
75
+ notifications?: number[];
76
+ events?: Event[];
77
+ markets?: GammaMarket[];
78
+ clob_token_ids?: string[];
79
+ clobTokenIds?: string[];
80
+ clobRewards?: ClobReward[];
81
+ tags?: Tag[];
82
+ cyom?: boolean;
83
+ competitive?: number;
84
+ neg_risk?: boolean;
85
+ neg_risk_market_id?: string;
86
+ neg_risk_request_id?: string;
87
+ accepting_orders?: boolean;
88
+ accepting_order_timestamp?: string;
89
+ minimum_order_size?: number;
90
+ minimum_tick_size?: number;
91
+ taker_fee_bps?: number;
92
+ maker_fee_bps?: number;
93
+ minimum_tick_size_usd?: number;
94
+ maker_base_fee?: number;
95
+ taker_base_fee?: number;
96
+ best_bid?: string;
97
+ best_ask?: string;
98
+ spread?: number;
99
+ spread_percent?: number;
100
+ volume_24hr?: string;
101
+ volume_num_trades_24hr?: number;
102
+ last_trade_price?: string;
103
+ last_trade_time?: string;
104
+ open_interest?: string;
105
+ rewards_daily_rate?: number;
106
+ rewards_min_size?: number;
107
+ rewards_max_spread?: number;
108
+ seconds_delay_requested?: number;
109
+ auto_update_schema?: boolean;
110
+ active_trading_prompt?: boolean;
111
+ }
112
+ /**
113
+ * Represents an event that contains one or more markets
114
+ */
115
+ export interface Event {
116
+ id?: string;
117
+ slug?: string;
118
+ title?: string;
119
+ description?: string;
120
+ start_date?: string;
121
+ end_date?: string;
122
+ image?: string;
123
+ icon?: string;
124
+ created_at?: string;
125
+ updated_at?: string;
126
+ archived?: boolean;
127
+ active?: boolean;
128
+ closed?: boolean;
129
+ restricted?: boolean;
130
+ liquidity?: number;
131
+ volume?: string;
132
+ markets?: GammaMarket[];
133
+ tags?: Tag[];
134
+ categories?: Category[];
135
+ series?: Series[];
136
+ comment_count?: number;
137
+ enable_comment?: boolean;
138
+ ticker?: string;
139
+ }
140
+ /**
141
+ * Represents a series or tournament of related events
142
+ */
143
+ export interface Series {
144
+ id?: string;
145
+ slug?: string;
146
+ title?: string;
147
+ description?: string;
148
+ image?: string;
149
+ created_at?: string;
150
+ updated_at?: string;
151
+ events?: Event[];
152
+ categories?: Category[];
153
+ }
154
+ /**
155
+ * Represents a category for organizing markets and events
156
+ */
157
+ export interface Category {
158
+ id?: string;
159
+ label?: string;
160
+ slug?: string;
161
+ }
162
+ /**
163
+ * Represents a tag for organizing and filtering content
164
+ */
165
+ export interface Tag {
166
+ id?: string;
167
+ label?: string;
168
+ slug?: string;
169
+ description?: string;
170
+ event_count?: number;
171
+ market_count?: number;
172
+ parent_id?: string;
173
+ children?: Tag[];
174
+ }
175
+ /**
176
+ * Represents a user profile
177
+ */
178
+ export interface Profile {
179
+ id?: string;
180
+ name?: string;
181
+ username?: string;
182
+ avatar_url?: string;
183
+ bio?: string;
184
+ }
185
+ /**
186
+ * Represents a comment on a market or event
187
+ */
188
+ export interface Comment {
189
+ id?: string;
190
+ market_id?: string;
191
+ event_id?: string;
192
+ user?: Profile;
193
+ content?: string;
194
+ created_at?: string;
195
+ updated_at?: string;
196
+ parent_id?: string;
197
+ reactions?: Reaction[];
198
+ reply_count?: number;
199
+ }
200
+ /**
201
+ * Represents a reaction to a comment
202
+ */
203
+ export interface Reaction {
204
+ id?: string;
205
+ comment_id?: string;
206
+ user?: Profile;
207
+ type?: string;
208
+ created_at?: string;
209
+ }
210
+ /**
211
+ * Represents a sports team
212
+ */
213
+ export interface Team {
214
+ id?: string;
215
+ name?: string;
216
+ short_name?: string;
217
+ abbreviation?: string;
218
+ logo?: string;
219
+ sport_id?: string;
220
+ sport?: Sport;
221
+ }
222
+ /**
223
+ * Represents a sport
224
+ */
225
+ export interface Sport {
226
+ id?: string;
227
+ name?: string;
228
+ slug?: string;
229
+ }
230
+ /**
231
+ * Represents a CLOB (Central Limit Order Book) reward
232
+ */
233
+ export interface ClobReward {
234
+ id?: string;
235
+ market_id?: string;
236
+ event_id?: string;
237
+ reward_epoch?: number;
238
+ asset_address?: string;
239
+ reward_amount?: string;
240
+ start_date?: string;
241
+ end_date?: string;
242
+ }
243
+ /**
244
+ * Represents a collection of markets
245
+ */
246
+ export interface Collection {
247
+ id?: string;
248
+ title?: string;
249
+ slug?: string;
250
+ description?: string;
251
+ markets?: GammaMarket[];
252
+ }
253
+ /**
254
+ * Represents a market creator
255
+ */
256
+ export interface Creator {
257
+ id?: string;
258
+ name?: string;
259
+ avatar_url?: string;
260
+ }
261
+ /**
262
+ * Search results wrapper
263
+ */
264
+ export interface SearchResults {
265
+ events?: Event[];
266
+ tags?: Tag[];
267
+ profiles?: Profile[];
268
+ }
269
+ /**
270
+ * Pagination parameters for list queries
271
+ */
272
+ export interface PaginationParams {
273
+ limit?: number;
274
+ offset?: number;
275
+ [key: string]: unknown;
276
+ }
277
+ /**
278
+ * Filter parameters for markets
279
+ */
280
+ export interface MarketFilters extends PaginationParams {
281
+ active?: boolean;
282
+ closed?: boolean;
283
+ archived?: boolean;
284
+ featured?: boolean;
285
+ restricted?: boolean;
286
+ tags?: string[];
287
+ category?: string;
288
+ event_id?: string;
289
+ order_by?: string;
290
+ ascending?: boolean;
291
+ }
292
+ /**
293
+ * Filter parameters for events
294
+ */
295
+ export interface EventFilters extends PaginationParams {
296
+ active?: boolean;
297
+ closed?: boolean;
298
+ archived?: boolean;
299
+ restricted?: boolean;
300
+ tags?: string[];
301
+ category?: string;
302
+ series_id?: string;
303
+ order_by?: string;
304
+ ascending?: boolean;
305
+ }
306
+ /**
307
+ * Search parameters
308
+ */
309
+ export interface SearchParams {
310
+ query: string;
311
+ limit?: number;
312
+ offset?: number;
313
+ [key: string]: unknown;
314
+ }
315
+ /**
316
+ * Pagination metadata
317
+ */
318
+ export interface PaginationMetadata {
319
+ hasMore: boolean;
320
+ totalResults: number;
321
+ }
322
+ /**
323
+ * Paginated response wrapper
324
+ */
325
+ export interface PaginatedResponse<T> {
326
+ data: T[];
327
+ pagination: PaginationMetadata;
328
+ }
329
+ /**
330
+ * Pagination filter parameters for events
331
+ */
332
+ export interface EventPaginationFilters extends PaginationParams {
333
+ active?: boolean;
334
+ closed?: boolean;
335
+ archived?: boolean;
336
+ order?: string;
337
+ ascending?: boolean;
338
+ }
339
+ //# sourceMappingURL=types.d.ts.map
package/dist/index.d.ts CHANGED
@@ -13,4 +13,6 @@ export { PolymarketEventRunner, createPolymarketEventRunner, type PolymarketEven
13
13
  export { UnifiedRTDSService, createUnifiedRTDSService, PolymarketRTDSService, createPolymarketRTDSService, OsirisRTDSService, createOsirisRTDSService, DEFAULT_OSIRIS_RTDS_URL, type UnifiedRTDSConfig, type PolymarketRTDSConfig, type OsirisRTDSConfig, type ClobApiKeyCreds, } from './rtds';
14
14
  export { createConsoleLogger, type Logger, } from './utils/logger';
15
15
  export { Signer, OsirisSigner, PrivateKeySigner, type ISigner, type SignerConfig, type OsirisSignerConfig, type PrivateKeySignerConfig, } from './signer';
16
+ export { PolymarketGammaClient, type GammaClientConfig, } from './gamma';
17
+ export type { Category, ClobReward, Collection, Comment, Creator, Event, EventFilters, EventPaginationFilters, GammaMarket, MarketFilters, PaginatedResponse, PaginationMetadata, PaginationParams, Profile, Reaction, SearchParams, SearchResults, Series, Sport, Tag, Team, } from './gamma';
16
18
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import { PolymarketGammaClient } from 'polymarket-gamma';
2
1
  import { ClobClient, Side } from '@polymarket/clob-client';
3
2
  import { ethers } from 'ethers';
4
3
  import axios from 'axios';
@@ -51,6 +50,361 @@ function isPolymarketSubscription(sub) {
51
50
  function isOsirisSubscription(sub) {
52
51
  return isWalletSubscription(sub) || isOpportunitySubscription(sub);
53
52
  }
53
+
54
+ // src/gamma/client.ts
55
+ var PolymarketGammaClient = class {
56
+ baseUrl;
57
+ timeout;
58
+ fetchFn;
59
+ customHeaders;
60
+ enableCache;
61
+ requestCache = /* @__PURE__ */ new Map();
62
+ /**
63
+ * Creates a new Polymarket Gamma API client
64
+ * @param config - Optional configuration
65
+ */
66
+ constructor(config = {}) {
67
+ this.baseUrl = config.baseUrl ?? "https://gamma-api.polymarket.com";
68
+ this.timeout = config.timeout ?? 3e4;
69
+ this.fetchFn = config.fetch ?? globalThis.fetch;
70
+ this.customHeaders = config.headers ?? {};
71
+ this.enableCache = config.enableCache ?? true;
72
+ }
73
+ /**
74
+ * Parse JSON string fields that the API returns as strings instead of arrays/objects
75
+ */
76
+ parseJsonFields(data) {
77
+ if (!data || typeof data !== "object") {
78
+ return data;
79
+ }
80
+ if (Array.isArray(data)) {
81
+ return data.map((item) => this.parseJsonFields(item));
82
+ }
83
+ const parsed = {};
84
+ const jsonStringFields = [
85
+ "outcomes",
86
+ "outcome_prices",
87
+ "outcomePrices",
88
+ "clob_token_ids",
89
+ "clobTokenIds",
90
+ "uma_resolution_statuses",
91
+ "umaResolutionStatuses"
92
+ ];
93
+ for (const [key, value] of Object.entries(data)) {
94
+ if (jsonStringFields.includes(key) && typeof value === "string" && value.startsWith("[")) {
95
+ try {
96
+ parsed[key] = JSON.parse(value);
97
+ } catch {
98
+ parsed[key] = value;
99
+ }
100
+ } else if (value && typeof value === "object") {
101
+ parsed[key] = this.parseJsonFields(value);
102
+ } else {
103
+ parsed[key] = value;
104
+ }
105
+ }
106
+ return parsed;
107
+ }
108
+ /**
109
+ * Validate API response to ensure it's a valid object
110
+ */
111
+ validateResponse(data, endpoint) {
112
+ if (data === null || typeof data !== "object") {
113
+ throw new Error(
114
+ `Invalid response from ${endpoint}: expected object, got ${data === null ? "null" : typeof data}`
115
+ );
116
+ }
117
+ return data;
118
+ }
119
+ /**
120
+ * Internal method to make HTTP requests with deduplication
121
+ */
122
+ async request(endpoint, params) {
123
+ if (!this.enableCache) {
124
+ return this.doRequest(endpoint, params);
125
+ }
126
+ let cacheKey;
127
+ if (params) {
128
+ const searchParams = new URLSearchParams();
129
+ for (const [key, value] of Object.entries(params)) {
130
+ if (value !== void 0 && value !== null) {
131
+ if (Array.isArray(value)) {
132
+ for (const item of value) {
133
+ searchParams.append(key, String(item));
134
+ }
135
+ } else {
136
+ searchParams.append(key, String(value));
137
+ }
138
+ }
139
+ }
140
+ cacheKey = `${endpoint}?${searchParams.toString()}`;
141
+ } else {
142
+ cacheKey = endpoint;
143
+ }
144
+ if (this.requestCache.has(cacheKey)) {
145
+ return this.requestCache.get(cacheKey);
146
+ }
147
+ const promise = this.doRequest(endpoint, params);
148
+ this.requestCache.set(cacheKey, promise);
149
+ promise.finally(() => {
150
+ setTimeout(() => this.requestCache.delete(cacheKey), 100);
151
+ });
152
+ return promise;
153
+ }
154
+ /**
155
+ * Perform the actual HTTP request
156
+ */
157
+ async doRequest(endpoint, params) {
158
+ const url = new URL(endpoint, this.baseUrl);
159
+ if (params) {
160
+ for (const [key, value] of Object.entries(params)) {
161
+ if (value !== void 0 && value !== null) {
162
+ if (Array.isArray(value)) {
163
+ for (const item of value) {
164
+ url.searchParams.append(key, String(item));
165
+ }
166
+ } else {
167
+ url.searchParams.append(key, String(value));
168
+ }
169
+ }
170
+ }
171
+ }
172
+ const controller = new AbortController();
173
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
174
+ try {
175
+ const response = await this.fetchFn(url.toString(), {
176
+ method: "GET",
177
+ headers: {
178
+ "Content-Type": "application/json",
179
+ ...this.customHeaders
180
+ },
181
+ signal: controller.signal
182
+ });
183
+ if (!response.ok) {
184
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
185
+ }
186
+ const data = await response.json();
187
+ const validated = this.validateResponse(data, endpoint);
188
+ return this.parseJsonFields(validated);
189
+ } finally {
190
+ clearTimeout(timeoutId);
191
+ }
192
+ }
193
+ /**
194
+ * Internal method to make POST requests
195
+ */
196
+ async post(url, body) {
197
+ const controller = new AbortController();
198
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
199
+ try {
200
+ const response = await this.fetchFn(url, {
201
+ method: "POST",
202
+ headers: {
203
+ "Content-Type": "application/json",
204
+ ...this.customHeaders
205
+ },
206
+ body: JSON.stringify(body),
207
+ signal: controller.signal
208
+ });
209
+ if (!response.ok) {
210
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
211
+ }
212
+ const data = await response.json();
213
+ return this.validateResponse(data, url);
214
+ } finally {
215
+ clearTimeout(timeoutId);
216
+ }
217
+ }
218
+ // ==================== Search Methods ====================
219
+ /**
220
+ * Search across events, tags, and profiles
221
+ * @param params - Search parameters
222
+ * @returns Search results
223
+ */
224
+ async search(params) {
225
+ return this.request("/public-search", params);
226
+ }
227
+ // ==================== Market Methods ====================
228
+ /**
229
+ * Get a market by ID or slug
230
+ * @param idOrSlug - Market ID or slug
231
+ * @returns Market details
232
+ */
233
+ async getMarket(idOrSlug) {
234
+ const endpoint = idOrSlug.includes("-") ? `/markets/slug/${idOrSlug}` : `/markets/${idOrSlug}`;
235
+ return this.request(endpoint);
236
+ }
237
+ /**
238
+ * Get markets with optional filtering and pagination
239
+ * @param filters - Filter and pagination parameters
240
+ * @returns Array of markets
241
+ */
242
+ async getMarkets(filters) {
243
+ return this.request("/markets", filters);
244
+ }
245
+ /**
246
+ * Get tags for a specific market
247
+ * @param marketId - Market ID
248
+ * @returns Array of tags
249
+ */
250
+ async getMarketTags(marketId) {
251
+ return this.request(`/markets/${marketId}/tags`);
252
+ }
253
+ // ==================== Event Methods ====================
254
+ /**
255
+ * Get an event by ID or slug
256
+ * @param idOrSlug - Event ID or slug
257
+ * @returns Event details
258
+ */
259
+ async getEvent(idOrSlug) {
260
+ const endpoint = idOrSlug.includes("-") ? `/events/slug/${idOrSlug}` : `/events/${idOrSlug}`;
261
+ return this.request(endpoint);
262
+ }
263
+ /**
264
+ * Get events with optional filtering and pagination
265
+ * @param filters - Filter and pagination parameters
266
+ * @returns Array of events
267
+ */
268
+ async getEvents(filters) {
269
+ return this.request("/events", filters);
270
+ }
271
+ /**
272
+ * Get tags for a specific event
273
+ * @param eventId - Event ID
274
+ * @returns Array of tags
275
+ */
276
+ async getEventTags(eventId) {
277
+ return this.request(`/events/${eventId}/tags`);
278
+ }
279
+ /**
280
+ * Get events with pagination metadata
281
+ * @param filters - Filter and pagination parameters
282
+ * @returns Paginated response with events and metadata
283
+ */
284
+ async getEventsPaginated(filters) {
285
+ return this.request("/events/pagination", filters);
286
+ }
287
+ // ==================== Tag Methods ====================
288
+ /**
289
+ * Get all tags
290
+ * @param params - Optional pagination parameters
291
+ * @returns Array of tags
292
+ */
293
+ async getTags(params) {
294
+ return this.request("/tags", params);
295
+ }
296
+ /**
297
+ * Get a specific tag by ID or slug
298
+ * @param idOrSlug - Tag ID or slug
299
+ * @returns Tag details
300
+ */
301
+ async getTag(idOrSlug) {
302
+ return this.request(`/tags/${idOrSlug}`);
303
+ }
304
+ /**
305
+ * Get related tags for a specific tag
306
+ * @param idOrSlug - Tag ID or slug
307
+ * @returns Array of related tags
308
+ */
309
+ async getRelatedTags(idOrSlug) {
310
+ const endpoint = idOrSlug.includes("-") ? `/tags/slug/${idOrSlug}/related-tags` : `/tags/${idOrSlug}/related-tags`;
311
+ return this.request(endpoint);
312
+ }
313
+ /**
314
+ * Get all tags related to a specific tag
315
+ * @param idOrSlug - Tag ID or slug
316
+ * @returns Array of tags
317
+ */
318
+ async getRelatedTagsTags(idOrSlug) {
319
+ const endpoint = idOrSlug.includes("-") ? `/tags/slug/${idOrSlug}/related-tags/tags` : `/tags/${idOrSlug}/related-tags/tags`;
320
+ return this.request(endpoint);
321
+ }
322
+ // ==================== Team and Sport Methods ====================
323
+ /**
324
+ * Get all teams
325
+ * @param params - Optional pagination parameters
326
+ * @returns Array of teams
327
+ */
328
+ async getTeams(params) {
329
+ return this.request("/teams", params);
330
+ }
331
+ /**
332
+ * Get all sports
333
+ * @param params - Optional pagination parameters
334
+ * @returns Array of sports
335
+ */
336
+ async getSports(params) {
337
+ return this.request("/sports", params);
338
+ }
339
+ // ==================== Series Methods ====================
340
+ /**
341
+ * Get all series
342
+ * @param params - Optional pagination parameters
343
+ * @returns Array of series
344
+ */
345
+ async getSeries(params) {
346
+ return this.request("/series", params);
347
+ }
348
+ /**
349
+ * Get a specific series by ID
350
+ * @param seriesId - Series ID
351
+ * @returns Series details
352
+ */
353
+ async getSeriesById(seriesId) {
354
+ return this.request(`/series/${seriesId}`);
355
+ }
356
+ // ==================== Comment Methods ====================
357
+ /**
358
+ * Get comments with optional filtering
359
+ * @param params - Optional pagination and filter parameters
360
+ * @returns Array of comments
361
+ */
362
+ async getComments(params) {
363
+ return this.request("/comments", params);
364
+ }
365
+ /**
366
+ * Get a specific comment by ID
367
+ * @param commentId - Comment ID
368
+ * @returns Comment details
369
+ */
370
+ async getComment(commentId) {
371
+ return this.request(`/comments/${commentId}`);
372
+ }
373
+ /**
374
+ * Get comments by user address
375
+ * @param userAddress - User's Ethereum address
376
+ * @param params - Optional pagination parameters
377
+ * @returns Array of comments
378
+ */
379
+ async getCommentsByUser(userAddress, params) {
380
+ return this.request(`/comments/user_address/${userAddress}`, params);
381
+ }
382
+ // ==================== Grok AI Methods ====================
383
+ /**
384
+ * Get Grok AI-powered event summary
385
+ * @param eventSlug - Event slug
386
+ * @returns Event summary text
387
+ */
388
+ async grokEventSummary(eventSlug) {
389
+ const response = await this.post(
390
+ "https://polymarket.com/api/grok/event-summary",
391
+ { event_slug: eventSlug }
392
+ );
393
+ return response.summary;
394
+ }
395
+ /**
396
+ * Get Grok AI-powered election market explanation
397
+ * @param marketSlug - Market slug
398
+ * @returns Market explanation text
399
+ */
400
+ async grokElectionMarketExplanation(marketSlug) {
401
+ const response = await this.post(
402
+ "https://polymarket.com/api/grok/election-market-explanation",
403
+ { market_slug: marketSlug }
404
+ );
405
+ return response.explanation;
406
+ }
407
+ };
54
408
  var OsirisSigner = class {
55
409
  hubBaseUrl;
56
410
  accessToken;
@@ -3798,6 +4152,6 @@ var Signer = class {
3798
4152
  }
3799
4153
  };
3800
4154
 
3801
- export { DEFAULT_OSIRIS_RTDS_URL, HyperliquidClient, MemoryStateManager, OsirisEventRunner, OsirisRTDSService, OsirisSigner, PolymarketClient, PolymarketEventRunner, PolymarketRTDSService, PrivateKeySigner, RedisStateManager, Signer, StrategyEngine, UnifiedRTDSService, createConsoleLogger, createEventRunner, createOsirisContext, createOsirisRTDSService, createPolymarketEventRunner, createPolymarketRTDSService, createStrategyEngine, createUnifiedRTDSService, isActivitySubscription, isClobMarketSubscription, isClobUserSubscription, isCommentsSubscription, isCryptoPricesSubscription, isCustomSubscription, isEventBasedStrategy, isMarketSubscription, isOpportunitySubscription, isOsirisSubscription, isPolymarketSubscription, isRfqSubscription, isTickBasedStrategy, isWalletSubscription, runStrategy, validateStrategy };
4155
+ export { DEFAULT_OSIRIS_RTDS_URL, HyperliquidClient, MemoryStateManager, OsirisEventRunner, OsirisRTDSService, OsirisSigner, PolymarketClient, PolymarketEventRunner, PolymarketGammaClient, PolymarketRTDSService, PrivateKeySigner, RedisStateManager, Signer, StrategyEngine, UnifiedRTDSService, createConsoleLogger, createEventRunner, createOsirisContext, createOsirisRTDSService, createPolymarketEventRunner, createPolymarketRTDSService, createStrategyEngine, createUnifiedRTDSService, isActivitySubscription, isClobMarketSubscription, isClobUserSubscription, isCommentsSubscription, isCryptoPricesSubscription, isCustomSubscription, isEventBasedStrategy, isMarketSubscription, isOpportunitySubscription, isOsirisSubscription, isPolymarketSubscription, isRfqSubscription, isTickBasedStrategy, isWalletSubscription, runStrategy, validateStrategy };
3802
4156
  //# sourceMappingURL=index.js.map
3803
4157
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
1
  import type { OHLCV, TAParams } from "@vesper85/technical-indicators";
2
- import type { Event as GammaEvent, Tag, Team, Sport, Series, Comment as GammaComment, SearchResults, PaginatedResponse, MarketFilters, EventFilters, EventPaginationFilters, PaginationParams, SearchParams, GammaMarket } from "polymarket-gamma";
2
+ import type { Event as GammaEvent, Tag, Team, Sport, Series, Comment as GammaComment, SearchResults, PaginatedResponse, MarketFilters, EventFilters, EventPaginationFilters, PaginationParams, SearchParams, GammaMarket } from "../gamma";
3
3
  import type { ClearinghouseState, SpotMeta, SpotClearinghouseState, SpotMetaAndAssetCtxs, Meta, MetaAndAssetCtxs, UserFunding, UserNonFundingLedgerUpdates, FundingHistory, PredictedFundings, PerpsAtOpenInterestCap, PerpDexLimits, AllMids, UserOpenOrders, FrontendOpenOrders, UserFills, UserRateLimit, OrderStatus, L2Book, CandleSnapshot, HistoricalOrder, TwapSliceFill, SubAccount, VaultDetails, VaultEquity, UserRole, Delegation, DelegatorSummary, DelegatorHistoryEntry, DelegatorReward, ValidatorSummary, VaultSummary, UserFees, PortfolioPeriods, PreTransferCheck, Referral, ExtraAgent, LegalCheck, TwapHistory, MultiSigSigners, BuilderFeeApproval, UserOrderHistory } from "hyperliquid";
4
4
  export interface OsirisState {
5
5
  get(key: string): Promise<any>;
@@ -1,3 +1,3 @@
1
- import { GammaMarket } from "polymarket-gamma";
1
+ import { GammaMarket } from "../gamma";
2
2
  export declare function mapToGammaMarket(raw: any): GammaMarket;
3
3
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vesper85/strategy-sdk",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "type": "module",
5
5
  "description": "SDK for writing and running trading strategies with Polymarket and Hyperliquid integrations",
6
6
  "keywords": [
@@ -11,11 +11,9 @@
11
11
  "trading-bot",
12
12
  "osiris"
13
13
  ],
14
- "main": "./dist/index.js",
15
- "types": "./dist/index.d.ts",
16
14
  "exports": {
17
15
  ".": {
18
- "types": "./gs/index.d.ts",
16
+ "types": "./dist/index.d.ts",
19
17
  "import": "./dist/index.js",
20
18
  "default": "./dist/index.js"
21
19
  },
@@ -54,9 +52,6 @@
54
52
  "superjson": "^2.2.6",
55
53
  "viem": "^2.30.1"
56
54
  },
57
- "peerDependencies": {
58
- "polymarket-gamma": "^0.4.0"
59
- },
60
55
  "devDependencies": {
61
56
  "@changesets/cli": "^2.29.8",
62
57
  "@osiris-ai/eslint-config": "workspace:*",