prediction-market-agent-tooling 0.67.1__tar.gz → 0.67.2__tar.gz

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.
Files changed (134) hide show
  1. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/PKG-INFO +2 -1
  2. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/deploy/agent.py +70 -14
  3. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/agent_market.py +9 -2
  4. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/manifold/manifold.py +2 -2
  5. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/markets.py +6 -5
  6. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/metaculus/metaculus.py +2 -2
  7. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/omen/omen.py +3 -3
  8. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/polymarket/polymarket.py +3 -3
  9. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/seer/data_models.py +5 -7
  10. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/seer/seer.py +22 -13
  11. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py +34 -9
  12. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/seer/subgraph_data_models.py +0 -4
  13. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/seer/swap_pool_handler.py +0 -10
  14. prediction_market_agent_tooling-0.67.2/prediction_market_agent_tooling/tools/rephrase.py +71 -0
  15. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/pyproject.toml +2 -1
  16. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/LICENSE +0 -0
  17. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/README.md +0 -0
  18. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/agentresultmapping.abi.json +0 -0
  19. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/debuggingcontract.abi.json +0 -0
  20. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/depositablewrapper_erc20.abi.json +0 -0
  21. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/erc20.abi.json +0 -0
  22. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/erc4626.abi.json +0 -0
  23. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/erc721.abi.json +0 -0
  24. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/gvp2_settlement.abi.json +0 -0
  25. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/omen_dxdao.abi.json +0 -0
  26. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/omen_fpmm.abi.json +0 -0
  27. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/omen_fpmm_conditionaltokens.abi.json +0 -0
  28. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/omen_fpmm_factory.abi.json +0 -0
  29. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/omen_kleros.abi.json +0 -0
  30. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/omen_oracle.abi.json +0 -0
  31. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/omen_realitio.abi.json +0 -0
  32. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json +0 -0
  33. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/ownable.abi.json +0 -0
  34. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/ownable_erc721.abi.json +0 -0
  35. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/proxy.abi.json +0 -0
  36. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/seer_gnosis_router.abi.json +0 -0
  37. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/seer_market_factory.abi.json +0 -0
  38. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/abis/swapr_router.abi.json +0 -0
  39. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/benchmark/__init__.py +0 -0
  40. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/benchmark/agents.py +0 -0
  41. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/benchmark/benchmark.py +0 -0
  42. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/benchmark/utils.py +0 -0
  43. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/chains.py +0 -0
  44. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/config.py +0 -0
  45. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/data_download/langfuse_data_downloader.py +0 -0
  46. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/deploy/agent_example.py +0 -0
  47. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/deploy/betting_strategy.py +0 -0
  48. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/deploy/constants.py +0 -0
  49. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/deploy/gcp/deploy.py +0 -0
  50. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +0 -0
  51. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/deploy/gcp/utils.py +0 -0
  52. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/deploy/trade_interval.py +0 -0
  53. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/gtypes.py +0 -0
  54. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/jobs/__init__.py +0 -0
  55. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/jobs/jobs_models.py +0 -0
  56. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/jobs/omen/omen_jobs.py +0 -0
  57. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/loggers.py +0 -0
  58. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/logprobs_parser.py +0 -0
  59. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/base_subgraph_handler.py +0 -0
  60. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/blockchain_utils.py +0 -0
  61. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/categorize.py +0 -0
  62. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/data_models.py +0 -0
  63. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/manifold/__init__.py +0 -0
  64. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/manifold/api.py +0 -0
  65. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/manifold/data_models.py +0 -0
  66. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/manifold/utils.py +0 -0
  67. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/market_fees.py +0 -0
  68. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/metaculus/api.py +0 -0
  69. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/metaculus/data_models.py +0 -0
  70. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/omen/__init__.py +0 -0
  71. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/omen/cow_contracts.py +0 -0
  72. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/omen/data_models.py +0 -0
  73. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/omen/omen_constants.py +0 -0
  74. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/omen/omen_contracts.py +0 -0
  75. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/omen/omen_resolving.py +0 -0
  76. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +0 -0
  77. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/polymarket/api.py +0 -0
  78. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/polymarket/data_models.py +0 -0
  79. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/polymarket/data_models_web.py +0 -0
  80. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/polymarket/polymarket_subgraph_handler.py +0 -0
  81. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/polymarket/utils.py +0 -0
  82. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/seer/exceptions.py +0 -0
  83. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/seer/price_manager.py +0 -0
  84. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/markets/seer/seer_contracts.py +0 -0
  85. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/py.typed +0 -0
  86. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/_generic_value.py +0 -0
  87. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/balances.py +0 -0
  88. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py +0 -0
  89. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py +0 -0
  90. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/betting_strategies/utils.py +0 -0
  91. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/caches/db_cache.py +0 -0
  92. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/caches/inmemory_cache.py +0 -0
  93. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/caches/serializers.py +0 -0
  94. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/contract.py +0 -0
  95. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/costs.py +0 -0
  96. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/cow/cow_order.py +0 -0
  97. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/cow/models.py +0 -0
  98. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/cow/semaphore.py +0 -0
  99. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/custom_exceptions.py +0 -0
  100. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/datetime_utc.py +0 -0
  101. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/db/db_manager.py +0 -0
  102. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/google_utils.py +0 -0
  103. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/hexbytes_custom.py +0 -0
  104. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/httpx_cached_client.py +0 -0
  105. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/image_gen/image_gen.py +0 -0
  106. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/image_gen/market_thumbnail_gen.py +0 -0
  107. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/ipfs/ipfs_handler.py +0 -0
  108. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/is_invalid.py +0 -0
  109. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/is_predictable.py +0 -0
  110. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/langfuse_.py +0 -0
  111. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/langfuse_client_utils.py +0 -0
  112. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/omen/reality_accuracy.py +0 -0
  113. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/omen/sell_positions.py +0 -0
  114. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/parallelism.py +0 -0
  115. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/perplexity/perplexity_client.py +0 -0
  116. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/perplexity/perplexity_models.py +0 -0
  117. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/perplexity/perplexity_search.py +0 -0
  118. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/relevant_news_analysis/data_models.py +0 -0
  119. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_analysis.py +0 -0
  120. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py +0 -0
  121. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/safe.py +0 -0
  122. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/singleton.py +0 -0
  123. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/streamlit_user_login.py +0 -0
  124. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/tavily/tavily_models.py +0 -0
  125. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/tavily/tavily_search.py +0 -0
  126. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/tokens/auto_deposit.py +0 -0
  127. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/tokens/auto_withdraw.py +0 -0
  128. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/tokens/main_token.py +0 -0
  129. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/tokens/slippage.py +0 -0
  130. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/tokens/token_utils.py +0 -0
  131. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/tokens/usd.py +0 -0
  132. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/transaction_cache.py +0 -0
  133. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/utils.py +0 -0
  134. {prediction_market_agent_tooling-0.67.1 → prediction_market_agent_tooling-0.67.2}/prediction_market_agent_tooling/tools/web3_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.67.1
3
+ Version: 0.67.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
@@ -42,6 +42,7 @@ Requires-Dist: proto-plus (>=1.0.0,<2.0.0)
42
42
  Requires-Dist: protobuf (>=5.0.0,<6.0.0)
43
43
  Requires-Dist: psycopg2-binary (>=2.9.9,<3.0.0)
44
44
  Requires-Dist: pydantic (>=2.6.1,<3.0.0)
45
+ Requires-Dist: pydantic-ai (>=0.1.9,<1.0.0)
45
46
  Requires-Dist: pydantic-settings (>=2.4.0,<3.0.0)
46
47
  Requires-Dist: pymongo (>=4.8.0,<5.0.0)
47
48
  Requires-Dist: pytest-postgresql (>=6.1.1,<7.0.0)
@@ -6,6 +6,7 @@ from enum import Enum
6
6
  from functools import cached_property
7
7
 
8
8
  from pydantic import computed_field
9
+ from pydantic_ai.exceptions import UnexpectedModelBehavior
9
10
 
10
11
  from prediction_market_agent_tooling.config import APIKeys
11
12
  from prediction_market_agent_tooling.deploy.betting_strategy import (
@@ -19,13 +20,12 @@ from prediction_market_agent_tooling.deploy.trade_interval import (
19
20
  )
20
21
  from prediction_market_agent_tooling.gtypes import USD, OutcomeToken, xDai
21
22
  from prediction_market_agent_tooling.loggers import logger
22
- from prediction_market_agent_tooling.markets.agent_market import AgentMarket, FilterBy
23
- from prediction_market_agent_tooling.markets.agent_market import (
24
- MarketType as AgentMarketType,
25
- )
26
23
  from prediction_market_agent_tooling.markets.agent_market import (
24
+ AgentMarket,
25
+ FilterBy,
27
26
  ProcessedMarket,
28
27
  ProcessedTradedMarket,
28
+ QuestionType,
29
29
  SortBy,
30
30
  )
31
31
  from prediction_market_agent_tooling.markets.data_models import (
@@ -47,6 +47,9 @@ from prediction_market_agent_tooling.tools.custom_exceptions import (
47
47
  from prediction_market_agent_tooling.tools.is_invalid import is_invalid
48
48
  from prediction_market_agent_tooling.tools.is_predictable import is_predictable_binary
49
49
  from prediction_market_agent_tooling.tools.langfuse_ import langfuse_context, observe
50
+ from prediction_market_agent_tooling.tools.rephrase import (
51
+ rephrase_question_to_unconditioned,
52
+ )
50
53
  from prediction_market_agent_tooling.tools.tokens.main_token import (
51
54
  MINIMUM_NATIVE_TOKEN_IN_EOA_FOR_FEES,
52
55
  )
@@ -196,6 +199,7 @@ class DeployablePredictionAgent(DeployableAgent):
196
199
  trade_on_markets_created_after: DatetimeUTC | None = None
197
200
  get_markets_sort_by: SortBy = SortBy.CLOSING_SOONEST
198
201
  get_markets_filter_by: FilterBy = FilterBy.OPEN
202
+ rephrase_conditioned_markets: bool = True
199
203
 
200
204
  # Agent behaviour when filtering fetched markets
201
205
  allow_invalid_questions: bool = False
@@ -205,6 +209,8 @@ class DeployablePredictionAgent(DeployableAgent):
205
209
  MINIMUM_NATIVE_TOKEN_IN_EOA_FOR_FEES
206
210
  )
207
211
 
212
+ just_warn_on_unexpected_model_behavior: bool = False
213
+
208
214
  # Only Metaculus allows to post predictions without trading (buying/selling of outcome tokens).
209
215
  supported_markets: t.Sequence[MarketType] = [MarketType.METACULUS]
210
216
 
@@ -224,6 +230,7 @@ class DeployablePredictionAgent(DeployableAgent):
224
230
  self.answer_categorical_market = observe()(self.answer_categorical_market) # type: ignore[method-assign]
225
231
  self.answer_scalar_market = observe()(self.answer_scalar_market) # type: ignore[method-assign]
226
232
  self.process_market = observe()(self.process_market) # type: ignore[method-assign]
233
+ self.rephrase_market_to_unconditioned = observe()(self.rephrase_market_to_unconditioned) # type: ignore[method-assign]
227
234
 
228
235
  def update_langfuse_trace_by_market(
229
236
  self, market_type: MarketType, market: AgentMarket
@@ -298,6 +305,34 @@ class DeployablePredictionAgent(DeployableAgent):
298
305
 
299
306
  return True
300
307
 
308
+ def rephrase_market_to_unconditioned(
309
+ self,
310
+ market_: AgentMarket,
311
+ ) -> AgentMarket:
312
+ """
313
+ If `rephrase_conditioned_markets` is set to True,
314
+ this method will be used to rephrase the question to account for the parent's market probability in the agent's decision process.
315
+ """
316
+ new = market_.model_copy(deep=True)
317
+
318
+ if new.parent is not None and new.parent.market.parent is not None:
319
+ new.parent.market = self.rephrase_market_to_unconditioned(new.parent.market)
320
+
321
+ rephrased_question = (
322
+ rephrase_question_to_unconditioned(
323
+ new.question,
324
+ new.parent.market.question,
325
+ new.parent.market.outcomes[new.parent.parent_outcome],
326
+ )
327
+ if new.parent is not None
328
+ else new.question
329
+ )
330
+
331
+ new.question = rephrased_question
332
+ new.parent = None
333
+
334
+ return new
335
+
301
336
  def answer_categorical_market(
302
337
  self, market: AgentMarket
303
338
  ) -> CategoricalProbabilisticAnswer | None:
@@ -338,13 +373,23 @@ class DeployablePredictionAgent(DeployableAgent):
338
373
  return False
339
374
 
340
375
  @property
341
- def agent_market_type(self) -> AgentMarketType:
376
+ def include_conditional_markets(self) -> bool:
377
+ # TODO: All should work in our code, except that currently CoW most of the time completely fails to swap xDai into outcome tokens of conditioned market.
378
+ # Enable after https://github.com/gnosis/prediction-market-agent-tooling/issues/748 and/or https://github.com/gnosis/prediction-market-agent-tooling/issues/759 is resolved.
379
+ return False
380
+ # `include_conditional_markets` if `rephrase_conditioned_markets` is enabled.
381
+ # We can expand this method in teh future, when we implement also more complex logic about conditional markets.
382
+ # Note that conditional market isn't a type of the market like Binary or Categorical, it means that it uses outcome tokens from parent market as a collateral token in this market.
383
+ return self.rephrase_conditioned_markets
384
+
385
+ @property
386
+ def agent_question_type(self) -> QuestionType:
342
387
  if self.fetch_scalar_markets:
343
- return AgentMarketType.SCALAR
388
+ return QuestionType.SCALAR
344
389
  elif self.fetch_categorical_markets:
345
- return AgentMarketType.CATEGORICAL
390
+ return QuestionType.CATEGORICAL
346
391
  else:
347
- return AgentMarketType.BINARY
392
+ return QuestionType.BINARY
348
393
 
349
394
  def get_markets(
350
395
  self,
@@ -355,15 +400,14 @@ class DeployablePredictionAgent(DeployableAgent):
355
400
  """
356
401
  cls = market_type.market_class
357
402
 
358
- agent_market_type = self.agent_market_type
359
-
360
403
  # Fetch the soonest closing markets to choose from
361
404
  available_markets = cls.get_markets(
362
405
  limit=self.n_markets_to_fetch,
363
406
  sort_by=self.get_markets_sort_by,
364
407
  filter_by=self.get_markets_filter_by,
365
408
  created_after=self.trade_on_markets_created_after,
366
- market_type=agent_market_type,
409
+ question_type=self.agent_question_type,
410
+ include_conditional_markets=self.include_conditional_markets,
367
411
  )
368
412
  return available_markets
369
413
 
@@ -396,6 +440,9 @@ class DeployablePredictionAgent(DeployableAgent):
396
440
 
397
441
  logger.info(f"Answering market '{market.question}'.")
398
442
 
443
+ if self.rephrase_conditioned_markets and market.parent is not None:
444
+ market = self.rephrase_market_to_unconditioned(market)
445
+
399
446
  if market.is_binary:
400
447
  try:
401
448
  binary_answer = self.answer_binary_market(market)
@@ -455,9 +502,18 @@ class DeployablePredictionAgent(DeployableAgent):
455
502
  f"Processing market {market.question=} from {market.url=} with liquidity {market.get_liquidity()}."
456
503
  )
457
504
 
458
- answer = self.build_answer(
459
- market=market, market_type=market_type, verify_market=verify_market
460
- )
505
+ try:
506
+ answer = self.build_answer(
507
+ market=market, market_type=market_type, verify_market=verify_market
508
+ )
509
+ except UnexpectedModelBehavior:
510
+ (
511
+ logger.warning
512
+ if self.just_warn_on_unexpected_model_behavior
513
+ else logger.exception
514
+ )(f"Unexpected model behaviour in {self.__class__.__name__}.")
515
+ answer = None
516
+
461
517
  if answer is not None:
462
518
  self.verify_answer_outcomes(market=market, answer=answer)
463
519
 
@@ -64,7 +64,12 @@ class FilterBy(str, Enum):
64
64
  NONE = "none"
65
65
 
66
66
 
67
- class MarketType(str, Enum):
67
+ class ParentMarket(BaseModel):
68
+ market: "AgentMarket"
69
+ parent_outcome: int
70
+
71
+
72
+ class QuestionType(str, Enum):
68
73
  ALL = "all"
69
74
  CATEGORICAL = "categorical"
70
75
  SCALAR = "scalar"
@@ -96,6 +101,8 @@ class AgentMarket(BaseModel):
96
101
  upper_bound: Wei | None = None
97
102
  lower_bound: Wei | None = None
98
103
 
104
+ parent: ParentMarket | None = None
105
+
99
106
  @field_validator("probabilities")
100
107
  def validate_probabilities(
101
108
  cls,
@@ -376,7 +383,7 @@ class AgentMarket(BaseModel):
376
383
  filter_by: FilterBy = FilterBy.OPEN,
377
384
  created_after: t.Optional[DatetimeUTC] = None,
378
385
  excluded_questions: set[str] | None = None,
379
- market_type: MarketType = MarketType.ALL,
386
+ question_type: QuestionType = QuestionType.ALL,
380
387
  include_conditional_markets: bool = False,
381
388
  ) -> t.Sequence["AgentMarket"]:
382
389
  raise NotImplementedError("Subclasses must implement this method")
@@ -12,7 +12,7 @@ from prediction_market_agent_tooling.markets.agent_market import (
12
12
  AgentMarket,
13
13
  FilterBy,
14
14
  MarketFees,
15
- MarketType,
15
+ QuestionType,
16
16
  SortBy,
17
17
  )
18
18
  from prediction_market_agent_tooling.markets.manifold.api import (
@@ -111,7 +111,7 @@ class ManifoldAgentMarket(AgentMarket):
111
111
  filter_by: FilterBy = FilterBy.OPEN,
112
112
  created_after: t.Optional[DatetimeUTC] = None,
113
113
  excluded_questions: set[str] | None = None,
114
- market_type: MarketType = MarketType.ALL,
114
+ question_type: QuestionType = QuestionType.ALL,
115
115
  include_conditional_markets: bool = False,
116
116
  ) -> t.Sequence["ManifoldAgentMarket"]:
117
117
  sort: t.Literal["newest", "close-date"] | None
@@ -3,11 +3,12 @@ from enum import Enum
3
3
 
4
4
  from prediction_market_agent_tooling.jobs.jobs_models import JobAgentMarket
5
5
  from prediction_market_agent_tooling.jobs.omen.omen_jobs import OmenJobAgentMarket
6
- from prediction_market_agent_tooling.markets.agent_market import AgentMarket, FilterBy
7
6
  from prediction_market_agent_tooling.markets.agent_market import (
8
- MarketType as AgentMarketType,
7
+ AgentMarket,
8
+ FilterBy,
9
+ QuestionType,
10
+ SortBy,
9
11
  )
10
- from prediction_market_agent_tooling.markets.agent_market import SortBy
11
12
  from prediction_market_agent_tooling.markets.manifold.manifold import (
12
13
  ManifoldAgentMarket,
13
14
  )
@@ -68,7 +69,7 @@ def get_binary_markets(
68
69
  sort_by: SortBy = SortBy.NONE,
69
70
  excluded_questions: set[str] | None = None,
70
71
  created_after: DatetimeUTC | None = None,
71
- agent_market_type: AgentMarketType = AgentMarketType.BINARY,
72
+ question_type: QuestionType = QuestionType.BINARY,
72
73
  ) -> t.Sequence[AgentMarket]:
73
74
  agent_market_class = MARKET_TYPE_TO_AGENT_MARKET[market_type]
74
75
  markets = agent_market_class.get_markets(
@@ -77,6 +78,6 @@ def get_binary_markets(
77
78
  filter_by=filter_by,
78
79
  created_after=created_after,
79
80
  excluded_questions=excluded_questions,
80
- market_type=agent_market_type,
81
+ question_type=question_type,
81
82
  )
82
83
  return markets
@@ -9,8 +9,8 @@ from prediction_market_agent_tooling.markets.agent_market import (
9
9
  AgentMarket,
10
10
  FilterBy,
11
11
  MarketFees,
12
- MarketType,
13
12
  ProcessedMarket,
13
+ QuestionType,
14
14
  SortBy,
15
15
  )
16
16
  from prediction_market_agent_tooling.markets.metaculus.api import (
@@ -73,7 +73,7 @@ class MetaculusAgentMarket(AgentMarket):
73
73
  filter_by: FilterBy = FilterBy.OPEN,
74
74
  created_after: t.Optional[DatetimeUTC] = None,
75
75
  excluded_questions: set[str] | None = None,
76
- market_type: MarketType = MarketType.ALL,
76
+ question_type: QuestionType = QuestionType.ALL,
77
77
  include_conditional_markets: bool = False,
78
78
  tournament_id: int | None = None,
79
79
  ) -> t.Sequence["MetaculusAgentMarket"]:
@@ -25,9 +25,9 @@ from prediction_market_agent_tooling.markets.agent_market import (
25
25
  AgentMarket,
26
26
  FilterBy,
27
27
  MarketFees,
28
- MarketType,
29
28
  ProcessedMarket,
30
29
  ProcessedTradedMarket,
30
+ QuestionType,
31
31
  SortBy,
32
32
  )
33
33
  from prediction_market_agent_tooling.markets.blockchain_utils import store_trades
@@ -380,10 +380,10 @@ class OmenAgentMarket(AgentMarket):
380
380
  filter_by: FilterBy = FilterBy.OPEN,
381
381
  created_after: t.Optional[DatetimeUTC] = None,
382
382
  excluded_questions: set[str] | None = None,
383
- market_type: MarketType = MarketType.ALL,
383
+ question_type: QuestionType = QuestionType.ALL,
384
384
  include_conditional_markets: bool = False,
385
385
  ) -> t.Sequence["OmenAgentMarket"]:
386
- fetch_categorical_markets = market_type == MarketType.CATEGORICAL
386
+ fetch_categorical_markets = question_type == QuestionType.CATEGORICAL
387
387
 
388
388
  return [
389
389
  OmenAgentMarket.from_data_model(m)
@@ -11,7 +11,7 @@ from prediction_market_agent_tooling.markets.agent_market import (
11
11
  AgentMarket,
12
12
  FilterBy,
13
13
  MarketFees,
14
- MarketType,
14
+ QuestionType,
15
15
  SortBy,
16
16
  )
17
17
  from prediction_market_agent_tooling.markets.data_models import Resolution
@@ -123,7 +123,7 @@ class PolymarketAgentMarket(AgentMarket):
123
123
  filter_by: FilterBy = FilterBy.OPEN,
124
124
  created_after: t.Optional[DatetimeUTC] = None,
125
125
  excluded_questions: set[str] | None = None,
126
- market_type: MarketType = MarketType.ALL,
126
+ question_type: QuestionType = QuestionType.ALL,
127
127
  include_conditional_markets: bool = False,
128
128
  ) -> t.Sequence["PolymarketAgentMarket"]:
129
129
  closed: bool | None
@@ -159,7 +159,7 @@ class PolymarketAgentMarket(AgentMarket):
159
159
  ascending=ascending,
160
160
  created_after=created_after,
161
161
  excluded_questions=excluded_questions,
162
- only_binary=market_type is not MarketType.CATEGORICAL,
162
+ only_binary=question_type is not QuestionType.CATEGORICAL,
163
163
  )
164
164
 
165
165
  condition_models = PolymarketSubgraphHandler().get_conditions(
@@ -3,7 +3,7 @@ from datetime import timedelta
3
3
  from typing import Annotated
4
4
  from urllib.parse import urljoin
5
5
 
6
- from pydantic import BaseModel, BeforeValidator, ConfigDict, Field
6
+ from pydantic import BaseModel, BeforeValidator, ConfigDict, Field, computed_field
7
7
  from web3 import Web3
8
8
  from web3.constants import ADDRESS_ZERO
9
9
 
@@ -17,9 +17,6 @@ from prediction_market_agent_tooling.gtypes import (
17
17
  Web3Wei,
18
18
  Wei,
19
19
  )
20
- from prediction_market_agent_tooling.markets.seer.subgraph_data_models import (
21
- SeerParentMarket,
22
- )
23
20
  from prediction_market_agent_tooling.tools.contract import ContractERC20OnGnosisChain
24
21
  from prediction_market_agent_tooling.tools.datetime_utc import DatetimeUTC
25
22
  from prediction_market_agent_tooling.tools.utils import utcnow
@@ -70,10 +67,10 @@ class SeerMarket(BaseModel):
70
67
  title: str = Field(alias="marketName")
71
68
  outcomes: t.Sequence[OutcomeStr]
72
69
  wrapped_tokens: list[HexAddress] = Field(alias="wrappedTokens")
73
- parent_outcome: int = Field(alias="parentOutcome")
74
- parent_market: t.Optional[SeerParentMarket] = Field(
75
- alias="parentMarket", default=None
70
+ parent_outcome: int = Field(
71
+ alias="parentOutcome", description="It comes as 0 from non-conditioned markets."
76
72
  )
73
+ parent_market: t.Optional["SeerMarket"] = Field(alias="parentMarket", default=None)
77
74
  collateral_token: HexAddress = Field(alias="collateralToken")
78
75
  condition_id: HexBytes = Field(alias="conditionId")
79
76
  opening_ts: int = Field(alias="openingTs")
@@ -139,6 +136,7 @@ class SeerMarket(BaseModel):
139
136
  def created_time(self) -> DatetimeUTC:
140
137
  return DatetimeUTC.to_datetime_utc(self.block_timestamp)
141
138
 
139
+ @computed_field # type: ignore[prop-decorator]
142
140
  @property
143
141
  def url(self) -> str:
144
142
  chain_id = RPCConfig().chain_id
@@ -25,9 +25,10 @@ from prediction_market_agent_tooling.markets.agent_market import (
25
25
  AgentMarket,
26
26
  FilterBy,
27
27
  MarketFees,
28
- MarketType,
28
+ ParentMarket,
29
29
  ProcessedMarket,
30
30
  ProcessedTradedMarket,
31
+ QuestionType,
31
32
  SortBy,
32
33
  )
33
34
  from prediction_market_agent_tooling.markets.blockchain_utils import store_trades
@@ -86,7 +87,7 @@ from prediction_market_agent_tooling.tools.tokens.usd import (
86
87
  get_token_in_usd,
87
88
  get_usd_in_token,
88
89
  )
89
- from prediction_market_agent_tooling.tools.utils import utcnow
90
+ from prediction_market_agent_tooling.tools.utils import check_not_none, utcnow
90
91
 
91
92
  # We place a larger bet amount by default than Omen so that cow presents valid quotes.
92
93
  SEER_TINY_BET_AMOUNT = USD(0.1)
@@ -374,6 +375,22 @@ class SeerAgentMarket(AgentMarket):
374
375
  probabilities=probability_map,
375
376
  upper_bound=model.upper_bound,
376
377
  lower_bound=model.lower_bound,
378
+ parent=(
379
+ ParentMarket(
380
+ market=(
381
+ check_not_none(
382
+ SeerAgentMarket.from_data_model_with_subgraph(
383
+ model.parent_market,
384
+ seer_subgraph,
385
+ False,
386
+ )
387
+ )
388
+ ),
389
+ parent_outcome=model.parent_outcome,
390
+ )
391
+ if model.parent_market
392
+ else None
393
+ ),
377
394
  )
378
395
 
379
396
  return market
@@ -385,7 +402,7 @@ class SeerAgentMarket(AgentMarket):
385
402
  filter_by: FilterBy = FilterBy.OPEN,
386
403
  created_after: t.Optional[DatetimeUTC] = None,
387
404
  excluded_questions: set[str] | None = None,
388
- market_type: MarketType = MarketType.ALL,
405
+ question_type: QuestionType = QuestionType.ALL,
389
406
  include_conditional_markets: bool = False,
390
407
  ) -> t.Sequence["SeerAgentMarket"]:
391
408
  seer_subgraph = SeerSubgraphHandler()
@@ -394,8 +411,8 @@ class SeerAgentMarket(AgentMarket):
394
411
  limit=limit,
395
412
  sort_by=sort_by,
396
413
  filter_by=filter_by,
397
- market_type=market_type,
398
- include_conditional_markets=False,
414
+ question_type=question_type,
415
+ include_conditional_markets=include_conditional_markets,
399
416
  )
400
417
 
401
418
  # We exclude the None values below because `from_data_model_with_subgraph` can return None, which
@@ -585,14 +602,6 @@ class SeerAgentMarket(AgentMarket):
585
602
  collateral_contract, amount_wei, api_keys, web3
586
603
  )
587
604
 
588
- collateral_balance = collateral_contract.balanceOf(
589
- api_keys.bet_from_address, web3=web3
590
- )
591
- if collateral_balance < amount_wei:
592
- raise ValueError(
593
- f"Balance {collateral_balance} not enough for bet size {amount}"
594
- )
595
-
596
605
  return self._swap_tokens_with_fallback(
597
606
  sell_token=collateral_contract.address,
598
607
  buy_token=outcome_token,
@@ -16,7 +16,7 @@ from prediction_market_agent_tooling.gtypes import ChecksumAddress, Wei
16
16
  from prediction_market_agent_tooling.loggers import logger
17
17
  from prediction_market_agent_tooling.markets.agent_market import (
18
18
  FilterBy,
19
- MarketType,
19
+ QuestionType,
20
20
  SortBy,
21
21
  )
22
22
  from prediction_market_agent_tooling.markets.base_subgraph_handler import (
@@ -62,7 +62,9 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
62
62
  )
63
63
  )
64
64
 
65
- def _get_fields_for_markets(self, markets_field: FieldPath) -> list[FieldPath]:
65
+ def _get_fields_for_markets(
66
+ self, markets_field: FieldPath, current_level: int = 0, max_level: int = 1
67
+ ) -> list[FieldPath]:
66
68
  fields = [
67
69
  markets_field.id,
68
70
  markets_field.factory,
@@ -76,7 +78,6 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
76
78
  markets_field.payoutNumerators,
77
79
  markets_field.hasAnswers,
78
80
  markets_field.blockTimestamp,
79
- markets_field.parentMarket.id,
80
81
  markets_field.openingTs,
81
82
  markets_field.finalizeTs,
82
83
  markets_field.wrappedTokens,
@@ -84,7 +85,25 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
84
85
  markets_field.upperBound,
85
86
  markets_field.lowerBound,
86
87
  markets_field.templateId,
88
+ # TODO: On the Subgraph, `questions` field is a kind of sub-query, instead of a classic list of values.
89
+ # See how it is shown on their UI: https://thegraph.com/explorer/subgraphs/B4vyRqJaSHD8dRDb3BFRoAzuBK18c1QQcXq94JbxDxWH?view=Query&chain=arbitrum-one.
90
+ # And that doesn't work with subgrounds.
91
+ # markets_field.questions.question.id,
92
+ # markets_field.questions.question.finalize_ts,
93
+ # markets_field.questions.question.best_answer,
87
94
  ]
95
+ if current_level < max_level:
96
+ fields.extend(
97
+ self._get_fields_for_markets(
98
+ markets_field.parentMarket, current_level + 1, max_level
99
+ )
100
+ )
101
+ # TODO: Same situation as with `questions` field above.
102
+ # fields.extend(
103
+ # self._get_fields_for_markets(
104
+ # markets_field.childMarkets, current_level + 1, max_level
105
+ # )
106
+ # )
88
107
  return fields
89
108
 
90
109
  @staticmethod
@@ -114,7 +133,8 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
114
133
  filter_by: FilterBy,
115
134
  outcome_supply_gt_if_open: Wei,
116
135
  include_conditional_markets: bool = False,
117
- market_type: MarketType = MarketType.ALL,
136
+ question_type: QuestionType = QuestionType.ALL,
137
+ parent_market_id: HexBytes | None = None,
118
138
  ) -> dict[Any, Any]:
119
139
  now = to_int_timestamp(utcnow())
120
140
 
@@ -136,9 +156,12 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
136
156
  if not include_conditional_markets:
137
157
  and_stms["parentMarket"] = ADDRESS_ZERO.lower()
138
158
 
159
+ if parent_market_id:
160
+ and_stms["parentMarket"] = parent_market_id.hex().lower()
161
+
139
162
  outcome_filters: list[dict[str, t.Any]] = []
140
163
 
141
- if market_type == MarketType.SCALAR:
164
+ if question_type == QuestionType.SCALAR:
142
165
  # Template ID "1" + UP/DOWN outcomes for scalar markets
143
166
  and_stms["templateId"] = TemplateId.SCALAR.value
144
167
  up_filter = SeerSubgraphHandler._create_case_variations_condition(
@@ -149,7 +172,7 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
149
172
  )
150
173
  outcome_filters.extend([up_filter, down_filter])
151
174
 
152
- elif market_type == MarketType.BINARY:
175
+ elif question_type == QuestionType.BINARY:
153
176
  # Template ID "2" + YES/NO outcomes for binary markets
154
177
  and_stms["templateId"] = TemplateId.CATEGORICAL.value
155
178
  yes_filter = SeerSubgraphHandler._create_case_variations_condition(
@@ -160,7 +183,7 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
160
183
  )
161
184
  outcome_filters.extend([yes_filter, no_filter])
162
185
 
163
- elif market_type == MarketType.CATEGORICAL:
186
+ elif question_type == QuestionType.CATEGORICAL:
164
187
  # Template ID 2 (categorical) OR Template ID 3 (multi-categorical,
165
188
  # we treat them as categorical for now for simplicity)
166
189
  # https://reality.eth.limo/app/docs/html/contracts.html#templates
@@ -211,16 +234,18 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
211
234
  sort_by: SortBy = SortBy.NONE,
212
235
  limit: int | None = None,
213
236
  outcome_supply_gt_if_open: Wei = Wei(0),
214
- market_type: MarketType = MarketType.ALL,
237
+ question_type: QuestionType = QuestionType.ALL,
215
238
  include_conditional_markets: bool = False,
239
+ parent_market_id: HexBytes | None = None,
216
240
  ) -> list[SeerMarket]:
217
241
  sort_direction, sort_by_field = self._build_sort_params(sort_by)
218
242
 
219
243
  where_stms = self._build_where_statements(
220
244
  filter_by=filter_by,
221
245
  outcome_supply_gt_if_open=outcome_supply_gt_if_open,
246
+ parent_market_id=parent_market_id,
247
+ question_type=question_type,
222
248
  include_conditional_markets=include_conditional_markets,
223
- market_type=market_type,
224
249
  )
225
250
 
226
251
  # These values can not be set to `None`, but they can be omitted.
@@ -58,7 +58,3 @@ class CreateCategoricalMarketsParams(BaseModel):
58
58
  ) # typed as int for later .model_dump() usage (if using Wei, other keys also exported)
59
59
  opening_time: int = Field(..., alias="openingTime")
60
60
  token_names: list[str] = Field(..., alias="tokenNames")
61
-
62
-
63
- class SeerParentMarket(BaseModel):
64
- id: HexBytes
@@ -19,7 +19,6 @@ from prediction_market_agent_tooling.markets.seer.seer_contracts import (
19
19
  from prediction_market_agent_tooling.markets.seer.seer_subgraph_handler import (
20
20
  SeerSubgraphHandler,
21
21
  )
22
- from prediction_market_agent_tooling.tools.contract import ContractERC20OnGnosisChain
23
22
 
24
23
 
25
24
  class SwapPoolHandler:
@@ -91,15 +90,6 @@ class SwapPoolHandler:
91
90
  amount_out_minimum=amount_out_minimum,
92
91
  )
93
92
 
94
- # make sure user has enough tokens to sell
95
- balance_collateral_token = ContractERC20OnGnosisChain(
96
- address=token_in
97
- ).balanceOf(self.api_keys.bet_from_address, web3=web3)
98
- if balance_collateral_token < amount_wei:
99
- raise ValueError(
100
- f"Balance {balance_collateral_token} of {token_in} insufficient for trade, required {amount_wei}"
101
- )
102
-
103
93
  tx_receipt = SwaprRouterContract().exact_input_single(
104
94
  api_keys=self.api_keys, params=p, web3=web3
105
95
  )
@@ -0,0 +1,71 @@
1
+ import tenacity
2
+
3
+ from prediction_market_agent_tooling.config import APIKeys
4
+ from prediction_market_agent_tooling.tools.caches.db_cache import db_cache
5
+ from prediction_market_agent_tooling.tools.langfuse_ import (
6
+ get_langfuse_langchain_config,
7
+ observe,
8
+ )
9
+ from prediction_market_agent_tooling.tools.utils import (
10
+ LLM_SEED,
11
+ LLM_SUPER_LOW_TEMPERATURE,
12
+ )
13
+
14
+ REPHRASE_QUESTION_PROMPT = """Given the following question of main interest: {question}
15
+
16
+ But it's conditioned on `{parent_question}` resolving to `{needed_parent_outcome}`.
17
+
18
+ Rewrite the main question to contain the parent question in the correct form.
19
+
20
+ The main question will be used as a prediction market, so it does need to be rephrased using the parent question properly. Such that the probability of the main question also accounts for the conditioned outcome.
21
+
22
+ For example:
23
+ ```
24
+ Main question: What is the probability of <X> happening before <date>?
25
+ Conditioned on: Will <Y> happen before <another-date>?
26
+ Rephrased: What is the joint probability of Y happening before <another-date> and then X happening before <date>?
27
+ ```
28
+
29
+ Output only the rephrased question.
30
+ """
31
+
32
+
33
+ @tenacity.retry(stop=tenacity.stop_after_attempt(3), wait=tenacity.wait_fixed(1))
34
+ @observe()
35
+ @db_cache
36
+ def rephrase_question_to_unconditioned(
37
+ question: str,
38
+ parent_question: str,
39
+ needed_parent_outcome: str,
40
+ engine: str = "gpt-4.1",
41
+ temperature: float = LLM_SUPER_LOW_TEMPERATURE,
42
+ seed: int = LLM_SEED,
43
+ prompt_template: str = REPHRASE_QUESTION_PROMPT,
44
+ max_tokens: int = 1024,
45
+ ) -> str:
46
+ try:
47
+ from langchain.prompts import ChatPromptTemplate
48
+ from langchain_openai import ChatOpenAI
49
+ except ImportError:
50
+ raise ImportError("langchain not installed")
51
+
52
+ llm = ChatOpenAI(
53
+ model_name=engine,
54
+ temperature=temperature,
55
+ seed=seed,
56
+ openai_api_key=APIKeys().openai_api_key,
57
+ )
58
+
59
+ prompt = ChatPromptTemplate.from_template(template=prompt_template)
60
+ messages = prompt.format_messages(
61
+ question=question,
62
+ parent_question=parent_question,
63
+ needed_parent_outcome=needed_parent_outcome,
64
+ )
65
+ completion = str(
66
+ llm.invoke(
67
+ messages, max_tokens=max_tokens, config=get_langfuse_langchain_config()
68
+ ).content
69
+ )
70
+
71
+ return completion
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "prediction-market-agent-tooling"
3
- version = "0.67.1"
3
+ version = "0.67.2"
4
4
  description = "Tools to benchmark, deploy and monitor prediction market agents."
5
5
  authors = ["Gnosis"]
6
6
  readme = "README.md"
@@ -61,6 +61,7 @@ proto-plus = "^1.0.0"
61
61
  protobuf = "^5.0.0"
62
62
  types-cachetools = "^5.5.0.20240820"
63
63
  python-json-logger = "^3.3.0"
64
+ pydantic-ai = ">=0.1.9,<1.0.0"
64
65
 
65
66
  [tool.poetry.extras]
66
67
  openai = ["openai"]