prediction-market-agent-tooling 0.60.0.dev411__py3-none-any.whl → 0.60.0.dev418__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.
@@ -408,7 +408,7 @@ class OmenAgentMarket(AgentMarket):
408
408
 
409
409
  @staticmethod
410
410
  def get_trade_balance(api_keys: APIKeys, web3: Web3 | None = None) -> xDai:
411
- native_token_balance = get_balances(api_keys.public_key, web3=web3).xdai
411
+ native_token_balance = get_balances(api_keys.bet_from_address, web3=web3).xdai
412
412
  return xdai_type(
413
413
  wei_to_xdai(
414
414
  KEEPING_ERC20_TOKEN.balanceOf(api_keys.bet_from_address, web3=web3)
@@ -26,7 +26,11 @@ from prediction_market_agent_tooling.markets.omen.omen_subgraph_handler import (
26
26
  OmenSubgraphHandler,
27
27
  )
28
28
  from prediction_market_agent_tooling.tools.utils import utcnow
29
- from prediction_market_agent_tooling.tools.web3_utils import ZERO_BYTES, xdai_to_wei
29
+ from prediction_market_agent_tooling.tools.web3_utils import (
30
+ ZERO_BYTES,
31
+ wei_to_xdai,
32
+ xdai_to_wei,
33
+ )
30
34
 
31
35
 
32
36
  def claim_bonds_on_realitio_questions(
@@ -116,7 +120,9 @@ def claim_bonds_on_realitio_question(
116
120
  current_balance = realitio_contract.balanceOf(public_key, web3=web3)
117
121
  # Keeping balance on Realitio is not useful, so it's recommended to just withdraw it.
118
122
  if current_balance > 0 and auto_withdraw:
119
- logger.info(f"Withdrawing remaining balance {current_balance=}")
123
+ logger.info(
124
+ f"Withdrawing remaining balance {wei_to_xdai(current_balance)} xDai from Realitio."
125
+ )
120
126
  realitio_contract.withdraw(api_keys, web3=web3)
121
127
 
122
128
 
@@ -46,10 +46,12 @@ from prediction_market_agent_tooling.tools.web3_utils import (
46
46
  byte32_to_ipfscidv0,
47
47
  )
48
48
 
49
- # TODO: Agents don't know how to convert value between other tokens, we assume 1 unit = 1xDai = $1 (for example if market would be in wETH, betting 1 unit of wETH would be crazy :D)
50
- SAFE_COLLATERAL_TOKEN_MARKETS = (
51
- WrappedxDaiContract().address,
52
- sDaiContract().address,
49
+ SAFE_COLLATERAL_TOKENS = (
50
+ WrappedxDaiContract(),
51
+ sDaiContract(),
52
+ )
53
+ SAFE_COLLATERAL_TOKENS_ADDRESSES = tuple(
54
+ contract.address for contract in SAFE_COLLATERAL_TOKENS
53
55
  )
54
56
 
55
57
 
@@ -326,7 +328,7 @@ class OmenSubgraphHandler(BaseSubgraphHandler):
326
328
  excluded_questions: set[str] | None = None, # question titles
327
329
  collateral_token_address_in: (
328
330
  tuple[ChecksumAddress, ...] | None
329
- ) = SAFE_COLLATERAL_TOKEN_MARKETS,
331
+ ) = SAFE_COLLATERAL_TOKENS_ADDRESSES,
330
332
  category: str | None = None,
331
333
  creator_in: t.Sequence[HexAddress] | None = None,
332
334
  ) -> t.List[OmenMarket]:
@@ -392,7 +394,7 @@ class OmenSubgraphHandler(BaseSubgraphHandler):
392
394
  outcomes: list[str] = OMEN_BINARY_MARKET_OUTCOMES,
393
395
  collateral_token_address_in: (
394
396
  tuple[ChecksumAddress, ...] | None
395
- ) = SAFE_COLLATERAL_TOKEN_MARKETS,
397
+ ) = SAFE_COLLATERAL_TOKENS_ADDRESSES,
396
398
  category: str | None = None,
397
399
  ) -> t.List[OmenMarket]:
398
400
  """
@@ -14,6 +14,7 @@ from typing import (
14
14
  overload,
15
15
  )
16
16
 
17
+ import psycopg2
17
18
  from pydantic import BaseModel
18
19
  from sqlalchemy import Column
19
20
  from sqlalchemy.dialects.postgresql import JSONB
@@ -200,12 +201,22 @@ def db_cache(
200
201
  result=computed_result,
201
202
  created_at=utcnow(),
202
203
  )
203
- with DBManager(
204
- api_keys.sqlalchemy_db_url.get_secret_value()
205
- ).get_session() as session:
206
- logger.info(f"Saving {cache_entry} into database.")
207
- session.add(cache_entry)
208
- session.commit()
204
+ # Do not raise an exception if saving to the database fails, just log it and let the agent continue the work.
205
+ try:
206
+ with DBManager(
207
+ api_keys.sqlalchemy_db_url.get_secret_value()
208
+ ).get_session() as session:
209
+ logger.info(f"Saving {cache_entry} into database.")
210
+ session.add(cache_entry)
211
+ session.commit()
212
+ except psycopg2.errors.UntranslatableCharacter as e:
213
+ logger.warning(
214
+ f"Failed to save {cache_entry} into database, ignoring, because: {e}"
215
+ )
216
+ except Exception:
217
+ logger.exception(
218
+ f"Failed to save {cache_entry} into database, ignoring."
219
+ )
209
220
 
210
221
  return computed_result
211
222
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.60.0.dev411
3
+ Version: 0.60.0.dev418
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.13
@@ -51,11 +51,11 @@ prediction_market_agent_tooling/markets/metaculus/data_models.py,sha256=FaBCTPPe
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
53
  prediction_market_agent_tooling/markets/omen/data_models.py,sha256=sfaOpNk6oFIzxYQzs9EehqAT_19IxYJy9pns-UTepOc,28934
54
- prediction_market_agent_tooling/markets/omen/omen.py,sha256=WImTOfqfLsWEJHWxwWiBjor4jcHvafTmclhgeAcuZrg,51617
54
+ prediction_market_agent_tooling/markets/omen/omen.py,sha256=nJGjVHKKWvrVtTRwLLdpZoOIpk9vuEtypl238nazO9c,51623
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=E1BVDvQd1qYtCxmfC94kJtGkmQqpGPHL3zTkcs5wW6M,9697
58
- prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=mZ0CgKfHj0gLFq9plNpBhNqMuclb8V3qNagWfLYcpUc,38806
57
+ prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=dMxnPK2DF3aL4oZkBkbxwTcU7EMmi1vnTm0oC5d91yY,9781
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
61
61
  prediction_market_agent_tooling/markets/polymarket/data_models_web.py,sha256=VZhVccTApygSKMmy6Au2G02JCJOKJnR_oVeKlaesuSg,12548
@@ -80,7 +80,7 @@ prediction_market_agent_tooling/tools/betting_strategies/market_moving.py,sha256
80
80
  prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py,sha256=-FUSuQQgjcWSSnoFxnlAyTeilY6raJABJVM2QKkFqAY,438
81
81
  prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py,sha256=THMXwFlskvzbjnX_OiYtDSzI8XVFyULWfP2525_9UGc,429
82
82
  prediction_market_agent_tooling/tools/betting_strategies/utils.py,sha256=kpIb-ci67Vc1Yqqaa-_S4OUkbhWSIYog4_Iwp69HU_k,97
83
- prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=aafau_n_AUbLIwkyIRiTPgKB0dmM0767mSqyPDLF2A4,10576
83
+ prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=Q5E5cI5Mn65wq8N9Mv7on_lOnl9JOqzezvZc2ZbWhFo,11119
84
84
  prediction_market_agent_tooling/tools/caches/inmemory_cache.py,sha256=ZW5iI5rmjqeAebu5T7ftRnlkxiL02IC-MxCfDB80x7w,1506
85
85
  prediction_market_agent_tooling/tools/caches/serializers.py,sha256=vFDx4fsPxclXp2q0sv27j4al_M_Tj9aR2JJP-xNHQXA,2151
86
86
  prediction_market_agent_tooling/tools/contract.py,sha256=gmSuANqlfwldFG7hc4uom0q1Z-mo40qfYh5TDUKLFTs,20518
@@ -117,8 +117,8 @@ prediction_market_agent_tooling/tools/tokens/main_token.py,sha256=v5PfD2m9m92bJp
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.0.dev411.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
121
- prediction_market_agent_tooling-0.60.0.dev411.dist-info/METADATA,sha256=xWyT-Hk2XabfoQDMmGASUG2wSlZ_-PDDpa2B14CridU,8636
122
- prediction_market_agent_tooling-0.60.0.dev411.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
123
- prediction_market_agent_tooling-0.60.0.dev411.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
124
- prediction_market_agent_tooling-0.60.0.dev411.dist-info/RECORD,,
120
+ prediction_market_agent_tooling-0.60.0.dev418.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
121
+ prediction_market_agent_tooling-0.60.0.dev418.dist-info/METADATA,sha256=jQnA7q4cVvDbsuTDW4z_DpdMmeSwrdN6bRn_PFvPeR4,8636
122
+ prediction_market_agent_tooling-0.60.0.dev418.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
123
+ prediction_market_agent_tooling-0.60.0.dev418.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
124
+ prediction_market_agent_tooling-0.60.0.dev418.dist-info/RECORD,,