prediction-market-agent-tooling 0.61.1.dev489__py3-none-any.whl → 0.62.0__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.
- prediction_market_agent_tooling/deploy/agent.py +4 -5
- prediction_market_agent_tooling/deploy/betting_strategy.py +53 -69
- prediction_market_agent_tooling/gtypes.py +105 -27
- prediction_market_agent_tooling/jobs/jobs_models.py +5 -7
- prediction_market_agent_tooling/jobs/omen/omen_jobs.py +13 -17
- prediction_market_agent_tooling/markets/agent_market.py +96 -55
- prediction_market_agent_tooling/markets/blockchain_utils.py +2 -32
- prediction_market_agent_tooling/markets/data_models.py +40 -44
- prediction_market_agent_tooling/markets/manifold/api.py +2 -6
- prediction_market_agent_tooling/markets/manifold/data_models.py +33 -25
- prediction_market_agent_tooling/markets/manifold/manifold.py +13 -11
- prediction_market_agent_tooling/markets/market_fees.py +6 -2
- prediction_market_agent_tooling/markets/omen/data_models.py +66 -57
- prediction_market_agent_tooling/markets/omen/omen.py +222 -250
- prediction_market_agent_tooling/markets/omen/omen_contracts.py +32 -33
- prediction_market_agent_tooling/markets/omen/omen_resolving.py +7 -14
- prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +20 -14
- prediction_market_agent_tooling/markets/polymarket/data_models.py +3 -3
- prediction_market_agent_tooling/markets/polymarket/data_models_web.py +4 -4
- prediction_market_agent_tooling/markets/polymarket/polymarket.py +3 -5
- prediction_market_agent_tooling/markets/seer/data_models.py +92 -5
- prediction_market_agent_tooling/markets/seer/seer.py +93 -115
- prediction_market_agent_tooling/markets/seer/seer_contracts.py +11 -6
- prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py +18 -26
- prediction_market_agent_tooling/monitor/monitor.py +2 -2
- prediction_market_agent_tooling/tools/_generic_value.py +261 -0
- prediction_market_agent_tooling/tools/balances.py +14 -11
- prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py +12 -10
- prediction_market_agent_tooling/tools/betting_strategies/market_moving.py +31 -24
- prediction_market_agent_tooling/tools/betting_strategies/utils.py +3 -1
- prediction_market_agent_tooling/tools/contract.py +14 -10
- prediction_market_agent_tooling/tools/cow/cow_manager.py +3 -4
- prediction_market_agent_tooling/tools/cow/cow_order.py +51 -7
- prediction_market_agent_tooling/tools/langfuse_client_utils.py +13 -1
- prediction_market_agent_tooling/tools/omen/sell_positions.py +6 -3
- prediction_market_agent_tooling/tools/safe.py +5 -6
- prediction_market_agent_tooling/tools/tokens/auto_deposit.py +36 -27
- prediction_market_agent_tooling/tools/tokens/auto_withdraw.py +4 -25
- prediction_market_agent_tooling/tools/tokens/main_token.py +2 -2
- prediction_market_agent_tooling/tools/tokens/token_utils.py +46 -0
- prediction_market_agent_tooling/tools/tokens/usd.py +79 -0
- prediction_market_agent_tooling/tools/utils.py +14 -8
- prediction_market_agent_tooling/tools/web3_utils.py +24 -41
- {prediction_market_agent_tooling-0.61.1.dev489.dist-info → prediction_market_agent_tooling-0.62.0.dist-info}/METADATA +2 -1
- {prediction_market_agent_tooling-0.61.1.dev489.dist-info → prediction_market_agent_tooling-0.62.0.dist-info}/RECORD +48 -47
- prediction_market_agent_tooling/markets/seer/price_manager.py +0 -111
- prediction_market_agent_tooling/markets/seer/subgraph_data_models.py +0 -57
- {prediction_market_agent_tooling-0.61.1.dev489.dist-info → prediction_market_agent_tooling-0.62.0.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.61.1.dev489.dist-info → prediction_market_agent_tooling-0.62.0.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.61.1.dev489.dist-info → prediction_market_agent_tooling-0.62.0.dist-info}/entry_points.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
import binascii
|
2
2
|
import secrets
|
3
|
-
from typing import Any, Optional
|
3
|
+
from typing import Any, Optional
|
4
4
|
|
5
5
|
import base58
|
6
6
|
import tenacity
|
@@ -11,7 +11,7 @@ from safe_eth.eth import EthereumClient
|
|
11
11
|
from safe_eth.safe.safe import SafeV141
|
12
12
|
from web3 import Web3
|
13
13
|
from web3.constants import HASH_ZERO
|
14
|
-
from web3.types import AccessList, AccessListEntry, Nonce, TxParams, TxReceipt
|
14
|
+
from web3.types import AccessList, AccessListEntry, Nonce, TxParams, TxReceipt
|
15
15
|
|
16
16
|
from prediction_market_agent_tooling.gtypes import (
|
17
17
|
ABI,
|
@@ -23,12 +23,13 @@ from prediction_market_agent_tooling.gtypes import (
|
|
23
23
|
PrivateKey,
|
24
24
|
private_key_type,
|
25
25
|
xDai,
|
26
|
-
|
26
|
+
xDaiWei,
|
27
27
|
)
|
28
28
|
from prediction_market_agent_tooling.loggers import logger
|
29
|
+
from prediction_market_agent_tooling.tools._generic_value import _GenericValue
|
29
30
|
|
30
31
|
ONE_NONCE = Nonce(1)
|
31
|
-
ONE_XDAI =
|
32
|
+
ONE_XDAI = xDai(1)
|
32
33
|
ZERO_BYTES = HexBytes(HASH_ZERO)
|
33
34
|
NOT_REVERTED_ICASE_REGEX_PATTERN = "(?i)(?!.*reverted.*)"
|
34
35
|
|
@@ -42,17 +43,6 @@ def private_key_to_public_key(private_key: SecretStr) -> ChecksumAddress:
|
|
42
43
|
return verify_address(account.address)
|
43
44
|
|
44
45
|
|
45
|
-
def wei_to_xdai(wei: Wei) -> xDai:
|
46
|
-
return xDai(float(Web3.from_wei(wei, "ether")))
|
47
|
-
|
48
|
-
|
49
|
-
def xdai_to_wei(native: xDai) -> Wei:
|
50
|
-
return Web3.to_wei(native, "ether")
|
51
|
-
|
52
|
-
|
53
|
-
RemoveOrAddFractionAmountType = TypeVar("RemoveOrAddFractionAmountType", bound=int)
|
54
|
-
|
55
|
-
|
56
46
|
def verify_address(address: str) -> ChecksumAddress:
|
57
47
|
if not Web3.is_checksum_address(address):
|
58
48
|
raise ValueError(
|
@@ -61,26 +51,6 @@ def verify_address(address: str) -> ChecksumAddress:
|
|
61
51
|
return ChecksumAddress(HexAddress(HexStr(address)))
|
62
52
|
|
63
53
|
|
64
|
-
def remove_fraction(
|
65
|
-
amount: RemoveOrAddFractionAmountType, fraction: float
|
66
|
-
) -> RemoveOrAddFractionAmountType:
|
67
|
-
"""Removes the given fraction from the given integer-bounded amount and returns the value as an original type."""
|
68
|
-
if 0 <= fraction <= 1:
|
69
|
-
keep_percentage = 1 - fraction
|
70
|
-
return type(amount)(int(amount * keep_percentage))
|
71
|
-
raise ValueError(f"The given fraction {fraction!r} is not in the range [0, 1].")
|
72
|
-
|
73
|
-
|
74
|
-
def add_fraction(
|
75
|
-
amount: RemoveOrAddFractionAmountType, fraction: float
|
76
|
-
) -> RemoveOrAddFractionAmountType:
|
77
|
-
"""Adds the given fraction to the given integer-bounded amount and returns the value as an original type."""
|
78
|
-
if 0 <= fraction <= 1:
|
79
|
-
keep_percentage = 1 + fraction
|
80
|
-
return type(amount)(int(amount * keep_percentage))
|
81
|
-
raise ValueError(f"The given fraction {fraction!r} is not in the range [0, 1].")
|
82
|
-
|
83
|
-
|
84
54
|
def check_tx_receipt(receipt: TxReceipt) -> None:
|
85
55
|
if receipt["status"] != 1:
|
86
56
|
raise ValueError(
|
@@ -88,7 +58,20 @@ def check_tx_receipt(receipt: TxReceipt) -> None:
|
|
88
58
|
)
|
89
59
|
|
90
60
|
|
61
|
+
def unwrap_generic_value(value: Any) -> Any:
|
62
|
+
if value is None:
|
63
|
+
return None
|
64
|
+
if isinstance(value, _GenericValue):
|
65
|
+
return value.value
|
66
|
+
elif isinstance(value, list):
|
67
|
+
return [unwrap_generic_value(v) for v in value]
|
68
|
+
elif isinstance(value, dict):
|
69
|
+
return {k: unwrap_generic_value(v) for k, v in value.items()}
|
70
|
+
return value
|
71
|
+
|
72
|
+
|
91
73
|
def parse_function_params(params: Optional[list[Any] | dict[str, Any]]) -> list[Any]:
|
74
|
+
params = unwrap_generic_value(params)
|
92
75
|
if params is None:
|
93
76
|
return []
|
94
77
|
if isinstance(params, list):
|
@@ -172,8 +155,8 @@ def _prepare_tx_params(
|
|
172
155
|
# Don't retry on `reverted` messages, as they would always fail again.
|
173
156
|
# TODO: Check this, see https://github.com/gnosis/prediction-market-agent-tooling/issues/625.
|
174
157
|
# retry=tenacity.retry_if_exception_message(match=NOT_REVERTED_ICASE_REGEX_PATTERN),
|
175
|
-
wait=tenacity.wait_chain(*[tenacity.wait_fixed(n) for n in range(1,
|
176
|
-
stop=tenacity.stop_after_attempt(
|
158
|
+
wait=tenacity.wait_chain(*[tenacity.wait_fixed(n) for n in range(1, 6)]),
|
159
|
+
stop=tenacity.stop_after_attempt(5),
|
177
160
|
after=lambda x: logger.debug(
|
178
161
|
f"send_function_on_contract_tx failed, {x.attempt_number=}."
|
179
162
|
),
|
@@ -210,7 +193,7 @@ def send_function_on_contract_tx(
|
|
210
193
|
# Don't retry on `reverted` messages, as they would always fail again.
|
211
194
|
# TODO: Check this, see https://github.com/gnosis/prediction-market-agent-tooling/issues/625.
|
212
195
|
# retry=tenacity.retry_if_exception_message(match=NOT_REVERTED_ICASE_REGEX_PATTERN),
|
213
|
-
wait=tenacity.wait_chain(*[tenacity.wait_fixed(n) for n in range(1,
|
196
|
+
wait=tenacity.wait_chain(*[tenacity.wait_fixed(n) for n in range(1, 6)]),
|
214
197
|
stop=tenacity.stop_after_attempt(5),
|
215
198
|
after=lambda x: logger.debug(
|
216
199
|
f"send_function_on_contract_tx_using_safe failed, {x.attempt_number=}."
|
@@ -307,14 +290,14 @@ def send_xdai_to(
|
|
307
290
|
web3: Web3,
|
308
291
|
from_private_key: PrivateKey,
|
309
292
|
to_address: ChecksumAddress,
|
310
|
-
value:
|
293
|
+
value: xDaiWei,
|
311
294
|
data_text: Optional[str | bytes] = None,
|
312
295
|
tx_params: Optional[TxParams] = None,
|
313
296
|
timeout: int = 180,
|
314
297
|
) -> TxReceipt:
|
315
298
|
from_address = private_key_to_public_key(from_private_key)
|
316
299
|
|
317
|
-
tx_params_new: TxParams = {"value": value, "to": to_address}
|
300
|
+
tx_params_new: TxParams = {"value": value.value, "to": to_address}
|
318
301
|
if data_text is not None:
|
319
302
|
tx_params_new["data"] = (
|
320
303
|
Web3.to_bytes(text=data_text)
|
@@ -360,7 +343,7 @@ def byte32_to_ipfscidv0(hex: HexBytes) -> IPFSCIDVersion0:
|
|
360
343
|
|
361
344
|
|
362
345
|
@tenacity.retry(
|
363
|
-
wait=tenacity.wait_chain(*[tenacity.wait_fixed(n) for n in range(1,
|
346
|
+
wait=tenacity.wait_chain(*[tenacity.wait_fixed(n) for n in range(1, 6)]),
|
364
347
|
stop=tenacity.stop_after_attempt(5),
|
365
348
|
after=lambda x: logger.debug(
|
366
349
|
f"get_receipt_block_timestamp failed, {x.attempt_number=}."
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: prediction-market-agent-tooling
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.62.0
|
4
4
|
Summary: Tools to benchmark, deploy and monitor prediction market agents.
|
5
5
|
Author: Gnosis
|
6
6
|
Requires-Python: >=3.10,<3.13
|
@@ -56,6 +56,7 @@ Requires-Dist: tabulate (>=0.9.0,<0.10.0)
|
|
56
56
|
Requires-Dist: tavily-python (>=0.5.0,<0.6.0)
|
57
57
|
Requires-Dist: tqdm (>=4.66.2,<5.0.0)
|
58
58
|
Requires-Dist: typer (>=0.9.0,<1.0.0)
|
59
|
+
Requires-Dist: types-cachetools (>=5.5.0.20240820,<6.0.0.0)
|
59
60
|
Requires-Dist: types-python-dateutil (>=2.9.0.20240906,<3.0.0.0)
|
60
61
|
Requires-Dist: types-pytz (>=2024.1.0.20240203,<2025.0.0.0)
|
61
62
|
Requires-Dist: types-requests (>=2.31.0.0,<3.0.0.0)
|
@@ -21,74 +21,73 @@ prediction_market_agent_tooling/benchmark/agents.py,sha256=B1-uWdyeN4GGKMWGK_-Cc
|
|
21
21
|
prediction_market_agent_tooling/benchmark/benchmark.py,sha256=MqTiaaJ3cYiOLUVR7OyImLWxcEya3Rl5JyFYW-K0lwM,17097
|
22
22
|
prediction_market_agent_tooling/benchmark/utils.py,sha256=D0MfUkVZllmvcU0VOurk9tcKT7JTtwwOp-63zuCBVuc,2880
|
23
23
|
prediction_market_agent_tooling/config.py,sha256=So5l8KbgmzcCpxzzf13TNrEJPu_4iQnUDhzus6XRvSc,10151
|
24
|
-
prediction_market_agent_tooling/deploy/agent.py,sha256=
|
24
|
+
prediction_market_agent_tooling/deploy/agent.py,sha256=DW9edzHDX7QVURMGyOoIHTIvl3Itpbi8i0l5XPrEkbk,24974
|
25
25
|
prediction_market_agent_tooling/deploy/agent_example.py,sha256=dIIdZashExWk9tOdyDjw87AuUcGyM7jYxNChYrVK2dM,1001
|
26
|
-
prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=
|
26
|
+
prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=iU-D7cdcwiCOWbjDt8hin3ZpL633pQbw9GIKRnIR3FY,12494
|
27
27
|
prediction_market_agent_tooling/deploy/constants.py,sha256=M5ty8URipYMGe_G-RzxRydK3AFL6CyvmqCraJUrLBnE,82
|
28
28
|
prediction_market_agent_tooling/deploy/gcp/deploy.py,sha256=CYUgnfy-9XVk04kkxA_5yp0GE9Mw5caYqlFUZQ2j3ks,3739
|
29
29
|
prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py,sha256=OsPboCFGiZKsvGyntGZHwdqPlLTthITkNF5rJFvGgU8,2582
|
30
30
|
prediction_market_agent_tooling/deploy/gcp/utils.py,sha256=WI2ycX1X-IlTRoNoG4ggFlRwPL28kwM9VGDFD2fePLo,5699
|
31
31
|
prediction_market_agent_tooling/deploy/trade_interval.py,sha256=Xk9j45alQ_vrasGvsNyuW70XHIQ7wfvjoxNR3F6HYCw,1155
|
32
|
-
prediction_market_agent_tooling/gtypes.py,sha256=
|
32
|
+
prediction_market_agent_tooling/gtypes.py,sha256=DaerVkKVqhIhTwCB9A8piwCR97ZMnd8nSTSOlI9XcLM,5549
|
33
33
|
prediction_market_agent_tooling/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
34
|
-
prediction_market_agent_tooling/jobs/jobs_models.py,sha256=
|
35
|
-
prediction_market_agent_tooling/jobs/omen/omen_jobs.py,sha256=
|
34
|
+
prediction_market_agent_tooling/jobs/jobs_models.py,sha256=8vYafsK1cqMWQtjBoq9rruroF84xAVD00vBTMWH6QMg,2166
|
35
|
+
prediction_market_agent_tooling/jobs/omen/omen_jobs.py,sha256=Pf6QxPXGyie-2l_wZUjaGPTjZTlpv50_JhP40mULBaU,5048
|
36
36
|
prediction_market_agent_tooling/loggers.py,sha256=MvCkQSJL2_0yErNatqr81sJlc4aOgPzDp9VNrIhKUcc,4140
|
37
|
-
prediction_market_agent_tooling/markets/agent_market.py,sha256=
|
37
|
+
prediction_market_agent_tooling/markets/agent_market.py,sha256=A8eHhV68RIBUE1eIxVchp3QstzpnAYdZxaANyS6vg68,14866
|
38
38
|
prediction_market_agent_tooling/markets/base_subgraph_handler.py,sha256=7RaYO_4qAmQ6ZGM8oPK2-CkiJfKmV9MxM-rJlduaecU,1971
|
39
|
-
prediction_market_agent_tooling/markets/blockchain_utils.py,sha256=
|
39
|
+
prediction_market_agent_tooling/markets/blockchain_utils.py,sha256=1iTU_D-Uof0E442qVUhSBCfc1rJNQpDcd3UjSnilYZg,2129
|
40
40
|
prediction_market_agent_tooling/markets/categorize.py,sha256=jsoHWvZk9pU6n17oWSCcCxNNYVwlb_NXsZxKRI7vmsk,1301
|
41
|
-
prediction_market_agent_tooling/markets/data_models.py,sha256=
|
41
|
+
prediction_market_agent_tooling/markets/data_models.py,sha256=_R9Hr5zwGLpZLPXq0Jo2wZRNRQyOnSi3WVQJZ81syuk,4541
|
42
42
|
prediction_market_agent_tooling/markets/manifold/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
43
|
-
prediction_market_agent_tooling/markets/manifold/api.py,sha256=
|
44
|
-
prediction_market_agent_tooling/markets/manifold/data_models.py,sha256=
|
45
|
-
prediction_market_agent_tooling/markets/manifold/manifold.py,sha256=
|
43
|
+
prediction_market_agent_tooling/markets/manifold/api.py,sha256=ih92UTZdSbmy6tTUgSCps_HqYQXpMSsfne5Np5znVEM,7217
|
44
|
+
prediction_market_agent_tooling/markets/manifold/data_models.py,sha256=DWNvK6Qdxz7Lxqpe-qQE4X-mw8GFGpukGfnjT_ohcZA,6364
|
45
|
+
prediction_market_agent_tooling/markets/manifold/manifold.py,sha256=TakZ0SqyDFal0QECKCkKkuqqeUm1o3mTpesQIuYInig,4800
|
46
46
|
prediction_market_agent_tooling/markets/manifold/utils.py,sha256=_gGlWid0sPF127Omx5qQ1fq17frLInv0wdyXJBMGVzM,670
|
47
|
-
prediction_market_agent_tooling/markets/market_fees.py,sha256=
|
47
|
+
prediction_market_agent_tooling/markets/market_fees.py,sha256=YeK3ynjYIguB0xf6sO5iyg9lOdW_HD4C6nbJfiGyRCU,1351
|
48
48
|
prediction_market_agent_tooling/markets/markets.py,sha256=OMADWd1C5wD7sVdcY_GVdxAFDndkU9kn6Ble4GXCw0c,4045
|
49
49
|
prediction_market_agent_tooling/markets/metaculus/api.py,sha256=4TRPGytQQbSdf42DCg2M_JWYPAuNjqZ3eBqaQBLkNks,2736
|
50
50
|
prediction_market_agent_tooling/markets/metaculus/data_models.py,sha256=FaBCTPPezXbBwZ9p791CiVgQ4vB696xnMbz9XVXmiVI,3267
|
51
51
|
prediction_market_agent_tooling/markets/metaculus/metaculus.py,sha256=86TIx6cavEWc8Cv4KpZxSvwiSw9oFybXE3YB49pg-CA,4377
|
52
52
|
prediction_market_agent_tooling/markets/omen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
53
|
-
prediction_market_agent_tooling/markets/omen/data_models.py,sha256=
|
54
|
-
prediction_market_agent_tooling/markets/omen/omen.py,sha256=
|
53
|
+
prediction_market_agent_tooling/markets/omen/data_models.py,sha256=URvplDcTLeL6vfpkSgi8ln2iEKxt8w5qf6mTZkSyrCo,29189
|
54
|
+
prediction_market_agent_tooling/markets/omen/omen.py,sha256=_Vt1_w_A6-FHPVgNclwSh2qpABBXXTJ2wKPtcFfrDTQ,51893
|
55
55
|
prediction_market_agent_tooling/markets/omen/omen_constants.py,sha256=D9oflYKafLQiHYtB5sScMHqmXyzM8JP8J0yATmc4SQQ,233
|
56
|
-
prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=
|
57
|
-
prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=
|
58
|
-
prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=
|
56
|
+
prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=bCC9A7ZTJxMDJcPbl3jof6HcAGGHv1BrFq3RRWbkQ_c,28739
|
57
|
+
prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=Cyi9Ci-Z-K8WCZWVLs9oSuJC6qRobi_CpqDCno_5F-0,10238
|
58
|
+
prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=6N6RJ-noC7gkoDBeYdBSXp1QI3u4iftBLu8Dtew9yU4,39017
|
59
59
|
prediction_market_agent_tooling/markets/polymarket/api.py,sha256=UZ4_TG8ceb9Y-qgsOKs8Qiv8zDt957QkT8IX2c83yqo,4800
|
60
|
-
prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=
|
61
|
-
prediction_market_agent_tooling/markets/polymarket/data_models_web.py,sha256=
|
62
|
-
prediction_market_agent_tooling/markets/polymarket/polymarket.py,sha256=
|
60
|
+
prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=utGN-Lhjsa-RHX5WW_jcqgWXtRkEZn0JemwYZkt3Lng,4344
|
61
|
+
prediction_market_agent_tooling/markets/polymarket/data_models_web.py,sha256=LVEsNw2nUx5poiU1m803NNqG5-fs8-MODQRyGLqy4mE,12585
|
62
|
+
prediction_market_agent_tooling/markets/polymarket/polymarket.py,sha256=6rc9qulPl90MxXKB55XiiWKLhjfAyG_eUzAlqpq1UIE,3339
|
63
63
|
prediction_market_agent_tooling/markets/polymarket/utils.py,sha256=8kTeVjXPcXC6DkDvWYsZQLY7x8DS6CEp_yznSEazsNU,2037
|
64
|
-
prediction_market_agent_tooling/markets/seer/data_models.py,sha256=
|
65
|
-
prediction_market_agent_tooling/markets/seer/
|
66
|
-
prediction_market_agent_tooling/markets/seer/
|
67
|
-
prediction_market_agent_tooling/markets/seer/
|
68
|
-
prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=R4aKMZQEE9ocMqr9r4lX4so1h-HrJd2H79ElNzXXIZM,9042
|
69
|
-
prediction_market_agent_tooling/markets/seer/subgraph_data_models.py,sha256=RIt2oO-PbykzbYN11Qltt8tjjYTty-PfjH3Q4D2VEoA,1644
|
64
|
+
prediction_market_agent_tooling/markets/seer/data_models.py,sha256=qo8qH-3j0czH8zrgHnaYyB5-f38zZcl9MNtQfXi_JZM,8192
|
65
|
+
prediction_market_agent_tooling/markets/seer/seer.py,sha256=l9H7AYRje4bEXMdVzw83cseY46BLgOAgiJarE_8faHk,13189
|
66
|
+
prediction_market_agent_tooling/markets/seer/seer_contracts.py,sha256=XOEhaL5wrKEg7P-xg1mW5mJXVfeALuflJOvqAeuwrWM,2717
|
67
|
+
prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=o5Sh_6bpiJQb1KnW3rf4cBqN2PM8IdggQARdBeDMvIE,8725
|
70
68
|
prediction_market_agent_tooling/monitor/financial_metrics/financial_metrics.py,sha256=fjIgjDIx5MhH5mwf7S0cspLOOSU3elYLhGYoIiM26mU,2746
|
71
69
|
prediction_market_agent_tooling/monitor/markets/manifold.py,sha256=TS4ERwTfQnot8dhekNyVNhJYf5ysYsjF-9v5_kM3aVI,3334
|
72
70
|
prediction_market_agent_tooling/monitor/markets/metaculus.py,sha256=LOnyWWBFdg10-cTWdb76nOsNjDloO8OfMT85GBzRCFI,1455
|
73
71
|
prediction_market_agent_tooling/monitor/markets/omen.py,sha256=EqiJYTvDbSu7fBpbrBmCuf3fc6GHr4MxWrBGa69MIyc,3305
|
74
72
|
prediction_market_agent_tooling/monitor/markets/polymarket.py,sha256=wak8o4BYaGbLpshQD12OrsqNABdanyID6ql95lEG2io,1870
|
75
|
-
prediction_market_agent_tooling/monitor/monitor.py,sha256=
|
73
|
+
prediction_market_agent_tooling/monitor/monitor.py,sha256=yvSXwV-3DSAm3vsFZnFC9jEQzlaB9KUOxI6pOyNKGQk,14147
|
76
74
|
prediction_market_agent_tooling/monitor/monitor_app.py,sha256=-_6w_ZvQ-Ad5qaeuo7NKTXUOOZ_6OrR8jMe25BGOY4k,4615
|
77
75
|
prediction_market_agent_tooling/monitor/monitor_settings.py,sha256=Xiozs3AsufuJ04JOe1vjUri-IAMWHjjmc2ugGGiHNH4,947
|
78
76
|
prediction_market_agent_tooling/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
79
|
-
prediction_market_agent_tooling/tools/
|
80
|
-
prediction_market_agent_tooling/tools/
|
81
|
-
prediction_market_agent_tooling/tools/betting_strategies/
|
77
|
+
prediction_market_agent_tooling/tools/_generic_value.py,sha256=0_EDybTsr3iXqPPqy2U1WMw4st_SlYaCrf2p1MZhED4,10511
|
78
|
+
prediction_market_agent_tooling/tools/balances.py,sha256=Osab21btfJDw2Y-jT_TV-KHGrseCRxcsYeW6WcOMB8E,1050
|
79
|
+
prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py,sha256=L9yp3m_81i-y85dGZH1rYRv9YXYYt1w3RGroFAAYSbw,4873
|
80
|
+
prediction_market_agent_tooling/tools/betting_strategies/market_moving.py,sha256=36ucOuF38bdB4rnSPNjC1qpidBo30Ff4P5Kb-7emKEQ,5469
|
82
81
|
prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py,sha256=-FUSuQQgjcWSSnoFxnlAyTeilY6raJABJVM2QKkFqAY,438
|
83
82
|
prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py,sha256=THMXwFlskvzbjnX_OiYtDSzI8XVFyULWfP2525_9UGc,429
|
84
|
-
prediction_market_agent_tooling/tools/betting_strategies/utils.py,sha256=
|
83
|
+
prediction_market_agent_tooling/tools/betting_strategies/utils.py,sha256=68zFWUj43GUaSpOPowVrbI-t6qbCE29RsVHNzCVuJ9U,175
|
85
84
|
prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=dB8LNs2JvVRaFCeAKRmIQRwiirsMgtL31he8051wM-g,11431
|
86
85
|
prediction_market_agent_tooling/tools/caches/inmemory_cache.py,sha256=ZW5iI5rmjqeAebu5T7ftRnlkxiL02IC-MxCfDB80x7w,1506
|
87
86
|
prediction_market_agent_tooling/tools/caches/serializers.py,sha256=vFDx4fsPxclXp2q0sv27j4al_M_Tj9aR2JJP-xNHQXA,2151
|
88
|
-
prediction_market_agent_tooling/tools/contract.py,sha256=
|
87
|
+
prediction_market_agent_tooling/tools/contract.py,sha256=PJaC_Mc06vowyHD6f4MNQuEfo-h0H-Lh741YzRuemUk,21018
|
89
88
|
prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
|
90
|
-
prediction_market_agent_tooling/tools/cow/cow_manager.py,sha256=
|
91
|
-
prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=
|
89
|
+
prediction_market_agent_tooling/tools/cow/cow_manager.py,sha256=ZX6K0ZKMpcgiDsIrv4wtZAPg-LTozIbvOyQFyVgDpMA,3812
|
90
|
+
prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=4BV9t_RZU07SxwAzjTVkXKoQtm9l-roFHJR_cE8O04A,5837
|
92
91
|
prediction_market_agent_tooling/tools/custom_exceptions.py,sha256=Fh8z1fbwONvP4-j7AmV_PuEcoqb6-QXa9PJ9m7guMcM,93
|
93
92
|
prediction_market_agent_tooling/tools/datetime_utc.py,sha256=8_WackjtjC8zHXrhQFTGQ6e6Fz_6llWoKR4CSFvIv9I,2766
|
94
93
|
prediction_market_agent_tooling/tools/db/db_manager.py,sha256=GtzHH1NLl8HwqC8Z7s6eTlIQXuV0blxfaV2PeQrBnfQ,3013
|
@@ -101,26 +100,28 @@ prediction_market_agent_tooling/tools/ipfs/ipfs_handler.py,sha256=CTTMfTvs_8PH4k
|
|
101
100
|
prediction_market_agent_tooling/tools/is_invalid.py,sha256=TAHQXiiusAU45xJ11ZyEP7PnEfcjfzVG7qHRbsHiAd0,5335
|
102
101
|
prediction_market_agent_tooling/tools/is_predictable.py,sha256=qVd6zqay2Dg2fyeAuZvAFqSHMg71TcPfCZULsVk2XvA,6797
|
103
102
|
prediction_market_agent_tooling/tools/langfuse_.py,sha256=jI_4ROxqo41CCnWGS1vN_AeDVhRzLMaQLxH3kxDu3L8,1153
|
104
|
-
prediction_market_agent_tooling/tools/langfuse_client_utils.py,sha256=
|
103
|
+
prediction_market_agent_tooling/tools/langfuse_client_utils.py,sha256=636bHCxwfWSbQYQQ0ipeyJUDXCbAC1zP6ZqzeLL2GJk,6582
|
105
104
|
prediction_market_agent_tooling/tools/omen/reality_accuracy.py,sha256=M1SF7iSW1gVlQSTskdVFTn09uPLST23YeipVIWj54io,2236
|
106
|
-
prediction_market_agent_tooling/tools/omen/sell_positions.py,sha256=
|
105
|
+
prediction_market_agent_tooling/tools/omen/sell_positions.py,sha256=7b2qHGQ_2V3ke_UTR9wQeJW88z5ub1GTre9Y_zd4e9E,2387
|
107
106
|
prediction_market_agent_tooling/tools/parallelism.py,sha256=6Gou0hbjtMZrYvxjTDFUDZuxmE2nqZVbb6hkg1hF82A,1022
|
108
107
|
prediction_market_agent_tooling/tools/relevant_news_analysis/data_models.py,sha256=95l84aztFaxcRLLcRQ46yKJbIlOEuDAbIGLouyliDzA,1316
|
109
108
|
prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_analysis.py,sha256=CddJem7tk15NAudJDwmuL8znTycbR-YI8kTNtd3LzG8,5474
|
110
109
|
prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py,sha256=kNWq92T11Knb9mYBZlMiZUzOpKgCd-5adanylQUMRJA,3085
|
111
|
-
prediction_market_agent_tooling/tools/safe.py,sha256=
|
110
|
+
prediction_market_agent_tooling/tools/safe.py,sha256=o477HGPQv7X_eDoOeYoELCHryiq1_102y_JVhGEPDXw,5165
|
112
111
|
prediction_market_agent_tooling/tools/singleton.py,sha256=CiIELUiI-OeS7U7eeHEt0rnVhtQGzwoUdAgn_7u_GBM,729
|
113
112
|
prediction_market_agent_tooling/tools/streamlit_user_login.py,sha256=NXEqfjT9Lc9QtliwSGRASIz1opjQ7Btme43H4qJbzgE,3010
|
114
113
|
prediction_market_agent_tooling/tools/tavily/tavily_models.py,sha256=5ldQs1pZe6uJ5eDAuP4OLpzmcqYShlIV67kttNFvGS0,342
|
115
114
|
prediction_market_agent_tooling/tools/tavily/tavily_search.py,sha256=pPs0qZNfJ7G-1ajfz0iaWOBQyiC0TbcShfrW8T39jtg,3859
|
116
|
-
prediction_market_agent_tooling/tools/tokens/auto_deposit.py,sha256=
|
117
|
-
prediction_market_agent_tooling/tools/tokens/auto_withdraw.py,sha256=
|
118
|
-
prediction_market_agent_tooling/tools/tokens/main_token.py,sha256=
|
115
|
+
prediction_market_agent_tooling/tools/tokens/auto_deposit.py,sha256=MWIRHYCN-7o2uawEBwnBNhlzme1kLyX_5Q2zg7UIegQ,6700
|
116
|
+
prediction_market_agent_tooling/tools/tokens/auto_withdraw.py,sha256=22g0SIVmLlgITpdt3kPhJOw0sU4OPeBuYk_7xCrQr9U,2491
|
117
|
+
prediction_market_agent_tooling/tools/tokens/main_token.py,sha256=1rbwpdCusPgQIVFuo3m00nBZ_b2lCAoFVm67i-YDcEw,812
|
118
|
+
prediction_market_agent_tooling/tools/tokens/token_utils.py,sha256=zwV-jGFkPJu4-IslXOUqnsNQjzh_9CrfkruDQL0dq0c,1381
|
119
|
+
prediction_market_agent_tooling/tools/tokens/usd.py,sha256=l4vPemtF6Zcwh8HNXH3-L5k7OE_XolbklzBsTpFruW8,3116
|
119
120
|
prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
|
120
|
-
prediction_market_agent_tooling/tools/utils.py,sha256=
|
121
|
-
prediction_market_agent_tooling/tools/web3_utils.py,sha256=
|
122
|
-
prediction_market_agent_tooling-0.
|
123
|
-
prediction_market_agent_tooling-0.
|
124
|
-
prediction_market_agent_tooling-0.
|
125
|
-
prediction_market_agent_tooling-0.
|
126
|
-
prediction_market_agent_tooling-0.
|
121
|
+
prediction_market_agent_tooling/tools/utils.py,sha256=1xsyBBJfiEdSoMlceB2F8o2sCb6Z8-qNz11pEJFrdyE,6566
|
122
|
+
prediction_market_agent_tooling/tools/web3_utils.py,sha256=eYCc1iWAVtqDKUPTwnMUHuYolPdwh_OTiM3-AdRgDp4,12198
|
123
|
+
prediction_market_agent_tooling-0.62.0.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
124
|
+
prediction_market_agent_tooling-0.62.0.dist-info/METADATA,sha256=mHLpcxuRssymn1B7Uo1kA1iZNhNVkbVUxItxF9ERZos,8689
|
125
|
+
prediction_market_agent_tooling-0.62.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
126
|
+
prediction_market_agent_tooling-0.62.0.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
127
|
+
prediction_market_agent_tooling-0.62.0.dist-info/RECORD,,
|
@@ -1,111 +0,0 @@
|
|
1
|
-
from functools import lru_cache
|
2
|
-
|
3
|
-
from web3 import Web3
|
4
|
-
|
5
|
-
from prediction_market_agent_tooling.gtypes import ChecksumAddress, xdai_type
|
6
|
-
from prediction_market_agent_tooling.gtypes import Probability
|
7
|
-
from prediction_market_agent_tooling.loggers import logger
|
8
|
-
from prediction_market_agent_tooling.markets.seer.data_models import (
|
9
|
-
SeerMarket,
|
10
|
-
SeerOutcomeEnum,
|
11
|
-
)
|
12
|
-
from prediction_market_agent_tooling.markets.seer.seer_subgraph_handler import (
|
13
|
-
SeerSubgraphHandler,
|
14
|
-
)
|
15
|
-
from prediction_market_agent_tooling.markets.seer.subgraph_data_models import SeerPool
|
16
|
-
from prediction_market_agent_tooling.tools.cow.cow_manager import CowManager
|
17
|
-
from prediction_market_agent_tooling.tools.web3_utils import xdai_to_wei
|
18
|
-
|
19
|
-
|
20
|
-
class PriceManager:
|
21
|
-
def __init__(self, seer_market: SeerMarket, seer_subgraph: SeerSubgraphHandler):
|
22
|
-
self.seer_market = seer_market
|
23
|
-
self.seer_subgraph = seer_subgraph
|
24
|
-
|
25
|
-
def current_p_yes(self) -> Probability:
|
26
|
-
price_data = {}
|
27
|
-
for idx, wrapped_token in enumerate(self.seer_market.wrapped_tokens):
|
28
|
-
price = self.get_price_for_token(
|
29
|
-
token=Web3.to_checksum_address(wrapped_token),
|
30
|
-
)
|
31
|
-
|
32
|
-
price_data[idx] = price
|
33
|
-
|
34
|
-
if sum(price_data.values()) == 0:
|
35
|
-
logger.warning(
|
36
|
-
f"Could not get p_yes for market {self.seer_market.id.hex()}, all price quotes are 0."
|
37
|
-
)
|
38
|
-
return Probability(0)
|
39
|
-
|
40
|
-
price_yes = price_data[self.seer_market.outcome_as_enums[SeerOutcomeEnum.YES]]
|
41
|
-
price_no = price_data[self.seer_market.outcome_as_enums[SeerOutcomeEnum.NO]]
|
42
|
-
if price_yes and not price_no:
|
43
|
-
# We simply return p_yes since it's probably a bug that p_no wasn't found.
|
44
|
-
return Probability(price_yes)
|
45
|
-
elif price_no and not price_yes:
|
46
|
-
# We return the complement of p_no (and ignore invalid).
|
47
|
-
return Probability(1.0 - price_no)
|
48
|
-
else:
|
49
|
-
# If all prices are available, we normalize price_yes by the other prices for the final probability.
|
50
|
-
price_yes = price_yes / sum(price_data.values())
|
51
|
-
return Probability(price_yes)
|
52
|
-
|
53
|
-
@lru_cache(typed=True)
|
54
|
-
def get_price_for_token(
|
55
|
-
self,
|
56
|
-
token: ChecksumAddress,
|
57
|
-
) -> float:
|
58
|
-
collateral_exchange_amount = xdai_to_wei(xdai_type(1))
|
59
|
-
try:
|
60
|
-
quote = CowManager().get_quote(
|
61
|
-
collateral_token=self.seer_market.collateral_token_contract_address_checksummed,
|
62
|
-
buy_token=token,
|
63
|
-
sell_amount=collateral_exchange_amount,
|
64
|
-
)
|
65
|
-
except Exception as e:
|
66
|
-
logger.warning(
|
67
|
-
f"Could not get quote for {token=} from Cow, exception {e=}. Falling back to pools. "
|
68
|
-
)
|
69
|
-
price = self.get_token_price_from_pools(token=token)
|
70
|
-
return price
|
71
|
-
|
72
|
-
return collateral_exchange_amount / float(quote.quote.buyAmount.root)
|
73
|
-
|
74
|
-
@staticmethod
|
75
|
-
def _pool_token0_matches_token(token: ChecksumAddress, pool: SeerPool) -> bool:
|
76
|
-
return pool.token0.id.hex().lower() == token.lower()
|
77
|
-
|
78
|
-
def get_token_price_from_pools(
|
79
|
-
self,
|
80
|
-
token: ChecksumAddress,
|
81
|
-
) -> float:
|
82
|
-
pool = SeerSubgraphHandler().get_pool_by_token(token_address=token)
|
83
|
-
|
84
|
-
if not pool:
|
85
|
-
logger.warning(f"Could not find a pool for {token=}, returning 0.")
|
86
|
-
return 0
|
87
|
-
# Check if other token is market's collateral (sanity check).
|
88
|
-
|
89
|
-
# Collateral is the other token in the pair
|
90
|
-
collateral_address = Web3.to_checksum_address(
|
91
|
-
pool.token0.id
|
92
|
-
if not self._pool_token0_matches_token(token=token, pool=pool)
|
93
|
-
else pool.token1.id
|
94
|
-
)
|
95
|
-
if (
|
96
|
-
collateral_address
|
97
|
-
!= self.seer_market.collateral_token_contract_address_checksummed
|
98
|
-
):
|
99
|
-
logger.warning(
|
100
|
-
f"Pool {pool.id.hex()} has collateral mismatch with market. Collateral from pool {collateral_address.hex()}, collateral from market {self.seer_market.collateral_token_contract_address_checksummed}, returning 0."
|
101
|
-
)
|
102
|
-
return 0
|
103
|
-
|
104
|
-
# The mapping below is odd but surprisingly the Algebra subgraph delivers the token1Price
|
105
|
-
# for the token0 and the token0Price for the token1 pool.
|
106
|
-
price_in_collateral_units = (
|
107
|
-
pool.token1Price
|
108
|
-
if self._pool_token0_matches_token(token=token, pool=pool)
|
109
|
-
else pool.token0Price
|
110
|
-
)
|
111
|
-
return price_in_collateral_units
|
@@ -1,57 +0,0 @@
|
|
1
|
-
from pydantic import BaseModel, ConfigDict, Field
|
2
|
-
from web3.constants import ADDRESS_ZERO
|
3
|
-
|
4
|
-
from prediction_market_agent_tooling.gtypes import HexBytes, HexAddress, Wei
|
5
|
-
|
6
|
-
|
7
|
-
class SeerToken(BaseModel):
|
8
|
-
id: HexBytes
|
9
|
-
name: str
|
10
|
-
symbol: str
|
11
|
-
|
12
|
-
|
13
|
-
class SeerPool(BaseModel):
|
14
|
-
model_config = ConfigDict(populate_by_name=True)
|
15
|
-
id: HexBytes
|
16
|
-
liquidity: int
|
17
|
-
token0: SeerToken
|
18
|
-
token1: SeerToken
|
19
|
-
token0Price: float
|
20
|
-
token1Price: float
|
21
|
-
sqrtPrice: int
|
22
|
-
|
23
|
-
|
24
|
-
class NewMarketEvent(BaseModel):
|
25
|
-
market: HexAddress
|
26
|
-
marketName: str
|
27
|
-
parentMarket: HexAddress
|
28
|
-
conditionId: HexBytes
|
29
|
-
questionId: HexBytes
|
30
|
-
questionsIds: list[HexBytes]
|
31
|
-
|
32
|
-
|
33
|
-
class CreateCategoricalMarketsParams(BaseModel):
|
34
|
-
model_config = ConfigDict(populate_by_name=True)
|
35
|
-
|
36
|
-
market_name: str = Field(..., alias="marketName")
|
37
|
-
outcomes: list[str]
|
38
|
-
# Only relevant for scalar markets
|
39
|
-
question_start: str = Field(alias="questionStart", default="")
|
40
|
-
question_end: str = Field(alias="questionEnd", default="")
|
41
|
-
outcome_type: str = Field(alias="outcomeType", default="")
|
42
|
-
|
43
|
-
# Not needed for non-conditional markets.
|
44
|
-
parent_outcome: int = Field(alias="parentOutcome", default=0)
|
45
|
-
parent_market: HexAddress = Field(alias="parentMarket", default=ADDRESS_ZERO)
|
46
|
-
|
47
|
-
category: str
|
48
|
-
lang: str
|
49
|
-
lower_bound: int = Field(alias="lowerBound", default=0)
|
50
|
-
upper_bound: int = Field(alias="upperBound", default=0)
|
51
|
-
min_bond: Wei = Field(..., alias="minBond")
|
52
|
-
opening_time: int = Field(..., alias="openingTime")
|
53
|
-
token_names: list[str] = Field(..., alias="tokenNames")
|
54
|
-
|
55
|
-
|
56
|
-
class SeerParentMarket(BaseModel):
|
57
|
-
id: HexBytes
|
File without changes
|
File without changes
|