pmxtjs 2.50.15 → 2.51.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.
@@ -57,6 +57,18 @@ export interface UserTrade {
57
57
  * @memberof UserTrade
58
58
  */
59
59
  orderId?: string;
60
+ /**
61
+ * The market this trade belongs to, when the venue exposes it (e.g. derivable from the fill's coin/asset).
62
+ * @type {string}
63
+ * @memberof UserTrade
64
+ */
65
+ marketId?: string;
66
+ /**
67
+ * Trading fee paid by the user for this fill, when the venue exposes it.
68
+ * @type {number}
69
+ * @memberof UserTrade
70
+ */
71
+ fee?: number;
60
72
  /**
61
73
  * Populated in hosted mode after on-chain settlement; null for local-mode and for non-on-chain venues.
62
74
  * @type {string}
@@ -50,6 +50,8 @@ export function UserTradeFromJSONTyped(json, ignoreDiscriminator) {
50
50
  'side': json['side'],
51
51
  'outcomeId': json['outcomeId'] == null ? undefined : json['outcomeId'],
52
52
  'orderId': json['orderId'] == null ? undefined : json['orderId'],
53
+ 'marketId': json['marketId'] == null ? undefined : json['marketId'],
54
+ 'fee': json['fee'] == null ? undefined : json['fee'],
53
55
  'txHash': json['txHash'] == null ? undefined : json['txHash'],
54
56
  'chain': json['chain'] == null ? undefined : json['chain'],
55
57
  'blockNumber': json['blockNumber'] == null ? undefined : json['blockNumber'],
@@ -70,6 +72,8 @@ export function UserTradeToJSONTyped(value, ignoreDiscriminator = false) {
70
72
  'side': value['side'],
71
73
  'outcomeId': value['outcomeId'],
72
74
  'orderId': value['orderId'],
75
+ 'marketId': value['marketId'],
76
+ 'fee': value['fee'],
73
77
  'txHash': value['txHash'],
74
78
  'chain': value['chain'],
75
79
  'blockNumber': value['blockNumber'],
@@ -5,7 +5,7 @@
5
5
  * OpenAPI client, matching the Python API exactly.
6
6
  */
7
7
  import { Configuration, DefaultApi, ExchangeCredentials } from "../generated/src/index.js";
8
- import { Balance, BuiltOrder, CreateOrderParams, EventFetchParams, EventFilterCriteria, EventFilterFunction, ExecutionPriceResult, FetchOrderBookParams, MarketFetchParams, MarketFilterCriteria, MarketFilterFunction, MarketOutcome, MyTradesParams, Order, OrderBook, OrderHistoryParams, PaginatedMarketsResult, Position, SeriesFetchParams, PriceCandle, SubscribedAddressSnapshot, SubscriptionOption, Trade, UnifiedEvent, UnifiedMarket, UnifiedSeries, UserTrade, FirehoseEvent, FetchMatchedMarketClustersParams } from "./models.js";
8
+ import { Balance, BuiltOrder, CreateOrderParams, EventFetchParams, EventFilterCriteria, EventFilterFunction, ExecutionPriceResult, FetchOrderBookParams, MarketFetchParams, MarketFilterCriteria, MarketFilterFunction, MarketOutcome, MyTradesParams, Order, OrderBook, OrderHistoryParams, PaginatedMarketsResult, PaginatedEventsResult, Position, SeriesFetchParams, PriceCandle, SubscribedAddressSnapshot, SubscriptionOption, Trade, UnifiedEvent, UnifiedMarket, UnifiedSeries, UserTrade, FirehoseEvent, FetchMatchedMarketClustersParams } from "./models.js";
9
9
  import { ServerManager } from "./server-manager.js";
10
10
  import type { Signer } from "./signers.js";
11
11
  import { Escrow } from "./escrow.js";
@@ -212,6 +212,7 @@ export declare abstract class Exchange {
212
212
  loadMarkets(reload?: boolean): Promise<Record<string, UnifiedMarket>>;
213
213
  fetchMarkets(params?: MarketFetchParams): Promise<UnifiedMarket[]>;
214
214
  fetchMarketsPaginated(params?: any): Promise<PaginatedMarketsResult>;
215
+ fetchEventsPaginated(params?: any): Promise<PaginatedEventsResult>;
215
216
  fetchEvents(params?: EventFetchParams): Promise<UnifiedEvent[]>;
216
217
  fetchSeries(params?: SeriesFetchParams): Promise<UnifiedSeries[]>;
217
218
  fetchMarket(params?: MarketFetchParams): Promise<UnifiedMarket>;
@@ -740,6 +740,38 @@ export class Exchange {
740
740
  throw new PmxtError(`Failed to fetchMarketsPaginated: ${error}`);
741
741
  }
742
742
  }
743
+ async fetchEventsPaginated(params) {
744
+ await this.initPromise;
745
+ try {
746
+ const args = [];
747
+ if (params !== undefined)
748
+ args.push(params);
749
+ const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchEventsPaginated`, {
750
+ method: 'POST',
751
+ headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
752
+ body: JSON.stringify({ args, credentials: this.getCredentials() }),
753
+ });
754
+ if (!response.ok) {
755
+ const body = await response.json().catch(() => ({}));
756
+ if (body.error && typeof body.error === "object") {
757
+ throw fromServerError(body.error);
758
+ }
759
+ throw new PmxtError(body.error?.message || response.statusText);
760
+ }
761
+ const json = await response.json();
762
+ const data = this.handleResponse(json);
763
+ return {
764
+ data: (data.data || []).map(convertEvent),
765
+ total: data.total,
766
+ nextCursor: data.nextCursor,
767
+ };
768
+ }
769
+ catch (error) {
770
+ if (error instanceof PmxtError)
771
+ throw error;
772
+ throw new PmxtError(`Failed to fetchEventsPaginated: ${error}`);
773
+ }
774
+ }
743
775
  async fetchEvents(params) {
744
776
  await this.initPromise;
745
777
  try {
@@ -1015,6 +1047,19 @@ export class Exchange {
1015
1047
  }
1016
1048
  async fetchOpenOrders(marketId) {
1017
1049
  await this.initPromise;
1050
+ if (this.isHosted) {
1051
+ const resolvedAddress = resolveWalletAddress(this, undefined);
1052
+ const route = HOSTED_METHOD_ROUTES.get("fetchOpenOrders");
1053
+ const path = formatRoutePath(route, {});
1054
+ const params = { address: resolvedAddress };
1055
+ if (marketId !== undefined)
1056
+ params.market_id = marketId;
1057
+ const data = await _tradingRequest(this, { method: route.method, path, params });
1058
+ const list = Array.isArray(data)
1059
+ ? data
1060
+ : (data && Array.isArray(data.orders) ? data.orders : []);
1061
+ return list.map((o) => orderFromV0(o));
1062
+ }
1018
1063
  try {
1019
1064
  const args = [];
1020
1065
  if (marketId !== undefined)
@@ -1554,7 +1599,7 @@ export class Exchange {
1554
1599
  paramsDict.limit = params.limit;
1555
1600
  }
1556
1601
  const args = [resolvedOutcomeId, paramsDict];
1557
- const query = { id: resolvedOutcomeId, ...paramsDict };
1602
+ const query = { outcomeId: resolvedOutcomeId, ...paramsDict };
1558
1603
  const json = await this.sidecarReadRequest('fetchOHLCV', query, args);
1559
1604
  const data = this.handleResponse(json);
1560
1605
  return data.map(convertCandle);
@@ -1592,7 +1637,7 @@ export class Exchange {
1592
1637
  paramsDict.end = params.end instanceof Date ? params.end.toISOString() : params.end;
1593
1638
  }
1594
1639
  const args = [resolvedOutcomeId, paramsDict];
1595
- const query = { id: resolvedOutcomeId, ...paramsDict };
1640
+ const query = { outcomeId: resolvedOutcomeId, ...paramsDict };
1596
1641
  const json = await this.sidecarReadRequest('fetchTrades', query, args);
1597
1642
  const data = this.handleResponse(json);
1598
1643
  return data.map(convertTrade);
@@ -57,6 +57,18 @@ export interface UserTrade {
57
57
  * @memberof UserTrade
58
58
  */
59
59
  orderId?: string;
60
+ /**
61
+ * The market this trade belongs to, when the venue exposes it (e.g. derivable from the fill's coin/asset).
62
+ * @type {string}
63
+ * @memberof UserTrade
64
+ */
65
+ marketId?: string;
66
+ /**
67
+ * Trading fee paid by the user for this fill, when the venue exposes it.
68
+ * @type {number}
69
+ * @memberof UserTrade
70
+ */
71
+ fee?: number;
60
72
  /**
61
73
  * Populated in hosted mode after on-chain settlement; null for local-mode and for non-on-chain venues.
62
74
  * @type {string}
@@ -58,6 +58,8 @@ function UserTradeFromJSONTyped(json, ignoreDiscriminator) {
58
58
  'side': json['side'],
59
59
  'outcomeId': json['outcomeId'] == null ? undefined : json['outcomeId'],
60
60
  'orderId': json['orderId'] == null ? undefined : json['orderId'],
61
+ 'marketId': json['marketId'] == null ? undefined : json['marketId'],
62
+ 'fee': json['fee'] == null ? undefined : json['fee'],
61
63
  'txHash': json['txHash'] == null ? undefined : json['txHash'],
62
64
  'chain': json['chain'] == null ? undefined : json['chain'],
63
65
  'blockNumber': json['blockNumber'] == null ? undefined : json['blockNumber'],
@@ -78,6 +80,8 @@ function UserTradeToJSONTyped(value, ignoreDiscriminator = false) {
78
80
  'side': value['side'],
79
81
  'outcomeId': value['outcomeId'],
80
82
  'orderId': value['orderId'],
83
+ 'marketId': value['marketId'],
84
+ 'fee': value['fee'],
81
85
  'txHash': value['txHash'],
82
86
  'chain': value['chain'],
83
87
  'blockNumber': value['blockNumber'],
@@ -5,7 +5,7 @@
5
5
  * OpenAPI client, matching the Python API exactly.
6
6
  */
7
7
  import { Configuration, DefaultApi, ExchangeCredentials } from "../generated/src/index.js";
8
- import { Balance, BuiltOrder, CreateOrderParams, EventFetchParams, EventFilterCriteria, EventFilterFunction, ExecutionPriceResult, FetchOrderBookParams, MarketFetchParams, MarketFilterCriteria, MarketFilterFunction, MarketOutcome, MyTradesParams, Order, OrderBook, OrderHistoryParams, PaginatedMarketsResult, Position, SeriesFetchParams, PriceCandle, SubscribedAddressSnapshot, SubscriptionOption, Trade, UnifiedEvent, UnifiedMarket, UnifiedSeries, UserTrade, FirehoseEvent, FetchMatchedMarketClustersParams } from "./models.js";
8
+ import { Balance, BuiltOrder, CreateOrderParams, EventFetchParams, EventFilterCriteria, EventFilterFunction, ExecutionPriceResult, FetchOrderBookParams, MarketFetchParams, MarketFilterCriteria, MarketFilterFunction, MarketOutcome, MyTradesParams, Order, OrderBook, OrderHistoryParams, PaginatedMarketsResult, PaginatedEventsResult, Position, SeriesFetchParams, PriceCandle, SubscribedAddressSnapshot, SubscriptionOption, Trade, UnifiedEvent, UnifiedMarket, UnifiedSeries, UserTrade, FirehoseEvent, FetchMatchedMarketClustersParams } from "./models.js";
9
9
  import { ServerManager } from "./server-manager.js";
10
10
  import type { Signer } from "./signers.js";
11
11
  import { Escrow } from "./escrow.js";
@@ -212,6 +212,7 @@ export declare abstract class Exchange {
212
212
  loadMarkets(reload?: boolean): Promise<Record<string, UnifiedMarket>>;
213
213
  fetchMarkets(params?: MarketFetchParams): Promise<UnifiedMarket[]>;
214
214
  fetchMarketsPaginated(params?: any): Promise<PaginatedMarketsResult>;
215
+ fetchEventsPaginated(params?: any): Promise<PaginatedEventsResult>;
215
216
  fetchEvents(params?: EventFetchParams): Promise<UnifiedEvent[]>;
216
217
  fetchSeries(params?: SeriesFetchParams): Promise<UnifiedSeries[]>;
217
218
  fetchMarket(params?: MarketFetchParams): Promise<UnifiedMarket>;
@@ -743,6 +743,38 @@ class Exchange {
743
743
  throw new errors_js_1.PmxtError(`Failed to fetchMarketsPaginated: ${error}`);
744
744
  }
745
745
  }
746
+ async fetchEventsPaginated(params) {
747
+ await this.initPromise;
748
+ try {
749
+ const args = [];
750
+ if (params !== undefined)
751
+ args.push(params);
752
+ const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchEventsPaginated`, {
753
+ method: 'POST',
754
+ headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
755
+ body: JSON.stringify({ args, credentials: this.getCredentials() }),
756
+ });
757
+ if (!response.ok) {
758
+ const body = await response.json().catch(() => ({}));
759
+ if (body.error && typeof body.error === "object") {
760
+ throw (0, errors_js_1.fromServerError)(body.error);
761
+ }
762
+ throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
763
+ }
764
+ const json = await response.json();
765
+ const data = this.handleResponse(json);
766
+ return {
767
+ data: (data.data || []).map(convertEvent),
768
+ total: data.total,
769
+ nextCursor: data.nextCursor,
770
+ };
771
+ }
772
+ catch (error) {
773
+ if (error instanceof errors_js_1.PmxtError)
774
+ throw error;
775
+ throw new errors_js_1.PmxtError(`Failed to fetchEventsPaginated: ${error}`);
776
+ }
777
+ }
746
778
  async fetchEvents(params) {
747
779
  await this.initPromise;
748
780
  try {
@@ -1018,6 +1050,19 @@ class Exchange {
1018
1050
  }
1019
1051
  async fetchOpenOrders(marketId) {
1020
1052
  await this.initPromise;
1053
+ if (this.isHosted) {
1054
+ const resolvedAddress = (0, hosted_routing_js_1.resolveWalletAddress)(this, undefined);
1055
+ const route = hosted_routing_js_1.HOSTED_METHOD_ROUTES.get("fetchOpenOrders");
1056
+ const path = (0, hosted_routing_js_1.formatRoutePath)(route, {});
1057
+ const params = { address: resolvedAddress };
1058
+ if (marketId !== undefined)
1059
+ params.market_id = marketId;
1060
+ const data = await (0, hosted_routing_js_1._tradingRequest)(this, { method: route.method, path, params });
1061
+ const list = Array.isArray(data)
1062
+ ? data
1063
+ : (data && Array.isArray(data.orders) ? data.orders : []);
1064
+ return list.map((o) => (0, hosted_mappers_js_1.orderFromV0)(o));
1065
+ }
1021
1066
  try {
1022
1067
  const args = [];
1023
1068
  if (marketId !== undefined)
@@ -1557,7 +1602,7 @@ class Exchange {
1557
1602
  paramsDict.limit = params.limit;
1558
1603
  }
1559
1604
  const args = [resolvedOutcomeId, paramsDict];
1560
- const query = { id: resolvedOutcomeId, ...paramsDict };
1605
+ const query = { outcomeId: resolvedOutcomeId, ...paramsDict };
1561
1606
  const json = await this.sidecarReadRequest('fetchOHLCV', query, args);
1562
1607
  const data = this.handleResponse(json);
1563
1608
  return data.map(convertCandle);
@@ -1595,7 +1640,7 @@ class Exchange {
1595
1640
  paramsDict.end = params.end instanceof Date ? params.end.toISOString() : params.end;
1596
1641
  }
1597
1642
  const args = [resolvedOutcomeId, paramsDict];
1598
- const query = { id: resolvedOutcomeId, ...paramsDict };
1643
+ const query = { outcomeId: resolvedOutcomeId, ...paramsDict };
1599
1644
  const json = await this.sidecarReadRequest('fetchTrades', query, args);
1600
1645
  const data = this.handleResponse(json);
1601
1646
  return data.map(convertTrade);
@@ -13,6 +13,8 @@ Name | Type
13
13
  `side` | string
14
14
  `outcomeId` | string
15
15
  `orderId` | string
16
+ `marketId` | string
17
+ `fee` | number
16
18
  `txHash` | string
17
19
  `chain` | string
18
20
  `blockNumber` | number
@@ -31,6 +33,8 @@ const example = {
31
33
  "side": null,
32
34
  "outcomeId": null,
33
35
  "orderId": null,
36
+ "marketId": null,
37
+ "fee": null,
34
38
  "txHash": null,
35
39
  "chain": null,
36
40
  "blockNumber": null,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmxtjs",
3
- "version": "2.50.15",
3
+ "version": "2.51.0",
4
4
  "description": "OpenAPI client for pmxtjs",
5
5
  "author": "OpenAPI-Generator",
6
6
  "repository": {
@@ -61,6 +61,18 @@ export interface UserTrade {
61
61
  * @memberof UserTrade
62
62
  */
63
63
  orderId?: string;
64
+ /**
65
+ * The market this trade belongs to, when the venue exposes it (e.g. derivable from the fill's coin/asset).
66
+ * @type {string}
67
+ * @memberof UserTrade
68
+ */
69
+ marketId?: string;
70
+ /**
71
+ * Trading fee paid by the user for this fill, when the venue exposes it.
72
+ * @type {number}
73
+ * @memberof UserTrade
74
+ */
75
+ fee?: number;
64
76
  /**
65
77
  * Populated in hosted mode after on-chain settlement; null for local-mode and for non-on-chain venues.
66
78
  * @type {string}
@@ -122,6 +134,8 @@ export function UserTradeFromJSONTyped(json: any, ignoreDiscriminator: boolean):
122
134
  'side': json['side'],
123
135
  'outcomeId': json['outcomeId'] == null ? undefined : json['outcomeId'],
124
136
  'orderId': json['orderId'] == null ? undefined : json['orderId'],
137
+ 'marketId': json['marketId'] == null ? undefined : json['marketId'],
138
+ 'fee': json['fee'] == null ? undefined : json['fee'],
125
139
  'txHash': json['txHash'] == null ? undefined : json['txHash'],
126
140
  'chain': json['chain'] == null ? undefined : json['chain'],
127
141
  'blockNumber': json['blockNumber'] == null ? undefined : json['blockNumber'],
@@ -146,6 +160,8 @@ export function UserTradeToJSONTyped(value?: UserTrade | null, ignoreDiscriminat
146
160
  'side': value['side'],
147
161
  'outcomeId': value['outcomeId'],
148
162
  'orderId': value['orderId'],
163
+ 'marketId': value['marketId'],
164
+ 'fee': value['fee'],
149
165
  'txHash': value['txHash'],
150
166
  'chain': value['chain'],
151
167
  'blockNumber': value['blockNumber'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmxtjs",
3
- "version": "2.50.15",
3
+ "version": "2.51.0",
4
4
  "description": "Unified prediction market data API - The ccxt for prediction markets",
5
5
  "author": "PMXT Contributors",
6
6
  "repository": {
@@ -43,7 +43,7 @@
43
43
  "unified"
44
44
  ],
45
45
  "dependencies": {
46
- "pmxt-core": "2.50.15",
46
+ "pmxt-core": "2.51.0",
47
47
  "ws": "^8.18.0"
48
48
  },
49
49
  "peerDependencies": {
package/pmxt/client.ts CHANGED
@@ -963,6 +963,36 @@ export abstract class Exchange {
963
963
  }
964
964
  }
965
965
 
966
+ async fetchEventsPaginated(params?: any): Promise<PaginatedEventsResult> {
967
+ await this.initPromise;
968
+ try {
969
+ const args: any[] = [];
970
+ if (params !== undefined) args.push(params);
971
+ const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchEventsPaginated`, {
972
+ method: 'POST',
973
+ headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
974
+ body: JSON.stringify({ args, credentials: this.getCredentials() }),
975
+ });
976
+ if (!response.ok) {
977
+ const body = await response.json().catch(() => ({}));
978
+ if (body.error && typeof body.error === "object") {
979
+ throw fromServerError(body.error);
980
+ }
981
+ throw new PmxtError(body.error?.message || response.statusText);
982
+ }
983
+ const json = await response.json();
984
+ const data = this.handleResponse(json);
985
+ return {
986
+ data: (data.data || []).map(convertEvent),
987
+ total: data.total,
988
+ nextCursor: data.nextCursor,
989
+ };
990
+ } catch (error) {
991
+ if (error instanceof PmxtError) throw error;
992
+ throw new PmxtError(`Failed to fetchEventsPaginated: ${error}`);
993
+ }
994
+ }
995
+
966
996
  async fetchEvents(params?: EventFetchParams): Promise<UnifiedEvent[]> {
967
997
  await this.initPromise;
968
998
  try {
@@ -1223,6 +1253,18 @@ export abstract class Exchange {
1223
1253
 
1224
1254
  async fetchOpenOrders(marketId?: string): Promise<Order[]> {
1225
1255
  await this.initPromise;
1256
+ if (this.isHosted) {
1257
+ const resolvedAddress = resolveWalletAddress(this, undefined);
1258
+ const route = HOSTED_METHOD_ROUTES.get("fetchOpenOrders")!;
1259
+ const path = formatRoutePath(route, {});
1260
+ const params: Record<string, string> = { address: resolvedAddress };
1261
+ if (marketId !== undefined) params.market_id = marketId;
1262
+ const data = await _tradingRequest(this, { method: route.method, path, params });
1263
+ const list = Array.isArray(data)
1264
+ ? data
1265
+ : (data && Array.isArray((data as any).orders) ? (data as any).orders : []);
1266
+ return list.map((o: unknown) => orderFromV0(o as Record<string, unknown>));
1267
+ }
1226
1268
  try {
1227
1269
  const args: any[] = [];
1228
1270
  if (marketId !== undefined) args.push(marketId);
@@ -1738,7 +1780,7 @@ export abstract class Exchange {
1738
1780
  }
1739
1781
 
1740
1782
  const args = [resolvedOutcomeId, paramsDict];
1741
- const query = { id: resolvedOutcomeId, ...paramsDict };
1783
+ const query = { outcomeId: resolvedOutcomeId, ...paramsDict };
1742
1784
  const json = await this.sidecarReadRequest('fetchOHLCV', query, args);
1743
1785
  const data = this.handleResponse(json);
1744
1786
  return data.map(convertCandle);
@@ -1779,7 +1821,7 @@ export abstract class Exchange {
1779
1821
  }
1780
1822
 
1781
1823
  const args = [resolvedOutcomeId, paramsDict];
1782
- const query = { id: resolvedOutcomeId, ...paramsDict };
1824
+ const query = { outcomeId: resolvedOutcomeId, ...paramsDict };
1783
1825
  const json = await this.sidecarReadRequest('fetchTrades', query, args);
1784
1826
  const data = this.handleResponse(json);
1785
1827
  return data.map(convertTrade);