synpath 0.7.0__tar.gz → 0.7.2__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 (121) hide show
  1. {synpath-0.7.0 → synpath-0.7.2}/PKG-INFO +1 -1
  2. {synpath-0.7.0 → synpath-0.7.2}/pyproject.toml +1 -1
  3. {synpath-0.7.0 → synpath-0.7.2}/synpath/__init__.py +1 -1
  4. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/kalshi.py +18 -10
  5. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/polymarket.py +23 -5
  6. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/polymarket_signing.py +9 -3
  7. {synpath-0.7.0 → synpath-0.7.2}/Cargo.toml +0 -0
  8. {synpath-0.7.0 → synpath-0.7.2}/LICENSE +0 -0
  9. {synpath-0.7.0 → synpath-0.7.2}/README.md +0 -0
  10. {synpath-0.7.0 → synpath-0.7.2}/bindings/python/Cargo.lock +0 -0
  11. {synpath-0.7.0 → synpath-0.7.2}/bindings/python/Cargo.toml +0 -0
  12. {synpath-0.7.0 → synpath-0.7.2}/bindings/python/src/kalshi.rs +0 -0
  13. {synpath-0.7.0 → synpath-0.7.2}/bindings/python/src/lib.rs +0 -0
  14. {synpath-0.7.0 → synpath-0.7.2}/bindings/python/src/objects.rs +0 -0
  15. {synpath-0.7.0 → synpath-0.7.2}/bindings/python/src/polymarket.rs +0 -0
  16. {synpath-0.7.0 → synpath-0.7.2}/bindings/python/src/pyjson.rs +0 -0
  17. {synpath-0.7.0 → synpath-0.7.2}/bindings/python/src/router.rs +0 -0
  18. {synpath-0.7.0 → synpath-0.7.2}/bindings/python/src/signing.rs +0 -0
  19. {synpath-0.7.0 → synpath-0.7.2}/bindings/python/src/venues.rs +0 -0
  20. {synpath-0.7.0 → synpath-0.7.2}/build_backend/synpath_build.py +0 -0
  21. {synpath-0.7.0 → synpath-0.7.2}/crates/synpath-core/Cargo.lock +0 -0
  22. {synpath-0.7.0 → synpath-0.7.2}/crates/synpath-core/Cargo.toml +0 -0
  23. {synpath-0.7.0 → synpath-0.7.2}/crates/synpath-core/examples/decode_timing.rs +0 -0
  24. {synpath-0.7.0 → synpath-0.7.2}/crates/synpath-core/src/book.rs +0 -0
  25. {synpath-0.7.0 → synpath-0.7.2}/crates/synpath-core/src/kalshi.rs +0 -0
  26. {synpath-0.7.0 → synpath-0.7.2}/crates/synpath-core/src/lib.rs +0 -0
  27. {synpath-0.7.0 → synpath-0.7.2}/crates/synpath-core/src/opinion.rs +0 -0
  28. {synpath-0.7.0 → synpath-0.7.2}/crates/synpath-core/src/polymarket.rs +0 -0
  29. {synpath-0.7.0 → synpath-0.7.2}/crates/synpath-core/src/polymarket_us.rs +0 -0
  30. {synpath-0.7.0 → synpath-0.7.2}/crates/synpath-core/src/router.rs +0 -0
  31. {synpath-0.7.0 → synpath-0.7.2}/crates/synpath-core/src/signing.rs +0 -0
  32. {synpath-0.7.0 → synpath-0.7.2}/crates/synpath-core/src/wire.rs +0 -0
  33. {synpath-0.7.0 → synpath-0.7.2}/synpath/__main__.py +0 -0
  34. {synpath-0.7.0 → synpath-0.7.2}/synpath/_native.py +0 -0
  35. {synpath-0.7.0 → synpath-0.7.2}/synpath/base.py +0 -0
  36. {synpath-0.7.0 → synpath-0.7.2}/synpath/bucket.py +0 -0
  37. {synpath-0.7.0 → synpath-0.7.2}/synpath/client.py +0 -0
  38. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/__init__.py +0 -0
  39. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/__main__.py +0 -0
  40. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/alerts.py +0 -0
  41. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/engine.py +0 -0
  42. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/eod.py +0 -0
  43. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/events.py +0 -0
  44. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/fair_values.py +0 -0
  45. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/feeds.py +0 -0
  46. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/journal.py +0 -0
  47. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/ledger.py +0 -0
  48. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/orders/__init__.py +0 -0
  49. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/orders/base.py +0 -0
  50. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/orders/day.py +0 -0
  51. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/orders/iceberg.py +0 -0
  52. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/orders/manager.py +0 -0
  53. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/orders/oco.py +0 -0
  54. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/orders/peg.py +0 -0
  55. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/orders/routed.py +0 -0
  56. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/orders/stop.py +0 -0
  57. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/orders/taker.py +0 -0
  58. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/orders/twap.py +0 -0
  59. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/paper.py +0 -0
  60. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/reconcile.py +0 -0
  61. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/risk.py +0 -0
  62. {synpath-0.7.0 → synpath-0.7.2}/synpath/engine/router.py +0 -0
  63. {synpath-0.7.0 → synpath-0.7.2}/synpath/errors.py +0 -0
  64. {synpath-0.7.0 → synpath-0.7.2}/synpath/history.py +0 -0
  65. {synpath-0.7.0 → synpath-0.7.2}/synpath/hosted.py +0 -0
  66. {synpath-0.7.0 → synpath-0.7.2}/synpath/hosted_auth.py +0 -0
  67. {synpath-0.7.0 → synpath-0.7.2}/synpath/hyperliquid.py +0 -0
  68. {synpath-0.7.0 → synpath-0.7.2}/synpath/ids.py +0 -0
  69. {synpath-0.7.0 → synpath-0.7.2}/synpath/kalshi.py +0 -0
  70. {synpath-0.7.0 → synpath-0.7.2}/synpath/limitless.py +0 -0
  71. {synpath-0.7.0 → synpath-0.7.2}/synpath/matching.py +0 -0
  72. {synpath-0.7.0 → synpath-0.7.2}/synpath/opinion.py +0 -0
  73. {synpath-0.7.0 → synpath-0.7.2}/synpath/polymarket.py +0 -0
  74. {synpath-0.7.0 → synpath-0.7.2}/synpath/polymarket_us.py +0 -0
  75. {synpath-0.7.0 → synpath-0.7.2}/synpath/predict_fun.py +0 -0
  76. {synpath-0.7.0 → synpath-0.7.2}/synpath/remote.py +0 -0
  77. {synpath-0.7.0 → synpath-0.7.2}/synpath/server/__init__.py +0 -0
  78. {synpath-0.7.0 → synpath-0.7.2}/synpath/server/__main__.py +0 -0
  79. {synpath-0.7.0 → synpath-0.7.2}/synpath/server/api.py +0 -0
  80. {synpath-0.7.0 → synpath-0.7.2}/synpath/server/errors.py +0 -0
  81. {synpath-0.7.0 → synpath-0.7.2}/synpath/server/local.py +0 -0
  82. {synpath-0.7.0 → synpath-0.7.2}/synpath/server/models.py +0 -0
  83. {synpath-0.7.0 → synpath-0.7.2}/synpath/server/serve.py +0 -0
  84. {synpath-0.7.0 → synpath-0.7.2}/synpath/server/store.py +0 -0
  85. {synpath-0.7.0 → synpath-0.7.2}/synpath/server/trading.py +0 -0
  86. {synpath-0.7.0 → synpath-0.7.2}/synpath/sx_bet.py +0 -0
  87. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/__init__.py +0 -0
  88. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/__main__.py +0 -0
  89. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/base.py +0 -0
  90. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/credentials.py +0 -0
  91. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/errors.py +0 -0
  92. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/hyperliquid.py +0 -0
  93. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/hyperliquid_signing.py +0 -0
  94. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/init.py +0 -0
  95. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/instruments.py +0 -0
  96. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/limiter.py +0 -0
  97. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/limitless.py +0 -0
  98. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/limitless_signing.py +0 -0
  99. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/money.py +0 -0
  100. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/opinion.py +0 -0
  101. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/opinion_signing.py +0 -0
  102. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/polymarket_us.py +0 -0
  103. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/polymarket_us_exchange.py +0 -0
  104. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/predict_fun.py +0 -0
  105. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/predict_fun_signing.py +0 -0
  106. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/sx_bet.py +0 -0
  107. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/sx_bet_signing.py +0 -0
  108. {synpath-0.7.0 → synpath-0.7.2}/synpath/trading/types.py +0 -0
  109. {synpath-0.7.0 → synpath-0.7.2}/synpath/types.py +0 -0
  110. {synpath-0.7.0 → synpath-0.7.2}/synpath/ws/__init__.py +0 -0
  111. {synpath-0.7.0 → synpath-0.7.2}/synpath/ws/base.py +0 -0
  112. {synpath-0.7.0 → synpath-0.7.2}/synpath/ws/grpc.py +0 -0
  113. {synpath-0.7.0 → synpath-0.7.2}/synpath/ws/hyperliquid.py +0 -0
  114. {synpath-0.7.0 → synpath-0.7.2}/synpath/ws/kalshi.py +0 -0
  115. {synpath-0.7.0 → synpath-0.7.2}/synpath/ws/limitless.py +0 -0
  116. {synpath-0.7.0 → synpath-0.7.2}/synpath/ws/opinion.py +0 -0
  117. {synpath-0.7.0 → synpath-0.7.2}/synpath/ws/polymarket.py +0 -0
  118. {synpath-0.7.0 → synpath-0.7.2}/synpath/ws/polymarket_us.py +0 -0
  119. {synpath-0.7.0 → synpath-0.7.2}/synpath/ws/polymarket_us_exchange.py +0 -0
  120. {synpath-0.7.0 → synpath-0.7.2}/synpath/ws/predict_fun.py +0 -0
  121. {synpath-0.7.0 → synpath-0.7.2}/synpath/ws/sx_bet.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: synpath
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Intended Audience :: Financial and Insurance Industry
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -9,7 +9,7 @@ backend-path = ["build_backend"]
9
9
 
