polyedge 0.0.0-stage → 1.0.0

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,1106 @@
1
+ import { EventEmitter } from 'node:events';
2
+
3
+ /**
4
+ * PolyEdge API Data Models
5
+ * Aligned with PolyEdge OpenAPI 3.1.0 specification.
6
+ */
7
+ type Side = "BUY" | "SELL";
8
+ type TokenIndex = 0 | 1;
9
+ /**
10
+ * Data model for ActiveSessionInfo
11
+ */
12
+ interface ActiveSessionInfo {
13
+ /** Masked API credential used to authenticate the stream connection */
14
+ api_key?: string;
15
+ /** Remote IP address of the connected client */
16
+ client_ip?: string;
17
+ /** ISO 8601 timestamp when the SSE connection was established */
18
+ connected_at?: string;
19
+ /** Total active connection uptime in seconds */
20
+ duration_seconds?: number;
21
+ /** Total number of live matched order events delivered over this connection */
22
+ pushed_tx_count?: number;
23
+ /** Unique persistent stream identifier (UUID) */
24
+ stream_id?: string;
25
+ /** HTTP User-Agent identifier of the client library or application */
26
+ user_agent?: string;
27
+ }
28
+ /**
29
+ * Data model for CreateAPIKeyRequest
30
+ */
31
+ interface CreateAPIKeyRequest {
32
+ key?: string;
33
+ name?: string;
34
+ }
35
+ /**
36
+ * Data model for DeleteKeyResponse
37
+ */
38
+ interface DeleteKeyResponse {
39
+ id?: string;
40
+ }
41
+ /**
42
+ * Data model for DeleteStreamResponse
43
+ */
44
+ interface DeleteStreamResponse {
45
+ id?: string;
46
+ }
47
+ /**
48
+ * Data model for DepositItem
49
+ */
50
+ interface DepositItem {
51
+ address?: string;
52
+ deposit_count?: number;
53
+ /** Earliest deposit time in 60-day window (RFC3339) */
54
+ first_deposit_at?: string;
55
+ first_trade_at?: string;
56
+ /** Most recent deposit time (RFC3339) */
57
+ last_deposit_at?: string;
58
+ last_trade_at?: string;
59
+ /** 6 decimals micro-USD integer as string (e.g. "100000000") */
60
+ total_deposit?: string;
61
+ }
62
+ /**
63
+ * Data model for DepositQueryResult
64
+ */
65
+ interface DepositQueryResult {
66
+ items?: DepositItem[];
67
+ total?: number;
68
+ updated_at?: string;
69
+ }
70
+ /**
71
+ * Data model for ErrorResponse
72
+ */
73
+ interface ErrorResponse {
74
+ error?: string;
75
+ message?: string;
76
+ }
77
+ /**
78
+ * Data model for HistoryMarket
79
+ */
80
+ interface HistoryMarket {
81
+ /** Market thumbnail image URL */
82
+ icon?: string;
83
+ /** Unique numeric prediction market identifier */
84
+ id?: number;
85
+ /** Raw JSON array of outcome display names, e.g. ["Yes", "No"] */
86
+ outcomes?: [string, string];
87
+ /** Full title question describing the market condition */
88
+ question?: string;
89
+ /** Timestamp when market officially settled (RFC 3339 UTC), or null if active */
90
+ resolved_at?: string;
91
+ /** Resolution outcome (-2: unresolved, -1: void/invalid, 0-100: payout percentage for Outcome 0, e.g. 100 = Outcome 0 won, 0 = Outcome 1 won, 50 = 50/50 split) */
92
+ result?: number;
93
+ /** URL slug of the recurring sports league or tournament series */
94
+ series_slug?: string;
95
+ /** URL-friendly slug identifying the market on Polymarket */
96
+ slug?: string;
97
+ }
98
+ /**
99
+ * Data model for HourlyStat
100
+ */
101
+ interface HourlyStat {
102
+ /** Aggregate capital cost basis in micro-USD (6 decimals) */
103
+ cost_basis?: number;
104
+ /** Total trading fees incurred in micro-USD (6 decimals) */
105
+ fee?: number;
106
+ /** 1-hour UTC bucket timestamp (ISO 8601) */
107
+ hour?: string;
108
+ /** Maker trading volume in micro-USD (6 decimals) */
109
+ maker_volume?: number;
110
+ /** Number of distinct prediction markets active or settled in this hour */
111
+ market_count?: number;
112
+ /** Realized net PnL in micro-USD (6 decimals) */
113
+ pnl?: number;
114
+ /** Taker trading volume in micro-USD (6 decimals) */
115
+ taker_volume?: number;
116
+ /** Number of profitable markets settled in this hour */
117
+ win_count?: number;
118
+ }
119
+ /**
120
+ * Data model for LeaderboardResponse
121
+ */
122
+ interface LeaderboardResponse {
123
+ /** Total count of matching traders for pagination */
124
+ total_count?: number;
125
+ /** Ranked array of trader performance summaries */
126
+ traders?: TraderSummary[];
127
+ }
128
+ /**
129
+ * Data model for LiveOrder
130
+ */
131
+ interface LiveOrder {
132
+ /** Execution and relayer fee paid in micro-USDC */
133
+ fee?: string;
134
+ /** Underlying signed off-chain CLOB limit order metadata */
135
+ order?: OrderInfo;
136
+ /** Market outcome label (e.g. "Yes", "No", "Up", "Down") */
137
+ outcome?: string;
138
+ /** Filled outcome shares amount represented as a 10^6 fixed-point decimal string */
139
+ shares?: string;
140
+ /** Order execution direction: "BUY" or "SELL" */
141
+ side?: Side;
142
+ /** 0-based index matching market.token_ids and market.outcomes */
143
+ token_ids_index?: 0 | 1;
144
+ /** Filled USDC notional amount in micro-USDC (10^6 scale) decimal string */
145
+ usdc?: string;
146
+ /** Trader account identity (wallet address and optional display pseudonym) */
147
+ user?: MonitorTrader;
148
+ }
149
+ /**
150
+ * Data model for LiveTransaction
151
+ */
152
+ interface LiveTransaction {
153
+ /** List of matched maker limit orders filled in this transaction */
154
+ makers?: LiveOrder[];
155
+ /** Associated Polymarket prediction market condition and metadata */
156
+ market?: Market;
157
+ /** Taker order execution details that initiated the match against the CLOB */
158
+ taker?: LiveOrder;
159
+ /** ISO 8601 UTC timestamp (millisecond precision) indicating when the pending transaction was detected in the mempool */
160
+ timestamp?: string;
161
+ /** Canonical Ethereum/Polygon on-chain transaction hash confirming the match execution */
162
+ tx_hash?: string;
163
+ }
164
+ /**
165
+ * Data model for Market
166
+ */
167
+ interface Market {
168
+ /** 32-byte hexadecimal condition ID from Gnosis Conditional Tokens */
169
+ condition_id?: string;
170
+ /** URL slug of the parent event containing this market */
171
+ event_slug?: string;
172
+ /** Sub-category item title within a grouped multi-market event */
173
+ group_item_title?: string;
174
+ /** Polymarket numeric prediction market identifier (e.g. 3688221) */
175
+ id?: number;
176
+ /** True if market operates under multi-outcome negative risk adapter */
177
+ neg_risk?: boolean;
178
+ /** Array of market outcome labels: [Outcome 1, Outcome 2] (e.g. ["Yes", "No"]) */
179
+ outcomes?: [string, string];
180
+ /** Full question describing the prediction market condition */
181
+ question?: string;
182
+ /** URL slug of the recurring sports league or tournament series */
183
+ series_slug?: string;
184
+ /** URL-friendly slug identifying the market on Polymarket */
185
+ slug?: string;
186
+ /** Sports market classification (e.g. moneyline, spread, over/under) */
187
+ sports_market_type?: string;
188
+ /** ISO 8601 UTC timestamp when trading began */
189
+ start_date?: string;
190
+ /** Canonical categorical tags for content filtering */
191
+ tags_slug?: string[];
192
+ /** ERC-1155 token IDs: [Token 1, Token 2] */
193
+ token_ids?: [string, string];
194
+ }
195
+ /**
196
+ * Data model for MarketDetailResponse
197
+ */
198
+ interface MarketDetailResponse {
199
+ /** Complete standardized market metadata matching exporter format */
200
+ market?: MarketMetadata;
201
+ /** Ranked list of top 20 profitable traders in this market */
202
+ top_earners?: MarketEarner[];
203
+ /** Total protocol and liquidity fees collected in micro-USD (6 decimals) */
204
+ total_fees?: number;
205
+ /** Total positive realized PnL distributed to winners in micro-USD (6 decimals) */
206
+ total_pnl_distributed?: number;
207
+ /** Total count of distinct wallet addresses that traded this market */
208
+ total_traders?: number;
209
+ /** Cumulative trading volume across all participants in micro-USD (6 decimals) */
210
+ total_volume?: number;
211
+ /** Total number of distinct traders with positive realized PnL */
212
+ total_winners?: number;
213
+ }
214
+ /**
215
+ * Data model for MarketEarner
216
+ */
217
+ interface MarketEarner {
218
+ /** Executed fill orders for this earner (included when include_orders=true) */
219
+ orders?: UserOrder[];
220
+ /** Realized net profit and loss in micro-USD (6 decimals, e.g. 1000000 = 1 USD) */
221
+ pnl?: number;
222
+ /** Public identity dossier of the earner */
223
+ profile?: TraderIdentity;
224
+ /** Rank position among top earners in this market (1-based) */
225
+ rank?: number;
226
+ /** Return on investment percentage (e.g. 25.5 for 25.5%) */
227
+ roi?: number;
228
+ /** Total traded volume in micro-USD (6 decimals) */
229
+ volume?: number;
230
+ }
231
+ /**
232
+ * Data model for MarketMetadata
233
+ */
234
+ interface MarketMetadata {
235
+ /** 0x-prefixed 66-character CTF condition identifier */
236
+ condition_id?: string;
237
+ /** Timestamp when market was indexed in database (RFC 3339 UTC) */
238
+ created_at?: string;
239
+ /** Extended details and market resolution criteria */
240
+ description?: string;
241
+ /** Estimated resolution date or scheduled closing time (RFC 3339 UTC) */
242
+ end_date?: string;
243
+ /** URL slug of the parent event containing this market */
244
+ event_slug?: string;
245
+ /** Detailed fee schedule JSON specification */
246
+ fee_schedule?: Record<string, any>;
247
+ /** Fee model classification (e.g. "dynamic", "fixed") */
248
+ fee_type?: string;
249
+ /** Whether trading fees are activated on this market */
250
+ fees_enabled?: boolean;
251
+ /** Threshold for numerical interval outcomes if applicable */
252
+ group_item_threshold?: number;
253
+ /** Sub-category item title within a grouped multi-market event */
254
+ group_item_title?: string;
255
+ /** Market thumbnail image URL */
256
+ icon?: string;
257
+ /** Unique numeric prediction market identifier */
258
+ id?: number;
259
+ /** True if market operates under multi-outcome negative risk adapter */
260
+ neg_risk?: boolean;
261
+ /** Raw JSON array of outcome display names, e.g. ["Yes", "No"] */
262
+ outcomes?: [string, string];
263
+ /** Full title question describing the market condition */
264
+ question?: string;
265
+ /** Source URL or oracle specification for resolution */
266
+ resolution_source?: string;
267
+ /** Timestamp when the market officially settled (RFC 3339 UTC), or null if active */
268
+ resolved_at?: string;
269
+ /** Resolution outcome (-2: unresolved, -1: void/invalid, 0-100: payout percentage for Outcome 0, e.g. 100 = Outcome 0 won, 0 = Outcome 1 won, 50 = 50/50 split) */
270
+ result?: number;
271
+ /** URL slug of the recurring sports league or tournament series */
272
+ series_slug?: string;
273
+ /** URL-friendly slug identifying the market on Polymarket */
274
+ slug?: string;
275
+ /** Sports market classification type if applicable */
276
+ sports_market_type?: string;
277
+ /** Timestamp when trading began (RFC 3339 UTC) */
278
+ start_date?: string;
279
+ /** Raw JSON array of topic tag URL slugs */
280
+ tags_slug?: string[];
281
+ /** Array of 2 ERC-1155 token IDs corresponding to outcomes */
282
+ token_ids?: [string, string];
283
+ }
284
+ /**
285
+ * Data model for MarketSettlementDetail
286
+ */
287
+ interface MarketSettlementDetail {
288
+ /** ISO 8601 UTC timestamp of the trader's last trade in this market */
289
+ last_trade_at?: string;
290
+ /** Concise standardized market metadata */
291
+ market?: HistoryMarket;
292
+ /** Detailed order fill events (present only when include_orders=true) */
293
+ orders?: UserOrder[];
294
+ /** Realized net PnL in micro-USD (6 decimals) */
295
+ pnl?: number;
296
+ /** Return on investment percentage in this market */
297
+ roi?: number;
298
+ /** Total traded volume in this market in micro-USD (6 decimals) */
299
+ volume?: number;
300
+ }
301
+ /**
302
+ * Data model for MonitorTrader
303
+ */
304
+ interface MonitorTrader {
305
+ /** Canonical 42-character hexadecimal Ethereum/Polygon wallet address */
306
+ address?: string;
307
+ /** Polymarket public username */
308
+ name?: string;
309
+ }
310
+ /**
311
+ * Data model for OrderInfo
312
+ */
313
+ interface OrderInfo {
314
+ /** Cryptographic EIP-712 order hash identifying the unique off-chain order */
315
+ order_hash?: string;
316
+ /** Original clob order shares capacity in 10^6 scale */
317
+ shares?: string;
318
+ /** Signature scheme encoding (0: Direct EOA, 1: Magic / Proxy Wallet, 2: Gnosis Safe, 3: Deposit Wallet (ERC-1271)) */
319
+ signature_type?: number;
320
+ /** Unix epoch seconds when the order was signed */
321
+ timestamp?: string;
322
+ /** Original clob order notional value in micro-USDC (10^6 scale) */
323
+ usdc?: string;
324
+ }
325
+ /**
326
+ * Data model for QuoteSubscriptionRequest
327
+ */
328
+ interface QuoteSubscriptionRequest {
329
+ billing_cycle?: string;
330
+ promo_code?: string;
331
+ tier?: string;
332
+ }
333
+ /**
334
+ * Data model for QuoteSubscriptionResponse
335
+ */
336
+ interface QuoteSubscriptionResponse {
337
+ amount_to_pay?: number;
338
+ billing_cycle?: string;
339
+ can_afford?: boolean;
340
+ current_balance?: number;
341
+ current_billing_cycle?: string;
342
+ current_license?: string;
343
+ current_tier?: string;
344
+ discount_amount?: number;
345
+ duration_days?: number;
346
+ is_active?: boolean;
347
+ license?: string;
348
+ message?: string;
349
+ original_price?: number;
350
+ prorated_credit?: number;
351
+ tier?: string;
352
+ }
353
+ /**
354
+ * Data model for SubscribeRequest
355
+ */
356
+ interface SubscribeRequest {
357
+ billing_cycle?: string;
358
+ idempotency_key?: string;
359
+ promo_code?: string;
360
+ tier?: string;
361
+ }
362
+ /**
363
+ * Data model for SubscribeResponse
364
+ */
365
+ interface SubscribeResponse {
366
+ subscription?: UserSubscription;
367
+ user?: UserProfile;
368
+ }
369
+ /**
370
+ * Data model for TagStat
371
+ */
372
+ interface TagStat {
373
+ /** Passive maker volume in micro-USD (6 decimals) */
374
+ maker_volume?: number;
375
+ /** Number of markets traded in this tag */
376
+ markets_count?: number;
377
+ /** Realized net PnL in micro-USD (6 decimals) */
378
+ pnl?: number;
379
+ /** Return on investment percentage for this tag */
380
+ roi?: number;
381
+ /** Category tag URL slug (e.g. "crypto", "politics", "sports") */
382
+ slug?: string;
383
+ /** Aggressive taker volume in micro-USD (6 decimals) */
384
+ taker_volume?: number;
385
+ /** Aggregated trading volume in micro-USD (6 decimals) */
386
+ volume?: number;
387
+ /** Win rate percentage for this tag (0.0 to 100.0) */
388
+ win_rate?: number;
389
+ /** Number of profitable markets in this tag */
390
+ wins_count?: number;
391
+ }
392
+ /**
393
+ * Data model for Tier
394
+ */
395
+ interface Tier {
396
+ /** Whether the tier is permitted to access REST API endpoints */
397
+ allow_rest_api?: boolean;
398
+ /** Whether the tier is permitted to access real-time stream endpoints */
399
+ allow_stream?: boolean;
400
+ /** Whether this tier supports a trial subscription */
401
+ allow_trial?: boolean;
402
+ /** Record creation timestamp */
403
+ created_at?: string;
404
+ /** Unique tier identifier (e.g. "free", "starter", "individual", "builder") */
405
+ id?: string;
406
+ /** Relative tier rank for upgrade comparison (0=free, 1=starter, etc.) */
407
+ level?: number;
408
+ /** License type: "personal" or "builder" */
409
+ license?: string;
410
+ /** Maximum API queries allowed per 24-hour UTC window (0 = unlimited) */
411
+ max_daily_requests?: number;
412
+ /** Maximum aggregated streaming seconds allowed per 24-hour UTC window */
413
+ max_daily_stream_seconds?: number;
414
+ /** Maximum wallet addresses that can be filtered per stream */
415
+ max_filter_addrs?: number;
416
+ /** Maximum market series allowed across active streams (0 = disabled) */
417
+ max_filter_series?: number;
418
+ /** Maximum market tags allowed across active streams (0 = disabled) */
419
+ max_filter_tags?: number;
420
+ /** Maximum concurrent API keys allowed per account */
421
+ max_keys?: number;
422
+ /** Maximum unfiltered streams allowed */
423
+ max_naked_streams?: number;
424
+ /** Maximum API queries allowed per second */
425
+ max_qps?: number;
426
+ /** Maximum concurrent active SSE connections per account */
427
+ max_sessions?: number;
428
+ /** Maximum persistent stream IDs the user can create */
429
+ max_streams?: number;
430
+ /** Monthly credit quota allocated to this tier */
431
+ monthly_credits?: number;
432
+ /** Display title of the tier */
433
+ name?: string;
434
+ /** 6 decimals, micro-USD (e.g. 99_000_000 = 99 USD) */
435
+ price_monthly?: number;
436
+ /** 6 decimals, micro-USD (e.g. 237_000_000 = 237 USD) */
437
+ price_quarterly?: number;
438
+ /** 6 decimals, micro-USD for trial (e.g. 10_000_000 = 10 USD) */
439
+ price_trial?: number;
440
+ /** 6 decimals, micro-USD (e.g. 499_000_000 = 499 USD) */
441
+ price_yearly?: number;
442
+ /** Duration in days for trial subscription (e.g. 5) */
443
+ trial_duration_days?: number;
444
+ /** Last modification timestamp */
445
+ updated_at?: string;
446
+ }
447
+ /**
448
+ * Data model for TraderHistoryResponse
449
+ */
450
+ interface TraderHistoryResponse {
451
+ /** Paginated list of market settlement details */
452
+ history?: MarketSettlementDetail[];
453
+ /** Total count of matching market positions for pagination */
454
+ total_count?: number;
455
+ }
456
+ /**
457
+ * Data model for TraderHourlyStatsResponse
458
+ */
459
+ interface TraderHourlyStatsResponse {
460
+ /** Chronological array of 1-hour performance metrics */
461
+ stats?: HourlyStat[];
462
+ }
463
+ /**
464
+ * Data model for TraderIdentity
465
+ */
466
+ interface TraderIdentity {
467
+ /** Checksummed 0x-prefixed EVM wallet address */
468
+ address?: string;
469
+ /** Custom display name or Polymarket profile username */
470
+ name?: string;
471
+ /** ISO 8601 UTC timestamp of Polymarket profile creation */
472
+ profile_created_at?: string;
473
+ /** Public avatar image URL */
474
+ profile_image?: string;
475
+ /** Linked X (formerly Twitter) social handle */
476
+ x_username?: string;
477
+ }
478
+ /**
479
+ * Data model for TraderProfileResponse
480
+ */
481
+ interface TraderProfileResponse {
482
+ /** ISO 8601 UTC timestamp of trader's most recent trade across the platform */
483
+ last_trade_at?: string;
484
+ /** Public identity dossier of the trader */
485
+ profile?: TraderIdentity;
486
+ /** Trader's pUSD balance in micro-pUSD (6 decimals, e.g. 1000000 = 1 pUSD) */
487
+ pusd_balance?: number;
488
+ /** Polymarket Taker Rebate Program tier level (0-6: 0=Tier 0, 1=Bronze, 2=Silver, 3=Gold, 4=Platinum, 5=Diamond, 6=Obsidian) */
489
+ taker_tier?: number;
490
+ /** Descriptive taker rebate tier name ("Tier 0", "Bronze", "Silver", "Gold", "Platinum", "Diamond", "Obsidian", or empty string if unsynced) */
491
+ taker_tier_name?: string;
492
+ /** Performance breakdown across top 5 categories in last 30 days */
493
+ top_tags?: TagStat[];
494
+ /** Rolling 30-day taker Weighted Volume (wV) in USD, calculated by Trade Size * (1 - Entry Price) * Category Weight * Bonuses */
495
+ weighted_volume?: number;
496
+ }
497
+ /**
498
+ * Data model for TraderSummary
499
+ */
500
+ interface TraderSummary {
501
+ /** ISO 8601 UTC timestamp of trader's most recent trade across the platform */
502
+ last_trade_at?: string;
503
+ /** Number of distinct prediction markets traded in timeframe */
504
+ markets_count?: number;
505
+ /** Public identity dossier of the trader */
506
+ profile?: TraderIdentity;
507
+ /** Leaderboard ranking position (1-based) */
508
+ rank?: number;
509
+ /** Return on investment percentage over timeframe (e.g. 25.5 for 25.5%) */
510
+ roi?: number;
511
+ /** Realized net profit and loss in micro-USD (6 decimals, e.g. 1000000 = 1 USD) */
512
+ total_pnl?: number;
513
+ /** Aggregated trading volume in micro-USD (6 decimals) */
514
+ total_volume?: number;
515
+ /** Percentage of profitable closed positions (0.0 to 100.0) */
516
+ win_rate?: number;
517
+ /** Number of profitable settled markets in timeframe */
518
+ wins_count?: number;
519
+ }
520
+ /**
521
+ * Data model for UpdateSubscriptionRequest
522
+ */
523
+ interface UpdateSubscriptionRequest {
524
+ addresses?: string[];
525
+ series?: string[];
526
+ tags?: string[];
527
+ }
528
+ /**
529
+ * Data model for UserAPIKey
530
+ */
531
+ interface UserAPIKey {
532
+ created_at?: string;
533
+ key?: string;
534
+ name?: string;
535
+ status?: number;
536
+ }
537
+ /**
538
+ * Data model for UserActiveSessionsResponse
539
+ */
540
+ interface UserActiveSessionsResponse {
541
+ /** Array of active connected client session metadata */
542
+ data?: ActiveSessionInfo[];
543
+ /** Total concurrent active sessions currently running across all user streams */
544
+ total_count?: number;
545
+ }
546
+ /**
547
+ * Data model for UserCreateStreamRequest
548
+ */
549
+ interface UserCreateStreamRequest {
550
+ addresses?: string[];
551
+ name?: string;
552
+ series?: string[];
553
+ tags?: string[];
554
+ }
555
+ /**
556
+ * Data model for UserKeysResponse
557
+ */
558
+ interface UserKeysResponse {
559
+ data?: UserAPIKey[];
560
+ total_count?: number;
561
+ }
562
+ /**
563
+ * Data model for UserLedgerEntry
564
+ */
565
+ interface UserLedgerEntry {
566
+ amount?: number;
567
+ balance_after?: number;
568
+ created_at?: string;
569
+ reference_id?: string;
570
+ type?: string;
571
+ }
572
+ /**
573
+ * Data model for UserLedgerResponse
574
+ */
575
+ interface UserLedgerResponse {
576
+ data?: UserLedgerEntry[];
577
+ total_count?: number;
578
+ }
579
+ /**
580
+ * Data model for UserOrder
581
+ */
582
+ interface UserOrder {
583
+ /** Protocol trading fee deducted in micro-USD (6 decimals) */
584
+ fee?: number;
585
+ /** True if executed against resting book liquidity as a taker */
586
+ is_taker?: boolean;
587
+ /** Prediction outcome label (e.g. "Yes", "No") */
588
+ outcome?: string;
589
+ /** Filled outcome token shares (6 decimals) */
590
+ shares?: number;
591
+ /** Order execution side: "BUY" or "SELL" */
592
+ side?: Side;
593
+ /** ISO 8601 UTC timestamp of order fill execution */
594
+ time?: string;
595
+ /** Total collateral USDC transferred (6 decimals micro-USD) */
596
+ usdc?: number;
597
+ }
598
+ /**
599
+ * Data model for UserOrdersResponse
600
+ */
601
+ interface UserOrdersResponse {
602
+ /** Chronological list of compacted order fill events */
603
+ orders?: UserOrder[];
604
+ }
605
+ /**
606
+ * Data model for UserProfile
607
+ */
608
+ interface UserProfile {
609
+ billing_cycle?: string;
610
+ created_at?: string;
611
+ deposit_address?: string;
612
+ deposit_balance?: number;
613
+ email?: string;
614
+ is_expired?: boolean;
615
+ status?: number;
616
+ telegram_id?: number;
617
+ tier?: string;
618
+ tier_expires_at?: string;
619
+ updated_at?: string;
620
+ }
621
+ /**
622
+ * Data model for UserSessionHistoryResponse
623
+ */
624
+ interface UserSessionHistoryResponse {
625
+ /** Array of historical stream session records */
626
+ data?: UserSessionRecord[];
627
+ /** Total count of historical session records */
628
+ total_count?: number;
629
+ }
630
+ /**
631
+ * Data model for UserSessionRecord
632
+ */
633
+ interface UserSessionRecord {
634
+ /** Masked API credential used to authenticate the stream connection */
635
+ api_key?: string;
636
+ /** Remote IP address of the connected client */
637
+ client_ip?: string;
638
+ /** Diagnostic termination reason (e.g. client_closed, admin_force_disconnect, quota_exceeded) */
639
+ close_reason?: string;
640
+ /** ISO 8601 timestamp when the SSE connection was established */
641
+ connected_at?: string;
642
+ /** ISO 8601 timestamp when the connection was closed, or null if currently active */
643
+ disconnected_at?: string;
644
+ /** Total connection duration in seconds */
645
+ duration_seconds?: number;
646
+ /** Total number of live matched order events delivered over this connection */
647
+ pushed_tx_count?: number;
648
+ /** Target stream unique identifier (UUID) */
649
+ stream_id?: string;
650
+ /** HTTP User-Agent identifier of the client library or application */
651
+ user_agent?: string;
652
+ }
653
+ /**
654
+ * Data model for UserStreamResponse
655
+ */
656
+ interface UserStreamResponse {
657
+ active_sessions?: number;
658
+ addresses?: string[];
659
+ created_at?: string;
660
+ enabled?: boolean;
661
+ id?: string;
662
+ name?: string;
663
+ series?: string[];
664
+ tags?: string[];
665
+ updated_at?: string;
666
+ }
667
+ /**
668
+ * Data model for UserStreamsResponse
669
+ */
670
+ interface UserStreamsResponse {
671
+ data?: UserStreamResponse[];
672
+ total_count?: number;
673
+ }
674
+ /**
675
+ * Data model for UserSubscription
676
+ */
677
+ interface UserSubscription {
678
+ amount_paid?: number;
679
+ billing_cycle?: string;
680
+ created_at?: string;
681
+ discount_amount?: number;
682
+ duration_days?: number;
683
+ expires_at?: string;
684
+ original_price?: number;
685
+ plan_tier?: string;
686
+ promo_code?: string;
687
+ prorated_credit?: number;
688
+ starts_at?: string;
689
+ status?: string;
690
+ }
691
+ /**
692
+ * Data model for UserTelemetryResponse
693
+ */
694
+ interface UserTelemetryResponse {
695
+ date?: string;
696
+ endpoints?: Record<string, any>;
697
+ total_requests?: number;
698
+ }
699
+ /**
700
+ * Data model for UserUpdateKeyRequest
701
+ */
702
+ interface UserUpdateKeyRequest {
703
+ name?: string;
704
+ /** 1: Active, 0: Disabled */
705
+ status?: number;
706
+ }
707
+ /**
708
+ * Data model for UserUpdateStreamMetadataRequest
709
+ */
710
+ interface UserUpdateStreamMetadataRequest {
711
+ enabled?: boolean;
712
+ name?: string;
713
+ }
714
+ /**
715
+ * Data model for UserWithdrawRequest
716
+ */
717
+ interface UserWithdrawRequest {
718
+ network: string;
719
+ to_address: string;
720
+ token: string;
721
+ }
722
+ /**
723
+ * Data model for UserWithdrawResponse
724
+ */
725
+ interface UserWithdrawResponse {
726
+ user?: UserProfile;
727
+ withdrawal?: Withdrawal;
728
+ }
729
+ /**
730
+ * Data model for ValidatePromoCodeRequest
731
+ */
732
+ interface ValidatePromoCodeRequest {
733
+ billing_cycle?: string;
734
+ code?: string;
735
+ tier?: string;
736
+ }
737
+ /**
738
+ * Data model for ValidatePromoCodeResponse
739
+ */
740
+ interface ValidatePromoCodeResponse {
741
+ amount_to_pay?: number;
742
+ code?: string;
743
+ discount_amount?: number;
744
+ message?: string;
745
+ original_price?: number;
746
+ prorated_credit?: number;
747
+ valid?: boolean;
748
+ }
749
+ /**
750
+ * Data model for Withdrawal
751
+ */
752
+ interface Withdrawal {
753
+ /** Full balance amount withdrawn in micro-USD */
754
+ amount?: number;
755
+ /** Withdrawal request creation timestamp */
756
+ created_at?: string;
757
+ id?: number;
758
+ /** User's most recent deposit timestamp */
759
+ last_deposit_at?: string;
760
+ /** "bsc" or "polygon" */
761
+ network?: string;
762
+ /** Reason recorded upon rejection */
763
+ reject_reason?: string;
764
+ /** Administrative review timestamp */
765
+ reviewed_at?: string;
766
+ /** "pending", "completed", "rejected" */
767
+ status?: string;
768
+ /** Destination EVM wallet address */
769
+ to_address?: string;
770
+ /** "USDC" or "USDT" */
771
+ token?: string;
772
+ /** Transaction hash on destination network */
773
+ tx_hash?: string;
774
+ /** Last modification timestamp */
775
+ updated_at?: string;
776
+ user_email?: string;
777
+ user_id?: number;
778
+ }
779
+
780
+ interface StreamOptions {
781
+ apiKey: string;
782
+ streamBaseUrl?: string;
783
+ heartbeatTimeoutMs?: number;
784
+ initialBackoffMs?: number;
785
+ maxBackoffMs?: number;
786
+ }
787
+ interface StreamEvents {
788
+ tx: (tx: LiveTransaction, eventId: string) => void;
789
+ heartbeat: () => void;
790
+ error: (err: Error) => void;
791
+ reconnect: (attempt: number, delayMs: number) => void;
792
+ close: (reason: string) => void;
793
+ }
794
+ declare class PolyEdgeStream extends EventEmitter {
795
+ private readonly streamId;
796
+ private readonly apiKey;
797
+ private readonly streamBaseUrl;
798
+ private readonly heartbeatTimeoutMs;
799
+ private readonly initialBackoffMs;
800
+ private readonly maxBackoffMs;
801
+ private lastEventId;
802
+ private abortController;
803
+ private watchdogTimer;
804
+ private reconnectTimer;
805
+ private reconnectAttempts;
806
+ private isDestroyed;
807
+ private isConnecting;
808
+ private asyncQueue;
809
+ private asyncResolvers;
810
+ constructor(streamId: string, options: StreamOptions);
811
+ getLastEventId(): string | null;
812
+ connect(): void;
813
+ private parseBlock;
814
+ private startWatchdog;
815
+ private resetWatchdog;
816
+ private clearWatchdog;
817
+ private clearTimers;
818
+ private scheduleReconnect;
819
+ private pushAsync;
820
+ [Symbol.asyncIterator](): AsyncGenerator<LiveTransaction, void, undefined>;
821
+ destroy(reason?: string): void;
822
+ }
823
+
824
+ interface PolyEdgeClientOptions {
825
+ /** API Key token for authentication */
826
+ apiKey: string;
827
+ /** Base URL for REST analytics & account gateway (default: https://api.polyedge.dev) */
828
+ apiBaseUrl?: string;
829
+ /** Base URL for SSE real-time streaming gateway (default: https://stream.polyedge.dev) */
830
+ streamBaseUrl?: string;
831
+ }
832
+ /** Base requester helper shared by services */
833
+ type Requester = <T>(baseUrl: string, endpoint: string, options?: RequestInit) => Promise<T>;
834
+ /** Streams Service: APIs for streams operations */
835
+ declare class StreamsService {
836
+ private readonly request;
837
+ private readonly apiBaseUrl;
838
+ private readonly streamBaseUrl;
839
+ private readonly apiKey;
840
+ constructor(request: Requester, apiBaseUrl: string, streamBaseUrl: string, apiKey: string);
841
+ /**
842
+ * Connect to real-time Server-Sent Events (SSE) order execution stream
843
+ * @param streamId Target stream ID
844
+ */
845
+ connect(streamId: string, options?: Partial<StreamOptions>): PolyEdgeStream;
846
+ /**
847
+ * List User Streams
848
+ * Returns custom and managed real-time trade streams configured by the user.
849
+ * @returns Models.UserStreamsResponse
850
+ */
851
+ list(): Promise<UserStreamsResponse>;
852
+ /**
853
+ * Create Filtered Order Stream
854
+ * Provisions a new custom real-time stream with optional address, tag, or series filters.
855
+ * @param req Request payload
856
+ * @returns Models.UserStreamResponse
857
+ */
858
+ create(req: UserCreateStreamRequest): Promise<UserStreamResponse>;
859
+ /**
860
+ * Get Stream Metadata
861
+ * Fetches metadata, active sessions count, and filter configuration for a specific stream.
862
+ * @param id Stream unique ID
863
+ * @returns Models.UserStreamResponse
864
+ */
865
+ get(id: string): Promise<UserStreamResponse>;
866
+ /**
867
+ * Delete Stream
868
+ * Permanently removes a stream and gracefully disconnects all connected listener sessions.
869
+ * @param id Stream unique ID
870
+ * @returns Models.DeleteStreamResponse
871
+ */
872
+ delete(id: string): Promise<DeleteStreamResponse>;
873
+ /**
874
+ * Update Stream Metadata
875
+ * Updates operational attributes of the stream, such as nickname or enabled/disabled status.
876
+ * @param id Stream unique ID
877
+ * @param req Request payload
878
+ * @returns Models.UserStreamResponse
879
+ */
880
+ updateMetadata(id: string, req: UserUpdateStreamMetadataRequest): Promise<UserStreamResponse>;
881
+ /**
882
+ * Update Stream Filter Subscription
883
+ * Dynamically mutates monitored wallet addresses, market tags, or series slugs without disconnecting SSE clients.
884
+ * @param id Stream unique ID
885
+ * @param req Request payload
886
+ * @returns Models.UserStreamResponse
887
+ */
888
+ updateSubscription(id: string, req: UpdateSubscriptionRequest): Promise<UserStreamResponse>;
889
+ /**
890
+ * List All User Active Sessions
891
+ * Returns all currently connected active SSE listeners for this account.
892
+ * @returns Models.UserActiveSessionsResponse
893
+ */
894
+ getActiveSessions(): Promise<UserActiveSessionsResponse>;
895
+ /**
896
+ * List User Stream Session History
897
+ * Returns historical SSE connection logs including duration and pushed transactions count.
898
+ * @param params.limit Max records to return
899
+ * @param params.offset Pagination offset
900
+ * @returns Models.UserSessionHistoryResponse
901
+ */
902
+ getSessionHistory(params?: {
903
+ limit?: number;
904
+ offset?: number;
905
+ }): Promise<UserSessionHistoryResponse>;
906
+ }
907
+ /** Analytics Service: APIs for analytics operations */
908
+ declare class AnalyticsService {
909
+ private readonly request;
910
+ private readonly apiBaseUrl;
911
+ private readonly streamBaseUrl;
912
+ private readonly apiKey;
913
+ constructor(request: Requester, apiBaseUrl: string, streamBaseUrl: string, apiKey: string);
914
+ /**
915
+ * 60-Day Trader Deposit Analytics
916
+ * Returns 60-day aggregated deposit summary and individual transaction breakdown for top traders.
917
+ * @param params.limit Max records to return
918
+ * @param params.offset Pagination offset
919
+ * @returns Models.DepositQueryResult
920
+ */
921
+ getDeposits(params?: {
922
+ limit?: number;
923
+ offset?: number;
924
+ }): Promise<DepositQueryResult>;
925
+ /**
926
+ * Top Traders PnL Leaderboard
927
+ * Queries ranked traders across timeframes with PnL, volume, win rate, and performance metrics.
928
+ * @param params.limit Max traders to return
929
+ * @param params.offset Pagination offset
930
+ * @returns Models.LeaderboardResponse
931
+ */
932
+ getLeaderboard(params?: {
933
+ limit?: number;
934
+ offset?: number;
935
+ }): Promise<LeaderboardResponse>;
936
+ /**
937
+ * Get Prediction Market Detail
938
+ * Fetches standardized market metadata matching on-chain condition IDs and NegRisk parameters.
939
+ * @param id Market numeric ID or condition ID
940
+ * @returns Models.MarketDetailResponse
941
+ */
942
+ getMarket(id: string): Promise<MarketDetailResponse>;
943
+ /**
944
+ * Get Trader Intelligence Profile
945
+ * Fetches trader identity dossier, pUSD balance, total PnL, win rates, and ranking metrics.
946
+ * @param address Trader Polygon/Ethereum wallet address
947
+ * @returns Models.TraderProfileResponse
948
+ */
949
+ getTrader(address: string): Promise<TraderProfileResponse>;
950
+ /**
951
+ * Get Hourly PnL Equity Curve
952
+ * Provides 1-hour bucketed historical equity curves and trade metrics for a specific trader.
953
+ * @param address Trader Polygon/Ethereum wallet address
954
+ * @returns Models.TraderHourlyStatsResponse
955
+ */
956
+ getTraderHourlyStats(address: string): Promise<TraderHourlyStatsResponse>;
957
+ /**
958
+ * Get Trader Market Participation History
959
+ * Queries resolved and active prediction markets traded by the specified wallet address.
960
+ * @param address Trader Polygon/Ethereum wallet address
961
+ * @param params.limit Max markets to return
962
+ * @param params.offset Pagination offset
963
+ * @returns Models.TraderHistoryResponse
964
+ */
965
+ getTraderMarkets(address: string, params?: {
966
+ limit?: number;
967
+ offset?: number;
968
+ }): Promise<TraderHistoryResponse>;
969
+ /**
970
+ * Get Trader Orders in Market
971
+ * Retrieves granular fill events, side, price, and token outcomes for a trader in a given market.
972
+ * @param address Trader wallet address
973
+ * @param id Market numeric ID
974
+ * @param params.limit Max orders to return
975
+ * @param params.offset Pagination offset
976
+ * @returns Models.UserOrdersResponse
977
+ */
978
+ getTraderMarketOrders(address: string, id: string, params?: {
979
+ limit?: number;
980
+ offset?: number;
981
+ }): Promise<UserOrdersResponse>;
982
+ }
983
+ /** Account Service: APIs for account operations */
984
+ declare class AccountService {
985
+ private readonly request;
986
+ private readonly apiBaseUrl;
987
+ private readonly streamBaseUrl;
988
+ private readonly apiKey;
989
+ constructor(request: Requester, apiBaseUrl: string, streamBaseUrl: string, apiKey: string);
990
+ /**
991
+ * Get Current Profile
992
+ * Retrieves the authenticated user profile, tier subscription status, and available USDC balance.
993
+ * @returns Models.UserProfile
994
+ */
995
+ getProfile(): Promise<UserProfile>;
996
+ /**
997
+ * List API Keys
998
+ * Lists all active and revoked API keys issued to the authenticated account.
999
+ * @returns Models.UserKeysResponse
1000
+ */
1001
+ listKeys(): Promise<UserKeysResponse>;
1002
+ /**
1003
+ * Create API Key
1004
+ * Generates a new authenticated API key token with optional memo label.
1005
+ * @param req Request payload
1006
+ * @returns Models.UserAPIKey
1007
+ */
1008
+ createKey(req: CreateAPIKeyRequest): Promise<UserAPIKey>;
1009
+ /**
1010
+ * Update API Key
1011
+ * Modifies label memo or operational status of an existing API key.
1012
+ * @param key API key string
1013
+ * @param req Request payload
1014
+ * @returns Models.UserAPIKey
1015
+ */
1016
+ updateKey(key: string, req: UserUpdateKeyRequest): Promise<UserAPIKey>;
1017
+ /**
1018
+ * Revoke API Key
1019
+ * Permanently revokes and deactivates an API key token.
1020
+ * @param key API key string
1021
+ * @returns Models.DeleteKeyResponse
1022
+ */
1023
+ deleteKey(key: string): Promise<DeleteKeyResponse>;
1024
+ /**
1025
+ * List User Balance Ledger
1026
+ * Lists chronological ledger entries (subscription billing charges, deposits, withdrawals).
1027
+ * @param params.limit Max entries to return
1028
+ * @param params.offset Pagination offset
1029
+ * @returns Models.UserLedgerResponse
1030
+ */
1031
+ getLedger(params?: {
1032
+ limit?: number;
1033
+ offset?: number;
1034
+ }): Promise<UserLedgerResponse>;
1035
+ /**
1036
+ * Get Account Telemetry & Limits
1037
+ * Provides live usage statistics, quota limits, and remaining streaming bandwidth.
1038
+ * @returns Models.UserTelemetryResponse
1039
+ */
1040
+ getTelemetry(): Promise<UserTelemetryResponse>;
1041
+ /**
1042
+ * Request Balance Withdrawal
1043
+ * Submits a request to withdraw unspent USDC balance to a designated Polygon address.
1044
+ * @param req Request payload
1045
+ * @returns Models.UserWithdrawResponse
1046
+ */
1047
+ withdraw(req: UserWithdrawRequest): Promise<UserWithdrawResponse>;
1048
+ }
1049
+ /** Subscription Service: APIs for subscription operations */
1050
+ declare class SubscriptionService {
1051
+ private readonly request;
1052
+ private readonly apiBaseUrl;
1053
+ private readonly streamBaseUrl;
1054
+ private readonly apiKey;
1055
+ constructor(request: Requester, apiBaseUrl: string, streamBaseUrl: string, apiKey: string);
1056
+ /**
1057
+ * List Public Tiers Catalog
1058
+ * Returns plan tiers (Free, Starter, Pro, Growth, Whale) with limits and pricing details.
1059
+ * @returns Models.Tier[]
1060
+ */
1061
+ listTiers(): Promise<Tier[]>;
1062
+ /**
1063
+ * Get Subscription Quote
1064
+ * Calculates prorated billing amounts for subscribing to or upgrading a tier plan.
1065
+ * @param req Request payload
1066
+ * @returns Models.QuoteSubscriptionResponse
1067
+ */
1068
+ getQuote(req: QuoteSubscriptionRequest): Promise<QuoteSubscriptionResponse>;
1069
+ /**
1070
+ * Purchase / Upgrade Tier Subscription
1071
+ * Executes purchase, renewal, or upgrade of an active subscription tier plan.
1072
+ * @param req Request payload
1073
+ * @returns Models.SubscribeResponse
1074
+ */
1075
+ subscribe(req: SubscribeRequest): Promise<SubscribeResponse>;
1076
+ /**
1077
+ * Validate Promo Code
1078
+ * Verifies validity, discount percentage, and applicable plans for a promotion coupon code.
1079
+ * @param req Request payload
1080
+ * @returns Models.ValidatePromoCodeResponse
1081
+ */
1082
+ validatePromoCode(req: ValidatePromoCodeRequest): Promise<ValidatePromoCodeResponse>;
1083
+ }
1084
+ /**
1085
+ * PolyEdge API Client
1086
+ * Provides namespaced access to Streams, Analytics, Account, and Subscription services.
1087
+ */
1088
+ declare class PolyEdgeClient {
1089
+ private readonly apiKey;
1090
+ private readonly apiBaseUrl;
1091
+ private readonly streamBaseUrl;
1092
+ /** Streams Service: Real-time SSE trade streaming & filters */
1093
+ readonly streams: StreamsService;
1094
+ /** Analytics Service: Leaderboard, trader intelligence, markets */
1095
+ readonly analytics: AnalyticsService;
1096
+ /** Account Service: Profile, keys, ledger, telemetry */
1097
+ readonly account: AccountService;
1098
+ /** Subscription Service: Plan tiers, quotes, checkout */
1099
+ readonly subscription: SubscriptionService;
1100
+ constructor(options: PolyEdgeClientOptions);
1101
+ private request;
1102
+ /** Direct helper to create SSE order stream */
1103
+ stream(streamId: string, options?: Partial<StreamOptions>): PolyEdgeStream;
1104
+ }
1105
+
1106
+ export { AccountService, type ActiveSessionInfo, AnalyticsService, type CreateAPIKeyRequest, type DeleteKeyResponse, type DeleteStreamResponse, type DepositItem, type DepositQueryResult, type ErrorResponse, type HistoryMarket, type HourlyStat, type LeaderboardResponse, type LiveOrder, type LiveTransaction, type Market, type MarketDetailResponse, type MarketEarner, type MarketMetadata, type MarketSettlementDetail, type MonitorTrader, type OrderInfo, PolyEdgeClient, type PolyEdgeClientOptions, PolyEdgeStream, type QuoteSubscriptionRequest, type QuoteSubscriptionResponse, type Requester, type Side, type StreamEvents, type StreamOptions, StreamsService, type SubscribeRequest, type SubscribeResponse, SubscriptionService, type TagStat, type Tier, type TokenIndex, type TraderHistoryResponse, type TraderHourlyStatsResponse, type TraderIdentity, type TraderProfileResponse, type TraderSummary, type UpdateSubscriptionRequest, type UserAPIKey, type UserActiveSessionsResponse, type UserCreateStreamRequest, type UserKeysResponse, type UserLedgerEntry, type UserLedgerResponse, type UserOrder, type UserOrdersResponse, type UserProfile, type UserSessionHistoryResponse, type UserSessionRecord, type UserStreamResponse, type UserStreamsResponse, type UserSubscription, type UserTelemetryResponse, type UserUpdateKeyRequest, type UserUpdateStreamMetadataRequest, type UserWithdrawRequest, type UserWithdrawResponse, type ValidatePromoCodeRequest, type ValidatePromoCodeResponse, type Withdrawal };