prediction-market-agent-tooling 0.60.1__py3-none-any.whl → 0.60.2__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.
@@ -3,13 +3,13 @@ import typing as t
3
3
  from copy import deepcopy
4
4
 
5
5
  from eth_account.signers.local import LocalAccount
6
- from pydantic import Field, model_validator
6
+ from pydantic import BeforeValidator, Field, model_validator
7
7
  from pydantic.types import SecretStr
8
8
  from pydantic.v1.types import SecretStr as SecretStrV1
9
9
  from pydantic_settings import BaseSettings, SettingsConfigDict
10
10
  from safe_eth.eth import EthereumClient
11
11
  from safe_eth.safe.safe import SafeV141
12
- from web3 import Account
12
+ from web3 import Account, Web3
13
13
 
14
14
  from prediction_market_agent_tooling.deploy.gcp.utils import gcp_get_secret_value
15
15
  from prediction_market_agent_tooling.gtypes import (
@@ -39,7 +39,10 @@ class APIKeys(BaseSettings):
39
39
  METACULUS_API_KEY: t.Optional[SecretStr] = None
40
40
  METACULUS_USER_ID: t.Optional[int] = None
41
41
  BET_FROM_PRIVATE_KEY: t.Optional[PrivateKey] = None
42
- SAFE_ADDRESS: t.Optional[ChecksumAddress] = None
42
+ SAFE_ADDRESS: t.Annotated[
43
+ ChecksumAddress | None,
44
+ BeforeValidator(lambda x: x if x is None else Web3.to_checksum_address(x)),
45
+ ] = None
43
46
  OPENAI_API_KEY: t.Optional[SecretStr] = None
44
47
  GRAPH_API_KEY: t.Optional[SecretStr] = None
45
48
  TENDERLY_FORK_RPC: t.Optional[str] = None
@@ -30,7 +30,7 @@ from prediction_market_agent_tooling.deploy.trade_interval import (
30
30
  FixedInterval,
31
31
  TradeInterval,
32
32
  )
33
- from prediction_market_agent_tooling.gtypes import xDai, xdai_type
33
+ from prediction_market_agent_tooling.gtypes import xDai
34
34
  from prediction_market_agent_tooling.loggers import logger
35
35
  from prediction_market_agent_tooling.markets.agent_market import (
36
36
  AgentMarket,
@@ -62,6 +62,9 @@ from prediction_market_agent_tooling.tools.custom_exceptions import (
62
62
  from prediction_market_agent_tooling.tools.is_invalid import is_invalid
63
63
  from prediction_market_agent_tooling.tools.is_predictable import is_predictable_binary
64
64
  from prediction_market_agent_tooling.tools.langfuse_ import langfuse_context, observe
65
+ from prediction_market_agent_tooling.tools.tokens.main_token import (
66
+ MINIMUM_NATIVE_TOKEN_IN_EOA_FOR_FEES,
67
+ )
65
68
  from prediction_market_agent_tooling.tools.utils import DatetimeUTC, utcnow
66
69
 
67
70
  MAX_AVAILABLE_MARKETS = 1000
@@ -289,7 +292,9 @@ class DeployablePredictionAgent(DeployableAgent):
289
292
  allow_invalid_questions: bool = False
290
293
  same_market_trade_interval: TradeInterval = FixedInterval(timedelta(hours=24))
291
294
 
292
- min_balance_to_keep_in_native_currency: xDai | None = xdai_type(0.1)
295
+ min_balance_to_keep_in_native_currency: xDai | None = (
296
+ MINIMUM_NATIVE_TOKEN_IN_EOA_FOR_FEES
297
+ )
293
298
 
294
299
  # Only Metaculus allows to post predictions without trading (buying/selling of outcome tokens).
295
300
  supported_markets: t.Sequence[MarketType] = [MarketType.METACULUS]
@@ -18,6 +18,9 @@ from prediction_market_agent_tooling.markets.omen.data_models import (
18
18
  OmenMarket,
19
19
  RealityQuestion,
20
20
  )
21
+ from prediction_market_agent_tooling.markets.omen.omen import (
22
+ send_keeping_token_to_eoa_xdai,
23
+ )
21
24
  from prediction_market_agent_tooling.markets.omen.omen_contracts import (
22
25
  OmenOracleContract,
23
26
  OmenRealitioContract,
@@ -25,11 +28,15 @@ from prediction_market_agent_tooling.markets.omen.omen_contracts import (
25
28
  from prediction_market_agent_tooling.markets.omen.omen_subgraph_handler import (
26
29
  OmenSubgraphHandler,
27
30
  )
31
+ from prediction_market_agent_tooling.tools.tokens.main_token import (
32
+ MINIMUM_NATIVE_TOKEN_IN_EOA_FOR_FEES,
33
+ )
28
34
  from prediction_market_agent_tooling.tools.utils import utcnow
29
35
  from prediction_market_agent_tooling.tools.web3_utils import (
30
36
  ZERO_BYTES,
31
37
  wei_to_xdai,
32
38
  xdai_to_wei,
39
+ xdai_type,
33
40
  )
34
41
 
35
42
 
@@ -139,6 +146,16 @@ def finalize_markets(
139
146
  logger.info(
140
147
  f"[{idx+1} / {len(markets_with_resolutions)}] Looking into {market.url=} {market.question_title=}"
141
148
  )
149
+
150
+ # If we don't have enough of xDai for bond, try to get it from the keeping token.
151
+ send_keeping_token_to_eoa_xdai(
152
+ api_keys=api_keys,
153
+ min_required_balance=xdai_type(
154
+ realitio_bond + MINIMUM_NATIVE_TOKEN_IN_EOA_FOR_FEES
155
+ ),
156
+ web3=web3,
157
+ )
158
+
142
159
  closed_before_days = (utcnow() - market.close_time).days
143
160
 
144
161
  if resolution is None:
@@ -1,3 +1,4 @@
1
+ from prediction_market_agent_tooling.gtypes import xdai_type
1
2
  from prediction_market_agent_tooling.markets.omen.omen_constants import (
2
3
  WRAPPED_XDAI_CONTRACT_ADDRESS,
3
4
  )
@@ -13,3 +14,5 @@ from prediction_market_agent_tooling.tools.contract import (
13
14
  KEEPING_ERC20_TOKEN = ContractDepositableWrapperERC20OnGnosisChain(
14
15
  address=WRAPPED_XDAI_CONTRACT_ADDRESS
15
16
  )
17
+
18
+ MINIMUM_NATIVE_TOKEN_IN_EOA_FOR_FEES = xdai_type(0.1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.60.1
3
+ Version: 0.60.2
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.13
@@ -20,8 +20,8 @@ prediction_market_agent_tooling/benchmark/__init__.py,sha256=47DEQpj8HBSa-_TImW-
20
20
  prediction_market_agent_tooling/benchmark/agents.py,sha256=B1-uWdyeN4GGKMWGK_-CcAFJg1m9Y_XuaeIHPB29QR8,3971
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
- prediction_market_agent_tooling/config.py,sha256=hiZc_A6q7-_kHW2OdavHNBjNrCpxIEqaklfIf0TFyy0,9499
24
- prediction_market_agent_tooling/deploy/agent.py,sha256=TRQ5F-b3NA6zVn6tJBlXl_ZDI73b4q7WPZCMxFxzTtE,24847
23
+ prediction_market_agent_tooling/config.py,sha256=eiJPhb736Jtgrbh2d035_bFz2YaIiipUPapgIjYNqM4,9629
24
+ prediction_market_agent_tooling/deploy/agent.py,sha256=tC0MQKR_63SdsfDrCWXAko0yP01zvP7tuspAbjCj0eE,24988
25
25
  prediction_market_agent_tooling/deploy/agent_example.py,sha256=dIIdZashExWk9tOdyDjw87AuUcGyM7jYxNChYrVK2dM,1001
26
26
  prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=Y6Pb8OfSb6galRbfdNBvvNTgO-4dR2ybJ4o5GKJcMoM,12894
27
27
  prediction_market_agent_tooling/deploy/constants.py,sha256=M5ty8URipYMGe_G-RzxRydK3AFL6CyvmqCraJUrLBnE,82
@@ -54,7 +54,7 @@ prediction_market_agent_tooling/markets/omen/data_models.py,sha256=sfaOpNk6oFIzx
54
54
  prediction_market_agent_tooling/markets/omen/omen.py,sha256=ZLKa0X5hSQucqcqIyuwUM_NzHuAlbLZzUPSqSQBUscE,53213
55
55
  prediction_market_agent_tooling/markets/omen/omen_constants.py,sha256=D9oflYKafLQiHYtB5sScMHqmXyzM8JP8J0yATmc4SQQ,233
56
56
  prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=EXqBlVivbmW8aBQ65O09X2xkyesHAop49GUl1tUffWA,28648
57
- prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=dMxnPK2DF3aL4oZkBkbxwTcU7EMmi1vnTm0oC5d91yY,9781
57
+ prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=B4z9dPqtEfows8-1hkstBLLS_7X0L9z3CG41adyCYgg,10336
58
58
  prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=dQyz1RR1MlQncb1Slq7tk1Maql-sbb5YYE_sDe26MYA,38711
59
59
  prediction_market_agent_tooling/markets/polymarket/api.py,sha256=UZ4_TG8ceb9Y-qgsOKs8Qiv8zDt957QkT8IX2c83yqo,4800
60
60
  prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=Fd5PI5y3mJM8VHExBhWFWEnuuIKxQmIAXgBuoPDvNjw,4341
@@ -113,12 +113,12 @@ prediction_market_agent_tooling/tools/tavily/tavily_models.py,sha256=5ldQs1pZe6u
113
113
  prediction_market_agent_tooling/tools/tavily/tavily_search.py,sha256=pPs0qZNfJ7G-1ajfz0iaWOBQyiC0TbcShfrW8T39jtg,3859
114
114
  prediction_market_agent_tooling/tools/tokens/auto_deposit.py,sha256=o8_ERfPL-ps9FLvH5vgdiSRJQ4dZONJw9KK9sHgeP2I,6390
115
115
  prediction_market_agent_tooling/tools/tokens/auto_withdraw.py,sha256=25Y0H1p0hSD3gWShKPcJ5BckQc3nr_hOAvImOFODC0w,3160
116
- prediction_market_agent_tooling/tools/tokens/main_token.py,sha256=SWkoa2VYEoNBWR5Umraa2g-LEAwQB252fQJ28oI49pI,706
116
+ prediction_market_agent_tooling/tools/tokens/main_token.py,sha256=7JPgVF4RbiFzLDQVBkBuC--eUoM1AYOcJ4VygbmK5yo,822
117
117
  prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
118
118
  prediction_market_agent_tooling/tools/utils.py,sha256=jLG4nbEoIzzJiZ4RgMx4Q969Zdl0p0s63p8uET_0Fuw,6440
119
119
  prediction_market_agent_tooling/tools/web3_utils.py,sha256=2PXZfGRrDVZD60agVpBN4JkOF0YsNBXgTEH1y-V71uQ,12723
120
- prediction_market_agent_tooling-0.60.1.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
121
- prediction_market_agent_tooling-0.60.1.dist-info/METADATA,sha256=UAGTKEHQz1wnZiLPHWxxgHTPoQK75ouA578h__WZ9S0,8629
122
- prediction_market_agent_tooling-0.60.1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
123
- prediction_market_agent_tooling-0.60.1.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
124
- prediction_market_agent_tooling-0.60.1.dist-info/RECORD,,
120
+ prediction_market_agent_tooling-0.60.2.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
121
+ prediction_market_agent_tooling-0.60.2.dist-info/METADATA,sha256=vijNsJBwWEVEPwvWJdGA-SQ7uklcgNzXF5IbcQyTVZs,8629
122
+ prediction_market_agent_tooling-0.60.2.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
123
+ prediction_market_agent_tooling-0.60.2.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
124
+ prediction_market_agent_tooling-0.60.2.dist-info/RECORD,,