prediction-market-agent-tooling 0.48.8__py3-none-any.whl → 0.48.10__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 +35 -5
- prediction_market_agent_tooling/markets/omen/omen.py +7 -1
- prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +46 -8
- {prediction_market_agent_tooling-0.48.8.dist-info → prediction_market_agent_tooling-0.48.10.dist-info}/METADATA +1 -1
- {prediction_market_agent_tooling-0.48.8.dist-info → prediction_market_agent_tooling-0.48.10.dist-info}/RECORD +8 -8
- {prediction_market_agent_tooling-0.48.8.dist-info → prediction_market_agent_tooling-0.48.10.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.48.8.dist-info → prediction_market_agent_tooling-0.48.10.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.48.8.dist-info → prediction_market_agent_tooling-0.48.10.dist-info}/entry_points.txt +0 -0
@@ -100,6 +100,10 @@ def initialize_langfuse(enable_langfuse: bool) -> None:
|
|
100
100
|
Decision = Annotated[bool, BeforeValidator(to_boolean_outcome)]
|
101
101
|
|
102
102
|
|
103
|
+
class CantPayForGasError(ValueError):
|
104
|
+
pass
|
105
|
+
|
106
|
+
|
103
107
|
class OutOfFundsError(ValueError):
|
104
108
|
pass
|
105
109
|
|
@@ -337,17 +341,38 @@ class DeployableTraderAgent(DeployableAgent):
|
|
337
341
|
]
|
338
342
|
)
|
339
343
|
|
340
|
-
def check_min_required_balance_to_operate(
|
344
|
+
def check_min_required_balance_to_operate(
|
345
|
+
self,
|
346
|
+
market_type: MarketType,
|
347
|
+
check_for_gas: bool = True,
|
348
|
+
check_for_trades: bool = True,
|
349
|
+
) -> None:
|
341
350
|
api_keys = APIKeys()
|
351
|
+
if (
|
352
|
+
market_type == MarketType.OMEN
|
353
|
+
and check_for_gas
|
354
|
+
and not is_minimum_required_balance(
|
355
|
+
api_keys.public_key,
|
356
|
+
min_required_balance=xdai_type(0.001),
|
357
|
+
sum_wxdai=False,
|
358
|
+
)
|
359
|
+
):
|
360
|
+
raise CantPayForGasError(
|
361
|
+
f"{api_keys.public_key=} doesn't have enough xDai to pay for gas."
|
362
|
+
)
|
342
363
|
if self.min_required_balance_to_operate is None:
|
343
364
|
return
|
344
|
-
if
|
345
|
-
|
346
|
-
|
365
|
+
if (
|
366
|
+
market_type == MarketType.OMEN
|
367
|
+
and check_for_trades
|
368
|
+
and not is_minimum_required_balance(
|
369
|
+
api_keys.bet_from_address,
|
370
|
+
min_required_balance=self.min_required_balance_to_operate,
|
371
|
+
)
|
347
372
|
):
|
348
373
|
raise OutOfFundsError(
|
349
374
|
f"Minimum required balance {self.min_required_balance_to_operate} "
|
350
|
-
f"for agent with address {api_keys.
|
375
|
+
f"for agent with address {api_keys.bet_from_address=} is not met."
|
351
376
|
)
|
352
377
|
|
353
378
|
def have_bet_on_market_since(self, market: AgentMarket, since: timedelta) -> bool:
|
@@ -448,8 +473,13 @@ class DeployableTraderAgent(DeployableAgent):
|
|
448
473
|
"""
|
449
474
|
api_keys = APIKeys()
|
450
475
|
if market_type == MarketType.OMEN:
|
476
|
+
# First, check if we have enough xDai to pay for gas, there is no way of doing anything without it.
|
477
|
+
self.check_min_required_balance_to_operate(
|
478
|
+
market_type, check_for_trades=False
|
479
|
+
)
|
451
480
|
# Omen is specific, because the user (agent) needs to manually withdraw winnings from the market.
|
452
481
|
redeem_from_all_user_positions(api_keys)
|
482
|
+
# After redeeming, check if we have enough xDai to pay for gas and place bets.
|
453
483
|
self.check_min_required_balance_to_operate(market_type)
|
454
484
|
# Exchange wxdai back to xdai if the balance is getting low, so we can keep paying for fees.
|
455
485
|
if self.min_balance_to_keep_in_native_currency is not None:
|
@@ -1047,13 +1047,19 @@ def is_minimum_required_balance(
|
|
1047
1047
|
address: ChecksumAddress,
|
1048
1048
|
min_required_balance: xDai,
|
1049
1049
|
web3: Web3 | None = None,
|
1050
|
+
sum_xdai: bool = True,
|
1051
|
+
sum_wxdai: bool = True,
|
1050
1052
|
) -> bool:
|
1051
1053
|
"""
|
1052
1054
|
Checks if the total balance of xDai and wxDai in the wallet is above the minimum required balance.
|
1053
1055
|
"""
|
1054
1056
|
current_balances = get_balances(address, web3)
|
1055
1057
|
# xDai and wxDai have equal value and can be exchanged for almost no cost, so we can sum them up.
|
1056
|
-
total_balance =
|
1058
|
+
total_balance = 0.0
|
1059
|
+
if sum_xdai:
|
1060
|
+
total_balance += current_balances.xdai
|
1061
|
+
if sum_wxdai:
|
1062
|
+
total_balance += current_balances.wxdai
|
1057
1063
|
return total_balance >= min_required_balance
|
1058
1064
|
|
1059
1065
|
|
@@ -608,21 +608,25 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
608
608
|
)
|
609
609
|
return [b for b in bets if b.fpmm.is_resolved_with_valid_answer]
|
610
610
|
|
611
|
-
|
612
|
-
|
611
|
+
@staticmethod
|
612
|
+
def get_reality_question_filters(
|
613
613
|
user: HexAddress | None = None,
|
614
614
|
claimed: bool | None = None,
|
615
615
|
current_answer_before: datetime | None = None,
|
616
616
|
finalized_before: datetime | None = None,
|
617
617
|
finalized_after: datetime | None = None,
|
618
618
|
id_in: list[str] | None = None,
|
619
|
+
question_id: HexBytes | None = None,
|
619
620
|
question_id_in: list[HexBytes] | None = None,
|
620
|
-
) ->
|
621
|
+
) -> dict[str, t.Any]:
|
621
622
|
where_stms: dict[str, t.Any] = {}
|
622
623
|
|
623
624
|
if user is not None:
|
624
625
|
where_stms["user"] = user.lower()
|
625
626
|
|
627
|
+
if question_id is not None:
|
628
|
+
where_stms["questionId"] = question_id.hex()
|
629
|
+
|
626
630
|
if claimed is not None:
|
627
631
|
if claimed:
|
628
632
|
where_stms["historyHash"] = ZERO_BYTES.hex()
|
@@ -650,6 +654,27 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
650
654
|
if question_id_in is not None:
|
651
655
|
where_stms["questionId_in"] = [x.hex() for x in question_id_in]
|
652
656
|
|
657
|
+
return where_stms
|
658
|
+
|
659
|
+
def get_questions(
|
660
|
+
self,
|
661
|
+
user: HexAddress | None = None,
|
662
|
+
claimed: bool | None = None,
|
663
|
+
current_answer_before: datetime | None = None,
|
664
|
+
finalized_before: datetime | None = None,
|
665
|
+
finalized_after: datetime | None = None,
|
666
|
+
id_in: list[str] | None = None,
|
667
|
+
question_id_in: list[HexBytes] | None = None,
|
668
|
+
) -> list[RealityQuestion]:
|
669
|
+
where_stms: dict[str, t.Any] = self.get_reality_question_filters(
|
670
|
+
user=user,
|
671
|
+
claimed=claimed,
|
672
|
+
finalized_before=finalized_before,
|
673
|
+
finalized_after=finalized_after,
|
674
|
+
current_answer_before=current_answer_before,
|
675
|
+
id_in=id_in,
|
676
|
+
question_id_in=question_id_in,
|
677
|
+
)
|
653
678
|
questions = self.realityeth_subgraph.Query.questions(where=where_stms)
|
654
679
|
fields = self._get_fields_for_reality_questions(questions)
|
655
680
|
result = self.sg.query_json(fields)
|
@@ -669,11 +694,24 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
669
694
|
items = self._parse_items_from_json(result)
|
670
695
|
return [RealityAnswer.model_validate(i) for i in items]
|
671
696
|
|
672
|
-
def get_responses(
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
697
|
+
def get_responses(
|
698
|
+
self,
|
699
|
+
user: HexAddress | None = None,
|
700
|
+
question_id: HexBytes | None = None,
|
701
|
+
question_claimed: bool | None = None,
|
702
|
+
question_finalized_before: datetime | None = None,
|
703
|
+
) -> list[RealityResponse]:
|
704
|
+
where_stms: dict[str, t.Any] = {}
|
705
|
+
|
706
|
+
if user is not None:
|
707
|
+
where_stms["user"] = user.lower()
|
708
|
+
|
709
|
+
where_stms["question_"] = self.get_reality_question_filters(
|
710
|
+
question_id=question_id,
|
711
|
+
claimed=question_claimed,
|
712
|
+
finalized_before=question_finalized_before,
|
713
|
+
)
|
714
|
+
|
677
715
|
responses = self.realityeth_subgraph.Query.responses(where=where_stms)
|
678
716
|
fields = self._get_fields_for_responses(responses)
|
679
717
|
result = self.sg.query_json(fields)
|
@@ -15,7 +15,7 @@ prediction_market_agent_tooling/benchmark/agents.py,sha256=BwE3U11tQq0rfOJBn-Xn5
|
|
15
15
|
prediction_market_agent_tooling/benchmark/benchmark.py,sha256=xiHKzZx5GHSsDerFHMZ9j_LXAXnSaITSvv67iPe3MEU,21095
|
16
16
|
prediction_market_agent_tooling/benchmark/utils.py,sha256=D0MfUkVZllmvcU0VOurk9tcKT7JTtwwOp-63zuCBVuc,2880
|
17
17
|
prediction_market_agent_tooling/config.py,sha256=9h68Nb9O1YZabZqtOBrH1S-4U5aIdLKfVYLSKspfUeA,6008
|
18
|
-
prediction_market_agent_tooling/deploy/agent.py,sha256=
|
18
|
+
prediction_market_agent_tooling/deploy/agent.py,sha256=KsAFknAbMPVSqBSSahuZuu2cX08azZ8EZ481XwWgR_8,18746
|
19
19
|
prediction_market_agent_tooling/deploy/agent_example.py,sha256=dIIdZashExWk9tOdyDjw87AuUcGyM7jYxNChYrVK2dM,1001
|
20
20
|
prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=nJizN4d_jsw5WA8uukaKModVezAgVwoLrCOXsaBOwXo,2223
|
21
21
|
prediction_market_agent_tooling/deploy/constants.py,sha256=M5ty8URipYMGe_G-RzxRydK3AFL6CyvmqCraJUrLBnE,82
|
@@ -38,10 +38,10 @@ prediction_market_agent_tooling/markets/metaculus/data_models.py,sha256=6TBy17xn
|
|
38
38
|
prediction_market_agent_tooling/markets/metaculus/metaculus.py,sha256=uNF7LP4evvubk818g2zbX1VlnFxeUQOkNgx_e_LwaJA,3416
|
39
39
|
prediction_market_agent_tooling/markets/omen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
40
40
|
prediction_market_agent_tooling/markets/omen/data_models.py,sha256=7KXT8a_WYyXMFR8OtcPlaazeigc8eE_AvBkx2q-CNi8,16764
|
41
|
-
prediction_market_agent_tooling/markets/omen/omen.py,sha256=
|
41
|
+
prediction_market_agent_tooling/markets/omen/omen.py,sha256=0odOGRtuDjB12sXnRglUyW8IdOsuha7X6ALc2OryF3c,40156
|
42
42
|
prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=MfaWfDDfEzHYVAbeT3Dgtl8KG7XsqEpdY3m3-rsOPwo,23588
|
43
43
|
prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=Awaw1r32IBAClCktrXbYJ24RNyLDWcLb8RqAx6FGSkI,9529
|
44
|
-
prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=
|
44
|
+
prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=Zxxu3HKg8e-uUNywJSaXUjkzHHrZxq3WC0x6pILAavA,29742
|
45
45
|
prediction_market_agent_tooling/markets/polymarket/api.py,sha256=HXmA1akA0qDj0m3e-GEvWG8x75pm6BX4H7YJPQcST7I,4767
|
46
46
|
prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=9CJzakyEcsn6DQBK2nOXjOMzTZBLAmK_KqevXvW17DI,4292
|
47
47
|
prediction_market_agent_tooling/markets/polymarket/data_models_web.py,sha256=IPsFT3FX9Ge5l5zR1nBd2w-sd5ue7oR8PJSW710vFWY,12479
|
@@ -78,8 +78,8 @@ prediction_market_agent_tooling/tools/tavily_storage/tavily_models.py,sha256=dr-
|
|
78
78
|
prediction_market_agent_tooling/tools/tavily_storage/tavily_storage.py,sha256=eln3BygdfsDf8WOlSQPL7qH946QnGnThRkazRZKBA8o,3194
|
79
79
|
prediction_market_agent_tooling/tools/utils.py,sha256=JE9YWtPPhnTgLiOyGAZDNG5K8nCwUY9IZEuAlm9UcxA,6611
|
80
80
|
prediction_market_agent_tooling/tools/web3_utils.py,sha256=euq_MH-LhTowACq42colks2IXxZQjqjuisYl91EYZtU,10440
|
81
|
-
prediction_market_agent_tooling-0.48.
|
82
|
-
prediction_market_agent_tooling-0.48.
|
83
|
-
prediction_market_agent_tooling-0.48.
|
84
|
-
prediction_market_agent_tooling-0.48.
|
85
|
-
prediction_market_agent_tooling-0.48.
|
81
|
+
prediction_market_agent_tooling-0.48.10.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
82
|
+
prediction_market_agent_tooling-0.48.10.dist-info/METADATA,sha256=KCZBnatFqFzYv_MNiRcnAomqicUKMhxjlEaf5gCdKjc,7811
|
83
|
+
prediction_market_agent_tooling-0.48.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
84
|
+
prediction_market_agent_tooling-0.48.10.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
85
|
+
prediction_market_agent_tooling-0.48.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|