pmxt 1.5.5__tar.gz → 1.5.7__tar.gz

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 (79) hide show
  1. {pmxt-1.5.5 → pmxt-1.5.7}/PKG-INFO +1 -1
  2. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/__init__.py +3 -1
  3. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/api_client.py +1 -1
  4. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/configuration.py +1 -1
  5. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/__init__.py +1 -0
  6. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/create_order_params.py +4 -2
  7. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/exchange_credentials.py +10 -2
  8. pmxt-1.5.7/generated/pmxt_internal/models/exchange_credentials_signature_type.py +143 -0
  9. {pmxt-1.5.5 → pmxt-1.5.7}/pmxt/__init__.py +1 -1
  10. {pmxt-1.5.5 → pmxt-1.5.7}/pmxt/_server/server/bundled.js +171 -22
  11. {pmxt-1.5.5 → pmxt-1.5.7}/pmxt/client.py +16 -0
  12. {pmxt-1.5.5 → pmxt-1.5.7}/pmxt/models.py +3 -0
  13. {pmxt-1.5.5 → pmxt-1.5.7}/pmxt.egg-info/PKG-INFO +1 -1
  14. {pmxt-1.5.5 → pmxt-1.5.7}/pmxt.egg-info/SOURCES.txt +1 -0
  15. {pmxt-1.5.5 → pmxt-1.5.7}/pyproject.toml +1 -1
  16. {pmxt-1.5.5 → pmxt-1.5.7}/README.md +0 -0
  17. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/api/__init__.py +0 -0
  18. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/api/default_api.py +0 -0
  19. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/api_response.py +0 -0
  20. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/exceptions.py +0 -0
  21. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/balance.py +0 -0
  22. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/base_request.py +0 -0
  23. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/base_response.py +0 -0
  24. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/cancel_order_request.py +0 -0
  25. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/create_order200_response.py +0 -0
  26. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/create_order_request.py +0 -0
  27. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/error_detail.py +0 -0
  28. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/error_response.py +0 -0
  29. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/execution_price_result.py +0 -0
  30. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/fetch_balance200_response.py +0 -0
  31. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/fetch_markets200_response.py +0 -0
  32. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/fetch_markets_request.py +0 -0
  33. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/fetch_ohlcv200_response.py +0 -0
  34. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/fetch_ohlcv_request.py +0 -0
  35. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/fetch_ohlcv_request_args_inner.py +0 -0
  36. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/fetch_open_orders200_response.py +0 -0
  37. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/fetch_open_orders_request.py +0 -0
  38. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/fetch_order_book200_response.py +0 -0
  39. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/fetch_order_book_request.py +0 -0
  40. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/fetch_positions200_response.py +0 -0
  41. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/fetch_positions_request.py +0 -0
  42. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/fetch_trades200_response.py +0 -0
  43. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/fetch_trades_request.py +0 -0
  44. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/get_execution_price200_response.py +0 -0
  45. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/get_execution_price_detailed200_response.py +0 -0
  46. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/get_execution_price_request.py +0 -0
  47. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/get_execution_price_request_args_inner.py +0 -0
  48. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/get_markets_by_slug_request.py +0 -0
  49. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/health_check200_response.py +0 -0
  50. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/history_filter_params.py +0 -0
  51. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/market_filter_params.py +0 -0
  52. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/market_outcome.py +0 -0
  53. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/order.py +0 -0
  54. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/order_book.py +0 -0
  55. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/order_level.py +0 -0
  56. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/position.py +0 -0
  57. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/price_candle.py +0 -0
  58. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/search_events200_response.py +0 -0
  59. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/search_events_request.py +0 -0
  60. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/search_markets_request.py +0 -0
  61. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/search_markets_request_args_inner.py +0 -0
  62. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/trade.py +0 -0
  63. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/unified_event.py +0 -0
  64. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/unified_market.py +0 -0
  65. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/watch_order_book_request.py +0 -0
  66. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/watch_order_book_request_args_inner.py +0 -0
  67. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/models/watch_trades_request.py +0 -0
  68. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/py.typed +0 -0
  69. {pmxt-1.5.5 → pmxt-1.5.7}/generated/pmxt_internal/rest.py +0 -0
  70. {pmxt-1.5.5 → pmxt-1.5.7}/pmxt/_server/__init__.py +0 -0
  71. {pmxt-1.5.5 → pmxt-1.5.7}/pmxt/_server/bin/pmxt-ensure-server +0 -0
  72. {pmxt-1.5.5 → pmxt-1.5.7}/pmxt/_server/bin/pmxt-ensure-server.js +0 -0
  73. {pmxt-1.5.5 → pmxt-1.5.7}/pmxt/server_manager.py +0 -0
  74. {pmxt-1.5.5 → pmxt-1.5.7}/pmxt.egg-info/dependency_links.txt +0 -0
  75. {pmxt-1.5.5 → pmxt-1.5.7}/pmxt.egg-info/requires.txt +0 -0
  76. {pmxt-1.5.5 → pmxt-1.5.7}/pmxt.egg-info/top_level.txt +0 -0
  77. {pmxt-1.5.5 → pmxt-1.5.7}/setup.cfg +0 -0
  78. {pmxt-1.5.5 → pmxt-1.5.7}/tests/test_integration.py +0 -0
  79. {pmxt-1.5.5 → pmxt-1.5.7}/tests/test_server_manager.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pmxt
