poly-web3 0.0.3__py3-none-any.whl → 0.0.5__py3-none-any.whl
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.
- examples/example_redeem.py +67 -63
- poly_web3/__init__.py +33 -33
- poly_web3/const.py +171 -171
- poly_web3/log.py +48 -18
- poly_web3/schema.py +22 -22
- poly_web3/signature/__init__.py +6 -6
- poly_web3/signature/build.py +113 -113
- poly_web3/signature/hash_message.py +48 -48
- poly_web3/signature/secp256k1.py +57 -57
- poly_web3/web3_service/__init__.py +9 -9
- poly_web3/web3_service/base.py +208 -182
- poly_web3/web3_service/eoa_service.py +17 -17
- poly_web3/web3_service/proxy_service.py +235 -166
- poly_web3/web3_service/safe_service.py +17 -17
- {poly_web3-0.0.3.dist-info → poly_web3-0.0.5.dist-info}/METADATA +298 -302
- poly_web3-0.0.5.dist-info/RECORD +18 -0
- poly_web3-0.0.3.dist-info/RECORD +0 -18
- {poly_web3-0.0.3.dist-info → poly_web3-0.0.5.dist-info}/WHEEL +0 -0
- {poly_web3-0.0.3.dist-info → poly_web3-0.0.5.dist-info}/top_level.txt +0 -0
|
@@ -1,302 +1,298 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: poly-web3
|
|
3
|
-
Version: 0.0.
|
|
4
|
-
Summary: Polymarket Proxy wallet redeem SDK - Execute redeem operations on Polymarket using proxy wallets
|
|
5
|
-
Home-page: https://github.com/tosmart01/poly-web3
|
|
6
|
-
Author: PinBar
|
|
7
|
-
Project-URL: Homepage, https://github.com/tosmart01/poly-web3
|
|
8
|
-
Project-URL: Repository, https://github.com/tosmart01/poly-web3
|
|
9
|
-
Project-URL: Bug Tracker, https://github.com/tosmart01/poly-web3/issues
|
|
10
|
-
Keywords: polymarket,web3,proxy,wallet,redeem,blockchain,polygon
|
|
11
|
-
Classifier: Development Status :: 3 - Alpha
|
|
12
|
-
Classifier: Intended Audience :: Developers
|
|
13
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
-
Classifier: Topic :: Internet :: WWW/HTTP
|
|
18
|
-
Requires-Python: >=3.11
|
|
19
|
-
Description-Content-Type: text/markdown
|
|
20
|
-
Requires-Dist: py-clob-client>=0.25.0
|
|
21
|
-
Requires-Dist: py-builder-relayer-client>=0.0.1
|
|
22
|
-
Requires-Dist: web3==6.8
|
|
23
|
-
Requires-Dist: eth-utils==5.3.1
|
|
24
|
-
Requires-Dist: setuptools>=80.9.0
|
|
25
|
-
Dynamic: home-page
|
|
26
|
-
Dynamic: requires-python
|
|
27
|
-
|
|
28
|
-
# poly-web3
|
|
29
|
-
|
|
30
|
-
Python SDK for Polymarket Proxy wallet redeem operations. Supports executing Conditional Token Fund (CTF) redeem operations on Polymarket through proxy wallets, Free gas.
|
|
31
|
-
|
|
32
|
-
[English](README.md) | [中文](README.zh.md)
|
|
33
|
-
|
|
34
|
-
## About the Project
|
|
35
|
-
|
|
36
|
-
This project is a Python rewrite of Polymarket's official TypeScript implementation of `builder-relayer-client`, designed to provide Python developers with a convenient tool for executing proxy wallet redeem operations on Polymarket.
|
|
37
|
-
|
|
38
|
-
**Important Notes:**
|
|
39
|
-
- This project **only implements the official redeem functionality**, focusing on Conditional Token Fund (CTF) redeem operations
|
|
40
|
-
- Other features (such as trading, order placement, etc.) are not within the scope of this project
|
|
41
|
-
|
|
42
|
-
**Some Polymarket-related redeem or write operations implemented in this project depend on access granted through Polymarket's Builder program. To perform real redeem operations against Polymarket, you must apply for and obtain a Builder key/credentials via Polymarket's official Builder application process. After approval you will receive the credentials required to use the Builder API—only then will the redeem flows in this repository work against the live service. For local development or automated tests, use mocks or testnet setups instead of real keys to avoid exposing production credentials.**
|
|
43
|
-
|
|
44
|
-
Reference:
|
|
45
|
-
- Polymarket Builders — Introduction: https://docs.polymarket.com/developers/builders/builder-intro
|
|
46
|
-
|
|
47
|
-
**Current Status:**
|
|
48
|
-
- ✅ **Proxy Wallet** - Fully supported for redeem functionality
|
|
49
|
-
- 🚧 **Safe Wallet** - Under development
|
|
50
|
-
- 🚧 **EOA Wallet** - Under development
|
|
51
|
-
|
|
52
|
-
We welcome community contributions! If you'd like to help implement Safe or EOA wallet redeem functionality, or have other improvement suggestions, please feel free to submit a Pull Request.
|
|
53
|
-
|
|
54
|
-
## Features
|
|
55
|
-
|
|
56
|
-
- ✅ Support for Polymarket Proxy wallet redeem operations (currently only Proxy wallet is supported)
|
|
57
|
-
- ✅ Check if conditions are resolved
|
|
58
|
-
- ✅ Get redeemable indexes and balances
|
|
59
|
-
- ✅ Support for standard CTF redeem and negative risk (neg_risk) redeem
|
|
60
|
-
- ✅ Automatic transaction execution through Relayer service
|
|
61
|
-
|
|
62
|
-
## Installation
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
pip install poly-web3
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
Or using uv:
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
uv add poly-web3
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Requirements
|
|
75
|
-
|
|
76
|
-
- Python >= 3.11
|
|
77
|
-
|
|
78
|
-
## Dependencies
|
|
79
|
-
|
|
80
|
-
- `py-clob-client >= 0.25.0` - Polymarket CLOB client
|
|
81
|
-
- `py-builder-relayer-client >= 0.0.1` - Builder Relayer client
|
|
82
|
-
- `web3 == 6.8` - Web3.py library
|
|
83
|
-
- `eth-utils == 5.3.1` - Ethereum utilities library
|
|
84
|
-
|
|
85
|
-
## Quick Start
|
|
86
|
-
|
|
87
|
-
### Basic Usage - Execute Redeem
|
|
88
|
-
|
|
89
|
-
```python
|
|
90
|
-
import os
|
|
91
|
-
import dotenv
|
|
92
|
-
from py_builder_relayer_client.client import RelayClient
|
|
93
|
-
from py_builder_signing_sdk.config import BuilderConfig
|
|
94
|
-
from py_builder_signing_sdk.sdk_types import BuilderApiKeyCreds
|
|
95
|
-
from py_clob_client.client import ClobClient
|
|
96
|
-
from poly_web3 import RELAYER_URL, PolyWeb3Service
|
|
97
|
-
|
|
98
|
-
dotenv.load_dotenv()
|
|
99
|
-
|
|
100
|
-
# Initialize ClobClient
|
|
101
|
-
host = "https://clob.polymarket.com"
|
|
102
|
-
chain_id = 137 # Polygon mainnet
|
|
103
|
-
client = ClobClient(
|
|
104
|
-
host,
|
|
105
|
-
key=os.getenv("POLY_API_KEY"),
|
|
106
|
-
chain_id=chain_id,
|
|
107
|
-
signature_type=1, # Proxy wallet type
|
|
108
|
-
funder=os.getenv("POLYMARKET_PROXY_ADDRESS"),
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
client.set_api_creds(client.create_or_derive_api_creds())
|
|
112
|
-
|
|
113
|
-
# Initialize RelayerClient
|
|
114
|
-
relayer_client = RelayClient(
|
|
115
|
-
RELAYER_URL,
|
|
116
|
-
chain_id,
|
|
117
|
-
os.getenv("POLY_API_KEY"),
|
|
118
|
-
BuilderConfig(
|
|
119
|
-
local_builder_creds=BuilderApiKeyCreds(
|
|
120
|
-
key=os.getenv("BUILDER_KEY"),
|
|
121
|
-
secret=os.getenv("BUILDER_SECRET"),
|
|
122
|
-
passphrase=os.getenv("BUILDER_PASSPHRASE"),
|
|
123
|
-
)
|
|
124
|
-
),
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
# Create service instance
|
|
128
|
-
service = PolyWeb3Service(
|
|
129
|
-
clob_client=client,
|
|
130
|
-
relayer_client=relayer_client,
|
|
131
|
-
rpc_url="https://polygon-bor.publicnode.com", # optional
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
print(f"Redeem
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
#
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
**
|
|
199
|
-
- `
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
- `
|
|
212
|
-
|
|
213
|
-
**
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
#
|
|
220
|
-
result = service.redeem(
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
├──
|
|
246
|
-
├──
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
└──
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
##
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
##
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
## Related Links
|
|
300
|
-
|
|
301
|
-
- [Polymarket](https://polymarket.com/)
|
|
302
|
-
- [Polygon Network](https://polygon.technology/)
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: poly-web3
|
|
3
|
+
Version: 0.0.5
|
|
4
|
+
Summary: Polymarket Proxy wallet redeem SDK - Execute redeem operations on Polymarket using proxy wallets
|
|
5
|
+
Home-page: https://github.com/tosmart01/poly-web3
|
|
6
|
+
Author: PinBar
|
|
7
|
+
Project-URL: Homepage, https://github.com/tosmart01/poly-web3
|
|
8
|
+
Project-URL: Repository, https://github.com/tosmart01/poly-web3
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/tosmart01/poly-web3/issues
|
|
10
|
+
Keywords: polymarket,web3,proxy,wallet,redeem,blockchain,polygon
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
Requires-Dist: py-clob-client>=0.25.0
|
|
21
|
+
Requires-Dist: py-builder-relayer-client>=0.0.1
|
|
22
|
+
Requires-Dist: web3==6.8
|
|
23
|
+
Requires-Dist: eth-utils==5.3.1
|
|
24
|
+
Requires-Dist: setuptools>=80.9.0
|
|
25
|
+
Dynamic: home-page
|
|
26
|
+
Dynamic: requires-python
|
|
27
|
+
|
|
28
|
+
# poly-web3
|
|
29
|
+
|
|
30
|
+
Python SDK for Polymarket Proxy wallet redeem operations. Supports executing Conditional Token Fund (CTF) redeem operations on Polymarket through proxy wallets, Free gas.
|
|
31
|
+
|
|
32
|
+
[English](README.md) | [中文](README.zh.md)
|
|
33
|
+
|
|
34
|
+
## About the Project
|
|
35
|
+
|
|
36
|
+
This project is a Python rewrite of Polymarket's official TypeScript implementation of `builder-relayer-client`, designed to provide Python developers with a convenient tool for executing proxy wallet redeem operations on Polymarket.
|
|
37
|
+
|
|
38
|
+
**Important Notes:**
|
|
39
|
+
- This project **only implements the official redeem functionality**, focusing on Conditional Token Fund (CTF) redeem operations
|
|
40
|
+
- Other features (such as trading, order placement, etc.) are not within the scope of this project
|
|
41
|
+
|
|
42
|
+
**Some Polymarket-related redeem or write operations implemented in this project depend on access granted through Polymarket's Builder program. To perform real redeem operations against Polymarket, you must apply for and obtain a Builder key/credentials via Polymarket's official Builder application process. After approval you will receive the credentials required to use the Builder API—only then will the redeem flows in this repository work against the live service. For local development or automated tests, use mocks or testnet setups instead of real keys to avoid exposing production credentials.**
|
|
43
|
+
|
|
44
|
+
Reference:
|
|
45
|
+
- Polymarket Builders — Introduction: https://docs.polymarket.com/developers/builders/builder-intro
|
|
46
|
+
|
|
47
|
+
**Current Status:**
|
|
48
|
+
- ✅ **Proxy Wallet** - Fully supported for redeem functionality
|
|
49
|
+
- 🚧 **Safe Wallet** - Under development
|
|
50
|
+
- 🚧 **EOA Wallet** - Under development
|
|
51
|
+
|
|
52
|
+
We welcome community contributions! If you'd like to help implement Safe or EOA wallet redeem functionality, or have other improvement suggestions, please feel free to submit a Pull Request.
|
|
53
|
+
|
|
54
|
+
## Features
|
|
55
|
+
|
|
56
|
+
- ✅ Support for Polymarket Proxy wallet redeem operations (currently only Proxy wallet is supported)
|
|
57
|
+
- ✅ Check if conditions are resolved
|
|
58
|
+
- ✅ Get redeemable indexes and balances
|
|
59
|
+
- ✅ Support for standard CTF redeem and negative risk (neg_risk) redeem
|
|
60
|
+
- ✅ Automatic transaction execution through Relayer service
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install poly-web3
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Or using uv:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
uv add poly-web3
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Requirements
|
|
75
|
+
|
|
76
|
+
- Python >= 3.11
|
|
77
|
+
|
|
78
|
+
## Dependencies
|
|
79
|
+
|
|
80
|
+
- `py-clob-client >= 0.25.0` - Polymarket CLOB client
|
|
81
|
+
- `py-builder-relayer-client >= 0.0.1` - Builder Relayer client
|
|
82
|
+
- `web3 == 6.8` - Web3.py library
|
|
83
|
+
- `eth-utils == 5.3.1` - Ethereum utilities library
|
|
84
|
+
|
|
85
|
+
## Quick Start
|
|
86
|
+
|
|
87
|
+
### Basic Usage - Execute Redeem
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
import os
|
|
91
|
+
import dotenv
|
|
92
|
+
from py_builder_relayer_client.client import RelayClient
|
|
93
|
+
from py_builder_signing_sdk.config import BuilderConfig
|
|
94
|
+
from py_builder_signing_sdk.sdk_types import BuilderApiKeyCreds
|
|
95
|
+
from py_clob_client.client import ClobClient
|
|
96
|
+
from poly_web3 import RELAYER_URL, PolyWeb3Service
|
|
97
|
+
|
|
98
|
+
dotenv.load_dotenv()
|
|
99
|
+
|
|
100
|
+
# Initialize ClobClient
|
|
101
|
+
host = "https://clob.polymarket.com"
|
|
102
|
+
chain_id = 137 # Polygon mainnet
|
|
103
|
+
client = ClobClient(
|
|
104
|
+
host,
|
|
105
|
+
key=os.getenv("POLY_API_KEY"),
|
|
106
|
+
chain_id=chain_id,
|
|
107
|
+
signature_type=1, # Proxy wallet type
|
|
108
|
+
funder=os.getenv("POLYMARKET_PROXY_ADDRESS"),
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
client.set_api_creds(client.create_or_derive_api_creds())
|
|
112
|
+
|
|
113
|
+
# Initialize RelayerClient
|
|
114
|
+
relayer_client = RelayClient(
|
|
115
|
+
RELAYER_URL,
|
|
116
|
+
chain_id,
|
|
117
|
+
os.getenv("POLY_API_KEY"),
|
|
118
|
+
BuilderConfig(
|
|
119
|
+
local_builder_creds=BuilderApiKeyCreds(
|
|
120
|
+
key=os.getenv("BUILDER_KEY"),
|
|
121
|
+
secret=os.getenv("BUILDER_SECRET"),
|
|
122
|
+
passphrase=os.getenv("BUILDER_PASSPHRASE"),
|
|
123
|
+
)
|
|
124
|
+
),
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
# Create service instance
|
|
128
|
+
service = PolyWeb3Service(
|
|
129
|
+
clob_client=client,
|
|
130
|
+
relayer_client=relayer_client,
|
|
131
|
+
rpc_url="https://polygon-bor.publicnode.com", # optional
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
# Execute redeem operation (batch)
|
|
136
|
+
condition_ids = [
|
|
137
|
+
"0xc3df016175463c44f9c9f98bddaa3bf3daaabb14b069fb7869621cffe73ddd1c",
|
|
138
|
+
"0x31fb435a9506d14f00b9de5e5e4491cf2223b6d40a2525d9afa8b620b61b50e2",
|
|
139
|
+
]
|
|
140
|
+
redeem_batch_result = service.redeem(condition_ids, batch_size=20)
|
|
141
|
+
print(f"Redeem batch result: {redeem_batch_result}")
|
|
142
|
+
|
|
143
|
+
# Redeem all positions that are currently redeemable
|
|
144
|
+
redeem_all_result = service.redeem_all(batch_size=20)
|
|
145
|
+
print(f"Redeem all result: {redeem_all_result}")
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Optional - Query Operations
|
|
149
|
+
|
|
150
|
+
Before executing redeem, you can optionally check the condition status and query redeemable balances:
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
# Check if condition is resolved
|
|
154
|
+
condition_id = "0xc3df016175463c44f9c9f98bddaa3bf3daaabb14b069fb7869621cffe73ddd1c"
|
|
155
|
+
can_redeem = service.is_condition_resolved(condition_id)
|
|
156
|
+
|
|
157
|
+
# Get redeemable indexes and balances
|
|
158
|
+
redeem_balance = service.get_redeemable_index_and_balance(
|
|
159
|
+
condition_id, owner=client.builder.funder
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
print(f"Can redeem: {can_redeem}")
|
|
163
|
+
print(f"Redeemable balance: {redeem_balance}")
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## API Documentation
|
|
167
|
+
|
|
168
|
+
### PolyWeb3Service
|
|
169
|
+
|
|
170
|
+
The main service class that automatically selects the appropriate service implementation based on wallet type.
|
|
171
|
+
|
|
172
|
+
#### Methods
|
|
173
|
+
|
|
174
|
+
##### `is_condition_resolved(condition_id: str) -> bool`
|
|
175
|
+
|
|
176
|
+
Check if the specified condition is resolved.
|
|
177
|
+
|
|
178
|
+
**Parameters:**
|
|
179
|
+
- `condition_id` (str): Condition ID (32-byte hexadecimal string)
|
|
180
|
+
|
|
181
|
+
**Returns:**
|
|
182
|
+
- `bool`: Returns `True` if the condition is resolved, otherwise `False`
|
|
183
|
+
|
|
184
|
+
##### `get_winning_indexes(condition_id: str) -> list[int]`
|
|
185
|
+
|
|
186
|
+
Get the list of winning indexes.
|
|
187
|
+
|
|
188
|
+
**Parameters:**
|
|
189
|
+
- `condition_id` (str): Condition ID
|
|
190
|
+
|
|
191
|
+
**Returns:**
|
|
192
|
+
- `list[int]`: List of winning indexes
|
|
193
|
+
|
|
194
|
+
##### `get_redeemable_index_and_balance(condition_id: str, owner: str) -> list[tuple]`
|
|
195
|
+
|
|
196
|
+
Get redeemable indexes and balances for the specified address.
|
|
197
|
+
|
|
198
|
+
**Parameters:**
|
|
199
|
+
- `condition_id` (str): Condition ID
|
|
200
|
+
- `owner` (str): Wallet address
|
|
201
|
+
|
|
202
|
+
**Returns:**
|
|
203
|
+
- `list[tuple]`: List of tuples containing (index, balance), balance is in USDC units
|
|
204
|
+
|
|
205
|
+
##### `redeem(condition_ids: list[str], batch_size: int = 20)`
|
|
206
|
+
|
|
207
|
+
Execute redeem operation.
|
|
208
|
+
|
|
209
|
+
**Parameters:**
|
|
210
|
+
- `condition_ids` (list[str]): List of condition IDs
|
|
211
|
+
- `batch_size` (int): Batch size for redeem requests
|
|
212
|
+
|
|
213
|
+
**Returns:**
|
|
214
|
+
- `dict | list[dict]`: Transaction result(s) containing transaction status and related information
|
|
215
|
+
|
|
216
|
+
**Examples:**
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
# Batch redeem
|
|
220
|
+
result = service.redeem(["0x...", "0x..."], batch_size=20)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
##### `redeem_all(batch_size: int = 20) -> list[dict] | None`
|
|
224
|
+
|
|
225
|
+
Redeem all positions that are currently redeemable for the authenticated account.
|
|
226
|
+
|
|
227
|
+
**Returns:**
|
|
228
|
+
- `list[dict] | None`: List of redeem results, or `None` if no redeemable positions
|
|
229
|
+
|
|
230
|
+
**Examples:**
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
# Redeem all positions that can be redeemed
|
|
234
|
+
service.redeem_all(batch_size=20)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Project Structure
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
poly_web3/
|
|
241
|
+
├── __init__.py # Main entry point, exports PolyWeb3Service
|
|
242
|
+
├── const.py # Constant definitions (contract addresses, ABIs, etc.)
|
|
243
|
+
├── schema.py # Data models (WalletType, etc.)
|
|
244
|
+
├── signature/ # Signature-related modules
|
|
245
|
+
│ ├── build.py # Proxy wallet derivation and struct hashing
|
|
246
|
+
│ ├── hash_message.py # Message hashing
|
|
247
|
+
│ └── secp256k1.py # secp256k1 signing
|
|
248
|
+
└── web3_service/ # Web3 service implementations
|
|
249
|
+
├── base.py # Base service class
|
|
250
|
+
├── proxy_service.py # Proxy wallet service (✅ Implemented)
|
|
251
|
+
├── eoa_service.py # EOA wallet service (🚧 Under development)
|
|
252
|
+
└── safe_service.py # Safe wallet service (🚧 Under development)
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Notes
|
|
256
|
+
|
|
257
|
+
1. **Environment Variable Security**: Make sure `.env` file is added to `.gitignore`, do not commit sensitive information to the code repository
|
|
258
|
+
2. **Network Support**: Currently mainly supports Polygon mainnet (chain_id: 137), Amoy testnet may have limited functionality
|
|
259
|
+
3. **Wallet Type**: **Currently only Proxy wallet is supported** (signature_type: 1), Safe and EOA wallet redeem functionality is under development
|
|
260
|
+
4. **Gas Fees**: Transactions are executed through Relayer, gas fees are handled by the Relayer
|
|
261
|
+
|
|
262
|
+
## Development
|
|
263
|
+
|
|
264
|
+
### Install Development Dependencies
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
uv pip install -e ".[dev]"
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Run Examples
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
python examples/example_redeem.py
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Contributing
|
|
277
|
+
|
|
278
|
+
We welcome all forms of contributions! If you'd like to:
|
|
279
|
+
|
|
280
|
+
- Implement Safe or EOA wallet support
|
|
281
|
+
- Fix bugs or improve existing functionality
|
|
282
|
+
- Add new features or improve documentation
|
|
283
|
+
- Make suggestions or report issues
|
|
284
|
+
|
|
285
|
+
Please feel free to submit an Issue or Pull Request. Your contributions will help make this project better!
|
|
286
|
+
|
|
287
|
+
## License
|
|
288
|
+
|
|
289
|
+
MIT
|
|
290
|
+
|
|
291
|
+
## Author
|
|
292
|
+
|
|
293
|
+
PinBar
|
|
294
|
+
|
|
295
|
+
## Related Links
|
|
296
|
+
|
|
297
|
+
- [Polymarket](https://polymarket.com/)
|
|
298
|
+
- [Polygon Network](https://polygon.technology/)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
examples/example_redeem.py,sha256=grSaAsmjgQDKd1zpd17-cYkAv7fkqFUqDEvCr3gXJtA,2149
|
|
2
|
+
poly_web3/__init__.py,sha256=O4xBBGCQoO453RdGZ9eWpjpOEOz_kFoU_TTnigbBaPs,1078
|
|
3
|
+
poly_web3/const.py,sha256=UYBs1b9P2YJw1isbUzlGOxMWIqWyRiyGt9D2WmZCYfU,4959
|
|
4
|
+
poly_web3/log.py,sha256=63XRfNTyZoQCgS5DRnZCdrMyQM1C-4bXhQ-izyvYWNI,1254
|
|
5
|
+
poly_web3/schema.py,sha256=GTzpEy8-mqw2fCqoQKQFn6ieyhXdSnW6I9YQMKGnnhM,435
|
|
6
|
+
poly_web3/signature/__init__.py,sha256=p4EwohjUtwEsFqrc7eeqY5sQa14GWc8BdR6km8c7SH8,123
|
|
7
|
+
poly_web3/signature/build.py,sha256=PEyMFbE2PM2Xvz3wvmA6T6FVnU3mB7uanoEutbneFQ8,3614
|
|
8
|
+
poly_web3/signature/hash_message.py,sha256=hREtjuOdLcm_IlBz1YuzyrObVdxs7Yn-ULfh09PeNmk,1319
|
|
9
|
+
poly_web3/signature/secp256k1.py,sha256=IBgp0vNJyskU7ZUcWCdDttrzmJgEWH6lakB74whur_w,1500
|
|
10
|
+
poly_web3/web3_service/__init__.py,sha256=HNRh06yZNYXDmGS69ISXG7_PPG9foGXLyHOdnbgYXk0,315
|
|
11
|
+
poly_web3/web3_service/base.py,sha256=cchUlqcLiOfThDFolWHudrEX6NM5sPUYpVcAkX3xung,7136
|
|
12
|
+
poly_web3/web3_service/eoa_service.py,sha256=_5nmTX7aG4u5QMECwqVOdaYK4bgE5yI1BsW4aT_UiFU,429
|
|
13
|
+
poly_web3/web3_service/proxy_service.py,sha256=TX9SVboIG7X_MeIN1diSqv8MEz9k7YrR2M4Ks8-n7Og,8650
|
|
14
|
+
poly_web3/web3_service/safe_service.py,sha256=emT7h5JmvgFKX_Rl4YP8Zj5MOLNf_4QHx8Ts1lb3WJo,432
|
|
15
|
+
poly_web3-0.0.5.dist-info/METADATA,sha256=2dsBnvsJr3QjXO47F6FZhJUIsoiJkUNPQdpk8_bq-xY,9765
|
|
16
|
+
poly_web3-0.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
17
|
+
poly_web3-0.0.5.dist-info/top_level.txt,sha256=wW40wsocHfhFgqSWWvYWrhwKGQU5IWkhyaz5J90vmHo,19
|
|
18
|
+
poly_web3-0.0.5.dist-info/RECORD,,
|
poly_web3-0.0.3.dist-info/RECORD
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
examples/example_redeem.py,sha256=jBTHM_qHbTMDwBfeD_M2oc9sDXbd-8GseBUHxpQ0M3Q,2063
|
|
2
|
-
poly_web3/__init__.py,sha256=9SfcOZtFSMErtmGG7rTtd5L2xb3pg9I7e9ctto3u3qE,1111
|
|
3
|
-
poly_web3/const.py,sha256=mmNbN4rUMHjH_65aIGoVIB1c7My_8dB1uL0eiH36f_I,5130
|
|
4
|
-
poly_web3/log.py,sha256=UaMJkBntAuWFO4yLFVQRUQHqFTiRLXnexdaBrWIGkOI,487
|
|
5
|
-
poly_web3/schema.py,sha256=sxZOzYglLLyQLwbSlQGpQzQ3IB7R059XQzJAO9T5frg,457
|
|
6
|
-
poly_web3/signature/__init__.py,sha256=g5z1cPO_o-LPdvKb3VQu4aEcpJMMjJW-a9h9Mo6qczo,129
|
|
7
|
-
poly_web3/signature/build.py,sha256=iSOzrMQOte6NWA981gQYPkCtRSoXhlFEcmV0bI7XMrA,3727
|
|
8
|
-
poly_web3/signature/hash_message.py,sha256=IYCtqdV9HKE6bG6DZXt3wedrrXUn8KQ4RBgcqZq45aI,1367
|
|
9
|
-
poly_web3/signature/secp256k1.py,sha256=AGpItsDFTAJR9ZpAfyC26llKaNmIfpD8v6HM3qqMAIA,1557
|
|
10
|
-
poly_web3/web3_service/__init__.py,sha256=pxW7XqlSDZeoYc3ohwCcdtd_9aK3gJBIQ2ANXwHXUcE,324
|
|
11
|
-
poly_web3/web3_service/base.py,sha256=7GIDYseLFuGfpfxmrfePNwywlMOUc9DGoj1U1XNpLIA,6377
|
|
12
|
-
poly_web3/web3_service/eoa_service.py,sha256=MmwaAmpD_WLk4M-2w99_F7iHTZ-pKtAnPw4m5x2h6CA,446
|
|
13
|
-
poly_web3/web3_service/proxy_service.py,sha256=L_bNWzKAKv1nQ3cBn5AxbuP6Hv3D3SbqMZgp19DtNsw,6204
|
|
14
|
-
poly_web3/web3_service/safe_service.py,sha256=KPmToVjqxFqFhFrDbY0hfR3Z00Alu9w31QKMyyluzX8,449
|
|
15
|
-
poly_web3-0.0.3.dist-info/METADATA,sha256=wiZzR2j8aDtjj3meYr1kXmZKaRtlojHEe6LSrRptd0Y,10212
|
|
16
|
-
poly_web3-0.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
17
|
-
poly_web3-0.0.3.dist-info/top_level.txt,sha256=wW40wsocHfhFgqSWWvYWrhwKGQU5IWkhyaz5J90vmHo,19
|
|
18
|
-
poly_web3-0.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|