pmxtjs 2.19.5 → 2.20.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.
- package/dist/esm/generated/src/apis/DefaultApi.d.ts +53 -1
- package/dist/esm/generated/src/apis/DefaultApi.js +83 -1
- package/dist/esm/generated/src/models/FetchBalanceRequest.d.ts +2 -2
- package/dist/esm/generated/src/models/FetchPositionsRequest.d.ts +2 -2
- package/dist/esm/generated/src/models/UnwatchAddressRequest.d.ts +39 -0
- package/dist/esm/generated/src/models/UnwatchAddressRequest.js +46 -0
- package/dist/esm/generated/src/models/WatchAddress200Response.d.ts +45 -0
- package/dist/esm/generated/src/models/WatchAddress200Response.js +46 -0
- package/dist/esm/generated/src/models/WatchAddressRequest.d.ts +40 -0
- package/dist/esm/generated/src/models/WatchAddressRequest.js +47 -0
- package/dist/esm/generated/src/models/WatchAddressRequestArgsInner.d.ts +21 -0
- package/dist/esm/generated/src/models/WatchAddressRequestArgsInner.js +37 -0
- package/dist/esm/generated/src/models/index.d.ts +4 -0
- package/dist/esm/generated/src/models/index.js +4 -0
- package/dist/esm/pmxt/args.d.ts +1 -0
- package/dist/esm/pmxt/args.js +3 -0
- package/dist/esm/pmxt/client.d.ts +94 -5
- package/dist/esm/pmxt/client.js +217 -33
- package/dist/esm/pmxt/models.d.ts +45 -0
- package/dist/generated/src/apis/DefaultApi.d.ts +53 -1
- package/dist/generated/src/apis/DefaultApi.js +83 -1
- package/dist/generated/src/models/FetchBalanceRequest.d.ts +2 -2
- package/dist/generated/src/models/FetchPositionsRequest.d.ts +2 -2
- package/dist/generated/src/models/UnwatchAddressRequest.d.ts +39 -0
- package/dist/generated/src/models/UnwatchAddressRequest.js +53 -0
- package/dist/generated/src/models/WatchAddress200Response.d.ts +45 -0
- package/dist/generated/src/models/WatchAddress200Response.js +53 -0
- package/dist/generated/src/models/WatchAddressRequest.d.ts +40 -0
- package/dist/generated/src/models/WatchAddressRequest.js +54 -0
- package/dist/generated/src/models/WatchAddressRequestArgsInner.d.ts +21 -0
- package/dist/generated/src/models/WatchAddressRequestArgsInner.js +43 -0
- package/dist/generated/src/models/index.d.ts +4 -0
- package/dist/generated/src/models/index.js +4 -0
- package/dist/pmxt/args.d.ts +1 -0
- package/dist/pmxt/args.js +6 -0
- package/dist/pmxt/client.d.ts +94 -5
- package/dist/pmxt/client.js +216 -32
- package/dist/pmxt/models.d.ts +45 -0
- package/generated/.openapi-generator/FILES +8 -0
- package/generated/docs/DefaultApi.md +142 -0
- package/generated/docs/FetchBalanceRequest.md +1 -1
- package/generated/docs/FetchPositionsRequest.md +1 -1
- package/generated/docs/UnwatchAddressRequest.md +36 -0
- package/generated/docs/WatchAddress200Response.md +38 -0
- package/generated/docs/WatchAddressRequest.md +36 -0
- package/generated/docs/WatchAddressRequestArgsInner.md +32 -0
- package/generated/package.json +1 -1
- package/generated/src/apis/DefaultApi.ts +127 -0
- package/generated/src/models/FetchBalanceRequest.ts +2 -2
- package/generated/src/models/FetchPositionsRequest.ts +2 -2
- package/generated/src/models/UnwatchAddressRequest.ts +82 -0
- package/generated/src/models/WatchAddress200Response.ts +89 -0
- package/generated/src/models/WatchAddressRequest.ts +89 -0
- package/generated/src/models/WatchAddressRequestArgsInner.ts +49 -0
- package/generated/src/models/index.ts +4 -0
- package/package.json +2 -2
- package/pmxt/args.ts +3 -0
- package/pmxt/client.ts +263 -39
- package/pmxt/models.ts +55 -1
package/dist/pmxt/client.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.Baozi = exports.Probable = exports.Myriad = exports.KalshiDemo = exports
|
|
|
10
10
|
const index_js_1 = require("../generated/src/index.js");
|
|
11
11
|
const models_js_1 = require("./models.js");
|
|
12
12
|
const server_manager_js_1 = require("./server-manager.js");
|
|
13
|
+
const args_js_1 = require("./args.js");
|
|
13
14
|
// Converter functions
|
|
14
15
|
function convertMarket(raw) {
|
|
15
16
|
const outcomes = (raw.outcomes || []).map((o) => ({
|
|
@@ -146,6 +147,19 @@ function convertEvent(raw) {
|
|
|
146
147
|
};
|
|
147
148
|
return event;
|
|
148
149
|
}
|
|
150
|
+
function convertSubscriptionSnapshot(raw) {
|
|
151
|
+
const trades = (raw.trades ?? []).map(convertTrade);
|
|
152
|
+
const balances = (raw.balances ?? []).map(convertBalance);
|
|
153
|
+
const positions = (raw.positions ?? []).map(convertPosition);
|
|
154
|
+
const snapShot = {
|
|
155
|
+
address: raw.address,
|
|
156
|
+
trades,
|
|
157
|
+
balances,
|
|
158
|
+
positions,
|
|
159
|
+
timestamp: raw.timestamp,
|
|
160
|
+
};
|
|
161
|
+
return snapShot;
|
|
162
|
+
}
|
|
149
163
|
/**
|
|
150
164
|
* Base class for prediction market exchanges.
|
|
151
165
|
*
|
|
@@ -298,9 +312,7 @@ class Exchange {
|
|
|
298
312
|
async fetchMarkets(params) {
|
|
299
313
|
await this.initPromise;
|
|
300
314
|
try {
|
|
301
|
-
const args =
|
|
302
|
-
if (params !== undefined)
|
|
303
|
-
args.push(params);
|
|
315
|
+
const args = (0, args_js_1.buildArgsWithOptionalOptions)(params);
|
|
304
316
|
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchMarkets`, {
|
|
305
317
|
method: 'POST',
|
|
306
318
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -321,9 +333,7 @@ class Exchange {
|
|
|
321
333
|
async fetchMarketsPaginated(params) {
|
|
322
334
|
await this.initPromise;
|
|
323
335
|
try {
|
|
324
|
-
const args =
|
|
325
|
-
if (params !== undefined)
|
|
326
|
-
args.push(params);
|
|
336
|
+
const args = (0, args_js_1.buildArgsWithOptionalOptions)(params);
|
|
327
337
|
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchMarketsPaginated`, {
|
|
328
338
|
method: 'POST',
|
|
329
339
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -348,9 +358,7 @@ class Exchange {
|
|
|
348
358
|
async fetchEvents(params) {
|
|
349
359
|
await this.initPromise;
|
|
350
360
|
try {
|
|
351
|
-
const args =
|
|
352
|
-
if (params !== undefined)
|
|
353
|
-
args.push(params);
|
|
361
|
+
const args = (0, args_js_1.buildArgsWithOptionalOptions)(params);
|
|
354
362
|
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchEvents`, {
|
|
355
363
|
method: 'POST',
|
|
356
364
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -371,9 +379,7 @@ class Exchange {
|
|
|
371
379
|
async fetchMarket(params) {
|
|
372
380
|
await this.initPromise;
|
|
373
381
|
try {
|
|
374
|
-
const args =
|
|
375
|
-
if (params !== undefined)
|
|
376
|
-
args.push(params);
|
|
382
|
+
const args = (0, args_js_1.buildArgsWithOptionalOptions)(params);
|
|
377
383
|
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchMarket`, {
|
|
378
384
|
method: 'POST',
|
|
379
385
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -394,9 +400,7 @@ class Exchange {
|
|
|
394
400
|
async fetchEvent(params) {
|
|
395
401
|
await this.initPromise;
|
|
396
402
|
try {
|
|
397
|
-
const args =
|
|
398
|
-
if (params !== undefined)
|
|
399
|
-
args.push(params);
|
|
403
|
+
const args = (0, args_js_1.buildArgsWithOptionalOptions)(params);
|
|
400
404
|
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchEvent`, {
|
|
401
405
|
method: 'POST',
|
|
402
406
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -483,9 +487,7 @@ class Exchange {
|
|
|
483
487
|
async fetchOpenOrders(marketId) {
|
|
484
488
|
await this.initPromise;
|
|
485
489
|
try {
|
|
486
|
-
const args =
|
|
487
|
-
if (marketId !== undefined)
|
|
488
|
-
args.push(marketId);
|
|
490
|
+
const args = (0, args_js_1.buildArgsWithOptionalOptions)(marketId);
|
|
489
491
|
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchOpenOrders`, {
|
|
490
492
|
method: 'POST',
|
|
491
493
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -506,9 +508,7 @@ class Exchange {
|
|
|
506
508
|
async fetchMyTrades(params) {
|
|
507
509
|
await this.initPromise;
|
|
508
510
|
try {
|
|
509
|
-
const args =
|
|
510
|
-
if (params !== undefined)
|
|
511
|
-
args.push(params);
|
|
511
|
+
const args = (0, args_js_1.buildArgsWithOptionalOptions)(params);
|
|
512
512
|
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchMyTrades`, {
|
|
513
513
|
method: 'POST',
|
|
514
514
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -529,9 +529,7 @@ class Exchange {
|
|
|
529
529
|
async fetchClosedOrders(params) {
|
|
530
530
|
await this.initPromise;
|
|
531
531
|
try {
|
|
532
|
-
const args =
|
|
533
|
-
if (params !== undefined)
|
|
534
|
-
args.push(params);
|
|
532
|
+
const args = (0, args_js_1.buildArgsWithOptionalOptions)(params);
|
|
535
533
|
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchClosedOrders`, {
|
|
536
534
|
method: 'POST',
|
|
537
535
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -552,9 +550,7 @@ class Exchange {
|
|
|
552
550
|
async fetchAllOrders(params) {
|
|
553
551
|
await this.initPromise;
|
|
554
552
|
try {
|
|
555
|
-
const args =
|
|
556
|
-
if (params !== undefined)
|
|
557
|
-
args.push(params);
|
|
553
|
+
const args = (0, args_js_1.buildArgsWithOptionalOptions)(params);
|
|
558
554
|
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchAllOrders`, {
|
|
559
555
|
method: 'POST',
|
|
560
556
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -572,10 +568,10 @@ class Exchange {
|
|
|
572
568
|
throw new Error(`Failed to fetchAllOrders: ${error}`);
|
|
573
569
|
}
|
|
574
570
|
}
|
|
575
|
-
async fetchPositions() {
|
|
571
|
+
async fetchPositions(address) {
|
|
576
572
|
await this.initPromise;
|
|
577
573
|
try {
|
|
578
|
-
const args = [];
|
|
574
|
+
const args = address ? [address] : [];
|
|
579
575
|
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchPositions`, {
|
|
580
576
|
method: 'POST',
|
|
581
577
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -593,10 +589,10 @@ class Exchange {
|
|
|
593
589
|
throw new Error(`Failed to fetchPositions: ${error}`);
|
|
594
590
|
}
|
|
595
591
|
}
|
|
596
|
-
async fetchBalance() {
|
|
592
|
+
async fetchBalance(address) {
|
|
597
593
|
await this.initPromise;
|
|
598
594
|
try {
|
|
599
|
-
const args = [];
|
|
595
|
+
const args = address ? [address] : [];
|
|
600
596
|
const response = await fetch(`${this.config.basePath}/api/${this.exchangeName}/fetchBalance`, {
|
|
601
597
|
method: 'POST',
|
|
602
598
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
@@ -761,6 +757,7 @@ class Exchange {
|
|
|
761
757
|
* Call repeatedly in a loop to stream updates (CCXT Pro pattern).
|
|
762
758
|
*
|
|
763
759
|
* @param outcomeId - Outcome ID to watch
|
|
760
|
+
* @param address - Public wallet to be watched
|
|
764
761
|
* @param since - Optional timestamp to filter trades from
|
|
765
762
|
* @param limit - Optional limit for number of trades
|
|
766
763
|
* @returns Next trade update(s)
|
|
@@ -776,10 +773,13 @@ class Exchange {
|
|
|
776
773
|
* }
|
|
777
774
|
* ```
|
|
778
775
|
*/
|
|
779
|
-
async watchTrades(outcomeId, since, limit) {
|
|
776
|
+
async watchTrades(outcomeId, address, since, limit) {
|
|
780
777
|
await this.initPromise;
|
|
781
778
|
try {
|
|
782
779
|
const args = [outcomeId];
|
|
780
|
+
if (address !== undefined) {
|
|
781
|
+
args.push(address);
|
|
782
|
+
}
|
|
783
783
|
if (since !== undefined) {
|
|
784
784
|
args.push(since);
|
|
785
785
|
}
|
|
@@ -801,7 +801,191 @@ class Exchange {
|
|
|
801
801
|
throw new Error(`Failed to watch trades: ${error}`);
|
|
802
802
|
}
|
|
803
803
|
}
|
|
804
|
+
/**
|
|
805
|
+
* Watch real-time updates of a public wallet via WebSocket.
|
|
806
|
+
*
|
|
807
|
+
* Returns a promise that resolves with the next update(s).
|
|
808
|
+
* Call repeatedly in a loop to stream updates (CCXT Pro pattern).
|
|
809
|
+
*
|
|
810
|
+
* @param address - Public wallet to be watched
|
|
811
|
+
* @param types - Subscription options including 'trades', 'positions', and 'balances'
|
|
812
|
+
* @returns Next update(s)
|
|
813
|
+
*
|
|
814
|
+
* @example
|
|
815
|
+
* ```typescript
|
|
816
|
+
* // Stream updates of a public wallet address
|
|
817
|
+
* while (true) {
|
|
818
|
+
* const snapshots = await exchange.watchAddress(address, types);
|
|
819
|
+
* for (const snapshot of snapshots) {
|
|
820
|
+
* console.log(`Trade: ${snapshot.trades}`);
|
|
821
|
+
* }
|
|
822
|
+
* }
|
|
823
|
+
* ```
|
|
824
|
+
*/
|
|
825
|
+
async watchAddress(address, types) {
|
|
826
|
+
await this.initPromise;
|
|
827
|
+
try {
|
|
828
|
+
const args = [address];
|
|
829
|
+
if (types !== undefined) {
|
|
830
|
+
args.push(types);
|
|
831
|
+
}
|
|
832
|
+
const requestBody = {
|
|
833
|
+
args,
|
|
834
|
+
credentials: this.getCredentials()
|
|
835
|
+
};
|
|
836
|
+
const response = await this.api.watchAddress({
|
|
837
|
+
exchange: this.exchangeName,
|
|
838
|
+
watchAddressRequest: requestBody,
|
|
839
|
+
});
|
|
840
|
+
const data = this.handleResponse(response);
|
|
841
|
+
return convertSubscriptionSnapshot(data);
|
|
842
|
+
}
|
|
843
|
+
catch (error) {
|
|
844
|
+
throw new Error(`Failed to watch address: ${error}`);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Stop watching a previously registered wallet address and release its resource updates.
|
|
849
|
+
*
|
|
850
|
+
* @param address - Public wallet to be watched
|
|
851
|
+
* @returns
|
|
852
|
+
*/
|
|
853
|
+
async unwatchAddress(address) {
|
|
854
|
+
await this.initPromise;
|
|
855
|
+
try {
|
|
856
|
+
const args = [address];
|
|
857
|
+
const requestBody = {
|
|
858
|
+
args,
|
|
859
|
+
credentials: this.getCredentials()
|
|
860
|
+
};
|
|
861
|
+
const response = await this.api.unwatchAddress({
|
|
862
|
+
exchange: this.exchangeName,
|
|
863
|
+
unwatchAddressRequest: requestBody,
|
|
864
|
+
});
|
|
865
|
+
return this.handleResponse(response);
|
|
866
|
+
}
|
|
867
|
+
catch (error) {
|
|
868
|
+
throw new Error(`Failed to unwatch address: ${error}`);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
804
871
|
// Trading Methods (require authentication)
|
|
872
|
+
/**
|
|
873
|
+
* Build an order payload without submitting it to the exchange.
|
|
874
|
+
* Returns the exchange-native signed order or transaction payload for
|
|
875
|
+
* inspection, forwarding through a middleware layer, or deferred
|
|
876
|
+
* submission via {@link submitOrder}.
|
|
877
|
+
*
|
|
878
|
+
* You can specify the market either with explicit marketId/outcomeId,
|
|
879
|
+
* or by passing an outcome object directly (e.g., market.yes).
|
|
880
|
+
*
|
|
881
|
+
* @param params - Order parameters (same as createOrder)
|
|
882
|
+
* @returns A BuiltOrder containing the exchange-native payload
|
|
883
|
+
*
|
|
884
|
+
* @example
|
|
885
|
+
* ```typescript
|
|
886
|
+
* // Build, inspect, then submit:
|
|
887
|
+
* const built = await exchange.buildOrder({
|
|
888
|
+
* marketId: "663583",
|
|
889
|
+
* outcomeId: "10991849...",
|
|
890
|
+
* side: "buy",
|
|
891
|
+
* type: "limit",
|
|
892
|
+
* amount: 10,
|
|
893
|
+
* price: 0.55
|
|
894
|
+
* });
|
|
895
|
+
*
|
|
896
|
+
* console.log(built.signedOrder); // inspect before submitting
|
|
897
|
+
* const order = await exchange.submitOrder(built);
|
|
898
|
+
*
|
|
899
|
+
* // Using outcome shorthand:
|
|
900
|
+
* const built2 = await exchange.buildOrder({
|
|
901
|
+
* outcome: market.yes,
|
|
902
|
+
* side: "buy",
|
|
903
|
+
* type: "market",
|
|
904
|
+
* amount: 10
|
|
905
|
+
* });
|
|
906
|
+
* ```
|
|
907
|
+
*/
|
|
908
|
+
async buildOrder(params) {
|
|
909
|
+
await this.initPromise;
|
|
910
|
+
try {
|
|
911
|
+
let marketId = params.marketId;
|
|
912
|
+
let outcomeId = params.outcomeId;
|
|
913
|
+
if (params.outcome) {
|
|
914
|
+
if (marketId !== undefined || outcomeId !== undefined) {
|
|
915
|
+
throw new Error("Cannot specify both 'outcome' and 'marketId'/'outcomeId'. Use one or the other.");
|
|
916
|
+
}
|
|
917
|
+
const outcome = params.outcome;
|
|
918
|
+
if (!outcome.marketId) {
|
|
919
|
+
throw new Error("outcome.marketId is not set. Ensure the outcome comes from a fetched market.");
|
|
920
|
+
}
|
|
921
|
+
marketId = outcome.marketId;
|
|
922
|
+
outcomeId = outcome.outcomeId;
|
|
923
|
+
}
|
|
924
|
+
const paramsDict = {
|
|
925
|
+
marketId,
|
|
926
|
+
outcomeId,
|
|
927
|
+
side: params.side,
|
|
928
|
+
type: params.type,
|
|
929
|
+
amount: params.amount,
|
|
930
|
+
};
|
|
931
|
+
if (params.price !== undefined) {
|
|
932
|
+
paramsDict.price = params.price;
|
|
933
|
+
}
|
|
934
|
+
if (params.fee !== undefined) {
|
|
935
|
+
paramsDict.fee = params.fee;
|
|
936
|
+
}
|
|
937
|
+
const requestBody = {
|
|
938
|
+
args: [paramsDict],
|
|
939
|
+
credentials: this.getCredentials()
|
|
940
|
+
};
|
|
941
|
+
const response = await this.api.buildOrder({
|
|
942
|
+
exchange: this.exchangeName,
|
|
943
|
+
buildOrderRequest: requestBody,
|
|
944
|
+
});
|
|
945
|
+
const data = this.handleResponse(response);
|
|
946
|
+
return data;
|
|
947
|
+
}
|
|
948
|
+
catch (error) {
|
|
949
|
+
throw new Error(`Failed to build order: ${error}`);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* Submit a pre-built order returned by {@link buildOrder}.
|
|
954
|
+
*
|
|
955
|
+
* @param built - The BuiltOrder payload from buildOrder()
|
|
956
|
+
* @returns The submitted order
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```typescript
|
|
960
|
+
* const built = await exchange.buildOrder({
|
|
961
|
+
* outcome: market.yes,
|
|
962
|
+
* side: "buy",
|
|
963
|
+
* type: "limit",
|
|
964
|
+
* amount: 10,
|
|
965
|
+
* price: 0.55
|
|
966
|
+
* });
|
|
967
|
+
* const order = await exchange.submitOrder(built);
|
|
968
|
+
* console.log(order.id, order.status);
|
|
969
|
+
* ```
|
|
970
|
+
*/
|
|
971
|
+
async submitOrder(built) {
|
|
972
|
+
await this.initPromise;
|
|
973
|
+
try {
|
|
974
|
+
const requestBody = {
|
|
975
|
+
args: [built],
|
|
976
|
+
credentials: this.getCredentials()
|
|
977
|
+
};
|
|
978
|
+
const response = await this.api.submitOrder({
|
|
979
|
+
exchange: this.exchangeName,
|
|
980
|
+
submitOrderRequest: requestBody,
|
|
981
|
+
});
|
|
982
|
+
const data = this.handleResponse(response);
|
|
983
|
+
return convertOrder(data);
|
|
984
|
+
}
|
|
985
|
+
catch (error) {
|
|
986
|
+
throw new Error(`Failed to submit order: ${error}`);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
805
989
|
/**
|
|
806
990
|
* Create a new order.
|
|
807
991
|
*
|
package/dist/pmxt/models.d.ts
CHANGED
|
@@ -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
|
+
}
|
|
@@ -82,7 +82,11 @@ docs/Trade.md
|
|
|
82
82
|
docs/TradesParams.md
|
|
83
83
|
docs/UnifiedEvent.md
|
|
84
84
|
docs/UnifiedMarket.md
|
|
85
|
+
docs/UnwatchAddressRequest.md
|
|
85
86
|
docs/UserTrade.md
|
|
87
|
+
docs/WatchAddress200Response.md
|
|
88
|
+
docs/WatchAddressRequest.md
|
|
89
|
+
docs/WatchAddressRequestArgsInner.md
|
|
86
90
|
docs/WatchOrderBookRequest.md
|
|
87
91
|
docs/WatchOrderBookRequestArgsInner.md
|
|
88
92
|
docs/WatchTradesRequest.md
|
|
@@ -169,7 +173,11 @@ src/models/Trade.ts
|
|
|
169
173
|
src/models/TradesParams.ts
|
|
170
174
|
src/models/UnifiedEvent.ts
|
|
171
175
|
src/models/UnifiedMarket.ts
|
|
176
|
+
src/models/UnwatchAddressRequest.ts
|
|
172
177
|
src/models/UserTrade.ts
|
|
178
|
+
src/models/WatchAddress200Response.ts
|
|
179
|
+
src/models/WatchAddressRequest.ts
|
|
180
|
+
src/models/WatchAddressRequestArgsInner.ts
|
|
173
181
|
src/models/WatchOrderBookRequest.ts
|
|
174
182
|
src/models/WatchOrderBookRequestArgsInner.ts
|
|
175
183
|
src/models/WatchTradesRequest.ts
|
|
@@ -30,6 +30,8 @@ All URIs are relative to *http://localhost:3847*
|
|
|
30
30
|
| [**healthCheck**](DefaultApi.md#healthcheck) | **GET** /health | Server Health Check |
|
|
31
31
|
| [**loadMarkets**](DefaultApi.md#loadmarketsoperation) | **POST** /api/{exchange}/loadMarkets | Load Markets |
|
|
32
32
|
| [**submitOrder**](DefaultApi.md#submitorderoperation) | **POST** /api/{exchange}/submitOrder | Submit Order |
|
|
33
|
+
| [**unwatchAddress**](DefaultApi.md#unwatchaddressoperation) | **POST** /api/{exchange}/unwatchAddress | Unwatch Address |
|
|
34
|
+
| [**watchAddress**](DefaultApi.md#watchaddressoperation) | **POST** /api/{exchange}/watchAddress | Watch Address |
|
|
33
35
|
| [**watchOrderBook**](DefaultApi.md#watchorderbookoperation) | **POST** /api/{exchange}/watchOrderBook | Watch Order Book |
|
|
34
36
|
| [**watchTrades**](DefaultApi.md#watchtradesoperation) | **POST** /api/{exchange}/watchTrades | Watch Trades |
|
|
35
37
|
|
|
@@ -1836,6 +1838,146 @@ No authorization required
|
|
|
1836
1838
|
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
1837
1839
|
|
|
1838
1840
|
|
|
1841
|
+
## unwatchAddress
|
|
1842
|
+
|
|
1843
|
+
> BaseResponse unwatchAddress(exchange, unwatchAddressRequest)
|
|
1844
|
+
|
|
1845
|
+
Unwatch Address
|
|
1846
|
+
|
|
1847
|
+
Stop watching a previously registered wallet address and release its resource updates.
|
|
1848
|
+
|
|
1849
|
+
### Example
|
|
1850
|
+
|
|
1851
|
+
```ts
|
|
1852
|
+
import {
|
|
1853
|
+
Configuration,
|
|
1854
|
+
DefaultApi,
|
|
1855
|
+
} from 'pmxtjs';
|
|
1856
|
+
import type { UnwatchAddressOperationRequest } from 'pmxtjs';
|
|
1857
|
+
|
|
1858
|
+
async function example() {
|
|
1859
|
+
console.log("🚀 Testing pmxtjs SDK...");
|
|
1860
|
+
const api = new DefaultApi();
|
|
1861
|
+
|
|
1862
|
+
const body = {
|
|
1863
|
+
// 'polymarket' | 'kalshi' | 'limitless' | 'probable' | 'baozi' | 'myriad' | The prediction market exchange to target.
|
|
1864
|
+
exchange: exchange_example,
|
|
1865
|
+
// UnwatchAddressRequest (optional)
|
|
1866
|
+
unwatchAddressRequest: ...,
|
|
1867
|
+
} satisfies UnwatchAddressOperationRequest;
|
|
1868
|
+
|
|
1869
|
+
try {
|
|
1870
|
+
const data = await api.unwatchAddress(body);
|
|
1871
|
+
console.log(data);
|
|
1872
|
+
} catch (error) {
|
|
1873
|
+
console.error(error);
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
// Run the test
|
|
1878
|
+
example().catch(console.error);
|
|
1879
|
+
```
|
|
1880
|
+
|
|
1881
|
+
### Parameters
|
|
1882
|
+
|
|
1883
|
+
|
|
1884
|
+
| Name | Type | Description | Notes |
|
|
1885
|
+
|------------- | ------------- | ------------- | -------------|
|
|
1886
|
+
| **exchange** | `polymarket`, `kalshi`, `limitless`, `probable`, `baozi`, `myriad` | The prediction market exchange to target. | [Defaults to `undefined`] [Enum: polymarket, kalshi, limitless, probable, baozi, myriad] |
|
|
1887
|
+
| **unwatchAddressRequest** | [UnwatchAddressRequest](UnwatchAddressRequest.md) | | [Optional] |
|
|
1888
|
+
|
|
1889
|
+
### Return type
|
|
1890
|
+
|
|
1891
|
+
[**BaseResponse**](BaseResponse.md)
|
|
1892
|
+
|
|
1893
|
+
### Authorization
|
|
1894
|
+
|
|
1895
|
+
No authorization required
|
|
1896
|
+
|
|
1897
|
+
### HTTP request headers
|
|
1898
|
+
|
|
1899
|
+
- **Content-Type**: `application/json`
|
|
1900
|
+
- **Accept**: `application/json`
|
|
1901
|
+
|
|
1902
|
+
|
|
1903
|
+
### HTTP response details
|
|
1904
|
+
| Status code | Description | Response headers |
|
|
1905
|
+
|-------------|-------------|------------------|
|
|
1906
|
+
| **200** | Unwatch Address response | - |
|
|
1907
|
+
|
|
1908
|
+
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
1909
|
+
|
|
1910
|
+
|
|
1911
|
+
## watchAddress
|
|
1912
|
+
|
|
1913
|
+
> WatchAddress200Response watchAddress(exchange, watchAddressRequest)
|
|
1914
|
+
|
|
1915
|
+
Watch Address
|
|
1916
|
+
|
|
1917
|
+
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).
|
|
1918
|
+
|
|
1919
|
+
### Example
|
|
1920
|
+
|
|
1921
|
+
```ts
|
|
1922
|
+
import {
|
|
1923
|
+
Configuration,
|
|
1924
|
+
DefaultApi,
|
|
1925
|
+
} from 'pmxtjs';
|
|
1926
|
+
import type { WatchAddressOperationRequest } from 'pmxtjs';
|
|
1927
|
+
|
|
1928
|
+
async function example() {
|
|
1929
|
+
console.log("🚀 Testing pmxtjs SDK...");
|
|
1930
|
+
const api = new DefaultApi();
|
|
1931
|
+
|
|
1932
|
+
const body = {
|
|
1933
|
+
// 'polymarket' | 'kalshi' | 'limitless' | 'probable' | 'baozi' | 'myriad' | The prediction market exchange to target.
|
|
1934
|
+
exchange: exchange_example,
|
|
1935
|
+
// WatchAddressRequest (optional)
|
|
1936
|
+
watchAddressRequest: ...,
|
|
1937
|
+
} satisfies WatchAddressOperationRequest;
|
|
1938
|
+
|
|
1939
|
+
try {
|
|
1940
|
+
const data = await api.watchAddress(body);
|
|
1941
|
+
console.log(data);
|
|
1942
|
+
} catch (error) {
|
|
1943
|
+
console.error(error);
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
// Run the test
|
|
1948
|
+
example().catch(console.error);
|
|
1949
|
+
```
|
|
1950
|
+
|
|
1951
|
+
### Parameters
|
|
1952
|
+
|
|
1953
|
+
|
|
1954
|
+
| Name | Type | Description | Notes |
|
|
1955
|
+
|------------- | ------------- | ------------- | -------------|
|
|
1956
|
+
| **exchange** | `polymarket`, `kalshi`, `limitless`, `probable`, `baozi`, `myriad` | The prediction market exchange to target. | [Defaults to `undefined`] [Enum: polymarket, kalshi, limitless, probable, baozi, myriad] |
|
|
1957
|
+
| **watchAddressRequest** | [WatchAddressRequest](WatchAddressRequest.md) | | [Optional] |
|
|
1958
|
+
|
|
1959
|
+
### Return type
|
|
1960
|
+
|
|
1961
|
+
[**WatchAddress200Response**](WatchAddress200Response.md)
|
|
1962
|
+
|
|
1963
|
+
### Authorization
|
|
1964
|
+
|
|
1965
|
+
No authorization required
|
|
1966
|
+
|
|
1967
|
+
### HTTP request headers
|
|
1968
|
+
|
|
1969
|
+
- **Content-Type**: `application/json`
|
|
1970
|
+
- **Accept**: `application/json`
|
|
1971
|
+
|
|
1972
|
+
|
|
1973
|
+
### HTTP response details
|
|
1974
|
+
| Status code | Description | Response headers |
|
|
1975
|
+
|-------------|-------------|------------------|
|
|
1976
|
+
| **200** | Watch Address response | - |
|
|
1977
|
+
|
|
1978
|
+
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
1979
|
+
|
|
1980
|
+
|
|
1839
1981
|
## watchOrderBook
|
|
1840
1982
|
|
|
1841
1983
|
> FetchOrderBook200Response watchOrderBook(exchange, watchOrderBookRequest)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
# UnwatchAddressRequest
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
Name | Type
|
|
8
|
+
------------ | -------------
|
|
9
|
+
`args` | Array<string>
|
|
10
|
+
`credentials` | [ExchangeCredentials](ExchangeCredentials.md)
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import type { UnwatchAddressRequest } from 'pmxtjs'
|
|
16
|
+
|
|
17
|
+
// TODO: Update the object below with actual values
|
|
18
|
+
const example = {
|
|
19
|
+
"args": null,
|
|
20
|
+
"credentials": null,
|
|
21
|
+
} satisfies UnwatchAddressRequest
|
|
22
|
+
|
|
23
|
+
console.log(example)
|
|
24
|
+
|
|
25
|
+
// Convert the instance to a JSON string
|
|
26
|
+
const exampleJSON: string = JSON.stringify(example)
|
|
27
|
+
console.log(exampleJSON)
|
|
28
|
+
|
|
29
|
+
// Parse the JSON string back to an object
|
|
30
|
+
const exampleParsed = JSON.parse(exampleJSON) as UnwatchAddressRequest
|
|
31
|
+
console.log(exampleParsed)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
35
|
+
|
|
36
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
# WatchAddress200Response
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
Name | Type
|
|
8
|
+
------------ | -------------
|
|
9
|
+
`success` | boolean
|
|
10
|
+
`error` | [ErrorDetail](ErrorDetail.md)
|
|
11
|
+
`data` | object
|
|
12
|
+
|
|
13
|
+
## Example
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import type { WatchAddress200Response } from 'pmxtjs'
|
|
17
|
+
|
|
18
|
+
// TODO: Update the object below with actual values
|
|
19
|
+
const example = {
|
|
20
|
+
"success": true,
|
|
21
|
+
"error": null,
|
|
22
|
+
"data": null,
|
|
23
|
+
} satisfies WatchAddress200Response
|
|
24
|
+
|
|
25
|
+
console.log(example)
|
|
26
|
+
|
|
27
|
+
// Convert the instance to a JSON string
|
|
28
|
+
const exampleJSON: string = JSON.stringify(example)
|
|
29
|
+
console.log(exampleJSON)
|
|
30
|
+
|
|
31
|
+
// Parse the JSON string back to an object
|
|
32
|
+
const exampleParsed = JSON.parse(exampleJSON) as WatchAddress200Response
|
|
33
|
+
console.log(exampleParsed)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
37
|
+
|
|
38
|
+
|