3
- Version: 1.5.5
3
+ Version: 1.5.7
4
4
  Summary: Unified prediction market data API - The ccxt for prediction markets
5
5
  Author: PMXT Contributors
6
6
  License: MIT
@@ -14,7 +14,7 @@
14
14
  """ # noqa: E501
15
15
 
16
16
 
17
- __version__ = "1.5.5"
17
+ __version__ = "1.5.7"
18
18
 
19
19
  # Define package exports
20
20
  __all__ = [
@@ -38,6 +38,7 @@ __all__ = [
38
38
  "ErrorDetail",
39
39
  "ErrorResponse",
40
40
  "ExchangeCredentials",
41
+ "ExchangeCredentialsSignatureType",
41
42
  "ExecutionPriceResult",
42
43
  "FetchBalance200Response",
43
44
  "FetchMarkets200Response",
@@ -104,6 +105,7 @@ from pmxt_internal.models.create_order_request import CreateOrderRequest as Crea
104
105
  from pmxt_internal.models.error_detail import ErrorDetail as ErrorDetail
105
106
  from pmxt_internal.models.error_response import ErrorResponse as ErrorResponse
106
107
  from pmxt_internal.models.exchange_credentials import ExchangeCredentials as ExchangeCredentials
108
+ from pmxt_internal.models.exchange_credentials_signature_type import ExchangeCredentialsSignatureType as ExchangeCredentialsSignatureType
107
109
  from pmxt_internal.models.execution_price_result import ExecutionPriceResult as ExecutionPriceResult
108
110
  from pmxt_internal.models.fetch_balance200_response import FetchBalance200Response as FetchBalance200Response
109
111
  from pmxt_internal.models.fetch_markets200_response import FetchMarkets200Response as FetchMarkets200Response
@@ -91,7 +91,7 @@ class ApiClient:
91
91
  self.default_headers[header_name] = header_value
92
92
  self.cookie = cookie
93
93
  # Set default User-Agent.
94
- self.user_agent = 'OpenAPI-Generator/1.5.5/python'
94
+ self.user_agent = 'OpenAPI-Generator/1.5.7/python'
95
95
  self.client_side_validation = configuration.client_side_validation
96
96
 
97
97
  def __enter__(self):
@@ -506,7 +506,7 @@ class Configuration:
506
506
  "OS: {env}\n"\
507
507
  "Python Version: {pyversion}\n"\
508
508
  "Version of the API: 0.4.4\n"\
509
- "SDK Package Version: 1.5.5".\
509
+ "SDK Package Version: 1.5.7".\
510
510
  format(env=sys.platform, pyversion=sys.version)
511
511
 
512
512
  def get_host_settings(self) -> List[HostSetting]:
@@ -23,6 +23,7 @@ from pmxt_internal.models.create_order_request import CreateOrderRequest
23
23
  from pmxt_internal.models.error_detail import ErrorDetail
24
24
  from pmxt_internal.models.error_response import ErrorResponse
25
25
  from pmxt_internal.models.exchange_credentials import ExchangeCredentials
26
+ from pmxt_internal.models.exchange_credentials_signature_type import ExchangeCredentialsSignatureType
26
27
  from pmxt_internal.models.execution_price_result import ExecutionPriceResult
27
28
  from pmxt_internal.models.fetch_balance200_response import FetchBalance200Response
28
29
  from pmxt_internal.models.fetch_markets200_response import FetchMarkets200Response
@@ -32,7 +32,8 @@ class CreateOrderParams(BaseModel):
32
32
  type: StrictStr
33
33
  amount: Union[StrictFloat, StrictInt]
34
34
  price: Optional[Union[StrictFloat, StrictInt]] = None
35
- __properties: ClassVar[List[str]] = ["marketId", "outcomeId", "side", "type", "amount", "price"]
35
+ fee: Optional[Union[StrictFloat, StrictInt]] = None
36
+ __properties: ClassVar[List[str]] = ["marketId", "outcomeId", "side", "type", "amount", "price", "fee"]
36
37
 
37
38
  @field_validator('side')
38
39
  def side_validate_enum(cls, value):
@@ -104,7 +105,8 @@ class CreateOrderParams(BaseModel):
104
105
  "side": obj.get("side"),
105
106
  "type": obj.get("type"),
106
107
  "amount": obj.get("amount"),
107
- "price": obj.get("price")
108
+ "price": obj.get("price"),
109
+ "fee": obj.get("fee")
108
110
  })
109
111
  return _obj
110
112
 
@@ -19,6 +19,7 @@ import json
19
19
 
20
20
  from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
21
  from typing import Any, ClassVar, Dict, List, Optional
22
+ from pmxt_internal.models.exchange_credentials_signature_type import ExchangeCredentialsSignatureType
22
23
  from typing import Optional, Set
23
24
  from typing_extensions import Self
24
25
 
@@ -30,7 +31,9 @@ class ExchangeCredentials(BaseModel):
30
31
  private_key: Optional[StrictStr] = Field(default=None, description="Private key for signing transactions", alias="privateKey")
31
32
  api_secret: Optional[StrictStr] = Field(default=None, description="API secret (if required by exchange)", alias="apiSecret")
32
33
  passphrase: Optional[StrictStr] = Field(default=None, description="Passphrase (if required by exchange)")
33
- __properties: ClassVar[List[str]] = ["apiKey", "privateKey", "apiSecret", "passphrase"]
34
+ funder_address: Optional[StrictStr] = Field(default=None, description="The address funding the trades (Proxy address)", alias="funderAddress")
35
+ signature_type: Optional[ExchangeCredentialsSignatureType] = Field(default=None, alias="signatureType")
36
+ __properties: ClassVar[List[str]] = ["apiKey", "privateKey", "apiSecret", "passphrase", "funderAddress", "signatureType"]
34
37
 
35
38
  model_config = ConfigDict(
36
39
  populate_by_name=True,
@@ -71,6 +74,9 @@ class ExchangeCredentials(BaseModel):
71
74
  exclude=excluded_fields,
72
75
  exclude_none=True,
73
76
  )
77
+ # override the default output from pydantic by calling `to_dict()` of signature_type
78
+ if self.signature_type:
79
+ _dict['signatureType'] = self.signature_type.to_dict()
74
80
  return _dict
75
81
 
76
82
  @classmethod
@@ -86,7 +92,9 @@ class ExchangeCredentials(BaseModel):
86
92
  "apiKey": obj.get("apiKey"),
87
93
  "privateKey": obj.get("privateKey"),
88
94
  "apiSecret": obj.get("apiSecret"),
89
- "passphrase": obj.get("passphrase")
95
+ "passphrase": obj.get("passphrase"),
96
+ "funderAddress": obj.get("funderAddress"),
97
+ "signatureType": ExchangeCredentialsSignatureType.from_dict(obj["signatureType"]) if obj.get("signatureType") is not None else None
90
98
  })
91
99
  return _obj
92
100
 
@@ -0,0 +1,143 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ PMXT Sidecar API
5
+
6
+ A unified local sidecar API for prediction markets (Polymarket, Kalshi). This API acts as a JSON-RPC-style gateway. Each endpoint corresponds to a specific method on the generic exchange implementation.
7
+
8
+ The version of the OpenAPI document: 0.4.4
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import json
17
+ import pprint
18
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, ValidationError, field_validator
19
+ from typing import Any, List, Optional
20
+ from pydantic import StrictStr, Field
21
+ from typing import Union, List, Set, Optional, Dict
22
+ from typing_extensions import Literal, Self
23
+
24
+ EXCHANGECREDENTIALSSIGNATURETYPE_ONE_OF_SCHEMAS = ["int", "str"]
25
+
26
+ class ExchangeCredentialsSignatureType(BaseModel):
27
+ """
28
+ Signature type (0=EOA, 1=Poly Proxy, 2=Gnosis Safe, or names like 'gnosis_safe')
29
+ """
30
+ # data type: int
31
+ oneof_schema_1_validator: Optional[StrictInt] = None
32
+ # data type: str
33
+ oneof_schema_2_validator: Optional[StrictStr] = None
34
+ actual_instance: Optional[Union[int, str]] = None
35
+ one_of_schemas: Set[str] = { "int", "str" }
36
+
37
+ model_config = ConfigDict(
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+
43
+ def __init__(self, *args, **kwargs) -> None:
44
+ if args:
45
+ if len(args) > 1:
46
+ raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
47
+ if kwargs:
48
+ raise ValueError("If a position argument is used, keyword arguments cannot be used.")
49
+ super().__init__(actual_instance=args[0])
50
+ else:
51
+ super().__init__(**kwargs)
52
+
53
+ @field_validator('actual_instance')
54
+ def actual_instance_must_validate_oneof(cls, v):
55
+ instance = ExchangeCredentialsSignatureType.model_construct()
56
+ error_messages = []
57
+ match = 0
58
+ # validate data type: int
59
+ try:
60
+ instance.oneof_schema_1_validator = v
61
+ match += 1
62
+ except (ValidationError, ValueError) as e:
63
+ error_messages.append(str(e))
64
+ # validate data type: str
65
+ try:
66
+ instance.oneof_schema_2_validator = v
67
+ match += 1
68
+ except (ValidationError, ValueError) as e:
69
+ error_messages.append(str(e))
70
+ if match > 1:
71
+ # more than 1 match
72
+ raise ValueError("Multiple matches found when setting `actual_instance` in ExchangeCredentialsSignatureType with oneOf schemas: int, str. Details: " + ", ".join(error_messages))
73
+ elif match == 0:
74
+ # no match
75
+ raise ValueError("No match found when setting `actual_instance` in ExchangeCredentialsSignatureType with oneOf schemas: int, str. Details: " + ", ".join(error_messages))
76
+ else:
77
+ return v
78
+
79
+ @classmethod
80
+ def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
81
+ return cls.from_json(json.dumps(obj))
82
+
83
+ @classmethod
84
+ def from_json(cls, json_str: str) -> Self:
85
+ """Returns the object represented by the json string"""
86
+ instance = cls.model_construct()
87
+ error_messages = []
88
+ match = 0
89
+
90
+ # deserialize data into int
91
+ try:
92
+ # validation
93
+ instance.oneof_schema_1_validator = json.loads(json_str)
94
+ # assign value to actual_instance
95
+ instance.actual_instance = instance.oneof_schema_1_validator
96
+ match += 1
97
+ except (ValidationError, ValueError) as e:
98
+ error_messages.append(str(e))
99
+ # deserialize data into str
100
+ try:
101
+ # validation
102
+ instance.oneof_schema_2_validator = json.loads(json_str)
103
+ # assign value to actual_instance
104
+ instance.actual_instance = instance.oneof_schema_2_validator
105
+ match += 1
106
+ except (ValidationError, ValueError) as e:
107
+ error_messages.append(str(e))
108
+
109
+ if match > 1:
110
+ # more than 1 match
111
+ raise ValueError("Multiple matches found when deserializing the JSON string into ExchangeCredentialsSignatureType with oneOf schemas: int, str. Details: " + ", ".join(error_messages))
112
+ elif match == 0:
113
+ # no match
114
+ raise ValueError("No match found when deserializing the JSON string into ExchangeCredentialsSignatureType with oneOf schemas: int, str. Details: " + ", ".join(error_messages))
115
+ else:
116
+ return instance
117
+
118
+ def to_json(self) -> str:
119
+ """Returns the JSON representation of the actual instance"""
120
+ if self.actual_instance is None:
121
+ return "null"
122
+
123
+ if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
124
+ return self.actual_instance.to_json()
125
+ else:
126
+ return json.dumps(self.actual_instance)
127
+
128
+ def to_dict(self) -> Optional[Union[Dict[str, Any], int, str]]:
129
+ """Returns the dict representation of the actual instance"""
130
+ if self.actual_instance is None:
131
+ return None
132
+
133
+ if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
134
+ return self.actual_instance.to_dict()
135
+ else:
136
+ # primitive type
137
+ return self.actual_instance
138
+
139
+ def to_str(self) -> str:
140
+ """Returns the string representation of the actual instance"""
141
+ return pprint.pformat(self.model_dump())
142
+
143
+
@@ -33,7 +33,7 @@ from .models import (
33
33
  CreateOrderParams,
34
34
  )
35
35
 
36
- __version__ = "1.5.5"
36
+ __version__ = "1.5.7"
37
37
  __all__ = [
38
38
  # Exchanges
39
39
  "Polymarket",
@@ -83184,10 +83184,14 @@ var require_lib36 = __commonJS({
83184
83184
  var require_auth = __commonJS({
83185
83185
  "dist/exchanges/polymarket/auth.js"(exports2) {
83186
83186
  "use strict";
83187
+ var __importDefault = exports2 && exports2.__importDefault || function(mod) {
83188
+ return mod && mod.__esModule ? mod : { "default": mod };
83189
+ };
83187
83190
  Object.defineProperty(exports2, "__esModule", { value: true });
83188
83191
  exports2.PolymarketAuth = void 0;
83189
83192
  var clob_client_1 = (init_dist2(), __toCommonJS(dist_exports));
83190
83193
  var ethers_1 = require_lib36();
83194
+ var axios_1 = __importDefault(require_axios());
83191
83195
  var POLYMARKET_HOST = "https://clob.polymarket.com";
83192
83196
  var POLYGON_CHAIN_ID = 137;
83193
83197
  var PolymarketAuth = class {
@@ -83218,20 +83222,84 @@ var require_auth = __commonJS({
83218
83222
  let creds;
83219
83223
  try {
83220
83224
  creds = await l1Client.deriveApiKey();
83225
+ if (!creds || !creds.key || !creds.secret || !creds.passphrase) {
83226
+ throw new Error("Derived credentials are incomplete/empty");
83227
+ }
83221
83228
  } catch (deriveError) {
83229
+ console.log("[PolymarketAuth] Derivation failed:", deriveError.message || deriveError);
83230
+ console.log("[PolymarketAuth] Attempting to create new API key...");
83222
83231
  try {
83223
83232
  creds = await l1Client.createApiKey();
83233
+ console.log("[PolymarketAuth] createApiKey returned:", JSON.stringify(creds, null, 2));
83224
83234
  } catch (createError) {
83225
- console.error("Failed to both derive and create API key:", createError?.message || createError);
83226
- throw new Error("Authentication failed: Could not create or derive API key.");
83235
+ const apiError = createError?.response?.data?.error || createError?.message || createError;
83236
+ console.error("[PolymarketAuth] Failed to both derive and create API key. Create error:", apiError);
83237
+ throw new Error(`Authentication failed: Could not create or derive API key. Latest error: ${apiError}`);
83227
83238
  }
83228
83239
  }
83229
- if (!creds) {
83230
- throw new Error("Authentication failed: Credentials are empty.");
83240
+ if (!creds || !creds.key || !creds.secret || !creds.passphrase) {
83241
+ console.error("[PolymarketAuth] Incomplete credentials:", { hasKey: !!creds?.key, hasSecret: !!creds?.secret, hasPassphrase: !!creds?.passphrase });
83242
+ throw new Error("Authentication failed: Derived credentials are incomplete.");
83231
83243
  }
83244
+ console.log(`[PolymarketAuth] Successfully obtained API credentials for key ${creds.key.substring(0, 8)}...`);
83232
83245
  this.apiCreds = creds;
83233
83246
  return creds;
83234
83247
  }
83248
+ /**
83249
+ * Discover the proxy address and signature type for the signer.
83250
+ */
83251
+ async discoverProxy() {
83252
+ if (this.discoveredProxyAddress) {
83253
+ return {
83254
+ proxyAddress: this.discoveredProxyAddress,
83255
+ signatureType: this.discoveredSignatureType ?? 0
83256
+ };
83257
+ }
83258
+ const address = this.signer.address;
83259
+ try {
83260
+ const response = await axios_1.default.get(`https://data-api.polymarket.com/profiles/${address}`);
83261
+ const profile = response.data;
83262
+ console.log(`[PolymarketAuth] Profile for ${address}:`, JSON.stringify(profile));
83263
+ if (profile && profile.proxyAddress) {
83264
+ this.discoveredProxyAddress = profile.proxyAddress;
83265
+ this.discoveredSignatureType = profile.isGnosisSafe ? 2 : 1;
83266
+ console.log(`[PolymarketAuth] Auto-discovered proxy for ${address}: ${this.discoveredProxyAddress} (Type: ${this.discoveredSignatureType})`);
83267
+ return {
83268
+ proxyAddress: this.discoveredProxyAddress,
83269
+ signatureType: this.discoveredSignatureType
83270
+ };
83271
+ }
83272
+ } catch (error) {
83273
+ console.warn(`[PolymarketAuth] Could not auto-discover proxy for ${address}:`, error instanceof Error ? error.message : error);
83274
+ }
83275
+ return {
83276
+ proxyAddress: address,
83277
+ signatureType: 0
83278
+ };
83279
+ }
83280
+ /**
83281
+ * Maps human-readable signature type names to their numeric values.
83282
+ */
83283
+ mapSignatureType(type) {
83284
+ if (type === void 0 || type === null)
83285
+ return 0;
83286
+ if (typeof type === "number")
83287
+ return type;
83288
+ const normalized = type.toLowerCase().replace(/[^a-z0-9]/g, "");
83289
+ switch (normalized) {
83290
+ case "eoa":
83291
+ return 0;
83292
+ case "polyproxy":
83293
+ case "polymarketproxy":
83294
+ return 1;
83295
+ case "gnosissafe":
83296
+ case "safe":
83297
+ return 2;
83298
+ default:
83299
+ const parsed = parseInt(normalized);
83300
+ return isNaN(parsed) ? 0 : parsed;
83301
+ }
83302
+ }
83235
83303
  /**
83236
83304
  * Get an authenticated CLOB client for L2 operations (trading).
83237
83305
  * This client can place orders, cancel orders, query positions, etc.
@@ -83240,12 +83308,40 @@ var require_auth = __commonJS({
83240
83308
  if (this.clobClient) {
83241
83309
  return this.clobClient;
83242
83310
  }
83311
+ let proxyAddress = this.credentials.funderAddress || void 0;
83312
+ let signatureType = this.mapSignatureType(this.credentials.signatureType);
83313
+ if (!proxyAddress) {
83314
+ const discovered = await this.discoverProxy();
83315
+ proxyAddress = discovered.proxyAddress;
83316
+ if (this.credentials.signatureType === void 0 || this.credentials.signatureType === null) {
83317
+ signatureType = discovered.signatureType;
83318
+ }
83319
+ }
83243
83320
  const apiCreds = await this.getApiCredentials();
83244
- const signatureType = this.credentials.signatureType ?? 0;
83245
- const funderAddress = this.credentials.funderAddress ?? this.signer.address;
83246
- this.clobClient = new clob_client_1.ClobClient(POLYMARKET_HOST, POLYGON_CHAIN_ID, this.signer, apiCreds, signatureType, funderAddress);
83321
+ const signerAddress = this.signer.address;
83322
+ const finalProxyAddress = proxyAddress || signerAddress;
83323
+ const finalSignatureType = signatureType;
83324
+ console.log(`[PolymarketAuth] Initializing ClobClient | Signer: ${signerAddress} | Funder: ${finalProxyAddress} | SigType: ${finalSignatureType}`);
83325
+ this.clobClient = new clob_client_1.ClobClient(POLYMARKET_HOST, POLYGON_CHAIN_ID, this.signer, apiCreds, finalSignatureType, finalProxyAddress);
83247
83326
  return this.clobClient;
83248
83327
  }
83328
+ /**
83329
+ * Get the funder address (Proxy) if available.
83330
+ * Note: This is an async-safe getter if discovery is needed.
83331
+ */
83332
+ async getEffectiveFunderAddress() {
83333
+ if (this.credentials.funderAddress) {
83334
+ return this.credentials.funderAddress;
83335
+ }
83336
+ const discovered = await this.discoverProxy();
83337
+ return discovered.proxyAddress;
83338
+ }
83339
+ /**
83340
+ * Synchronous getter for credentials funder address.
83341
+ */
83342
+ getFunderAddress() {
83343
+ return this.credentials.funderAddress || this.signer.address;
83344
+ }
83249
83345
  /**
83250
83346
  * Get the signer's address.
83251
83347
  */
@@ -104860,13 +104956,16 @@ var require_polymarket = __commonJS({
104860
104956
  }
104861
104957
  }
104862
104958
  try {
104863
- const response = await client.createAndPostOrder({
104959
+ const orderArgs = {
104864
104960
  tokenID: params.outcomeId,
104865
104961
  price,
104866
104962
  side,
104867
- size: params.amount,
104868
- feeRateBps: 0
104869
- }, {
104963
+ size: params.amount
104964
+ };
104965
+ if (params.fee !== void 0 && params.fee !== null) {
104966
+ orderArgs.feeRateBps = params.fee;
104967
+ }
104968
+ const response = await client.createAndPostOrder(orderArgs, {
104870
104969
  tickSize
104871
104970
  });
104872
104971
  if (!response || !response.success) {
@@ -104883,6 +104982,7 @@ var require_polymarket = __commonJS({
104883
104982
  status: "open",
104884
104983
  filled: 0,
104885
104984
  remaining: params.amount,
104985
+ fee: params.fee,
104886
104986
  timestamp: Date.now()
104887
104987
  };
104888
104988
  } catch (error) {
@@ -104995,7 +105095,7 @@ var require_polymarket = __commonJS({
104995
105095
  }
104996
105096
  async fetchPositions() {
104997
105097
  const auth = this.ensureAuth();
104998
- const address = auth.getAddress();
105098
+ const address = await auth.getEffectiveFunderAddress();
104999
105099
  return (0, fetchPositions_1.fetchPositions)(address);
105000
105100
  }
105001
105101
  async fetchBalance() {
@@ -105003,11 +105103,32 @@ var require_polymarket = __commonJS({
105003
105103
  const client = await auth.getClobClient();
105004
105104
  try {
105005
105105
  const USDC_DECIMALS = 6;
105006
- const balRes = await client.getBalanceAllowance({
105007
- asset_type: clob_client_1.AssetType.COLLATERAL
105008
- });
105009
- const rawBalance = parseFloat(balRes.balance);
105010
- const total = rawBalance / Math.pow(10, USDC_DECIMALS);
105106
+ let total = 0;
105107
+ try {
105108
+ const balRes = await client.getBalanceAllowance({
105109
+ asset_type: clob_client_1.AssetType.COLLATERAL
105110
+ });
105111
+ const rawBalance = parseFloat(balRes.balance);
105112
+ total = rawBalance / Math.pow(10, USDC_DECIMALS);
105113
+ } catch (clobError) {
105114
+ }
105115
+ if (total === 0) {
105116
+ try {
105117
+ const { ethers } = require_lib36();
105118
+ const provider = new ethers.providers.JsonRpcProvider("https://polygon-rpc.com");
105119
+ const usdcAddress = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
105120
+ const usdcAbi = ["function balanceOf(address) view returns (uint256)", "function decimals() view returns (uint8)"];
105121
+ const usdcContract = new ethers.Contract(usdcAddress, usdcAbi, provider);
105122
+ const targetAddress = await auth.getEffectiveFunderAddress();
105123
+ const usdcBal = await usdcContract.balanceOf(targetAddress);
105124
+ const decimals = await usdcContract.decimals();
105125
+ const onChainTotal = parseFloat(ethers.utils.formatUnits(usdcBal, decimals));
105126
+ if (onChainTotal > 0) {
105127
+ total = onChainTotal;
105128
+ }
105129
+ } catch (chainError) {
105130
+ }
105131
+ }
105011
105132
  const openOrders = await client.getOpenOrders({});
105012
105133
  let locked = 0;
105013
105134
  if (openOrders && Array.isArray(openOrders)) {
@@ -105473,6 +105594,29 @@ var require_auth2 = __commonJS({
105473
105594
  this.apiCreds = creds;
105474
105595
  return creds;
105475
105596
  }
105597
+ /**
105598
+ * Maps human-readable signature type names to their numeric values.
105599
+ */
105600
+ mapSignatureType(type) {
105601
+ if (type === void 0 || type === null)
105602
+ return 0;
105603
+ if (typeof type === "number")
105604
+ return type;
105605
+ const normalized = type.toLowerCase().replace(/[^a-z0-9]/g, "");
105606
+ switch (normalized) {
105607
+ case "eoa":
105608
+ return 0;
105609
+ case "polyproxy":
105610
+ case "polymarketproxy":
105611
+ return 1;
105612
+ case "gnosissafe":
105613
+ case "safe":
105614
+ return 2;
105615
+ default:
105616
+ const parsed = parseInt(normalized);
105617
+ return isNaN(parsed) ? 0 : parsed;
105618
+ }
105619
+ }
105476
105620
  /**
105477
105621
  * Get an authenticated CLOB client for L2 operations (trading).
105478
105622
  * This client can place orders, cancel orders, query positions, etc.
@@ -105482,7 +105626,7 @@ var require_auth2 = __commonJS({
105482
105626
  return this.clobClient;
105483
105627
  }
105484
105628
  const apiCreds = await this.getApiCredentials();
105485
- const signatureType = this.credentials.signatureType ?? 0;
105629
+ const signatureType = this.mapSignatureType(this.credentials.signatureType);
105486
105630
  const funderAddress = this.credentials.funderAddress ?? this.signer.address;
105487
105631
  this.clobClient = new clob_client_1.ClobClient(LIMITLESS_HOST, BASE_CHAIN_ID, this.signer, apiCreds, signatureType, funderAddress);
105488
105632
  return this.clobClient;
@@ -107248,12 +107392,15 @@ var require_app = __commonJS({
107248
107392
  }
107249
107393
  });
107250
107394
  app.use((error, req, res, next) => {
107251
- console.error("Error:", error);
107395
+ console.error("API Error:", error);
107396
+ if (error.stack) {
107397
+ console.error(error.stack);
107398
+ }
107252
107399
  res.status(error.status || 500).json({
107253
107400
  success: false,
107254
107401
  error: {
107255
- message: error.message || "Internal server error"
107256
- // stack: process.env.NODE_ENV === 'development' ? error.stack : undefined
107402
+ message: error.message || "Internal server error",
107403
+ stack: process.env.NODE_ENV === "development" ? error.stack : void 0
107257
107404
  }
107258
107405
  });
107259
107406
  });
@@ -107266,7 +107413,9 @@ var require_app = __commonJS({
107266
107413
  privateKey: credentials?.privateKey || process.env.POLYMARKET_PK || process.env.POLYMARKET_PRIVATE_KEY,
107267
107414
  apiKey: credentials?.apiKey || process.env.POLYMARKET_API_KEY,
107268
107415
  apiSecret: credentials?.apiSecret || process.env.POLYMARKET_API_SECRET,
107269
- passphrase: credentials?.passphrase || process.env.POLYMARKET_PASSPHRASE
107416
+ passphrase: credentials?.passphrase || process.env.POLYMARKET_PASSPHRASE,
107417
+ funderAddress: credentials?.funderAddress,
107418
+ signatureType: credentials?.signatureType
107270
107419
  });
107271
107420
  case "limitless":
107272
107421
  return new limitless_1.LimitlessExchange({
@@ -195,6 +195,8 @@ class Exchange(ABC):
195
195
  private_key: Optional[str] = None,
196
196
  base_url: str = "http://localhost:3847",
197
197
  auto_start_server: bool = True,
198
+ proxy_address: Optional[str] = None,
199
+ signature_type: Optional[Any] = None,
198
200
  ):
199
201
  """
200
202
  Initialize an exchange client.
@@ -209,6 +211,8 @@ class Exchange(ABC):
209
211
  self.exchange_name = exchange_name.lower()
210
212
  self.api_key = api_key
211
213
  self.private_key = private_key
214
+ self.proxy_address = proxy_address
215
+ self.signature_type = signature_type
212
216
 
213
217
  # Initialize server manager
214
218
  self._server_manager = ServerManager(base_url)
@@ -264,6 +268,10 @@ class Exchange(ABC):
264
268
  creds["apiKey"] = self.api_key
265
269
  if self.private_key:
266
270
  creds["privateKey"] = self.private_key
271
+ if self.proxy_address:
272
+ creds["funderAddress"] = self.proxy_address
273
+ if self.signature_type is not None:
274
+ creds["signatureType"] = self.signature_type
267
275
  return creds if creds else None
268
276
 
269
277
  # Market Data Methods
@@ -670,6 +678,8 @@ class Exchange(ABC):
670
678
  }
671
679
  if params.price is not None:
672
680
  params_dict["price"] = params.price
681
+ if params.fee is not None:
682
+ params_dict["fee"] = params.fee
673
683
 
674
684
  request_body_dict = {"args": [params_dict]}
675
685
 
@@ -933,6 +943,8 @@ class Polymarket(Exchange):
933
943
  private_key: Optional[str] = None,
934
944
  base_url: str = "http://localhost:3847",
935
945
  auto_start_server: bool = True,
946
+ proxy_address: Optional[str] = None,
947
+ signature_type: Optional[Any] = None,
936
948
  ):
937
949
  """
938
950
  Initialize Polymarket client.
@@ -941,12 +953,16 @@ class Polymarket(Exchange):
941
953
  private_key: Polygon private key (required for trading)
942
954
  base_url: Base URL of the PMXT sidecar server
943
955
  auto_start_server: Automatically start server if not running (default: True)
956
+ proxy_address: Optional Polymarket Proxy/Smart Wallet address
957
+ signature_type: Optional signature type (0=EOA, 1=Proxy)
944
958
  """
945
959
  super().__init__(
946
960
  exchange_name="polymarket",
947
961
  private_key=private_key,
948
962
  base_url=base_url,
949
963
  auto_start_server=auto_start_server,
964
+ proxy_address=proxy_address,
965
+ signature_type=signature_type,
950
966
  )
951
967
 
952
968
 
@@ -395,3 +395,6 @@ class CreateOrderParams:
395
395
 
396
396
  price: Optional[float] = None
397
397
  """Limit price (required for limit orders, 0.0-1.0)"""
398
+
399
+ fee: Optional[int] = None
400
+ """Optional fee rate (e.g., 1000 for 0.1%)"""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pmxt
3
- Version: 1.5.5
3
+ Version: 1.5.7
4
4
  Summary: Unified prediction market data API - The ccxt for prediction markets
5
5
  Author: PMXT Contributors
6
6
  License: MIT
@@ -20,6 +20,7 @@ generated/pmxt_internal/models/create_order_request.py
20
20
  generated/pmxt_internal/models/error_detail.py
21
21
  generated/pmxt_internal/models/error_response.py
22
22
  generated/pmxt_internal/models/exchange_credentials.py
23
+ generated/pmxt_internal/models/exchange_credentials_signature_type.py
23
24
  generated/pmxt_internal/models/execution_price_result.py
24
25
  generated/pmxt_internal/models/fetch_balance200_response.py
25
26
  generated/pmxt_internal/models/fetch_markets200_response.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pmxt"
7
- version = "1.5.5"
7
+ version = "1.5.7"
8
8
  description = "Unified prediction market data API - The ccxt for prediction markets"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes