polynode 0.9.2__tar.gz → 0.10.0__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.
- {polynode-0.9.2 → polynode-0.10.0}/.gitignore +3 -0
- {polynode-0.9.2 → polynode-0.10.0}/PKG-INFO +1 -1
- {polynode-0.9.2 → polynode-0.10.0}/polynode/trading/V2_ORDER_FLOW.md +2 -2
- {polynode-0.9.2 → polynode-0.10.0}/polynode/trading/constants.py +5 -1
- {polynode-0.9.2 → polynode-0.10.0}/polynode/trading/onboarding.py +49 -3
- {polynode-0.9.2 → polynode-0.10.0}/polynode/trading/types.py +1 -0
- {polynode-0.9.2 → polynode-0.10.0}/pyproject.toml +1 -1
- {polynode-0.9.2 → polynode-0.10.0}/tests/test_trading.py +1 -1
- {polynode-0.9.2 → polynode-0.10.0}/README.md +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/__init__.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/_version.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/cache/__init__.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/client.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/engine.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/errors.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/orderbook.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/orderbook_state.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/redemption_watcher.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/short_form.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/subscription.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/testing.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/trading/__init__.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/trading/clob_api.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/trading/cosigner.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/trading/eip712.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/trading/escrow.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/trading/position_management.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/trading/privy.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/trading/relayer.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/trading/signer.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/trading/sqlite_backend.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/trading/trader.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/types/__init__.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/types/enums.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/types/events.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/types/orderbook.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/types/rest.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/types/short_form.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/types/ws.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/polynode/ws.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/tests/__init__.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/tests/conftest.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/tests/test_client.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/tests/test_orderbook.py +0 -0
- {polynode-0.9.2 → polynode-0.10.0}/tests/test_types.py +0 -0
|
@@ -256,8 +256,8 @@ CTF (ERC-1155) : 0x4D97DCd97eC945f40cF65F87097ACe5EA0476045
|
|
|
256
256
|
CTF_EXCHANGE_V2 : 0xe111180000d2663c0091e4f400237545b87b996b
|
|
257
257
|
NEG_RISK_EXCHANGE_V2_A : 0xe2222d279d744050d28e00520010520000310f59
|
|
258
258
|
NegRiskAdapter (V1) : 0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296
|
|
259
|
-
CtfCollateralAdapter :
|
|
260
|
-
NegRiskCtfCollateralAdapter :
|
|
259
|
+
CtfCollateralAdapter : 0xAdA100Db00Ca00073811820692005400218FcE1f
|
|
260
|
+
NegRiskCtfCollateralAdapter : 0xadA2005600Dec949baf300f4C6120000bDB6eAab
|
|
261
261
|
|
|
262
262
|
CLOB_V2_HOST : https://clob-v2.polymarket.com
|
|
263
263
|
RELAYER : https://relayer-v2.polymarket.com
|
|
@@ -12,7 +12,7 @@ NEG_RISK_CTF_EXCHANGE = "0xC5d563A36AE78145C45a50134d48A1215220f80a"
|
|
|
12
12
|
NEG_RISK_ADAPTER = "0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296"
|
|
13
13
|
|
|
14
14
|
# ── V2 ──
|
|
15
|
-
CLOB_HOST_V2 = "https://clob
|
|
15
|
+
CLOB_HOST_V2 = "https://clob.polymarket.com"
|
|
16
16
|
CTF_EXCHANGE_V2 = "0xe111180000d2663c0091e4f400237545b87b996b"
|
|
17
17
|
NEG_RISK_CTF_EXCHANGE_V2_A = "0xe2222d279d744050d28e00520010520000310f59"
|
|
18
18
|
NEG_RISK_CTF_EXCHANGE_V2_B = "0xe2222d002000ba0053cef3375333610f64600036"
|
|
@@ -30,6 +30,10 @@ SAFE_INIT_CODE_HASH = "0x2bce2127ff07fb632d16c8347c4ebf501f4841168bed00d9e6ef715
|
|
|
30
30
|
PROXY_FACTORY = "0xaB45c5A4B0c941a2F231C04C3f49182e1A254052"
|
|
31
31
|
PROXY_INIT_CODE_HASH = "0xd21df8dc65880a8606f09fe0ce3df9b8869287ab0b058be05aa9e8af6330a00b"
|
|
32
32
|
|
|
33
|
+
# Deposit wallet derivation (Solady ERC-1967 clones)
|
|
34
|
+
DEPOSIT_WALLET_FACTORY = "0x00000000000Fb5C9ADea0298D729A0CB3823Cc07"
|
|
35
|
+
DEPOSIT_WALLET_IMPL = "0x58CA52ebe0DadfdF531Cde7062e76746de4Db1eB"
|
|
36
|
+
|
|
33
37
|
# All spender contracts that need approval
|
|
34
38
|
SPENDERS = [CTF_EXCHANGE, NEG_RISK_CTF_EXCHANGE, NEG_RISK_ADAPTER]
|
|
35
39
|
|
|
@@ -15,6 +15,8 @@ from .constants import (
|
|
|
15
15
|
CTF,
|
|
16
16
|
CTF_EXCHANGE,
|
|
17
17
|
CTF_EXCHANGE_V2,
|
|
18
|
+
DEPOSIT_WALLET_FACTORY,
|
|
19
|
+
DEPOSIT_WALLET_IMPL,
|
|
18
20
|
NEG_RISK_ADAPTER,
|
|
19
21
|
NEG_RISK_CTF_EXCHANGE,
|
|
20
22
|
NEG_RISK_CTF_EXCHANGE_V2_A,
|
|
@@ -76,22 +78,55 @@ def derive_proxy_address(eoa: str) -> str:
|
|
|
76
78
|
return to_checksum_address("0x" + addr_bytes[-20:].hex())
|
|
77
79
|
|
|
78
80
|
|
|
81
|
+
def derive_deposit_wallet_address(eoa: str) -> str:
|
|
82
|
+
"""Derive the CREATE2 deposit wallet address for an EOA (Solady ERC-1967)."""
|
|
83
|
+
try:
|
|
84
|
+
from eth_abi import encode
|
|
85
|
+
from eth_utils import keccak, to_checksum_address
|
|
86
|
+
except ImportError:
|
|
87
|
+
raise ImportError("eth-account/web3 required. Install with: pip install polynode[trading]")
|
|
88
|
+
|
|
89
|
+
factory_bytes = bytes.fromhex(DEPOSIT_WALLET_FACTORY[2:])
|
|
90
|
+
impl_bytes = bytes.fromhex(DEPOSIT_WALLET_IMPL[2:])
|
|
91
|
+
eoa_bytes = bytes.fromhex(eoa[2:] if eoa.startswith("0x") else eoa)
|
|
92
|
+
|
|
93
|
+
wallet_id = eoa_bytes.rjust(32, b"\x00")
|
|
94
|
+
args = encode(["address", "bytes32"], [DEPOSIT_WALLET_FACTORY, wallet_id])
|
|
95
|
+
salt = keccak(args)
|
|
96
|
+
|
|
97
|
+
n = len(args)
|
|
98
|
+
prefix = 0x61003d3d8160233d3973
|
|
99
|
+
combined = prefix + (n << 56)
|
|
100
|
+
cb = combined.to_bytes(10, "big")
|
|
101
|
+
|
|
102
|
+
c2 = bytes.fromhex("5155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076")
|
|
103
|
+
c1 = bytes.fromhex("cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3")
|
|
104
|
+
|
|
105
|
+
init_code = cb + impl_bytes + b"\x60\x09" + c2 + c1 + args
|
|
106
|
+
bytecode_hash = keccak(init_code)
|
|
107
|
+
|
|
108
|
+
addr_bytes = keccak(b"\xff" + factory_bytes + salt + bytecode_hash)
|
|
109
|
+
return to_checksum_address("0x" + addr_bytes[-20:].hex())
|
|
110
|
+
|
|
111
|
+
|
|
79
112
|
async def derive_funder_address(eoa: str, sig_type: SignatureType) -> str:
|
|
80
113
|
"""Derive the funder address based on signature type."""
|
|
81
114
|
if sig_type == SignatureType.POLY_GNOSIS_SAFE:
|
|
82
115
|
return derive_safe_address(eoa)
|
|
83
116
|
elif sig_type == SignatureType.POLY_PROXY:
|
|
84
117
|
return derive_proxy_address(eoa)
|
|
118
|
+
elif sig_type == SignatureType.POLY_1271:
|
|
119
|
+
return derive_deposit_wallet_address(eoa)
|
|
85
120
|
return eoa
|
|
86
121
|
|
|
87
122
|
|
|
88
123
|
async def detect_wallet_type(eoa: str) -> dict:
|
|
89
|
-
"""Auto-detect if a Safe or
|
|
124
|
+
"""Auto-detect if a Safe, Proxy, or deposit wallet is deployed for this EOA."""
|
|
90
125
|
safe_addr = derive_safe_address(eoa)
|
|
91
126
|
proxy_addr = derive_proxy_address(eoa)
|
|
92
127
|
|
|
93
128
|
async with httpx.AsyncClient(timeout=10.0) as http:
|
|
94
|
-
# Check Safe first (most common)
|
|
129
|
+
# Check Safe first (most common for existing users)
|
|
95
130
|
try:
|
|
96
131
|
resp = await http.get(f"{RELAYER_HOST}/deployed?owner={eoa}&salt={eoa}")
|
|
97
132
|
if resp.is_success:
|
|
@@ -117,7 +152,18 @@ async def detect_wallet_type(eoa: str) -> dict:
|
|
|
117
152
|
except Exception:
|
|
118
153
|
pass
|
|
119
154
|
|
|
120
|
-
#
|
|
155
|
+
# Check deposit wallet (newer accounts)
|
|
156
|
+
try:
|
|
157
|
+
dw_addr = derive_deposit_wallet_address(eoa)
|
|
158
|
+
if await is_safe_deployed(dw_addr):
|
|
159
|
+
return {
|
|
160
|
+
"signature_type": SignatureType.POLY_1271,
|
|
161
|
+
"funder_address": dw_addr,
|
|
162
|
+
}
|
|
163
|
+
except Exception:
|
|
164
|
+
pass
|
|
165
|
+
|
|
166
|
+
# Nothing deployed — default to Safe
|
|
121
167
|
return {
|
|
122
168
|
"signature_type": SignatureType.POLY_GNOSIS_SAFE,
|
|
123
169
|
"funder_address": safe_addr,
|
|
@@ -81,7 +81,7 @@ def test_safe_address_derivation():
|
|
|
81
81
|
|
|
82
82
|
def test_v2_constants():
|
|
83
83
|
"""V2 CLOB host and exchange addresses are correct."""
|
|
84
|
-
assert CLOB_HOST_V2 == "https://clob
|
|
84
|
+
assert CLOB_HOST_V2 == "https://clob.polymarket.com"
|
|
85
85
|
assert CTF_EXCHANGE_V2 == "0xe111180000d2663c0091e4f400237545b87b996b"
|
|
86
86
|
assert NEG_RISK_CTF_EXCHANGE_V2_A == "0xe2222d279d744050d28e00520010520000310f59"
|
|
87
87
|
|
|
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
|