prediction-market-agent-tooling 0.65.0__py3-none-any.whl → 0.65.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.
@@ -11,6 +11,7 @@ from pydantic_settings import BaseSettings, SettingsConfigDict
11
11
  from safe_eth.eth import EthereumClient
12
12
  from safe_eth.safe.safe import SafeV141
13
13
  from web3 import Account, Web3
14
+ from web3._utils.http import construct_user_agent
14
15
 
15
16
  from prediction_market_agent_tooling.chains import ETHEREUM_ID, GNOSIS_CHAIN_ID
16
17
  from prediction_market_agent_tooling.deploy.gcp.utils import gcp_get_secret_value
@@ -280,7 +281,9 @@ class RPCConfig(BaseSettings):
280
281
  )
281
282
 
282
283
  ETHEREUM_RPC_URL: URI = Field(default=URI("https://rpc.eth.gateway.fm"))
284
+ ETHEREUM_RPC_BEARER: SecretStr | None = None
283
285
  GNOSIS_RPC_URL: URI = Field(default=URI("https://rpc.gnosis.gateway.fm"))
286
+ GNOSIS_RPC_BEARER: SecretStr | None = None
284
287
  CHAIN_ID: ChainID = Field(default=GNOSIS_CHAIN_ID)
285
288
 
286
289
  @property
@@ -300,15 +303,33 @@ class RPCConfig(BaseSettings):
300
303
  return check_not_none(self.CHAIN_ID, "CHAIN_ID missing in the environment.")
301
304
 
302
305
  def chain_id_to_rpc_url(self, chain_id: ChainID) -> URI:
303
- if chain_id == ETHEREUM_ID:
304
- return self.ethereum_rpc_url
305
- elif chain_id == GNOSIS_CHAIN_ID:
306
- return self.gnosis_rpc_url
307
- else:
308
- raise ValueError(f"Unsupported chain ID: {chain_id}")
306
+ return {
307
+ ETHEREUM_ID: self.ethereum_rpc_url,
308
+ GNOSIS_CHAIN_ID: self.gnosis_rpc_url,
309
+ }[chain_id]
310
+
311
+ def chain_id_to_rpc_bearer(self, chain_id: ChainID) -> SecretStr | None:
312
+ return {
313
+ ETHEREUM_ID: self.ETHEREUM_RPC_BEARER,
314
+ GNOSIS_CHAIN_ID: self.GNOSIS_RPC_BEARER,
315
+ }[chain_id]
309
316
 
310
317
  def get_web3(self) -> Web3:
311
- return Web3(Web3.HTTPProvider(self.gnosis_rpc_url))
318
+ headers = {
319
+ "Content-Type": "application/json",
320
+ "User-Agent": construct_user_agent(str(type(self))),
321
+ }
322
+ if bearer := self.chain_id_to_rpc_bearer(self.chain_id):
323
+ headers["Authorization"] = f"Bearer {bearer.get_secret_value()}"
324
+
325
+ return Web3(
326
+ Web3.HTTPProvider(
327
+ self.chain_id_to_rpc_url(self.chain_id),
328
+ request_kwargs={
329
+ "headers": headers,
330
+ },
331
+ )
332
+ )
312
333
 
313
334
 
314
335
  class CloudCredentials(BaseSettings):
@@ -134,6 +134,7 @@ def patch_logger(force_patch: bool = False) -> None:
134
134
  handler,
135
135
  level=config.LOG_LEVEL.value,
136
136
  colorize=False,
137
+ catch=False,
137
138
  )
138
139
 
139
140
  # Use logging module for warnings.
@@ -122,10 +122,15 @@ class PriceManager:
122
122
  # Inspired by https://github.com/seer-pm/demo/blob/ca682153a6b4d4dd3dcc4ad8bdcbe32202fc8fe7/web/src/hooks/useMarketOdds.ts#L15
123
123
  price_data: dict[HexAddress, CollateralToken] = {}
124
124
 
125
- for wrapped_token in self.seer_market.wrapped_tokens:
125
+ for idx, wrapped_token in enumerate(self.seer_market.wrapped_tokens):
126
126
  price = self.get_price_for_token(
127
127
  token=Web3.to_checksum_address(wrapped_token),
128
128
  )
129
+ # It's okay if invalid (last) outcome has price 0, but not the other outcomes.
130
+ if price is None and idx != len(self.seer_market.wrapped_tokens) - 1:
131
+ raise ValueError(
132
+ f"Couldn't get price for {wrapped_token} for market {self.seer_market.url}."
133
+ )
129
134
  price_data[wrapped_token] = (
130
135
  price if price is not None else CollateralToken.zero()
131
136
  )
@@ -137,10 +142,9 @@ class PriceManager:
137
142
  sum(price_data.values(), start=CollateralToken.zero())
138
143
  == CollateralToken.zero()
139
144
  ):
140
- return {
141
- OutcomeStr(outcome): Probability(0)
142
- for outcome in self.seer_market.outcomes
143
- }
145
+ raise ValueError(
146
+ f"All prices for market {self.seer_market.url} are zero. This shouldn't happen."
147
+ )
144
148
 
145
149
  for outcome_token, price in price_data.items():
146
150
  old_price = price
@@ -9,7 +9,7 @@ from prediction_market_agent_tooling.deploy.constants import (
9
9
  NO_OUTCOME_LOWERCASE_IDENTIFIER,
10
10
  YES_OUTCOME_LOWERCASE_IDENTIFIER,
11
11
  )
12
- from prediction_market_agent_tooling.gtypes import ChecksumAddress
12
+ from prediction_market_agent_tooling.gtypes import ChecksumAddress, Wei
13
13
  from prediction_market_agent_tooling.loggers import logger
14
14
  from prediction_market_agent_tooling.markets.agent_market import FilterBy, SortBy
15
15
  from prediction_market_agent_tooling.markets.base_subgraph_handler import (
@@ -77,6 +77,7 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
77
77
  @staticmethod
78
78
  def _build_where_statements(
79
79
  filter_by: FilterBy,
80
+ outcome_supply_gt_if_open: Wei,
80
81
  include_conditional_markets: bool = False,
81
82
  include_categorical_markets: bool = True,
82
83
  ) -> dict[Any, Any]:
@@ -88,6 +89,7 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
88
89
  case FilterBy.OPEN:
89
90
  and_stms["openingTs_gt"] = now
90
91
  and_stms["hasAnswers"] = False
92
+ and_stms["outcomesSupply_gt"] = outcome_supply_gt_if_open.value
91
93
  case FilterBy.RESOLVED:
92
94
  # We consider RESOLVED == CLOSED (on Seer UI)
93
95
  and_stms["payoutReported"] = True
@@ -154,6 +156,7 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
154
156
  filter_by: FilterBy,
155
157
  sort_by: SortBy = SortBy.NONE,
156
158
  limit: int | None = None,
159
+ outcome_supply_gt_if_open: Wei = Wei(0),
157
160
  include_conditional_markets: bool = True,
158
161
  include_categorical_markets: bool = True,
159
162
  ) -> list[SeerMarket]:
@@ -163,6 +166,7 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
163
166
  # Binary markets on Seer contain 3 outcomes: OutcomeA, outcomeB and an Invalid option.
164
167
  where_stms = self._build_where_statements(
165
168
  filter_by=filter_by,
169
+ outcome_supply_gt_if_open=outcome_supply_gt_if_open,
166
170
  include_conditional_markets=include_conditional_markets,
167
171
  include_categorical_markets=include_categorical_markets,
168
172
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.65.0
3
+ Version: 0.65.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
@@ -23,7 +23,7 @@ prediction_market_agent_tooling/benchmark/agents.py,sha256=zC5tUM6pPTWtqSddOOSYV
23
23
  prediction_market_agent_tooling/benchmark/benchmark.py,sha256=KwMZzwise3sgmhdjw7xCgHMmjKHdHqQC-zc9untOLWg,17832
24
24
  prediction_market_agent_tooling/benchmark/utils.py,sha256=xQd7p9H08-OtN3iC4QT2i9bkUTmrXa6rxGXeg9yMhgU,2986
25
25
  prediction_market_agent_tooling/chains.py,sha256=1qQstoqXMwqwM7k-KH7MjMz8Ei-D83KZByvDbCZpAxs,116
26
- prediction_market_agent_tooling/config.py,sha256=rdpRHZyoTvRIDn7Qu6eViOjPBkR9Z0MOdEMFsQOuAIE,10822
26
+ prediction_market_agent_tooling/config.py,sha256=UyhK6u261tBLVsRwvXJm9C0wy6UrUpfAKH6xk4CSfk8,11535
27
27
  prediction_market_agent_tooling/deploy/agent.py,sha256=kxfJNfuvGJ2LFReI-PCyjGuubZKIrPEYiyphaS6eKcM,25476
28
28
  prediction_market_agent_tooling/deploy/agent_example.py,sha256=yS1fWkHynr9MYGNOM2WsCnRWLPaffY4bOc6bIudrdd4,1377
29
29
  prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=YYayGjTKW02d3BUavJ8M3NmFk41oldEM3FHbwppZGRM,17184
@@ -36,7 +36,7 @@ prediction_market_agent_tooling/gtypes.py,sha256=bUIZfZIGvIi3aiZNu5rVE9kRevw8sfM
36
36
  prediction_market_agent_tooling/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  prediction_market_agent_tooling/jobs/jobs_models.py,sha256=DoZ9dlvVhpNrnINiR1uy6YUOsuzI_L-avBt362y5xXM,2467
38
38
  prediction_market_agent_tooling/jobs/omen/omen_jobs.py,sha256=qbTZ9HVvu_iP4dDxuvOZxAp6JsRKejvEW2YDYCnRmd4,5039
39
- prediction_market_agent_tooling/loggers.py,sha256=hF_n-E5iMSqh3dY5G6LkQRHyReMYGPNTLu82dDFh1PU,5187
39
+ prediction_market_agent_tooling/loggers.py,sha256=kFZ1BrI8hvWgZO1vzptFnYiOEDx9Ozs86DA9yF3bSgY,5212
40
40
  prediction_market_agent_tooling/logprobs_parser.py,sha256=Du1Yc-fAVSixQX_Zx6KWpgSzI_ZYhv5tS1b8IcOPPr8,4979
41
41
  prediction_market_agent_tooling/markets/agent_market.py,sha256=smKuMaP1zyTtw31Robbj3ospF03xptWX0EDKPJbHH9I,19070
42
42
  prediction_market_agent_tooling/markets/base_subgraph_handler.py,sha256=7RaYO_4qAmQ6ZGM8oPK2-CkiJfKmV9MxM-rJlduaecU,1971
@@ -67,10 +67,10 @@ prediction_market_agent_tooling/markets/polymarket/data_models_web.py,sha256=wCw
67
67
  prediction_market_agent_tooling/markets/polymarket/polymarket.py,sha256=meAhQ5_gwVDvlSxhGGVAvRB7B47zKLnRvZ-_13tKtwY,3433
68
68
  prediction_market_agent_tooling/markets/polymarket/utils.py,sha256=8kTeVjXPcXC6DkDvWYsZQLY7x8DS6CEp_yznSEazsNU,2037
69
69
  prediction_market_agent_tooling/markets/seer/data_models.py,sha256=G0i-fnVaK16KWDYVI6w3lvyte6Op7ca_iIC8IfrXmlM,4702
70
- prediction_market_agent_tooling/markets/seer/price_manager.py,sha256=ciplVu2BnI9D9REq9x9cVlBLlzhzZSMmNWTulfO2YRg,5787
70
+ prediction_market_agent_tooling/markets/seer/price_manager.py,sha256=4hSSDyxSj9po9-tRrdtNvJ2d9v0xXT08Ezgbk1JDE3c,6122
71
71
  prediction_market_agent_tooling/markets/seer/seer.py,sha256=5uSKUhyM_3PTguYi9yiD3-E5Famb6M_fayBX1NqebAE,20273
72
72
  prediction_market_agent_tooling/markets/seer/seer_contracts.py,sha256=kH9nPXsx6UM5er42g2f3fLvy36sY5JM2f_beXeuNgUc,3790
73
- prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=v7gOlRRsbj1xpQiz3D3TE6gbO8_Itg2xhPeTqU9DBsc,9701
73
+ prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=pJxch9_u0EdiIatQP1-UFClt8UEfMZAXBlk5wDO_ovk,9940
74
74
  prediction_market_agent_tooling/markets/seer/subgraph_data_models.py,sha256=0izxS8Mtzonfdl9UqvFVXrdj0hVzieroekXhogfZKCw,1817
75
75
  prediction_market_agent_tooling/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
76
76
  prediction_market_agent_tooling/tools/_generic_value.py,sha256=pD_PI13lpPp1gFoljHwa_Lzlp-u2pu0m-Z7LcxwDM2U,10618
@@ -116,8 +116,8 @@ prediction_market_agent_tooling/tools/tokens/usd.py,sha256=yuW8iPPtcpP4eLH2nORMD
116
116
  prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
117
117
  prediction_market_agent_tooling/tools/utils.py,sha256=Jzpck3_QwShhejhgbAhmNxPSOPQJssBQep0eVemVjZ4,7064
118
118
  prediction_market_agent_tooling/tools/web3_utils.py,sha256=zRq-eeBGWt8uUGN9G_WfjmJ0eVvO8aWE9S0Pz_Y6AOA,12342
119
- prediction_market_agent_tooling-0.65.0.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
120
- prediction_market_agent_tooling-0.65.0.dist-info/METADATA,sha256=y1MAlJYLGomNEXjCKul5qGed38uRLULoYAtzh-xFZ2E,8734
121
- prediction_market_agent_tooling-0.65.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
122
- prediction_market_agent_tooling-0.65.0.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
123
- prediction_market_agent_tooling-0.65.0.dist-info/RECORD,,
119
+ prediction_market_agent_tooling-0.65.2.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
120
+ prediction_market_agent_tooling-0.65.2.dist-info/METADATA,sha256=jBOq7XzJn2iSjWMZMgdo0kdt-KZ26z6KP2pKb3EqtaY,8734
121
+ prediction_market_agent_tooling-0.65.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
122
+ prediction_market_agent_tooling-0.65.2.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
123
+ prediction_market_agent_tooling-0.65.2.dist-info/RECORD,,