poly-web3 0.0.1__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.
@@ -0,0 +1,275 @@
1
+ Metadata-Version: 2.4
2
+ Name: poly-web3
3
+ Version: 0.0.1
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.
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
+ **Current Status:**
43
+ - βœ… **Proxy Wallet** - Fully supported for redeem functionality
44
+ - 🚧 **Safe Wallet** - Under development
45
+ - 🚧 **EOA Wallet** - Under development
46
+
47
+ 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.
48
+
49
+ ## Features
50
+
51
+ - βœ… Support for Polymarket Proxy wallet redeem operations (currently only Proxy wallet is supported)
52
+ - βœ… Check if conditions are resolved
53
+ - βœ… Get redeemable indexes and balances
54
+ - βœ… Support for standard CTF redeem and negative risk (neg_risk) redeem
55
+ - βœ… Automatic transaction execution through Relayer service
56
+
57
+ ## Installation
58
+
59
+ ```bash
60
+ pip install poly-web3
61
+ ```
62
+
63
+ Or using uv:
64
+
65
+ ```bash
66
+ uv add poly-web3
67
+ ```
68
+
69
+ ## Requirements
70
+
71
+ - Python >= 3.11
72
+
73
+ ## Dependencies
74
+
75
+ - `py-clob-client >= 0.25.0` - Polymarket CLOB client
76
+ - `py-builder-relayer-client >= 0.0.1` - Builder Relayer client
77
+ - `web3 == 6.8` - Web3.py library
78
+ - `eth-utils == 5.3.1` - Ethereum utilities library
79
+
80
+ ## Quick Start
81
+
82
+ ### Basic Usage - Execute Redeem
83
+
84
+ ```python
85
+ import os
86
+ import dotenv
87
+ from py_builder_relayer_client.client import RelayClient
88
+ from py_builder_signing_sdk.config import BuilderConfig
89
+ from py_builder_signing_sdk.sdk_types import BuilderApiKeyCreds
90
+ from py_clob_client.client import ClobClient
91
+ from poly_web3 import RELAYER_URL, PolyWeb3Service
92
+
93
+ dotenv.load_dotenv()
94
+
95
+ # Initialize ClobClient
96
+ host = "https://clob.polymarket.com"
97
+ chain_id = 137 # Polygon mainnet
98
+ client = ClobClient(
99
+ host,
100
+ key=os.getenv("POLY_API_KEY"),
101
+ chain_id=chain_id,
102
+ signature_type=1, # Proxy wallet type
103
+ funder=os.getenv("POLYMARKET_PROXY_ADDRESS"),
104
+ )
105
+
106
+ client.set_api_creds(client.create_or_derive_api_creds())
107
+
108
+ # Initialize RelayerClient
109
+ relayer_client = RelayClient(
110
+ RELAYER_URL,
111
+ chain_id,
112
+ os.getenv("POLY_API_KEY"),
113
+ BuilderConfig(
114
+ local_builder_creds=BuilderApiKeyCreds(
115
+ key=os.getenv("BUILDER_KEY"),
116
+ secret=os.getenv("BUILDER_SECRET"),
117
+ passphrase=os.getenv("BUILDER_PASSPHRASE"),
118
+ )
119
+ ),
120
+ )
121
+
122
+ # Create service instance
123
+ service = PolyWeb3Service(clob_client=client, relayer_client=relayer_client)
124
+
125
+ # Execute redeem operation
126
+ condition_id = "0xc3df016175463c44f9c9f98bddaa3bf3daaabb14b069fb7869621cffe73ddd1c"
127
+ redeem_result = service.redeem(condition_id=condition_id)
128
+ print(f"Redeem result: {redeem_result}")
129
+ ```
130
+
131
+ ### Optional - Query Operations
132
+
133
+ Before executing redeem, you can optionally check the condition status and query redeemable balances:
134
+
135
+ ```python
136
+ # Check if condition is resolved
137
+ condition_id = "0xc3df016175463c44f9c9f98bddaa3bf3daaabb14b069fb7869621cffe73ddd1c"
138
+ can_redeem = service.is_condition_resolved(condition_id)
139
+
140
+ # Get redeemable indexes and balances
141
+ redeem_balance = service.get_redeemable_index_and_balance(
142
+ condition_id, owner=client.builder.funder
143
+ )
144
+
145
+ print(f"Can redeem: {can_redeem}")
146
+ print(f"Redeemable balance: {redeem_balance}")
147
+ ```
148
+
149
+ ## API Documentation
150
+
151
+ ### PolyWeb3Service
152
+
153
+ The main service class that automatically selects the appropriate service implementation based on wallet type.
154
+
155
+ #### Methods
156
+
157
+ ##### `is_condition_resolved(condition_id: str) -> bool`
158
+
159
+ Check if the specified condition is resolved.
160
+
161
+ **Parameters:**
162
+ - `condition_id` (str): Condition ID (32-byte hexadecimal string)
163
+
164
+ **Returns:**
165
+ - `bool`: Returns `True` if the condition is resolved, otherwise `False`
166
+
167
+ ##### `get_winning_indexes(condition_id: str) -> list[int]`
168
+
169
+ Get the list of winning indexes.
170
+
171
+ **Parameters:**
172
+ - `condition_id` (str): Condition ID
173
+
174
+ **Returns:**
175
+ - `list[int]`: List of winning indexes
176
+
177
+ ##### `get_redeemable_index_and_balance(condition_id: str, owner: str) -> list[tuple]`
178
+
179
+ Get redeemable indexes and balances for the specified address.
180
+
181
+ **Parameters:**
182
+ - `condition_id` (str): Condition ID
183
+ - `owner` (str): Wallet address
184
+
185
+ **Returns:**
186
+ - `list[tuple]`: List of tuples containing (index, balance), balance is in USDC units
187
+
188
+ ##### `redeem(condition_id: str, neg_risk: bool = False, redeem_amounts: list[int] | None = None)`
189
+
190
+ Execute redeem operation.
191
+
192
+ **Parameters:**
193
+ - `condition_id` (str): Condition ID
194
+ - `neg_risk` (bool): Whether it's a negative risk redeem, defaults to `False`
195
+ - `redeem_amounts` (list[int] | None): Amount list for negative risk redeem, must contain 2 elements
196
+
197
+ **Returns:**
198
+ - `dict`: Transaction result containing transaction status and related information
199
+
200
+ **Examples:**
201
+
202
+ ```python
203
+ # Standard CTF redeem
204
+ result = service.redeem(condition_id="0x...")
205
+
206
+ # Negative risk redeem
207
+ result = service.redeem(
208
+ condition_id="0x...",
209
+ neg_risk=True,
210
+ redeem_amounts=[1000000, 2000000] # Amounts in smallest unit (6 decimal places)
211
+ )
212
+ ```
213
+
214
+ ## Project Structure
215
+
216
+ ```
217
+ poly_web3/
218
+ β”œβ”€β”€ __init__.py # Main entry point, exports PolyWeb3Service
219
+ β”œβ”€β”€ const.py # Constant definitions (contract addresses, ABIs, etc.)
220
+ β”œβ”€β”€ schema.py # Data models (WalletType, etc.)
221
+ β”œβ”€β”€ signature/ # Signature-related modules
222
+ β”‚ β”œβ”€β”€ build.py # Proxy wallet derivation and struct hashing
223
+ β”‚ β”œβ”€β”€ hash_message.py # Message hashing
224
+ β”‚ └── secp256k1.py # secp256k1 signing
225
+ └── web3_service/ # Web3 service implementations
226
+ β”œβ”€β”€ base.py # Base service class
227
+ β”œβ”€β”€ proxy_service.py # Proxy wallet service (βœ… Implemented)
228
+ β”œβ”€β”€ eoa_service.py # EOA wallet service (🚧 Under development)
229
+ └── safe_service.py # Safe wallet service (🚧 Under development)
230
+ ```
231
+
232
+ ## Notes
233
+
234
+ 1. **Environment Variable Security**: Make sure `.env` file is added to `.gitignore`, do not commit sensitive information to the code repository
235
+ 2. **Network Support**: Currently mainly supports Polygon mainnet (chain_id: 137), Amoy testnet may have limited functionality
236
+ 3. **Wallet Type**: **Currently only Proxy wallet is supported** (signature_type: 1), Safe and EOA wallet redeem functionality is under development
237
+ 4. **Gas Fees**: Transactions are executed through Relayer, gas fees are handled by the Relayer
238
+
239
+ ## Development
240
+
241
+ ### Install Development Dependencies
242
+
243
+ ```bash
244
+ uv pip install -e ".[dev]"
245
+ ```
246
+
247
+ ### Run Examples
248
+
249
+ ```bash
250
+ python examples/example_redeem.py
251
+ ```
252
+
253
+ ### Contributing
254
+
255
+ We welcome all forms of contributions! If you'd like to:
256
+
257
+ - Implement Safe or EOA wallet support
258
+ - Fix bugs or improve existing functionality
259
+ - Add new features or improve documentation
260
+ - Make suggestions or report issues
261
+
262
+ Please feel free to submit an Issue or Pull Request. Your contributions will help make this project better!
263
+
264
+ ## License
265
+
266
+ MIT
267
+
268
+ ## Author
269
+
270
+ PinBar
271
+
272
+ ## Related Links
273
+
274
+ - [Polymarket](https://polymarket.com/)
275
+ - [Polygon Network](https://polygon.technology/)
@@ -0,0 +1,248 @@
1
+ # poly-web3
2
+
3
+ Python SDK for Polymarket Proxy wallet redeem operations. Supports executing Conditional Token Fund (CTF) redeem operations on Polymarket through proxy wallets.
4
+
5
+ [English](README.md) | [δΈ­ζ–‡](README.zh.md)
6
+
7
+ ## About the Project
8
+
9
+ 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.
10
+
11
+ **Important Notes:**
12
+ - This project **only implements the official redeem functionality**, focusing on Conditional Token Fund (CTF) redeem operations
13
+ - Other features (such as trading, order placement, etc.) are not within the scope of this project
14
+
15
+ **Current Status:**
16
+ - βœ… **Proxy Wallet** - Fully supported for redeem functionality
17
+ - 🚧 **Safe Wallet** - Under development
18
+ - 🚧 **EOA Wallet** - Under development
19
+
20
+ 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.
21
+
22
+ ## Features
23
+
24
+ - βœ… Support for Polymarket Proxy wallet redeem operations (currently only Proxy wallet is supported)
25
+ - βœ… Check if conditions are resolved
26
+ - βœ… Get redeemable indexes and balances
27
+ - βœ… Support for standard CTF redeem and negative risk (neg_risk) redeem
28
+ - βœ… Automatic transaction execution through Relayer service
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install poly-web3
34
+ ```
35
+
36
+ Or using uv:
37
+
38
+ ```bash
39
+ uv add poly-web3
40
+ ```
41
+
42
+ ## Requirements
43
+
44
+ - Python >= 3.11
45
+
46
+ ## Dependencies
47
+
48
+ - `py-clob-client >= 0.25.0` - Polymarket CLOB client
49
+ - `py-builder-relayer-client >= 0.0.1` - Builder Relayer client
50
+ - `web3 == 6.8` - Web3.py library
51
+ - `eth-utils == 5.3.1` - Ethereum utilities library
52
+
53
+ ## Quick Start
54
+
55
+ ### Basic Usage - Execute Redeem
56
+
57
+ ```python
58
+ import os
59
+ import dotenv
60
+ from py_builder_relayer_client.client import RelayClient
61
+ from py_builder_signing_sdk.config import BuilderConfig
62
+ from py_builder_signing_sdk.sdk_types import BuilderApiKeyCreds
63
+ from py_clob_client.client import ClobClient
64
+ from poly_web3 import RELAYER_URL, PolyWeb3Service
65
+
66
+ dotenv.load_dotenv()
67
+
68
+ # Initialize ClobClient
69
+ host = "https://clob.polymarket.com"
70
+ chain_id = 137 # Polygon mainnet
71
+ client = ClobClient(
72
+ host,
73
+ key=os.getenv("POLY_API_KEY"),
74
+ chain_id=chain_id,
75
+ signature_type=1, # Proxy wallet type
76
+ funder=os.getenv("POLYMARKET_PROXY_ADDRESS"),
77
+ )
78
+
79
+ client.set_api_creds(client.create_or_derive_api_creds())
80
+
81
+ # Initialize RelayerClient
82
+ relayer_client = RelayClient(
83
+ RELAYER_URL,
84
+ chain_id,
85
+ os.getenv("POLY_API_KEY"),
86
+ BuilderConfig(
87
+ local_builder_creds=BuilderApiKeyCreds(
88
+ key=os.getenv("BUILDER_KEY"),
89
+ secret=os.getenv("BUILDER_SECRET"),
90
+ passphrase=os.getenv("BUILDER_PASSPHRASE"),
91
+ )
92
+ ),
93
+ )
94
+
95
+ # Create service instance
96
+ service = PolyWeb3Service(clob_client=client, relayer_client=relayer_client)
97
+
98
+ # Execute redeem operation
99
+ condition_id = "0xc3df016175463c44f9c9f98bddaa3bf3daaabb14b069fb7869621cffe73ddd1c"
100
+ redeem_result = service.redeem(condition_id=condition_id)
101
+ print(f"Redeem result: {redeem_result}")
102
+ ```
103
+
104
+ ### Optional - Query Operations
105
+
106
+ Before executing redeem, you can optionally check the condition status and query redeemable balances:
107
+
108
+ ```python
109
+ # Check if condition is resolved
110
+ condition_id = "0xc3df016175463c44f9c9f98bddaa3bf3daaabb14b069fb7869621cffe73ddd1c"
111
+ can_redeem = service.is_condition_resolved(condition_id)
112
+
113
+ # Get redeemable indexes and balances
114
+ redeem_balance = service.get_redeemable_index_and_balance(
115
+ condition_id, owner=client.builder.funder
116
+ )
117
+
118
+ print(f"Can redeem: {can_redeem}")
119
+ print(f"Redeemable balance: {redeem_balance}")
120
+ ```
121
+
122
+ ## API Documentation
123
+
124
+ ### PolyWeb3Service
125
+
126
+ The main service class that automatically selects the appropriate service implementation based on wallet type.
127
+
128
+ #### Methods
129
+
130
+ ##### `is_condition_resolved(condition_id: str) -> bool`
131
+
132
+ Check if the specified condition is resolved.
133
+
134
+ **Parameters:**
135
+ - `condition_id` (str): Condition ID (32-byte hexadecimal string)
136
+
137
+ **Returns:**
138
+ - `bool`: Returns `True` if the condition is resolved, otherwise `False`
139
+
140
+ ##### `get_winning_indexes(condition_id: str) -> list[int]`
141
+
142
+ Get the list of winning indexes.
143
+
144
+ **Parameters:**
145
+ - `condition_id` (str): Condition ID
146
+
147
+ **Returns:**
148
+ - `list[int]`: List of winning indexes
149
+
150
+ ##### `get_redeemable_index_and_balance(condition_id: str, owner: str) -> list[tuple]`
151
+
152
+ Get redeemable indexes and balances for the specified address.
153
+
154
+ **Parameters:**
155
+ - `condition_id` (str): Condition ID
156
+ - `owner` (str): Wallet address
157
+
158
+ **Returns:**
159
+ - `list[tuple]`: List of tuples containing (index, balance), balance is in USDC units
160
+
161
+ ##### `redeem(condition_id: str, neg_risk: bool = False, redeem_amounts: list[int] | None = None)`
162
+
163
+ Execute redeem operation.
164
+
165
+ **Parameters:**
166
+ - `condition_id` (str): Condition ID
167
+ - `neg_risk` (bool): Whether it's a negative risk redeem, defaults to `False`
168
+ - `redeem_amounts` (list[int] | None): Amount list for negative risk redeem, must contain 2 elements
169
+
170
+ **Returns:**
171
+ - `dict`: Transaction result containing transaction status and related information
172
+
173
+ **Examples:**
174
+
175
+ ```python
176
+ # Standard CTF redeem
177
+ result = service.redeem(condition_id="0x...")
178
+
179
+ # Negative risk redeem
180
+ result = service.redeem(
181
+ condition_id="0x...",
182
+ neg_risk=True,
183
+ redeem_amounts=[1000000, 2000000] # Amounts in smallest unit (6 decimal places)
184
+ )
185
+ ```
186
+
187
+ ## Project Structure
188
+
189
+ ```
190
+ poly_web3/
191
+ β”œβ”€β”€ __init__.py # Main entry point, exports PolyWeb3Service
192
+ β”œβ”€β”€ const.py # Constant definitions (contract addresses, ABIs, etc.)
193
+ β”œβ”€β”€ schema.py # Data models (WalletType, etc.)
194
+ β”œβ”€β”€ signature/ # Signature-related modules
195
+ β”‚ β”œβ”€β”€ build.py # Proxy wallet derivation and struct hashing
196
+ β”‚ β”œβ”€β”€ hash_message.py # Message hashing
197
+ β”‚ └── secp256k1.py # secp256k1 signing
198
+ └── web3_service/ # Web3 service implementations
199
+ β”œβ”€β”€ base.py # Base service class
200
+ β”œβ”€β”€ proxy_service.py # Proxy wallet service (βœ… Implemented)
201
+ β”œβ”€β”€ eoa_service.py # EOA wallet service (🚧 Under development)
202
+ └── safe_service.py # Safe wallet service (🚧 Under development)
203
+ ```
204
+
205
+ ## Notes
206
+
207
+ 1. **Environment Variable Security**: Make sure `.env` file is added to `.gitignore`, do not commit sensitive information to the code repository
208
+ 2. **Network Support**: Currently mainly supports Polygon mainnet (chain_id: 137), Amoy testnet may have limited functionality
209
+ 3. **Wallet Type**: **Currently only Proxy wallet is supported** (signature_type: 1), Safe and EOA wallet redeem functionality is under development
210
+ 4. **Gas Fees**: Transactions are executed through Relayer, gas fees are handled by the Relayer
211
+
212
+ ## Development
213
+
214
+ ### Install Development Dependencies
215
+
216
+ ```bash
217
+ uv pip install -e ".[dev]"
218
+ ```
219
+
220
+ ### Run Examples
221
+
222
+ ```bash
223
+ python examples/example_redeem.py
224
+ ```
225
+
226
+ ### Contributing
227
+
228
+ We welcome all forms of contributions! If you'd like to:
229
+
230
+ - Implement Safe or EOA wallet support
231
+ - Fix bugs or improve existing functionality
232
+ - Add new features or improve documentation
233
+ - Make suggestions or report issues
234
+
235
+ Please feel free to submit an Issue or Pull Request. Your contributions will help make this project better!
236
+
237
+ ## License
238
+
239
+ MIT
240
+
241
+ ## Author
242
+
243
+ PinBar
244
+
245
+ ## Related Links
246
+
247
+ - [Polymarket](https://polymarket.com/)
248
+ - [Polygon Network](https://polygon.technology/)
@@ -0,0 +1,54 @@
1
+ # -*- coding = utf-8 -*-
2
+ # @Time: 2025-12-27 17:01:20
3
+ # @Author: PinBar
4
+ # @Site:
5
+ # @File: example_redeem.py
6
+ # @Software: PyCharm
7
+ import os
8
+
9
+ import dotenv
10
+ from py_builder_relayer_client.client import RelayClient
11
+ from py_builder_signing_sdk.config import BuilderConfig
12
+ from py_builder_signing_sdk.sdk_types import BuilderApiKeyCreds
13
+
14
+ from py_clob_client.client import ClobClient
15
+
16
+ from poly_web3 import RELAYER_URL, PolyWeb3Service
17
+
18
+ dotenv.load_dotenv()
19
+
20
+ if __name__ == "__main__":
21
+ host: str = "https://clob.polymarket.com"
22
+ chain_id: int = 137 # No need to adjust this
23
+ client = ClobClient(
24
+ host,
25
+ key=os.getenv("POLY_API_KEY"),
26
+ chain_id=chain_id,
27
+ signature_type=1,
28
+ funder=os.getenv("POLYMARKET_PROXY_ADDRESS"),
29
+ )
30
+ creds = client.create_or_derive_api_creds()
31
+ client.set_api_creds(creds)
32
+ relayer_client = RelayClient(
33
+ RELAYER_URL,
34
+ chain_id,
35
+ os.getenv("POLY_API_KEY"),
36
+ BuilderConfig(
37
+ local_builder_creds=BuilderApiKeyCreds(
38
+ key=os.getenv("BUILDER_KEY"),
39
+ secret=os.getenv("BUILDER_SECRET"),
40
+ passphrase=os.getenv("BUILDER_PASSPHRASE"),
41
+ )
42
+ ),
43
+ )
44
+ condition_id = "0xc3df016175463c44f9c9f98bddaa3bf3daaabb14b069fb7869621cffe73ddd1c"
45
+ service = PolyWeb3Service(clob_client=client, relayer_client=relayer_client)
46
+ redeem = service.redeem(condition_id=condition_id)
47
+ print(redeem)
48
+
49
+ # Optional - Query operations (ε―ι€‰ζ“δ½œοΌŒη”¨δΊŽζŸ₯θ―’)
50
+ # can_redeem = service.is_condition_resolved(condition_id)
51
+ # redeem_balance = service.get_redeemable_index_and_balance(
52
+ # condition_id, owner=client.builder.funder
53
+ # )
54
+ # print(can_redeem, redeem_balance)
@@ -0,0 +1,31 @@
1
+ # -*- coding = utf-8 -*-
2
+ # @Time: 2025/12/19 15:24
3
+ # @Author: PinBar
4
+ # @Site:
5
+ # @File: __init__.py.py
6
+ # @Software: PyCharm
7
+ from typing import Union
8
+
9
+ from py_clob_client.client import ClobClient
10
+ from py_builder_relayer_client.client import RelayClient
11
+
12
+ from poly_web3.const import RELAYER_URL
13
+ from poly_web3.web3_service.base import BaseWeb3Service
14
+ from poly_web3.schema import WalletType
15
+ from poly_web3.web3_service import SafeWeb3Service, EOAWeb3Service, ProxyWeb3Service
16
+
17
+
18
+ def PolyWeb3Service(
19
+ clob_client: ClobClient, relayer_client: RelayClient = None
20
+ ) -> Union[SafeWeb3Service, EOAWeb3Service, ProxyWeb3Service]: # noqa
21
+ services = {
22
+ WalletType.EOA: EOAWeb3Service,
23
+ WalletType.PROXY: ProxyWeb3Service,
24
+ WalletType.SAFE: SafeWeb3Service,
25
+ }
26
+
27
+ wallet_type = WalletType.get_with_code(clob_client.builder.sig_type)
28
+ if service := services.get(wallet_type):
29
+ return service(clob_client, relayer_client)
30
+ else:
31
+ raise Exception(f"Unknown wallet type: {wallet_type}")