10
10
  [project]
11
11
  name = "synpath"
12
- version = "0.7.0"
12
+ version = "0.7.2"
13
13
  description = "One API for prediction markets. Kalshi and Polymarket, normalized, with every price labelled by source and time."
14
14
  readme = "README.md"
15
15
  requires-python = ">=3.10"
@@ -80,7 +80,7 @@ from .types import (
80
80
  TradesRangeResponse,
81
81
  )
82
82
 
83
- __version__ = "0.7.0"
83
+ __version__ = "0.7.2"
84
84
 
85
85
  exchanges: dict[str, type[Exchange]] = {
86
86
  "kalshi": Kalshi,
@@ -15,7 +15,7 @@ made.
15
15
  here is an immediate-or-cancel limit at the caller's protection price, and a
16
16
  request without one is refused rather than sent at a price nobody chose.
17
17
 
18
- Every request is signed: `timestamp + METHOD + path`, RSA-PSS with SHA-256
18
+ Every request is signed: `timestamp + METHOD + path`, Ed25519 or RSA-PSS with SHA-256
19
19
  over the full request path (`/trade-api/v2/...`, no query string), sent in
20
20
  three headers. The private key never leaves `KalshiSigner`.
21
21
 
@@ -102,29 +102,37 @@ class KalshiSigner:
102
102
 
103
103
  The signing payload is `timestamp_ms + METHOD + path` with `path` the full
104
104
  request path including the `/trade-api/v2` prefix and excluding any query
105
- string, per the venue's own examples. RSA-PSS, SHA-256, salt length equal
106
- to the digest -- the combination the venue's reference client uses and
107
- that a `openssl dgst -sigopt rsa_pss_saltlen:digest` reproduces.
105
+ string, per the venue's own examples. The key's type picks the scheme:
106
+ an Ed25519 key (the venue's default for new keys) signs the payload
107
+ directly; an RSA key uses RSA-PSS, SHA-256, salt length equal to the
108
+ digest -- the combination the venue's reference client uses and that a
109
+ `openssl dgst -sigopt rsa_pss_saltlen:digest` reproduces.
108
110
  """
109
111
 
110
112
  def __init__(self, key_id: str, private_key_pem: bytes):
111
113
  try:
112
114
  from cryptography.hazmat.primitives import serialization
115
+ from cryptography.hazmat.primitives.asymmetric import ed25519, rsa
113
116
  except ImportError as exc: # pragma: no cover - depends on the environment
114
117
  raise ImportError("Kalshi signing needs the `cryptography` package: pip install synpath") from exc
115
118
  self.key_id = key_id
116
119
  self._key = serialization.load_pem_private_key(private_key_pem, password=None)
120
+ if not isinstance(self._key, (ed25519.Ed25519PrivateKey, rsa.RSAPrivateKey)):
121
+ raise ValueError(f"Kalshi keys are Ed25519 or RSA; this one is {type(self._key).__name__}")
117
122
 
118
123
  def sign(self, timestamp_ms: int, method: str, path: str) -> str:
119
124
  from cryptography.hazmat.primitives import hashes
120
- from cryptography.hazmat.primitives.asymmetric import padding
125
+ from cryptography.hazmat.primitives.asymmetric import ed25519, padding
121
126
 
122
127
  payload = f"{timestamp_ms}{method.upper()}{path}".encode()
123
- signature = self._key.sign(
124
- payload,
125
- padding.PSS(mgf=padding.MGF1(hashes.SHA256()), salt_length=padding.PSS.DIGEST_LENGTH),
126
- hashes.SHA256(),
127
- )
128
+ if isinstance(self._key, ed25519.Ed25519PrivateKey):
129
+ signature = self._key.sign(payload)
130
+ else:
131
+ signature = self._key.sign(
132
+ payload,
133
+ padding.PSS(mgf=padding.MGF1(hashes.SHA256()), salt_length=padding.PSS.DIGEST_LENGTH),
134
+ hashes.SHA256(),
135
+ )
128
136
  return base64.b64encode(signature).decode()
129
137
 
130
138
  def headers(self, method: str, path: str, *, timestamp_ms: int | None = None) -> dict[str, str]:
@@ -499,7 +499,22 @@ def error_of(message: str, *, body: Any = None, status: int | None = None) -> Ex
499
499
  ones."""
500
500
  text = message.lower()
501
501
  if "not enough balance" in text or "allowance" in text:
502
+ if "allowance is not enough" in text:
503
+ message += " -- an approval is missing; run approve_trading() once from this wallet"
502
504
  return InsufficientFunds(message, body=body, status=status)
505
+ if "deposit wallet flow" in text:
506
+ # A legacy proxy or Safe wallet: the CLOB takes API orders only from a Deposit Wallet now,
507
+ # whatever the docs' wallet table still lists (seen 2026-10-13).
508
+ return OrderRejected(
509
+ f"{message} -- this account trades from a legacy wallet, and the exchange now takes API orders only "
510
+ "from a Deposit Wallet: deploy the signer's Deposit Wallet, move the pUSD into it, approve trading, "
511
+ "then set POLYMARKET_SIGNATURE_TYPE=3 and POLYMARKET_FUNDER to it",
512
+ reason="deposit_wallet_required", info=body if isinstance(body, dict) else {}, body=body, status=status)
513
+ if "signer address has to be the address of the api key" in text:
514
+ return OrderRejected(
515
+ f"{message} -- POLYMARKET_FUNDER is not this signer's account wallet: copy the address from the "
516
+ "profile menu on polymarket.com, not the deposit address the Deposit window shows",
517
+ reason="funder_not_signers_wallet", info=body if isinstance(body, dict) else {}, body=body, status=status)
503
518
  if "tick size" in text or "lower than the minimum" in text or "invalid expiration" in text:
504
519
  return InvalidOrder(message)
505
520
  if "cancel-only" in text or "post-only mode" in text or "trading is currently disabled" in text \
@@ -1117,10 +1132,12 @@ class PolymarketTrading(TradingExchange):
1117
1132
  return {spender: from_poly_raw_amount(value) for spender, value in ((raw or {}).get("allowances") or {}).items()}
1118
1133
 
1119
1134
  async def check_approvals(self) -> dict[str, bool]:
1120
- """Whether each exchange may spend the wallet's pUSD. Missing ones
1121
- are what `approve_trading` fixes."""
1135
+ """Whether each contract an order needs may spend the wallet's pUSD:
1136
+ both exchanges and the neg-risk adapter. Missing ones are what
1137
+ `approve_trading` fixes."""
1122
1138
  allowances = {k.lower(): v for k, v in (await self.fetch_allowances()).items()}
1123
- return {spender: allowances.get(spender.lower(), Decimal("0")) > 0 for spender in (sig.EXCHANGE, sig.NEG_RISK_EXCHANGE)}
1139
+ return {spender: allowances.get(spender.lower(), Decimal("0")) > 0
1140
+ for spender in (sig.EXCHANGE, sig.NEG_RISK_EXCHANGE, sig.NEG_RISK_ADAPTER)}
1124
1141
 
1125
1142
  async def sync_allowances(self, *, token_id: str | None = None) -> None:
1126
1143
  """Tell the CLOB to re-read on-chain balances and allowances, after an
@@ -1133,11 +1150,12 @@ class PolymarketTrading(TradingExchange):
1133
1150
  async def approve_trading(self, *, include_adapters: bool = True) -> dict[str, Any]:
1134
1151
  """Grant every approval trading needs, in one wallet transaction.
1135
1152
 
1136
- pUSD and the conditional tokens for both exchanges, and with
1153
+ pUSD and the conditional tokens for both exchanges and the neg-risk
1154
+ adapter (orders on a neg-risk market need it), and with
1137
1155
  `include_adapters` for both collateral adapters that split, merge and
1138
1156
  redeem use. Idempotent: an approval already granted is granted again.
1139
1157
  """
1140
- spenders = [sig.EXCHANGE, sig.NEG_RISK_EXCHANGE]
1158
+ spenders = [sig.EXCHANGE, sig.NEG_RISK_EXCHANGE, sig.NEG_RISK_ADAPTER]
1141
1159
  if include_adapters:
1142
1160
  spenders += [sig.CTF_COLLATERAL_ADAPTER, sig.NEG_RISK_CTF_COLLATERAL_ADAPTER]
1143
1161
  calls = sig.trading_approval_calls(spenders)
@@ -41,6 +41,11 @@ CONDITIONAL_TOKENS = "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045"
41
41
  PUSD = "0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB"
42
42
  CTF_COLLATERAL_ADAPTER = "0xAdA100Db00Ca00073811820692005400218FcE1f"
43
43
  NEG_RISK_CTF_COLLATERAL_ADAPTER = "0xadA2005600Dec949baf300f4C6120000bDB6eAab"
44
+ NEG_RISK_ADAPTER = "0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296"
45
+ """The CLOB checks the wallet's pUSD allowance to this adapter before it accepts
46
+ an order on a neg-risk market (several outcomes of one event), as well as the
47
+ neg-risk exchange's (seen 2026-10-13: an order refused with `spender:
48
+ 0xd91E…, allowance: 0`)."""
44
49
  DEPOSIT_WALLET_FACTORY = "0x00000000000Fb5C9ADea0298D729A0CB3823Cc07"
45
50
  """Addresses from the venue's contract page, Polygon mainnet, CLOB V2."""
46
51
 
@@ -483,9 +488,10 @@ def collateral_adapter_for(neg_risk: bool) -> str:
483
488
 
484
489
  def trading_approval_calls(spenders: list[str] | None = None) -> list[dict[str, str]]:
485
490
  """Unlimited pUSD and conditional-token approvals for each spender: by
486
- default both exchanges (trading) and both collateral adapters (split,
487
- merge, redeem)."""
488
- spenders = spenders or [EXCHANGE, NEG_RISK_EXCHANGE, CTF_COLLATERAL_ADAPTER, NEG_RISK_CTF_COLLATERAL_ADAPTER]
491
+ default both exchanges and the neg-risk adapter (trading) and both
492
+ collateral adapters (split, merge, redeem)."""
493
+ spenders = spenders or [EXCHANGE, NEG_RISK_EXCHANGE, NEG_RISK_ADAPTER, CTF_COLLATERAL_ADAPTER,
494
+ NEG_RISK_CTF_COLLATERAL_ADAPTER]
489
495
  calls = [{"target": PUSD, "value": "0", "data": approve_calldata(spender)} for spender in spenders]
490
496
  calls += [{"target": CONDITIONAL_TOKENS, "value": "0", "data": set_approval_for_all_calldata(spender)} for spender in spenders]
491
497
  return calls
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes