pmxtjs 2.19.6 → 2.20.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.
Files changed (59) hide show
  1. package/dist/esm/generated/src/apis/DefaultApi.d.ts +53 -1
  2. package/dist/esm/generated/src/apis/DefaultApi.js +83 -1
  3. package/dist/esm/generated/src/models/FetchBalanceRequest.d.ts +2 -2
  4. package/dist/esm/generated/src/models/FetchPositionsRequest.d.ts +2 -2
  5. package/dist/esm/generated/src/models/UnwatchAddressRequest.d.ts +39 -0
  6. package/dist/esm/generated/src/models/UnwatchAddressRequest.js +46 -0
  7. package/dist/esm/generated/src/models/WatchAddress200Response.d.ts +45 -0
  8. package/dist/esm/generated/src/models/WatchAddress200Response.js +46 -0
  9. package/dist/esm/generated/src/models/WatchAddressRequest.d.ts +40 -0
  10. package/dist/esm/generated/src/models/WatchAddressRequest.js +47 -0
  11. package/dist/esm/generated/src/models/WatchAddressRequestArgsInner.d.ts +21 -0
  12. package/dist/esm/generated/src/models/WatchAddressRequestArgsInner.js +37 -0
  13. package/dist/esm/generated/src/models/index.d.ts +4 -0
  14. package/dist/esm/generated/src/models/index.js +4 -0
  15. package/dist/esm/pmxt/args.d.ts +1 -0
  16. package/dist/esm/pmxt/args.js +3 -0
  17. package/dist/esm/pmxt/client.d.ts +94 -6
  18. package/dist/esm/pmxt/client.js +217 -55
  19. package/dist/esm/pmxt/models.d.ts +45 -0
  20. package/dist/generated/src/apis/DefaultApi.d.ts +53 -1
  21. package/dist/generated/src/apis/DefaultApi.js +83 -1
  22. package/dist/generated/src/models/FetchBalanceRequest.d.ts +2 -2
  23. package/dist/generated/src/models/FetchPositionsRequest.d.ts +2 -2
  24. package/dist/generated/src/models/UnwatchAddressRequest.d.ts +39 -0
  25. package/dist/generated/src/models/UnwatchAddressRequest.js +53 -0
  26. package/dist/generated/src/models/WatchAddress200Response.d.ts +45 -0
  27. package/dist/generated/src/models/WatchAddress200Response.js +53 -0
  28. package/dist/generated/src/models/WatchAddressRequest.d.ts +40 -0
  29. package/dist/generated/src/models/WatchAddressRequest.js +54 -0
  30. package/dist/generated/src/models/WatchAddressRequestArgsInner.d.ts +21 -0
  31. package/dist/generated/src/models/WatchAddressRequestArgsInner.js +43 -0
  32. package/dist/generated/src/models/index.d.ts +4 -0
  33. package/dist/generated/src/models/index.js +4 -0
  34. package/dist/pmxt/args.d.ts +1 -0
  35. package/dist/pmxt/args.js +6 -0
  36. package/dist/pmxt/client.d.ts +94 -6
  37. package/dist/pmxt/client.js +216 -54
  38. package/dist/pmxt/models.d.ts +45 -0
  39. package/generated/.openapi-generator/FILES +8 -0
  40. package/generated/docs/DefaultApi.md +142 -0
  41. package/generated/docs/FetchBalanceRequest.md +1 -1
  42. package/generated/docs/FetchPositionsRequest.md +1 -1
  43. package/generated/docs/UnwatchAddressRequest.md +36 -0
  44. package/generated/docs/WatchAddress200Response.md +38 -0
  45. package/generated/docs/WatchAddressRequest.md +36 -0
  46. package/generated/docs/WatchAddressRequestArgsInner.md +32 -0
  47. package/generated/package.json +1 -1
  48. package/generated/src/apis/DefaultApi.ts +127 -0
  49. package/generated/src/models/FetchBalanceRequest.ts +2 -2
  50. package/generated/src/models/FetchPositionsRequest.ts +2 -2
  51. package/generated/src/models/UnwatchAddressRequest.ts +82 -0
  52. package/generated/src/models/WatchAddress200Response.ts +89 -0
  53. package/generated/src/models/WatchAddressRequest.ts +89 -0
  54. package/generated/src/models/WatchAddressRequestArgsInner.ts +49 -0
  55. package/generated/src/models/index.ts +4 -0
  56. package/package.json +2 -2
  57. package/pmxt/args.ts +3 -0
  58. package/pmxt/client.ts +262 -60
  59. package/pmxt/models.ts +55 -1
@@ -4,8 +4,8 @@
4
4
  * This module provides clean, TypeScript-friendly wrappers around the auto-generated
5
5
  * OpenAPI client, matching the Python API exactly.
6
6
  */
7
- import { DefaultApi, Configuration, ExchangeCredentials } from "../generated/src/index.js";
8
- import { UnifiedMarket, PriceCandle, OrderBook, Trade, UserTrade, Order, Position, Balance, UnifiedEvent, ExecutionPriceResult, PaginatedMarketsResult, MarketFilterCriteria, MarketFilterFunction, EventFilterCriteria, EventFilterFunction } from "./models.js";
7
+ import { Configuration, DefaultApi, ExchangeCredentials } from "../generated/src/index.js";
8
+ import { Balance, BuiltOrder, CreateOrderParams, EventFilterCriteria, EventFilterFunction, ExecutionPriceResult, MarketFilterCriteria, MarketFilterFunction, MarketOutcome, Order, OrderBook, PaginatedMarketsResult, Position, PriceCandle, SubscribedAddressSnapshot, SubscriptionOption, Trade, UnifiedEvent, UnifiedMarket, UserTrade } from "./models.js";
9
9
  import { ServerManager } from "./server-manager.js";
10
10
  /**
11
11
  * Base exchange client options.
@@ -68,15 +68,14 @@ export declare abstract class Exchange {
68
68
  fetchMarket(params?: any): Promise<UnifiedMarket>;
69
69
  fetchEvent(params?: any): Promise<UnifiedEvent>;
70
70
  fetchOrderBook(id: string): Promise<OrderBook>;
71
- submitOrder(built: any): Promise<Order>;
72
71
  cancelOrder(orderId: string): Promise<Order>;
73
72
  fetchOrder(orderId: string): Promise<Order>;
74
73
  fetchOpenOrders(marketId?: string): Promise<Order[]>;
75
74
  fetchMyTrades(params?: any): Promise<UserTrade[]>;
76
75
  fetchClosedOrders(params?: any): Promise<Order[]>;
77
76
  fetchAllOrders(params?: any): Promise<Order[]>;
78
- fetchPositions(): Promise<Position[]>;
79
- fetchBalance(): Promise<Balance[]>;
77
+ fetchPositions(address?: string): Promise<Position[]>;
78
+ fetchBalance(address?: string): Promise<Balance[]>;
80
79
  close(): Promise<void>;
81
80
  /**
82
81
  * Get historical price candles.
@@ -134,6 +133,7 @@ export declare abstract class Exchange {
134
133
  * Call repeatedly in a loop to stream updates (CCXT Pro pattern).
135
134
  *
136
135
  * @param outcomeId - Outcome ID to watch
136
+ * @param address - Public wallet to be watched
137
137
  * @param since - Optional timestamp to filter trades from
138
138
  * @param limit - Optional limit for number of trades
139
139
  * @returns Next trade update(s)
@@ -149,7 +149,95 @@ export declare abstract class Exchange {
149
149
  * }
150
150
  * ```
151
151
  */
