prediction-market-agent-tooling 0.65.6__py3-none-any.whl → 0.65.7__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/markets/data_models.py +21 -1
- prediction_market_agent_tooling/markets/omen/omen_resolving.py +5 -2
- prediction_market_agent_tooling/markets/seer/exceptions.py +2 -0
- prediction_market_agent_tooling/markets/seer/price_manager.py +5 -2
- prediction_market_agent_tooling/markets/seer/seer.py +28 -9
- {prediction_market_agent_tooling-0.65.6.dist-info → prediction_market_agent_tooling-0.65.7.dist-info}/METADATA +1 -1
- {prediction_market_agent_tooling-0.65.6.dist-info → prediction_market_agent_tooling-0.65.7.dist-info}/RECORD +10 -9
- {prediction_market_agent_tooling-0.65.6.dist-info → prediction_market_agent_tooling-0.65.7.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.65.6.dist-info → prediction_market_agent_tooling-0.65.7.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.65.6.dist-info → prediction_market_agent_tooling-0.65.7.dist-info}/entry_points.txt +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
from enum import Enum
|
2
|
-
from typing import Annotated
|
2
|
+
from typing import Annotated, Sequence
|
3
3
|
|
4
4
|
from pydantic import BaseModel, BeforeValidator, computed_field
|
5
5
|
|
@@ -26,6 +26,26 @@ class Resolution(BaseModel):
|
|
26
26
|
def from_answer(answer: OutcomeStr) -> "Resolution":
|
27
27
|
return Resolution(outcome=answer, invalid=False)
|
28
28
|
|
29
|
+
def find_outcome_matching_market(
|
30
|
+
self, market_outcomes: Sequence[OutcomeStr]
|
31
|
+
) -> OutcomeStr | None:
|
32
|
+
"""
|
33
|
+
Finds a matching outcome in the provided market outcomes.
|
34
|
+
|
35
|
+
Performs case-insensitive matching between this resolution's outcome
|
36
|
+
and the provided market outcomes.
|
37
|
+
|
38
|
+
"""
|
39
|
+
|
40
|
+
if not self.outcome:
|
41
|
+
return None
|
42
|
+
|
43
|
+
normalized_outcome = self.outcome.lower()
|
44
|
+
for outcome in market_outcomes:
|
45
|
+
if outcome.lower() == normalized_outcome:
|
46
|
+
return outcome
|
47
|
+
return None
|
48
|
+
|
29
49
|
|
30
50
|
class Bet(BaseModel):
|
31
51
|
id: str
|
@@ -31,7 +31,7 @@ from prediction_market_agent_tooling.markets.omen.omen_subgraph_handler import (
|
|
31
31
|
from prediction_market_agent_tooling.tools.tokens.main_token import (
|
32
32
|
MINIMUM_NATIVE_TOKEN_IN_EOA_FOR_FEES,
|
33
33
|
)
|
34
|
-
from prediction_market_agent_tooling.tools.utils import utcnow
|
34
|
+
from prediction_market_agent_tooling.tools.utils import check_not_none, utcnow
|
35
35
|
from prediction_market_agent_tooling.tools.web3_utils import ZERO_BYTES
|
36
36
|
|
37
37
|
|
@@ -223,7 +223,10 @@ def omen_submit_answer_market_tx(
|
|
223
223
|
And after the period is over, you need to resolve the market using `omen_resolve_market_tx`.
|
224
224
|
"""
|
225
225
|
realitio_contract = OmenRealitioContract()
|
226
|
-
|
226
|
+
outcome_matching_market = check_not_none(
|
227
|
+
resolution.find_outcome_matching_market(market.outcomes)
|
228
|
+
)
|
229
|
+
outcome_index = market.outcomes.index(outcome_matching_market)
|
227
230
|
realitio_contract.submit_answer(
|
228
231
|
api_keys=api_keys,
|
229
232
|
question_id=market.question.id,
|
@@ -12,6 +12,9 @@ from prediction_market_agent_tooling.gtypes import (
|
|
12
12
|
)
|
13
13
|
from prediction_market_agent_tooling.loggers import logger
|
14
14
|
from prediction_market_agent_tooling.markets.seer.data_models import SeerMarket
|
15
|
+
from prediction_market_agent_tooling.markets.seer.exceptions import (
|
16
|
+
PriceCalculationError,
|
17
|
+
)
|
15
18
|
from prediction_market_agent_tooling.markets.seer.seer_subgraph_handler import (
|
16
19
|
SeerSubgraphHandler,
|
17
20
|
)
|
@@ -128,7 +131,7 @@ class PriceManager:
|
|
128
131
|
)
|
129
132
|
# It's okay if invalid (last) outcome has price 0, but not the other outcomes.
|
130
133
|
if price is None and idx != len(self.seer_market.wrapped_tokens) - 1:
|
131
|
-
raise
|
134
|
+
raise PriceCalculationError(
|
132
135
|
f"Couldn't get price for {wrapped_token} for market {self.seer_market.url}."
|
133
136
|
)
|
134
137
|
price_data[wrapped_token] = (
|
@@ -142,7 +145,7 @@ class PriceManager:
|
|
142
145
|
sum(price_data.values(), start=CollateralToken.zero())
|
143
146
|
== CollateralToken.zero()
|
144
147
|
):
|
145
|
-
raise
|
148
|
+
raise PriceCalculationError(
|
146
149
|
f"All prices for market {self.seer_market.url} are zero. This shouldn't happen."
|
147
150
|
)
|
148
151
|
|
@@ -31,6 +31,9 @@ from prediction_market_agent_tooling.markets.seer.data_models import (
|
|
31
31
|
RedeemParams,
|
32
32
|
SeerMarket,
|
33
33
|
)
|
34
|
+
from prediction_market_agent_tooling.markets.seer.exceptions import (
|
35
|
+
PriceCalculationError,
|
36
|
+
)
|
34
37
|
from prediction_market_agent_tooling.markets.seer.price_manager import PriceManager
|
35
38
|
from prediction_market_agent_tooling.markets.seer.seer_contracts import (
|
36
39
|
GnosisRouter,
|
@@ -275,18 +278,24 @@ class SeerAgentMarket(AgentMarket):
|
|
275
278
|
|
276
279
|
@staticmethod
|
277
280
|
def from_data_model_with_subgraph(
|
278
|
-
model: SeerMarket,
|
281
|
+
model: SeerMarket,
|
282
|
+
seer_subgraph: SeerSubgraphHandler,
|
283
|
+
must_have_prices: bool,
|
279
284
|
) -> t.Optional["SeerAgentMarket"]:
|
280
|
-
|
285
|
+
price_manager = PriceManager(seer_market=model, seer_subgraph=seer_subgraph)
|
281
286
|
|
282
|
-
probability_map =
|
283
|
-
|
287
|
+
probability_map = {}
|
288
|
+
try:
|
289
|
+
probability_map = price_manager.build_probability_map()
|
290
|
+
except PriceCalculationError as e:
|
284
291
|
logger.info(
|
285
|
-
f"
|
292
|
+
f"Error when calculating probabilities for market {model.id.hex()} - {e}"
|
286
293
|
)
|
287
|
-
|
294
|
+
if must_have_prices:
|
295
|
+
# Price calculation failed, so don't return the market
|
296
|
+
return None
|
288
297
|
|
289
|
-
|
298
|
+
market = SeerAgentMarket(
|
290
299
|
id=model.id.hex(),
|
291
300
|
question=model.title,
|
292
301
|
creator=model.creator,
|
@@ -305,6 +314,8 @@ class SeerAgentMarket(AgentMarket):
|
|
305
314
|
probabilities=probability_map,
|
306
315
|
)
|
307
316
|
|
317
|
+
return market
|
318
|
+
|
308
319
|
@staticmethod
|
309
320
|
def get_markets(
|
310
321
|
limit: int,
|
@@ -324,17 +335,25 @@ class SeerAgentMarket(AgentMarket):
|
|
324
335
|
|
325
336
|
# We exclude the None values below because `from_data_model_with_subgraph` can return None, which
|
326
337
|
# represents an invalid market.
|
327
|
-
|
338
|
+
seer_agent_markets = [
|
328
339
|
market
|
329
340
|
for m in markets
|
330
341
|
if (
|
331
342
|
market := SeerAgentMarket.from_data_model_with_subgraph(
|
332
|
-
model=m,
|
343
|
+
model=m,
|
344
|
+
seer_subgraph=seer_subgraph,
|
345
|
+
must_have_prices=filter_by == FilterBy.OPEN,
|
333
346
|
)
|
334
347
|
)
|
335
348
|
is not None
|
336
349
|
]
|
337
350
|
|
351
|
+
if filter_by == FilterBy.OPEN:
|
352
|
+
# Extra manual filter for liquidity, as subgraph is sometimes unreliable.
|
353
|
+
seer_agent_markets = [m for m in seer_agent_markets if m.has_liquidity()]
|
354
|
+
|
355
|
+
return seer_agent_markets
|
356
|
+
|
338
357
|
def get_outcome_str_from_idx(self, outcome_index: int) -> OutcomeStr:
|
339
358
|
return self.outcomes[outcome_index]
|
340
359
|
|
@@ -42,7 +42,7 @@ prediction_market_agent_tooling/markets/agent_market.py,sha256=smKuMaP1zyTtw31Ro
|
|
42
42
|
prediction_market_agent_tooling/markets/base_subgraph_handler.py,sha256=7RaYO_4qAmQ6ZGM8oPK2-CkiJfKmV9MxM-rJlduaecU,1971
|
43
43
|
prediction_market_agent_tooling/markets/blockchain_utils.py,sha256=gZMwCTO-1d2ALXeY7-LP6U4kCpotJ6GMPZwN11kFOfE,2604
|
44
44
|
prediction_market_agent_tooling/markets/categorize.py,sha256=orLZlPaHgeREU66m1amxfWikeV77idV4sZDPB8NgSD0,1300
|
45
|
-
prediction_market_agent_tooling/markets/data_models.py,sha256=
|
45
|
+
prediction_market_agent_tooling/markets/data_models.py,sha256=seifqxjVpzZdVKJQ7a5sKPPUM749EHV80SdI6pVQ3b4,7542
|
46
46
|
prediction_market_agent_tooling/markets/manifold/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
47
47
|
prediction_market_agent_tooling/markets/manifold/api.py,sha256=tWnjuqvU8pcCuja2B_ynHeds1iiEFc6QWHjeSO_GSxY,7676
|
48
48
|
prediction_market_agent_tooling/markets/manifold/data_models.py,sha256=QzRfR2g_3vzCw4azj_lOSKSFAZczjAWlM0lQy2dZry8,6704
|
@@ -59,7 +59,7 @@ prediction_market_agent_tooling/markets/omen/data_models.py,sha256=0jCxgUEVpaggt
|
|
59
59
|
prediction_market_agent_tooling/markets/omen/omen.py,sha256=jyoAV-E_Qcbqqs4oi7junE3rHTG3kaYLMtIVzEkNC6M,49981
|
60
60
|
prediction_market_agent_tooling/markets/omen/omen_constants.py,sha256=D9oflYKafLQiHYtB5sScMHqmXyzM8JP8J0yATmc4SQQ,233
|
61
61
|
prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=f0dKbdVM2OUTSpkCSZdPtKqeckS2c48j3rjnK8oD3wE,29716
|
62
|
-
prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=
|
62
|
+
prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=h4iK7r57D0EaJqfk_n7ISaJHOB93ALL-fCPI1VztXbQ,10364
|
63
63
|
prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=149T_tJxK2GFnGCulOlGr2Mwiaa7sa74E4lqYsuCv68,39962
|
64
64
|
prediction_market_agent_tooling/markets/polymarket/api.py,sha256=UZ4_TG8ceb9Y-qgsOKs8Qiv8zDt957QkT8IX2c83yqo,4800
|
65
65
|
prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=U1SXTz93FIG3GO1h5BJWSt1hPKn_YAMBeZ3k8IS-ook,4552
|
@@ -67,8 +67,9 @@ 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/
|
71
|
-
prediction_market_agent_tooling/markets/seer/
|
70
|
+
prediction_market_agent_tooling/markets/seer/exceptions.py,sha256=cEObdjluivD94tgOLzmimR7wgQEOt6SRakrYdhsRQtk,112
|
71
|
+
prediction_market_agent_tooling/markets/seer/price_manager.py,sha256=MClY2NGwOV70nZYIcmzXFy6Ogd8NBIq7telQcQ3VcU4,6243
|
72
|
+
prediction_market_agent_tooling/markets/seer/seer.py,sha256=9AsfvsCVxNvieDPqGtyjdESzFyPEzDVpTR-4P9mL9Y8,20966
|
72
73
|
prediction_market_agent_tooling/markets/seer/seer_contracts.py,sha256=kH9nPXsx6UM5er42g2f3fLvy36sY5JM2f_beXeuNgUc,3790
|
73
74
|
prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=pJxch9_u0EdiIatQP1-UFClt8UEfMZAXBlk5wDO_ovk,9940
|
74
75
|
prediction_market_agent_tooling/markets/seer/subgraph_data_models.py,sha256=0izxS8Mtzonfdl9UqvFVXrdj0hVzieroekXhogfZKCw,1817
|
@@ -119,8 +120,8 @@ prediction_market_agent_tooling/tools/tokens/usd.py,sha256=yuW8iPPtcpP4eLH2nORMD
|
|
119
120
|
prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
|
120
121
|
prediction_market_agent_tooling/tools/utils.py,sha256=Jzpck3_QwShhejhgbAhmNxPSOPQJssBQep0eVemVjZ4,7064
|
121
122
|
prediction_market_agent_tooling/tools/web3_utils.py,sha256=zRq-eeBGWt8uUGN9G_WfjmJ0eVvO8aWE9S0Pz_Y6AOA,12342
|
122
|
-
prediction_market_agent_tooling-0.65.
|
123
|
-
prediction_market_agent_tooling-0.65.
|
124
|
-
prediction_market_agent_tooling-0.65.
|
125
|
-
prediction_market_agent_tooling-0.65.
|
126
|
-
prediction_market_agent_tooling-0.65.
|
123
|
+
prediction_market_agent_tooling-0.65.7.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
124
|
+
prediction_market_agent_tooling-0.65.7.dist-info/METADATA,sha256=Swm7dO-d5M0d1OqUB21l3QZ8gsrlORPKbG_UDDnZRZo,8734
|
125
|
+
prediction_market_agent_tooling-0.65.7.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
126
|
+
prediction_market_agent_tooling-0.65.7.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
127
|
+
prediction_market_agent_tooling-0.65.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|