poly-web3 0.0.2__py3-none-any.whl → 0.0.3__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 +63 -63
- poly_web3/__init__.py +33 -33
- poly_web3/const.py +171 -171
- poly_web3/log.py +18 -0
- 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 +182 -181
- poly_web3/web3_service/eoa_service.py +17 -17
- poly_web3/web3_service/proxy_service.py +166 -163
- poly_web3/web3_service/safe_service.py +17 -17
- {poly_web3-0.0.2.dist-info → poly_web3-0.0.3.dist-info}/METADATA +302 -302
- poly_web3-0.0.3.dist-info/RECORD +18 -0
- poly_web3-0.0.2.dist-info/RECORD +0 -17
- {poly_web3-0.0.2.dist-info → poly_web3-0.0.3.dist-info}/WHEEL +0 -0
- {poly_web3-0.0.2.dist-info → poly_web3-0.0.3.dist-info}/top_level.txt +0 -0
examples/example_redeem.py
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
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 = "0x38124532c68bf16aa5800433118463acdbf09152237b45bb9e11bd4b73e0d1c4"
|
|
45
|
-
service = PolyWeb3Service(
|
|
46
|
-
clob_client=client,
|
|
47
|
-
relayer_client=relayer_client,
|
|
48
|
-
rpc_url="https://polygon-bor.publicnode.com",
|
|
49
|
-
)
|
|
50
|
-
# Redeem by condition_id
|
|
51
|
-
redeem = service.redeem(condition_id=condition_id)
|
|
52
|
-
print(redeem)
|
|
53
|
-
|
|
54
|
-
# Redeem all positions that are currently redeemable (returns list or None)
|
|
55
|
-
redeem_all = service.redeem_all()
|
|
56
|
-
print(redeem_all)
|
|
57
|
-
|
|
58
|
-
# Optional - Query operations (可选操作,用于查询)
|
|
59
|
-
# can_redeem = service.is_condition_resolved(condition_id)
|
|
60
|
-
# redeem_balance = service.get_redeemable_index_and_balance(
|
|
61
|
-
# condition_id, owner=client.builder.funder
|
|
62
|
-
# )
|
|
63
|
-
# print(can_redeem, redeem_balance)
|
|
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 = "0x38124532c68bf16aa5800433118463acdbf09152237b45bb9e11bd4b73e0d1c4"
|
|
45
|
+
service = PolyWeb3Service(
|
|
46
|
+
clob_client=client,
|
|
47
|
+
relayer_client=relayer_client,
|
|
48
|
+
rpc_url="https://polygon-bor.publicnode.com",
|
|
49
|
+
)
|
|
50
|
+
# Redeem by condition_id
|
|
51
|
+
redeem = service.redeem(condition_id=condition_id)
|
|
52
|
+
print(redeem)
|
|
53
|
+
|
|
54
|
+
# Redeem all positions that are currently redeemable (returns list or None)
|
|
55
|
+
redeem_all = service.redeem_all()
|
|
56
|
+
print(redeem_all)
|
|
57
|
+
|
|
58
|
+
# Optional - Query operations (可选操作,用于查询)
|
|
59
|
+
# can_redeem = service.is_condition_resolved(condition_id)
|
|
60
|
+
# redeem_balance = service.get_redeemable_index_and_balance(
|
|
61
|
+
# condition_id, owner=client.builder.funder
|
|
62
|
+
# )
|
|
63
|
+
# print(can_redeem, redeem_balance)
|
poly_web3/__init__.py
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
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,
|
|
20
|
-
relayer_client: RelayClient = None,
|
|
21
|
-
rpc_url: str | None = None,
|
|
22
|
-
) -> Union[SafeWeb3Service, EOAWeb3Service, ProxyWeb3Service]: # noqa
|
|
23
|
-
services = {
|
|
24
|
-
WalletType.EOA: EOAWeb3Service,
|
|
25
|
-
WalletType.PROXY: ProxyWeb3Service,
|
|
26
|
-
WalletType.SAFE: SafeWeb3Service,
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
wallet_type = WalletType.get_with_code(clob_client.builder.sig_type)
|
|
30
|
-
if service := services.get(wallet_type):
|
|
31
|
-
return service(clob_client, relayer_client, rpc_url=rpc_url)
|
|
32
|
-
else:
|
|
33
|
-
raise Exception(f"Unknown wallet type: {wallet_type}")
|
|
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,
|
|
20
|
+
relayer_client: RelayClient = None,
|
|
21
|
+
rpc_url: str | None = None,
|
|
22
|
+
) -> Union[SafeWeb3Service, EOAWeb3Service, ProxyWeb3Service]: # noqa
|
|
23
|
+
services = {
|
|
24
|
+
WalletType.EOA: EOAWeb3Service,
|
|
25
|
+
WalletType.PROXY: ProxyWeb3Service,
|
|
26
|
+
WalletType.SAFE: SafeWeb3Service,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
wallet_type = WalletType.get_with_code(clob_client.builder.sig_type)
|
|
30
|
+
if service := services.get(wallet_type):
|
|
31
|
+
return service(clob_client, relayer_client, rpc_url=rpc_url)
|
|
32
|
+
else:
|
|
33
|
+
raise Exception(f"Unknown wallet type: {wallet_type}")
|
poly_web3/const.py
CHANGED
|
@@ -1,171 +1,171 @@
|
|
|
1
|
-
# -*- coding = utf-8 -*-
|
|
2
|
-
# @Time: 2025/12/19 15:29
|
|
3
|
-
# @Author: PinBar
|
|
4
|
-
# @Site:
|
|
5
|
-
# @File: const.py
|
|
6
|
-
# @Software: PyCharm
|
|
7
|
-
from web3 import Web3
|
|
8
|
-
|
|
9
|
-
GET_NONCE = "/nonce"
|
|
10
|
-
GET_RELAY_PAYLOAD = "/relay-payload"
|
|
11
|
-
GET_TRANSACTION = "/transaction"
|
|
12
|
-
GET_TRANSACTIONS = "/transactions"
|
|
13
|
-
SUBMIT_TRANSACTION = "/submit"
|
|
14
|
-
GET_DEPLOYED = "/deployed"
|
|
15
|
-
RPC_URL = "https://polygon-bor.publicnode.com" # "https://polygon-rpc.com"
|
|
16
|
-
RELAYER_URL = "https://relayer-v2.polymarket.com"
|
|
17
|
-
|
|
18
|
-
STATE_NEW = ("STATE_NEW",)
|
|
19
|
-
STATE_EXECUTED = "STATE_EXECUTED"
|
|
20
|
-
STATE_MINED = "STATE_MINED"
|
|
21
|
-
STATE_INVALID = "STATE_INVALID"
|
|
22
|
-
STATE_CONFIRMED = "STATE_CONFIRMED"
|
|
23
|
-
STATE_FAILED = "STATE_FAILED"
|
|
24
|
-
|
|
25
|
-
# address
|
|
26
|
-
CTF_ADDRESS = Web3.to_checksum_address("0x4d97dcd97ec945f40cf65f87097ace5ea0476045")
|
|
27
|
-
USDC_POLYGON = Web3.to_checksum_address("0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174")
|
|
28
|
-
NEG_RISK_ADAPTER_ADDRESS = Web3.to_checksum_address(
|
|
29
|
-
"0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296"
|
|
30
|
-
)
|
|
31
|
-
ZERO_BYTES32 = "0x" + "00" * 32
|
|
32
|
-
proxy_factory_address = Web3.to_checksum_address(
|
|
33
|
-
"0xaB45c5A4B0c941a2F231C04C3f49182e1A254052"
|
|
34
|
-
)
|
|
35
|
-
SAFE_INIT_CODE_HASH = (
|
|
36
|
-
"0x2bce2127ff07fb632d16c8347c4ebf501f4841168bed00d9e6ef715ddb6fcecf"
|
|
37
|
-
)
|
|
38
|
-
PROXY_INIT_CODE_HASH = (
|
|
39
|
-
"0xd21df8dc65880a8606f09fe0ce3df9b8869287ab0b058be05aa9e8af6330a00b"
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
AMOY = {
|
|
43
|
-
"ProxyContracts": {
|
|
44
|
-
# Proxy factory unsupported on Amoy testnet
|
|
45
|
-
"RelayHub": "",
|
|
46
|
-
"ProxyFactory": "",
|
|
47
|
-
},
|
|
48
|
-
"SafeContracts": {
|
|
49
|
-
"SafeFactory": "0xaacFeEa03eb1561C4e67d661e40682Bd20E3541b",
|
|
50
|
-
"SafeMultisend": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761",
|
|
51
|
-
},
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
POL = {
|
|
55
|
-
"ProxyContracts": {
|
|
56
|
-
"ProxyFactory": "0xaB45c5A4B0c941a2F231C04C3f49182e1A254052",
|
|
57
|
-
"RelayHub": "0xD216153c06E857cD7f72665E0aF1d7D82172F494",
|
|
58
|
-
},
|
|
59
|
-
"SafeContracts": {
|
|
60
|
-
"SafeFactory": "0xaacFeEa03eb1561C4e67d661e40682Bd20E3541b",
|
|
61
|
-
"SafeMultisend": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761",
|
|
62
|
-
},
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
# abi
|
|
66
|
-
CTF_ABI_REDEEM = [
|
|
67
|
-
{
|
|
68
|
-
"name": "redeemPositions",
|
|
69
|
-
"type": "function",
|
|
70
|
-
"stateMutability": "nonpayable",
|
|
71
|
-
"inputs": [
|
|
72
|
-
{"name": "collateralToken", "type": "address"},
|
|
73
|
-
{"name": "parentCollectionId", "type": "bytes32"},
|
|
74
|
-
{"name": "conditionId", "type": "bytes32"},
|
|
75
|
-
{"name": "indexSets", "type": "uint256[]"},
|
|
76
|
-
],
|
|
77
|
-
"outputs": [],
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
|
|
81
|
-
NEG_RISK_ADAPTER_ABI_REDEEM = [
|
|
82
|
-
{
|
|
83
|
-
"name": "redeemPositions",
|
|
84
|
-
"type": "function",
|
|
85
|
-
"stateMutability": "nonpayable",
|
|
86
|
-
"inputs": [
|
|
87
|
-
{"name": "_conditionId", "type": "bytes32"},
|
|
88
|
-
{"name": "_amounts", "type": "uint256[]"},
|
|
89
|
-
],
|
|
90
|
-
"outputs": [],
|
|
91
|
-
}
|
|
92
|
-
]
|
|
93
|
-
|
|
94
|
-
proxy_wallet_factory_abi = [
|
|
95
|
-
{
|
|
96
|
-
"inputs": [
|
|
97
|
-
{
|
|
98
|
-
"components": [
|
|
99
|
-
{"name": "typeCode", "type": "uint8"},
|
|
100
|
-
{"name": "to", "type": "address"},
|
|
101
|
-
{"name": "value", "type": "uint256"},
|
|
102
|
-
{"name": "data", "type": "bytes"},
|
|
103
|
-
],
|
|
104
|
-
"name": "calls",
|
|
105
|
-
"type": "tuple[]",
|
|
106
|
-
}
|
|
107
|
-
],
|
|
108
|
-
"name": "proxy",
|
|
109
|
-
"outputs": [{"name": "returnValues", "type": "bytes[]"}],
|
|
110
|
-
"stateMutability": "payable",
|
|
111
|
-
"type": "function",
|
|
112
|
-
}
|
|
113
|
-
]
|
|
114
|
-
|
|
115
|
-
CTF_ABI_PAYOUT = [
|
|
116
|
-
{
|
|
117
|
-
"name": "payoutDenominator",
|
|
118
|
-
"type": "function",
|
|
119
|
-
"stateMutability": "view",
|
|
120
|
-
"inputs": [{"name": "conditionId", "type": "bytes32"}],
|
|
121
|
-
"outputs": [{"type": "uint256"}],
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
"name": "payoutNumerators",
|
|
125
|
-
"type": "function",
|
|
126
|
-
"stateMutability": "view",
|
|
127
|
-
"inputs": [
|
|
128
|
-
{"name": "conditionId", "type": "bytes32"},
|
|
129
|
-
{"name": "index", "type": "uint256"},
|
|
130
|
-
],
|
|
131
|
-
"outputs": [{"type": "uint256"}],
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
"name": "getOutcomeSlotCount",
|
|
135
|
-
"type": "function",
|
|
136
|
-
"stateMutability": "view",
|
|
137
|
-
"inputs": [{"name": "conditionId", "type": "bytes32"}],
|
|
138
|
-
"outputs": [{"type": "uint256"}],
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
"name": "getCollectionId",
|
|
142
|
-
"type": "function",
|
|
143
|
-
"stateMutability": "view",
|
|
144
|
-
"inputs": [
|
|
145
|
-
{"name": "parentCollectionId", "type": "bytes32"},
|
|
146
|
-
{"name": "conditionId", "type": "bytes32"},
|
|
147
|
-
{"name": "indexSet", "type": "uint256"},
|
|
148
|
-
],
|
|
149
|
-
"outputs": [{"type": "bytes32"}],
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
"name": "getPositionId",
|
|
153
|
-
"type": "function",
|
|
154
|
-
"stateMutability": "view",
|
|
155
|
-
"inputs": [
|
|
156
|
-
{"name": "collateralToken", "type": "address"},
|
|
157
|
-
{"name": "collectionId", "type": "bytes32"},
|
|
158
|
-
],
|
|
159
|
-
"outputs": [{"type": "uint256"}],
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
"name": "balanceOf",
|
|
163
|
-
"type": "function",
|
|
164
|
-
"stateMutability": "view",
|
|
165
|
-
"inputs": [
|
|
166
|
-
{"name": "owner", "type": "address"},
|
|
167
|
-
{"name": "id", "type": "uint256"},
|
|
168
|
-
],
|
|
169
|
-
"outputs": [{"type": "uint256"}],
|
|
170
|
-
},
|
|
171
|
-
]
|
|
1
|
+
# -*- coding = utf-8 -*-
|
|
2
|
+
# @Time: 2025/12/19 15:29
|
|
3
|
+
# @Author: PinBar
|
|
4
|
+
# @Site:
|
|
5
|
+
# @File: const.py
|
|
6
|
+
# @Software: PyCharm
|
|
7
|
+
from web3 import Web3
|
|
8
|
+
|
|
9
|
+
GET_NONCE = "/nonce"
|
|
10
|
+
GET_RELAY_PAYLOAD = "/relay-payload"
|
|
11
|
+
GET_TRANSACTION = "/transaction"
|
|
12
|
+
GET_TRANSACTIONS = "/transactions"
|
|
13
|
+
SUBMIT_TRANSACTION = "/submit"
|
|
14
|
+
GET_DEPLOYED = "/deployed"
|
|
15
|
+
RPC_URL = "https://polygon-bor.publicnode.com" # "https://polygon-rpc.com"
|
|
16
|
+
RELAYER_URL = "https://relayer-v2.polymarket.com"
|
|
17
|
+
|
|
18
|
+
STATE_NEW = ("STATE_NEW",)
|
|
19
|
+
STATE_EXECUTED = "STATE_EXECUTED"
|
|
20
|
+
STATE_MINED = "STATE_MINED"
|
|
21
|
+
STATE_INVALID = "STATE_INVALID"
|
|
22
|
+
STATE_CONFIRMED = "STATE_CONFIRMED"
|
|
23
|
+
STATE_FAILED = "STATE_FAILED"
|
|
24
|
+
|
|
25
|
+
# address
|
|
26
|
+
CTF_ADDRESS = Web3.to_checksum_address("0x4d97dcd97ec945f40cf65f87097ace5ea0476045")
|
|
27
|
+
USDC_POLYGON = Web3.to_checksum_address("0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174")
|
|
28
|
+
NEG_RISK_ADAPTER_ADDRESS = Web3.to_checksum_address(
|
|
29
|
+
"0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296"
|
|
30
|
+
)
|
|
31
|
+
ZERO_BYTES32 = "0x" + "00" * 32
|
|
32
|
+
proxy_factory_address = Web3.to_checksum_address(
|
|
33
|
+
"0xaB45c5A4B0c941a2F231C04C3f49182e1A254052"
|
|
34
|
+
)
|
|
35
|
+
SAFE_INIT_CODE_HASH = (
|
|
36
|
+
"0x2bce2127ff07fb632d16c8347c4ebf501f4841168bed00d9e6ef715ddb6fcecf"
|
|
37
|
+
)
|
|
38
|
+
PROXY_INIT_CODE_HASH = (
|
|
39
|
+
"0xd21df8dc65880a8606f09fe0ce3df9b8869287ab0b058be05aa9e8af6330a00b"
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
AMOY = {
|
|
43
|
+
"ProxyContracts": {
|
|
44
|
+
# Proxy factory unsupported on Amoy testnet
|
|
45
|
+
"RelayHub": "",
|
|
46
|
+
"ProxyFactory": "",
|
|
47
|
+
},
|
|
48
|
+
"SafeContracts": {
|
|
49
|
+
"SafeFactory": "0xaacFeEa03eb1561C4e67d661e40682Bd20E3541b",
|
|
50
|
+
"SafeMultisend": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761",
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
POL = {
|
|
55
|
+
"ProxyContracts": {
|
|
56
|
+
"ProxyFactory": "0xaB45c5A4B0c941a2F231C04C3f49182e1A254052",
|
|
57
|
+
"RelayHub": "0xD216153c06E857cD7f72665E0aF1d7D82172F494",
|
|
58
|
+
},
|
|
59
|
+
"SafeContracts": {
|
|
60
|
+
"SafeFactory": "0xaacFeEa03eb1561C4e67d661e40682Bd20E3541b",
|
|
61
|
+
"SafeMultisend": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761",
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# abi
|
|
66
|
+
CTF_ABI_REDEEM = [
|
|
67
|
+
{
|
|
68
|
+
"name": "redeemPositions",
|
|
69
|
+
"type": "function",
|
|
70
|
+
"stateMutability": "nonpayable",
|
|
71
|
+
"inputs": [
|
|
72
|
+
{"name": "collateralToken", "type": "address"},
|
|
73
|
+
{"name": "parentCollectionId", "type": "bytes32"},
|
|
74
|
+
{"name": "conditionId", "type": "bytes32"},
|
|
75
|
+
{"name": "indexSets", "type": "uint256[]"},
|
|
76
|
+
],
|
|
77
|
+
"outputs": [],
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
NEG_RISK_ADAPTER_ABI_REDEEM = [
|
|
82
|
+
{
|
|
83
|
+
"name": "redeemPositions",
|
|
84
|
+
"type": "function",
|
|
85
|
+
"stateMutability": "nonpayable",
|
|
86
|
+
"inputs": [
|
|
87
|
+
{"name": "_conditionId", "type": "bytes32"},
|
|
88
|
+
{"name": "_amounts", "type": "uint256[]"},
|
|
89
|
+
],
|
|
90
|
+
"outputs": [],
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
proxy_wallet_factory_abi = [
|
|
95
|
+
{
|
|
96
|
+
"inputs": [
|
|
97
|
+
{
|
|
98
|
+
"components": [
|
|
99
|
+
{"name": "typeCode", "type": "uint8"},
|
|
100
|
+
{"name": "to", "type": "address"},
|
|
101
|
+
{"name": "value", "type": "uint256"},
|
|
102
|
+
{"name": "data", "type": "bytes"},
|
|
103
|
+
],
|
|
104
|
+
"name": "calls",
|
|
105
|
+
"type": "tuple[]",
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
"name": "proxy",
|
|
109
|
+
"outputs": [{"name": "returnValues", "type": "bytes[]"}],
|
|
110
|
+
"stateMutability": "payable",
|
|
111
|
+
"type": "function",
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
|
|
115
|
+
CTF_ABI_PAYOUT = [
|
|
116
|
+
{
|
|
117
|
+
"name": "payoutDenominator",
|
|
118
|
+
"type": "function",
|
|
119
|
+
"stateMutability": "view",
|
|
120
|
+
"inputs": [{"name": "conditionId", "type": "bytes32"}],
|
|
121
|
+
"outputs": [{"type": "uint256"}],
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "payoutNumerators",
|
|
125
|
+
"type": "function",
|
|
126
|
+
"stateMutability": "view",
|
|
127
|
+
"inputs": [
|
|
128
|
+
{"name": "conditionId", "type": "bytes32"},
|
|
129
|
+
{"name": "index", "type": "uint256"},
|
|
130
|
+
],
|
|
131
|
+
"outputs": [{"type": "uint256"}],
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"name": "getOutcomeSlotCount",
|
|
135
|
+
"type": "function",
|
|
136
|
+
"stateMutability": "view",
|
|
137
|
+
"inputs": [{"name": "conditionId", "type": "bytes32"}],
|
|
138
|
+
"outputs": [{"type": "uint256"}],
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"name": "getCollectionId",
|
|
142
|
+
"type": "function",
|
|
143
|
+
"stateMutability": "view",
|
|
144
|
+
"inputs": [
|
|
145
|
+
{"name": "parentCollectionId", "type": "bytes32"},
|
|
146
|
+
{"name": "conditionId", "type": "bytes32"},
|
|
147
|
+
{"name": "indexSet", "type": "uint256"},
|
|
148
|
+
],
|
|
149
|
+
"outputs": [{"type": "bytes32"}],
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "getPositionId",
|
|
153
|
+
"type": "function",
|
|
154
|
+
"stateMutability": "view",
|
|
155
|
+
"inputs": [
|
|
156
|
+
{"name": "collateralToken", "type": "address"},
|
|
157
|
+
{"name": "collectionId", "type": "bytes32"},
|
|
158
|
+
],
|
|
159
|
+
"outputs": [{"type": "uint256"}],
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "balanceOf",
|
|
163
|
+
"type": "function",
|
|
164
|
+
"stateMutability": "view",
|
|
165
|
+
"inputs": [
|
|
166
|
+
{"name": "owner", "type": "address"},
|
|
167
|
+
{"name": "id", "type": "uint256"},
|
|
168
|
+
],
|
|
169
|
+
"outputs": [{"type": "uint256"}],
|
|
170
|
+
},
|
|
171
|
+
]
|
poly_web3/log.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# -*- coding = utf-8 -*-
|
|
2
|
+
# @Time: 2026-01-13 14:40:20
|
|
3
|
+
# @Author: PinBar
|
|
4
|
+
# @Site:
|
|
5
|
+
# @File: log.py
|
|
6
|
+
# @Software: PyCharm
|
|
7
|
+
import sys
|
|
8
|
+
import logging
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger("poly_web3")
|
|
11
|
+
handler = logging.StreamHandler(sys.stdout)
|
|
12
|
+
formatter = logging.Formatter(
|
|
13
|
+
'%(asctime)s | %(levelname)s | %(name)s | %(filename)s:%(lineno)d %(message)s',
|
|
14
|
+
datefmt='%Y-%m-%d %H:%M:%S'
|
|
15
|
+
)
|
|
16
|
+
handler.setFormatter(formatter)
|
|
17
|
+
logger.addHandler(handler)
|
|
18
|
+
logger.setLevel(logging.INFO)
|
poly_web3/schema.py
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
# -*- coding = utf-8 -*-
|
|
2
|
-
# @Time: 2025/12/19 15:31
|
|
3
|
-
# @Author: PinBar
|
|
4
|
-
# @Site:
|
|
5
|
-
# @File: model.py
|
|
6
|
-
# @Software: PyCharm
|
|
7
|
-
from enum import Enum
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class WalletType(str, Enum):
|
|
11
|
-
EOA = "EOA"
|
|
12
|
-
SAFE = "SAFE"
|
|
13
|
-
PROXY = "PROXY"
|
|
14
|
-
|
|
15
|
-
@classmethod
|
|
16
|
-
def get_with_code(cls, code: int):
|
|
17
|
-
if code == 0:
|
|
18
|
-
return cls.EOA
|
|
19
|
-
elif code == 1:
|
|
20
|
-
return cls.PROXY
|
|
21
|
-
elif code == 2:
|
|
22
|
-
return cls.SAFE
|
|
1
|
+
# -*- coding = utf-8 -*-
|
|
2
|
+
# @Time: 2025/12/19 15:31
|
|
3
|
+
# @Author: PinBar
|
|
4
|
+
# @Site:
|
|
5
|
+
# @File: model.py
|
|
6
|
+
# @Software: PyCharm
|
|
7
|
+
from enum import Enum
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class WalletType(str, Enum):
|
|
11
|
+
EOA = "EOA"
|
|
12
|
+
SAFE = "SAFE"
|
|
13
|
+
PROXY = "PROXY"
|
|
14
|
+
|
|
15
|
+
@classmethod
|
|
16
|
+
def get_with_code(cls, code: int):
|
|
17
|
+
if code == 0:
|
|
18
|
+
return cls.EOA
|
|
19
|
+
elif code == 1:
|
|
20
|
+
return cls.PROXY
|
|
21
|
+
elif code == 2:
|
|
22
|
+
return cls.SAFE
|
poly_web3/signature/__init__.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# -*- coding = utf-8 -*-
|
|
2
|
-
# @Time: 2025/12/21 19:42
|
|
3
|
-
# @Author: PinBar
|
|
4
|
-
# @Site:
|
|
5
|
-
# @File: __init__.py.py
|
|
6
|
-
# @Software: PyCharm
|
|
1
|
+
# -*- coding = utf-8 -*-
|
|
2
|
+
# @Time: 2025/12/21 19:42
|
|
3
|
+
# @Author: PinBar
|
|
4
|
+
# @Site:
|
|
5
|
+
# @File: __init__.py.py
|
|
6
|
+
# @Software: PyCharm
|