152
- watchTrades(outcomeId: string, since?: number, limit?: number): Promise<Trade[]>;
152
+ watchTrades(outcomeId: string, address?: string, since?: number, limit?: number): Promise<Trade[]>;
153
+ /**
154
+ * Watch real-time updates of a public wallet via WebSocket.
155
+ *
156
+ * Returns a promise that resolves with the next update(s).
157
+ * Call repeatedly in a loop to stream updates (CCXT Pro pattern).
158
+ *
159
+ * @param address - Public wallet to be watched
160
+ * @param types - Subscription options including 'trades', 'positions', and 'balances'
161
+ * @returns Next update(s)
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * // Stream updates of a public wallet address
166
+ * while (true) {
167
+ * const snapshots = await exchange.watchAddress(address, types);
168
+ * for (const snapshot of snapshots) {
169
+ * console.log(`Trade: ${snapshot.trades}`);
170
+ * }
171
+ * }
172
+ * ```
173
+ */
174
+ watchAddress(address: string, types?: SubscriptionOption[]): Promise<SubscribedAddressSnapshot>;
175
+ /**
176
+ * Stop watching a previously registered wallet address and release its resource updates.
177
+ *
178
+ * @param address - Public wallet to be watched
179
+ * @returns
180
+ */
181
+ unwatchAddress(address: string): Promise<Trade[]>;
182
+ /**
183
+ * Build an order payload without submitting it to the exchange.
184
+ * Returns the exchange-native signed order or transaction payload for
185
+ * inspection, forwarding through a middleware layer, or deferred
186
+ * submission via {@link submitOrder}.
187
+ *
188
+ * You can specify the market either with explicit marketId/outcomeId,
189
+ * or by passing an outcome object directly (e.g., market.yes).
190
+ *
191
+ * @param params - Order parameters (same as createOrder)
192
+ * @returns A BuiltOrder containing the exchange-native payload
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * // Build, inspect, then submit:
197
+ * const built = await exchange.buildOrder({
198
+ * marketId: "663583",
199
+ * outcomeId: "10991849...",
200
+ * side: "buy",
201
+ * type: "limit",
202
+ * amount: 10,
203
+ * price: 0.55
204
+ * });
205
+ *
206
+ * console.log(built.signedOrder); // inspect before submitting
207
+ * const order = await exchange.submitOrder(built);
208
+ *
209
+ * // Using outcome shorthand:
210
+ * const built2 = await exchange.buildOrder({
211
+ * outcome: market.yes,
212
+ * side: "buy",
213
+ * type: "market",
214
+ * amount: 10
215
+ * });
216
+ * ```
217
+ */
218
+ buildOrder(params: CreateOrderParams & {
219
+ outcome?: MarketOutcome;
220
+ }): Promise<BuiltOrder>;
221
+ /**
222
+ * Submit a pre-built order returned by {@link buildOrder}.
223
+ *
224
+ * @param built - The BuiltOrder payload from buildOrder()
225
+ * @returns The submitted order
226
+ *
227
+ * @example
228
+ * ```typescript
229
+ * const built = await exchange.buildOrder({
230
+ * outcome: market.yes,
231
+ * side: "buy",
232
+ * type: "limit",
233
+ * amount: 10,
234
+ * price: 0.55
235
+ * });
236
+ * const order = await exchange.submitOrder(built);
237
+ * console.log(order.id, order.status);
238
+ * ```
239
+ */
240
+ submitOrder(built: BuiltOrder): Promise<Order>;
153
241
  /**
154
242
  * Create a new order.
155
243
  *
@@ -4,9 +4,10 @@
4
4
  * This module provides clean, TypeScript-friendly wrappers around the auto-generated
5
5
  * OpenAPI client, matching the Python API exactly.
6
6
  */
7
- import { DefaultApi, Configuration, } from "../generated/src/index.js";
7
+ import { Configuration, DefaultApi, } from "../generated/src/index.js";
8
8
  import { MarketList, } from "./models.js";
9
9
  import { ServerManager } from "./server-manager.js";
10
+ import { buildArgsWithOptionalOptions } from "./args.js";
10
11
  // Converter functions
11
12
  function convertMarket(raw) {
12
13
  const outcomes = (raw.outcomes || []).map((o) => ({
@@ -143,6 +144,19 @@ function convertEvent(raw) {
143
144
  };
144
145
  return event;
145
146
  }
147
+ function convertSubscriptionSnapshot(raw) {
148
+ const trades = (raw.trades ?? []).map(convertTrade);
149
+ const balances = (raw.balances ?? []).map(convertBalance);
150
+ const positions = (raw.positions ?? []).map(convertPosition);
151
+ const snapShot = {
152
+ address: raw.address,
153
+ trades,
154
+ balances,
155
+ positions,
156
+ timestamp: raw.timestamp,
157
+ };
158
+ return snapShot;
159
+ }
146
160
  /**
147
161
  * Base class for prediction market exchanges.
148
162
  *
@@ -295,9 +309,7 @@ export class Exchange {
295
309
  async fetchMarkets(params) {
296
310
  await this.initPromise;
297
311
  try {
298
- const args = [];
299
- if (params !== undefined)
300
- args.push(params);
312
+ const args = buildArgsWithOptionalOptions(params);
301
313
  const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchMarkets`, {
302
314
  method: 'POST',
303
315
  headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
@@ -318,9 +330,7 @@ export class Exchange {
318
330
  async fetchMarketsPaginated(params) {
319
331
  await this.initPromise;
320
332
  try {
321
- const args = [];
322
- if (params !== undefined)
323
- args.push(params);
333
+ const args = buildArgsWithOptionalOptions(params);
324
334
  const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchMarketsPaginated`, {
325
335
  method: 'POST',
326
336
  headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
@@ -345,9 +355,7 @@ export class Exchange {
345
355
  async fetchEvents(params) {
346
356
  await this.initPromise;
347
357
  try {
348
- const args = [];
349
- if (params !== undefined)
350
- args.push(params);
358
+ const args = buildArgsWithOptionalOptions(params);
351
359
  const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchEvents`, {
352
360
  method: 'POST',
353
361
  headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
@@ -368,9 +376,7 @@ export class Exchange {
368
376
  async fetchMarket(params) {
369
377
  await this.initPromise;
370
378
  try {
371
- const args = [];
372
- if (params !== undefined)
373
- args.push(params);
379
+ const args = buildArgsWithOptionalOptions(params);
374
380
  const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchMarket`, {
375
381
  method: 'POST',
376
382
  headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
@@ -391,9 +397,7 @@ export class Exchange {
391
397
  async fetchEvent(params) {
392
398
  await this.initPromise;
393
399
  try {
394
- const args = [];
395
- if (params !== undefined)
396
- args.push(params);
400
+ const args = buildArgsWithOptionalOptions(params);
397
401
  const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchEvent`, {
398
402
  method: 'POST',
399
403
  headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
@@ -433,28 +437,6 @@ export class Exchange {
433
437
  throw new Error(`Failed to fetchOrderBook: ${error}`);
434
438
  }
435
439
  }
436
- async submitOrder(built) {
437
- await this.initPromise;
438
- try {
439
- const args = [];
440
- args.push(built);
441
- const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/submitOrder`, {
442
- method: 'POST',
443
- headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
444
- body: JSON.stringify({ args, credentials: this.getCredentials() }),
445
- });
446
- if (!response.ok) {
447
- const error = await response.json().catch(() => ({}));
448
- throw new Error(error.error?.message || response.statusText);
449
- }
450
- const json = await response.json();
451
- const data = this.handleResponse(json);
452
- return convertOrder(data);
453
- }
454
- catch (error) {
455
- throw new Error(`Failed to submitOrder: ${error}`);
456
- }
457
- }
458
440
  async cancelOrder(orderId) {
459
441
  await this.initPromise;
460
442
  try {
@@ -502,9 +484,7 @@ export class Exchange {
502
484
  async fetchOpenOrders(marketId) {
503
485
  await this.initPromise;
504
486
  try {
505
- const args = [];
506
- if (marketId !== undefined)
507
- args.push(marketId);
487
+ const args = buildArgsWithOptionalOptions(marketId);
508
488
  const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchOpenOrders`, {
509
489
  method: 'POST',
510
490
  headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
@@ -525,9 +505,7 @@ export class Exchange {
525
505
  async fetchMyTrades(params) {
526
506
  await this.initPromise;
527
507
  try {
528
- const args = [];
529
- if (params !== undefined)
530
- args.push(params);
508
+ const args = buildArgsWithOptionalOptions(params);
531
509
  const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchMyTrades`, {
532
510
  method: 'POST',
533
511
  headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
@@ -548,9 +526,7 @@ export class Exchange {
548
526
  async fetchClosedOrders(params) {
549
527
  await this.initPromise;
550
528
  try {
551
- const args = [];
552
- if (params !== undefined)
553
- args.push(params);
529
+ const args = buildArgsWithOptionalOptions(params);
554
530
  const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchClosedOrders`, {
555
531
  method: 'POST',
556
532
  headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
@@ -571,9 +547,7 @@ export class Exchange {
571
547
  async fetchAllOrders(params) {
572
548
  await this.initPromise;
573
549
  try {
574
- const args = [];
575
- if (params !== undefined)
576
- args.push(params);
550
+ const args = buildArgsWithOptionalOptions(params);
577
551
  const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchAllOrders`, {
578
552
  method: 'POST',
579
553
  headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
@@ -591,10 +565,10 @@ export class Exchange {
591
565
  throw new Error(`Failed to fetchAllOrders: ${error}`);
592
566
  }
593
567
  }
594
- async fetchPositions() {
568
+ async fetchPositions(address) {
595
569
  await this.initPromise;
596
570
  try {
597
- const args = [];
571
+ const args = address ? [address] : [];
598
572
  const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchPositions`, {
599
573
  method: 'POST',
600
574
  headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
@@ -612,10 +586,10 @@ export class Exchange {
612
586
  throw new Error(`Failed to fetchPositions: ${error}`);
613
587
  }
614
588
  }
615
- async fetchBalance() {
589
+ async fetchBalance(address) {
616
590
  await this.initPromise;
617
591
  try {
618
- const args = [];
592
+ const args = address ? [address] : [];
619
593
  const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchBalance`, {
620
594
  method: 'POST',
621
595
  headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
@@ -780,6 +754,7 @@ export class Exchange {
780
754
  * Call repeatedly in a loop to stream updates (CCXT Pro pattern).
781
755
  *
782
756
  * @param outcomeId - Outcome ID to watch
757
+ * @param address - Public wallet to be watched
783
758
  * @param since - Optional timestamp to filter trades from
784
759
  * @param limit - Optional limit for number of trades
785
760
  * @returns Next trade update(s)
@@ -795,10 +770,13 @@ export class Exchange {
795
770
  * }
796
771
  * ```
797
772
  */
798
- async watchTrades(outcomeId, since, limit) {
773
+ async watchTrades(outcomeId, address, since, limit) {
799
774
  await this.initPromise;
800
775
  try {
801
776
  const args = [outcomeId];
777
+ if (address !== undefined) {
778
+ args.push(address);
779
+ }
802
780
  if (since !== undefined) {
803
781
  args.push(since);
804
782
  }
@@ -820,7 +798,191 @@ export class Exchange {
820
798
  throw new Error(`Failed to watch trades: ${error}`);
821
799
  }
822
800
  }
801
+ /**
802
+ * Watch real-time updates of a public wallet via WebSocket.
803
+ *
804
+ * Returns a promise that resolves with the next update(s).
805
+ * Call repeatedly in a loop to stream updates (CCXT Pro pattern).
806
+ *
807
+ * @param address - Public wallet to be watched
808
+ * @param types - Subscription options including 'trades', 'positions', and 'balances'
809
+ * @returns Next update(s)
810
+ *
811
+ * @example
812
+ * ```typescript
813
+ * // Stream updates of a public wallet address
814
+ * while (true) {
815
+ * const snapshots = await exchange.watchAddress(address, types);
816
+ * for (const snapshot of snapshots) {
817
+ * console.log(`Trade: ${snapshot.trades}`);
818
+ * }
819
+ * }
820
+ * ```
821
+ */
822
+ async watchAddress(address, types) {
823
+ await this.initPromise;
824
+ try {
825
+ const args = [address];
826
+ if (types !== undefined) {
827
+ args.push(types);
828
+ }
829
+ const requestBody = {
830
+ args,
831
+ credentials: this.getCredentials()
832
+ };
833
+ const response = await this.api.watchAddress({
834
+ exchange: this.exchangeName,
835
+ watchAddressRequest: requestBody,
836
+ });
837
+ const data = this.handleResponse(response);
838
+ return convertSubscriptionSnapshot(data);
839
+ }
840
+ catch (error) {
841
+ throw new Error(`Failed to watch address: ${error}`);
842
+ }
843
+ }
844
+ /**
845
+ * Stop watching a previously registered wallet address and release its resource updates.
846
+ *
847
+ * @param address - Public wallet to be watched
848
+ * @returns
849
+ */
850
+ async unwatchAddress(address) {
851
+ await this.initPromise;
852
+ try {
853
+ const args = [address];
854
+ const requestBody = {
855
+ args,
856
+ credentials: this.getCredentials()
857
+ };
858
+ const response = await this.api.unwatchAddress({
859
+ exchange: this.exchangeName,
860
+ unwatchAddressRequest: requestBody,
861
+ });
862
+ return this.handleResponse(response);
863
+ }
864
+ catch (error) {
865
+ throw new Error(`Failed to unwatch address: ${error}`);
866
+ }
867
+ }
823
868
  // Trading Methods (require authentication)
869
+ /**
870
+ * Build an order payload without submitting it to the exchange.
871
+ * Returns the exchange-native signed order or transaction payload for
872
+ * inspection, forwarding through a middleware layer, or deferred
873
+ * submission via {@link submitOrder}.
874
+ *
875
+ * You can specify the market either with explicit marketId/outcomeId,
876
+ * or by passing an outcome object directly (e.g., market.yes).
877
+ *
878
+ * @param params - Order parameters (same as createOrder)
879
+ * @returns A BuiltOrder containing the exchange-native payload
880
+ *
881
+ * @example
882
+ * ```typescript
883
+ * // Build, inspect, then submit:
884
+ * const built = await exchange.buildOrder({
885
+ * marketId: "663583",
886
+ * outcomeId: "10991849...",
887
+ * side: "buy",
888
+ * type: "limit",
889
+ * amount: 10,
890
+ * price: 0.55
891
+ * });
892
+ *
893
+ * console.log(built.signedOrder); // inspect before submitting
894
+ * const order = await exchange.submitOrder(built);
895
+ *
896
+ * // Using outcome shorthand:
897
+ * const built2 = await exchange.buildOrder({
898
+ * outcome: market.yes,
899
+ * side: "buy",
900
+ * type: "market",
901
+ * amount: 10
902
+ * });
903
+ * ```
904
+ */
905
+ async buildOrder(params) {
906
+ await this.initPromise;
907
+ try {
908
+ let marketId = params.marketId;
909
+ let outcomeId = params.outcomeId;
910
+ if (params.outcome) {
911
+ if (marketId !== undefined || outcomeId !== undefined) {
912
+ throw new Error("Cannot specify both 'outcome' and 'marketId'/'outcomeId'. Use one or the other.");
913
+ }
914
+ const outcome = params.outcome;
915
+ if (!outcome.marketId) {
916
+ throw new Error("outcome.marketId is not set. Ensure the outcome comes from a fetched market.");
917
+ }
918
+ marketId = outcome.marketId;
919
+ outcomeId = outcome.outcomeId;
920
+ }
921
+ const paramsDict = {
922
+ marketId,
923
+ outcomeId,
924
+ side: params.side,
925
+ type: params.type,
926
+ amount: params.amount,
927
+ };
928
+ if (params.price !== undefined) {
929
+ paramsDict.price = params.price;
930
+ }
931
+ if (params.fee !== undefined) {
932
+ paramsDict.fee = params.fee;
933
+ }
934
+ const requestBody = {
935
+ args: [paramsDict],
936
+ credentials: this.getCredentials()
937
+ };
938
+ const response = await this.api.buildOrder({
939
+ exchange: this.exchangeName,
940
+ buildOrderRequest: requestBody,
941
+ });
942
+ const data = this.handleResponse(response);
943
+ return data;
944
+ }
945
+ catch (error) {
946
+ throw new Error(`Failed to build order: ${error}`);
947
+ }
948
+ }
949
+ /**
950
+ * Submit a pre-built order returned by {@link buildOrder}.
951
+ *
952
+ * @param built - The BuiltOrder payload from buildOrder()
953
+ * @returns The submitted order
954
+ *
955
+ * @example
956
+ * ```typescript
957
+ * const built = await exchange.buildOrder({
958
+ * outcome: market.yes,
959
+ * side: "buy",
960
+ * type: "limit",
961
+ * amount: 10,
962
+ * price: 0.55
963
+ * });
964
+ * const order = await exchange.submitOrder(built);
965
+ * console.log(order.id, order.status);
966
+ * ```
967
+ */
968
+ async submitOrder(built) {
969
+ await this.initPromise;
970
+ try {
971
+ const requestBody = {
972
+ args: [built],
973
+ credentials: this.getCredentials()
974
+ };
975
+ const response = await this.api.submitOrder({
976
+ exchange: this.exchangeName,
977
+ submitOrderRequest: requestBody,
978
+ });
979
+ const data = this.handleResponse(response);
980
+ return convertOrder(data);
981
+ }
982
+ catch (error) {
983
+ throw new Error(`Failed to submit order: ${error}`);
984
+ }
985
+ }
824
986
  /**
825
987
  * Create a new order.
826
988
  *
@@ -273,6 +273,26 @@ export interface CreateOrderParams {
273
273
  /** Optional fee rate (e.g., 1000 for 0.1%) */
274
274
  fee?: number;
275
275
  }
276
+ /**
277
+ * An order payload built but not yet submitted to the exchange.
278
+ */
279
+ export interface BuiltOrder {
280
+ /** The exchange name this order was built for. */
281
+ exchange: string;
282
+ /** The original params used to build this order. */
283
+ params: CreateOrderParams;
284
+ /** For CLOB exchanges (Polymarket): the EIP-712 signed order. */
285
+ signedOrder?: Record<string, unknown>;
286
+ /** For on-chain AMM exchanges: the EVM transaction payload. */
287
+ tx?: {
288
+ to: string;
289
+ data: string;
290
+ value: string;
291
+ chainId: number;
292
+ };
293
+ /** The raw, exchange-native payload. Always present. */
294
+ raw: unknown;
295
+ }
276
296
  /**
277
297
  * A list of UnifiedMarket objects with a convenience match() method.
278
298
  * Extends Array so all standard array operations work unchanged.
@@ -393,3 +413,28 @@ export interface EventFilterCriteria {
393
413
  * Function type for custom event filtering logic.
394
414
  */
395
415
  export type EventFilterFunction = (event: UnifiedEvent) => boolean;
416
+ /**
417
+ * Subscription options.
418
+ */
419
+ export type SubscriptionOption = 'trades' | 'positions' | 'balances';
420
+ /**
421
+ * Subscription snapshot of a watched public wallet address.
422
+ */
423
+ export interface SubscribedAddressSnapshot {
424
+ /** The wallet address being watched */
425
+ address: string;
426
+ /** Recent trades for this address
427
+ * (if the above SubscriptionOption 'trades' option was requested)
428
+ */
429
+ trades?: Trade[];
430
+ /** Current open positions for this address
431
+ * (if the above SubscriptionOption 'positions' option was requested)
432
+ */
433
+ positions?: Position[];
434
+ /** Current balances for this address
435
+ * (if the above SubscriptionOption 'balances' option was requested)
436
+ */
437
+ balances?: Balance[];
438
+ /** Unix timestamp (ms) of this snapshot */
439
+ timestamp: number;
440
+ }
@@ -10,7 +10,7 @@
10
10
  * Do not edit the class manually.
11
11
  */
12
12
  import * as runtime from '../runtime';
13
- import type { BaseResponse, BuildOrder200Response, BuildOrderRequest, CancelOrderRequest, CloseRequest, CreateOrder200Response, CreateOrderRequest, FetchAllOrdersRequest, FetchBalance200Response, FetchBalanceRequest, FetchClosedOrdersRequest, FetchEvent200Response, FetchEventRequest, FetchEvents200Response, FetchEventsRequest, FetchMarket200Response, FetchMarketRequest, FetchMarkets200Response, FetchMarketsPaginated200Response, FetchMarketsPaginatedRequest, FetchMarketsRequest, FetchMyTrades200Response, FetchMyTradesRequest, FetchOHLCV200Response, FetchOHLCVRequest, FetchOpenOrders200Response, FetchOpenOrdersRequest, FetchOrderBook200Response, FetchOrderBookRequest, FetchOrderRequest, FetchPositions200Response, FetchPositionsRequest, FetchTrades200Response, FetchTradesRequest, FilterEventsRequest, FilterMarketsRequest, GetExecutionPrice200Response, GetExecutionPriceDetailed200Response, GetExecutionPriceDetailedRequest, GetExecutionPriceRequest, HealthCheck200Response, LoadMarkets200Response, LoadMarketsRequest, SubmitOrderRequest, WatchOrderBookRequest, WatchTradesRequest } from '../models/index';
13
+ import type { BaseResponse, BuildOrder200Response, BuildOrderRequest, CancelOrderRequest, CloseRequest, CreateOrder200Response, CreateOrderRequest, FetchAllOrdersRequest, FetchBalance200Response, FetchBalanceRequest, FetchClosedOrdersRequest, FetchEvent200Response, FetchEventRequest, FetchEvents200Response, FetchEventsRequest, FetchMarket200Response, FetchMarketRequest, FetchMarkets200Response, FetchMarketsPaginated200Response, FetchMarketsPaginatedRequest, FetchMarketsRequest, FetchMyTrades200Response, FetchMyTradesRequest, FetchOHLCV200Response, FetchOHLCVRequest, FetchOpenOrders200Response, FetchOpenOrdersRequest, FetchOrderBook200Response, FetchOrderBookRequest, FetchOrderRequest, FetchPositions200Response, FetchPositionsRequest, FetchTrades200Response, FetchTradesRequest, FilterEventsRequest, FilterMarketsRequest, GetExecutionPrice200Response, GetExecutionPriceDetailed200Response, GetExecutionPriceDetailedRequest, GetExecutionPriceRequest, HealthCheck200Response, LoadMarkets200Response, LoadMarketsRequest, SubmitOrderRequest, UnwatchAddressRequest, WatchAddress200Response, WatchAddressRequest, WatchOrderBookRequest, WatchTradesRequest } from '../models/index';
14
14
  export interface BuildOrderOperationRequest {
15
15
  exchange: BuildOrderOperationExchangeEnum;
16
16
  buildOrderRequest?: BuildOrderRequest;
@@ -111,6 +111,14 @@ export interface SubmitOrderOperationRequest {
111
111
  exchange: SubmitOrderOperationExchangeEnum;
112
112
  submitOrderRequest?: SubmitOrderRequest;
113
113
  }
114
+ export interface UnwatchAddressOperationRequest {
115
+ exchange: UnwatchAddressOperationExchangeEnum;
116
+ unwatchAddressRequest?: UnwatchAddressRequest;
117
+ }
118
+ export interface WatchAddressOperationRequest {
119
+ exchange: WatchAddressOperationExchangeEnum;
120
+ watchAddressRequest?: WatchAddressRequest;
121
+ }
114
122
  export interface WatchOrderBookOperationRequest {
115
123
  exchange: WatchOrderBookOperationExchangeEnum;
116
124
  watchOrderBookRequest?: WatchOrderBookRequest;
@@ -375,6 +383,26 @@ export declare class DefaultApi extends runtime.BaseAPI {
375
383
  * Submit Order
376
384
  */
377
385
  submitOrder(requestParameters: SubmitOrderOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<CreateOrder200Response>;
386
+ /**
387
+ * Stop watching a previously registered wallet address and release its resource updates.
388
+ * Unwatch Address
389
+ */
390
+ unwatchAddressRaw(requestParameters: UnwatchAddressOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<BaseResponse>>;
391
+ /**
392
+ * Stop watching a previously registered wallet address and release its resource updates.
393
+ * Unwatch Address
394
+ */
395
+ unwatchAddress(requestParameters: UnwatchAddressOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<BaseResponse>;
396
+ /**
397
+ * Stream activity for a public wallet address Returns a promise that resolves with the next activity snapshot whenever a change is detected. Call repeatedly in a loop to stream updates (CCXT Pro pattern).
398
+ * Watch Address
399
+ */
400
+ watchAddressRaw(requestParameters: WatchAddressOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<WatchAddress200Response>>;
401
+ /**
402
+ * Stream activity for a public wallet address Returns a promise that resolves with the next activity snapshot whenever a change is detected. Call repeatedly in a loop to stream updates (CCXT Pro pattern).
403
+ * Watch Address
404
+ */
405
+ watchAddress(requestParameters: WatchAddressOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<WatchAddress200Response>;
378
406
  /**
379
407
  * Watch order book updates in real-time via WebSocket. Returns a promise that resolves with the next order book update. Call repeatedly in a loop to stream updates (CCXT Pro pattern).
380
408
  * Watch Order Book
@@ -696,6 +724,30 @@ export declare const SubmitOrderOperationExchangeEnum: {
696
724
  readonly Myriad: "myriad";
697
725
  };
698
726
  export type SubmitOrderOperationExchangeEnum = typeof SubmitOrderOperationExchangeEnum[keyof typeof SubmitOrderOperationExchangeEnum];
727
+ /**
728
+ * @export
729
+ */
730
+ export declare const UnwatchAddressOperationExchangeEnum: {
731
+ readonly Polymarket: "polymarket";
732
+ readonly Kalshi: "kalshi";
733
+ readonly Limitless: "limitless";
734
+ readonly Probable: "probable";
735
+ readonly Baozi: "baozi";
736
+ readonly Myriad: "myriad";
737
+ };
738
+ export type UnwatchAddressOperationExchangeEnum = typeof UnwatchAddressOperationExchangeEnum[keyof typeof UnwatchAddressOperationExchangeEnum];
739
+ /**
740
+ * @export
741
+ */
742
+ export declare const WatchAddressOperationExchangeEnum: {
743
+ readonly Polymarket: "polymarket";
744
+ readonly Kalshi: "kalshi";
745
+ readonly Limitless: "limitless";
746
+ readonly Probable: "probable";
747
+ readonly Baozi: "baozi";
748
+ readonly Myriad: "myriad";
749
+ };
750
+ export type WatchAddressOperationExchangeEnum = typeof WatchAddressOperationExchangeEnum[keyof typeof WatchAddressOperationExchangeEnum];
699
751
  /**
700
752
  * @export
701
753
  */